diff --git a/src/backends/meta-monitor-manager-dummy.c b/src/backends/meta-monitor-manager-dummy.c index 004374a17..dfc14da0d 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 707d639d8..072e7659a 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 404dbcddd..3e0d980fb 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 73842648f..c369d4960 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); - meta_monitor_manager_rebuild_derived (manager, flags); + config = meta_monitor_config_manager_get_current (config_manager); + } + else + { + config = NULL; + } + + 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 3e105de11..a457b9006 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; }