gnome-settings-daemon r306 - in trunk: . plugins plugins/common plugins/keybindings plugins/media-keys plugins/media-keys/actions
- From: jensg svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-settings-daemon r306 - in trunk: . plugins plugins/common plugins/keybindings plugins/media-keys plugins/media-keys/actions
- Date: Sun, 13 Apr 2008 11:40:01 +0100 (BST)
Author: jensg
Date: Sun Apr 13 11:40:01 2008
New Revision: 306
URL: http://svn.gnome.org/viewvc/gnome-settings-daemon?rev=306&view=rev
Log:
2008-04-13 Jens Granseuer <jensgr gmx net>
Extract some functionality used by several plugins into a separate
shared helper library (bug #525426).
* configure.ac:
* plugins/Makefile.am:
* plugins/common/Makefile.am:
* plugins/common/gsd-keygrab.c:
* plugins/common/gsd-keygrab.h:
* plugins/common/eggaccelerators.c:
* plugins/common/eggaccelerators.h: new shared components
* plugins/keybindings/Makefile.am:
* plugins/keybindings/eggaccelerators.c:
* plugins/keybindings/eggaccelerators.h:
* plugins/keybindings/gsd-keybindings-manager.c:
(binding_register_keys), (keybindings_filter):
* plugins/media-keys/Makefile.am:
* plugins/media-keys/actions/Makefile.am:
* plugins/media-keys/actions/acme.h:
* plugins/media-keys/eggaccelerators.c:
* plugins/media-keys/eggaccelerators.h:
* plugins/media-keys/gsd-media-keys-manager.c: (update_kbd_cb),
(init_kbd), (acme_filter_events):
make keybindings and media-keys plugins use the shared components
Added:
trunk/plugins/common/ (props changed)
trunk/plugins/common/Makefile.am
trunk/plugins/common/eggaccelerators.c
- copied unchanged from r304, /trunk/plugins/media-keys/eggaccelerators.c
trunk/plugins/common/eggaccelerators.h
- copied unchanged from r304, /trunk/plugins/media-keys/eggaccelerators.h
trunk/plugins/common/gsd-keygrab.c
trunk/plugins/common/gsd-keygrab.h
Removed:
trunk/plugins/keybindings/eggaccelerators.c
trunk/plugins/keybindings/eggaccelerators.h
trunk/plugins/media-keys/eggaccelerators.c
trunk/plugins/media-keys/eggaccelerators.h
Modified:
trunk/ChangeLog
trunk/configure.ac
trunk/plugins/Makefile.am
trunk/plugins/keybindings/Makefile.am
trunk/plugins/keybindings/gsd-keybindings-manager.c
trunk/plugins/media-keys/Makefile.am
trunk/plugins/media-keys/actions/Makefile.am
trunk/plugins/media-keys/actions/acme.h
trunk/plugins/media-keys/gsd-media-keys-manager.c
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Sun Apr 13 11:40:01 2008
@@ -56,8 +56,6 @@
dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION
libgnome-2.0
)
-AC_SUBST(SETTINGS_DAEMON_CFLAGS)
-AC_SUBST(SETTINGS_DAEMON_LIBS)
PKG_CHECK_MODULES(SETTINGS_PLUGIN,
gtk+-2.0 >= $GTK_REQUIRED_VERSION
@@ -67,8 +65,6 @@
libglade-2.0 >= 2.0.0
dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION
)
-AC_SUBST(SETTINGS_PLUGIN_CFLAGS)
-AC_SUBST(SETTINGS_PLUGIN_LIBS)
PKG_CHECK_MODULES(GNOME, libgnome-2.0 libgnomeui-2.0)
PKG_CHECK_MODULES(LIBBACKGROUND, glib-2.0 gobject-2.0 gdk-2.0 gconf-2.0)
@@ -406,6 +402,7 @@
plugins/background/Makefile
plugins/background/libbackground/Makefile
plugins/clipboard/Makefile
+plugins/common/Makefile
plugins/dummy/Makefile
plugins/font/Makefile
plugins/housekeeping/Makefile
Modified: trunk/plugins/Makefile.am
==============================================================================
--- trunk/plugins/Makefile.am (original)
+++ trunk/plugins/Makefile.am Sun Apr 13 11:40:01 2008
@@ -1,6 +1,7 @@
NULL =
SUBDIRS = \
+ common \
a11y-keyboard \
background \
clipboard \
Added: trunk/plugins/common/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/plugins/common/Makefile.am Sun Apr 13 11:40:01 2008
@@ -0,0 +1,21 @@
+
+noinst_LTLIBRARIES = libcommon.la
+
+libcommon_la_SOURCES = \
+ eggaccelerators.c \
+ eggaccelerators.h \
+ gsd-keygrab.c \
+ gsd-keygrab.h
+
+libcommon_la_CPPFLAGS = \
+ $(AM_CPPFLAGS)
+
+libcommon_la_CFLAGS = \
+ $(SETTINGS_PLUGIN_CFLAGS) \
+ $(AM_CFLAGS)
+
+libcommon_la_LDFLAGS = \
+ $(GSD_PLUGIN_LDFLAGS)
+
+libcommon_la_LIBADD = \
+ $(SETTINGS_PLUGIN_LIBS)
Added: trunk/plugins/common/gsd-keygrab.c
==============================================================================
--- (empty file)
+++ trunk/plugins/common/gsd-keygrab.c Sun Apr 13 11:40:01 2008
@@ -0,0 +1,128 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2001-2003 Bastien Nocera <hadess hadess net>
+ * Copyright (C) 2006-2007 William Jon McCann <mccann jhu edu>
+ * Copyright (C) 2008 Jens Granseuer <jensgr gmx net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+
+#include <gdk/gdk.h>
+#include <gdk/gdkx.h>
+
+#include "gsd-keygrab.h"
+
+/* we exclude shift, GDK_CONTROL_MASK and GDK_MOD1_MASK since we know what
+ these modifiers mean
+ these are the mods whose combinations are bound by the keygrabbing code */
+#define GSD_IGNORED_MODS (0x2000 /*Xkb modifier*/ | GDK_LOCK_MASK | \
+ GDK_MOD2_MASK | GDK_MOD3_MASK | GDK_MOD4_MASK | GDK_MOD5_MASK)
+/* these are the ones we actually use for global keys, we always only check
+ * for these set */
+#define GSD_USED_MODS (GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)
+
+
+static gboolean
+grab_key_real (guint keycode,
+ GdkWindow *root,
+ gboolean grab,
+ int mask)
+{
+ gdk_error_trap_push ();
+ if (grab) {
+ XGrabKey (GDK_DISPLAY (),
+ keycode,
+ mask,
+ GDK_WINDOW_XID (root),
+ True,
+ GrabModeAsync,
+ GrabModeAsync);
+ } else {
+ XUngrabKey (GDK_DISPLAY (),
+ keycode,
+ mask,
+ GDK_WINDOW_XID (root));
+ }
+
+ gdk_flush ();
+ return gdk_error_trap_pop () == 0;
+}
+
+/* Grab the key. In order to ignore GSD_IGNORED_MODS we need to grab
+ * all combinations of the ignored modifiers and those actually used
+ * for the binding (if any).
+ *
+ * inspired by all_combinations from gnome-panel/gnome-panel/global-keys.c */
+#define N_BITS 32
+void
+grab_key (Key *key,
+ gboolean grab,
+ GSList *screens)
+{
+ int indexes[N_BITS]; /* indexes of bits we need to flip */
+ int i;
+ int bit;
+ int bits_set_cnt;
+ int uppervalue;
+ guint mask = GSD_IGNORED_MODS & ~key->state & GDK_MODIFIER_MASK;
+
+ bit = 0;
+ /* store the indexes of all set bits in mask in the array */
+ for (i = 0; mask; ++i, mask >>= 1) {
+ if (mask & 0x1) {
+ indexes[bit++] = i;
+ }
+ }
+
+ bits_set_cnt = bit;
+
+ uppervalue = 1 << bits_set_cnt;
+ /* grab all possible modifier combinations for our mask */
+ for (i = 0; i < uppervalue; ++i) {
+ GSList *l;
+ int j;
+ int result = 0;
+
+ /* map bits in the counter to those in the mask */
+ for (j = 0; j < bits_set_cnt; ++j) {
+ if (i & (1 << j)) {
+ result |= (1 << indexes[j]);
+ }
+ }
+
+ for (l = screens; l; l = l->next) {
+ GdkScreen *screen = l->data;
+ if (!grab_key_real (key->keycode,
+ gdk_screen_get_root_window (screen),
+ grab,
+ result | key->state)) {
+ g_warning ("Grab failed, another application may already have access to key '%u'",
+ key->keycode);
+ return;
+ }
+ }
+ }
+}
+
+gboolean
+match_key (Key *key, XEvent *event)
+{
+ return (key != NULL
+ && key->keycode == event->xkey.keycode
+ && key->state == (event->xkey.state & GSD_USED_MODS));
+}
Added: trunk/plugins/common/gsd-keygrab.h
==============================================================================
--- (empty file)
+++ trunk/plugins/common/gsd-keygrab.h Sun Apr 13 11:40:01 2008
@@ -0,0 +1,44 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Jens Granseuer <jensgr gmx net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GSD_COMMON_KEYGRAB_H
+#define __GSD_COMMON_KEYGRAB_H
+
+G_BEGIN_DECLS
+
+#include <glib.h>
+#include <X11/keysym.h>
+
+typedef struct {
+ guint keysym;
+ guint state;
+ guint keycode;
+} Key;
+
+
+void grab_key (Key *key,
+ gboolean grab,
+ GSList *screens);
+
+gboolean match_key (Key *key,
+ XEvent *event);
+
+G_END_DECLS
+
+#endif /* __GSD_COMMON_KEYGRAB_H */
Modified: trunk/plugins/keybindings/Makefile.am
==============================================================================
--- trunk/plugins/keybindings/Makefile.am (original)
+++ trunk/plugins/keybindings/Makefile.am Sun Apr 13 11:40:01 2008
@@ -9,12 +9,11 @@
gsd-keybindings-plugin.c \
gsd-keybindings-manager.h \
gsd-keybindings-manager.c \
- eggaccelerators.h \
- eggaccelerators.c \
$(NULL)
libkeybindings_la_CPPFLAGS = \
-I$(top_srcdir)/gnome-settings-daemon \
+ -I$(top_srcdir)/plugins/common \
-DGNOME_SETTINGS_LOCALEDIR=\""$(datadir)/locale"\" \
$(AM_CPPFLAGS)
@@ -27,7 +26,8 @@
$(NULL)
libkeybindings_la_LIBADD = \
- $(SETTINGS_PLUGIN_LIBS) \
+ $(top_builddir)/plugins/common/libcommon.la \
+ $(SETTINGS_PLUGIN_LIBS) \
$(NULL)
plugin_in_files = \
Modified: trunk/plugins/keybindings/gsd-keybindings-manager.c
==============================================================================
--- trunk/plugins/keybindings/gsd-keybindings-manager.c (original)
+++ trunk/plugins/keybindings/gsd-keybindings-manager.c Sun Apr 13 11:40:01 2008
@@ -41,28 +41,14 @@
#include "gnome-settings-profile.h"
#include "gsd-keybindings-manager.h"
+#include "gsd-keygrab.h"
#include "eggaccelerators.h"
-/* we exclude shift, GDK_CONTROL_MASK and GDK_MOD1_MASK since we know what
- these modifiers mean
- these are the mods whose combinations are bound by the keygrabbing code */
-#define IGNORED_MODS (0x2000 /*Xkb modifier*/ | GDK_LOCK_MASK | \
- GDK_MOD2_MASK | GDK_MOD3_MASK | GDK_MOD4_MASK | GDK_MOD5_MASK)
-/* these are the ones we actually use for global keys, we always only check
- * for these set */
-#define USED_MODS (GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)
-
#define GCONF_BINDING_DIR "/desktop/gnome/keybindings"
#define GSD_KEYBINDINGS_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_KEYBINDINGS_MANAGER, GsdKeybindingsManagerPrivate))
typedef struct {
- guint keysym;
- guint state;
- guint keycode;
-} Key;
-
-typedef struct {
char *binding_str;
char *action;
char *gconf_key;
@@ -257,7 +243,6 @@
return TRUE;
}
-
static gboolean
key_already_used (GsdKeybindingsManager *manager,
Binding *binding)
@@ -277,86 +262,6 @@
}
static void
-grab_key (GdkWindow *root,
- Key *key,
- int result,
- gboolean grab)
-{
- gdk_error_trap_push ();
-
- if (grab) {
- XGrabKey (GDK_DISPLAY (),
- key->keycode,
- (result | key->state),
- GDK_WINDOW_XID (root),
- True,
- GrabModeAsync,
- GrabModeAsync);
- } else {
- XUngrabKey (GDK_DISPLAY (),
- key->keycode,
- (result | key->state),
- GDK_WINDOW_XID (root));
- }
- gdk_flush ();
- if (gdk_error_trap_pop ()) {
- g_warning (_("It seems that another application already has access to key '%u'."),
- key->keycode);
- }
-}
-
-/* Grab the key. In order to ignore IGNORED_MODS we need to grab
- * all combinations of the ignored modifiers and those actually used
- * for the binding (if any).
- *
- * inspired by all_combinations from gnome-panel/gnome-panel/global-keys.c */
-#define N_BITS 32
-static void
-do_grab (GsdKeybindingsManager *manager,
- gboolean grab,
- Key *key)
-{
- int indexes[N_BITS]; /* indexes of bits we need to flip */
- int i;
- int bit;
- int bits_set_cnt;
- int uppervalue;
- guint mask = IGNORED_MODS & ~key->state & GDK_MODIFIER_MASK;
-
- bit = 0;
- /* store the indices of all set bits in mask in the array */
- for (i = 0; mask; ++i, mask >>= 1) {
- if (mask & 0x1) {
- indexes[bit++] = i;
- }
- }
-
- bits_set_cnt = bit;
-
- uppervalue = 1 << bits_set_cnt;
- /* grab all possible modifier combinations for our mask */
- for (i = 0; i < uppervalue; ++i) {
- GSList *l;
- int j, result = 0;
-
- /* map bits in the counter to those in the mask */
- for (j = 0; j < bits_set_cnt; ++j) {
- if (i & (1<<j)) {
- result |= (1<<indexes[j]);
- }
- }
-
- for (l = manager->priv->screens; l ; l = l->next) {
- GdkScreen *screen = l->data;
- grab_key (gdk_screen_get_root_window (screen),
- key,
- result,
- grab);
- }
- }
-}
-
-static void
binding_register_keys (GsdKeybindingsManager *manager)
{
GSList *li;
@@ -372,15 +277,15 @@
/* Ungrab key if it changed and not clashing with previously set binding */
if (! key_already_used (manager, binding)) {
if (binding->previous_key.keycode) {
- do_grab (manager, FALSE, &binding->previous_key);
+ grab_key (&binding->previous_key, FALSE, manager->priv->screens);
}
- do_grab (manager, TRUE, &binding->key);
+ grab_key (&binding->key, TRUE, manager->priv->screens);
binding->previous_key.keysym = binding->key.keysym;
binding->previous_key.state = binding->key.state;
binding->previous_key.keycode = binding->key.keycode;
} else
- g_warning (_("Key Binding (%s) is already in use"), binding->binding_str);
+ g_warning ("Key binding (%s) is already in use", binding->binding_str);
}
}
gdk_flush ();
@@ -471,23 +376,17 @@
GdkEvent *event,
GsdKeybindingsManager *manager)
{
- XEvent *xevent = (XEvent *)gdk_xevent;
- guint keycode;
- guint state;
+ XEvent *xevent = (XEvent *) gdk_xevent;
GSList *li;
if (xevent->type != KeyPress) {
return GDK_FILTER_CONTINUE;
}
- keycode = xevent->xkey.keycode;
- state = xevent->xkey.state;
-
for (li = manager->priv->binding_list; li != NULL; li = li->next) {
- Binding *binding = (Binding*) li->data;
+ Binding *binding = (Binding *) li->data;
- if (keycode == binding->key.keycode &&
- (state & USED_MODS) == binding->key.state) {
+ if (match_key (&binding->key, xevent)) {
GError *error = NULL;
gboolean retval;
gchar **argv = NULL;
Modified: trunk/plugins/media-keys/Makefile.am
==============================================================================
--- trunk/plugins/media-keys/Makefile.am (original)
+++ trunk/plugins/media-keys/Makefile.am Sun Apr 13 11:40:01 2008
@@ -29,13 +29,12 @@
gsd-media-keys-manager.c \
gsd-media-keys-window.h \
gsd-media-keys-window.c \
- eggaccelerators.h \
- eggaccelerators.c \
$(BUILT_SOURCES) \
$(NULL)
libmedia_keys_la_CPPFLAGS = \
-I$(top_srcdir)/gnome-settings-daemon \
+ -I$(top_srcdir)/plugins/common \
-I$(top_builddir)/plugins/media-keys/actions \
-DPIXMAPDIR=\""$(pkgdatadir)"\" \
-DGLADEDIR=\""$(pkgdatadir)"\" \
@@ -50,6 +49,7 @@
$(GSD_PLUGIN_LDFLAGS)
libmedia_keys_la_LIBADD = \
+ $(top_builddir)/plugins/common/libcommon.la \
$(top_builddir)/plugins/media-keys/actions/libacme.la \
$(SETTINGS_PLUGIN_LIBS) \
$(XF86MISC_LIBS) \
@@ -94,14 +94,13 @@
gsd-media-keys-manager.h \
gsd-media-keys-window.h \
gsd-media-keys-window.c \
- eggaccelerators.h \
- eggaccelerators.c \
test-media-keys.c \
$(BUILT_SOURCES) \
$(NULL)
test_media_keys_CPPFLAGS = \
-I$(top_srcdir)/gnome-settings-daemon \
+ -I$(top_srcdir)/plugins/common \
-I$(top_builddir)/plugins/media-keys/actions \
-DPIXMAPDIR=\""$(pkgdatadir)"\" \
-DGLADEDIR=\""$(pkgdatadir)"\" \
@@ -114,6 +113,7 @@
test_media_keys_LDADD = \
$(top_builddir)/gnome-settings-daemon/libgsd-profile.la \
+ $(top_builddir)/plugins/common/libcommon.la \
$(top_builddir)/plugins/media-keys/actions/libacme.la \
$(SETTINGS_DAEMON_LIBS) \
$(SETTINGS_PLUGIN_LIBS) \
Modified: trunk/plugins/media-keys/actions/Makefile.am
==============================================================================
--- trunk/plugins/media-keys/actions/Makefile.am (original)
+++ trunk/plugins/media-keys/actions/Makefile.am Sun Apr 13 11:40:01 2008
@@ -12,6 +12,7 @@
libacme_la_CPPFLAGS = \
-I$(top_srcdir)/gnome-settings-daemon \
+ -I$(top_srcdir)/plugins/common \
-DGNOME_SETTINGS_LOCALEDIR=\""$(datadir)/locale"\" \
$(AM_CPPFLAGS)
Modified: trunk/plugins/media-keys/actions/acme.h
==============================================================================
--- trunk/plugins/media-keys/actions/acme.h (original)
+++ trunk/plugins/media-keys/actions/acme.h Sun Apr 13 11:40:01 2008
@@ -21,6 +21,8 @@
#ifndef __ACME_H__
#define __ACME_H__
+#include "gsd-keygrab.h"
+
#define GCONF_BINDING_DIR "/apps/gnome_settings_daemon/keybindings"
#define GCONF_MISC_DIR "/apps/gnome_settings_daemon"
@@ -47,12 +49,6 @@
HANDLED_KEYS
};
-typedef struct {
- guint keysym;
- guint state;
- guint keycode;
-} Key;
-
static struct {
int key_type;
const char *gconf_key;
Modified: trunk/plugins/media-keys/gsd-media-keys-manager.c
==============================================================================
--- trunk/plugins/media-keys/gsd-media-keys-manager.c (original)
+++ trunk/plugins/media-keys/gsd-media-keys-manager.c Sun Apr 13 11:40:01 2008
@@ -58,15 +58,6 @@
#define VOLUME_STEP 6 /* percents for one volume button press */
-/* we exclude shift, GDK_CONTROL_MASK and GDK_MOD1_MASK since we know what
- these modifiers mean
- these are the mods whose combinations are bound by the keygrabbing code */
-#define IGNORED_MODS (0x2000 /*Xkb modifier*/ | GDK_LOCK_MASK | \
- GDK_MOD2_MASK | GDK_MOD3_MASK | GDK_MOD4_MASK | GDK_MOD5_MASK)
-/* these are the ones we actually use for global keys, we always only check
- * for these set */
-#define USED_MODS (GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)
-
#define GSD_MEDIA_KEYS_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_MEDIA_KEYS_MANAGER, GsdMediaKeysManagerPrivate))
typedef struct {
@@ -266,85 +257,6 @@
}
static gboolean
-grab_key_real (Key *key,
- GdkWindow *root,
- gboolean grab,
- int result)
-{
- gdk_error_trap_push ();
- if (grab) {
- XGrabKey (GDK_DISPLAY (),
- key->keycode,
- (result | key->state),
- GDK_WINDOW_XID (root),
- True,
- GrabModeAsync,
- GrabModeAsync);
- } else {
- XUngrabKey (GDK_DISPLAY (),
- key->keycode,
- (result | key->state),
- GDK_WINDOW_XID (root));
- }
-
- gdk_flush ();
-
- gdk_error_trap_pop ();
-
- return TRUE;
-}
-
-/* Grab the key. In order to ignore IGNORED_MODS we need to grab
- * all combinations of the ignored modifiers and those actually used
- * for the binding (if any).
- *
- * inspired by all_combinations from gnome-panel/gnome-panel/global-keys.c */
-#define N_BITS 32
-static void
-grab_key (GsdMediaKeysManager *manager,
- Key *key,
- gboolean grab)
-{
- int indexes[N_BITS]; /* indexes of bits we need to flip */
- int i;
- int bit;
- int bits_set_cnt;
- int uppervalue;
- guint mask = IGNORED_MODS & ~key->state & GDK_MODIFIER_MASK;
-
- bit = 0;
- /* store the indices of all set bits in mask in the array */
- for (i = 0; mask; ++i, mask >>= 1) {
- if (mask & 0x1) {
- indexes[bit++] = i;
- }
- }
-
- bits_set_cnt = bit;
-
- uppervalue = 1 << bits_set_cnt;
- /* grab all possible modifier combinations for our mask */
- for (i = 0; i < uppervalue; ++i) {
- GSList *l;
- int j;
- int result = 0;
-
- /* map bits in the counter to those in the mask */
- for (j = 0; j < bits_set_cnt; ++j) {
- if (i & (1 << j)) {
- result |= (1 << indexes[j]);
- }
- }
-
- for (l = manager->priv->screens; l ; l = l->next) {
- GdkScreen *screen = l->data;
- if (grab_key_real (key, gdk_screen_get_root_window (screen), grab, result) == FALSE)
- return;
- }
- }
-}
-
-static gboolean
is_valid_shortcut (const char *string)
{
if (string == NULL || string[0] == '\0') {
@@ -364,7 +276,6 @@
GsdMediaKeysManager *manager)
{
int i;
- gboolean found = FALSE;
g_return_if_fail (entry->key != NULL);
@@ -374,10 +285,8 @@
char *tmp;
Key *key;
- found = TRUE;
-
if (keys[i].key != NULL) {
- grab_key (manager, keys[i].key, FALSE);
+ grab_key (keys[i].key, FALSE, manager->priv->screens);
}
g_free (keys[i].key);
@@ -399,7 +308,7 @@
break;
}
- grab_key (manager, key, TRUE);
+ grab_key (key, TRUE, manager->priv->screens);
keys[i].key = key;
g_free (tmp);
@@ -407,10 +316,6 @@
break;
}
}
-
- if (found != FALSE) {
- return;
- }
}
static void
@@ -450,7 +355,7 @@
g_free (key);
continue;
}
- /*avoid grabbing all the keyboard when KeyCode cannot be retrieved */
+ /* avoid grabbing all the keyboard when KeyCode cannot be retrieved */
if (key->keycode == AnyKey) {
g_warning ("The shortcut key \"%s\" cannot be found on the current system, ignoring the binding", tmp);
g_free (tmp);
@@ -462,7 +367,7 @@
keys[i].key = key;
- grab_key (manager, key, TRUE);
+ grab_key (key, TRUE, manager->priv->screens);
}
gnome_settings_profile_end (NULL);
@@ -952,27 +857,16 @@
GsdMediaKeysManager *manager)
{
XEvent *xev = (XEvent *) xevent;
- XAnyEvent *xanyev = (XAnyEvent *) xevent;
- guint keycode;
- guint state;
+ XAnyEvent *xany = (XAnyEvent *) xevent;
int i;
/* verify we have a key event */
- if (xev->xany.type != KeyPress
- && xev->xany.type != KeyRelease) {
+ if (xev->type != KeyPress && xev->type != KeyRelease) {
return GDK_FILTER_CONTINUE;
}
- keycode = xev->xkey.keycode;
- state = xev->xkey.state;
-
for (i = 0; i < HANDLED_KEYS; i++) {
- if (keys[i].key == NULL) {
- continue;
- }
-
- if (keys[i].key->keycode == keycode
- && (state & USED_MODS) == keys[i].key->state) {
+ if (match_key (keys[i].key, xev)) {
switch (keys[i].key_type) {
case VOLUME_DOWN_KEY:
case VOLUME_UP_KEY:
@@ -987,7 +881,7 @@
}
}
- manager->priv->current_screen = acme_get_screen_from_event (manager, xanyev);
+ manager->priv->current_screen = acme_get_screen_from_event (manager, xany);
if (do_action (manager, keys[i].key_type) == FALSE) {
return GDK_FILTER_REMOVE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]