xbacklight: Changes to 'debian-unstable'
ChangeLog | 106 ++++++++++++++++++++
Makefile.am | 17 ---
configure.ac | 16 ++-
debian/changelog | 8 +
debian/control | 5
debian/rules | 1
man/Makefile.am | 12 ++
man/xbacklight.man | 58 +++++++++++
xbacklight.c | 278 +++++++++++++++++++++++++++++++----------------------
xbacklight.man | 58 -----------
10 files changed, 366 insertions(+), 193 deletions(-)
New commits:
commit fdd0696b485e55280290b0a93629b2943ea25631
Author: Julien Cristau <jcristau@debian.org>
Date: Sat Jul 12 19:04:30 2014 +0200
Upload to unstable
diff --git a/debian/changelog b/debian/changelog
index 10792b7..3031a09 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,10 +1,10 @@
-xbacklight (1.2.1-1) UNRELEASED; urgency=medium
+xbacklight (1.2.1-1) unstable; urgency=medium
* New upstream release (closes: #716684)
- ported from Xlib to xcb
* Disable silent build rules.
- -- Julien Cristau <jcristau@debian.org> Sat, 12 Jul 2014 18:45:08 +0200
+ -- Julien Cristau <jcristau@debian.org> Sat, 12 Jul 2014 19:04:26 +0200
xbacklight (1.1.2-1) unstable; urgency=low
commit 9abf665426efc38014641d56324faace669b070e
Author: Julien Cristau <jcristau@debian.org>
Date: Sat Jul 12 19:04:25 2014 +0200
Disable silent build rules.
diff --git a/debian/changelog b/debian/changelog
index a7bb603..10792b7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,7 @@ xbacklight (1.2.1-1) UNRELEASED; urgency=medium
* New upstream release (closes: #716684)
- ported from Xlib to xcb
+ * Disable silent build rules.
-- Julien Cristau <jcristau@debian.org> Sat, 12 Jul 2014 18:45:08 +0200
diff --git a/debian/rules b/debian/rules
index 3d06f9d..8c75c59 100755
--- a/debian/rules
+++ b/debian/rules
@@ -31,6 +31,7 @@ BUILDDIR = build
override_dh_auto_configure:
autoreconf -vfi
dh_auto_configure --builddirectory=$(BUILDDIR) -- \
+ --disable-silent-rules \
CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,defs"
build build-arch build-indep binary binary-arch binary-indep:
commit c0471cdd9d3daf1e26e60f045e3a24fae3854201
Author: Julien Cristau <jcristau@debian.org>
Date: Sat Jul 12 18:59:12 2014 +0200
Update build-deps
diff --git a/debian/control b/debian/control
index fe21170..4e97fb7 100644
--- a/debian/control
+++ b/debian/control
@@ -4,8 +4,9 @@ Priority: optional
Maintainer: Debian X Strike Force <debian-x@lists.debian.org>
Build-Depends:
debhelper (>= 7.3),
- libxrandr-dev (>= 2:1.2),
- libx11-dev,
+ libxcb1-dev,
+ libxcb-randr0-dev,
+ libxcb-util0-dev,
pkg-config,
xutils-dev (>= 1:7.5+4),
automake,
commit 24b4e4b577f66e2d428c70528d073ca411c7ff13
Author: Julien Cristau <jcristau@debian.org>
Date: Sat Jul 12 18:45:39 2014 +0200
Bump changelogs
diff --git a/ChangeLog b/ChangeLog
index 17d3a2c..49a0ebe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,109 @@
+commit 8e0f47c1971f17ac37c89fb49a8f1807d25923a5
+Author: Matt Turner <mattst88@gmail.com>
+Date: Mon Oct 7 20:43:34 2013 -0700
+
+ xbacklight 1.2.1
+
+ Signed-off-by: Matt Turner <mattst88@gmail.com>
+
+commit a4c00b2662a4c7291627899021f10c6a6d4716f3
+Author: Julien Cristau <jcristau@debian.org>
+Date: Thu Jul 11 12:03:40 2013 +0200
+
+ man: replace hyphens with minus signs
+
+ Reported-by: Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
+ Signed-off-by: Julien Cristau <jcristau@debian.org>
+
+commit 5d7642ffd0de1d6037f6f98b8733e8a8161e24d3
+Author: Edward Sheldrake <ejsheldrake@gmail.com>
+Date: Sat Apr 6 13:39:38 2013 +0100
+
+ Fix reading backlight level on 64-bit systems (bug 63205)
+
+ obviously incorrect output of "xbacklight -get":
+ 51671552015166906368.000000
+
+ valgrind reports an invalid read of size 8 at xbacklight.c:91
+
+ https://bugs.freedesktop.org/show_bug.cgi?id=63205
+
+ Reviewed-by: Julien Cristau <jcristau@debian.org>
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 36ffc5e0eb50fdda93af3dd7dc3899622e80d3be
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date: Sat Apr 6 09:45:22 2013 -0700
+
+ Combine usage message strings
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit cc2a24b51637e8f21c9c0aed73394db67a965b62
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date: Sat Apr 6 09:40:53 2013 -0700
+
+ config: Add missing AC_CONFIG_SRCDIR
+
+ Regroup AC statements under the Autoconf initialization section.
+ Regroup AM statements under the Automake initialization section.
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 059c60e7a6ae7f6cdcf51b06ac733bb2392c2ec2
+Author: Matt Turner <mattst88@gmail.com>
+Date: Tue Sep 11 14:37:18 2012 -0700
+
+ xbacklight 1.2.0
+
+ Signed-off-by: Matt Turner <mattst88@gmail.com>
+
+commit 6f2668f2cede3598bad3feb1cae9e8de473d2531
+Author: Jon Lund Steffensen <jonlst@gmail.com>
+Date: Sun Aug 12 10:04:08 2012 -0700
+
+ Port xbacklight to XCB
+
+ Signed-off-by: Matt Turner <mattst88@gmail.com>
+
+commit a18911abb94ef0cfa55282b96027f501a82652a6
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date: Wed Jan 19 10:06:55 2011 -0500
+
+ config: move man pages into their own directory
+
+ Use services provided by XORG_MANPAGE_SECTIONS.
+ Use standard Makefile for man pages.
+
+ Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
+
+commit 8bc2e5a8888de4d457870986f442b628e4795364
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date: Thu Jan 13 17:15:36 2011 -0500
+
+ man: replace hard coded man page section with substitution strings
+
+ Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
+
+commit ae1445b4ce52ecc739faee1e69ab9f51d0ad90f3
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date: Wed Jan 12 16:28:02 2011 -0500
+
+ config: replace deprecated AM_CONFIG_HEADER with AC_CONFIG_HEADERS
+
+ This silences an Autoconf warning
+
+commit 3d55286af9f597d81099f58c7236a920d02c7519
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date: Mon Apr 5 20:42:20 2010 -0400
+
+ config: the file COPYING in EXTRA_DIST is redundant
+
+ COPYING is a filename known to Automake and does not
+ need to be on EXTRA_DIST.
+
+ Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
+
commit 30ed7c0b3f2dc131e9fa4bb53ba702b65b05b46a
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Fri Oct 29 23:36:28 2010 -0700
diff --git a/debian/changelog b/debian/changelog
index 7c8db24..a7bb603 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+xbacklight (1.2.1-1) UNRELEASED; urgency=medium
+
+ * New upstream release (closes: #716684)
+ - ported from Xlib to xcb
+
+ -- Julien Cristau <jcristau@debian.org> Sat, 12 Jul 2014 18:45:08 +0200
+
xbacklight (1.1.2-1) unstable; urgency=low
* Rename the build directory to not include DEB_BUILD_GNU_TYPE for no
commit 8e0f47c1971f17ac37c89fb49a8f1807d25923a5
Author: Matt Turner <mattst88@gmail.com>
Date: Mon Oct 7 20:43:34 2013 -0700
xbacklight 1.2.1
Signed-off-by: Matt Turner <mattst88@gmail.com>
diff --git a/configure.ac b/configure.ac
index a811f5e..f97497d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,7 @@ dnl Process this file with autoconf to create configure.
# Initialize Autoconf
AC_PREREQ([2.60])
-AC_INIT([xbacklight], [1.2.0],
+AC_INIT([xbacklight], [1.2.1],
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
[xbacklight])
AC_CONFIG_SRCDIR([Makefile.am])
commit a4c00b2662a4c7291627899021f10c6a6d4716f3
Author: Julien Cristau <jcristau@debian.org>
Date: Thu Jul 11 12:03:40 2013 +0200
man: replace hyphens with minus signs
Reported-by: Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
Signed-off-by: Julien Cristau <jcristau@debian.org>
diff --git a/man/xbacklight.man b/man/xbacklight.man
index 2983637..c3aa48e 100644
--- a/man/xbacklight.man
+++ b/man/xbacklight.man
@@ -24,32 +24,32 @@
xbacklight \- adjust backlight brightness using RandR extension
.SH SYNOPSIS
.B "xbacklight"
-[-help] [-display \fIdisplay\fP]
-[-get]
-[-set percent]
-[-inc percent]
-[-dec percent]
+[\-help] [\-display \fIdisplay\fP]
+[\-get]
+[\-set percent]
+[\-inc percent]
+[\-dec percent]
.SH DESCRIPTION
.I Xbacklight
is used to adjust the backlight brightness where supported. It finds all
outputs on the X server supporting backlight brightness control and changes
them all in the same way.
-.IP -get
+.IP \-get
Print out the current backlight brightness of each output with such a
control. The brightness is represented as a percentage of the maximum
brightness supported.
-.IP "-set \fIpercent\fP"
+.IP "\-set \fIpercent\fP"
Sets each backlight brightness to the specified level.
-.IP "-inc \fIpercent\fP"
+.IP "\-inc \fIpercent\fP"
Increases brightness by the specified amount.
-.IP "-dec \fIpercent\fP"
+.IP "\-dec \fIpercent\fP"
Decreases brightness by the specified amount.
-.IP -help
+.IP \-help
Print out a summary of the usage and exit.
-.IP "-time \fImilliseconds\fP"
+.IP "\-time \fImilliseconds\fP"
Length of time to spend fading the backlight between old and new value.
Default is 200.
-.IP "-steps \fInumber\fP"
+.IP "\-steps \fInumber\fP"
Number of steps to take while fading. Default is 20.
.SH "SEE ALSO"
Xrandr(__libmansuffix__)
commit 5d7642ffd0de1d6037f6f98b8733e8a8161e24d3
Author: Edward Sheldrake <ejsheldrake@gmail.com>
Date: Sat Apr 6 13:39:38 2013 +0100
Fix reading backlight level on 64-bit systems (bug 63205)
obviously incorrect output of "xbacklight -get":
51671552015166906368.000000
valgrind reports an invalid read of size 8 at xbacklight.c:91
https://bugs.freedesktop.org/show_bug.cgi?id=63205
Reviewed-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
diff --git a/xbacklight.c b/xbacklight.c
index 0614f03..214bd32 100644
--- a/xbacklight.c
+++ b/xbacklight.c
@@ -87,7 +87,7 @@ backlight_get (xcb_connection_t *conn, xcb_randr_output_t output)
prop_reply->format != 32) {
value = -1;
} else {
- value = *((long *) xcb_randr_get_output_property_data (prop_reply));
+ value = *((int32_t *) xcb_randr_get_output_property_data (prop_reply));
}
free (prop_reply);
commit 36ffc5e0eb50fdda93af3dd7dc3899622e80d3be
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Apr 6 09:45:22 2013 -0700
Combine usage message strings
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
diff --git a/xbacklight.c b/xbacklight.c
index 2189095..0614f03 100644
--- a/xbacklight.c
+++ b/xbacklight.c
@@ -40,17 +40,16 @@ static xcb_atom_t backlight, backlight_new, backlight_legacy;
static void
usage (void)
{
- fprintf(stderr, "usage: %s [options]\n", program_name);
- fprintf(stderr, " where options are:\n");
- fprintf(stderr, " -display <display> or -d <display>\n");
- fprintf(stderr, " -help\n");
- fprintf(stderr, " -set <percentage> or = <percentage>\n");
- fprintf(stderr, " -inc <percentage> or + <percentage>\n");
- fprintf(stderr, " -dec <percentage> or - <percentage>\n");
- fprintf(stderr, " -get\n");
- fprintf(stderr, " -time <fade time in milliseconds>\n");
- fprintf(stderr, " -steps <number of steps in fade>\n");
- /*NOTREACHED*/
+ fprintf(stderr, "usage: %s [options]\n%s", program_name,
+ " where options are:\n"
+ " -display <display> or -d <display>\n"
+ " -help\n"
+ " -set <percentage> or = <percentage>\n"
+ " -inc <percentage> or + <percentage>\n"
+ " -dec <percentage> or - <percentage>\n"
+ " -get\n"
+ " -time <fade time in milliseconds>\n"
+ " -steps <number of steps in fade>\n");
exit (1);
}
commit cc2a24b51637e8f21c9c0aed73394db67a965b62
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Apr 6 09:40:53 2013 -0700
config: Add missing AC_CONFIG_SRCDIR
Regroup AC statements under the Autoconf initialization section.
Regroup AM statements under the Automake initialization section.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
diff --git a/configure.ac b/configure.ac
index d7eab36..a811f5e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,10 +21,15 @@ dnl PERFORMANCE OF THIS SOFTWARE.
dnl
dnl Process this file with autoconf to create configure.
+# Initialize Autoconf
AC_PREREQ([2.60])
AC_INIT([xbacklight], [1.2.0],
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
[xbacklight])
+AC_CONFIG_SRCDIR([Makefile.am])
+AC_CONFIG_HEADERS([config.h])
+
+# Initialize Automake
AM_INIT_AUTOMAKE([foreign dist-bzip2])
AM_MAINTAINER_MODE
@@ -34,8 +39,6 @@ m4_ifndef([XORG_MACROS_VERSION],
XORG_MACROS_VERSION(1.8)
XORG_DEFAULT_OPTIONS
-AC_CONFIG_HEADERS([config.h])
-
# Checks for pkg-config packages
PKG_CHECK_MODULES(XRANDR, [xcb-randr >= 1.2 xcb-atom xcb-aux xcb])
commit 059c60e7a6ae7f6cdcf51b06ac733bb2392c2ec2
Author: Matt Turner <mattst88@gmail.com>
Date: Tue Sep 11 14:37:18 2012 -0700
xbacklight 1.2.0
Signed-off-by: Matt Turner <mattst88@gmail.com>
diff --git a/configure.ac b/configure.ac
index 87c7b26..d7eab36 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,7 @@ dnl
dnl Process this file with autoconf to create configure.
AC_PREREQ([2.60])
-AC_INIT([xbacklight], [1.1.2],
+AC_INIT([xbacklight], [1.2.0],
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
[xbacklight])
AM_INIT_AUTOMAKE([foreign dist-bzip2])
commit 6f2668f2cede3598bad3feb1cae9e8de473d2531
Author: Jon Lund Steffensen <jonlst@gmail.com>
Date: Sun Aug 12 10:04:08 2012 -0700
Port xbacklight to XCB
Signed-off-by: Matt Turner <mattst88@gmail.com>
diff --git a/configure.ac b/configure.ac
index 2c67604..87c7b26 100644
--- a/configure.ac
+++ b/configure.ac
@@ -37,7 +37,7 @@ XORG_DEFAULT_OPTIONS
AC_CONFIG_HEADERS([config.h])
# Checks for pkg-config packages
-PKG_CHECK_MODULES(XRANDR, xrandr >= 1.2.0 x11)
+PKG_CHECK_MODULES(XRANDR, [xcb-randr >= 1.2 xcb-atom xcb-aux xcb])
AC_CONFIG_FILES([
Makefile
diff --git a/xbacklight.c b/xbacklight.c
index 9b68ce8..2189095 100644
--- a/xbacklight.c
+++ b/xbacklight.c
@@ -21,9 +21,11 @@
*/
#include <stdio.h>
#include <stdlib.h>
-#include <X11/Xatom.h>
-#include <X11/Xlib.h>
-#include <X11/extensions/Xrandr.h>
+
+#include <xcb/xcb.h>
+#include <xcb/xcb_util.h>
+#include <xcb/xproto.h>
+#include <xcb/randr.h>
#include <ctype.h>
#include <string.h>
@@ -33,7 +35,7 @@ typedef enum { Get, Set, Inc, Dec } op_t;
static char *program_name;
-static Atom backlight, backlight_new, backlight_legacy;
+static xcb_atom_t backlight, backlight_new, backlight_legacy;
static void
usage (void)
@@ -53,58 +55,75 @@ usage (void)
}
static long
-backlight_get (Display *dpy, RROutput output)
+backlight_get (xcb_connection_t *conn, xcb_randr_output_t output)
{
- unsigned long nitems;
- unsigned long bytes_after;
- unsigned char *prop;
- Atom actual_type;
- int actual_format;
- long value;
+ xcb_generic_error_t *error;
+ xcb_randr_get_output_property_reply_t *prop_reply = NULL;
+ xcb_randr_get_output_property_cookie_t prop_cookie;
+ long value;
backlight = backlight_new;
- if (!backlight ||
- XRRGetOutputProperty (dpy, output, backlight,
- 0, 4, False, False, None,
- &actual_type, &actual_format,
- &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 (backlight != XCB_ATOM_NONE) {
+ prop_cookie = xcb_randr_get_output_property (conn, output,
+ backlight, XCB_ATOM_NONE,
+ 0, 4, 0, 0);
+ prop_reply = xcb_randr_get_output_property_reply (conn, prop_cookie, &error);
+ if (error != NULL || prop_reply == NULL) {
+ backlight = backlight_legacy;
+ if (backlight != XCB_ATOM_NONE) {
+ prop_cookie = xcb_randr_get_output_property (conn, output,
+ backlight, XCB_ATOM_NONE,
+ 0, 4, 0, 0);
+ prop_reply = xcb_randr_get_output_property_reply (conn, prop_cookie, &error);
+ if (error != NULL || prop_reply == NULL) {
+ return -1;
+ }
+ }
+ }
}
- if (actual_type != XA_INTEGER || nitems != 1 || actual_format != 32)
+ if (prop_reply == NULL ||
+ prop_reply->type != XCB_ATOM_INTEGER ||
+ prop_reply->num_items != 1 ||
+ prop_reply->format != 32) {
value = -1;
- else
- value = *((long *) prop);
- XFree (prop);
+ } else {
+ value = *((long *) xcb_randr_get_output_property_data (prop_reply));
+ }
+
+ free (prop_reply);
return value;
}
static void
-backlight_set (Display *dpy, RROutput output, long value)
+backlight_set (xcb_connection_t *conn, xcb_randr_output_t output, long value)
{
- XRRChangeOutputProperty (dpy, output, backlight, XA_INTEGER, 32,
- PropModeReplace, (unsigned char *) &value, 1);
+ xcb_randr_change_output_property (conn, output, backlight, XCB_ATOM_INTEGER,
+ 32, XCB_PROP_MODE_REPLACE,
+ 1, (unsigned char *)&value);
}
int
main (int argc, char **argv)
{
char *dpy_name = NULL;
- Display *dpy;
- int screen;
- int major, minor;
op_t op = Get;
int value = 0;
int i;
int total_time = 200; /* ms */
int steps = 20;
+ xcb_connection_t *conn;
+ xcb_generic_error_t *error;
+
+ xcb_randr_query_version_cookie_t ver_cookie;
+ xcb_randr_query_version_reply_t *ver_reply;
+
+ xcb_intern_atom_cookie_t backlight_cookie[2];
+ xcb_intern_atom_reply_t *backlight_reply;
+
+ xcb_screen_iterator_t iter;
+
program_name = argv[0];
for (i = 1; i < argc; i++)
@@ -177,97 +196,133 @@ main (int argc, char **argv)
}
usage ();
}
- dpy = XOpenDisplay (dpy_name);
- if (!dpy)
- {
- fprintf (stderr, "Cannot open display \"%s\"\n",
- XDisplayName (dpy_name));
+ conn = xcb_connect (dpy_name, NULL);
+ ver_cookie = xcb_randr_query_version (conn, 1, 2);
+ ver_reply = xcb_randr_query_version_reply (conn, ver_cookie, &error);
+ if (error != NULL || ver_reply == NULL) {
+ int ec = error ? error->error_code : -1;
+ fprintf (stderr, "RANDR Query Version returned error %d\n", ec);
exit (1);
}
- if (!XRRQueryVersion (dpy, &major, &minor))
- {
- fprintf (stderr, "RandR extension missing\n");
+ if (ver_reply->major_version != 1 ||
+ ver_reply->minor_version < 2) {
+ fprintf (stderr, "RandR version %d.%d too old\n",
+ ver_reply->major_version, ver_reply->minor_version);
exit (1);
}
- if (major < 1 || (major == 1 && minor < 2))
- {
- fprintf (stderr, "RandR version %d.%d too old\n", major, minor);
+ free (ver_reply);
+
+ backlight_cookie[0] = xcb_intern_atom (conn, 1, strlen("Backlight"), "Backlight");
+ backlight_cookie[1] = xcb_intern_atom (conn, 1, strlen("BACKLIGHT"), "BACKLIGHT");
+
+ backlight_reply = xcb_intern_atom_reply (conn, backlight_cookie[0], &error);
+ if (error != NULL || backlight_reply == NULL) {
+ int ec = error ? error->error_code : -1;
+ fprintf (stderr, "Intern Atom returned error %d\n", ec);
exit (1);
}
- backlight_new = XInternAtom (dpy, "Backlight", True);
- backlight_legacy = XInternAtom (dpy, "BACKLIGHT", True);
- if (backlight_new == None && backlight_legacy == None)
- {
+ backlight_new = backlight_reply->atom;
+ free (backlight_reply);
+
+ backlight_reply = xcb_intern_atom_reply (conn, backlight_cookie[1], &error);
+ if (error != NULL || backlight_reply == NULL) {
+ int ec = error ? error->error_code : -1;
+ fprintf (stderr, "Intern Atom returned error %d\n", ec);
+ exit (1);
+ }
+
+ backlight_legacy = backlight_reply->atom;
+ free (backlight_reply);
+
+ if (backlight_new == XCB_NONE && backlight_legacy == XCB_NONE) {
fprintf (stderr, "No outputs have backlight property\n");
exit (1);
}
- for (screen = 0; screen < ScreenCount (dpy); screen++)
- {
- Window root = RootWindow (dpy, screen);
- XRRScreenResources *resources = XRRGetScreenResources (dpy, root);
- int o;
-
- if (!resources) continue;
- for (o = 0; o < resources->noutput; o++)
+
+ iter = xcb_setup_roots_iterator (xcb_get_setup (conn));
+ while (iter.rem) {
+ xcb_screen_t *screen = iter.data;
+ xcb_window_t root = screen->root;
+ xcb_randr_output_t *outputs;
+
+ xcb_randr_get_screen_resources_cookie_t resources_cookie;
+ xcb_randr_get_screen_resources_reply_t *resources_reply;
+
+ resources_cookie = xcb_randr_get_screen_resources (conn, root);
+ resources_reply = xcb_randr_get_screen_resources_reply (conn, resources_cookie, &error);
+ if (error != NULL || resources_reply == NULL) {
+ int ec = error ? error->error_code : -1;
+ fprintf (stderr, "RANDR Get Screen Resources returned error %d\n", ec);
+ continue;
+ }
+
+ outputs = xcb_randr_get_screen_resources_outputs (resources_reply);
+ for (int o = 0; o < resources_reply->num_outputs; o++)
{
- RROutput output = resources->outputs[o];
- XRRPropertyInfo *info;
+ xcb_randr_output_t output = outputs[o];
double cur, new, step;
double min, max;
double set;
- cur = backlight_get (dpy, output);
+ cur = backlight_get (conn, output);
if (cur != -1)
{
- info = XRRQueryOutputProperty (dpy, output, backlight);
- if (info)
- {
- if (info->range && info->num_values == 2)
- {
- min = info->values[0];
- max = info->values[1];
- if (op == Get) {
- printf ("%f\n", (cur - min) * 100 / (max - min));
- } else {
- set = value * (max - min) / 100;
- switch (op) {
- case Set:
- new = min + set;
- break;
- case Inc:
- new = cur + set;
- break;
- case Dec:
- new = cur - set;
- break;
- default:
- XSync (dpy, False);
- return 1;
- }
- if (new > max) new = max;
- if (new < min) new = min;
- step = (new - cur) / steps;
- for (i = 0; i < steps && step != 0; i++)
- {
- if (i == steps - 1)
- cur = new;
- else
- cur += step;
- backlight_set (dpy, output, (long) cur);
- XFlush (dpy);
- usleep (total_time * 1000 / steps);
- }
+ xcb_randr_query_output_property_cookie_t prop_cookie;
+ xcb_randr_query_output_property_reply_t *prop_reply;
+
+ prop_cookie = xcb_randr_query_output_property (conn, output, backlight);
+ prop_reply = xcb_randr_query_output_property_reply (conn, prop_cookie, &error);
+
+ if (error != NULL || prop_reply == NULL) continue;
+
+ if (prop_reply->range &&
+ xcb_randr_query_output_property_valid_values_length (prop_reply) == 2) {
+ int32_t *values = xcb_randr_query_output_property_valid_values (prop_reply);
+ min = values[0];
+ max = values[1];
+
+ if (op == Get) {
+ printf ("%f\n", (cur - min) * 100 / (max - min));
+ } else {
+ set = value * (max - min) / 100;
+ switch (op) {
+ case Set:
+ new = min + set;
+ break;
+ case Inc:
+ new = cur + set;
+ break;
+ case Dec:
+ new = cur - set;
+ break;
+ default:
+ xcb_aux_sync (conn);
+ return 1;
+ }
+ if (new > max) new = max;
+ if (new < min) new = min;
+ step = (new - cur) / steps;
+ for (i = 0; i < steps && step != 0; i++)
+ {
+ if (i == steps - 1)
+ cur = new;
+ else
+ cur += step;
+ backlight_set (conn, output, (long) cur);
+ xcb_flush (conn);
+ usleep (total_time * 1000 / steps);
}
}
- XFree (info);
}
+ free (prop_reply);
}
}
-
- XRRFreeScreenResources (resources);
+
+ free (resources_reply);
+ xcb_screen_next (&iter);
}
- XSync (dpy, False);
+ xcb_aux_sync (conn);
return 0;
}
commit a18911abb94ef0cfa55282b96027f501a82652a6
Author: Gaetan Nadon <memsize@videotron.ca>
Date: Wed Jan 19 10:06:55 2011 -0500
config: move man pages into their own directory
Use services provided by XORG_MANPAGE_SECTIONS.
Use standard Makefile for man pages.
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
diff --git a/Makefile.am b/Makefile.am
index 7d85683..4b67745 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -21,6 +21,7 @@
AUTOMAKE_OPTIONS = foreign
+SUBDIRS = man
bin_PROGRAMS = xbacklight
AM_CFLAGS = $(CWARNFLAGS) $(XRANDR_CFLAGS)
@@ -29,23 +30,7 @@ xbacklight_LDADD = $(XRANDR_LIBS)
xbacklight_SOURCES = \
xbacklight.c
-appman_PRE = \
- xbacklight.man
-
-appmandir = $(APP_MAN_DIR)
-
-appman_DATA = $(appman_PRE:man=@APP_MAN_SUFFIX@)
-
-EXTRA_DIST = $(appman_PRE)
MAINTAINERCLEANFILES = ChangeLog INSTALL
-CLEANFILES = $(appman_DATA)
-
-SUFFIXES = .$(APP_MAN_SUFFIX) .man
-
-# String replacements in MAN_SUBSTS now come from xorg-macros.m4 via configure
-.man.$(APP_MAN_SUFFIX):
- $(AM_V_GEN)$(SED) $(MAN_SUBSTS) < $< > $@
-
.PHONY: ChangeLog INSTALL
diff --git a/configure.ac b/configure.ac
index ed690c5..2c67604 100644
--- a/configure.ac
+++ b/configure.ac
@@ -39,4 +39,7 @@ AC_CONFIG_HEADERS([config.h])
# Checks for pkg-config packages
PKG_CHECK_MODULES(XRANDR, xrandr >= 1.2.0 x11)
-AC_OUTPUT([Makefile])
+AC_CONFIG_FILES([
+ Makefile
+ man/Makefile])
+AC_OUTPUT
diff --git a/man/Makefile.am b/man/Makefile.am
new file mode 100644
index 0000000..9505afd
--- /dev/null
+++ b/man/Makefile.am
@@ -0,0 +1,12 @@
+
+appmandir = $(APP_MAN_DIR)
+appman_PRE = xbacklight.man
+appman_DATA = $(appman_PRE:man=$(APP_MAN_SUFFIX))
+
+EXTRA_DIST = $(appman_PRE)
+CLEANFILES = $(appman_DATA)
+SUFFIXES = .$(APP_MAN_SUFFIX) .man
+
+# String replacements in MAN_SUBSTS now come from xorg-macros.m4 via configure
+.man.$(APP_MAN_SUFFIX):
+ $(AM_V_GEN)$(SED) $(MAN_SUBSTS) < $< > $@
diff --git a/man/xbacklight.man b/man/xbacklight.man
new file mode 100644
index 0000000..2983637
--- /dev/null
+++ b/man/xbacklight.man
@@ -0,0 +1,58 @@
+.\"
+.\" Copyright © 2007 Keith Packard.\"
+.\" Permission to use, copy, modify, distribute, and sell this software and its
+.\" documentation for any purpose is hereby granted without fee, provided that
+.\" the above copyright notice appear in all copies and that both that
+.\" copyright notice and this permission notice appear in supporting
+.\" documentation, and that the name of Keith Packard not be used in
+.\" advertising or publicity pertaining to distribution of the software without
+.\" specific, written prior permission. Keith Packard makes no
+.\" representations about the suitability of this software for any purpose. It
+.\" is provided "as is" without express or implied warranty.
+.\"
+.\" KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+.\" INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+.\" EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+.\" CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+.\" DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+.\" TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+.\" PERFORMANCE OF THIS SOFTWARE.
+.\"
+.\"
+.TH XBACKLIGHT __appmansuffix__ __vendorversion__
+.SH NAME
+xbacklight \- adjust backlight brightness using RandR extension
+.SH SYNOPSIS
+.B "xbacklight"
+[-help] [-display \fIdisplay\fP]
+[-get]
+[-set percent]
+[-inc percent]
+[-dec percent]
+.SH DESCRIPTION
+.I Xbacklight
+is used to adjust the backlight brightness where supported. It finds all
+outputs on the X server supporting backlight brightness control and changes
+them all in the same way.
+.IP -get
+Print out the current backlight brightness of each output with such a
+control. The brightness is represented as a percentage of the maximum
+brightness supported.
+.IP "-set \fIpercent\fP"
+Sets each backlight brightness to the specified level.
+.IP "-inc \fIpercent\fP"
+Increases brightness by the specified amount.
+.IP "-dec \fIpercent\fP"
+Decreases brightness by the specified amount.
+.IP -help
+Print out a summary of the usage and exit.
+.IP "-time \fImilliseconds\fP"
+Length of time to spend fading the backlight between old and new value.
+Default is 200.
+.IP "-steps \fInumber\fP"
+Number of steps to take while fading. Default is 20.
+.SH "SEE ALSO"
+Xrandr(__libmansuffix__)
+.SH AUTHORS
+Keith Packard,
+Open Source Technology Center, Intel Corporation.
diff --git a/xbacklight.man b/xbacklight.man
deleted file mode 100644
index 2983637..0000000
--- a/xbacklight.man
+++ /dev/null
@@ -1,58 +0,0 @@
-.\"
-.\" Copyright © 2007 Keith Packard.\"
-.\" Permission to use, copy, modify, distribute, and sell this software and its
-.\" documentation for any purpose is hereby granted without fee, provided that
-.\" the above copyright notice appear in all copies and that both that
-.\" copyright notice and this permission notice appear in supporting
-.\" documentation, and that the name of Keith Packard not be used in
-.\" advertising or publicity pertaining to distribution of the software without
-.\" specific, written prior permission. Keith Packard makes no
-.\" representations about the suitability of this software for any purpose. It
-.\" is provided "as is" without express or implied warranty.
-.\"
-.\" KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
-.\" INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
-.\" EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
-.\" CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
-.\" DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
-.\" TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-.\" PERFORMANCE OF THIS SOFTWARE.
-.\"
-.\"
-.TH XBACKLIGHT __appmansuffix__ __vendorversion__
-.SH NAME
-xbacklight \- adjust backlight brightness using RandR extension
-.SH SYNOPSIS
-.B "xbacklight"
-[-help] [-display \fIdisplay\fP]
-[-get]
-[-set percent]
-[-inc percent]
-[-dec percent]
-.SH DESCRIPTION
-.I Xbacklight
-is used to adjust the backlight brightness where supported. It finds all
-outputs on the X server supporting backlight brightness control and changes
-them all in the same way.
-.IP -get
-Print out the current backlight brightness of each output with such a
-control. The brightness is represented as a percentage of the maximum
-brightness supported.
-.IP "-set \fIpercent\fP"
-Sets each backlight brightness to the specified level.
-.IP "-inc \fIpercent\fP"
-Increases brightness by the specified amount.
-.IP "-dec \fIpercent\fP"
-Decreases brightness by the specified amount.
-.IP -help
-Print out a summary of the usage and exit.
-.IP "-time \fImilliseconds\fP"
-Length of time to spend fading the backlight between old and new value.
-Default is 200.
-.IP "-steps \fInumber\fP"
-Number of steps to take while fading. Default is 20.
Reply to: