kando-menu / kando

🥧 The Cross-Platform Pie Menu.
https://kando.menu
Other
3.15k stars 89 forks source link

Fast Switching Between Menus #585

Closed ognistik closed 3 months ago

ognistik commented 3 months ago

Description

I often find myself triggering the wrong menu. I know about the multiple ways to close the current menu (pressing the center icon or right clicking) but it would be really nice if I could just press the keyboard shortcut for a different menu and have that one replace the current one. I think this wouldn't break any current functionality, it make sense (easy to adapt for the user), and would speed up switching menus when on the wrong one.

Affected Desktop Environments

All

Additional Information

No response

Schneegans commented 3 months ago

That's a good idea and there is nothing fundamental which speaks against this. I'll see if that's possible.

However, it is definitely more complicated than it may seem at first. This interferes with turbo-mode: Kando unbinds all shortcuts once a menu is opened in order to receive the key-repeat events which are emitted when the keys are held down for more than a few milliseconds.

If the shortcuts are not unbound, Kando does not receive key events when the keys are held down. Instead, the same shortcut will be triggered many times a second, resulting in re-opening the same menu at a high frequency.

So we need to check whether the menu is already open and if so, inject the shortcut as key events. A potential solution could be to unbind only the shortcut of the currently opened menu... But this somewhat interferes with menu conditions: What if multiple menus are bound to the same shortcut?

Let's say you have two menus configured, one which opens if your pointer is on screen A, one which opens if your pointer is on screen B. Now you accidentally open the screen-A menu. So you move your pointer to screen B and hit the same shortcut. Would you expect that the screen-A menu closes automatically and the screen-B menu shows up? This would be impossible if we unbind the shortcut...

Schneegans commented 3 months ago

I now went for the approach of unbinding a shortcut as long as a menu using that shortcut is visible. All other shortcuts remain active, so you can switch to another menu by pressing another shortcut!