Hi folks,
I just started playing around with awesome a couple of days ago, and as
I was working on my rc.lua, I hit an issue. I was trying to bind a
function to Mod-;, but keybinding({ modkey }, ";", ...) wasn't working.
I dug into the source and figured out that this was because keybindings
are parsed using XStringToKeysym, which takes the names of characters
rather than the characters themselves. This is fine for stuff like the
F-keys, tab, space, and so forth, but it's not at all clear that I'm
supposed to use "semicolon" rather than ";".
The attached patch makes both work. It starts out trying to use
XStringToKeysym, but if that fails and the string is only one character,
it uses that character as the keysym instead (which should work for all
ASCII chars).
- Nathan
>From c502972e451960fe7095908c132b433ee16abf0f Mon Sep 17 00:00:00 2001
From: Nathan Weizenbaum <[EMAIL PROTECTED]>
Date: Wed, 17 Sep 2008 11:26:01 -0700
Subject: [PATCH] keybinding: allow individual non-alphabetic characters to be used in bindings
Don't just use XStringToKeysym to get keysyms, because then stuff like ";" doesn't work.
If XStringToKeysym fails and the string is of length 1, use it as the keysym.
Signed-off-by: Nathan Weizenbaum <[EMAIL PROTECTED]>
---
keybinding.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/keybinding.c b/keybinding.c
index 95d0896..a5dcdda 100644
--- a/keybinding.c
+++ b/keybinding.c
@@ -299,10 +299,17 @@ keybinding_find(const xcb_key_press_event_t *ev)
static void
__luaA_keystore(keybinding_t *key, const char *str)
{
- if(a_strlen(str))
+ ssize_t len = a_strlen(str);
+ if(len)
{
- if(*str != '#')
+ if(len > 1 || *str != '#')
+ {
key->keysym = XStringToKeysym(str);
+ if (!key->keysym && len == 1)
+ key->keysym = *str;
+ else
+ warn("there's no keysym named \"%s\"", str);
+ }
else
key->keycode = atoi(str + 1);
}
--
1.6.0.1.267.gec3a.dirty