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

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