From 1d57d7b327a5cf712708d4446fff2769aeb568be Mon Sep 17 00:00:00 2001 From: Nathan LaFreniere Date: Fri, 8 Feb 2008 14:35:32 +0100 Subject: [PATCH] switch KeySym to KeyCode --- config.c | 20 ++++++++++---------- event.c | 11 ++++------- structs.h | 2 +- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/config.c b/config.c index f5961573..201f356d 100644 --- a/config.c +++ b/config.c @@ -49,7 +49,7 @@ extern cfg_opt_t awesome_opts[]; typedef struct { const char *name; - KeySym keysym; + KeyCode keycode; } KeyMod; /** Link a name to a mouse button symbol */ @@ -67,7 +67,7 @@ extern const name_func_link_t LayoutList[]; * \param keyname Key name * \return Key mask or 0 if not found */ -static KeySym +static KeyCode key_mask_lookup(const char *keyname) { /** List of keyname and corresponding X11 mask codes */ @@ -88,9 +88,9 @@ key_mask_lookup(const char *keyname) if(keyname) for(i = 0; KeyModList[i].name; i++) if(!a_strcmp(keyname, KeyModList[i].name)) - return KeyModList[i].keysym; + return KeyModList[i].keycode; - return NoSymbol; + return 0; } /** Lookup for a mouse button from its name @@ -165,18 +165,18 @@ set_key_info(Key *key, cfg_t *cfg) warn("unknown command %s\n", cfg_getstr(cfg, "command")); } -static KeySym -key_to_keysym(char *str) +static KeyCode +key_to_keycode(char *str) { KeyCode kc; int ikc; if(a_strncmp(str, "#", 1)) - return XStringToKeysym(str); + return XKeysymToKeycode(globalconf.display, XStringToKeysym(str)); ikc = atoi(str + 1); memcpy(&kc, &ikc, sizeof(KeyCode)); - return XKeycodeToKeysym(globalconf.display, kc, 0); + return kc; } static Key * @@ -191,7 +191,7 @@ section_keys(cfg_t *cfg_keys) key = p_new(Key, 1); cfgkeytmp = cfg_getnsec(cfg_keys, "key", i); set_key_info(key, cfgkeytmp); - key->keysym = key_to_keysym(cfg_getstr(cfgkeytmp, "key")); + key->keycode = key_to_keycode(cfg_getstr(cfgkeytmp, "key")); key->arg = a_strdup(cfg_getstr(cfgkeytmp, "arg")); key_list_push(&head, key); } @@ -210,7 +210,7 @@ section_keys(cfg_t *cfg_keys) { key = p_new(Key, 1); set_key_info(key, cfgkeytmp); - key->keysym = key_to_keysym(cfg_getnstr(cfgkeytmp, "keylist", j)); + key->keycode = key_to_keycode(cfg_getnstr(cfgkeytmp, "keylist", j)); key->arg = a_strdup(cfg_getnstr(cfgkeytmp, "arglist", j)); key_list_push(&head, key); } diff --git a/event.c b/event.c index 75d0336b..236b3643 100644 --- a/event.c +++ b/event.c @@ -259,13 +259,10 @@ handle_event_keypress(XEvent * e) { int screen, x, y, d; unsigned int m; - KeySym keysym; XKeyEvent *ev = &e->xkey; Window dummy; Key *k; - keysym = XKeycodeToKeysym(e->xany.display, (KeyCode) ev->keycode, 0); - /* find the right screen for this event */ for(screen = 0; screen < ScreenCount(e->xany.display); screen++) if(XQueryPointer(e->xany.display, RootWindow(e->xany.display, screen), &dummy, &dummy, &x, &y, &d, &d, &m)) @@ -280,8 +277,8 @@ handle_event_keypress(XEvent * e) } for(k = globalconf.keys; k; k = k->next) - if(keysym == k->keysym && k->func - && CLEANMASK(k->mod) == CLEANMASK(ev->state)) + if(ev->keycode == k->keycode && + k->func && CLEANMASK(k->mod) == CLEANMASK(ev->state)) { k->func(screen, k->arg); break; @@ -409,8 +406,8 @@ grabkeys(int phys_screen) XUngrabKey(globalconf.display, AnyKey, AnyModifier, RootWindow(globalconf.display, phys_screen)); for(k = globalconf.keys; k; k = k->next) { - if((code = XKeysymToKeycode(globalconf.display, k->keysym)) == NoSymbol) - continue; + if((code = k->keycode) == 0) + continue; XGrabKey(globalconf.display, code, k->mod, RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync); XGrabKey(globalconf.display, code, k->mod | LockMask, RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync); XGrabKey(globalconf.display, code, k->mod | globalconf.numlockmask, RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync); diff --git a/structs.h b/structs.h index 8d0bd0f0..ea1550cb 100644 --- a/structs.h +++ b/structs.h @@ -74,7 +74,7 @@ typedef struct Key Key; struct Key { unsigned long mod; - KeySym keysym; + KeyCode keycode; Uicb *func; char *arg; Key *next;