[gnome-settings-daemon/gnome-3-16] common: Add GsdDeviceManager::device-changed
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon/gnome-3-16] common: Add GsdDeviceManager::device-changed
- Date: Mon, 2 Nov 2015 18:46:16 +0000 (UTC)
commit 300c71dc344804464a2c195b5cf565ba3ea32847
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Oct 16 16:24:56 2015 +0200
common: Add GsdDeviceManager::device-changed
When devices are plugged, we may end up emitting
GsdDeviceManager::device-added at a time when not all GdkDevices have been
attached to the GsdDevice, this makes these devices occasionally not being
applied the right keep-aspect/area settings.
Add a GsdDeviceManager::device-changed signal, emitted for the GsdDevice
for those situations, so the late-added devices are ensured to be updated.
https://bugzilla.gnome.org/show_bug.cgi?id=753589
plugins/common/gsd-device-manager-x11.c | 6 +++++-
plugins/common/gsd-device-manager.c | 10 ++++++++++
plugins/common/gsd-device-manager.h | 2 ++
plugins/wacom/gsd-wacom-manager.c | 26 ++++++++++++++++++++++++++
4 files changed, 43 insertions(+), 1 deletions(-)
---
diff --git a/plugins/common/gsd-device-manager-x11.c b/plugins/common/gsd-device-manager-x11.c
index cee7b2f..14f6e72 100644
--- a/plugins/common/gsd-device-manager-x11.c
+++ b/plugins/common/gsd-device-manager-x11.c
@@ -112,7 +112,11 @@ add_device (GsdX11DeviceManager *manager,
/* Takes ownership of device_file */
g_hash_table_insert (manager->gdk_devices, gdk_device, device_file);
- if (!g_hash_table_lookup (manager->devices, device_file)) {
+ device = g_hash_table_lookup (manager->devices, device_file);
+
+ if (device) {
+ g_signal_emit_by_name (manager, "device-changed", device);
+ } else {
device = create_device (gdk_device, device_file);
g_hash_table_insert (manager->devices, g_strdup (device_file), device);
g_signal_emit_by_name (manager, "device-added", device);
diff --git a/plugins/common/gsd-device-manager.c b/plugins/common/gsd-device-manager.c
index aaf70bf..1737bf3 100644
--- a/plugins/common/gsd-device-manager.c
+++ b/plugins/common/gsd-device-manager.c
@@ -55,6 +55,7 @@ enum {
enum {
DEVICE_ADDED,
DEVICE_REMOVED,
+ DEVICE_CHANGED,
N_SIGNALS
};
@@ -246,6 +247,15 @@ gsd_device_manager_class_init (GsdDeviceManagerClass *klass)
NULL, NULL, NULL,
G_TYPE_NONE, 1,
GSD_TYPE_DEVICE | G_SIGNAL_TYPE_STATIC_SCOPE);
+
+ signals[DEVICE_CHANGED] =
+ g_signal_new ("device-changed",
+ GSD_TYPE_DEVICE_MANAGER,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GsdDeviceManagerClass, device_changed),
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 1,
+ GSD_TYPE_DEVICE | G_SIGNAL_TYPE_STATIC_SCOPE);
}
static void
diff --git a/plugins/common/gsd-device-manager.h b/plugins/common/gsd-device-manager.h
index 61e5727..baf46a8 100644
--- a/plugins/common/gsd-device-manager.h
+++ b/plugins/common/gsd-device-manager.h
@@ -76,6 +76,8 @@ struct _GsdDeviceManagerClass
GsdDevice *device);
void (* device_removed) (GsdDeviceManager *manager,
GsdDevice *device);
+ void (* device_changed) (GsdDeviceManager *manager,
+ GsdDevice *device);
};
GType gsd_device_get_type (void) G_GNUC_CONST;
diff --git a/plugins/wacom/gsd-wacom-manager.c b/plugins/wacom/gsd-wacom-manager.c
index a9dd716..adacebe 100644
--- a/plugins/wacom/gsd-wacom-manager.c
+++ b/plugins/wacom/gsd-wacom-manager.c
@@ -100,6 +100,7 @@ struct GsdWacomManagerPrivate
guint start_idle_id;
GsdDeviceManager *device_manager;
guint device_added_id;
+ guint device_changed_id;
guint device_removed_id;
GHashTable *devices; /* key = GdkDevice, value = GsdWacomDevice */
GnomeRRScreen *rr_screen;
@@ -1129,6 +1130,28 @@ device_added_cb (GsdDeviceManager *device_manager,
}
static void
+device_changed_cb (GsdDeviceManager *device_manager,
+ GsdDevice *gsd_device,
+ GsdWacomManager *manager)
+{
+ GdkDevice **devices;
+ guint i, n_gdk_devices;
+
+ if (gnome_settings_is_wayland ())
+ return;
+
+ devices = gsd_x11_device_manager_get_gdk_devices (GSD_X11_DEVICE_MANAGER (device_manager),
+ gsd_device, &n_gdk_devices);
+
+ for (i = 0; i < n_gdk_devices; i++) {
+ if (!g_hash_table_lookup (manager->priv->devices, devices[i]))
+ gsd_wacom_manager_add_gdk_device (manager, devices[i]);
+ }
+
+ g_free (devices);
+}
+
+static void
gsd_wacom_manager_remove_gdk_device (GsdWacomManager *manager,
GdkDevice *gdk_device)
{
@@ -1535,6 +1558,8 @@ set_devicepresence_handler (GsdWacomManager *manager)
device_manager = gsd_device_manager_get ();
manager->priv->device_added_id = g_signal_connect (G_OBJECT (device_manager), "device-added",
G_CALLBACK (device_added_cb), manager);
+ manager->priv->device_changed_id = g_signal_connect (G_OBJECT (device_manager), "device-changed",
+ G_CALLBACK (device_changed_cb), manager);
manager->priv->device_removed_id = g_signal_connect (G_OBJECT (device_manager), "device-removed",
G_CALLBACK (device_removed_cb), manager);
manager->priv->device_manager = device_manager;
@@ -1764,6 +1789,7 @@ gsd_wacom_manager_stop (GsdWacomManager *manager)
if (p->device_manager != NULL) {
g_signal_handler_disconnect (p->device_manager, p->device_added_id);
+ g_signal_handler_disconnect (p->device_manager, p->device_changed_id);
g_signal_handler_disconnect (p->device_manager, p->device_removed_id);
p->device_manager = NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]