From 2cb0077f7d7260109f0974d260cb4ed63ade6e9e Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 18 Jan 2011 13:03:07 +0000 Subject: [PATCH] device/xi2: Implement get_core_device() We ask XI2 to get the client pointer for CLUTTER_POINTER_DEVICE, and we use the attached keyboard device for CLUTTER_KEYBOARD_DEVICE. For everything else, we return NULL. --- clutter/x11/clutter-device-manager-xi2.c | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/clutter/x11/clutter-device-manager-xi2.c b/clutter/x11/clutter-device-manager-xi2.c index c21aa4218..dbdf67024 100644 --- a/clutter/x11/clutter-device-manager-xi2.c +++ b/clutter/x11/clutter-device-manager-xi2.c @@ -896,6 +896,31 @@ static ClutterInputDevice * 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; + + case CLUTTER_KEYBOARD_DEVICE: + return clutter_input_device_get_associated_device (device); + + default: + break; + } + return NULL; }