pablopunk / SwiftShift

Sweet window management for macOS
https://swiftshift.app
MIT License
216 stars 9 forks source link

Some shortcut combinations make one of them not to work #12

Closed pablopunk closed 7 months ago

pablopunk commented 8 months ago

CleanShot 2023-12-30 at 20 18 37@2x

Bryceshaw06 commented 8 months ago

Same issue here - M1 Macbook Air on latest version

pablopunk commented 7 months ago

@Bryceshaw06 @xezrunner Can you guys try v0.10.0? Let me know if the issues are fixed :)

Bryceshaw06 commented 7 months ago

@pablopunk It did not fix it for me. I am on the latest version, and the commands I'm trying to use are "Command" for "Move" and "Alt+Command" for "Resize". https://share.cleanshot.com/wGq9Jxst

xezrunner commented 7 months ago

Can confirm that there still is a shortcut overlap problem.

https://github.com/pablopunk/SwiftShift/assets/8061077/20ffc71d-47d5-497e-9de5-675bdab1e4c7

However, on Ventura, the shortcuts now work as expected when screen recording as well, was broken in the first few versions.

pablopunk commented 7 months ago

This seems to be a different issue to the one I solved (which was just triggering both actions at the same time, so one would shadow the other one).

This one only happens when one shortcut contains the other one (⌘⇪ contains ⌘) but I'm having a hard time fixing the code.

https://github.com/pablopunk/SwiftShift/blob/05305abd56a80e4aa541d82a08b6e7fcaf02253c/Swift%20Shift/src/shortchuts/ShortcutsManager.swift#L112-L116

Both shortcuts pass the second check because ⌘⇪ contains ⌘, so I think by inverting the check (⌘ contains ⌘⇪) it should work but the AlgebraSet might not work as I think 😅, cause this makes no shortcut to be triggered:

 if event.modifierFlags.isDisjoint(with: shortcut.modifierFlags) { 
     MouseTracker.shared.stopTracking(for: action) 
-} else if event.modifierFlags.contains(shortcut.modifierFlags) { 
+} else if shortcut.modifierFlags.contains(event.modifierFlags) { 
     MouseTracker.shared.startTracking(for: action) 
 } 
pablopunk commented 7 months ago

Well I asked ChatGPT and it completely solved the issue by using something I didn't know about (converting the events using .deviceIndependentFlagsMask). Should have done that much earlier.

pablopunk commented 7 months ago

@xezrunner @Bryceshaw06 Please check out the latest release and see if the issue is finally fixed 🙏🏻 https://github.com/pablopunk/SwiftShift/releases/tag/0.13.0

Bryceshaw06 commented 7 months ago

Works great @pablopunk ! Thanks for the fix!

xezrunner commented 7 months ago

Can also confirm that the issue is now fixed - shortcuts no longer overlap if both use the same key.