Blame SOURCES/0001-monitor-Use-current-monitor-mode-to-check-whether-ac.patch

f73620
From 22d626580cd84136b54ca1154852da6f990c00a2 Mon Sep 17 00:00:00 2001
f73620
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
f73620
Date: Tue, 31 Jul 2018 11:18:51 +0000
f73620
Subject: [PATCH 1/2] monitor: Use current monitor mode to check whether active
f73620
f73620
For historical reasons meta_monitor_is_active() checked whether it is
f73620
active by checking whether the main output have a CRTC assigned and
f73620
whether that CRTC has a current mode. At a later point, the MetaMonitor
f73620
got its own mode abstraction (MetaMonitorMode), but
f73620
meta_monitor_is_active() was never updated to use this.
f73620
f73620
An issue with checking the main output's CRTC state is that, if there is
f73620
some CRTC mode combination that for some reason isn't properly detected
f73620
by the MetaMonitorMode abstraction (e.g. some tiling configuration not
f73620
yet handled), meta_monitor_is_active() would return TRUE, even though no
f73620
(abstracted) mode was set. This would cause confusion here and there,
f73620
leading to NULL pointer dereferences due to the assumption that if a
f73620
monitor is active, it has an active mode.
f73620
f73620
Instead, change meta_monitor_is_active() to directly check the current
f73620
monitor mode, and log a warning if the main output still happen to have
f73620
a CRTC with a mode assigned to it. This way, when an not undrestood CRTC
f73620
mode combination is encountered, instead of dereferencing NULL pointers,
f73620
simply assume the monitor is not active, which means that it will not be
f73620
managed or rendered by mutter at all.
f73620
f73620
https://gitlab.gnome.org/GNOME/mutter/issues/130
f73620
f73620
f73620
(cherry picked from commit 4d465eac0806eb1ead375e2852d4a9d6bc24524f)
f73620
---
f73620
 src/backends/meta-monitor.c | 22 ++++++++++++++++------
f73620
 1 file changed, 16 insertions(+), 6 deletions(-)
f73620
f73620
diff --git a/src/backends/meta-monitor.c b/src/backends/meta-monitor.c
f73620
index 98330661e..9a412a612 100644
f73620
--- a/src/backends/meta-monitor.c
f73620
+++ b/src/backends/meta-monitor.c
f73620
@@ -203,13 +203,9 @@ meta_monitor_get_main_output (MetaMonitor *monitor)
f73620
 gboolean
f73620
 meta_monitor_is_active (MetaMonitor *monitor)
f73620
 {
f73620
-  MetaOutput *output;
f73620
-  MetaCrtc *crtc;
f73620
-
f73620
-  output = meta_monitor_get_main_output (monitor);
f73620
-  crtc = meta_output_get_assigned_crtc (output);
f73620
+  MetaMonitorPrivate *priv = meta_monitor_get_instance_private (monitor);
f73620
 
f73620
-  return crtc && crtc->current_mode;
f73620
+  return !!priv->current_mode;
f73620
 }
f73620
 
f73620
 gboolean
f73620
@@ -1411,6 +1407,18 @@ meta_monitor_get_current_mode (MetaMonitor *monitor)
f73620
   return priv->current_mode;
f73620
 }
f73620
 
f73620
+static gboolean
f73620
+is_current_mode_known (MetaMonitor *monitor)
f73620
+{
f73620
+  MetaOutput *output;
f73620
+  MetaCrtc *crtc;
f73620
+
f73620
+  output = meta_monitor_get_main_output (monitor);
f73620
+  crtc = meta_output_get_assigned_crtc (output);
f73620
+
f73620
+  return meta_monitor_is_active (monitor) == (crtc && crtc->current_mode);
f73620
+}
f73620
+
f73620
 void
f73620
 meta_monitor_derive_current_mode (MetaMonitor *monitor)
f73620
 {
f73620
@@ -1430,6 +1438,8 @@ meta_monitor_derive_current_mode (MetaMonitor *monitor)
f73620
     }
f73620
 
f73620
   priv->current_mode = current_mode;
f73620
+
f73620
+  g_warn_if_fail (is_current_mode_known (monitor));
f73620
 }
f73620
 
f73620
 void
f73620
-- 
f73620
2.21.0
f73620