-
-
Notifications
You must be signed in to change notification settings - Fork 154
Added functionality for disabling all Kando shortcuts while simulating hotkeys/shortcuts #1232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Added functionality for disabling all Kando shortcuts while simulating hotkeys/shortcuts #1232
Conversation
|
Hi there! Thanks for the initiative! However, for me (currently testing this on GNOME / Wayland), this does not work. I suppose that it's because binding and unbinding hotkeys takes a couple of milliseconds. Maybe the binding and unbinding of hotkeys is missing an Also, there are a couple of interesting cases:
Overall, I think it may be necessary to refactor the hotkey-inhibiting logic here. This is currently quite messy anyways. I think we would need some sort of stack of currently bound hotkeys. So we could make temporary changes to the set via a |
Thanks for the detailed feedback! I’ll check all these cases and do a small refactor of the hotkey logic accordingly 👍 |
|
Hello Simon! I tried to implement everything as you said, for me it worked in both cases, but i cant check this on Gnome. |
|
@Schneegans Im ready for review... |
|
I haven't looked into your implementation too much, but I see that you now have four memebers for the binding logic: private shortcuts: string[] = [];
private inhibitedShortcuts: string[] = [];
private boundShortcutsStack: string[][] = [];
private inhibitedShortcutsStack: string[][] = [];This somehow feels not easier than before. Why do we need the stacks and I thought (but haven't spent too much time thinking here) that a single |
A single |
|
I just pushed an example of this logic—maybe this is what you had in mind for me to do? |
|
I think the logic is still too complex and over-engineered here. The involved backend methods and members currently are:
Let's take a step back and think about what is really necessary here. And you are right, we have to consider that some backends cannot silently unbind shortcuts, so we definitely need the inhibition mechanism. So when are shortcuts really (re-)bound?
Do we need a stack here? I do not think so. So a single Then there is inhibiting shortcuts. When does this happen?
These inhibition scenarios can all happen simultaneously, so we need to make sure our implementation can handle that. So for instance, the tray-icon option to disable shortcuts could be enabled, then a menu is opened which inhibits the shortcut of the opened menu, even if it's already inhibited by the tray-icon option. Then, a hotkey or macro could be simulated, which would also inhibit the shortcut of the opened menu. Then, all parts of the implementation will undo their inhibitions again. But as the tray-icon option is still checked, the shortcut should remain inhibited. Our first idea was to go for a stack-based approach. So anyone can push and pop inhibited shortcuts. At any point in time, the effectively bound shortcuts will be "all bound shortcuts MINUS the union of all pushed stack items". If we go for this stack-based approach, it would be necessary that all inhibition-sources are undone in the correct order, which could be possible, but may be hard to enforce in the presence of async methods. So if I think about this, this comes to my mind:
As you can see from the example above, on second thought, a stack for inhibited shortcuts may not be ideal. So what can we do about this? One idea would be to abandon the stack approach and go for an inhibition-source based approach. So there would be a single So every time What do you think about this approach? |
This reverts commit 0b81bd1.
|
I think the inhibition-source based approach sounds reasonable and addresses the ordering issues you described. I don’t have a concrete implementation in mind yet, but I’m happy to explore this direction and see how it works out in practice. I’ll follow up with a draft implementation or questions if I get stuck, I guess. |
Added new option for macro and shortcuts items!