mirror of
https://github.com/labwc/labwc.git
synced 2025-11-05 13:29:58 -05:00
keybinds: allow non-english based keybinds
This commit is contained in:
parent
19ffbae320
commit
272222e3c9
1 changed files with 16 additions and 3 deletions
|
|
@ -45,6 +45,7 @@ keybind_the_same(struct keybind *a, struct keybind *b)
|
|||
struct keybind *
|
||||
keybind_create(const char *keybind)
|
||||
{
|
||||
xkb_keysym_t sym;
|
||||
struct keybind *k = znew(*k);
|
||||
xkb_keysym_t keysyms[MAX_KEYSYMS];
|
||||
gchar **symnames = g_strsplit(keybind, "-", -1);
|
||||
|
|
@ -54,9 +55,21 @@ keybind_create(const char *keybind)
|
|||
if (modifier != 0) {
|
||||
k->modifiers |= modifier;
|
||||
} else {
|
||||
xkb_keysym_t sym = xkb_keysym_to_lower(
|
||||
xkb_keysym_from_name(symname,
|
||||
XKB_KEYSYM_CASE_INSENSITIVE));
|
||||
sym = xkb_keysym_from_name(symname, XKB_KEYSYM_CASE_INSENSITIVE);
|
||||
if (sym == XKB_KEY_NoSymbol && g_utf8_strlen(symname, -1) == 1) {
|
||||
/*
|
||||
* xkb_keysym_from_name() only handles a legacy set of single
|
||||
* characters. Thus we try to get the unicode codepoint here
|
||||
* and try a direct translation instead.
|
||||
*
|
||||
* This allows using keybinds like 'W-ö' and similar.
|
||||
*/
|
||||
gunichar codepoint = g_utf8_get_char_validated(symname, -1);
|
||||
if (codepoint != (gunichar)-1) {
|
||||
sym = xkb_utf32_to_keysym(codepoint);
|
||||
}
|
||||
}
|
||||
sym = xkb_keysym_to_lower(sym);
|
||||
if (sym == XKB_KEY_NoSymbol) {
|
||||
wlr_log(WLR_ERROR, "unknown keybind (%s)", symname);
|
||||
free(k);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue