fix: triggering alt-tab during space transition failed (closes #566)

This commit is contained in:
Louis Pontoise authored and lwouis committed 2020-09-05 04:01:32 +09:00
1 parent 41384d9066
commit d66d7887f5
2 files changed
+10 -4

No files matched your search

+8 -4
View File
@@ -14,7 +14,7 @@ class KeyboardEvents {
"holdShortcut": 2,
"holdShortcut2": 3,
]
static var holdShortcutWasDown = [2: false, 3: false]
static var holdShortcutWasDown = ["holdShortcut": false, "holdShortcut2": false]
static var eventHotKeyRefs = [EventHotKeyRef?](repeating: nil, count: globalShortcuts.count)
static var hotModifierEventHandler: EventHandlerRef?
static var hotKeyEventHandler: EventHandlerRef?
@@ -104,7 +104,7 @@ fileprivate func handleHotModifier(_ modifiers: UInt32) -> Bool {
// modifiers down
if modifiers == value.carbonModifierFlags || modifiers == value.carbonModifierFlags | UInt32(alphaLock) {
if key.hasPrefix("holdShortcut") {
KeyboardEvents.holdShortcutWasDown[shortcutIndex] = true
KeyboardEvents.holdShortcutWasDown[key] = true
} else {
if handleHotAny(key, shortcutIndex) {
return true
@@ -112,8 +112,12 @@ fileprivate func handleHotModifier(_ modifiers: UInt32) -> Bool {
}
}
// modifiers up
else if key.hasPrefix("holdShortcut") && (modifiers & value.carbonModifierFlags == 0) && KeyboardEvents.holdShortcutWasDown[shortcutIndex]! {
KeyboardEvents.holdShortcutWasDown[shortcutIndex] = false
else if key.hasPrefix("holdShortcut") && (modifiers & value.carbonModifierFlags == 0) && KeyboardEvents.holdShortcutWasDown[key]! {
KeyboardEvents.holdShortcutWasDown[key] = false
if ControlsTab.globalShortcuts["holdShortcut"]!.carbonModifierFlags == ControlsTab.globalShortcuts["holdShortcut"]!.carbonModifierFlags {
let otherKey = key == "holdShortcut" ? "holdShortcut2" : "holdShortcut"
KeyboardEvents.holdShortcutWasDown[key] = false
}
if Preferences.shortcutStyle == .focusOnRelease && handleHotAny(key, shortcutIndex) {
return true
}
@@ -109,6 +109,8 @@ class ControlsTab {
if controlId.hasPrefix("holdShortcut") {
let i = controlId == "holdShortcut" ? 0 : 1
addShortcut(.up, Shortcut(keyEquivalent: Preferences.holdShortcut[i])!, controlId, globalId)
// hold shortcuts need to also be local for the case of space transition reopening the ui
addShortcut(.up, Shortcut(keyEquivalent: Preferences.holdShortcut[i])!, controlId, nil)
if let s = nextWindowShortcut?[i] {
shortcutChangedCallback(s)
}