Blame SOURCES/0001-common-Use-GdkDevices-directly-as-HT-keys-on-GsdDevi.patch

b8fc81
From 3bd808127daf9f8f83c711d49ffaa19ce8601164 Mon Sep 17 00:00:00 2001
b8fc81
From: Carlos Garnacho <carlosg@gnome.org>
b8fc81
Date: Thu, 18 Jan 2018 12:09:43 +0100
b8fc81
Subject: [PATCH] common: Use GdkDevices directly as HT keys on
b8fc81
 GsdDeviceManagerX11
b8fc81
b8fc81
The dance we do to fetch event nodes from devices seems a bit superfluous
b8fc81
now, and even wrong if multiple X11 devices boil down to the same event
b8fc81
node.
b8fc81
b8fc81
Fixes the wacom panel not showing the "Map buttons..." action on older
b8fc81
kernels and wacom.ko modules, because the pad device shares the event node
b8fc81
with the stylus. Pad device lookups in order to enable the action obtain
b8fc81
the stylus device, thus the action is not shown.
b8fc81
b8fc81
https://bugzilla.gnome.org/show_bug.cgi?id=793029
b8fc81
---
b8fc81
 panels/common/gsd-device-manager-x11.c | 33 +++++++--------------------------
b8fc81
 1 file changed, 7 insertions(+), 26 deletions(-)
b8fc81
b8fc81
diff --git a/panels/common/gsd-device-manager-x11.c b/panels/common/gsd-device-manager-x11.c
b8fc81
index a2704d1a5..a77d6faeb 100644
b8fc81
--- a/panels/common/gsd-device-manager-x11.c
b8fc81
+++ b/panels/common/gsd-device-manager-x11.c
b8fc81
@@ -117,16 +117,13 @@ add_device (GsdX11DeviceManager *manager,
b8fc81
 	if (!device_file)
b8fc81
 		return;
b8fc81
 
b8fc81
-	/* Takes ownership of device_file */
b8fc81
-	g_hash_table_insert (manager->gdk_devices, gdk_device, device_file);
b8fc81
-
b8fc81
-	device = g_hash_table_lookup (manager->devices, device_file);
b8fc81
+	device = g_hash_table_lookup (manager->devices, gdk_device);
b8fc81
 
b8fc81
 	if (device) {
b8fc81
 		g_signal_emit_by_name (manager, "device-changed", device);
b8fc81
 	} else {
b8fc81
 		device = create_device (gdk_device, device_file);
b8fc81
-		g_hash_table_insert (manager->devices, g_strdup (device_file), device);
b8fc81
+		g_hash_table_insert (manager->devices, gdk_device, device);
b8fc81
 		g_signal_emit_by_name (manager, "device-added", device);
b8fc81
 	}
b8fc81
 }
b8fc81
@@ -135,24 +132,17 @@ static void
b8fc81
 remove_device (GsdX11DeviceManager *manager,
b8fc81
 	       GdkDevice	   *gdk_device)
b8fc81
 {
b8fc81
-	const gchar *device_file;
b8fc81
 	GsdDevice *device;
b8fc81
 
b8fc81
-	device_file = g_hash_table_lookup (manager->gdk_devices, gdk_device);
b8fc81
-
b8fc81
-	if (!device_file)
b8fc81
-		return;
b8fc81
-
b8fc81
-	device = g_hash_table_lookup (manager->devices, device_file);
b8fc81
+	device = g_hash_table_lookup (manager->devices, gdk_device);
b8fc81
 
b8fc81
 	if (device) {
b8fc81
 		g_object_ref (device);
b8fc81
 		g_signal_emit_by_name (manager, "device-removed", device);
b8fc81
 		g_object_unref (device);
b8fc81
-	}
b8fc81
 
b8fc81
-	g_hash_table_remove (manager->devices, device_file);
b8fc81
-	g_hash_table_remove (manager->gdk_devices, gdk_device);
b8fc81
+                g_hash_table_remove (manager->devices, gdk_device);
b8fc81
+	}
b8fc81
 }
b8fc81
 
b8fc81
 static void
b8fc81
@@ -175,11 +165,8 @@ gsd_x11_device_manager_init (GsdX11DeviceManager *manager)
b8fc81
 {
b8fc81
 	GdkDisplay *display;
b8fc81
 
b8fc81
-	manager->devices = g_hash_table_new_full (g_str_hash, g_str_equal,
b8fc81
-						  (GDestroyNotify) g_free,
b8fc81
+	manager->devices = g_hash_table_new_full (NULL, NULL, NULL,
b8fc81
 						  (GDestroyNotify) g_object_unref);
b8fc81
-	manager->gdk_devices = g_hash_table_new_full (NULL, NULL, NULL,
b8fc81
-						      (GDestroyNotify) g_free);
b8fc81
 
b8fc81
 	display = gdk_display_get_default ();
b8fc81
 	manager->device_manager = gdk_display_get_device_manager (display);
b8fc81
@@ -229,12 +216,6 @@ gsd_x11_device_manager_lookup_gdk_device (GsdDeviceManager *manager,
b8fc81
 					  GdkDevice	   *gdk_device)
b8fc81
 {
b8fc81
 	GsdX11DeviceManager *manager_x11 = GSD_X11_DEVICE_MANAGER (manager);
b8fc81
-	const gchar *device_node;
b8fc81
-
b8fc81
-	device_node = g_hash_table_lookup (manager_x11->gdk_devices, gdk_device);
b8fc81
-
b8fc81
-	if (!device_node)
b8fc81
-		return NULL;
b8fc81
 
b8fc81
-	return g_hash_table_lookup (manager_x11->devices, device_node);
b8fc81
+	return g_hash_table_lookup (manager_x11->devices, gdk_device);
b8fc81
 }
b8fc81
-- 
b8fc81
2.16.1
b8fc81