monitor-manager: Try to restore previous config before regenerating

When opening a laptop lid, one will likely want to restore the
configuration one had prior to closing it, so when ensuring monitor
configuration, first try to see if the previously set configuration is
both complete (all connected monitors are configured) and applicable
(it is a valid configuration) and only try to generate a new from
scratch if that failed.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
This commit is contained in:
Jonas Ådahl
2017-08-11 15:21:36 +08:00
parent 8b92ad1d4b
commit 35c9280fb6
2 changed files with 73 additions and 19 deletions

View File

@ -2281,33 +2281,20 @@ meta_test_monitor_lid_switch_config (void)
meta_monitor_manager_test_set_is_lid_closed (monitor_manager_test, FALSE);
meta_monitor_manager_lid_is_closed_changed (monitor_manager);
test_case.expect.n_logical_monitors = 2;
test_case.expect.screen_width = 1024 * 2;
test_case.expect.monitors[0].current_mode = 0;
test_case.expect.crtcs[0].current_mode = 0;
test_case.expect.crtcs[1].current_mode = 0;
/*
* FIXME: The above expectation is correct, but MetaMonitorConfigManager
* doesn't support restoring previous configurations yet, so it'll
* pick keep the external monitor as primary and put it first.
*/
test_case.expect.logical_monitors[0] = (MonitorTestCaseLogicalMonitor) {
.monitors = { 1 },
.monitors = { 0 },
.n_monitors = 1,
.layout = {.x = 0, .y = 0, .width = 1024, .height = 768 },
.scale = 1
};
test_case.expect.logical_monitors[1] = (MonitorTestCaseLogicalMonitor) {
.monitors = { 0 },
.n_monitors = 1,
.layout = {.x = 1024, .y = 0, .width = 1024, .height = 768 },
.scale = 1
};
test_case.expect.n_logical_monitors = 2;
test_case.expect.screen_width = 1024 * 2;
test_case.expect.monitors[0].current_mode = 0;
test_case.expect.primary_logical_monitor = 0;
test_case.expect.crtcs[0].current_mode = 0;
test_case.expect.crtcs[1].current_mode = 0;
check_monitor_configuration (&test_case);
}