1
0
Fork 0

monitor-manager: Compare keys when checking whether a config is complete

We only counted configured monitors and whether the config was
applicable (could be assigned), howeverwe didn't include disabled
monitors when comparing. This could caused incorrect configurations to
be applied when trying to use the previous configuration.

One scenario where this happened was one a system with one laptop
screen and one external monitor that was hot plugged some point after
start up. When the laptop lid was closed, the 'previous configuration'
being the configuration where only the laptop panel was enabled, passed
'is-complete' check as the number of configured monitors were correct,
and the configuration was applicable.

Avoid this issue by simply comparing the configuration key of the
previous configuration and the configuration key of the current state.
This correctly identifies a laptop panel with the lid closed as
inaccessible, thus doesn't incorrectly revert to the previous
configuration.

https://bugzilla.gnome.org/show_bug.cgi?id=788915
This commit is contained in:
Jonas Ådahl 2017-11-03 16:03:23 +08:00
parent 62dedfbef3
commit b7518c8651
3 changed files with 16 additions and 29 deletions

View file

@ -327,8 +327,8 @@ meta_monitor_config_manager_assign (MetaMonitorManager *manager,
return TRUE; return TRUE;
} }
static MetaMonitorsConfigKey * MetaMonitorsConfigKey *
create_key_for_current_state (MetaMonitorManager *monitor_manager) meta_create_monitors_config_key_for_current_state (MetaMonitorManager *monitor_manager)
{ {
MetaMonitorsConfigKey *config_key; MetaMonitorsConfigKey *config_key;
GList *l; GList *l;
@ -370,7 +370,8 @@ meta_monitor_config_manager_get_stored (MetaMonitorConfigManager *config_manager
MetaMonitorsConfig *config; MetaMonitorsConfig *config;
GError *error = NULL; GError *error = NULL;
config_key = create_key_for_current_state (monitor_manager); config_key =
meta_create_monitors_config_key_for_current_state (monitor_manager);
if (!config_key) if (!config_key)
return NULL; return NULL;

View file

@ -135,6 +135,8 @@ void meta_logical_monitor_config_free (MetaLogicalMonitorConfig *logical_monitor
void meta_monitor_config_free (MetaMonitorConfig *monitor_config); void meta_monitor_config_free (MetaMonitorConfig *monitor_config);
MetaMonitorsConfigKey * meta_create_monitors_config_key_for_current_state (MetaMonitorManager *monitor_manager);
gboolean meta_logical_monitor_configs_have_monitor (GList *logical_monitor_configs, gboolean meta_logical_monitor_configs_have_monitor (GList *logical_monitor_configs,
MetaMonitorSpec *monitor_spec); MetaMonitorSpec *monitor_spec);

View file

@ -1590,35 +1590,19 @@ static gboolean
meta_monitor_manager_is_config_complete (MetaMonitorManager *manager, meta_monitor_manager_is_config_complete (MetaMonitorManager *manager,
MetaMonitorsConfig *config) MetaMonitorsConfig *config)
{ {
GList *l; MetaMonitorsConfigKey *current_state_key;
unsigned int configured_monitor_count = 0; gboolean is_config_complete;
unsigned int expected_monitor_count = 0;
for (l = config->logical_monitor_configs; l; l = l->next) current_state_key =
{ meta_create_monitors_config_key_for_current_state (manager);
MetaLogicalMonitorConfig *logical_monitor_config = l->data; if (!current_state_key)
GList *k; return FALSE;
for (k = logical_monitor_config->monitor_configs; k; k = k->next) is_config_complete = meta_monitors_config_key_equal (current_state_key,
configured_monitor_count++; config->key);
} meta_monitors_config_key_free (current_state_key);
for (l = manager->monitors; l; l = l->next) if (!is_config_complete)
{
MetaMonitor *monitor = l->data;
if (meta_monitor_is_laptop_panel (monitor))
{
if (!meta_monitor_manager_is_lid_closed (manager))
expected_monitor_count++;
}
else
{
expected_monitor_count++;
}
}
if (configured_monitor_count != expected_monitor_count)
return FALSE; return FALSE;
return meta_monitor_manager_is_config_applicable (manager, config, NULL); return meta_monitor_manager_is_config_applicable (manager, config, NULL);