monitor-manager-xrandr: Don't do extra work on RRScreenChangeNotify

The X server sends several RRScreenChangeNotify events in a burst when
something happens which, currently, causes us to rebuild our view of
the world as many times and notify the upper layers about it which
causes a lot of bogus repeated work like rebuilding background actors.

We can avoid this extra work by looking at the timestamp in the
XRRScreenResources struct which is updated when an X client (including
us!) last changed something and comparing it with the previous
timestamp.

https://bugzilla.gnome.org/show_bug.cgi?id=738630
This commit is contained in:
Rui Matos 2014-10-16 13:31:26 +02:00
parent 016b8f5b4a
commit 47e339b46e

View File

@ -1059,12 +1059,15 @@ meta_monitor_manager_xrandr_handle_xevent (MetaMonitorManagerXrandr *manager_xra
{
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_xrandr);
gboolean hotplug;
Time old_timestamp;
if ((event->type - manager_xrandr->rr_event_base) != RRScreenChangeNotify)
return FALSE;
XRRUpdateConfiguration (event);
old_timestamp = manager_xrandr->resources->timestamp;
meta_monitor_manager_read_current_config (manager);
hotplug = manager_xrandr->resources->timestamp < manager_xrandr->resources->configTimestamp;
@ -1075,7 +1078,8 @@ meta_monitor_manager_xrandr_handle_xevent (MetaMonitorManagerXrandr *manager_xra
}
else
{
/* Something else changed -- tell the world about it. */
/* If something else changed -- tell the world about it. */
if (old_timestamp < manager_xrandr->resources->timestamp)
meta_monitor_manager_rebuild_derived (manager);
}