From 073a328a3031faa82d388805c0a6890d4de001df Mon Sep 17 00:00:00 2001 From: Rui Matos Date: Tue, 6 Oct 2015 21:16:18 +0200 Subject: [PATCH] monitor-manager-xrandr: Work around spurious hotplugs on Xvnc Xvnc turns its outputs off/on on every mode set which makes us believe there was an hotplug when there actually wasn't. Work around this by requiring new randr configuration timestamps to be ahead of the last set timestamp by at least 100 ms for us to consider them an actual hotplug. --- src/backends/x11/meta-monitor-manager-xrandr.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/backends/x11/meta-monitor-manager-xrandr.c b/src/backends/x11/meta-monitor-manager-xrandr.c index 4c1b16c..190aeac 100644 --- a/src/backends/x11/meta-monitor-manager-xrandr.c +++ b/src/backends/x11/meta-monitor-manager-xrandr.c @@ -1064,6 +1064,18 @@ meta_monitor_manager_xrandr_class_init (MetaMonitorManagerXrandrClass *klass) manager_class->set_crtc_gamma = meta_monitor_manager_xrandr_set_crtc_gamma; } +static gboolean +is_xvnc (MetaMonitorManager *manager) +{ + unsigned int i; + + for (i = 0; i < manager->n_outputs; ++i) + if (g_str_has_prefix (manager->outputs[i].name, "VNC-")) + return TRUE; + + return FALSE; +} + gboolean meta_monitor_manager_xrandr_handle_xevent (MetaMonitorManagerXrandr *manager_xrandr, XEvent *event) @@ -1075,6 +1087,7 @@ meta_monitor_manager_xrandr_handle_xevent (MetaMonitorManagerXrandr *manager_xra unsigned int n_old_outputs, n_old_modes; gboolean new_config; gboolean applied_config = FALSE; + unsigned int timestamp; if ((event->type - manager_xrandr->rr_event_base) != RRScreenChangeNotify) return FALSE; @@ -1091,7 +1104,11 @@ meta_monitor_manager_xrandr_handle_xevent (MetaMonitorManagerXrandr *manager_xra manager->serial++; meta_monitor_manager_xrandr_read_current (manager); - new_config = manager_xrandr->resources->timestamp >= manager_xrandr->resources->configTimestamp; + timestamp = manager_xrandr->resources->timestamp; + if (is_xvnc (manager)) + timestamp += 100; + + new_config = timestamp >= manager_xrandr->resources->configTimestamp; /* If this is the X server telling us we set a new configuration, * we can simply short-cut to rebuilding our logical configuration. -- 2.4.3