switch KeySym to KeyCode
This commit is contained in:
parent
ecbdcd5bc9
commit
1d57d7b327
20
config.c
20
config.c
|
@ -49,7 +49,7 @@ extern cfg_opt_t awesome_opts[];
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
KeySym keysym;
|
KeyCode keycode;
|
||||||
} KeyMod;
|
} KeyMod;
|
||||||
|
|
||||||
/** Link a name to a mouse button symbol */
|
/** Link a name to a mouse button symbol */
|
||||||
|
@ -67,7 +67,7 @@ extern const name_func_link_t LayoutList[];
|
||||||
* \param keyname Key name
|
* \param keyname Key name
|
||||||
* \return Key mask or 0 if not found
|
* \return Key mask or 0 if not found
|
||||||
*/
|
*/
|
||||||
static KeySym
|
static KeyCode
|
||||||
key_mask_lookup(const char *keyname)
|
key_mask_lookup(const char *keyname)
|
||||||
{
|
{
|
||||||
/** List of keyname and corresponding X11 mask codes */
|
/** List of keyname and corresponding X11 mask codes */
|
||||||
|
@ -88,9 +88,9 @@ key_mask_lookup(const char *keyname)
|
||||||
if(keyname)
|
if(keyname)
|
||||||
for(i = 0; KeyModList[i].name; i++)
|
for(i = 0; KeyModList[i].name; i++)
|
||||||
if(!a_strcmp(keyname, KeyModList[i].name))
|
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
|
/** 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"));
|
warn("unknown command %s\n", cfg_getstr(cfg, "command"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static KeySym
|
static KeyCode
|
||||||
key_to_keysym(char *str)
|
key_to_keycode(char *str)
|
||||||
{
|
{
|
||||||
KeyCode kc;
|
KeyCode kc;
|
||||||
int ikc;
|
int ikc;
|
||||||
|
|
||||||
if(a_strncmp(str, "#", 1))
|
if(a_strncmp(str, "#", 1))
|
||||||
return XStringToKeysym(str);
|
return XKeysymToKeycode(globalconf.display, XStringToKeysym(str));
|
||||||
|
|
||||||
ikc = atoi(str + 1);
|
ikc = atoi(str + 1);
|
||||||
memcpy(&kc, &ikc, sizeof(KeyCode));
|
memcpy(&kc, &ikc, sizeof(KeyCode));
|
||||||
return XKeycodeToKeysym(globalconf.display, kc, 0);
|
return kc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Key *
|
static Key *
|
||||||
|
@ -191,7 +191,7 @@ section_keys(cfg_t *cfg_keys)
|
||||||
key = p_new(Key, 1);
|
key = p_new(Key, 1);
|
||||||
cfgkeytmp = cfg_getnsec(cfg_keys, "key", i);
|
cfgkeytmp = cfg_getnsec(cfg_keys, "key", i);
|
||||||
set_key_info(key, cfgkeytmp);
|
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->arg = a_strdup(cfg_getstr(cfgkeytmp, "arg"));
|
||||||
key_list_push(&head, key);
|
key_list_push(&head, key);
|
||||||
}
|
}
|
||||||
|
@ -210,7 +210,7 @@ section_keys(cfg_t *cfg_keys)
|
||||||
{
|
{
|
||||||
key = p_new(Key, 1);
|
key = p_new(Key, 1);
|
||||||
set_key_info(key, cfgkeytmp);
|
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->arg = a_strdup(cfg_getnstr(cfgkeytmp, "arglist", j));
|
||||||
key_list_push(&head, key);
|
key_list_push(&head, key);
|
||||||
}
|
}
|
||||||
|
|
9
event.c
9
event.c
|
@ -259,13 +259,10 @@ handle_event_keypress(XEvent * e)
|
||||||
{
|
{
|
||||||
int screen, x, y, d;
|
int screen, x, y, d;
|
||||||
unsigned int m;
|
unsigned int m;
|
||||||
KeySym keysym;
|
|
||||||
XKeyEvent *ev = &e->xkey;
|
XKeyEvent *ev = &e->xkey;
|
||||||
Window dummy;
|
Window dummy;
|
||||||
Key *k;
|
Key *k;
|
||||||
|
|
||||||
keysym = XKeycodeToKeysym(e->xany.display, (KeyCode) ev->keycode, 0);
|
|
||||||
|
|
||||||
/* find the right screen for this event */
|
/* find the right screen for this event */
|
||||||
for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
|
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))
|
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)
|
for(k = globalconf.keys; k; k = k->next)
|
||||||
if(keysym == k->keysym && k->func
|
if(ev->keycode == k->keycode &&
|
||||||
&& CLEANMASK(k->mod) == CLEANMASK(ev->state))
|
k->func && CLEANMASK(k->mod) == CLEANMASK(ev->state))
|
||||||
{
|
{
|
||||||
k->func(screen, k->arg);
|
k->func(screen, k->arg);
|
||||||
break;
|
break;
|
||||||
|
@ -409,7 +406,7 @@ grabkeys(int phys_screen)
|
||||||
XUngrabKey(globalconf.display, AnyKey, AnyModifier, RootWindow(globalconf.display, phys_screen));
|
XUngrabKey(globalconf.display, AnyKey, AnyModifier, RootWindow(globalconf.display, phys_screen));
|
||||||
for(k = globalconf.keys; k; k = k->next)
|
for(k = globalconf.keys; k; k = k->next)
|
||||||
{
|
{
|
||||||
if((code = XKeysymToKeycode(globalconf.display, k->keysym)) == NoSymbol)
|
if((code = k->keycode) == 0)
|
||||||
continue;
|
continue;
|
||||||
XGrabKey(globalconf.display, code, k->mod, RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
|
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 | LockMask, RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
|
||||||
|
|
Loading…
Reference in New Issue