allow the use of keycodes directly in key bindings
This commit is contained in:
parent
b288fdee41
commit
dbd3e9b6b2
1 changed files with 17 additions and 6 deletions
|
@ -89,13 +89,24 @@ gboolean translate_key(char *str, guint *state, guint *keycode)
|
||||||
*state |= m;
|
*state |= m;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* figure out the keycode */
|
if (!g_ascii_strncasecmp("0x", l, 2)) {
|
||||||
sym = XStringToKeysym(l);
|
gchar *end;
|
||||||
if (sym == NoSymbol) {
|
|
||||||
g_warning("Invalid key name '%s' in key binding.", l);
|
/* take it directly */
|
||||||
goto translation_fail;
|
*keycode = strtol(l, &end, 16);
|
||||||
|
if (*l == '\0' || *end != '\0') {
|
||||||
|
g_warning("Invalid key code '%s' in key binding.", l);
|
||||||
|
goto translation_fail;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* figure out the keycode */
|
||||||
|
sym = XStringToKeysym(l);
|
||||||
|
if (sym == NoSymbol) {
|
||||||
|
g_warning("Invalid key name '%s' in key binding.", l);
|
||||||
|
goto translation_fail;
|
||||||
|
}
|
||||||
|
*keycode = XKeysymToKeycode(ob_display, sym);
|
||||||
}
|
}
|
||||||
*keycode = XKeysymToKeycode(ob_display, sym);
|
|
||||||
if (!*keycode) {
|
if (!*keycode) {
|
||||||
g_warning("Key '%s' does not exist on the display.", l);
|
g_warning("Key '%s' does not exist on the display.", l);
|
||||||
goto translation_fail;
|
goto translation_fail;
|
||||||
|
|
Loading…
Reference in a new issue