Commit b7afc0ac authored by Jonas Ådahl's avatar Jonas Ådahl Committed by Alberts Muktupāvels
Browse files

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
parent 568d351c
......@@ -25,6 +25,7 @@
#include "gf-logical-monitor-config-private.h"
#include "gf-monitor-config-private.h"
#include "gf-monitor-manager-private.h"
#include "gf-monitors-config-private.h"
......@@ -71,6 +72,8 @@ void gf_monitor_config_manager_clear_history (GfM
void gf_monitor_config_manager_save_current (GfMonitorConfigManager *config_manager);
GfMonitorsConfigKey *gf_create_monitors_config_key_for_current_state (GfMonitorManager *monitor_manager);
......@@ -644,8 +644,8 @@ assign_logical_monitor_crtcs (GfMonitorManager *manager,
return TRUE;
static GfMonitorsConfigKey *
create_key_for_current_state (GfMonitorManager *monitor_manager)
GfMonitorsConfigKey *
gf_create_monitors_config_key_for_current_state (GfMonitorManager *monitor_manager)
GfMonitorsConfigKey *config_key;
GList *l;
......@@ -778,7 +778,7 @@ gf_monitor_config_manager_get_stored (GfMonitorConfigManager *config_manager)
GfMonitorsConfig *config;
GError *error = NULL;
config_key = create_key_for_current_state (monitor_manager);
config_key = gf_create_monitors_config_key_for_current_state (monitor_manager);
if (!config_key)
return NULL;
......@@ -271,35 +271,17 @@ static gboolean
gf_monitor_manager_is_config_complete (GfMonitorManager *manager,
GfMonitorsConfig *config)
GList *l;
guint configured_monitor_count = 0;
guint expected_monitor_count = 0;
for (l = config->logical_monitor_configs; l; l = l->next)
GfLogicalMonitorConfig *logical_monitor_config = l->data;
GList *k;
GfMonitorsConfigKey *current_state_key;
gboolean is_config_complete;
for (k = logical_monitor_config->monitor_configs; k; k = k->next)
for (l = manager->monitors; l; l = l->next)
GfMonitor *monitor = l->data;
current_state_key = gf_create_monitors_config_key_for_current_state (manager);
if (!current_state_key)
return FALSE;
if (gf_monitor_is_laptop_panel (monitor))
if (!gf_monitor_manager_is_lid_closed (manager))
is_config_complete = gf_monitors_config_key_equal (current_state_key, config->key);
gf_monitors_config_key_free (current_state_key);
if (configured_monitor_count != expected_monitor_count)
if (!is_config_complete)
return FALSE;
return gf_monitor_manager_is_config_applicable (manager, config, NULL);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment