summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Hopf <mhopf@suse.de>2009-08-19 14:38:31 +0200
committerMatthias Hopf <mhopf@suse.de>2009-08-19 14:38:31 +0200
commit5512e161157d6ac8a8d8a27fc99d596c6686b1da (patch)
treef58adbb9f71438389728477fb2e52eb057c96760
parent97a3f5665a62ff3a606da48f3854d082f249e6a8 (diff)
Use "Backlight" RandR property, fall back to legacy "BACKLIGHT".
-rw-r--r--xbacklight.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/xbacklight.c b/xbacklight.c
index 6eb3327..9b68ce8 100644
--- a/xbacklight.c
+++ b/xbacklight.c
@@ -33,7 +33,7 @@ typedef enum { Get, Set, Inc, Dec } op_t;
static char *program_name;
-static Atom backlight;
+static Atom backlight, backlight_new, backlight_legacy;
static void
usage (void)
@@ -62,11 +62,21 @@ backlight_get (Display *dpy, RROutput output)
int actual_format;
long value;
- if (XRRGetOutputProperty (dpy, output, backlight,
+ backlight = backlight_new;
+ if (!backlight ||
+ XRRGetOutputProperty (dpy, output, backlight,
0, 4, False, False, None,
&actual_type, &actual_format,
- &nitems, &bytes_after, &prop) != Success)
- return -1;
+ &nitems, &bytes_after, &prop) != Success) {
+ backlight = backlight_legacy;
+ if (!backlight ||
+ XRRGetOutputProperty (dpy, output, backlight,
+ 0, 4, False, False, None,
+ &actual_type, &actual_format,
+ &nitems, &bytes_after, &prop) != Success)
+ return -1;
+ }
+
if (actual_type != XA_INTEGER || nitems != 1 || actual_format != 32)
value = -1;
else
@@ -184,8 +194,10 @@ main (int argc, char **argv)
fprintf (stderr, "RandR version %d.%d too old\n", major, minor);
exit (1);
}
- backlight = XInternAtom (dpy, "BACKLIGHT", True);
- if (backlight == None)
+
+ backlight_new = XInternAtom (dpy, "Backlight", True);
+ backlight_legacy = XInternAtom (dpy, "BACKLIGHT", True);
+ if (backlight_new == None && backlight_legacy == None)
{
fprintf (stderr, "No outputs have backlight property\n");
exit (1);