summaryrefslogtreecommitdiff
path: root/src/input.c
diff options
context:
space:
mode:
authorShawn Betts <sabetts@gmail.com>2008-05-29 15:01:07 -0700
committerShawn Betts <sabetts@gmail.com>2008-05-29 15:01:07 -0700
commit040d4dbf7332d295b1c3078ded7c418ec396e8fa (patch)
tree9701dd6381a12d8c88e88c67d410b852f264a0ae /src/input.c
parentd1f633382214f50e07cea482249ff9733fa7ded3 (diff)
downloadratpoison-040d4dbf7332d295b1c3078ded7c418ec396e8fa.zip
don't grab the key if the keysym doesn't map to a keycode
Also, remove the restriction that a keysym must have a keycode in order to be bound.
Diffstat (limited to 'src/input.c')
-rw-r--r--src/input.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/input.c b/src/input.c
index d2e703e..c92acd8 100644
--- a/src/input.c
+++ b/src/input.c
@@ -242,8 +242,9 @@ update_modifier_map (void)
}
/* we need a keycode + modifier to generate the proper keysym (such as
- @). */
-static void
+ @). Return 1 if successful, 0 otherwise. This function can fail if a
+ keysym doesn't map to a keycode. */
+static int
keysym_to_keycode_mod (KeySym keysym, KeyCode *code, unsigned int *mod)
{
KeySym lower, upper;
@@ -256,6 +257,8 @@ keysym_to_keycode_mod (KeySym keysym, KeyCode *code, unsigned int *mod)
mask. */
if (upper == keysym && lower != keysym)
*mod = ShiftMask;
+
+ return *code != 0;
}
/* Grab the key while ignoring annoying modifier keys including
@@ -270,7 +273,8 @@ grab_key (KeySym keysym, unsigned int modifiers, Window grab_window)
/* Convert to a modifier mask that X Windows will understand. */
modifiers = rp_mask_to_x11_mask (modifiers);
- keysym_to_keycode_mod (keysym, &keycode, &mod);
+ if (!keysym_to_keycode_mod (keysym, &keycode, &mod))
+ return;
PRINT_DEBUG (("keycode_mod: %ld %d %d\n", keysym, keycode, mod));
modifiers |= mod;