mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-25 13:55:34 -05:00
xkb: Allow binding modifiers
And modified modifiers too. Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
This commit is contained in:
parent
6f117c3589
commit
bb5d839f9c
1 changed files with 12 additions and 3 deletions
|
@ -662,8 +662,10 @@ gboolean x11_parse_key ( const char *combo, unsigned int *mod, xkb_keysym_t *key
|
|||
char *input_key = g_strdup ( combo );
|
||||
char *mod_key = input_key;
|
||||
char *error_msg = NULL;
|
||||
unsigned int modmask = 0;
|
||||
xkb_keysym_t sym = XKB_KEY_NoSymbol;
|
||||
unsigned int last_modmask = 0;
|
||||
unsigned int modmask = 0;
|
||||
xkb_keysym_t last_sym = XKB_KEY_NoSymbol;
|
||||
xkb_keysym_t sym = XKB_KEY_NoSymbol;
|
||||
// Test if this works on release.
|
||||
if ( g_str_has_prefix ( mod_key, "!" ) ) {
|
||||
++mod_key;
|
||||
|
@ -676,6 +678,8 @@ gboolean x11_parse_key ( const char *combo, unsigned int *mod, xkb_keysym_t *key
|
|||
// Remove trailing and leading spaces.
|
||||
entry = g_strstrip ( entry );
|
||||
// Compare against lowered version.
|
||||
last_modmask = modmask;
|
||||
last_sym = xkb_keysym_from_name ( entry, XKB_KEYSYM_NO_FLAGS );
|
||||
char *entry_lowered = g_utf8_strdown ( entry, -1 );
|
||||
if ( g_utf8_collate ( entry_lowered, "shift" ) == 0 ) {
|
||||
modmask |= x11_mod_masks[X11MOD_SHIFT];
|
||||
|
@ -720,7 +724,7 @@ gboolean x11_parse_key ( const char *combo, unsigned int *mod, xkb_keysym_t *key
|
|||
if ( sym != XKB_KEY_NoSymbol ) {
|
||||
error_msg = g_markup_printf_escaped ( "Only one (non modifier) key can be bound per binding: <b>%s</b> is invalid.\n", entry );
|
||||
}
|
||||
sym = xkb_keysym_from_name ( entry, XKB_KEYSYM_NO_FLAGS );
|
||||
sym = last_sym;
|
||||
if ( sym == XKB_KEY_NoSymbol ) {
|
||||
error_msg = g_markup_printf_escaped ( "∙ Key <i>%s</i> is not understood\n", entry );
|
||||
}
|
||||
|
@ -730,6 +734,11 @@ gboolean x11_parse_key ( const char *combo, unsigned int *mod, xkb_keysym_t *key
|
|||
g_strfreev ( entries );
|
||||
|
||||
g_free ( input_key );
|
||||
if ( ( sym == XKB_KEY_NoSymbol ) && ( last_sym != XKB_KEY_NoSymbol ) ) {
|
||||
sym = last_sym;
|
||||
modmask = last_modmask;
|
||||
}
|
||||
|
||||
|
||||
if ( error_msg ) {
|
||||
char *name = g_markup_escape_text ( combo, -1 );
|
||||
|
|
Loading…
Reference in a new issue