From 25e2839339c65dcdb16dc09007fc88d8e81f07c5 Mon Sep 17 00:00:00 2001 From: Pascal Nowack Date: Sun, 16 May 2021 11:49:58 +0200 Subject: [PATCH] screencast: Fix transform_position(), when using fractional scaling Commit 64c9c9c5b005cf17103d8e1e0a08dec0b1094267 fixed monitor screencasting, when fractional screencasting is enabled. For the remote desktop usage, NotifyPointerMotionAbsolute() submits the new mouse pointer position in addition to the stream, where the mouse pointer was moved. When not using fractional scaling, the mouse pointer position is correct. With the usage of fractional scaling, the mouse pointer position is wrong, as the scale of the position is applied two times. Fix this behaviour, by reverting the second scale by dividing by the logical monitor scale, when fractional scaling is used. Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1808 Part-of: --- src/backends/meta-screen-cast-monitor-stream.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/backends/meta-screen-cast-monitor-stream.c b/src/backends/meta-screen-cast-monitor-stream.c index c7123a19b..ada9bc95f 100644 --- a/src/backends/meta-screen-cast-monitor-stream.c +++ b/src/backends/meta-screen-cast-monitor-stream.c @@ -194,12 +194,18 @@ meta_screen_cast_monitor_stream_transform_position (MetaScreenCastStream *stream MetaScreenCastMonitorStream *monitor_stream = META_SCREEN_CAST_MONITOR_STREAM (stream); MetaRectangle logical_monitor_layout; + double scale; logical_monitor_layout = meta_logical_monitor_get_layout (monitor_stream->logical_monitor); - *x = logical_monitor_layout.x + stream_x; - *y = logical_monitor_layout.y + stream_y; + if (meta_is_stage_views_scaled ()) + scale = meta_logical_monitor_get_scale (monitor_stream->logical_monitor); + else + scale = 1.0; + + *x = logical_monitor_layout.x + stream_x / scale; + *y = logical_monitor_layout.y + stream_y / scale; return TRUE; }