[mutter] window: Add monitor finder using stored IDs
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] window: Add monitor finder using stored IDs
- Date: Thu, 11 Aug 2022 12:06:31 +0000 (UTC)
commit 4ed965375758ac48887b887b80128730170c8a4c
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Wed Aug 3 22:59:16 2022 +0200
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>
src/core/window-private.h | 2 ++
src/core/window.c | 37 ++++++++++++++++++++++++++-----------
2 files changed, 28 insertions(+), 11 deletions(-)
---
diff --git a/src/core/window-private.h b/src/core/window-private.h
index fce2a4727e..4f269ff37a 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -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);
diff --git a/src/core/window.c b/src/core/window.c
index 621abd9a59..0a1a97547c 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -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)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]