From ee412cc4a351a1201a779e069ecd2b9498c6ce73 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 19 May 2023 16:19:44 +0200 Subject: [PATCH] backends/native: Change handling of display mapping for rel tablet tools We avoided setting the device matrix applying to the tablet tool (used if the tablet is in absolute coordinates mode) if the device is configured for relative motion, but forgot to apply the matrix if changing the device back to absolute mode, this made the device seemingly forget its attached display until later configuration changes. In order to avoid the hassle of looking up the right display again on unrelated configuration changes, make the matrix be always set on the device, but only actually used in absolute coordinates mode. This makes the device able to seamlessly switch between modes and remain mapped to the right display. Part-of: --- src/backends/native/meta-input-device-native.c | 3 +++ .../native/meta-input-settings-native.c | 17 +++-------------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/backends/native/meta-input-device-native.c b/src/backends/native/meta-input-device-native.c index f00064296..849694942 100644 --- a/src/backends/native/meta-input-device-native.c +++ b/src/backends/native/meta-input-device-native.c @@ -1592,6 +1592,9 @@ meta_input_device_native_translate_coordinates_in_impl (ClutterInputDevice *devi float stage_width, stage_height; double x_d, y_d; + if (device_evdev->mapping_mode == META_INPUT_DEVICE_MAPPING_RELATIVE) + return; + meta_viewport_info_get_extents (viewports, &stage_width, &stage_height); x_d = *x / stage_width; y_d = *y / stage_height; diff --git a/src/backends/native/meta-input-settings-native.c b/src/backends/native/meta-input-settings-native.c index 0c3719e0f..6a76e54be 100644 --- a/src/backends/native/meta-input-settings-native.c +++ b/src/backends/native/meta-input-settings-native.c @@ -138,20 +138,9 @@ set_matrix (GTask *task) float *matrix = g_task_get_task_data (task); cairo_matrix_t dev_matrix; - if (clutter_input_device_get_device_type (device) == - CLUTTER_TOUCHSCREEN_DEVICE || - meta_input_device_native_get_mapping_mode_in_impl (device) == - META_INPUT_DEVICE_MAPPING_ABSOLUTE) - { - cairo_matrix_init (&dev_matrix, - matrix[0], matrix[3], matrix[1], - matrix[4], matrix[2], matrix[5]); - } - else - { - cairo_matrix_init_identity (&dev_matrix); - } - + cairo_matrix_init (&dev_matrix, + matrix[0], matrix[3], matrix[1], + matrix[4], matrix[2], matrix[5]); g_object_set (device, "device-matrix", &dev_matrix, NULL); return G_SOURCE_REMOVE;