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>
This commit is contained in:
Pascal Nowack 2021-05-16 11:49:58 +02:00
parent 14063aff2f
commit 25e2839339

View File

@ -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;
}