@@ -109,9 +109,6 @@ xkb_keysym_t parse_keysym(const char *name) {
109109 if (!name || name [0 ] == '\0' )
110110 return XKB_KEY_NoSymbol ;
111111
112- if (strlen (name ) == 1 )
113- return xkb_keysym_from_name (name , XKB_KEYSYM_CASE_INSENSITIVE );
114-
115112 return xkb_keysym_from_name (name , XKB_KEYSYM_CASE_INSENSITIVE );
116113}
117114
@@ -129,7 +126,7 @@ uint32_t parse_keycode(const char *name) {
129126
130127 for (size_t i = 0 ; i < sizeof (mouse_buttons ) / sizeof (mouse_buttons [0 ]); i ++ )
131128 if (strcmp (name , mouse_buttons [i ]) == 0 )
132- return 0x20000000 + i + 272 ;
129+ return mouse_button_to_keycode ( i ) ;
133130
134131 if (name [0 ] >= '1' && name [0 ] <= '9' && name [1 ] == '\0' )
135132 return name [0 ] - '0' + 1 ;
@@ -1056,6 +1053,32 @@ bool keybind_matches(const keybind_t *kb, uint32_t modifiers, xkb_keysym_t keysy
10561053 }
10571054}
10581055
1056+ keybind_t * find_keybind (uint32_t modifiers , xkb_keysym_t keysym , uint32_t keycode ,
1057+ bool prefer_keycode , bool fallback_to_global ) {
1058+ if (active_submap ) {
1059+ for (size_t i = 0 ; i < active_submap -> num_keybinds ; i ++ ) {
1060+ keybind_t * kb = & active_submap -> keybinds [i ];
1061+ if (kb -> use_keycode == prefer_keycode && keybind_matches (kb , modifiers , keysym , keycode ))
1062+ return kb ;
1063+ }
1064+ if (!fallback_to_global )
1065+ return NULL ;
1066+ }
1067+
1068+ for (size_t i = 0 ; i < num_keybinds ; i ++ ) {
1069+ keybind_t * kb = & keybinds [i ];
1070+ if (kb -> use_keycode == prefer_keycode && keybind_matches (kb , modifiers , keysym , keycode ))
1071+ return kb ;
1072+ }
1073+
1074+ return NULL ;
1075+ }
1076+
1077+ bool is_interactive_bind (const keybind_t * kb ) {
1078+ return kb && (kb -> action == BIND_INTERACTIVE_MOVE || kb -> action == BIND_INTERACTIVE_RESIZE ||
1079+ kb -> action == BIND_TILING_DRAG );
1080+ }
1081+
10591082void execute_bind (bind_t b ) {
10601083 switch (b .action ) {
10611084 case BIND_QUIT :
0 commit comments