From 29e5c6c363735c04c25d9e4da2bb236ef5aa2e52 Mon Sep 17 00:00:00 2001 From: Rui Matos Date: Thu, 16 Oct 2014 20:31:03 +0200 Subject: [PATCH] monitor-manager-xrandr: Re-work xrandr event handling In randr events, configTimestamp can be considered the hotplug time, i.e. whenever the server notices hardware changes, this value will be updated. Having that in mind, we can re-work the logic to make it clearer. There are no semantic changes. --- .../x11/meta-monitor-manager-xrandr.c | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/backends/x11/meta-monitor-manager-xrandr.c b/src/backends/x11/meta-monitor-manager-xrandr.c index f93390d07..130cb6da8 100644 --- a/src/backends/x11/meta-monitor-manager-xrandr.c +++ b/src/backends/x11/meta-monitor-manager-xrandr.c @@ -1060,7 +1060,7 @@ meta_monitor_manager_xrandr_handle_xevent (MetaMonitorManagerXrandr *manager_xra XEvent *event) { MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_xrandr); - gboolean new_config; + gboolean hotplug; if ((event->type - manager_xrandr->rr_event_base) != RRScreenChangeNotify) return FALSE; @@ -1073,19 +1073,17 @@ meta_monitor_manager_xrandr_handle_xevent (MetaMonitorManagerXrandr *manager_xra if (meta_monitor_config_match_current (manager->config, manager)) return TRUE; - new_config = manager_xrandr->resources->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. - */ - if (new_config) + hotplug = manager_xrandr->resources->timestamp < manager_xrandr->resources->configTimestamp; + if (hotplug) { + /* This is a hotplug event, so go ahead and build a new configuration. */ + meta_monitor_manager_on_hotplug (manager); + } + else + { + /* Something else changed -- tell the world about it. */ meta_monitor_manager_rebuild_derived (manager); - return TRUE; } - /* Otherwise, this event was gotten from hotplug, so try to make - * a configuration for our new set of outputs. */ - meta_monitor_manager_on_hotplug (manager); return TRUE; }