backends/x11: Emit CLUTTER_DEVICE_ADDED events for initial devices

This is similar to commit b9e5a2d6e2, but for the X11 backend.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1553
This commit is contained in:
Carlos Garnacho 2020-11-06 18:00:55 +01:00
parent 34710eabc0
commit b6211bb684
3 changed files with 28 additions and 0 deletions

View File

@ -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 *

View File

@ -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)
{

View File

@ -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