Updating branch refs/heads/master
         to af2ddc039bc575518a99c80c39abe0ddcc388156 (commit)
       from 52a6cfd053b6d80300e62f6bac914d7df08d6a09 (commit)

commit af2ddc039bc575518a99c80c39abe0ddcc388156
Author: Steve Dodier <[email protected]>
Date:   Sat Sep 25 09:36:58 2010 +0200

    Releasing 0.1.9, with Jérôme Guelfucci's patch replacing xvd with keybinder

 ChangeLog            |    3 +
 INSTALL              |  302 ---------------------------------------------
 README               |    7 +-
 configure.ac         |   16 +--
 src/Makefile.am      |    9 +-
 src/main.c           |   14 +--
 src/xvd_data_types.h |   26 +---
 src/xvd_keys.c       |  331 ++++++++------------------------------------------
 src/xvd_keys.h       |    5 -
 9 files changed, 80 insertions(+), 633 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4f14405..01e847e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2010-06-07  Jérôme Guelfucci <[email protected]>
+       * Use libkeybinder instead of libxcb for key grabbing
+
 2009-11-05  Steve Dodier <[email protected]>
 
        * Use xfce4-dev-tools
diff --git a/INSTALL b/INSTALL
deleted file mode 100644
index 2550dab..0000000
--- a/INSTALL
+++ /dev/null
@@ -1,302 +0,0 @@
-Installation Instructions
-*************************
-
-Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
-2006, 2007, 2008, 2009 Free Software Foundation, Inc.
-
-   This file is free documentation; the Free Software Foundation gives
-unlimited permission to copy, distribute and modify it.
-
-Basic Installation
-==================
-
-   Briefly, the shell commands `./configure; make; make install' should
-configure, build, and install this package.  The following
-more-detailed instructions are generic; see the `README' file for
-instructions specific to this package.
-
-   The `configure' shell script attempts to guess correct values for
-various system-dependent variables used during compilation.  It uses
-those values to create a `Makefile' in each directory of the package.
-It may also create one or more `.h' files containing system-dependent
-definitions.  Finally, it creates a shell script `config.status' that
-you can run in the future to recreate the current configuration, and a
-file `config.log' containing compiler output (useful mainly for
-debugging `configure').
-
-   It can also use an optional file (typically called `config.cache'
-and enabled with `--cache-file=config.cache' or simply `-C') that saves
-the results of its tests to speed up reconfiguring.  Caching is
-disabled by default to prevent problems with accidental use of stale
-cache files.
-
-   If you need to do unusual things to compile the package, please try
-to figure out how `configure' could check whether to do them, and mail
-diffs or instructions to the address given in the `README' so they can
-be considered for the next release.  If you are using the cache, and at
-some point `config.cache' contains results you don't want to keep, you
-may remove or edit it.
-
-   The file `configure.ac' (or `configure.in') is used to create
-`configure' by a program called `autoconf'.  You need `configure.ac' if
-you want to change it or regenerate `configure' using a newer version
-of `autoconf'.
-
-The simplest way to compile this package is:
-
-  1. `cd' to the directory containing the package's source code and type
-     `./configure' to configure the package for your system.
-
-     Running `configure' might take a while.  While running, it prints
-     some messages telling which features it is checking for.
-
-  2. Type `make' to compile the package.
-
-  3. Optionally, type `make check' to run any self-tests that come with
-     the package.
-
-  4. Type `make install' to install the programs and any data files and
-     documentation.
-
-  5. You can remove the program binaries and object files from the
-     source code directory by typing `make clean'.  To also remove the
-     files that `configure' created (so you can compile the package for
-     a different kind of computer), type `make distclean'.  There is
-     also a `make maintainer-clean' target, but that is intended mainly
-     for the package's developers.  If you use it, you may have to get
-     all sorts of other programs in order to regenerate files that came
-     with the distribution.
-
-  6. Often, you can also type `make uninstall' to remove the installed
-     files again.
-
-Compilers and Options
-=====================
-
-   Some systems require unusual options for compilation or linking that
-the `configure' script does not know about.  Run `./configure --help'
-for details on some of the pertinent environment variables.
-
-   You can give `configure' initial values for configuration parameters
-by setting variables in the command line or in the environment.  Here
-is an example:
-
-     ./configure CC=c99 CFLAGS=-g LIBS=-lposix
-
-   *Note Defining Variables::, for more details.
-
-Compiling For Multiple Architectures
-====================================
-
-   You can compile the package for more than one kind of computer at the
-same time, by placing the object files for each architecture in their
-own directory.  To do this, you can use GNU `make'.  `cd' to the
-directory where you want the object files and executables to go and run
-the `configure' script.  `configure' automatically checks for the
-source code in the directory that `configure' is in and in `..'.
-
-   With a non-GNU `make', it is safer to compile the package for one
-architecture at a time in the source code directory.  After you have
-installed the package for one architecture, use `make distclean' before
-reconfiguring for another architecture.
-
-   On MacOS X 10.5 and later systems, you can create libraries and
-executables that work on multiple system types--known as "fat" or
-"universal" binaries--by specifying multiple `-arch' options to the
-compiler but only a single `-arch' option to the preprocessor.  Like
-this:
-
-     ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
-                 CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
-                 CPP="gcc -E" CXXCPP="g++ -E"
-
-   This is not guaranteed to produce working output in all cases, you
-may have to build one architecture at a time and combine the results
-using the `lipo' tool if you have problems.
-
-Installation Names
-==================
-
-   By default, `make install' installs the package's commands under
-`/usr/local/bin', include files under `/usr/local/include', etc.  You
-can specify an installation prefix other than `/usr/local' by giving
-`configure' the option `--prefix=PREFIX'.
-
-   You can specify separate installation prefixes for
-architecture-specific files and architecture-independent files.  If you
-pass the option `--exec-prefix=PREFIX' to `configure', the package uses
-PREFIX as the prefix for installing programs and libraries.
-Documentation and other data files still use the regular prefix.
-
-   In addition, if you use an unusual directory layout you can give
-options like `--bindir=DIR' to specify different values for particular
-kinds of files.  Run `configure --help' for a list of the directories
-you can set and what kinds of files go in them.
-
-   If the package supports it, you can cause programs to be installed
-with an extra prefix or suffix on their names by giving `configure' the
-option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
-
-Optional Features
-=================
-
-   Some packages pay attention to `--enable-FEATURE' options to
-`configure', where FEATURE indicates an optional part of the package.
-They may also pay attention to `--with-PACKAGE' options, where PACKAGE
-is something like `gnu-as' or `x' (for the X Window System).  The
-`README' should mention any `--enable-' and `--with-' options that the
-package recognizes.
-
-   For packages that use the X Window System, `configure' can usually
-find the X include and library files automatically, but if it doesn't,
-you can use the `configure' options `--x-includes=DIR' and
-`--x-libraries=DIR' to specify their locations.
-
-Particular systems
-==================
-
-   On HP-UX, the default C compiler is not ANSI C compatible.  If GNU
-CC is not installed, it is recommended to use the following options in
-order to use an ANSI C compiler:
-
-     ./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
-
-and if that doesn't work, install pre-built binaries of GCC for HP-UX.
-
-   On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
-parse its `<wchar.h>' header file.  The option `-nodtk' can be used as
-a workaround.  If GNU CC is not installed, it is therefore recommended
-to try
-
-     ./configure CC="cc"
-
-and if that doesn't work, try
-
-     ./configure CC="cc -nodtk"
-
-   On Solaris, don't put `/usr/ucb' early in your `PATH'.  This
-directory contains several dysfunctional programs; working variants of
-these programs are available in `/usr/bin'.  So, if you need `/usr/ucb'
-in your `PATH', put it _after_ `/usr/bin'.
-
-   On Haiku, software installed for all users goes in `/boot/common',
-not `/usr/local'.  It is recommended to use the following options:
-
-     ./configure --prefix=/boot/common
-
-Specifying the System Type
-==========================
-
-   There may be some features `configure' cannot figure out
-automatically, but needs to determine by the type of machine the package
-will run on.  Usually, assuming the package is built to be run on the
-_same_ architectures, `configure' can figure that out, but if it prints
-a message saying it cannot guess the machine type, give it the
-`--build=TYPE' option.  TYPE can either be a short name for the system
-type, such as `sun4', or a canonical name which has the form:
-
-     CPU-COMPANY-SYSTEM
-
-where SYSTEM can have one of these forms:
-
-     OS
-     KERNEL-OS
-
-   See the file `config.sub' for the possible values of each field.  If
-`config.sub' isn't included in this package, then this package doesn't
-need to know the machine type.
-
-   If you are _building_ compiler tools for cross-compiling, you should
-use the option `--target=TYPE' to select the type of system they will
-produce code for.
-
-   If you want to _use_ a cross compiler, that generates code for a
-platform different from the build platform, you should specify the
-"host" platform (i.e., that on which the generated programs will
-eventually be run) with `--host=TYPE'.
-
-Sharing Defaults
-================
-
-   If you want to set default values for `configure' scripts to share,
-you can create a site shell script called `config.site' that gives
-default values for variables like `CC', `cache_file', and `prefix'.
-`configure' looks for `PREFIX/share/config.site' if it exists, then
-`PREFIX/etc/config.site' if it exists.  Or, you can set the
-`CONFIG_SITE' environment variable to the location of the site script.
-A warning: not all `configure' scripts look for a site script.
-
-Defining Variables
-==================
-
-   Variables not defined in a site shell script can be set in the
-environment passed to `configure'.  However, some packages may run
-configure again during the build, and the customized values of these
-variables may be lost.  In order to avoid this problem, you should set
-them in the `configure' command line, using `VAR=value'.  For example:
-
-     ./configure CC=/usr/local2/bin/gcc
-
-causes the specified `gcc' to be used as the C compiler (unless it is
-overridden in the site shell script).
-
-Unfortunately, this technique does not work for `CONFIG_SHELL' due to
-an Autoconf bug.  Until the bug is fixed you can use this workaround:
-
-     CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
-
-`configure' Invocation
-======================
-
-   `configure' recognizes the following options to control how it
-operates.
-
-`--help'
-`-h'
-     Print a summary of all of the options to `configure', and exit.
-
-`--help=short'
-`--help=recursive'
-     Print a summary of the options unique to this package's
-     `configure', and exit.  The `short' variant lists options used
-     only in the top level, while the `recursive' variant lists options
-     also present in any nested packages.
-
-`--version'
-`-V'
-     Print the version of Autoconf used to generate the `configure'
-     script, and exit.
-
-`--cache-file=FILE'
-     Enable the cache: use and save the results of the tests in FILE,
-     traditionally `config.cache'.  FILE defaults to `/dev/null' to
-     disable caching.
-
-`--config-cache'
-`-C'
-     Alias for `--cache-file=config.cache'.
-
-`--quiet'
-`--silent'
-`-q'
-     Do not print messages saying which checks are being made.  To
-     suppress all normal output, redirect it to `/dev/null' (any error
-     messages will still be shown).
-
-`--srcdir=DIR'
-     Look for the package's source code in directory DIR.  Usually
-     `configure' can determine that directory automatically.
-
-`--prefix=DIR'
-     Use DIR as the installation prefix.  *Note Installation Names::
-     for more details, including other options available for fine-tuning
-     the installation locations.
-
-`--no-create'
-`-n'
-     Run the configure checks, but stop before creating any output
-     files.
-
-`configure' also accepts some other, not widely useful, options.  Run
-`configure --help' for more details.
-
diff --git a/README b/README
index 200a43b..687683a 100644
--- a/README
+++ b/README
@@ -6,7 +6,12 @@ Please read INSTALL
 
 https://bugs.launchpad.net/xfce4-volumed
 
-== Known Gstreamer prooblems
+== Known Gstreamer problems
  * No sound card detected: if this happens you're probably missing a GStreamer
    plugin for your sound system. If you're using ALSA then installing 
    gstreamer0.10-alsa should fix it.
+
+== Known installation problems
+ * Your system may not have libkeybinder packaged, or may have it without the
+   proper pkg-config file. You can find the libkeybinder source at
+   http://github.com/engla/keybinder/tree/master/libkeybinder/
diff --git a/configure.ac b/configure.ac
index 7918776..d187f9d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([xfce4-volumed], [0.1.8], [http://bugs.launchpad.net/xfce4-volumed])
+AC_INIT([xfce4-volumed], [0.1.9], [http://bugs.launchpad.net/xfce4-volumed])
 AM_INIT_AUTOMAKE([AC_PACKAGE_TARNAME()], [AC_PACKAGE_VERSION()])
 
 AC_CONFIG_SRCDIR([src/main.c])
@@ -23,14 +23,9 @@ PKG_CHECK_MODULES(GSTREAMER_AUDIO, [gstreamer-audio-0.10])
 AC_SUBST(GSTREAMER_AUDIO_CFLAGS)
 AC_SUBST(GSTREAMER_AUDIO_LIBS)
 
-PKG_CHECK_MODULES(XCB_KEYSYMS, xcb-keysyms >= 0.3.5, [],
-[
-    PKG_CHECK_MODULES(XCB_KEYSYMS, [xcb-keysyms])
-    LEGACY_XCB_KEYSYMS=1
-])
-AC_SUBST(XCB_KEYSYMS_CFLAGS)
-AC_SUBST(XCB_KEYSYMS_LIBS)
-AM_CONDITIONAL(LEGACY_XCBKEYSYMS, [test "$LEGACY_XCB_KEYSYMS" = "1"])
+PKG_CHECK_MODULES(LIBKEYBINDER, [keybinder])
+AC_SUBST(LIBKEYBINDER_CFLAGS)
+AC_SUBST(LIBKEYBINDER_LIBS)
 
 AC_ARG_WITH(libnotify,
    AS_HELP_STRING([--with-libnotify], [enable notifications 
(default=autodetect)]),
@@ -77,9 +72,6 @@ echo "----------------------------------------"
 echo "Xfce4-Volumed"
 echo " Installing in : ${prefix}"
 echo " Using LibNotify : ${with_libnotify}"
-if test "$LEGACY_XCB_KEYSYMS" = "1"; then
-    echo "     Legacy XCB Keysyms : yes"
-fi
 echo " Compiler : ${CC}"
 echo " Compiler flags : ${CFLAGS}"
 echo ""
diff --git a/src/Makefile.am b/src/Makefile.am
index d69fd35..2d04727 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -17,7 +17,7 @@ INCLUDES =                                            \
        @XFCONF_CFLAGS@                         \
        @GSTREAMER_CFLAGS@                      \
        @GSTREAMER_AUDIO_CFLAGS@        \
-       @XCB_KEYSYMS_CFLAGS@            \
+       @LIBKEYBINDER_CFLAGS@           \
        @LIBNOTIFY_CFLAGS@
 
 xfce4_volumed_LDADD =          \
@@ -25,9 +25,6 @@ xfce4_volumed_LDADD =                 \
        @XFCONF_LIBS@                   \
        @GSTREAMER_LIBS@                \
        @GSTREAMER_AUDIO_LIBS@  \
-       @XCB_KEYSYMS_LIBS@              \
+       @LIBKEYBINDER_LIBS@             \
        @LIBNOTIFY_LIBS@
-       
-if LEGACY_XCBKEYSYMS
-xfce4_volumed_CFLAGS = -DLEGACY_XCBKEYSYMS
-endif
+
diff --git a/src/main.c b/src/main.c
index b83fa85..18e8e01 100644
--- a/src/main.c
+++ b/src/main.c
@@ -103,14 +103,6 @@ xvd_instance_init(XvdInstance *i)
        i->loop = NULL;
        i->current_vol = 0;
        i->muted = FALSE;
-       i->conn = NULL;
-       #ifndef LEGACY_XCBKEYSYMS
-       // In legacy mode xcb keycodes are not pointers to lists but structs
-       i->keyRaise = NULL;
-       i->keyLower = NULL;
-       i->keyMute = NULL;
-       #endif
-       i->kss = NULL;
        #ifdef HAVE_LIBNOTIFY
        i->gauge_notifications = FALSE;
        i->notification = NULL;
@@ -126,16 +118,18 @@ main(gint argc, gchar **argv)
        #ifdef NDEBUG
        xvd_daemonize();
        #endif
+  
+  gtk_init(&argc, &argv);
 
        /* Gstreamer init */
        gst_init (NULL,NULL);
 
-       /* Xcb init */
+       /* Grab the keys */
        xvd_keys_init (Inst);
 
        /* Xfconf init */
        xvd_xfconf_init (Inst);
-       
+  
        /* Get card/track from xfconf */
        if (!xvd_xfconf_get_card (Inst)) {
                g_debug ("Main: There seems to be no active card defined in 
xfconf.\n");
diff --git a/src/xvd_data_types.h b/src/xvd_data_types.h
index 0cef4ed..16e5e1b 100644
--- a/src/xvd_data_types.h
+++ b/src/xvd_data_types.h
@@ -20,6 +20,10 @@
 #ifndef _XVD_DATA_TYPES_H
 #define _XVD_DATA_TYPES_H
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #define XFCONF_MIXER_CHANNEL_NAME "xfce4-mixer"
 #define XFCONF_MIXER_ACTIVECARD "/active-card"
 #define XFCONF_MIXER_ACTIVECARD_LEGACY "/sound-card"
@@ -36,9 +40,7 @@
 
 #include <gst/audio/mixerutils.h>
 
-#include <xcb/xcb.h>
-#include <xcb/xcb_keysyms.h>
-#include <X11/XF86keysym.h>
+#include <keybinder.h>
 #ifdef HAVE_LIBNOTIFY
 #include <libnotify/notification.h>
 #endif
@@ -69,22 +71,8 @@ typedef struct {
        guint                           current_vol;
        guint                           vol_step;
        gboolean                muted;
-       
-       /* Xcb vars */
-       xcb_connection_t        *conn;
-       xcb_window_t            root_win;
-       xcb_key_symbols_t       *kss;
-       #ifndef LEGACY_XCBKEYSYMS
-       xcb_keycode_t           *keyRaise,
-                                               *keyLower,
-                                               *keyMute;
-       #else
-       xcb_keycode_t           keyRaise,
-                                               keyLower,
-                                               keyMute;
-       #endif
-    
-    #ifdef HAVE_LIBNOTIFY
+  
+  #ifdef HAVE_LIBNOTIFY
     /* Libnotify vars */
        gboolean                        gauge_notifications;
        NotifyNotification* notification;
diff --git a/src/xvd_keys.c b/src/xvd_keys.c
index 51a8b11..fdb3473 100644
--- a/src/xvd_keys.c
+++ b/src/xvd_keys.c
@@ -27,298 +27,73 @@
 #include "xvd_notify.h"
 #endif
 
-#ifndef LEGACY_XCBKEYSYMS
-// This is only needed when the keycodes are a list and not a struct
-static gboolean
-_xvd_keys_is_symbol(xcb_keycode_t elem,
-                                       xcb_keycode_t *list)
+static
+void xvd_raise_handler (const char *keystring, void *Inst)
 {
-       gint i = 0;
-       gboolean belongs = FALSE;
-       
-       if (list == NULL)
-               return FALSE;
-       
-       while (list[i] != XCB_NO_SYMBOL) {
-               belongs |= (elem == list[i]);
-               i++;
-       }
-       
-       return belongs;
+  XvdInstance *xvd_inst = (XvdInstance *) Inst;
+  
+  g_debug ("The RaiseVolume key was pressed.");
+  
+  if (xvd_mixer_change_volume (xvd_inst, xvd_inst->vol_step)) {
+               #ifdef HAVE_LIBNOTIFY
+                       if (xvd_inst->current_vol == 100)
+                               xvd_notify_overshoot_notification (xvd_inst);
+                       else
+                               xvd_notify_volume_notification (xvd_inst);
+               #endif
+  }
 }
-#endif
 
-static gboolean 
-_xvd_keys_handle_events(GIOChannel *source, 
-                                               GIOCondition cond, 
-                                               gpointer data)
+static
+void xvd_lower_handler (const char *keystring, void *Inst)
 {
-       XvdInstance *Inst = (XvdInstance *)data;
-       
-       if (cond | G_IO_IN) {
-               xcb_generic_event_t *ev;
-               xcb_key_press_event_t *kpe;
-
-               while ((ev = xcb_poll_for_event(Inst->conn))) {
-                       switch (ev->response_type & ~0x80) {
-                               case XCB_KEY_PRESS:
-                                       kpe = (xcb_key_press_event_t *)ev;
-                                       
-                                       #ifndef LEGACY_XCBKEYSYMS
-                                       if (_xvd_keys_is_symbol(kpe->detail, 
Inst->keyRaise)) {
-                    #else
-                                       if (kpe->detail == Inst->keyRaise) {
-                    #endif
-                                           #ifndef NDEBUG
-                               g_debug ("The RaiseVolume key was pressed.\n");
-                               #endif
-                                               if (xvd_mixer_change_volume 
(Inst, Inst->vol_step)) {
-                                                       #ifdef HAVE_LIBNOTIFY
-/*                                                     if (!Inst->muted) {*/
-                                                       if (Inst->current_vol 
== 100)
-                                                               
xvd_notify_overshoot_notification (Inst);
-                                                       else
-                                                               
xvd_notify_volume_notification (Inst);
-/*                                                     }*/
-                                                       #endif
-                                               }
-                                       }
-
-                                       #ifndef LEGACY_XCBKEYSYMS
-                                       else if 
(_xvd_keys_is_symbol(kpe->detail, Inst->keyLower)) {
-                    #else
-                                       else if (kpe->detail == Inst->keyLower) 
{
-                    #endif
-                                           #ifndef NDEBUG
-                               g_debug ("The LowerVolume key was pressed.\n");
-                               #endif
-                                               if (xvd_mixer_change_volume 
(Inst, (Inst->vol_step * -1))) {
-                                                       #ifdef HAVE_LIBNOTIFY
-/*                                                     if (!Inst->muted) {*/
-                                                       if (Inst->current_vol 
== 0)
-                                                               
xvd_notify_undershoot_notification (Inst);
-                                                       else
-                                                               
xvd_notify_volume_notification (Inst);
-/*                                                     }*/
-                                                       #endif
-                                               }
-                                       }
-
-                                       #ifndef LEGACY_XCBKEYSYMS
-                                       else if 
(_xvd_keys_is_symbol(kpe->detail, Inst->keyMute)) {
-                    #else
-                                       else if (kpe->detail == Inst->keyMute) {
-                    #endif
-                                           #ifndef NDEBUG
-                               g_debug ("The Mute key was pressed.\n");
-                               #endif
-                                               if (xvd_mixer_toggle_mute 
(Inst)) {
-                                                       #ifdef HAVE_LIBNOTIFY
-                                                       if (Inst->muted)
-                                                               
xvd_notify_notification (Inst, "audio-volume-muted", Inst->current_vol);
-                                                       else {
-                                                               
xvd_mixer_init_volume (Inst);
-                                                               
xvd_notify_volume_notification (Inst);
-                                                       }
-                                                       #endif
-                                               }
-                                       }
-                                       break;
-                               
-                               default :
-                                       break;
-                       }
-
-                       free (ev);
-               }
-       }
-
-       return TRUE;
+  XvdInstance *xvd_inst = (XvdInstance *) Inst;
+  
+  g_debug ("The LowerVolume key was pressed.");
+  
+  if (xvd_mixer_change_volume (xvd_inst, xvd_inst->vol_step * -1)) {
+               #ifdef HAVE_LIBNOTIFY
+                       if (xvd_inst->current_vol == 0)
+                               xvd_notify_undershoot_notification (xvd_inst);
+                       else
+                               xvd_notify_volume_notification (xvd_inst);
+               #endif
+  }
 }
 
-void 
-xvd_keys_init(XvdInstance *Inst)
+static
+void xvd_mute_handler (const char *keystring, void *Inst)
 {
-       int                             screennum, 
-                                               i;
-       char                            *display =              NULL;
-       const xcb_setup_t       *setup =                NULL;
-       xcb_screen_t            *screen =               NULL;
-       xcb_void_cookie_t       cookie;
-       xcb_generic_error_t *error =            NULL;
-       uint16_t                        mod =                   0;
-       
-       /* Get the display and connect to it */
-       display = getenv ("DISPLAY");
-       if (!display) {
-               g_warning ("No DISPLAY variable set - X11 plugin disabled\n");
-               return;
-       }
-
-       Inst->conn = xcb_connect (display, &screennum);
-       if (!Inst->conn) {
-               g_warning ("Could not open display %s - X11 plugin disabled\n", 
display);
-               return;
-       }
-       
-       if (xcb_connection_has_error (Inst->conn)) {
-               g_warning ("XCB error while connecting\n");
-               return;
-       }
-
-       /* Init the window and symbols vars */
-       setup = xcb_get_setup (Inst->conn);
-
-       xcb_screen_iterator_t it = xcb_setup_roots_iterator (setup);
-       for (i = 0; i < screennum; i++)
-               xcb_screen_next (&it);
-       screen = it.data;
-
-       Inst->root_win = screen->root;
-       
-       Inst->kss = xcb_key_symbols_alloc (Inst->conn);
-
-       /* Grab the XF86AudioRaiseVolume key */
-       #ifndef LEGACY_XCBKEYSYMS
-       Inst->keyRaise = xcb_key_symbols_get_keycode (Inst->kss, 
XF86XK_AudioRaiseVolume);
-       
-       if (Inst->keyRaise == NULL) {
-               g_debug ("There is no X86AudioRaiseVolume key on your 
system.\n");
-       }
-       else {
-               i = 0;
-               while (Inst->keyRaise[i] != XCB_NO_SYMBOL) {
-                       cookie = xcb_grab_key_checked (Inst->conn, TRUE, 
Inst->root_win, 
-                                                                               
        mod, Inst->keyRaise[i], 
-                                                                               
        XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
-                       error = xcb_request_check (Inst->conn, cookie);
-                       if (error) {
-                               fprintf (stderr, "XCB: Unable to bind 
RaiseVolume keycode=%d mod=0x%04x: %d\n",
-                               Inst->keyRaise[i], mod, error->error_code);
-                       }
-                       else {
-                               g_print ("XCB: RaiseVolume ok, keycode=%d 
mod=0x%04x\n",
-                               Inst->keyRaise[i], mod);
-                       }
-                       i++;
-               }
-       }
-
-       /* Grab the XF86AudioLowerVolume key */
-       Inst->keyLower = xcb_key_symbols_get_keycode (Inst->kss, 
XF86XK_AudioLowerVolume);
-       
-       if (Inst->keyLower == NULL) {
-               g_debug ("There is no X86AudioLowerVolume key on your 
system.\n");
-       }
-       else {
-               i = 0;
-               while (Inst->keyLower[i] != XCB_NO_SYMBOL) {
-                       cookie = xcb_grab_key_checked (Inst->conn, TRUE, 
Inst->root_win, 
-                                                                               
        mod, Inst->keyLower[i], 
-                                                                               
        XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
-                       error = xcb_request_check (Inst->conn, cookie);
-                       if (error) {
-                               fprintf (stderr, "XCB: Unable to bind 
LowerVolume keycode=%d mod=0x%04x: %d\n",
-                               Inst->keyLower[i], mod, error->error_code);
-                       }
-                       else {
-                               g_print ("XCB: LowerVolume ok, keycode=%d 
mod=0x%04x\n",
-                               Inst->keyLower[i], mod);
-                       }
-                       i++;
-               }
-       }
-       
-       /* Grab the XF86AudioMute key */
-       Inst->keyMute = xcb_key_symbols_get_keycode (Inst->kss, 
XF86XK_AudioMute);
-
-       if (Inst->keyMute == NULL) {
-               g_debug ("There is no X86AudioMute key on your system.\n");
-       }
-       else {  
-               i = 0;
-               while (Inst->keyMute[i] != XCB_NO_SYMBOL) {
-                       cookie = xcb_grab_key_checked (Inst->conn, TRUE, 
Inst->root_win, 
-                                                                               
        mod, Inst->keyMute[i], 
-                                                                               
        XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
-                       error = xcb_request_check (Inst->conn, cookie);
-                       if (error) {
-                               fprintf (stderr, "XCB: Unable to bind Mute 
keycode=%d mod=0x%04x: %d\n",
-                               Inst->keyMute[i], mod, error->error_code);
-                       }
+  XvdInstance *xvd_inst = (XvdInstance *) Inst;
+  
+  g_debug ("The LowerVolume key was pressed.");
+  
+  if (xvd_mixer_toggle_mute (xvd_inst)) {
+               #ifdef HAVE_LIBNOTIFY
+                       if (xvd_inst->muted)
+                               xvd_notify_notification (xvd_inst, 
"audio-volume-muted", xvd_inst->current_vol);
                        else {
-                               g_print ("XCB: Mute ok, keycode=%d 
mod=0x%04x\n",
-                               Inst->keyMute[i], mod);
+                               xvd_mixer_init_volume (xvd_inst);
+                               xvd_notify_volume_notification (xvd_inst);
                        }
-                       i++;
-               }
-       }
-       
-       
-       #else
-       Inst->keyRaise = xcb_key_symbols_get_keycode (Inst->kss, 
XF86XK_AudioRaiseVolume);
-       
-       cookie = xcb_grab_key_checked (Inst->conn, TRUE, Inst->root_win, 
-                                                                       mod, 
Inst->keyRaise, 
-                                                                       
XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
-       error = xcb_request_check (Inst->conn, cookie);
-       if (error) {
-               fprintf (stderr, "XCB: Unable to bind RaiseVolume keycode=%d 
mod=0x%04x: %d\n",
-               Inst->keyRaise, mod, error->error_code);
-       }
-       else {
-               g_print ("XCB: RaiseVolume ok, keycode=%d mod=0x%04x\n",
-               Inst->keyRaise, mod);
-       }
-
-       /* Grab the XF86AudioLowerVolume key */
-       Inst->keyLower = xcb_key_symbols_get_keycode (Inst->kss, 
XF86XK_AudioLowerVolume);
-       
-       cookie = xcb_grab_key_checked (Inst->conn, TRUE, Inst->root_win, 
-                                                                       mod, 
Inst->keyLower, 
-                                                                       
XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
-       error = xcb_request_check (Inst->conn, cookie);
-       if (error) {
-               fprintf (stderr, "XCB: Unable to bind LowerVolume keycode=%d 
mod=0x%04x: %d\n",
-               Inst->keyLower, mod, error->error_code);
-       }
-       else {
-               g_print ("XCB: LowerVolume ok, keycode=%d mod=0x%04x\n",
-               Inst->keyLower, mod);
+               #endif
        }
+}
 
-       
-       /* Grab the XF86AudioMute key */
-       Inst->keyMute = xcb_key_symbols_get_keycode (Inst->kss, 
XF86XK_AudioMute);
-       
-       cookie = xcb_grab_key_checked (Inst->conn, TRUE, Inst->root_win, 
-                                                                       mod, 
Inst->keyMute, 
-                                                                       
XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
-       error = xcb_request_check (Inst->conn, cookie);
-       if (error) {
-               fprintf (stderr, "XCB: Unable to bind Mute keycode=%d 
mod=0x%04x: %d\n",
-               Inst->keyMute, mod, error->error_code);
-       }
-       else {
-               g_print ("XCB: Mute ok, keycode=%d mod=0x%04x\n",
-               Inst->keyMute, mod);
-       }
-       #endif
+void
+xvd_keys_init(XvdInstance *Inst)
+{
+    keybinder_init();
 
-       GIOChannel *channel = g_io_channel_unix_new (xcb_get_file_descriptor 
(Inst->conn));
-       g_io_add_watch (channel, G_IO_IN|G_IO_HUP, _xvd_keys_handle_events, 
Inst);
+    keybinder_bind ("XF86AudioRaiseVolume", xvd_raise_handler, Inst);
+    keybinder_bind ("XF86AudioLowerVolume", xvd_lower_handler, Inst);
+    keybinder_bind ("XF86AudioMute", xvd_mute_handler, Inst);
 }
 
-void 
+void
 xvd_keys_release (XvdInstance *Inst)
 {
-       #ifndef LEGACY_XCBKEYSYMS
-       g_free (Inst->keyRaise);
-       g_free (Inst->keyLower);
-       g_free (Inst->keyMute);
-       #endif
-       if (Inst->kss)
-               xcb_key_symbols_free (Inst->kss);
-       if (Inst->conn)
-               xcb_disconnect (Inst->conn);
+    keybinder_unbind ("XF86AudioRaiseVolume", xvd_raise_handler);
+    keybinder_unbind ("XF86AudioLowerVolume", xvd_lower_handler);
+    keybinder_unbind ("XF86AudioMute", xvd_mute_handler);
 }
diff --git a/src/xvd_keys.h b/src/xvd_keys.h
index d271693..1e70970 100644
--- a/src/xvd_keys.h
+++ b/src/xvd_keys.h
@@ -25,11 +25,6 @@
 
 #include "xvd_data_types.h"
 
-struct xvd_binding_t {
-  xcb_keycode_t code;
-  uint16_t mod;
-};
-
 void 
 xvd_keys_init(XvdInstance *Inst);
 
_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to