[gnome-settings-daemon/gnome-3-24] common: Sync with g-c-c GsdDeviceManager changes
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon/gnome-3-24] common: Sync with g-c-c GsdDeviceManager changes
- Date: Sat, 22 Jul 2017 16:55:40 +0000 (UTC)
commit e03bb70969985b72fd8215a12d7dc3a0f98d99c9
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Jul 13 18:05:45 2017 +0200
common: Sync with g-c-c GsdDeviceManager changes
plugins/common/gsd-device-manager-udev.c | 29 +++++++++++++++-
plugins/common/gsd-device-manager-x11.c | 55 +++++++++---------------------
plugins/common/gsd-device-manager-x11.h | 6 ---
plugins/common/gsd-device-manager.c | 16 +++++++++
plugins/common/gsd-device-manager.h | 11 +++---
5 files changed, 66 insertions(+), 51 deletions(-)
---
diff --git a/plugins/common/gsd-device-manager-udev.c b/plugins/common/gsd-device-manager-udev.c
index f83f433..aa93042 100644
--- a/plugins/common/gsd-device-manager-udev.c
+++ b/plugins/common/gsd-device-manager-udev.c
@@ -24,6 +24,7 @@
#include <string.h>
#include <gudev/gudev.h>
+#include <gdk/gdkwayland.h>
#include "gsd-device-manager-udev.h"
struct _GsdUdevDeviceManager
@@ -46,7 +47,8 @@ const gchar *udev_ids[] = {
"ID_INPUT_KEYBOARD",
"ID_INPUT_TOUCHPAD",
"ID_INPUT_TABLET",
- "ID_INPUT_TOUCHSCREEN"
+ "ID_INPUT_TOUCHSCREEN",
+ "ID_INPUT_TABLET_PAD",
};
static GsdDeviceType
@@ -227,6 +229,30 @@ gsd_udev_device_manager_list_devices (GsdDeviceManager *manager,
return devices;
}
+static GsdDevice *
+gsd_udev_device_manager_lookup_device (GsdDeviceManager *manager,
+ GdkDevice *gdk_device)
+{
+ const gchar *node_path;
+ GHashTableIter iter;
+ GsdDevice *device;
+
+ node_path = gdk_wayland_device_get_node_path (gdk_device);
+ if (!node_path)
+ return NULL;
+
+ g_hash_table_iter_init (&iter, GSD_UDEV_DEVICE_MANAGER (manager)->devices);
+
+ while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &device)) {
+ if (g_strcmp0 (node_path,
+ gsd_device_get_device_file (device)) == 0) {
+ return device;
+ }
+ }
+
+ return NULL;
+}
+
static void
gsd_udev_device_manager_class_init (GsdUdevDeviceManagerClass *klass)
{
@@ -235,4 +261,5 @@ gsd_udev_device_manager_class_init (GsdUdevDeviceManagerClass *klass)
object_class->finalize = gsd_udev_device_manager_finalize;
manager_class->list_devices = gsd_udev_device_manager_list_devices;
+ manager_class->lookup_device = gsd_udev_device_manager_lookup_device;
}
diff --git a/plugins/common/gsd-device-manager-x11.c b/plugins/common/gsd-device-manager-x11.c
index b1795df..a2704d1 100644
--- a/plugins/common/gsd-device-manager-x11.c
+++ b/plugins/common/gsd-device-manager-x11.c
@@ -21,6 +21,7 @@
#include "config.h"
+#include <string.h>
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
@@ -40,6 +41,9 @@ struct _GsdX11DeviceManagerClass
GsdDeviceManagerClass parent_class;
};
+GsdDevice * gsd_x11_device_manager_lookup_gdk_device (GsdDeviceManager *manager,
+ GdkDevice *gdk_device);
+
G_DEFINE_TYPE (GsdX11DeviceManager, gsd_x11_device_manager, GSD_TYPE_DEVICE_MANAGER)
static GsdDeviceType
@@ -51,10 +55,13 @@ device_get_device_type (GdkDevice *gdk_device)
switch (source) {
case GDK_SOURCE_MOUSE:
+ case GDK_SOURCE_TRACKPOINT:
return GSD_DEVICE_TYPE_MOUSE;
case GDK_SOURCE_PEN:
case GDK_SOURCE_ERASER:
case GDK_SOURCE_CURSOR:
+ if (strstr (gdk_device_get_name (gdk_device), "pad"))
+ return GSD_DEVICE_TYPE_TABLET | GSD_DEVICE_TYPE_PAD;
return GSD_DEVICE_TYPE_TABLET;
case GDK_SOURCE_KEYBOARD:
return GSD_DEVICE_TYPE_KEYBOARD;
@@ -62,10 +69,11 @@ device_get_device_type (GdkDevice *gdk_device)
return GSD_DEVICE_TYPE_TOUCHSCREEN;
case GDK_SOURCE_TOUCHPAD:
return GSD_DEVICE_TYPE_TOUCHPAD;
- default:
- g_warning ("Unhandled input source %d\n", source);
+ case GDK_SOURCE_TABLET_PAD:
+ return GSD_DEVICE_TYPE_TABLET | GSD_DEVICE_TYPE_PAD;
}
+ g_warning ("Unhandled input source %d\n", source);
return 0;
}
@@ -213,51 +221,20 @@ gsd_x11_device_manager_class_init (GsdX11DeviceManagerClass *klass)
GsdDeviceManagerClass *manager_class = GSD_DEVICE_MANAGER_CLASS (klass);
manager_class->list_devices = gsd_x11_device_manager_list_devices;
-}
-
-GdkDevice **
-gsd_x11_device_manager_get_gdk_devices (GsdX11DeviceManager *manager,
- GsdDevice *device,
- guint *n_gdk_devices)
-{
- const gchar *device_node;
- GPtrArray *gdk_devices;
- GdkDevice *gdk_device;
- GHashTableIter iter;
-
- if (n_gdk_devices)
- *n_gdk_devices = 0;
-
- g_return_val_if_fail (GSD_IS_X11_DEVICE_MANAGER (manager), NULL);
- g_return_val_if_fail (GSD_IS_DEVICE (device), NULL);
-
- gdk_devices = g_ptr_array_new ();
- g_hash_table_iter_init (&iter, manager->gdk_devices);
-
- while (g_hash_table_iter_next (&iter, (gpointer *) &gdk_device, (gpointer *) &device_node)) {
- if (g_strcmp0 (gsd_device_get_device_file (device), device_node) == 0)
- g_ptr_array_add (gdk_devices, gdk_device);
- }
-
- if (n_gdk_devices)
- *n_gdk_devices = gdk_devices->len;
-
- return (GdkDevice **) g_ptr_array_free (gdk_devices, FALSE);
+ manager_class->lookup_device = gsd_x11_device_manager_lookup_gdk_device;
}
GsdDevice *
-gsd_x11_device_manager_lookup_gdk_device (GsdX11DeviceManager *manager,
- GdkDevice *gdk_device)
+gsd_x11_device_manager_lookup_gdk_device (GsdDeviceManager *manager,
+ GdkDevice *gdk_device)
{
+ GsdX11DeviceManager *manager_x11 = GSD_X11_DEVICE_MANAGER (manager);
const gchar *device_node;
- g_return_val_if_fail (GSD_IS_X11_DEVICE_MANAGER (manager), NULL);
- g_return_val_if_fail (GDK_IS_DEVICE (gdk_device), NULL);
-
- device_node = g_hash_table_lookup (manager->gdk_devices, gdk_device);
+ device_node = g_hash_table_lookup (manager_x11->gdk_devices, gdk_device);
if (!device_node)
return NULL;
- return g_hash_table_lookup (manager->devices, device_node);
+ return g_hash_table_lookup (manager_x11->devices, device_node);
}
diff --git a/plugins/common/gsd-device-manager-x11.h b/plugins/common/gsd-device-manager-x11.h
index 876bf50..a5ea724 100644
--- a/plugins/common/gsd-device-manager-x11.h
+++ b/plugins/common/gsd-device-manager-x11.h
@@ -39,12 +39,6 @@ typedef struct _GsdX11DeviceManagerClass GsdX11DeviceManagerClass;
GType gsd_x11_device_manager_get_type (void) G_GNUC_CONST;
-GdkDevice ** gsd_x11_device_manager_get_gdk_devices (GsdX11DeviceManager *manager,
- GsdDevice *device,
- guint *n_gdk_devices);
-GsdDevice * gsd_x11_device_manager_lookup_gdk_device (GsdX11DeviceManager *manager,
- GdkDevice *gdk_device);
-
G_END_DECLS
#endif /* __GSD_X11_DEVICE_MANAGER_H__ */
diff --git a/plugins/common/gsd-device-manager.c b/plugins/common/gsd-device-manager.c
index 1737bf3..541f294 100644
--- a/plugins/common/gsd-device-manager.c
+++ b/plugins/common/gsd-device-manager.c
@@ -415,3 +415,19 @@ gsd_device_get_dimensions (GsdDevice *device,
return priv->width > 0 && priv->height > 0;
}
+
+GsdDevice *
+gsd_device_manager_lookup_gdk_device (GsdDeviceManager *manager,
+ GdkDevice *gdk_device)
+{
+ GsdDeviceManagerClass *klass;
+
+ g_return_val_if_fail (GSD_IS_DEVICE_MANAGER (manager), NULL);
+ g_return_val_if_fail (GDK_IS_DEVICE (gdk_device), NULL);
+
+ klass = GSD_DEVICE_MANAGER_GET_CLASS (manager);
+ if (!klass->lookup_device)
+ return NULL;
+
+ return klass->lookup_device (manager, gdk_device);
+}
diff --git a/plugins/common/gsd-device-manager.h b/plugins/common/gsd-device-manager.h
index baf46a8..1eb5c13 100644
--- a/plugins/common/gsd-device-manager.h
+++ b/plugins/common/gsd-device-manager.h
@@ -20,6 +20,7 @@
#ifndef __GSD_DEVICE_MANAGER_H__
#define __GSD_DEVICE_MANAGER_H__
+#include <gdk/gdk.h>
#include <glib-object.h>
#include <gio/gio.h>
@@ -49,7 +50,8 @@ typedef enum {
GSD_DEVICE_TYPE_KEYBOARD = 1 << 1,
GSD_DEVICE_TYPE_TOUCHPAD = 1 << 2,
GSD_DEVICE_TYPE_TABLET = 1 << 3,
- GSD_DEVICE_TYPE_TOUCHSCREEN = 1 << 4
+ GSD_DEVICE_TYPE_TOUCHSCREEN = 1 << 4,
+ GSD_DEVICE_TYPE_PAD = 1 << 5
} GsdDeviceType;
struct _GsdDevice {
@@ -78,6 +80,9 @@ struct _GsdDeviceManagerClass
GsdDevice *device);
void (* device_changed) (GsdDeviceManager *manager,
GsdDevice *device);
+
+ GsdDevice * (* lookup_device) (GsdDeviceManager *manager,
+ GdkDevice *gdk_device);
};
GType gsd_device_get_type (void) G_GNUC_CONST;
@@ -98,12 +103,8 @@ gboolean gsd_device_get_dimensions (GsdDevice *device,
guint *width,
guint *height);
-#ifdef GDK_WINDOWING_X11
-GdkDevice ** gsd_device_get_gdk_devices (GsdDevice *device,
- guint *n_gdk_devices);
GsdDevice * gsd_device_manager_lookup_gdk_device (GsdDeviceManager *manager,
GdkDevice *gdk_device);
-#endif
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]