diff --git a/src/backends/meta-monitor-config-manager.c b/src/backends/meta-monitor-config-manager.c index 67e7791f0..a3e92f2e7 100644 --- a/src/backends/meta-monitor-config-manager.c +++ b/src/backends/meta-monitor-config-manager.c @@ -1017,6 +1017,7 @@ meta_monitor_config_manager_create_for_switch_config (MetaMonitorConfigManager MetaMonitorSwitchConfigType config_type) { MetaMonitorManager *monitor_manager = config_manager->monitor_manager; + MetaMonitorsConfig *config; if (!meta_monitor_manager_can_switch_config (monitor_manager)) return NULL; @@ -1024,18 +1025,27 @@ meta_monitor_config_manager_create_for_switch_config (MetaMonitorConfigManager switch (config_type) { case META_MONITOR_SWITCH_CONFIG_ALL_MIRROR: - return create_for_switch_config_all_mirror (config_manager); - case META_MONITOR_SWITCH_CONFIG_ALL_LINEAR: - return meta_monitor_config_manager_create_linear (config_manager); - case META_MONITOR_SWITCH_CONFIG_EXTERNAL: - return create_for_switch_config_external (config_manager); - case META_MONITOR_SWITCH_CONFIG_BUILTIN: - return create_for_switch_config_builtin (config_manager); - case META_MONITOR_SWITCH_CONFIG_UNKNOWN: - g_warn_if_reached (); + config = create_for_switch_config_all_mirror (config_manager); break; + case META_MONITOR_SWITCH_CONFIG_ALL_LINEAR: + config = meta_monitor_config_manager_create_linear (config_manager); + break; + case META_MONITOR_SWITCH_CONFIG_EXTERNAL: + config = create_for_switch_config_external (config_manager); + break; + case META_MONITOR_SWITCH_CONFIG_BUILTIN: + config = create_for_switch_config_builtin (config_manager); + break; + case META_MONITOR_SWITCH_CONFIG_UNKNOWN: + default: + g_warn_if_reached (); + return NULL; } - return NULL; + + if (config) + meta_monitors_config_set_switch_config (config, config_type); + + return config; } void @@ -1227,6 +1237,19 @@ meta_monitors_config_key_equal (gconstpointer data_a, return TRUE; } +MetaMonitorSwitchConfigType +meta_monitors_config_get_switch_config (MetaMonitorsConfig *config) +{ + return config->switch_config; +} + +void +meta_monitors_config_set_switch_config (MetaMonitorsConfig *config, + MetaMonitorSwitchConfigType switch_config) +{ + config->switch_config = switch_config; +} + MetaMonitorsConfig * meta_monitors_config_new_full (GList *logical_monitor_configs, GList *disabled_monitor_specs, @@ -1242,6 +1265,7 @@ meta_monitors_config_new_full (GList *logical_monitor_con disabled_monitor_specs); config->layout_mode = layout_mode; config->flags = flags; + config->switch_config = META_MONITOR_SWITCH_CONFIG_UNKNOWN; return config; } diff --git a/src/backends/meta-monitor-config-manager.h b/src/backends/meta-monitor-config-manager.h index 269d8e1b7..900707446 100644 --- a/src/backends/meta-monitor-config-manager.h +++ b/src/backends/meta-monitor-config-manager.h @@ -69,6 +69,8 @@ struct _MetaMonitorsConfig MetaMonitorsConfigFlag flags; MetaLogicalMonitorLayoutMode layout_mode; + + MetaMonitorSwitchConfigType switch_config; }; #define META_TYPE_MONITORS_CONFIG (meta_monitors_config_get_type ()) @@ -124,6 +126,11 @@ MetaMonitorsConfig * meta_monitors_config_new (MetaMonitorManager *mon MetaLogicalMonitorLayoutMode layout_mode, MetaMonitorsConfigFlag flags); +MetaMonitorSwitchConfigType meta_monitors_config_get_switch_config (MetaMonitorsConfig *config); + +void meta_monitors_config_set_switch_config (MetaMonitorsConfig *config, + MetaMonitorSwitchConfigType switch_config); + unsigned int meta_monitors_config_key_hash (gconstpointer config_key); gboolean meta_monitors_config_key_equal (gconstpointer config_key_a, diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c index 3850dd0b9..baed7521d 100644 --- a/src/backends/meta-monitor-manager.c +++ b/src/backends/meta-monitor-manager.c @@ -561,7 +561,9 @@ meta_monitor_manager_ensure_configured (MetaMonitorManager *manager) g_clear_object (&config); } - config = meta_monitor_config_manager_create_linear (manager->config_manager); + config = + meta_monitor_config_manager_create_for_switch_config (manager->config_manager, + META_MONITOR_SWITCH_CONFIG_ALL_LINEAR); if (config) { if (!meta_monitor_manager_apply_monitors_config (manager, @@ -2621,8 +2623,6 @@ meta_monitor_manager_read_current_state (MetaMonitorManager *manager) static void meta_monitor_manager_notify_monitors_changed (MetaMonitorManager *manager) { - manager->current_switch_config = META_MONITOR_SWITCH_CONFIG_UNKNOWN; - meta_backend_monitors_changed (manager->backend); g_signal_emit (manager, signals[MONITORS_CHANGED_INTERNAL], 0); @@ -2679,10 +2679,17 @@ meta_monitor_manager_update_logical_state (MetaMonitorManager *manager, MetaMonitorsConfig *config) { if (config) - manager->layout_mode = config->layout_mode; + { + manager->layout_mode = config->layout_mode; + manager->current_switch_config = + meta_monitors_config_get_switch_config (config); + } else - manager->layout_mode = - meta_monitor_manager_get_default_layout_mode (manager); + { + manager->layout_mode = + meta_monitor_manager_get_default_layout_mode (manager); + manager->current_switch_config = META_MONITOR_SWITCH_CONFIG_UNKNOWN; + } meta_monitor_manager_rebuild_logical_monitors (manager, config); } @@ -2724,6 +2731,12 @@ void meta_monitor_manager_update_logical_state_derived (MetaMonitorManager *manager, MetaMonitorsConfig *config) { + if (config) + manager->current_switch_config = + meta_monitors_config_get_switch_config (config); + else + manager->current_switch_config = META_MONITOR_SWITCH_CONFIG_UNKNOWN; + manager->layout_mode = META_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL; meta_monitor_manager_rebuild_logical_monitors_derived (manager, config);