diff --git a/src/backends/meta-backend-private.h b/src/backends/meta-backend-private.h index 213cad5c1..416475bff 100644 --- a/src/backends/meta-backend-private.h +++ b/src/backends/meta-backend-private.h @@ -167,8 +167,8 @@ void meta_backend_freeze_updates (MetaBackend *backend); void meta_backend_thaw_updates (MetaBackend *backend); -void meta_backend_update_last_device (MetaBackend *backend, - int device_id); +void meta_backend_update_last_device (MetaBackend *backend, + ClutterInputDevice *device); gboolean meta_backend_get_relative_motion_deltas (MetaBackend *backend, const ClutterEvent *event, diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c index 4497f4279..158d8986a 100644 --- a/src/backends/meta-backend.c +++ b/src/backends/meta-backend.c @@ -148,7 +148,7 @@ struct _MetaBackendPrivate GHashTable *device_monitors; - int current_device_id; + ClutterInputDevice *current_device; MetaPointerConstraint *client_pointer_constraint; MetaDnd *dnd; @@ -425,13 +425,13 @@ on_device_removed (ClutterDeviceManager *device_manager, /* If the device the user last interacted goes away, check again pointer * visibility. */ - if (priv->current_device_id == device_id) + if (priv->current_device == device) { MetaCursorTracker *cursor_tracker = priv->cursor_tracker; gboolean has_touchscreen, has_pointing_device; ClutterInputDeviceType device_type; - priv->current_device_id = 0; + priv->current_device = NULL; device_type = clutter_input_device_get_device_type (device); has_touchscreen = check_has_slave_touchscreen (device_manager); @@ -770,7 +770,7 @@ meta_backend_class_init (MetaBackendClass *klass) G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, - G_TYPE_NONE, 1, G_TYPE_INT); + G_TYPE_NONE, 1, CLUTTER_TYPE_INPUT_DEVICE); signals[LID_IS_CLOSED_CHANGED] = g_signal_new ("lid-is-closed-changed", G_TYPE_FROM_CLASS (object_class), @@ -1171,17 +1171,12 @@ update_last_device (MetaBackend *backend) MetaBackendPrivate *priv = meta_backend_get_instance_private (backend); MetaCursorTracker *cursor_tracker = priv->cursor_tracker; ClutterInputDeviceType device_type; - ClutterDeviceManager *manager; - ClutterInputDevice *device; priv->device_update_idle_id = 0; - manager = clutter_device_manager_get_default (); - device = clutter_device_manager_get_device (manager, - priv->current_device_id); - device_type = clutter_input_device_get_device_type (device); + device_type = clutter_input_device_get_device_type (priv->current_device); g_signal_emit (backend, signals[LAST_DEVICE_CHANGED], 0, - priv->current_device_id); + priv->current_device); switch (device_type) { @@ -1199,24 +1194,19 @@ update_last_device (MetaBackend *backend) } void -meta_backend_update_last_device (MetaBackend *backend, - int device_id) +meta_backend_update_last_device (MetaBackend *backend, + ClutterInputDevice *device) { MetaBackendPrivate *priv = meta_backend_get_instance_private (backend); - ClutterDeviceManager *manager; - ClutterInputDevice *device; - if (priv->current_device_id == device_id) + if (priv->current_device == device) return; - manager = clutter_device_manager_get_default (); - device = clutter_device_manager_get_device (manager, device_id); - if (!device || clutter_input_device_get_device_mode (device) == CLUTTER_INPUT_MODE_MASTER) return; - priv->current_device_id = device_id; + priv->current_device = device; if (priv->device_update_idle_id == 0) { diff --git a/src/backends/x11/meta-backend-x11.c b/src/backends/x11/meta-backend-x11.c index 225d14d33..b5d051adc 100644 --- a/src/backends/x11/meta-backend-x11.c +++ b/src/backends/x11/meta-backend-x11.c @@ -46,6 +46,7 @@ #include "backends/meta-stage-private.h" #include "backends/x11/meta-clutter-backend-x11.h" #include "backends/x11/meta-event-x11.h" +#include "backends/x11/meta-seat-x11.h" #include "backends/x11/meta-stage-x11.h" #include "backends/x11/meta-renderer-x11.h" #include "clutter/clutter.h" @@ -242,6 +243,9 @@ handle_device_change (MetaBackendX11 *x11, XIEvent *event) { XIDeviceChangedEvent *device_changed; + ClutterInputDevice *device; + ClutterBackend *backend; + ClutterSeat *seat; if (event->evtype != XI_DeviceChanged) return; @@ -251,8 +255,11 @@ handle_device_change (MetaBackendX11 *x11, if (device_changed->reason != XISlaveSwitch) return; - meta_backend_update_last_device (META_BACKEND (x11), - device_changed->sourceid); + backend = meta_backend_get_clutter_backend (META_BACKEND (x11)); + seat = clutter_backend_get_default_seat (backend); + device = meta_seat_x11_lookup_device_id (META_SEAT_X11 (seat), + device_changed->sourceid); + meta_backend_update_last_device (META_BACKEND (x11), device); } /* Clutter makes the assumption that there is only one X window diff --git a/src/core/events.c b/src/core/events.c index d38377862..65a7792ee 100644 --- a/src/core/events.c +++ b/src/core/events.c @@ -273,10 +273,7 @@ meta_display_handle_event (MetaDisplay *display, source = clutter_event_get_source_device (event); if (source) - { - meta_backend_update_last_device (backend, - clutter_input_device_get_device_id (source)); - } + meta_backend_update_last_device (backend, source); #ifdef HAVE_WAYLAND if (meta_is_wayland_compositor () && event->type == CLUTTER_MOTION)