mirror of
https://github.com/brl/mutter.git
synced 2025-01-12 12:42:46 +00:00
seat/native/impl: Start reading input device events when starting
This opens up for a possibility to handle initial events (devices discovered on startup) during initialization, meaning we can figure out a more correct initial state that depends on available input devices. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3070>
This commit is contained in:
parent
af078264fa
commit
27606cf1fb
@ -756,6 +756,17 @@ init_gpus (MetaBackendNative *native,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
on_started (MetaContext *context,
|
||||
MetaBackend *backend)
|
||||
{
|
||||
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
|
||||
ClutterSeat *seat;
|
||||
|
||||
seat = clutter_backend_get_default_seat (clutter_backend);
|
||||
meta_seat_native_start (META_SEAT_NATIVE (seat));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
meta_backend_native_initable_init (GInitable *initable,
|
||||
GCancellable *cancellable,
|
||||
@ -804,6 +815,11 @@ meta_backend_native_initable_init (GInitable *initable,
|
||||
if (!init_gpus (native, error))
|
||||
return FALSE;
|
||||
|
||||
g_signal_connect (meta_backend_get_context (backend),
|
||||
"started",
|
||||
G_CALLBACK (on_started),
|
||||
backend);
|
||||
|
||||
return initable_parent_iface->init (initable, cancellable, error);
|
||||
}
|
||||
|
||||
|
@ -2809,7 +2809,6 @@ static gboolean
|
||||
init_libinput (MetaSeatImpl *seat_impl,
|
||||
GError **error)
|
||||
{
|
||||
MetaEventSource *source;
|
||||
struct udev *udev;
|
||||
struct libinput *libinput;
|
||||
|
||||
@ -2841,12 +2840,19 @@ init_libinput (MetaSeatImpl *seat_impl,
|
||||
}
|
||||
|
||||
seat_impl->libinput = libinput;
|
||||
source = meta_event_source_new (seat_impl);
|
||||
seat_impl->event_source = source;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
init_libinput_source (MetaSeatImpl *seat_impl)
|
||||
{
|
||||
MetaEventSource *source;
|
||||
|
||||
source = meta_event_source_new (seat_impl);
|
||||
seat_impl->event_source = source;
|
||||
}
|
||||
|
||||
static gpointer
|
||||
input_thread (MetaSeatImpl *seat_impl)
|
||||
{
|
||||
@ -3773,6 +3779,32 @@ meta_seat_impl_new (MetaSeatNative *seat_native,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
start_in_impl (GTask *task)
|
||||
{
|
||||
MetaSeatImpl *seat_impl = g_task_get_source_object (task);
|
||||
|
||||
if (seat_impl->libinput)
|
||||
init_libinput_source (seat_impl);
|
||||
|
||||
g_task_return_boolean (task, TRUE);
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
void
|
||||
meta_seat_impl_start (MetaSeatImpl *seat_impl)
|
||||
{
|
||||
GTask *task;
|
||||
|
||||
g_return_if_fail (META_IS_SEAT_IMPL (seat_impl));
|
||||
|
||||
task = g_task_new (seat_impl, NULL, NULL, NULL);
|
||||
meta_seat_impl_run_input_task (seat_impl, task,
|
||||
(GSourceFunc) start_in_impl);
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
void
|
||||
meta_seat_impl_notify_kbd_a11y_flags_changed_in_impl (MetaSeatImpl *seat_impl,
|
||||
MetaKeyboardA11yFlags new_flags,
|
||||
|
@ -131,6 +131,8 @@ MetaSeatImpl * meta_seat_impl_new (MetaSeatNative *seat_native,
|
||||
const char *seat_id,
|
||||
MetaSeatNativeFlag flags);
|
||||
|
||||
void meta_seat_impl_start (MetaSeatImpl *seat_impl);
|
||||
|
||||
void meta_seat_impl_destroy (MetaSeatImpl *seat_impl);
|
||||
|
||||
META_EXPORT_TEST
|
||||
|
@ -425,6 +425,12 @@ meta_seat_native_init (MetaSeatNative *seat)
|
||||
seat->reserved_virtual_slots = g_hash_table_new (NULL, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
meta_seat_native_start (MetaSeatNative *seat_native)
|
||||
{
|
||||
meta_seat_impl_start (seat_native->impl);
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_seat_native_release_devices:
|
||||
*
|
||||
|
@ -71,6 +71,8 @@ META_EXPORT_TEST
|
||||
G_DECLARE_FINAL_TYPE (MetaSeatNative, meta_seat_native,
|
||||
META, SEAT_NATIVE, ClutterSeat)
|
||||
|
||||
void meta_seat_native_start (MetaSeatNative *seat_native);
|
||||
|
||||
void meta_seat_native_set_libinput_seat (MetaSeatNative *seat,
|
||||
struct libinput_seat *libinput_seat);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user