gnome-power-manager r3167 - in trunk: . src



Author: rhughes
Date: Mon Jan 19 14:13:31 2009
New Revision: 3167
URL: http://svn.gnome.org/viewvc/gnome-power-manager?rev=3167&view=rev

Log:
2009-01-19  Richard Hughes  <richard hughsie com>

* src/gpm-brightness-xrandr.c:
(gpm_brightness_xrandr_update_cache):
According to the following bug report the gnome settings daemon causes
high CPU usage with libxrandr 1.2.99.2 or higher:
https://bugs.edge.launchpad.net/ubuntu/+source/libxrandr/+bug/307306

The problem is that it calls XRRGetScreenResources() (which is an rather
expensive call) instead of XRRGetScreenResourcesCurrent() which is
cheaper and doesn't cause hardware to be reprobed.

While I agree that listening to events which represent changes in output
properties is ideal, calling XRRGetScreenResources each time a property
(e.g. the backlight) changes is really expensive and (if RandR 1.3 is
available) this can be avoided.

Patch from Alberto Milone <albertomilone alice it>, many thanks.


Modified:
   trunk/ChangeLog
   trunk/src/gpm-brightness-xrandr.c

Modified: trunk/src/gpm-brightness-xrandr.c
==============================================================================
--- trunk/src/gpm-brightness-xrandr.c	(original)
+++ trunk/src/gpm-brightness-xrandr.c	Mon Jan 19 14:13:31 2009
@@ -610,9 +610,15 @@
 					  G_CALLBACK (gpm_brightness_monitors_changed), brightness);
 		}
 
-		/* this is slow */
 		root = RootWindow (brightness->priv->dpy, screen);
+		/* XRRGetScreenResourcesCurrent is less expensive than
+		   XRRGetScreenResources, however it is available only
+		   in RandR 1.3 or higher */
+#ifdef RANDR_13_INTERFACE
+		resource = XRRGetScreenResourcesCurrent (brightness->priv->dpy, root);
+#else
 		resource = XRRGetScreenResources (brightness->priv->dpy, root);
+#endif
 		if (resource != NULL) {
 			egg_debug ("adding resource %p", resource);
 			g_ptr_array_add (brightness->priv->resources, resource);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]