[clutter/clutter-1.18] DeviceManagerXi2: Cache the client pointer
- From: Adel Gadllah <agadllah src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter/clutter-1.18] DeviceManagerXi2: Cache the client pointer
- Date: Mon, 3 Mar 2014 14:06:23 +0000 (UTC)
commit 4a3ad9c3af2db9bb805b7abae018f6531087d1ac
Author: Adel Gadllah <adel gadllah gmail com>
Date: Mon Mar 3 11:36:11 2014 +0100
DeviceManagerXi2: Cache the client pointer
Currently clutter_device_manager_xi2_get_core_device always
does a round trip to query the client.
So avoid that by caching the client pointer and only update it when the
xi devices change.
https://bugzilla.gnome.org/show_bug.cgi?id=725561
clutter/x11/clutter-device-manager-xi2.c | 35 ++++++++++++++++++-----------
1 files changed, 22 insertions(+), 13 deletions(-)
---
diff --git a/clutter/x11/clutter-device-manager-xi2.c b/clutter/x11/clutter-device-manager-xi2.c
index d508026..b00cddb 100644
--- a/clutter/x11/clutter-device-manager-xi2.c
+++ b/clutter/x11/clutter-device-manager-xi2.c
@@ -222,6 +222,21 @@ is_touch_device (XIAnyClassInfo **classes,
return FALSE;
}
+static void
+update_client_pointer (ClutterDeviceManagerXI2 *manager_xi2)
+{
+ ClutterBackendX11 *backend_x11;
+ int device_id;
+
+ backend_x11 =
+ CLUTTER_BACKEND_X11 (_clutter_device_manager_get_backend (CLUTTER_DEVICE_MANAGER (manager_xi2)));
+
+ XIGetClientPointer (backend_x11->xdpy, None, &device_id);
+
+ manager_xi2->client_pointer = g_hash_table_lookup (manager_xi2->devices_by_id,
+ GINT_TO_POINTER (device_id));
+}
+
static ClutterInputDevice *
create_device (ClutterDeviceManagerXI2 *manager_xi2,
ClutterBackendX11 *backend_x11,
@@ -792,6 +807,7 @@ clutter_device_manager_xi2_translate_event (ClutterEventTranslator *translator,
XIHierarchyEvent *xev = (XIHierarchyEvent *) xi_event;
translate_hierarchy_event (backend_x11, manager_xi2, xev);
+ update_client_pointer (manager_xi2);
}
retval = CLUTTER_TRANSLATE_REMOVE;
break;
@@ -815,6 +831,8 @@ clutter_device_manager_xi2_translate_event (ClutterEventTranslator *translator,
if (source_device)
_clutter_input_device_reset_scroll_info (source_device);
+
+ update_client_pointer (manager_xi2);
}
retval = CLUTTER_TRANSLATE_REMOVE;
break;
@@ -1356,25 +1374,14 @@ clutter_device_manager_xi2_get_core_device (ClutterDeviceManager *manager,
ClutterInputDeviceType device_type)
{
ClutterDeviceManagerXI2 *manager_xi2 = CLUTTER_DEVICE_MANAGER_XI2 (manager);
- ClutterBackendX11 *backend_x11;
- ClutterInputDevice *device;
- int device_id;
-
- backend_x11 =
- CLUTTER_BACKEND_X11 (_clutter_device_manager_get_backend (manager));
-
- XIGetClientPointer (backend_x11->xdpy, None, &device_id);
-
- device = g_hash_table_lookup (manager_xi2->devices_by_id,
- GINT_TO_POINTER (device_id));
switch (device_type)
{
case CLUTTER_POINTER_DEVICE:
- return device;
+ return manager_xi2->client_pointer;
case CLUTTER_KEYBOARD_DEVICE:
- return clutter_input_device_get_associated_device (device);
+ return clutter_input_device_get_associated_device (manager_xi2->client_pointer);
default:
break;
@@ -1477,6 +1484,8 @@ clutter_device_manager_xi2_constructed (GObject *gobject)
clutter_x11_get_root_window (),
&event_mask);
+ update_client_pointer (manager_xi2);
+
if (G_OBJECT_CLASS (clutter_device_manager_xi2_parent_class)->constructed)
G_OBJECT_CLASS (clutter_device_manager_xi2_parent_class)->constructed (gobject);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]