mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 16:10:41 -05:00
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
This commit is contained in:
parent
edc91b7640
commit
4a3ad9c3af
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user