[gtk+] gdk,xi2: Make more resilient about not yet known devices
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] gdk,xi2: Make more resilient about not yet known devices
- Date: Sun, 18 Dec 2011 17:59:26 +0000 (UTC)
commit 358ecad50147f9ee377a86fb70a7e58cc600616f
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun Dec 18 18:56:51 2011 +0100
gdk,xi2: Make more resilient about not yet known devices
Dealing with disabled devices may turn into hierarchy/device
changed events on device IDs with no backing GdkDevice yet,
so protect against that. The device attachment will be handled
correctly when the device is enabled later.
gdk/x11/gdkdevicemanager-xi2.c | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c
index afa9f54..d1481aa 100644
--- a/gdk/x11/gdkdevicemanager-xi2.c
+++ b/gdk/x11/gdkdevicemanager-xi2.c
@@ -605,6 +605,9 @@ handle_hierarchy_changed (GdkX11DeviceManagerXI2 *device_manager,
slave = g_hash_table_lookup (device_manager->id_table,
GINT_TO_POINTER (ev->info[i].deviceid));
+ if (!slave)
+ continue;
+
/* Remove old master info */
master = gdk_device_get_associated_device (slave);
@@ -627,7 +630,10 @@ handle_hierarchy_changed (GdkX11DeviceManagerXI2 *device_manager,
master = g_hash_table_lookup (device_manager->id_table,
GINT_TO_POINTER (info->attachment));
XIFreeDeviceInfo (info);
+ }
+ if (master)
+ {
_gdk_device_set_associated_device (slave, master);
_gdk_device_add_slave (master, slave);
@@ -651,10 +657,13 @@ handle_device_changed (GdkX11DeviceManagerXI2 *device_manager,
device = g_hash_table_lookup (device_manager->id_table,
GUINT_TO_POINTER (ev->deviceid));
- _gdk_device_reset_axes (device);
- translate_device_classes (display, device, ev->classes, ev->num_classes);
+ if (device)
+ {
+ _gdk_device_reset_axes (device);
+ translate_device_classes (display, device, ev->classes, ev->num_classes);
- g_signal_emit_by_name (G_OBJECT (device), "changed");
+ g_signal_emit_by_name (G_OBJECT (device), "changed");
+ }
}
static GdkCrossingMode
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]