Skip to content

Commit

Permalink
meta-monitor-manager-xrandr.c: screen size fixes
Browse files Browse the repository at this point in the history
In previous commits, we have fixed "scale-up" fractional mode scaling
when done via the display settings UI.  However, there is still the
matter of meta_monitor_manager_xrandr_update_screen_size_derived() which
can be called on anyone's change to the xrandr configuration.

Prior to this commit, to work around an issue where CRTCs must be
disabled, this function *never* set the correct screen size when scaling
up.  This has some horrible consequences like breaking edges on the
sides of monitors, windows appearing completely offscreen, incorrect
workspace previews, etc., so we should *never* do this.

Let's instead try to set the correct screen size.  If it fails, that's
fine because we are doing it via XCB and will merely log the error.
It's better than always setting the wrong screen size.  Plus, there is
reason to think that the screen size will already be correct anyways.
In previous commits we already fixed *our* handling of xrandr scaling to
correctly update the screen size when the necessary CRTCs are disabled.
Hopefully all other tools are doing it correctly as well and we never
have to update the screen size here. :)

If this prediction proves inaccurate, we can later update this function
to (1) check if the screen size actually needs changing and, if it does,
then (2) disable any CRTCs that need disabling before changing the
screen size and (3) re-enable them after the change of screen size.
Unfortunately I don't know if there is a simpler way.

In general, we have to be careful to not disable CRTCs too eagerly
either because disabling a CRTC is typically quite easily noticed by a
user and results in the screen turning black for a moment.
  • Loading branch information
jknockel authored and mtwebster committed May 23, 2024
1 parent c0ddf33 commit 567ca4b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/backends/x11/meta-monitor-manager-xrandr.c
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ meta_monitor_manager_xrandr_update_screen_size_derived (MetaMonitorManager *mana
if (!crtc || !crtc->config)
continue;

if (!have_scaling || scale_mode != META_X11_SCALE_MODE_UI_DOWN)
if (!have_scaling)
{
/* When scaling up we should not reduce the screen size, or X will
* fail miserably, while we must do it when scaling down, in order to
Expand Down

0 comments on commit 567ca4b

Please sign in to comment.