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
This commit is contained in:
Emilio Pozuelo Monfort 2018-11-06 15:03:50 +01:00 committed by Pekka Paalanen
parent 1c67260bd4
commit f4f823f238

View File

@ -2,6 +2,7 @@
/* /*
* Copyright (C) 2016 Red Hat * Copyright (C) 2016 Red Hat
* Copyright (c) 2018 DisplayLink (UK) Ltd.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
@ -96,11 +97,16 @@ static MetaCrtc *
find_unassigned_crtc (MetaOutput *output, find_unassigned_crtc (MetaOutput *output,
GPtrArray *crtc_infos) GPtrArray *crtc_infos)
{ {
MetaCrtc *crtc;
unsigned int i; 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++) 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)) if (is_crtc_assigned (crtc, crtc_infos))
continue; continue;