From 567ca4baa1b4ae10d80f758b3dc782b9a260eef9 Mon Sep 17 00:00:00 2001 From: Jeffrey Knockel Date: Sun, 12 May 2024 10:38:06 -0400 Subject: [PATCH] meta-monitor-manager-xrandr.c: screen size fixes 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. --- src/backends/x11/meta-monitor-manager-xrandr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backends/x11/meta-monitor-manager-xrandr.c b/src/backends/x11/meta-monitor-manager-xrandr.c index effee56c3..452c987b3 100644 --- a/src/backends/x11/meta-monitor-manager-xrandr.c +++ b/src/backends/x11/meta-monitor-manager-xrandr.c @@ -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