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