|
|
e3f29c |
From 1d745a858470b29b44e5b0e308488a477c4526cb Mon Sep 17 00:00:00 2001
|
|
|
e3f29c |
From: Carlos Garnacho <carlosg@gnome.org>
|
|
|
e3f29c |
Date: Thu, 22 Feb 2018 17:48:17 +0100
|
|
|
e3f29c |
Subject: [PATCH 1/2] clutter/x11: Implement missing ClutterInputDevice pad
|
|
|
e3f29c |
vmethods
|
|
|
e3f29c |
|
|
|
e3f29c |
Use libwacom to be able to find out modes, groups and button roles on
|
|
|
e3f29c |
pad devices.
|
|
|
e3f29c |
|
|
|
e3f29c |
https://gitlab.gnome.org/GNOME/mutter/issues/48
|
|
|
e3f29c |
|
|
|
e3f29c |
Closes: #48
|
|
|
e3f29c |
---
|
|
|
e3f29c |
clutter/clutter/x11/clutter-device-manager-xi2.c | 11 +++
|
|
|
e3f29c |
clutter/clutter/x11/clutter-device-manager-xi2.h | 8 ++
|
|
|
e3f29c |
clutter/clutter/x11/clutter-input-device-xi2.c | 97 ++++++++++++++++++++++++
|
|
|
e3f29c |
clutter/clutter/x11/clutter-input-device-xi2.h | 10 +++
|
|
|
e3f29c |
clutter/configure.ac | 32 +++++++-
|
|
|
e3f29c |
5 files changed, 156 insertions(+), 2 deletions(-)
|
|
|
e3f29c |
|
|
|
e3f29c |
diff --git a/clutter/clutter/x11/clutter-device-manager-xi2.c b/clutter/clutter/x11/clutter-device-manager-xi2.c
|
|
|
e3f29c |
index d2610cc..dee2604 100644
|
|
|
e3f29c |
--- a/clutter/clutter/x11/clutter-device-manager-xi2.c
|
|
|
e3f29c |
+++ b/clutter/clutter/x11/clutter-device-manager-xi2.c
|
|
|
e3f29c |
@@ -495,11 +495,18 @@ create_device (ClutterDeviceManagerXI2 *manager_xi2,
|
|
|
e3f29c |
"device-node", node_path,
|
|
|
e3f29c |
"n-rings", num_rings,
|
|
|
e3f29c |
"n-strips", num_strips,
|
|
|
e3f29c |
+ "n-mode-groups", MAX (num_rings, num_strips),
|
|
|
e3f29c |
NULL);
|
|
|
e3f29c |
|
|
|
e3f29c |
translate_device_classes (backend_x11->xdpy, retval,
|
|
|
e3f29c |
info->classes,
|
|
|
e3f29c |
info->num_classes);
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+#ifdef HAVE_LIBWACOM
|
|
|
e3f29c |
+ if (source == CLUTTER_PAD_DEVICE)
|
|
|
e3f29c |
+ clutter_input_device_xi2_ensure_wacom_info (retval, manager_xi2->wacom_db);
|
|
|
e3f29c |
+#endif
|
|
|
e3f29c |
+
|
|
|
e3f29c |
g_free (vendor_id);
|
|
|
e3f29c |
g_free (product_id);
|
|
|
e3f29c |
|
|
|
e3f29c |
@@ -2063,4 +2070,8 @@ clutter_device_manager_xi2_init (ClutterDeviceManagerXI2 *self)
|
|
|
e3f29c |
(GDestroyNotify) g_object_unref);
|
|
|
e3f29c |
self->tools_by_serial = g_hash_table_new_full (NULL, NULL, NULL,
|
|
|
e3f29c |
(GDestroyNotify) g_object_unref);
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+#ifdef HAVE_LIBWACOM
|
|
|
e3f29c |
+ self->wacom_db = libwacom_database_new ();
|
|
|
e3f29c |
+#endif
|
|
|
e3f29c |
}
|
|
|
e3f29c |
diff --git a/clutter/clutter/x11/clutter-device-manager-xi2.h b/clutter/clutter/x11/clutter-device-manager-xi2.h
|
|
|
e3f29c |
index c8e66f9..be25759 100644
|
|
|
e3f29c |
--- a/clutter/clutter/x11/clutter-device-manager-xi2.h
|
|
|
e3f29c |
+++ b/clutter/clutter/x11/clutter-device-manager-xi2.h
|
|
|
e3f29c |
@@ -26,6 +26,10 @@
|
|
|
e3f29c |
|
|
|
e3f29c |
#include <clutter/clutter-device-manager.h>
|
|
|
e3f29c |
|
|
|
e3f29c |
+#ifdef HAVE_LIBWACOM
|
|
|
e3f29c |
+#include <libwacom/libwacom.h>
|
|
|
e3f29c |
+#endif
|
|
|
e3f29c |
+
|
|
|
e3f29c |
G_BEGIN_DECLS
|
|
|
e3f29c |
|
|
|
e3f29c |
#define CLUTTER_TYPE_DEVICE_MANAGER_XI2 (_clutter_device_manager_xi2_get_type ())
|
|
|
e3f29c |
@@ -51,6 +55,10 @@ struct _ClutterDeviceManagerXI2
|
|
|
e3f29c |
GList *slave_devices;
|
|
|
e3f29c |
|
|
|
e3f29c |
int opcode;
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+#ifdef HAVE_LIBWACOM
|
|
|
e3f29c |
+ WacomDeviceDatabase *wacom_db;
|
|
|
e3f29c |
+#endif
|
|
|
e3f29c |
};
|
|
|
e3f29c |
|
|
|
e3f29c |
struct _ClutterDeviceManagerXI2Class
|
|
|
e3f29c |
diff --git a/clutter/clutter/x11/clutter-input-device-xi2.c b/clutter/clutter/x11/clutter-input-device-xi2.c
|
|
|
e3f29c |
index 7fb0e05..2d9b6d2 100644
|
|
|
e3f29c |
--- a/clutter/clutter/x11/clutter-input-device-xi2.c
|
|
|
e3f29c |
+++ b/clutter/clutter/x11/clutter-input-device-xi2.c
|
|
|
e3f29c |
@@ -45,6 +45,10 @@ struct _ClutterInputDeviceXI2
|
|
|
e3f29c |
|
|
|
e3f29c |
gint device_id;
|
|
|
e3f29c |
ClutterInputDeviceTool *current_tool;
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+#ifdef HAVE_LIBWACOM
|
|
|
e3f29c |
+ WacomDevice *wacom_device;
|
|
|
e3f29c |
+#endif
|
|
|
e3f29c |
};
|
|
|
e3f29c |
|
|
|
e3f29c |
#define N_BUTTONS 5
|
|
|
e3f29c |
@@ -88,15 +92,94 @@ clutter_input_device_xi2_is_grouped (ClutterInputDevice *device,
|
|
|
e3f29c |
}
|
|
|
e3f29c |
|
|
|
e3f29c |
static void
|
|
|
e3f29c |
+clutter_input_device_xi2_finalize (GObject *object)
|
|
|
e3f29c |
+{
|
|
|
e3f29c |
+#ifdef HAVE_LIBWACOM
|
|
|
e3f29c |
+ ClutterInputDeviceXI2 *device_xi2 = CLUTTER_INPUT_DEVICE_XI2 (object);
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+ if (device_xi2->wacom_device)
|
|
|
e3f29c |
+ libwacom_destroy (device_xi2->wacom_device);
|
|
|
e3f29c |
+#endif
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+ G_OBJECT_CLASS (clutter_input_device_xi2_parent_class)->finalize (object);
|
|
|
e3f29c |
+}
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+static gint
|
|
|
e3f29c |
+clutter_input_device_xi2_get_group_n_modes (ClutterInputDevice *device,
|
|
|
e3f29c |
+ gint group)
|
|
|
e3f29c |
+{
|
|
|
e3f29c |
+#ifdef HAVE_LIBWACOM
|
|
|
e3f29c |
+ ClutterInputDeviceXI2 *device_xi2 = CLUTTER_INPUT_DEVICE_XI2 (device);
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+ if (device_xi2->wacom_device)
|
|
|
e3f29c |
+ {
|
|
|
e3f29c |
+ if (group == 0)
|
|
|
e3f29c |
+ {
|
|
|
e3f29c |
+ if (libwacom_has_ring (device_xi2->wacom_device))
|
|
|
e3f29c |
+ return libwacom_get_ring_num_modes (device_xi2->wacom_device);
|
|
|
e3f29c |
+ else if (libwacom_get_num_strips (device_xi2->wacom_device) >= 1)
|
|
|
e3f29c |
+ return libwacom_get_strips_num_modes (device_xi2->wacom_device);
|
|
|
e3f29c |
+ }
|
|
|
e3f29c |
+ else if (group == 1)
|
|
|
e3f29c |
+ {
|
|
|
e3f29c |
+ if (libwacom_has_ring2 (device_xi2->wacom_device))
|
|
|
e3f29c |
+ return libwacom_get_ring2_num_modes (device_xi2->wacom_device);
|
|
|
e3f29c |
+ else if (libwacom_get_num_strips (device_xi2->wacom_device) >= 2)
|
|
|
e3f29c |
+ return libwacom_get_strips_num_modes (device_xi2->wacom_device);
|
|
|
e3f29c |
+ }
|
|
|
e3f29c |
+ }
|
|
|
e3f29c |
+#endif
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+ return -1;
|
|
|
e3f29c |
+}
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+#ifdef HAVE_LIBWACOM
|
|
|
e3f29c |
+static int
|
|
|
e3f29c |
+clutter_input_device_xi2_get_button_group (ClutterInputDevice *device,
|
|
|
e3f29c |
+ guint button)
|
|
|
e3f29c |
+{
|
|
|
e3f29c |
+ ClutterInputDeviceXI2 *device_xi2 = CLUTTER_INPUT_DEVICE_XI2 (device);
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+ if (device_xi2->wacom_device)
|
|
|
e3f29c |
+ {
|
|
|
e3f29c |
+ if (button >= libwacom_get_num_buttons (device_xi2->wacom_device))
|
|
|
e3f29c |
+ return -1;
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+ return libwacom_get_button_led_group (device_xi2->wacom_device,
|
|
|
e3f29c |
+ 'A' + button);
|
|
|
e3f29c |
+ }
|
|
|
e3f29c |
+ else
|
|
|
e3f29c |
+ return -1;
|
|
|
e3f29c |
+}
|
|
|
e3f29c |
+#endif
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+static gboolean
|
|
|
e3f29c |
+clutter_input_device_xi2_is_mode_switch_button (ClutterInputDevice *device,
|
|
|
e3f29c |
+ guint group,
|
|
|
e3f29c |
+ guint button)
|
|
|
e3f29c |
+{
|
|
|
e3f29c |
+ int button_group = -1;
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+#ifdef HAVE_LIBWACOM
|
|
|
e3f29c |
+ button_group = clutter_input_device_xi2_get_button_group (device, button);
|
|
|
e3f29c |
+#endif
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+ return button_group == (int) group;
|
|
|
e3f29c |
+}
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+static void
|
|
|
e3f29c |
clutter_input_device_xi2_class_init (ClutterInputDeviceXI2Class *klass)
|
|
|
e3f29c |
{
|
|
|
e3f29c |
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
e3f29c |
ClutterInputDeviceClass *device_class = CLUTTER_INPUT_DEVICE_CLASS (klass);
|
|
|
e3f29c |
|
|
|
e3f29c |
gobject_class->constructed = clutter_input_device_xi2_constructed;
|
|
|
e3f29c |
+ gobject_class->finalize = clutter_input_device_xi2_finalize;
|
|
|
e3f29c |
|
|
|
e3f29c |
device_class->keycode_to_evdev = clutter_input_device_xi2_keycode_to_evdev;
|
|
|
e3f29c |
device_class->is_grouped = clutter_input_device_xi2_is_grouped;
|
|
|
e3f29c |
+ device_class->get_group_n_modes = clutter_input_device_xi2_get_group_n_modes;
|
|
|
e3f29c |
+ device_class->is_mode_switch_button = clutter_input_device_xi2_is_mode_switch_button;
|
|
|
e3f29c |
}
|
|
|
e3f29c |
|
|
|
e3f29c |
static void
|
|
|
e3f29c |
@@ -196,3 +279,17 @@ clutter_input_device_xi2_get_current_tool (ClutterInputDevice *device)
|
|
|
e3f29c |
ClutterInputDeviceXI2 *device_xi2 = CLUTTER_INPUT_DEVICE_XI2 (device);
|
|
|
e3f29c |
return device_xi2->current_tool;
|
|
|
e3f29c |
}
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+#ifdef HAVE_LIBWACOM
|
|
|
e3f29c |
+void
|
|
|
e3f29c |
+clutter_input_device_xi2_ensure_wacom_info (ClutterInputDevice *device,
|
|
|
e3f29c |
+ WacomDeviceDatabase *wacom_db)
|
|
|
e3f29c |
+{
|
|
|
e3f29c |
+ ClutterInputDeviceXI2 *device_xi2 = CLUTTER_INPUT_DEVICE_XI2 (device);
|
|
|
e3f29c |
+ const gchar *node_path;
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+ node_path = clutter_input_device_get_device_node (device);
|
|
|
e3f29c |
+ device_xi2->wacom_device = libwacom_new_from_path (wacom_db, node_path,
|
|
|
e3f29c |
+ WFALLBACK_NONE, NULL);
|
|
|
e3f29c |
+}
|
|
|
e3f29c |
+#endif
|
|
|
e3f29c |
diff --git a/clutter/clutter/x11/clutter-input-device-xi2.h b/clutter/clutter/x11/clutter-input-device-xi2.h
|
|
|
e3f29c |
index b93684f..e30fb4d 100644
|
|
|
e3f29c |
--- a/clutter/clutter/x11/clutter-input-device-xi2.h
|
|
|
e3f29c |
+++ b/clutter/clutter/x11/clutter-input-device-xi2.h
|
|
|
e3f29c |
@@ -27,6 +27,10 @@
|
|
|
e3f29c |
#include <clutter/clutter-input-device.h>
|
|
|
e3f29c |
#include <X11/extensions/XInput2.h>
|
|
|
e3f29c |
|
|
|
e3f29c |
+#ifdef HAVE_LIBWACOM
|
|
|
e3f29c |
+#include <libwacom/libwacom.h>
|
|
|
e3f29c |
+#endif
|
|
|
e3f29c |
+
|
|
|
e3f29c |
G_BEGIN_DECLS
|
|
|
e3f29c |
|
|
|
e3f29c |
#define CLUTTER_TYPE_INPUT_DEVICE_XI2 (_clutter_input_device_xi2_get_type ())
|
|
|
e3f29c |
@@ -45,6 +49,12 @@ void clutter_input_device_xi2_update_tool (ClutterInputDevice *device,
|
|
|
e3f29c |
ClutterInputDeviceTool *tool);
|
|
|
e3f29c |
ClutterInputDeviceTool * clutter_input_device_xi2_get_current_tool (ClutterInputDevice *device);
|
|
|
e3f29c |
|
|
|
e3f29c |
+#ifdef HAVE_LIBWACOM
|
|
|
e3f29c |
+void clutter_input_device_xi2_ensure_wacom_info (ClutterInputDevice *device,
|
|
|
e3f29c |
+ WacomDeviceDatabase *wacom_db);
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+#endif
|
|
|
e3f29c |
+
|
|
|
e3f29c |
G_END_DECLS
|
|
|
e3f29c |
|
|
|
e3f29c |
#endif /* __CLUTTER_INPUT_DEVICE_XI2_H__ */
|
|
|
e3f29c |
diff --git a/clutter/configure.ac b/clutter/configure.ac
|
|
|
e3f29c |
index 3c3d0c5..5474fa0 100644
|
|
|
e3f29c |
--- a/clutter/configure.ac
|
|
|
e3f29c |
+++ b/clutter/configure.ac
|
|
|
e3f29c |
@@ -121,6 +121,7 @@ m4_define([xcomposite_req_version], [0.4])
|
|
|
e3f29c |
m4_define([gdk_req_version], [3.3.18])
|
|
|
e3f29c |
m4_define([libinput_req_version], [1.4.0])
|
|
|
e3f29c |
m4_define([libudev_req_version], [136])
|
|
|
e3f29c |
+m4_define([libwacom_req_version], [0.13])
|
|
|
e3f29c |
|
|
|
e3f29c |
AC_SUBST([GLIB_REQ_VERSION], [glib_req_version])
|
|
|
e3f29c |
AC_SUBST([COGL_REQ_VERSION], [cogl_req_version])
|
|
|
e3f29c |
@@ -133,6 +134,7 @@ AC_SUBST([XCOMPOSITE_REQ_VERSION], [xcomposite_req_version])
|
|
|
e3f29c |
AC_SUBST([GDK_REQ_VERSION], [gdk_req_version])
|
|
|
e3f29c |
AC_SUBST([LIBINPUT_REQ_VERSION], [libinput_req_version])
|
|
|
e3f29c |
AC_SUBST([LIBUDEV_REQ_VERSION], [libudev_req_version])
|
|
|
e3f29c |
+AC_SUBST([LIBWACOM_REQ_VERSION], [libwacom_req_version])
|
|
|
e3f29c |
|
|
|
e3f29c |
# Checks for typedefs, structures, and compiler characteristics.
|
|
|
e3f29c |
AM_PATH_GLIB_2_0([glib_req_version],
|
|
|
e3f29c |
@@ -508,6 +510,32 @@ X11_EXTS=${X11_EXTS#* }
|
|
|
e3f29c |
|
|
|
e3f29c |
AC_CACHE_SAVE
|
|
|
e3f29c |
|
|
|
e3f29c |
+dnl === Libwacom support for X11 ===============================================
|
|
|
e3f29c |
+AC_ARG_WITH(libwacom,
|
|
|
e3f29c |
+ AC_HELP_STRING([--without-libwacom],
|
|
|
e3f29c |
+ [disable the use of libwacom for advanced tablet management]),,
|
|
|
e3f29c |
+ with_libwacom=auto)
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+have_libwacom=no
|
|
|
e3f29c |
+AC_MSG_CHECKING([libwacom])
|
|
|
e3f29c |
+if test x$with_libwacom = xno ; then
|
|
|
e3f29c |
+ AC_MSG_RESULT([disabled])
|
|
|
e3f29c |
+else
|
|
|
e3f29c |
+ if $PKG_CONFIG --exists libwacom '>=' $LIBWACOM_REQ_VERSION; then
|
|
|
e3f29c |
+ have_libwacom=yes
|
|
|
e3f29c |
+ AC_MSG_RESULT(yes)
|
|
|
e3f29c |
+ PKG_CHECK_MODULES([LIBWACOM], [libwacom])
|
|
|
e3f29c |
+ AC_SUBST(LIBWACOM_CFLAGS)
|
|
|
e3f29c |
+ AC_SUBST(LIBWACOM_LIBS)
|
|
|
e3f29c |
+ AC_DEFINE([HAVE_LIBWACOM], 1, [Building with libwacom for advanced tablet management])
|
|
|
e3f29c |
+ else
|
|
|
e3f29c |
+ AC_MSG_RESULT(no)
|
|
|
e3f29c |
+ if test x$with_libwacom = xyes ; then
|
|
|
e3f29c |
+ AC_MSG_ERROR([libwacom forced but not found])
|
|
|
e3f29c |
+ fi
|
|
|
e3f29c |
+ fi
|
|
|
e3f29c |
+fi
|
|
|
e3f29c |
+
|
|
|
e3f29c |
dnl === Enable GDK-Pixbuf in tests ============================================
|
|
|
e3f29c |
|
|
|
e3f29c |
m4_define([pixbuf_default], [yes])
|
|
|
e3f29c |
@@ -679,8 +707,8 @@ AS_IF([test "x$CLUTTER_BASE_PC_FILES_PRIVATE" = "x" && test "x$BACKEND_PC_FILES_
|
|
|
e3f29c |
AC_SUBST(CLUTTER_REQUIRES)
|
|
|
e3f29c |
AC_SUBST(CLUTTER_REQUIRES_PRIVATE)
|
|
|
e3f29c |
|
|
|
e3f29c |
-CLUTTER_CFLAGS="$FLAVOUR_CFLAGS $CLUTTER_DEPS_CFLAGS $CLUTTER_DEPS_PRIVATE_CFLAGS $GLIB_CFLAGS"
|
|
|
e3f29c |
-CLUTTER_LIBS="$FLAVOUR_LIBS $CLUTTER_DEPS_LIBS $CLUTTER_DEPS_PRIVATE_LIBS $GLIB_LIBS"
|
|
|
e3f29c |
+CLUTTER_CFLAGS="$FLAVOUR_CFLAGS $CLUTTER_DEPS_CFLAGS $CLUTTER_DEPS_PRIVATE_CFLAGS $GLIB_CFLAGS $LIBWACOM_CFLAGS"
|
|
|
e3f29c |
+CLUTTER_LIBS="$FLAVOUR_LIBS $CLUTTER_DEPS_LIBS $CLUTTER_DEPS_PRIVATE_LIBS $GLIB_LIBS $LIBWACOM_LIBS"
|
|
|
e3f29c |
AC_SUBST(CLUTTER_CFLAGS)
|
|
|
e3f29c |
AC_SUBST(CLUTTER_LIBS)
|
|
|
e3f29c |
|
|
|
e3f29c |
--
|
|
|
e3f29c |
1.8.3.1
|
|
|
e3f29c |
|
|
|
e3f29c |
|
|
|
e3f29c |
From f8fa4b8fa13fba9ed484be74fb7fc82499d46261 Mon Sep 17 00:00:00 2001
|
|
|
e3f29c |
From: Carlos Garnacho <carlosg@gnome.org>
|
|
|
e3f29c |
Date: Thu, 22 Feb 2018 17:50:42 +0100
|
|
|
e3f29c |
Subject: [PATCH 2/2] clutter/x11: Communicate proper group/mode on pad events.
|
|
|
e3f29c |
|
|
|
e3f29c |
So we can trigger actions for the right mode.
|
|
|
e3f29c |
|
|
|
e3f29c |
https://gitlab.gnome.org/GNOME/mutter/issues/48
|
|
|
e3f29c |
|
|
|
e3f29c |
Closes: #48
|
|
|
e3f29c |
---
|
|
|
e3f29c |
clutter/clutter/x11/clutter-device-manager-xi2.c | 15 +++++-
|
|
|
e3f29c |
clutter/clutter/x11/clutter-input-device-xi2.c | 61 ++++++++++++++++++++++++
|
|
|
e3f29c |
clutter/clutter/x11/clutter-input-device-xi2.h | 9 ++++
|
|
|
e3f29c |
3 files changed, 84 insertions(+), 1 deletion(-)
|
|
|
e3f29c |
|
|
|
e3f29c |
diff --git a/clutter/clutter/x11/clutter-device-manager-xi2.c b/clutter/clutter/x11/clutter-device-manager-xi2.c
|
|
|
e3f29c |
index dee2604..d269a38 100644
|
|
|
e3f29c |
--- a/clutter/clutter/x11/clutter-device-manager-xi2.c
|
|
|
e3f29c |
+++ b/clutter/clutter/x11/clutter-device-manager-xi2.c
|
|
|
e3f29c |
@@ -1133,7 +1133,7 @@ translate_pad_event (ClutterEvent *event,
|
|
|
e3f29c |
ClutterInputDevice *device)
|
|
|
e3f29c |
{
|
|
|
e3f29c |
gdouble value;
|
|
|
e3f29c |
- guint number;
|
|
|
e3f29c |
+ guint number, mode = 0;
|
|
|
e3f29c |
|
|
|
e3f29c |
if (!translate_pad_axis (device, &xev->valuators,
|
|
|
e3f29c |
&event->any.type,
|
|
|
e3f29c |
@@ -1147,15 +1147,21 @@ translate_pad_event (ClutterEvent *event,
|
|
|
e3f29c |
if (xev->evtype == XI_Motion)
|
|
|
e3f29c |
value = -1;
|
|
|
e3f29c |
|
|
|
e3f29c |
+#ifdef HAVE_LIBWACOM
|
|
|
e3f29c |
+ mode = clutter_input_device_xi2_get_pad_group_mode (device, number);
|
|
|
e3f29c |
+#endif
|
|
|
e3f29c |
+
|
|
|
e3f29c |
if (event->any.type == CLUTTER_PAD_RING)
|
|
|
e3f29c |
{
|
|
|
e3f29c |
event->pad_ring.ring_number = number;
|
|
|
e3f29c |
event->pad_ring.angle = value;
|
|
|
e3f29c |
+ event->pad_ring.mode = mode;
|
|
|
e3f29c |
}
|
|
|
e3f29c |
else
|
|
|
e3f29c |
{
|
|
|
e3f29c |
event->pad_strip.strip_number = number;
|
|
|
e3f29c |
event->pad_strip.value = value;
|
|
|
e3f29c |
+ event->pad_strip.mode = mode;
|
|
|
e3f29c |
}
|
|
|
e3f29c |
|
|
|
e3f29c |
event->any.time = xev->time;
|
|
|
e3f29c |
@@ -1382,6 +1388,13 @@ clutter_device_manager_xi2_translate_event (ClutterEventTranslator *translator,
|
|
|
e3f29c |
|
|
|
e3f29c |
/* Pad buttons are 0-indexed */
|
|
|
e3f29c |
event->pad_button.button = xev->detail - 1;
|
|
|
e3f29c |
+#ifdef HAVE_LIBWACOM
|
|
|
e3f29c |
+ clutter_input_device_xi2_update_pad_state (device,
|
|
|
e3f29c |
+ event->pad_button.button,
|
|
|
e3f29c |
+ (xi_event->evtype == XI_ButtonPress),
|
|
|
e3f29c |
+ &event->pad_button.group,
|
|
|
e3f29c |
+ &event->pad_button.mode);
|
|
|
e3f29c |
+#endif
|
|
|
e3f29c |
clutter_event_set_device (event, device);
|
|
|
e3f29c |
clutter_event_set_source_device (event, source_device);
|
|
|
e3f29c |
|
|
|
e3f29c |
diff --git a/clutter/clutter/x11/clutter-input-device-xi2.c b/clutter/clutter/x11/clutter-input-device-xi2.c
|
|
|
e3f29c |
index 2d9b6d2..f62ba85 100644
|
|
|
e3f29c |
--- a/clutter/clutter/x11/clutter-input-device-xi2.c
|
|
|
e3f29c |
+++ b/clutter/clutter/x11/clutter-input-device-xi2.c
|
|
|
e3f29c |
@@ -48,6 +48,7 @@ struct _ClutterInputDeviceXI2
|
|
|
e3f29c |
|
|
|
e3f29c |
#ifdef HAVE_LIBWACOM
|
|
|
e3f29c |
WacomDevice *wacom_device;
|
|
|
e3f29c |
+ GArray *group_modes;
|
|
|
e3f29c |
#endif
|
|
|
e3f29c |
};
|
|
|
e3f29c |
|
|
|
e3f29c |
@@ -68,6 +69,15 @@ clutter_input_device_xi2_constructed (GObject *gobject)
|
|
|
e3f29c |
|
|
|
e3f29c |
if (G_OBJECT_CLASS (clutter_input_device_xi2_parent_class)->constructed)
|
|
|
e3f29c |
G_OBJECT_CLASS (clutter_input_device_xi2_parent_class)->constructed (gobject);
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+#ifdef HAVE_LIBWACOM
|
|
|
e3f29c |
+ if (clutter_input_device_get_device_type (CLUTTER_INPUT_DEVICE (gobject)) == CLUTTER_PAD_DEVICE)
|
|
|
e3f29c |
+ {
|
|
|
e3f29c |
+ device_xi2->group_modes = g_array_new (FALSE, TRUE, sizeof (guint));
|
|
|
e3f29c |
+ g_array_set_size (device_xi2->group_modes,
|
|
|
e3f29c |
+ clutter_input_device_get_n_mode_groups (CLUTTER_INPUT_DEVICE (gobject)));
|
|
|
e3f29c |
+ }
|
|
|
e3f29c |
+#endif
|
|
|
e3f29c |
}
|
|
|
e3f29c |
|
|
|
e3f29c |
static gboolean
|
|
|
e3f29c |
@@ -99,6 +109,8 @@ clutter_input_device_xi2_finalize (GObject *object)
|
|
|
e3f29c |
|
|
|
e3f29c |
if (device_xi2->wacom_device)
|
|
|
e3f29c |
libwacom_destroy (device_xi2->wacom_device);
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+ g_array_unref (device_xi2->group_modes);
|
|
|
e3f29c |
#endif
|
|
|
e3f29c |
|
|
|
e3f29c |
G_OBJECT_CLASS (clutter_input_device_xi2_parent_class)->finalize (object);
|
|
|
e3f29c |
@@ -292,4 +304,53 @@ clutter_input_device_xi2_ensure_wacom_info (ClutterInputDevice *device,
|
|
|
e3f29c |
device_xi2->wacom_device = libwacom_new_from_path (wacom_db, node_path,
|
|
|
e3f29c |
WFALLBACK_NONE, NULL);
|
|
|
e3f29c |
}
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+guint
|
|
|
e3f29c |
+clutter_input_device_xi2_get_pad_group_mode (ClutterInputDevice *device,
|
|
|
e3f29c |
+ guint group)
|
|
|
e3f29c |
+{
|
|
|
e3f29c |
+ ClutterInputDeviceXI2 *device_xi2 = CLUTTER_INPUT_DEVICE_XI2 (device);
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+ if (group >= device_xi2->group_modes->len)
|
|
|
e3f29c |
+ return 0;
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+ return g_array_index (device_xi2->group_modes, guint, group);
|
|
|
e3f29c |
+}
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+void
|
|
|
e3f29c |
+clutter_input_device_xi2_update_pad_state (ClutterInputDevice *device,
|
|
|
e3f29c |
+ guint button,
|
|
|
e3f29c |
+ guint state,
|
|
|
e3f29c |
+ guint *group,
|
|
|
e3f29c |
+ guint *mode)
|
|
|
e3f29c |
+{
|
|
|
e3f29c |
+ ClutterInputDeviceXI2 *device_xi2 = CLUTTER_INPUT_DEVICE_XI2 (device);
|
|
|
e3f29c |
+ guint button_group, *group_mode;
|
|
|
e3f29c |
+ gboolean is_mode_switch = FALSE;
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+ button_group = clutter_input_device_xi2_get_button_group (device, button);
|
|
|
e3f29c |
+ is_mode_switch = button_group >= 0;
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+ /* Assign all non-mode-switch buttons to group 0 so far */
|
|
|
e3f29c |
+ button_group = MAX (0, button_group);
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+ if (button_group >= device_xi2->group_modes->len)
|
|
|
e3f29c |
+ return;
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+ group_mode = &g_array_index (device_xi2->group_modes, guint, button_group);
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+ if (is_mode_switch && state)
|
|
|
e3f29c |
+ {
|
|
|
e3f29c |
+ guint next, n_modes;
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+ n_modes = clutter_input_device_get_group_n_modes (device, button_group);
|
|
|
e3f29c |
+ next = (*group_mode + 1) % n_modes;
|
|
|
e3f29c |
+ *group_mode = next;
|
|
|
e3f29c |
+ }
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+ if (group)
|
|
|
e3f29c |
+ *group = button_group;
|
|
|
e3f29c |
+ if (mode)
|
|
|
e3f29c |
+ *mode = *group_mode;
|
|
|
e3f29c |
+}
|
|
|
e3f29c |
#endif
|
|
|
e3f29c |
diff --git a/clutter/clutter/x11/clutter-input-device-xi2.h b/clutter/clutter/x11/clutter-input-device-xi2.h
|
|
|
e3f29c |
index e30fb4d..2194e1b 100644
|
|
|
e3f29c |
--- a/clutter/clutter/x11/clutter-input-device-xi2.h
|
|
|
e3f29c |
+++ b/clutter/clutter/x11/clutter-input-device-xi2.h
|
|
|
e3f29c |
@@ -53,6 +53,15 @@ ClutterInputDeviceTool * clutter_input_device_xi2_get_current_tool (ClutterInput
|
|
|
e3f29c |
void clutter_input_device_xi2_ensure_wacom_info (ClutterInputDevice *device,
|
|
|
e3f29c |
WacomDeviceDatabase *wacom_db);
|
|
|
e3f29c |
|
|
|
e3f29c |
+guint clutter_input_device_xi2_get_pad_group_mode (ClutterInputDevice *device,
|
|
|
e3f29c |
+ guint group);
|
|
|
e3f29c |
+
|
|
|
e3f29c |
+void clutter_input_device_xi2_update_pad_state (ClutterInputDevice *device,
|
|
|
e3f29c |
+ guint button,
|
|
|
e3f29c |
+ guint state,
|
|
|
e3f29c |
+ guint *group,
|
|
|
e3f29c |
+ guint *mode);
|
|
|
e3f29c |
+
|
|
|
e3f29c |
#endif
|
|
|
e3f29c |
|
|
|
e3f29c |
G_END_DECLS
|
|
|
e3f29c |
--
|
|
|
e3f29c |
1.8.3.1
|
|
|
e3f29c |
|