From 3263084bcf7f241267dc4dc840b81cc4617bed20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Mon, 8 Mar 2021 15:09:07 +0100 Subject: [PATCH] backends/native: Translate right coords when creating motion events With commit 7d7876880998fe7b414bb38f8094af9822020d1b we switched to storing pointer coordinates in MetaInputDeviceNative instead of ClutterInputDevice, and while we had set the coordinates of the ClutterInputDevice in ClutterStage when queueing an event, we now set the MetaInputDeviceNative coordinates in new_absolute_motion_event(). Here a small mistake snuck in: new_absolute_motion_event() only translates the coordinates of the event, but we call meta_input_device_native_set_coords() using the x and y variables (which remain untranslated), so now the input device coordinates are no longer translated. Fix that by translating the coordinates of the x and y variables in case we're we handling a tablet/stylus event instead of only translating the event coordinates. Fixes https://gitlab.gnome.org/GNOME/mutter/-/issues/1685 Part-of: --- src/backends/native/meta-seat-impl.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/backends/native/meta-seat-impl.c b/src/backends/native/meta-seat-impl.c index 1ffc9e685..71da8f8fa 100644 --- a/src/backends/native/meta-seat-impl.c +++ b/src/backends/native/meta-seat-impl.c @@ -514,6 +514,17 @@ new_absolute_motion_event (MetaSeatImpl *seat_impl, seat_impl->pointer_y, &x, &y); } + else + { + /* This may happen early at startup */ + if (seat_impl->viewports) + { + meta_input_device_native_translate_coordinates_in_impl (input_device, + seat_impl->viewports, + &x, + &y); + } + } event->motion.time_us = time_us; event->motion.time = us2ms (time_us); @@ -521,15 +532,6 @@ new_absolute_motion_event (MetaSeatImpl *seat_impl, event->motion.x = x; event->motion.y = y; - /* This may happen early at startup */ - if (seat_impl->viewports) - { - meta_input_device_native_translate_coordinates_in_impl (input_device, - seat_impl->viewports, - &event->motion.x, - &event->motion.y); - } - event->motion.axes = axes; clutter_event_set_device (event, seat_impl->core_pointer); clutter_event_set_source_device (event, input_device);