[mutter/wip/carlosg/dispose-libinput-device: 4/4] backends/native: Dispose the libinput device in the input thread
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/dispose-libinput-device: 4/4] backends/native: Dispose the libinput device in the input thread
- Date: Tue, 15 Dec 2020 23:26:54 +0000 (UTC)
commit fdd75f465d2463947144daf4939f9315db0c740e
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Dec 16 00:09:37 2020 +0100
backends/native: Dispose the libinput device in the input thread
Currently, the MetaInputDeviceNative owns the libinput_device, with the
small catch that it is eventually finished in the main thread (as the
CLUTTER_DEVICE_REMOVED event keeps the last reference to it).
Make it sure that the libinput_device is destroyed in the input thread,
before giving away the last extra input device references.
src/backends/native/meta-input-device-native.c | 6 ++++++
src/backends/native/meta-input-device-native.h | 1 +
src/backends/native/meta-seat-impl.c | 4 +++-
3 files changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/src/backends/native/meta-input-device-native.c b/src/backends/native/meta-input-device-native.c
index 02149497c9..3d2096207f 100644
--- a/src/backends/native/meta-input-device-native.c
+++ b/src/backends/native/meta-input-device-native.c
@@ -1592,3 +1592,9 @@ meta_input_device_native_get_coords_in_impl (MetaInputDeviceNative *device_nativ
if (y)
*y = device_native->pointer_y;
}
+
+void
+meta_input_device_native_detach_libinput_in_impl (MetaInputDeviceNative *device_native)
+{
+ g_clear_pointer (&device_native->libinput_device, libinput_device_unref);
+}
diff --git a/src/backends/native/meta-input-device-native.h b/src/backends/native/meta-input-device-native.h
index 11551c278e..e0d66ed02c 100644
--- a/src/backends/native/meta-input-device-native.h
+++ b/src/backends/native/meta-input-device-native.h
@@ -157,5 +157,6 @@ void meta_input_device_native_get_coords_in_impl (MetaInputD
float *y);
gboolean meta_input_device_native_process_kbd_a11y_event_in_impl (ClutterInputDevice *device,
ClutterEvent *event);
+void meta_input_device_native_detach_libinput_in_impl (MetaInputDeviceNative
*device_native);
#endif /* META_INPUT_DEVICE_NATIVE_H */
diff --git a/src/backends/native/meta-seat-impl.c b/src/backends/native/meta-seat-impl.c
index 09bef5e8bd..904a9079f6 100644
--- a/src/backends/native/meta-seat-impl.c
+++ b/src/backends/native/meta-seat-impl.c
@@ -1602,6 +1602,8 @@ evdev_remove_device (MetaSeatImpl *seat_impl,
if (seat_impl->repeat_source && seat_impl->repeat_device == device)
meta_seat_impl_clear_repeat_source (seat_impl);
+ meta_input_device_native_detach_libinput_in_impl (device_native);
+
g_object_unref (device);
}
@@ -1633,9 +1635,9 @@ process_base_event (MetaSeatImpl *seat_impl,
device = libinput_device_get_user_data (libinput_device);
device_event = clutter_event_new (CLUTTER_DEVICE_REMOVED);
clutter_event_set_device (device_event, device);
+ meta_input_settings_remove_device (input_settings, device);
evdev_remove_device (seat_impl,
META_INPUT_DEVICE_NATIVE (device));
- meta_input_settings_remove_device (input_settings, device);
break;
default:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]