summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/actions.c6
-rw-r--r--src/input.c10
2 files changed, 9 insertions, 7 deletions
diff --git a/src/actions.c b/src/actions.c
index 374bbae..c46e5ae 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -916,8 +916,7 @@ parse_keydesc (char *s, struct rp_key *key)
/* Its got no hyphens in it, so just grab the keysym */
key->sym = string_to_keysym (keydesc);
- /* A keycode of 0 means the keysym doesn't have a keycode. */
- if (key->sym == NoSymbol || XKeysymToKeycode (dpy, key->sym) == 0)
+ if (key->sym == NoSymbol)
{
cmdret *ret = cmdret_new (RET_FAILURE, "parse_keydesc: Unknown key '%s'", keydesc);
free (keydesc);
@@ -952,8 +951,7 @@ parse_keydesc (char *s, struct rp_key *key)
keysym name. */
key->sym = string_to_keysym (token);
- /* A keycode of 0 means the keysym doesn't have a keycode. */
- if (key->sym == NoSymbol || XKeysymToKeycode (dpy, key->sym) == 0)
+ if (key->sym == NoSymbol)
{
cmdret *ret = cmdret_new (RET_FAILURE, "parse_keydesc: Unknown key '%s'", token);
free (keydesc);
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;