mirror of https://github.com/davatorium/rofi.git
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
|
@ -662,7 +662,9 @@ gboolean x11_parse_key ( const char *combo, unsigned int *mod, xkb_keysym_t *key
|
||||||
char *input_key = g_strdup ( combo );
|
char *input_key = g_strdup ( combo );
|
||||||
char *mod_key = input_key;
|
char *mod_key = input_key;
|
||||||
char *error_msg = NULL;
|
char *error_msg = NULL;
|
||||||
|
unsigned int last_modmask = 0;
|
||||||
unsigned int modmask = 0;
|
unsigned int modmask = 0;
|
||||||
|
xkb_keysym_t last_sym = XKB_KEY_NoSymbol;
|
||||||
xkb_keysym_t sym = XKB_KEY_NoSymbol;
|
xkb_keysym_t sym = XKB_KEY_NoSymbol;
|
||||||
// Test if this works on release.
|
// Test if this works on release.
|
||||||
if ( g_str_has_prefix ( mod_key, "!" ) ) {
|
if ( g_str_has_prefix ( 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.
|
// Remove trailing and leading spaces.
|
||||||
entry = g_strstrip ( entry );
|
entry = g_strstrip ( entry );
|
||||||
// Compare against lowered version.
|
// 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 );
|
char *entry_lowered = g_utf8_strdown ( entry, -1 );
|
||||||
if ( g_utf8_collate ( entry_lowered, "shift" ) == 0 ) {
|
if ( g_utf8_collate ( entry_lowered, "shift" ) == 0 ) {
|
||||||
modmask |= x11_mod_masks[X11MOD_SHIFT];
|
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 ) {
|
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 );
|
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 ) {
|
if ( sym == XKB_KEY_NoSymbol ) {
|
||||||
error_msg = g_markup_printf_escaped ( "∙ Key <i>%s</i> is not understood\n", entry );
|
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_strfreev ( entries );
|
||||||
|
|
||||||
g_free ( input_key );
|
g_free ( input_key );
|
||||||
|
if ( ( sym == XKB_KEY_NoSymbol ) && ( last_sym != XKB_KEY_NoSymbol ) ) {
|
||||||
|
sym = last_sym;
|
||||||
|
modmask = last_modmask;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( error_msg ) {
|
if ( error_msg ) {
|
||||||
char *name = g_markup_escape_text ( combo, -1 );
|
char *name = g_markup_escape_text ( combo, -1 );
|
||||||
|
|
Loading…
Reference in New Issue