mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 00:20:42 -05:00
window: Add monitor finder using stored IDs
This will be used to find new monitors on e.g. "winsys ID" of previous monitors. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2554>
This commit is contained in:
parent
cf848c577e
commit
4ed9653757
@ -851,6 +851,8 @@ void meta_window_activate_full (MetaWindow *window,
|
||||
META_EXPORT_TEST
|
||||
MetaLogicalMonitor * meta_window_find_monitor_from_frame_rect (MetaWindow *window);
|
||||
|
||||
MetaLogicalMonitor * meta_window_find_monitor_from_id (MetaWindow *window);
|
||||
|
||||
MetaLogicalMonitor * meta_window_get_main_logical_monitor (MetaWindow *window);
|
||||
void meta_window_update_monitor (MetaWindow *window,
|
||||
MetaWindowUpdateMonitorFlags flags);
|
||||
|
@ -3647,6 +3647,31 @@ find_monitor_by_winsys_id (MetaWindow *window,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
MetaLogicalMonitor *
|
||||
meta_window_find_monitor_from_id (MetaWindow *window)
|
||||
{
|
||||
MetaContext *context = meta_display_get_context (window->display);
|
||||
MetaBackend *backend = meta_context_get_backend (context);
|
||||
MetaMonitorManager *monitor_manager =
|
||||
meta_backend_get_monitor_manager (backend);
|
||||
MetaLogicalMonitor *old_monitor = window->monitor;
|
||||
MetaLogicalMonitor *new_monitor;
|
||||
|
||||
new_monitor = find_monitor_by_winsys_id (window,
|
||||
window->preferred_output_winsys_id);
|
||||
|
||||
if (old_monitor && !new_monitor)
|
||||
new_monitor = find_monitor_by_winsys_id (window, old_monitor->winsys_id);
|
||||
|
||||
if (!new_monitor)
|
||||
{
|
||||
new_monitor =
|
||||
meta_monitor_manager_get_primary_logical_monitor (monitor_manager);
|
||||
}
|
||||
|
||||
return new_monitor;
|
||||
}
|
||||
|
||||
/* This is called when the monitor setup has changed. The window->monitor
|
||||
* reference is still "valid", but refer to the previous monitor setup */
|
||||
void
|
||||
@ -3669,17 +3694,7 @@ meta_window_update_for_monitors_changed (MetaWindow *window)
|
||||
}
|
||||
|
||||
old = window->monitor;
|
||||
|
||||
/* Try the preferred output first */
|
||||
new = find_monitor_by_winsys_id (window, window->preferred_output_winsys_id);
|
||||
|
||||
/* Otherwise, try to find the old output on a new monitor */
|
||||
if (old && !new)
|
||||
new = find_monitor_by_winsys_id (window, old->winsys_id);
|
||||
|
||||
/* Fall back to primary if everything else failed */
|
||||
if (!new)
|
||||
new = meta_monitor_manager_get_primary_logical_monitor (monitor_manager);
|
||||
new = meta_window_find_monitor_from_id (window);
|
||||
|
||||
if (window->tile_mode != META_TILE_NONE)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user