Blame SOURCES/0001-monitor-manager-xrandr-Work-around-spurious-hotplugs.patch

41c151
From ad61347e9d92380fbbb4effd8a19349777d76715 Mon Sep 17 00:00:00 2001
2c033f
From: Rui Matos <tiagomatos@gmail.com>
2c033f
Date: Tue, 6 Oct 2015 21:16:18 +0200
41c151
Subject: [PATCH] monitor-manager-xrandr: Work around spurious hotplugs on Xvnc
2c033f
2c033f
Xvnc turns its outputs off/on on every mode set which makes us believe
2c033f
there was an hotplug when there actually wasn't. Work around this by
2c033f
requiring new randr configuration timestamps to be ahead of the last
2c033f
set timestamp by at least 100 ms for us to consider them an actual
2c033f
hotplug.
2c033f
---
41c151
 .../x11/meta-monitor-manager-xrandr.c         | 25 ++++++++++++++++++-
41c151
 1 file changed, 24 insertions(+), 1 deletion(-)
2c033f
2c033f
diff --git a/src/backends/x11/meta-monitor-manager-xrandr.c b/src/backends/x11/meta-monitor-manager-xrandr.c
41c151
index dbe3e4e3b..90a3952db 100644
2c033f
--- a/src/backends/x11/meta-monitor-manager-xrandr.c
2c033f
+++ b/src/backends/x11/meta-monitor-manager-xrandr.c
41c151
@@ -1058,6 +1058,24 @@ meta_monitor_manager_xrandr_class_init (MetaMonitorManagerXrandrClass *klass)
e47e58
     g_quark_from_static_string ("-meta-monitor-xrandr-data");
2c033f
 }
2c033f
 
2c033f
+static gboolean
2c033f
+is_xvnc (MetaMonitorManager *manager)
2c033f
+{
41c151
+  MetaMonitorManagerXrandr *manager_xrandr =
41c151
+    META_MONITOR_MANAGER_XRANDR (manager);
41c151
+  GList *l;
2c033f
+
41c151
+  for (l = meta_gpu_get_outputs (manager_xrandr->gpu); l; l = l->next)
41c151
+    {
41c151
+      MetaOutput *output = l->data;
41c151
+
41c151
+      if (g_str_has_prefix (output->name, "VNC-"))
41c151
+        return TRUE;
41c151
+    }
2c033f
+
2c033f
+  return FALSE;
2c033f
+}
2c033f
+
2c033f
 gboolean
2c033f
 meta_monitor_manager_xrandr_handle_xevent (MetaMonitorManagerXrandr *manager_xrandr,
2c033f
 					   XEvent                   *event)
41c151
@@ -1067,6 +1085,7 @@ meta_monitor_manager_xrandr_handle_xevent (MetaMonitorManagerXrandr *manager_xra
41c151
   XRRScreenResources *resources;
e47e58
   gboolean is_hotplug;
e47e58
   gboolean is_our_configuration;
2c033f
+  unsigned int timestamp;
2c033f
 
2c033f
   if ((event->type - manager_xrandr->rr_event_base) != RRScreenChangeNotify)
2c033f
     return FALSE;
41c151
@@ -1078,7 +1097,11 @@ meta_monitor_manager_xrandr_handle_xevent (MetaMonitorManagerXrandr *manager_xra
41c151
   gpu_xrandr = META_GPU_XRANDR (manager_xrandr->gpu);
41c151
   resources = meta_gpu_xrandr_get_resources (gpu_xrandr);
67f8b7
 
41c151
-  is_hotplug = resources->timestamp < resources->configTimestamp;
41c151
+  timestamp = resources->timestamp;
2c033f
+  if (is_xvnc (manager))
2c033f
+    timestamp += 100;
2c033f
+
41c151
+  is_hotplug = timestamp < resources->configTimestamp;
41c151
   is_our_configuration = (resources->timestamp ==
e47e58
                           manager_xrandr->last_xrandr_set_timestamp);
e47e58
   if (is_hotplug)
2c033f
-- 
41c151
2.17.0
2c033f