From b6211bb6842fd7f88bc4f70f0d268614b85f4b3d Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 6 Nov 2020 18:00:55 +0100 Subject: [PATCH] backends/x11: Emit CLUTTER_DEVICE_ADDED events for initial devices This is similar to commit b9e5a2d6e23, but for the X11 backend. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1553 --- src/backends/x11/meta-backend-x11.c | 7 +++++++ src/backends/x11/meta-seat-x11.c | 19 +++++++++++++++++++ src/backends/x11/meta-seat-x11.h | 2 ++ 3 files changed, 28 insertions(+) diff --git a/src/backends/x11/meta-backend-x11.c b/src/backends/x11/meta-backend-x11.c index 36349ffbb..d53deb386 100644 --- a/src/backends/x11/meta-backend-x11.c +++ b/src/backends/x11/meta-backend-x11.c @@ -525,6 +525,8 @@ meta_backend_x11_post_init (MetaBackend *backend) MetaBackendX11 *x11 = META_BACKEND_X11 (backend); MetaBackendX11Private *priv = meta_backend_x11_get_instance_private (x11); MetaMonitorManager *monitor_manager; + ClutterBackend *clutter_backend; + ClutterSeat *seat; int major, minor; gboolean has_xi = FALSE; @@ -577,6 +579,11 @@ meta_backend_x11_post_init (MetaBackend *backend) priv->touch_replay_sync_atom = XInternAtom (priv->xdisplay, "_MUTTER_TOUCH_SEQUENCE_SYNC", False); + + clutter_backend = meta_backend_get_clutter_backend (backend); + seat = clutter_backend_get_default_seat (clutter_backend); + meta_seat_x11_notify_devices (META_SEAT_X11 (seat), + CLUTTER_STAGE (meta_backend_get_stage (backend))); } static ClutterBackend * diff --git a/src/backends/x11/meta-seat-x11.c b/src/backends/x11/meta-seat-x11.c index de775e1f9..a00c3994e 100644 --- a/src/backends/x11/meta-seat-x11.c +++ b/src/backends/x11/meta-seat-x11.c @@ -1383,6 +1383,25 @@ meta_seat_x11_get_property (GObject *object, } } +void +meta_seat_x11_notify_devices (MetaSeatX11 *seat_x11, + ClutterStage *stage) +{ + GHashTableIter iter; + ClutterInputDevice *device; + + g_hash_table_iter_init (&iter, seat_x11->devices_by_id); + while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &device)) + { + ClutterEvent *event; + + event = clutter_event_new (CLUTTER_DEVICE_ADDED); + clutter_event_set_device (event, device); + clutter_event_set_stage (event, stage); + clutter_do_event (event); + } +} + static void meta_seat_x11_constructed (GObject *object) { diff --git a/src/backends/x11/meta-seat-x11.h b/src/backends/x11/meta-seat-x11.h index 0573f64b8..326db4a45 100644 --- a/src/backends/x11/meta-seat-x11.h +++ b/src/backends/x11/meta-seat-x11.h @@ -36,6 +36,8 @@ ClutterInputDevice * meta_seat_x11_lookup_device_id (MetaSeatX11 *seat_x11, int device_id); void meta_seat_x11_select_stage_events (MetaSeatX11 *seat, ClutterStage *stage); +void meta_seat_x11_notify_devices (MetaSeatX11 *seat_x11, + ClutterStage *stage); G_END_DECLS