From f4f823f2380b94e97f7d7952bae200ab7e791699 Mon Sep 17 00:00:00 2001 From: Emilio Pozuelo Monfort Date: Tue, 6 Nov 2018 15:03:50 +0100 Subject: [PATCH] monitor-config-manager: reuse old CRTC when possible We shouldn't change an output's CRTC if we don't have to, as that causes the output to go black. This patch depends on "monitor-unit-tests: initial crtcs in custom_lid_switch". https://gitlab.gnome.org/GNOME/mutter/issues/373 --- src/backends/meta-monitor-config-manager.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/backends/meta-monitor-config-manager.c b/src/backends/meta-monitor-config-manager.c index 431f1c1c3..335c3f34b 100644 --- a/src/backends/meta-monitor-config-manager.c +++ b/src/backends/meta-monitor-config-manager.c @@ -2,6 +2,7 @@ /* * Copyright (C) 2016 Red Hat + * Copyright (c) 2018 DisplayLink (UK) Ltd. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -96,11 +97,16 @@ static MetaCrtc * find_unassigned_crtc (MetaOutput *output, GPtrArray *crtc_infos) { + MetaCrtc *crtc; unsigned int i; + crtc = meta_output_get_assigned_crtc (output); + if (crtc && !is_crtc_assigned (crtc, crtc_infos)) + return crtc; + for (i = 0; i < output->n_possible_crtcs; i++) { - MetaCrtc *crtc = output->possible_crtcs[i]; + crtc = output->possible_crtcs[i]; if (is_crtc_assigned (crtc, crtc_infos)) continue;