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

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