backends/native: Pass ClutterSeat into virtual input device constructor

Avoid passing the MetaSeatImpl, since it may be potentially null at
MetaSeatNative construction time. An example of this triggering issues
are mousekeys, since those work on an emulated pointer device created
indirectly after a keyboard device is added (and the right settings are
enabled) at a time that the MetaSeatImpl is still being created, so the
MetaSeatNative cannot yet have a reference to it.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2869
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3278>
This commit is contained in:
Carlos Garnacho 2023-09-13 19:06:51 +02:00
parent 00bb4190b3
commit e056ce0ea3
4 changed files with 13 additions and 11 deletions

View File

@ -1554,11 +1554,13 @@ meta_input_device_native_new_in_impl (MetaSeatImpl *seat_impl,
* Create a new virtual ClutterInputDevice of the given type.
*/
ClutterInputDevice *
meta_input_device_native_new_virtual (MetaSeatImpl *seat_impl,
meta_input_device_native_new_virtual (ClutterSeat *seat,
ClutterInputDeviceType type,
ClutterInputMode mode)
{
MetaInputDeviceNative *device;
MetaBackend *backend =
meta_seat_native_get_backend (META_SEAT_NATIVE (seat));
const char *name;
switch (type)
@ -1578,11 +1580,11 @@ meta_input_device_native_new_virtual (MetaSeatImpl *seat_impl,
};
device = g_object_new (META_TYPE_INPUT_DEVICE_NATIVE,
"backend", meta_seat_impl_get_backend (seat_impl),
"backend", backend,
"name", name,
"device-type", type,
"device-mode", mode,
"seat", seat_impl->seat_native,
"seat", seat,
NULL);
return CLUTTER_INPUT_DEVICE (device);

View File

@ -135,9 +135,9 @@ GType meta_input_device_native_get_type (void) G_GNUC
ClutterInputDevice * meta_input_device_native_new_in_impl (MetaSeatImpl *seat_impl,
struct libinput_device *libinput_device);
ClutterInputDevice * meta_input_device_native_new_virtual (MetaSeatImpl *seat_impl,
ClutterInputDeviceType type,
ClutterInputMode mode);
ClutterInputDevice * meta_input_device_native_new_virtual (ClutterSeat *seat,
ClutterInputDeviceType type,
ClutterInputMode mode);
void meta_input_device_native_update_leds_in_impl (MetaInputDeviceNative *device,
enum libinput_led leds);

View File

@ -2964,8 +2964,8 @@ meta_seat_impl_constructed (GObject *object)
ClutterInputDevice *device;
device = meta_input_device_native_new_virtual (
seat_impl, CLUTTER_POINTER_DEVICE,
CLUTTER_INPUT_MODE_LOGICAL);
CLUTTER_SEAT (seat_impl->seat_native), CLUTTER_POINTER_DEVICE,
CLUTTER_INPUT_MODE_LOGICAL);
seat_impl->pointer_x = INITIAL_POINTER_X;
seat_impl->pointer_y = INITIAL_POINTER_Y;
meta_input_device_native_set_coords_in_impl (META_INPUT_DEVICE_NATIVE (device),
@ -2974,8 +2974,8 @@ meta_seat_impl_constructed (GObject *object)
seat_impl->core_pointer = device;
device = meta_input_device_native_new_virtual (
seat_impl, CLUTTER_KEYBOARD_DEVICE,
CLUTTER_INPUT_MODE_LOGICAL);
CLUTTER_SEAT (seat_impl->seat_native), CLUTTER_KEYBOARD_DEVICE,
CLUTTER_INPUT_MODE_LOGICAL);
seat_impl->core_keyboard = device;
if (G_OBJECT_CLASS (meta_seat_impl_parent_class)->constructed)

View File

@ -1036,7 +1036,7 @@ meta_virtual_input_device_native_constructed (GObject *object)
virtual_evdev->impl_state = g_new0 (ImplState, 1);
virtual_evdev->impl_state->device =
meta_input_device_native_new_virtual (virtual_evdev->seat->impl,
meta_input_device_native_new_virtual (CLUTTER_SEAT (virtual_evdev->seat),
device_type,
CLUTTER_INPUT_MODE_PHYSICAL);