monitor: Use current monitor mode to check whether active
authorJonas Ådahl <jadahl@gmail.com>
Tue, 31 Jul 2018 11:18:51 +0000 (13:18 +0200)
committerSimon McVittie <smcv@debian.org>
Tue, 31 Jul 2018 14:35:03 +0000 (15:35 +0100)
commit9e085bc743374fb79657f8599ca29e29f093d2df
tree3c081e1b3d711101ebf635f583ceef1976b9ef10
parent8a6d1e0d41a2d3a2ed02b57f2061e19026fb038f
monitor: Use current monitor mode to check whether active

For historical reasons meta_monitor_is_active() checked whether it is
active by checking whether the main output have a CRTC assigned and
whether that CRTC has a current mode. At a later point, the MetaMonitor
got its own mode abstraction (MetaMonitorMode), but
meta_monitor_is_active() was never updated to use this.

An issue with checking the main output's CRTC state is that, if there is
some CRTC mode combination that for some reason isn't properly detected
by the MetaMonitorMode abstraction (e.g. some tiling configuration not
yet handled), meta_monitor_is_active() would return TRUE, even though no
(abstracted) mode was set. This would cause confusion here and there,
leading to NULL pointer dereferences due to the assumption that if a
monitor is active, it has an active mode.

Instead, change meta_monitor_is_active() to directly check the current
monitor mode, and log a warning if the main output still happen to have
a CRTC with a mode assigned to it. This way, when an not undrestood CRTC
mode combination is encountered, instead of dereferencing NULL pointers,
simply assume the monitor is not active, which means that it will not be
managed or rendered by mutter at all.

https://gitlab.gnome.org/GNOME/mutter/issues/130

(cherry picked from commit 4d465eac0806eb1ead375e2852d4a9d6bc24524f)

Bug-GNOME: https://gitlab.gnome.org/GNOME/mutter/issues/130
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/gnome-shell/+bug/1723615
Applied-Upstream: 3.28.4, commit:https://gitlab.gnome.org/GNOME/mutter/commit/d0d80780

Gbp-Pq: Name monitor-Use-current-monitor-mode-to-check-whether-active.patch
src/backends/meta-monitor.c