1
0
Fork 0

window: Fall back to main window monitor for highest scale monitor

MetaWindow always tries to have a main monitor: If the frame rect is empty
and the window has not been positioned, in meta_window_constructed() we fall
back to asking the backend for the current monitor, and in
meta_window_wayland_update_main_monitor() we fall back to
meta_window_find_monitor_from_id(), which then falls back to the primary
monitor.

In general this means that window->monitor is always set as long as there is
a monitor around.

For getting the highest-scale-monitor the window is on, we currently rely
completely on the frame rect. If the frame rect is empty, we set the
highest-scale-monitor to NULL. Since we usually know though which monitor
the window is, or will be on, and window->monitor is even set to that, we
can just fall back to window->monitor for the highest-scale-monitor.

This makes sure ::highest-scale-monitor-changed is emitted right after the
window is created, and it's set to the correct monitor that the window will
be on. This in turn means that we can send a correct wp_fractional_scale
fraction_scale event to clients right away.

https://gitlab.gnome.org/GNOME/mutter/-/issues/3262

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3598>
This commit is contained in:
Jonas Dreßler 2024-02-19 19:32:24 +01:00 committed by Marge Bot
parent 9dff6a5013
commit bf4aff823f

View file

@ -1112,12 +1112,16 @@ meta_window_constructed (GObject *object)
window->compositor_private = NULL;
if (window->rect.width > 0 && window->rect.height > 0)
{
window->monitor = meta_window_find_monitor_from_frame_rect (window);
else
window->monitor = meta_backend_get_current_logical_monitor (backend);
window->highest_scale_monitor =
meta_window_find_highest_scale_monitor_from_frame_rect (window);
}
else
{
window->monitor = meta_backend_get_current_logical_monitor (backend);
window->highest_scale_monitor = window->monitor;
}
if (window->monitor)
window->preferred_output_winsys_id = window->monitor->winsys_id;
@ -3725,8 +3729,11 @@ meta_window_update_monitor (MetaWindow *window,
}
old_highest_scale = window->highest_scale_monitor;
window->highest_scale_monitor =
meta_window_find_highest_scale_monitor_from_frame_rect (window);
window->highest_scale_monitor = window->rect.width > 0 && window->rect.height > 0
? meta_window_find_highest_scale_monitor_from_frame_rect (window)
: window->monitor;
if (old_highest_scale != window->highest_scale_monitor)
g_signal_emit (window, window_signals[HIGHEST_SCALE_MONITOR_CHANGED], 0);
}