Skip to content

Commit

Permalink
fix: triggering alt-tab during space transition failed (closes #566)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwouis committed Sep 3, 2020
1 parent e8a2137 commit ac51e1e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/logic/events/KeyboardEvents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -104,16 +104,20 @@ 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
}
}
}
// 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
}
Expand Down
2 changes: 2 additions & 0 deletions src/ui/preferences-window/tabs/ControlsTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit ac51e1e

Please sign in to comment.