From e3b9fe7e58af09d1f3a8fdd5c78a2dd4b938cc16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Mon, 19 Dec 2016 14:58:44 +0800 Subject: [PATCH] monitor-manager: Use MetaMonitor to check laptop panel status Instead of looking at the current configuration, just find the MetaMonitor of the laptop display panel and check the currest status directly. https://bugzilla.gnome.org/show_bug.cgi?id=777732 --- src/backends/meta-monitor-manager-private.h | 2 ++ src/backends/meta-monitor-manager.c | 33 ++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/backends/meta-monitor-manager-private.h b/src/backends/meta-monitor-manager-private.h index 0de68a038..641071efe 100644 --- a/src/backends/meta-monitor-manager-private.h +++ b/src/backends/meta-monitor-manager-private.h @@ -348,6 +348,8 @@ MetaLogicalMonitor *meta_monitor_manager_get_logical_monitor_neighbor (MetaMonit MetaLogicalMonitor *logical_monitor, MetaScreenDirection direction); +MetaMonitor * meta_monitor_manager_get_laptop_panel (MetaMonitorManager *manager); + GList * meta_monitor_manager_get_monitors (MetaMonitorManager *manager); MetaOutput *meta_monitor_manager_get_outputs (MetaMonitorManager *manager, diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c index 951cba16d..12854adfe 100644 --- a/src/backends/meta-monitor-manager.c +++ b/src/backends/meta-monitor-manager.c @@ -1198,6 +1198,31 @@ meta_monitor_manager_get_primary_logical_monitor (MetaMonitorManager *manager) return manager->primary_logical_monitor; } +static MetaMonitor * +find_monitor (MetaMonitorManager *monitor_manager, + gboolean (*match_func) (MetaMonitor *monitor)) +{ + GList *monitors; + GList *l; + + monitors = meta_monitor_manager_get_monitors (monitor_manager); + for (l = monitors; l; l = l->next) + { + MetaMonitor *monitor = l->data; + + if (match_func (monitor)) + return monitor; + } + + return NULL; +} + +MetaMonitor * +meta_monitor_manager_get_laptop_panel (MetaMonitorManager *manager) +{ + return find_monitor (manager, meta_monitor_is_laptop_panel); +} + MetaLogicalMonitor * meta_monitor_manager_get_logical_monitor_at (MetaMonitorManager *manager, float x, @@ -1644,7 +1669,13 @@ meta_monitor_manager_get_monitor_for_output (MetaMonitorManager *manager, gboolean meta_monitor_manager_get_is_builtin_display_on (MetaMonitorManager *manager) { + MetaMonitor *laptop_panel; + g_return_val_if_fail (META_IS_MONITOR_MANAGER (manager), FALSE); - return meta_monitor_config_get_is_builtin_display_on (manager->config); + laptop_panel = meta_monitor_manager_get_laptop_panel (manager); + if (!laptop_panel) + return FALSE; + + return meta_monitor_is_active (laptop_panel); }