From 4ce97fba6ccbfcaa5cc7507f64a9bb51028bea97 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 13 Sep 2023 18:54:05 +0200 Subject: [PATCH] backends/native: Avoid meta_input_device_native_get_seat_impl() These objects already have a pointer to the ClutterSeat that has a pointer to the MetaSeatImpl in its native implementation. This data may be considered pretty much immutable (a pointer to the seat is held, and the native implementation will shut down the implementation thread within ClutterSeat finalization. Avoids some awkward code, since the MetaInputDeviceNative needs to be aware of the Clutter object implementation and the implementation object. Part-of: --- src/backends/native/meta-input-device-native.c | 6 ------ src/backends/native/meta-input-device-native.h | 2 -- src/backends/native/meta-seat-impl.c | 6 ++++-- src/backends/native/meta-virtual-input-device-native.c | 8 ++++---- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/backends/native/meta-input-device-native.c b/src/backends/native/meta-input-device-native.c index 1ccbda130..2f8fd1592 100644 --- a/src/backends/native/meta-input-device-native.c +++ b/src/backends/native/meta-input-device-native.c @@ -1563,12 +1563,6 @@ meta_input_device_native_new_virtual (MetaSeatImpl *seat_impl, return CLUTTER_INPUT_DEVICE (device); } -MetaSeatImpl * -meta_input_device_native_get_seat_impl (MetaInputDeviceNative *device) -{ - return device->seat_impl; -} - void meta_input_device_native_update_leds_in_impl (MetaInputDeviceNative *device, enum libinput_led leds) diff --git a/src/backends/native/meta-input-device-native.h b/src/backends/native/meta-input-device-native.h index a8a9fde1c..2833060f2 100644 --- a/src/backends/native/meta-input-device-native.h +++ b/src/backends/native/meta-input-device-native.h @@ -139,8 +139,6 @@ ClutterInputDevice * meta_input_device_native_new_virtual (MetaSeatImpl ClutterInputDeviceType type, ClutterInputMode mode); -MetaSeatImpl * meta_input_device_native_get_seat_impl (MetaInputDeviceNative *device); - void meta_input_device_native_update_leds_in_impl (MetaInputDeviceNative *device, enum libinput_led leds); diff --git a/src/backends/native/meta-seat-impl.c b/src/backends/native/meta-seat-impl.c index 3db3753a9..09ccaad43 100644 --- a/src/backends/native/meta-seat-impl.c +++ b/src/backends/native/meta-seat-impl.c @@ -803,9 +803,11 @@ meta_seat_impl_notify_button_in_impl (MetaSeatImpl *seat_impl, static MetaSeatImpl * seat_impl_from_device (ClutterInputDevice *device) { - MetaInputDeviceNative *device_native = META_INPUT_DEVICE_NATIVE (device); + ClutterSeat *seat; - return meta_input_device_native_get_seat_impl (device_native); + seat = clutter_input_device_get_seat (device); + + return META_SEAT_NATIVE (seat)->impl; } static void diff --git a/src/backends/native/meta-virtual-input-device-native.c b/src/backends/native/meta-virtual-input-device-native.c index 3d56b4167..0cb890a2c 100644 --- a/src/backends/native/meta-virtual-input-device-native.c +++ b/src/backends/native/meta-virtual-input-device-native.c @@ -158,19 +158,19 @@ static gboolean release_device_in_impl (GTask *task) { ImplState *impl_state = g_task_get_task_data (task); - MetaInputDeviceNative *device_native; + ClutterSeat *seat; MetaSeatImpl *seat_impl; int code; uint64_t time_us; ClutterEvent *device_event; - device_native = META_INPUT_DEVICE_NATIVE (impl_state->device); - seat_impl = meta_input_device_native_get_seat_impl (device_native); + seat = clutter_input_device_get_seat (impl_state->device); + seat_impl = META_SEAT_NATIVE (seat)->impl; time_us = g_get_monotonic_time (); meta_topic (META_DEBUG_INPUT, "Releasing pressed buttons while destroying virtual input device " - "(device %p)", device_native); + "(device %p)", impl_state->device); for (code = 0; code < G_N_ELEMENTS (impl_state->button_count); code++) {