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

e3f29c
From 73cae2c78af65cdfd6fa0c8257b4d3ae593f9f74 Mon Sep 17 00:00:00 2001
db633a
From: Rui Matos <tiagomatos@gmail.com>
db633a
Date: Tue, 6 Oct 2015 21:16:18 +0200
e3f29c
Subject: [PATCH 2/8] monitor-manager-xrandr: Work around spurious hotplugs on
e3f29c
 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
---
e3f29c
 src/backends/x11/meta-monitor-manager-xrandr.c | 20 ++++++++++++++++++--
e3f29c
 1 file changed, 18 insertions(+), 2 deletions(-)
db633a
db633a
diff --git a/src/backends/x11/meta-monitor-manager-xrandr.c b/src/backends/x11/meta-monitor-manager-xrandr.c
e3f29c
index c369d4960..8d1bdfb69 100644
db633a
--- a/src/backends/x11/meta-monitor-manager-xrandr.c
db633a
+++ b/src/backends/x11/meta-monitor-manager-xrandr.c
e3f29c
@@ -1909,6 +1909,18 @@ meta_monitor_manager_xrandr_class_init (MetaMonitorManagerXrandrClass *klass)
e3f29c
     g_quark_from_static_string ("-meta-monitor-xrandr-data");
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)
e3f29c
@@ -1916,6 +1928,7 @@ meta_monitor_manager_xrandr_handle_xevent (MetaMonitorManagerXrandr *manager_xra
db633a
   MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_xrandr);
e3f29c
   gboolean is_hotplug;
e3f29c
   gboolean is_our_configuration;
db633a
+  unsigned int timestamp;
db633a
 
db633a
   if ((event->type - manager_xrandr->rr_event_base) != RRScreenChangeNotify)
db633a
     return FALSE;
e3f29c
@@ -1925,8 +1938,11 @@ meta_monitor_manager_xrandr_handle_xevent (MetaMonitorManagerXrandr *manager_xra
e3f29c
   meta_monitor_manager_read_current_state (manager);
db633a
 
db633a
 
e3f29c
-  is_hotplug = (manager_xrandr->resources->timestamp <
e3f29c
-                manager_xrandr->resources->configTimestamp);
db633a
+  timestamp = manager_xrandr->resources->timestamp;
db633a
+  if (is_xvnc (manager))
db633a
+    timestamp += 100;
db633a
+
e3f29c
+  is_hotplug = (timestamp < manager_xrandr->resources->configTimestamp);
e3f29c
   is_our_configuration = (manager_xrandr->resources->timestamp ==
e3f29c
                           manager_xrandr->last_xrandr_set_timestamp);
e3f29c
   if (is_hotplug)
db633a
-- 
e3f29c
2.14.2
db633a