[gnome-settings-daemon/wip/settings-relocation: 2/10] common: Add GsdDeviceManager
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon/wip/settings-relocation: 2/10] common: Add GsdDeviceManager
- Date: Thu, 18 Dec 2014 17:09:38 +0000 (UTC)
commit 9003eacfc841e0add2c1397e0b58d5696cfaaa7f
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Dec 17 13:48:52 2014 +0100
common: Add GsdDeviceManager
This is a GUdev-based object that keeps track of the plugged in input
devices. Meant to be used across g-s-d wherever some knowledge about these
must remain.
On X11, some API is still offered to access the gdk/X devices (which may not
map 1:1 with the udev devices).
For both platforms, the relevant /org/gnome/desktop/peripherals/... settings
can be accessed, in order to interoperate with the settings that mutter
applies on libinput devices.
configure.ac | 2 +-
plugins/common/Makefile.am | 2 +
plugins/common/gsd-device-manager.c | 632 +++++++++++++++++++++++++++++++++++
plugins/common/gsd-device-manager.h | 74 ++++
plugins/mouse/gsd-mouse-manager.c | 4 +-
5 files changed, 711 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 84b9266..5e28f8f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -164,7 +164,7 @@ dnl ---------------------------------------------------------------------------
dnl - common
dnl ---------------------------------------------------------------------------
-PKG_CHECK_MODULES(COMMON, x11 kbproto xi)
+PKG_CHECK_MODULES(COMMON, x11 kbproto xi $GUDEV_PKG)
dnl ---------------------------------------------------------------------------
dnl - XTest
diff --git a/plugins/common/Makefile.am b/plugins/common/Makefile.am
index fd2a7af..fc07709 100644
--- a/plugins/common/Makefile.am
+++ b/plugins/common/Makefile.am
@@ -3,6 +3,8 @@ plugin_name = common
noinst_LTLIBRARIES = libcommon.la
libcommon_la_SOURCES = \
+ gsd-device-manager.c \
+ gsd-device-manager.h \
gsd-device-mapper.c \
gsd-device-mapper.h \
gsd-keygrab.c \
diff --git a/plugins/common/gsd-device-manager.c b/plugins/common/gsd-device-manager.c
new file mode 100644
index 0000000..33dcb17
--- /dev/null
+++ b/plugins/common/gsd-device-manager.c
@@ -0,0 +1,632 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2014 Red Hat
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Author: Carlos Garnacho <carlosg gnome org>
+ */
+
+#include "config.h"
+
+#include <gdk/gdk.h>
+#include <gudev/gudev.h>
+
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h>
+#endif
+
+#include "gsd-device-manager.h"
+#include "gsd-input-helper.h"
+#include "gnome-settings-bus.h"
+
+/* Index matches GsdDeviceType */
+const gchar *udev_ids[] = {
+ "ID_INPUT_MOUSE",
+ "ID_INPUT_KEYBOARD",
+ "ID_INPUT_TOUCHPAD",
+ "ID_INPUT_TABLET",
+ "ID_INPUT_TOUCHSCREEN"
+};
+
+struct _GsdDevice
+{
+ GUdevDevice *udev_device;
+ gchar *name;
+ GsdDeviceType type;
+
+ GDestroyNotify destroy_notify;
+ gpointer data;
+
+ gint ref_count;
+};
+
+struct _GsdDeviceManager
+{
+ GObject parent_instance;
+ GUdevClient *udev_client;
+
+ GHashTable *devices;
+
+#ifdef GDK_WINDOWING_X11
+ GHashTable *gdk_devices;
+ GdkDeviceManager *device_manager;
+#endif
+};
+
+struct _GsdDeviceManagerClass
+{
+ GObjectClass parent_instance;
+
+ void (* device_added) (GsdDeviceManager *manager,
+ GUdevDevice *device);
+ void (* device_removed) (GsdDeviceManager *manager,
+ GUdevDevice *device);
+};
+
+enum {
+ DEVICE_ADDED,
+ DEVICE_REMOVED,
+ N_SIGNALS
+};
+
+static guint signals[N_SIGNALS] = { 0 };
+
+G_DEFINE_TYPE (GsdDeviceManager, gsd_device_manager, G_TYPE_OBJECT)
+
+static GsdDeviceType
+udev_device_get_device_type (GUdevDevice *device)
+{
+ GsdDeviceType type = 0;
+ gint i;
+
+ for (i = 0; i < G_N_ELEMENTS (udev_ids); i++) {
+ if (g_udev_device_get_property_as_boolean (device, udev_ids[i]))
+ type |= (1 << i);
+ }
+
+ return type;
+}
+
+static GsdDevice *
+gsd_device_new (GUdevDevice *device)
+{
+ GUdevDevice *parent;
+ GsdDevice *data;
+
+ data = g_new0 (GsdDevice, 1);
+ data->udev_device = g_object_ref (device);
+ data->type = udev_device_get_device_type (device);
+
+ parent = g_udev_device_get_parent (device);
+
+ if (parent)
+ data->name = g_strdup (g_udev_device_get_sysfs_attr (parent, "name"));
+
+ return data;
+}
+
+static void
+gsd_device_set_data (GsdDevice *device,
+ gpointer data,
+ GDestroyNotify destroy_notify)
+{
+ if (device->data && device->destroy_notify)
+ device->destroy_notify (device->data);
+
+ device->data = data;
+ device->destroy_notify = destroy_notify;
+}
+
+static GsdDevice *
+gsd_device_ref (GsdDevice *device)
+{
+ g_atomic_int_inc (&device->ref_count);
+ return device;
+}
+
+static void
+gsd_device_unref (GsdDevice *device)
+{
+ if (g_atomic_int_dec_and_test (&device->ref_count)) {
+ if (device->data && device->destroy_notify)
+ device->destroy_notify (device->data);
+
+ g_object_unref (device->udev_device);
+ g_free (device);
+ }
+}
+
+G_DEFINE_BOXED_TYPE (GsdDevice, gsd_device, gsd_device_ref, gsd_device_unref)
+
+static gboolean
+device_is_input (GUdevDevice *device)
+{
+ return (g_udev_device_get_device_file (device) &&
+ g_udev_device_get_property_as_boolean (device, "ID_INPUT"));
+}
+
+static void
+gsd_device_manager_finalize (GObject *object)
+{
+ GsdDeviceManager *manager = GSD_DEVICE_MANAGER (object);
+
+ g_object_unref (manager->udev_client);
+ g_hash_table_destroy (manager->devices);
+
+#ifdef GDK_WINDOWING_X11
+ if (manager->gdk_devices)
+ g_hash_table_destroy (manager->gdk_devices);
+#endif
+}
+
+static void
+gsd_device_manager_class_init (GsdDeviceManagerClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = gsd_device_manager_finalize;
+
+ signals[DEVICE_ADDED] =
+ g_signal_new ("device-added",
+ GSD_TYPE_DEVICE_MANAGER,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GsdDeviceManagerClass, device_added),
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 1,
+ GSD_TYPE_DEVICE | G_SIGNAL_TYPE_STATIC_SCOPE);
+
+ signals[DEVICE_REMOVED] =
+ g_signal_new ("device-removed",
+ GSD_TYPE_DEVICE_MANAGER,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GsdDeviceManagerClass, device_removed),
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 1,
+ GSD_TYPE_DEVICE | G_SIGNAL_TYPE_STATIC_SCOPE);
+}
+
+static GsdDevice *
+gsd_device_manager_add_device (GsdDeviceManager *manager,
+ GUdevDevice *device)
+{
+ const gchar *parent_sysfs_path;
+ GUdevDevice *parent;
+ GsdDevice *info;
+
+ if (!device_is_input (device))
+ return NULL;
+
+ parent = g_udev_device_get_parent (device);
+
+ if (!parent)
+ return NULL;
+
+ parent_sysfs_path = g_udev_device_get_sysfs_path (parent);
+
+ if (g_hash_table_lookup (manager->devices, parent_sysfs_path)) {
+ g_debug ("Device '%s' was added with another device file",
+ g_udev_device_get_device_file (device));
+ return NULL;
+ }
+
+ info = gsd_device_new (device);
+ g_hash_table_insert (manager->devices,
+ g_strdup (parent_sysfs_path), info);
+
+ g_signal_emit (manager, signals[DEVICE_ADDED], 0, info);
+
+ return info;
+}
+
+static void
+gsd_device_manager_remove_device (GsdDeviceManager *manager,
+ GUdevDevice *device)
+{
+ const gchar *parent_sysfs_path;
+ GUdevDevice *parent;
+ GsdDevice *info;
+
+ parent = g_udev_device_get_parent (device);
+
+ if (!parent)
+ return;
+
+ parent_sysfs_path = g_udev_device_get_sysfs_path (parent);
+ info = g_hash_table_lookup (manager->devices, parent_sysfs_path);
+
+ if (info) {
+ g_hash_table_steal (manager->devices, parent_sysfs_path);
+ g_signal_emit (manager, signals[DEVICE_REMOVED], 0, device);
+ gsd_device_unref (info);
+ }
+}
+
+#ifdef GDK_WINDOWING_X11
+static void
+gsd_device_manager_add_gdk_device (GsdDeviceManager *manager,
+ GdkDevice *gdk_device)
+{
+ GUdevDevice *udev_device, *parent;
+ const gchar *parent_sysfs_path;
+ GPtrArray *gdk_devices = NULL;
+ GsdDevice *device;
+ gchar *devnode;
+
+ if (g_hash_table_lookup (manager->gdk_devices, gdk_device))
+ return;
+
+ devnode = xdevice_get_device_node (gdk_x11_device_get_id (gdk_device));
+
+ if (!devnode)
+ return;
+
+ udev_device = g_udev_client_query_by_device_file (manager->udev_client, devnode);
+ g_free (devnode);
+
+ if (!udev_device)
+ return;
+
+ parent = g_udev_device_get_parent (udev_device);
+
+ if (!parent)
+ return;
+
+ parent_sysfs_path = g_udev_device_get_sysfs_path (parent);
+
+ g_hash_table_insert (manager->gdk_devices, gdk_device, g_strdup (parent_sysfs_path));
+
+ device = g_hash_table_lookup (manager->devices, parent_sysfs_path);
+
+ if (device) {
+ gdk_devices = (GPtrArray *) device->data;
+ } else {
+ device = gsd_device_manager_add_device (manager, udev_device);
+
+ if (!device)
+ return;
+
+ gdk_devices = g_ptr_array_new ();
+ gsd_device_set_data (device, gdk_devices,
+ (GDestroyNotify) g_ptr_array_unref);
+ }
+
+ if (gdk_devices) {
+ g_ptr_array_add (gdk_devices, gdk_device);
+ }
+}
+
+static void
+gsd_device_manager_remove_gdk_device (GsdDeviceManager *manager,
+ GdkDevice *gdk_device)
+{
+ const gchar *parent_sysfs_path;
+ GsdDevice *device;
+
+ parent_sysfs_path = g_hash_table_lookup (manager->gdk_devices, gdk_device);
+
+ if (!parent_sysfs_path)
+ return;
+
+ g_hash_table_remove (manager->gdk_devices, gdk_device);
+ device = g_hash_table_lookup (manager->devices, parent_sysfs_path);
+
+ if (!device)
+ return;
+
+ gsd_device_manager_remove_device (manager, device->udev_device);
+}
+
+static void
+device_manager_device_added_cb (GdkDeviceManager *gdk_device_manager,
+ GdkDevice *device,
+ GsdDeviceManager *manager)
+{
+ gsd_device_manager_add_gdk_device (manager, device);
+}
+
+static void
+device_manager_device_removed_cb (GdkDeviceManager *gdk_device_manager,
+ GdkDevice *device,
+ GsdDeviceManager *manager)
+{
+ gsd_device_manager_remove_gdk_device (manager, device);
+}
+
+static void
+gsd_device_manager_init_gdk (GsdDeviceManager *manager,
+ GdkDeviceType device_type)
+{
+ GList *devices, *l;
+
+ devices = gdk_device_manager_list_devices (manager->device_manager,
+ device_type);
+
+ for (l = devices; l; l = l->next)
+ gsd_device_manager_add_gdk_device (manager, l->data);
+
+ g_list_free (devices);
+}
+#endif /* GDK_WINDOWING_X11 */
+
+#ifdef HAVE_WAYLAND
+static void
+gsd_device_manager_init_udev (GsdDeviceManager *manager)
+{
+ GList *devices, *l;
+
+ devices = g_udev_client_query_by_subsystem (manager->udev_client, "input");
+
+ for (l = devices; l; l = l->next) {
+ GUdevDevice *device = l->data;
+
+ if (device_is_input (device))
+ gsd_device_manager_add_device (manager, device);
+
+ g_object_unref (device);
+ }
+
+ g_list_free (devices);
+}
+
+static void
+udev_event_cb (GUdevClient *client,
+ gchar *action,
+ GUdevDevice *device,
+ GsdDeviceManager *manager)
+{
+ if (!device_is_input (device))
+ return;
+
+ if (g_strcmp0 (action, "add") == 0) {
+ gsd_device_manager_add_device (manager, device);
+ } else if (g_strcmp0 (action, "remove") == 0) {
+ gsd_device_manager_remove_device (manager, device);
+ }
+}
+#endif /* HAVE_WAYLAND */
+
+static void
+gsd_device_manager_init (GsdDeviceManager *manager)
+{
+ const gchar *subsystems[] = { "input", NULL };
+
+ manager->udev_client = g_udev_client_new (subsystems);
+
+ manager->devices = g_hash_table_new_full (g_str_hash, g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) gsd_device_unref);
+
+#ifdef HAVE_WAYLAND
+ if (gnome_settings_is_wayland ()) {
+ g_signal_connect (manager->udev_client, "uevent",
+ G_CALLBACK (udev_event_cb), manager);
+ gsd_device_manager_init_udev (manager);
+ } else
+#endif /* HAVE_WAYLAND */
+#ifdef GDK_WINDOWING_X11
+ {
+ GdkDisplay *display;
+
+ /* On X11, we must hold on until the X server has seen the input
+ * devices, so we use the GdkDeviceManager for this purpose.
+ */
+ display = gdk_display_get_default ();
+ manager->device_manager = gdk_display_get_device_manager (display);
+ g_signal_connect (manager->device_manager, "device-added",
+ G_CALLBACK (device_manager_device_added_cb), manager);
+ g_signal_connect (manager->device_manager, "device-removed",
+ G_CALLBACK (device_manager_device_removed_cb), manager);
+
+ manager->gdk_devices = g_hash_table_new_full (NULL, NULL, NULL,
+ (GDestroyNotify) g_free);
+
+ gsd_device_manager_init_gdk (manager, GDK_DEVICE_TYPE_SLAVE);
+ gsd_device_manager_init_gdk (manager, GDK_DEVICE_TYPE_FLOATING);
+ }
+#endif /* GDK_WINDOWING_X11 */
+}
+
+GsdDeviceManager *
+gsd_device_manager_get (void)
+{
+ GsdDeviceManager *manager;
+ GdkScreen *screen;
+
+ screen = gdk_screen_get_default ();
+ g_return_val_if_fail (screen != NULL, NULL);
+
+ manager = g_object_get_data (G_OBJECT (screen), "gsd-device-manager-data");
+
+ if (!manager) {
+ manager = g_object_new (GSD_TYPE_DEVICE_MANAGER, NULL);
+ g_object_set_data_full (G_OBJECT (screen), "gsd-device-manager-data",
+ manager, (GDestroyNotify) g_object_unref);
+ }
+
+ return manager;
+}
+
+GList *
+gsd_device_manager_list_devices (GsdDeviceManager *manager,
+ GsdDeviceType type)
+{
+ GsdDeviceType device_type;
+ GList *devices = NULL;
+ GHashTableIter iter;
+ GsdDevice *info;
+
+ g_hash_table_iter_init (&iter, manager->devices);
+
+ while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &info)) {
+ device_type = gsd_device_get_device_type (info);
+
+ if ((device_type & type) == type)
+ devices = g_list_prepend (devices, info);
+ }
+
+ return devices;
+}
+
+GsdDeviceType
+gsd_device_get_device_type (GsdDevice *device)
+{
+ g_return_val_if_fail (device != NULL, 0);
+ g_return_val_if_fail (G_UDEV_IS_DEVICE (device->udev_device), 0);
+
+ return device->type;
+}
+
+gboolean
+gsd_device_get_device_ids (GsdDevice *device,
+ gchar **vendor,
+ gchar **product)
+{
+ GUdevDevice *parent;
+
+ g_return_val_if_fail (device != NULL, FALSE);
+ g_return_val_if_fail (G_UDEV_IS_DEVICE (device->udev_device), FALSE);
+
+ parent = g_udev_device_get_parent (device->udev_device);
+
+ if (!parent)
+ return FALSE;
+
+ if (vendor)
+ *vendor = g_strdup (g_udev_device_get_property (parent, "ID_VENDOR_ID"));
+ if (product)
+ *product = g_strdup (g_udev_device_get_property (parent, "ID_MODEL_ID"));
+
+ return TRUE;
+}
+
+GSettings *
+gsd_device_get_settings (GsdDevice *device)
+{
+ gchar *path = NULL, *vendor, *product;
+ const gchar *schema = NULL;
+ GSettings *settings;
+ GsdDeviceType type;
+
+ g_return_val_if_fail (device != NULL, NULL);
+ g_return_val_if_fail (G_UDEV_IS_DEVICE (device->udev_device), NULL);
+
+ type = gsd_device_get_device_type (device);
+
+ if (type & (GSD_DEVICE_TYPE_TOUCHSCREEN | GSD_DEVICE_TYPE_TABLET)) {
+ if (!gsd_device_get_device_ids (device, &vendor, &product))
+ return NULL;
+
+ if (type & GSD_DEVICE_TYPE_TOUCHSCREEN) {
+ schema = "org.gnome.desktop.peripherals.touchscreen";
+ path = g_strdup_printf ("/org/gnome/desktop/peripherals/touchscreens/%s:%s/",
+ vendor, product);
+ } else if (type & GSD_DEVICE_TYPE_TABLET) {
+ schema = "org.gnome.desktop.peripherals.tablet";
+ path = g_strdup_printf ("/org/gnome/desktop/peripherals/tablets/%s:%s/",
+ vendor, product);
+ }
+
+ g_free (vendor);
+ g_free (product);
+ } else if (type & (GSD_DEVICE_TYPE_MOUSE | GSD_DEVICE_TYPE_TOUCHPAD)) {
+ schema = "org.gnome.desktop.peripherals.mouse";
+ } else if (type & GSD_DEVICE_TYPE_KEYBOARD) {
+ schema = "org.gnome.desktop.peripherals.keyboard";
+ } else {
+ return NULL;
+ }
+
+ if (path) {
+ settings = g_settings_new_with_path (schema, path);
+ g_free (path);
+ } else {
+ settings = g_settings_new (schema);
+ }
+
+ return settings;
+}
+
+const gchar *
+gsd_device_get_name (GsdDevice *device)
+{
+ g_return_val_if_fail (device != NULL, NULL);
+ g_return_val_if_fail (G_UDEV_IS_DEVICE (device->udev_device), NULL);
+
+ return device->name;
+}
+
+const gchar *
+gsd_device_get_device_file (GsdDevice *device)
+{
+ return g_udev_device_get_device_file (device->udev_device);
+}
+
+gboolean
+gsd_device_get_dimensions (GsdDevice *device,
+ guint *width,
+ guint *height)
+{
+ guint w, h;
+
+ g_return_val_if_fail (device != NULL, FALSE);
+ g_return_val_if_fail (G_UDEV_IS_DEVICE (device->udev_device), FALSE);
+
+ w = g_udev_device_get_property_as_int (device->udev_device,
+ "ID_INPUT_WIDTH_MM");
+ h = g_udev_device_get_property_as_int (device->udev_device,
+ "ID_INPUT_HEIGHT_MM");
+
+ if (width)
+ *width = w;
+ if (height)
+ *height = h;
+
+ return (w > 0 && h > 0);
+}
+
+#ifdef GDK_WINDOWING_X11
+GdkDevice **
+gsd_device_get_gdk_devices (GsdDevice *device,
+ guint *n_gdk_devices)
+{
+ GPtrArray *gdk_devices;
+
+ g_return_val_if_fail (device != NULL, NULL);
+ g_return_val_if_fail (n_gdk_devices != NULL, NULL);
+
+ gdk_devices = device->data;
+ *n_gdk_devices = gdk_devices->len;
+
+ return (GdkDevice **) gdk_devices->pdata;
+}
+
+GsdDevice *
+gsd_device_manager_lookup_gdk_device (GsdDeviceManager *manager,
+ GdkDevice *gdk_device)
+{
+ const gchar *parent_sysfs_path;
+
+ g_return_val_if_fail (GSD_IS_DEVICE_MANAGER (manager), NULL);
+ g_return_val_if_fail (GDK_IS_DEVICE (gdk_device), NULL);
+
+ parent_sysfs_path = g_hash_table_lookup (manager->gdk_devices, gdk_device);
+
+ if (!parent_sysfs_path)
+ return NULL;
+
+ return g_hash_table_lookup (manager->devices, parent_sysfs_path);
+}
+#endif
diff --git a/plugins/common/gsd-device-manager.h b/plugins/common/gsd-device-manager.h
new file mode 100644
index 0000000..3817722
--- /dev/null
+++ b/plugins/common/gsd-device-manager.h
@@ -0,0 +1,74 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2014 Carlos Garnacho <carlosg gnome org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GSD_DEVICE_MANAGER_H__
+#define __GSD_DEVICE_MANAGER_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GSD_TYPE_DEVICE (gsd_device_get_type ())
+#define GSD_TYPE_DEVICE_MANAGER (gsd_device_manager_get_type ())
+#define GSD_DEVICE_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GSD_TYPE_DEVICE_MANAGER,
GsdDeviceManager))
+#define GSD_DEVICE_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GSD_TYPE_DEVICE_MANAGER,
GsdDeviceManagerClass))
+#define GSD_IS_DEVICE_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSD_TYPE_DEVICE_MANAGER))
+#define GSD_IS_DEVICE_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GSD_TYPE_DEVICE_MANAGER))
+#define GSD_DEVICE_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSD_TYPE_DEVICE_MANAGER,
GsdDeviceManagerClass))
+
+typedef struct _GsdDevice GsdDevice;
+typedef struct _GsdDeviceManager GsdDeviceManager;
+typedef struct _GsdDeviceManagerClass GsdDeviceManagerClass;
+
+typedef enum {
+ GSD_DEVICE_TYPE_MOUSE = 1 << 0,
+ GSD_DEVICE_TYPE_KEYBOARD = 1 << 1,
+ GSD_DEVICE_TYPE_TOUCHPAD = 1 << 2,
+ GSD_DEVICE_TYPE_TABLET = 1 << 3,
+ GSD_DEVICE_TYPE_TOUCHSCREEN = 1 << 4
+} GsdDeviceType;
+
+GType gsd_device_get_type (void) G_GNUC_CONST;
+GType gsd_device_manager_get_type (void) G_GNUC_CONST;
+GsdDeviceManager * gsd_device_manager_get (void);
+GList * gsd_device_manager_list_devices (GsdDeviceManager *manager,
+ GsdDeviceType type);
+
+const gchar * gsd_device_get_name (GsdDevice *device);
+GsdDeviceType gsd_device_get_device_type (GsdDevice *device);
+gboolean gsd_device_get_device_ids (GsdDevice *device,
+ gchar **vendor,
+ gchar **product);
+GSettings * gsd_device_get_settings (GsdDevice *device);
+
+const gchar * gsd_device_get_device_file (GsdDevice *device);
+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
+
+#endif /* __GSD_DEVICE_MANAGER_H__ */
diff --git a/plugins/mouse/gsd-mouse-manager.c b/plugins/mouse/gsd-mouse-manager.c
index 60e77c2..1c63a85 100644
--- a/plugins/mouse/gsd-mouse-manager.c
+++ b/plugins/mouse/gsd-mouse-manager.c
@@ -902,7 +902,7 @@ set_locate_pointer (GsdMouseManager *manager,
manager->priv->locate_pointer_spawned = (error == NULL);
if (error) {
- g_settings_set_boolean (manager->priv->mouse_settings, KEY_LOCATE_POINTER, FALSE);
+ g_settings_set_boolean (manager->priv->gsd_mouse_settings, KEY_LOCATE_POINTER,
FALSE);
g_error_free (error);
}
@@ -1344,7 +1344,7 @@ gsd_mouse_manager_idle_cb (GsdMouseManager *manager)
manager->priv->syndaemon_spawned = FALSE;
- set_locate_pointer (manager, g_settings_get_boolean (manager->priv->mouse_settings,
KEY_LOCATE_POINTER));
+ set_locate_pointer (manager, g_settings_get_boolean (manager->priv->gsd_mouse_settings,
KEY_LOCATE_POINTER));
set_mousetweaks_daemon (manager,
g_settings_get_boolean (manager->priv->mouse_a11y_settings,
KEY_DWELL_CLICK_ENABLED),
g_settings_get_boolean (manager->priv->mouse_a11y_settings,
KEY_SECONDARY_CLICK_ENABLED));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]