Index: gnome-power-manager-2.24.2/src/gpm-brightness-xrandr.c =================================================================== --- gnome-power-manager-2.24.2.orig/src/gpm-brightness-xrandr.c 2009-05-05 22:55:35.000000000 +0100 +++ gnome-power-manager-2.24.2/src/gpm-brightness-xrandr.c 2009-05-05 22:58:36.000000000 +0100 @@ -56,6 +56,7 @@ guint last_set_hw; Atom backlight; Display *dpy; + guint rr_version; guint shared_value; gboolean has_extension; gboolean hw_changed; @@ -148,6 +149,7 @@ /* get the display */ brightness->priv->dpy = GDK_DISPLAY(); + brightness->priv->rr_version = 0; if (!brightness->priv->dpy) { egg_error ("Cannot open display"); return FALSE; @@ -157,7 +159,8 @@ egg_debug ("RandR extension missing"); return FALSE; } - if (major < 1 || (major == 1 && minor < 2)) { + brightness->priv->rr_version = (major << 12) | minor; + if (brightness->priv->rr_version < 0x1002) { egg_debug ("RandR version %d.%d too old", major, minor); return FALSE; } @@ -611,9 +614,16 @@ G_CALLBACK (gpm_brightness_monitors_changed), brightness); } - /* this is slow */ root = RootWindow (brightness->priv->dpy, screen); - resource = XRRGetScreenResources (brightness->priv->dpy, root); + /* XRRGetScreenResourcesCurrent is less expensive than + XRRGetScreenResources, however it is available only + in RandR 1.3 or higher */ +#if (RANDR_MAJOR == 1 && RANDR_MINOR >= 3) + if (brightness->priv->rr_version >= 0x1003) + resource = XRRGetScreenResourcesCurrent (brightness->priv->dpy, root); + else +#endif + resource = XRRGetScreenResources (brightness->priv->dpy, root); if (resource != NULL) { egg_debug ("adding resource %p", resource); g_ptr_array_add (brightness->priv->resources, resource);