[mutter/cherry-pick-25e28393] screencast: Fix transform_position(), when using fractional scaling




commit 6822b0e7cc75f3cf66cf486266bcd9a6f11e807b
Author: Pascal Nowack <Pascal Nowack gmx de>
Date:   Sun May 16 11:49:58 2021 +0200

    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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1867>
    
    
    (cherry picked from commit 25e2839339c65dcdb16dc09007fc88d8e81f07c5)

 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 c7123a19b0..ada9bc95f6 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;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]