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

db633a
From 257c8e8d3b7103973dfdc2665d210c63496be457 Mon Sep 17 00:00:00 2001
db633a
From: Rui Matos <tiagomatos@gmail.com>
db633a
Date: Tue, 6 Oct 2015 21:16:18 +0200
db633a
Subject: [PATCH] monitor-manager-xrandr: Work around spurious hotplugs on Xvnc
db633a
db633a
Xvnc turns its outputs off/on on every mode set which makes us believe
db633a
there was an hotplug when there actually wasn't. Work around this by
db633a
requiring new randr configuration timestamps to be ahead of the last
db633a
set timestamp by at least 100 ms for us to consider them an actual
db633a
hotplug.
db633a
---
db633a
 src/backends/x11/meta-monitor-manager-xrandr.c | 19 ++++++++++++++++++-
db633a
 1 file changed, 18 insertions(+), 1 deletion(-)
db633a
db633a
diff --git a/src/backends/x11/meta-monitor-manager-xrandr.c b/src/backends/x11/meta-monitor-manager-xrandr.c
db633a
index b82120af9..4a27b3a14 100644
db633a
--- a/src/backends/x11/meta-monitor-manager-xrandr.c
db633a
+++ b/src/backends/x11/meta-monitor-manager-xrandr.c
db633a
@@ -1484,12 +1484,25 @@ meta_monitor_manager_xrandr_class_init (MetaMonitorManagerXrandrClass *klass)
db633a
 #endif
db633a
 }
db633a
 
db633a
+static gboolean
db633a
+is_xvnc (MetaMonitorManager *manager)
db633a
+{
db633a
+  unsigned int i;
db633a
+
db633a
+  for (i = 0; i < manager->n_outputs; ++i)
db633a
+    if (g_str_has_prefix (manager->outputs[i].name, "VNC-"))
db633a
+      return TRUE;
db633a
+
db633a
+  return FALSE;
db633a
+}
db633a
+
db633a
 gboolean
db633a
 meta_monitor_manager_xrandr_handle_xevent (MetaMonitorManagerXrandr *manager_xrandr,
db633a
 					   XEvent                   *event)
db633a
 {
db633a
   MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_xrandr);
db633a
   gboolean hotplug;
db633a
+  unsigned int timestamp;
db633a
 
db633a
   if ((event->type - manager_xrandr->rr_event_base) != RRScreenChangeNotify)
db633a
     return FALSE;
db633a
@@ -1498,7 +1511,11 @@ meta_monitor_manager_xrandr_handle_xevent (MetaMonitorManagerXrandr *manager_xra
db633a
 
db633a
   meta_monitor_manager_read_current_config (manager);
db633a
 
db633a
-  hotplug = manager_xrandr->resources->timestamp < manager_xrandr->resources->configTimestamp;
db633a
+  timestamp = manager_xrandr->resources->timestamp;
db633a
+  if (is_xvnc (manager))
db633a
+    timestamp += 100;
db633a
+
db633a
+  hotplug = timestamp < manager_xrandr->resources->configTimestamp;
db633a
   if (hotplug)
db633a
     {
db633a
       /* This is a hotplug event, so go ahead and build a new configuration. */
db633a
-- 
db633a
2.12.0
db633a