[mutter] monitor-manager: Pass config to derive from when updating state
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] monitor-manager: Pass config to derive from when updating state
- Date: Wed, 20 Sep 2017 09:39:26 +0000 (UTC)
commit 22cdc8f41442413740c6d80bf68ffa62cd4b8793
Author: Jonas Ådahl <jadahl gmail com>
Date: Mon Sep 11 14:10:26 2017 +0800
monitor-manager: Pass config to derive from when updating state
When we update state, we might not have set the current config yet (for
example if the Xrandr assignment didn't change), so pass the monitors
config we should derive from instead of fetching it from the monitor
config manager.
https://bugzilla.gnome.org/show_bug.cgi?id=787477
src/backends/meta-monitor-manager-dummy.c | 7 +---
src/backends/meta-monitor-manager-private.h | 17 ++++-----
src/backends/meta-monitor-manager.c | 45 +++++++++++-------------
src/backends/x11/meta-monitor-manager-xrandr.c | 35 ++++++++++--------
src/tests/meta-monitor-manager-test.c | 27 +++-----------
5 files changed, 53 insertions(+), 78 deletions(-)
---
diff --git a/src/backends/meta-monitor-manager-dummy.c b/src/backends/meta-monitor-manager-dummy.c
index 004374a..dfc14da 100644
--- a/src/backends/meta-monitor-manager-dummy.c
+++ b/src/backends/meta-monitor-manager-dummy.c
@@ -353,12 +353,7 @@ meta_monitor_manager_dummy_ensure_initial_config (MetaMonitorManager *manager)
if (meta_is_stage_views_enabled ())
meta_monitor_manager_update_logical_state (manager, config);
else
- {
- MetaMonitorManagerDeriveFlag flags =
- META_MONITOR_MANAGER_DERIVE_FLAG_NONE;
-
- meta_monitor_manager_update_logical_state_derived (manager, flags);
- }
+ meta_monitor_manager_update_logical_state_derived (manager, NULL);
}
static void
diff --git a/src/backends/meta-monitor-manager-private.h b/src/backends/meta-monitor-manager-private.h
index 707d639..072e765 100644
--- a/src/backends/meta-monitor-manager-private.h
+++ b/src/backends/meta-monitor-manager-private.h
@@ -93,12 +93,6 @@ typedef enum _MetaLogicalMonitorLayoutMode
META_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL = 2
} MetaLogicalMonitorLayoutMode;
-typedef enum _MetaMonitorManagerDeriveFlag
-{
- META_MONITOR_MANAGER_DERIVE_FLAG_NONE = 0,
- META_MONITOR_MANAGER_DERIVE_FLAG_CONFIGURED_SCALE = (1 << 0)
-} MetaMonitorManagerDeriveFlag;
-
typedef enum
{
META_MONITOR_TRANSFORM_NORMAL,
@@ -422,8 +416,8 @@ struct _MetaMonitorManagerClass
void meta_monitor_manager_rebuild (MetaMonitorManager *manager,
MetaMonitorsConfig *config);
-void meta_monitor_manager_rebuild_derived (MetaMonitorManager *manager,
- MetaMonitorManagerDeriveFlag flags);
+void meta_monitor_manager_rebuild_derived (MetaMonitorManager *manager,
+ MetaMonitorsConfig *config);
int meta_monitor_manager_get_num_logical_monitors (MetaMonitorManager *manager);
@@ -500,8 +494,8 @@ MetaMonitorsConfig * meta_monitor_manager_ensure_configured (MetaMonitorManager
void meta_monitor_manager_update_logical_state (MetaMonitorManager *manager,
MetaMonitorsConfig *config);
-void meta_monitor_manager_update_logical_state_derived (MetaMonitorManager *manager,
- MetaMonitorManagerDeriveFlag flags);
+void meta_monitor_manager_update_logical_state_derived (MetaMonitorManager *manager,
+ MetaMonitorsConfig *config);
gboolean meta_monitor_manager_is_lid_closed (MetaMonitorManager *manager);
@@ -535,6 +529,9 @@ gboolean meta_monitor_manager_get_max_screen_size (MetaMonitorManager
MetaLogicalMonitorLayoutMode
meta_monitor_manager_get_default_layout_mode (MetaMonitorManager *manager);
+MetaMonitorConfigManager *
+ meta_monitor_manager_get_config_manager (MetaMonitorManager *manager);
+
void meta_monitor_manager_rotate_monitor (MetaMonitorManager *manager);
void meta_monitor_manager_clear_output (MetaOutput *output);
diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c
index 404dbcd..3e0d980 100644
--- a/src/backends/meta-monitor-manager.c
+++ b/src/backends/meta-monitor-manager.c
@@ -153,15 +153,11 @@ meta_monitor_manager_rebuild_logical_monitors (MetaMonitorManager *manager,
}
static float
-derive_configured_global_scale (MetaMonitorManager *manager)
+derive_configured_global_scale (MetaMonitorManager *manager,
+ MetaMonitorsConfig *config)
{
- MetaMonitorsConfig *config;
MetaLogicalMonitorConfig *logical_monitor_config;
- config = meta_monitor_config_manager_get_current (manager->config_manager);
- if (!config)
- return 1.0;
-
logical_monitor_config = config->logical_monitor_configs->data;
return logical_monitor_config->scale;
@@ -193,12 +189,11 @@ derive_calculated_global_scale (MetaMonitorManager *manager)
static float
derive_scale_from_config (MetaMonitorManager *manager,
+ MetaMonitorsConfig *config,
MetaRectangle *layout)
{
- MetaMonitorsConfig *config;
GList *l;
- config = meta_monitor_config_manager_get_current (manager->config_manager);
for (l = config->logical_monitor_configs; l; l = l->next)
{
MetaLogicalMonitorConfig *logical_monitor_config = l->data;
@@ -212,14 +207,13 @@ derive_scale_from_config (MetaMonitorManager *manager,
}
static void
-meta_monitor_manager_rebuild_logical_monitors_derived (MetaMonitorManager *manager,
- MetaMonitorManagerDeriveFlag flags)
+meta_monitor_manager_rebuild_logical_monitors_derived (MetaMonitorManager *manager,
+ MetaMonitorsConfig *config)
{
GList *logical_monitors = NULL;
GList *l;
int monitor_number;
MetaLogicalMonitor *primary_logical_monitor = NULL;
- gboolean use_configured_scale;
gboolean use_global_scale;
float global_scale = 0.0;
MetaMonitorManagerCapability capabilities;
@@ -230,13 +224,10 @@ meta_monitor_manager_rebuild_logical_monitors_derived (MetaMonitorManager
use_global_scale =
!!(capabilities & META_MONITOR_MANAGER_CAPABILITY_GLOBAL_SCALE_REQUIRED);
- use_configured_scale =
- !!(flags & META_MONITOR_MANAGER_DERIVE_FLAG_CONFIGURED_SCALE);
-
if (use_global_scale)
{
- if (use_configured_scale)
- global_scale = derive_configured_global_scale (manager);
+ if (config)
+ global_scale = derive_configured_global_scale (manager, config);
else
global_scale = derive_calculated_global_scale (manager);
}
@@ -263,8 +254,8 @@ meta_monitor_manager_rebuild_logical_monitors_derived (MetaMonitorManager
if (use_global_scale)
scale = global_scale;
- else if (use_configured_scale)
- scale = derive_scale_from_config (manager, &layout);
+ else if (config)
+ scale = derive_scale_from_config (manager, config, &layout);
else
scale = calculate_monitor_scale (manager, monitor);
@@ -2676,17 +2667,17 @@ meta_monitor_manager_update_monitor_modes_derived (MetaMonitorManager *manager)
}
void
-meta_monitor_manager_update_logical_state_derived (MetaMonitorManager *manager,
- MetaMonitorManagerDeriveFlag flags)
+meta_monitor_manager_update_logical_state_derived (MetaMonitorManager *manager,
+ MetaMonitorsConfig *config)
{
manager->layout_mode = META_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL;
- meta_monitor_manager_rebuild_logical_monitors_derived (manager, flags);
+ meta_monitor_manager_rebuild_logical_monitors_derived (manager, config);
}
void
-meta_monitor_manager_rebuild_derived (MetaMonitorManager *manager,
- MetaMonitorManagerDeriveFlag flags)
+meta_monitor_manager_rebuild_derived (MetaMonitorManager *manager,
+ MetaMonitorsConfig *config)
{
GList *old_logical_monitors;
@@ -2697,7 +2688,7 @@ meta_monitor_manager_rebuild_derived (MetaMonitorManager *manager,
old_logical_monitors = manager->logical_monitors;
- meta_monitor_manager_update_logical_state_derived (manager, flags);
+ meta_monitor_manager_update_logical_state_derived (manager, config);
meta_monitor_manager_notify_monitors_changed (manager);
@@ -2966,3 +2957,9 @@ meta_monitor_manager_get_switch_config (MetaMonitorManager *manager)
{
return manager->current_switch_config;
}
+
+MetaMonitorConfigManager *
+meta_monitor_manager_get_config_manager (MetaMonitorManager *manager)
+{
+ return manager->config_manager;
+}
diff --git a/src/backends/x11/meta-monitor-manager-xrandr.c b/src/backends/x11/meta-monitor-manager-xrandr.c
index 7384264..c369d49 100644
--- a/src/backends/x11/meta-monitor-manager-xrandr.c
+++ b/src/backends/x11/meta-monitor-manager-xrandr.c
@@ -1464,7 +1464,9 @@ apply_crtc_assignments (MetaMonitorManager *manager,
static void
meta_monitor_manager_xrandr_ensure_initial_config (MetaMonitorManager *manager)
{
- MetaMonitorManagerDeriveFlag flags;
+ MetaMonitorConfigManager *config_manager =
+ meta_monitor_manager_get_config_manager (manager);
+ MetaMonitorsConfig *config;
meta_monitor_manager_ensure_configured (manager);
@@ -1475,8 +1477,8 @@ meta_monitor_manager_xrandr_ensure_initial_config (MetaMonitorManager *manager)
*/
meta_monitor_manager_read_current_state (manager);
- flags = META_MONITOR_MANAGER_DERIVE_FLAG_CONFIGURED_SCALE;
- meta_monitor_manager_update_logical_state_derived (manager, flags);
+ config = meta_monitor_config_manager_get_current (config_manager);
+ meta_monitor_manager_update_logical_state_derived (manager, config);
}
static gboolean
@@ -1490,10 +1492,7 @@ meta_monitor_manager_xrandr_apply_monitors_config (MetaMonitorManager *mana
if (!config)
{
- MetaMonitorManagerDeriveFlag flags =
- META_MONITOR_MANAGER_DERIVE_FLAG_NONE;
-
- meta_monitor_manager_rebuild_derived (manager, flags);
+ meta_monitor_manager_rebuild_derived (manager, NULL);
return TRUE;
}
@@ -1527,11 +1526,7 @@ meta_monitor_manager_xrandr_apply_monitors_config (MetaMonitorManager *mana
}
else
{
- MetaMonitorManagerDeriveFlag flags;
-
- flags = (META_MONITOR_MANAGER_DERIVE_FLAG_NONE |
- META_MONITOR_MANAGER_DERIVE_FLAG_CONFIGURED_SCALE);
- meta_monitor_manager_rebuild_derived (manager, flags);
+ meta_monitor_manager_rebuild_derived (manager, config);
}
}
@@ -1940,13 +1935,21 @@ meta_monitor_manager_xrandr_handle_xevent (MetaMonitorManagerXrandr *manager_xra
}
else
{
- MetaMonitorManagerDeriveFlag flags =
- META_MONITOR_MANAGER_DERIVE_FLAG_NONE;
+ MetaMonitorsConfig *config;
if (is_our_configuration)
- flags |= META_MONITOR_MANAGER_DERIVE_FLAG_CONFIGURED_SCALE;
+ {
+ MetaMonitorConfigManager *config_manager =
+ meta_monitor_manager_get_config_manager (manager);
+
+ config = meta_monitor_config_manager_get_current (config_manager);
+ }
+ else
+ {
+ config = NULL;
+ }
- meta_monitor_manager_rebuild_derived (manager, flags);
+ meta_monitor_manager_rebuild_derived (manager, config);
}
return TRUE;
diff --git a/src/tests/meta-monitor-manager-test.c b/src/tests/meta-monitor-manager-test.c
index 3e105de..a457b90 100644
--- a/src/tests/meta-monitor-manager-test.c
+++ b/src/tests/meta-monitor-manager-test.c
@@ -123,10 +123,7 @@ meta_monitor_manager_test_ensure_initial_config (MetaMonitorManager *manager)
}
else
{
- MetaMonitorManagerDeriveFlag flags =
- META_MONITOR_MANAGER_DERIVE_FLAG_NONE;
-
- meta_monitor_manager_update_logical_state_derived (manager, flags);
+ meta_monitor_manager_update_logical_state_derived (manager, NULL);
}
}
@@ -280,16 +277,9 @@ meta_monitor_manager_test_apply_monitors_config (MetaMonitorManager *manage
manager->screen_height = META_MONITOR_MANAGER_MIN_SCREEN_HEIGHT;
if (meta_is_stage_views_enabled ())
- {
- meta_monitor_manager_rebuild (manager, NULL);
- }
+ meta_monitor_manager_rebuild (manager, NULL);
else
- {
- MetaMonitorManagerDeriveFlag flags =
- META_MONITOR_MANAGER_DERIVE_FLAG_CONFIGURED_SCALE;
-
- meta_monitor_manager_rebuild_derived (manager, flags);
- }
+ meta_monitor_manager_rebuild_derived (manager, config);
return TRUE;
}
@@ -319,16 +309,9 @@ meta_monitor_manager_test_apply_monitors_config (MetaMonitorManager *manage
update_screen_size (manager, config);
if (meta_is_stage_views_enabled ())
- {
- meta_monitor_manager_rebuild (manager, config);
- }
+ meta_monitor_manager_rebuild (manager, config);
else
- {
- MetaMonitorManagerDeriveFlag flags =
- META_MONITOR_MANAGER_DERIVE_FLAG_CONFIGURED_SCALE;
-
- meta_monitor_manager_rebuild_derived (manager, flags);
- }
+ meta_monitor_manager_rebuild_derived (manager, config);
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]