mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 19:42:05 +00:00
monitor-manager: use MonitorsConfig to track switch_config
When constructing MetaMonitorsConfig objects, store which type of switch_config they are for (or UNKNOWN if it is not such type of config). Stop unconditionally setting current_switch_config to UNKNOWN when handling monitors changed events. Instead, set it to the switch_config type stored in the MonitorsConfig in the codepath that updates logical state. In addition to being called in the hotplug case along the same code flow that generates monitors changed events, this is also called in the coldplug case where a secondary monitor was connected before mutter was started. When creating the default linear display config, create it as a switch_config so that internal state gets updated to represent linear mode when this config is used. The previous behaviour of unconditionally resetting current_switch_config to UNKNOWN was breaking the internal state machine for display config switching, causing misbehaviour in gnome-shell's switchMonitor UI when using display switch hotkeys. The lack of internal tracking when the displays are already in the default "Join Displays" linear mode was then causing the first display switch hotkey press to do nothing (it would attempt to select "Join Displays" mode, but that was already active). Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/281 https://gitlab.gnome.org/GNOME/mutter/merge_requests/213
This commit is contained in:
parent
95649fd2bc
commit
6267732bec
@ -1017,6 +1017,7 @@ meta_monitor_config_manager_create_for_switch_config (MetaMonitorConfigManager
|
|||||||
MetaMonitorSwitchConfigType config_type)
|
MetaMonitorSwitchConfigType config_type)
|
||||||
{
|
{
|
||||||
MetaMonitorManager *monitor_manager = config_manager->monitor_manager;
|
MetaMonitorManager *monitor_manager = config_manager->monitor_manager;
|
||||||
|
MetaMonitorsConfig *config;
|
||||||
|
|
||||||
if (!meta_monitor_manager_can_switch_config (monitor_manager))
|
if (!meta_monitor_manager_can_switch_config (monitor_manager))
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1024,18 +1025,27 @@ meta_monitor_config_manager_create_for_switch_config (MetaMonitorConfigManager
|
|||||||
switch (config_type)
|
switch (config_type)
|
||||||
{
|
{
|
||||||
case META_MONITOR_SWITCH_CONFIG_ALL_MIRROR:
|
case META_MONITOR_SWITCH_CONFIG_ALL_MIRROR:
|
||||||
return create_for_switch_config_all_mirror (config_manager);
|
config = 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 ();
|
|
||||||
break;
|
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
|
void
|
||||||
@ -1227,6 +1237,19 @@ meta_monitors_config_key_equal (gconstpointer data_a,
|
|||||||
return TRUE;
|
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 *
|
MetaMonitorsConfig *
|
||||||
meta_monitors_config_new_full (GList *logical_monitor_configs,
|
meta_monitors_config_new_full (GList *logical_monitor_configs,
|
||||||
GList *disabled_monitor_specs,
|
GList *disabled_monitor_specs,
|
||||||
@ -1242,6 +1265,7 @@ meta_monitors_config_new_full (GList *logical_monitor_con
|
|||||||
disabled_monitor_specs);
|
disabled_monitor_specs);
|
||||||
config->layout_mode = layout_mode;
|
config->layout_mode = layout_mode;
|
||||||
config->flags = flags;
|
config->flags = flags;
|
||||||
|
config->switch_config = META_MONITOR_SWITCH_CONFIG_UNKNOWN;
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,8 @@ struct _MetaMonitorsConfig
|
|||||||
MetaMonitorsConfigFlag flags;
|
MetaMonitorsConfigFlag flags;
|
||||||
|
|
||||||
MetaLogicalMonitorLayoutMode layout_mode;
|
MetaLogicalMonitorLayoutMode layout_mode;
|
||||||
|
|
||||||
|
MetaMonitorSwitchConfigType switch_config;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define META_TYPE_MONITORS_CONFIG (meta_monitors_config_get_type ())
|
#define META_TYPE_MONITORS_CONFIG (meta_monitors_config_get_type ())
|
||||||
@ -124,6 +126,11 @@ MetaMonitorsConfig * meta_monitors_config_new (MetaMonitorManager *mon
|
|||||||
MetaLogicalMonitorLayoutMode layout_mode,
|
MetaLogicalMonitorLayoutMode layout_mode,
|
||||||
MetaMonitorsConfigFlag flags);
|
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);
|
unsigned int meta_monitors_config_key_hash (gconstpointer config_key);
|
||||||
|
|
||||||
gboolean meta_monitors_config_key_equal (gconstpointer config_key_a,
|
gboolean meta_monitors_config_key_equal (gconstpointer config_key_a,
|
||||||
|
@ -561,7 +561,9 @@ meta_monitor_manager_ensure_configured (MetaMonitorManager *manager)
|
|||||||
g_clear_object (&config);
|
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 (config)
|
||||||
{
|
{
|
||||||
if (!meta_monitor_manager_apply_monitors_config (manager,
|
if (!meta_monitor_manager_apply_monitors_config (manager,
|
||||||
@ -2621,8 +2623,6 @@ meta_monitor_manager_read_current_state (MetaMonitorManager *manager)
|
|||||||
static void
|
static void
|
||||||
meta_monitor_manager_notify_monitors_changed (MetaMonitorManager *manager)
|
meta_monitor_manager_notify_monitors_changed (MetaMonitorManager *manager)
|
||||||
{
|
{
|
||||||
manager->current_switch_config = META_MONITOR_SWITCH_CONFIG_UNKNOWN;
|
|
||||||
|
|
||||||
meta_backend_monitors_changed (manager->backend);
|
meta_backend_monitors_changed (manager->backend);
|
||||||
|
|
||||||
g_signal_emit (manager, signals[MONITORS_CHANGED_INTERNAL], 0);
|
g_signal_emit (manager, signals[MONITORS_CHANGED_INTERNAL], 0);
|
||||||
@ -2679,10 +2679,17 @@ meta_monitor_manager_update_logical_state (MetaMonitorManager *manager,
|
|||||||
MetaMonitorsConfig *config)
|
MetaMonitorsConfig *config)
|
||||||
{
|
{
|
||||||
if (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
|
else
|
||||||
|
{
|
||||||
manager->layout_mode =
|
manager->layout_mode =
|
||||||
meta_monitor_manager_get_default_layout_mode (manager);
|
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);
|
meta_monitor_manager_rebuild_logical_monitors (manager, config);
|
||||||
}
|
}
|
||||||
@ -2724,6 +2731,12 @@ void
|
|||||||
meta_monitor_manager_update_logical_state_derived (MetaMonitorManager *manager,
|
meta_monitor_manager_update_logical_state_derived (MetaMonitorManager *manager,
|
||||||
MetaMonitorsConfig *config)
|
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;
|
manager->layout_mode = META_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL;
|
||||||
|
|
||||||
meta_monitor_manager_rebuild_logical_monitors_derived (manager, config);
|
meta_monitor_manager_rebuild_logical_monitors_derived (manager, config);
|
||||||
|
Loading…
Reference in New Issue
Block a user