window: Make a better guess at initial monitor

We'd guess the initial monitor before it was actually calculated by
looking at the initial geometry. For Wayland windows, this geometry was
always 0x0+0+0, thus the selected monitor was always the primary one.

This is problematic if we want to provide initial more likely
configurations to Wayland clients. While we're not doing that yet, it'll
be added later, and this is in preparation for that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2167>
This commit is contained in:
Jonas Ådahl 2021-12-18 00:03:21 +01:00 committed by Marge Bot
parent 17e239246a
commit 546b94545e
2 changed files with 10 additions and 1 deletions

View File

@ -964,6 +964,8 @@ _meta_window_shared_new (MetaDisplay *display,
MetaCompEffect effect,
XWindowAttributes *attrs)
{
MetaContext *context = meta_display_get_context (display);
MetaBackend *backend = meta_context_get_backend (context);
MetaWorkspaceManager *workspace_manager = display->workspace_manager;
MetaWindow *window;
@ -1157,7 +1159,11 @@ _meta_window_shared_new (MetaDisplay *display,
window->compositor_private = NULL;
window->monitor = meta_window_calculate_main_logical_monitor (window);
if (window->rect.width > 0 && window->rect.height > 0)
window->monitor = meta_window_calculate_main_logical_monitor (window);
else
window->monitor = meta_backend_get_current_logical_monitor (backend);
if (window->monitor)
window->preferred_output_winsys_id = window->monitor->winsys_id;
else

View File

@ -468,6 +468,9 @@ meta_window_wayland_update_main_monitor (MetaWindow *window,
return;
}
if (window->rect.width == 0 || window->rect.height == 0)
return;
/* Require both the current and the new monitor would be the new main monitor,
* even given the resulting scale the window would end up having. This is
* needed to avoid jumping back and forth between the new and the old, since