fix: meta+arrow activates only if meta+tab was first pressed
Also potentially meta+other_key would be absorbed by the app and not propagated to the focused app
This commit is contained in:
1 parent
cd52663def
commit
aa5f748fa9
3 files changed
+25
-12
No files matched your search
@@ -51,15 +51,24 @@ func keyboardHandler(_ cgEvent: CGEvent, _ delegate: Application) -> Unmanaged<C
|
|||||||
if event.modifierFlags.contains(Preferences.metaModifierFlag!) {
|
if event.modifierFlags.contains(Preferences.metaModifierFlag!) {
|
||||||
if isMeta {
|
if isMeta {
|
||||||
delegate.preActivate()
|
delegate.preActivate()
|
||||||
} else if keyDown && (isLeftArrow || (isTab && event.modifierFlags.contains(.shift))) {
|
|
||||||
delegate.showUiOrSelectPrevious()
|
|
||||||
return nil // previously focused app should not receive keys
|
|
||||||
} else if keyDown && (isRightArrow || isTab) {
|
|
||||||
delegate.showUiOrSelectNext()
|
|
||||||
return nil // previously focused app should not receive keys
|
|
||||||
} else if keyDown && isEscape {
|
|
||||||
delegate.hideUi()
|
|
||||||
return nil // previously focused app should not receive keys
|
return nil // previously focused app should not receive keys
|
||||||
|
} else if keyDown {
|
||||||
|
if isTab && event.modifierFlags.contains(.shift) {
|
||||||
|
delegate.showUiOrSelectPrevious()
|
||||||
|
return nil // previously focused app should not receive keys
|
||||||
|
} else if isTab {
|
||||||
|
delegate.showUiOrSelectNext()
|
||||||
|
return nil // previously focused app should not receive keys
|
||||||
|
} else if isRightArrow && delegate.appIsBeingUsed {
|
||||||
|
delegate.cycleSelection(1)
|
||||||
|
return nil // previously focused app should not receive keys
|
||||||
|
} else if isLeftArrow && delegate.appIsBeingUsed {
|
||||||
|
delegate.cycleSelection(-1)
|
||||||
|
return nil // previously focused app should not receive keys
|
||||||
|
} else if keyDown && isEscape {
|
||||||
|
delegate.hideUi()
|
||||||
|
return nil // previously focused app should not receive keys
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if isMeta && !keyDown {
|
} else if isMeta && !keyDown {
|
||||||
delegate.focusTarget()
|
delegate.focusTarget()
|
||||||
|
|||||||
@@ -100,22 +100,26 @@ class Application: NSApplication, NSApplicationDelegate, NSWindowDelegate {
|
|||||||
selectedOpenWindow + step < 0 ? openWindows.count - 1 : (selectedOpenWindow + step) % openWindows.count
|
selectedOpenWindow + step < 0 ? openWindows.count - 1 : (selectedOpenWindow + step) % openWindows.count
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func cycleSelection(_ step: Int) {
|
||||||
|
selectedOpenWindow = cellWithStep(step)
|
||||||
|
thumbnailsPanel!.highlightCell(step)
|
||||||
|
}
|
||||||
|
|
||||||
func showUiOrCycleSelection(_ step: Int) {
|
func showUiOrCycleSelection(_ step: Int) {
|
||||||
appIsBeingUsed = true
|
appIsBeingUsed = true
|
||||||
if openWindows.count > 0 {
|
if openWindows.count > 0 {
|
||||||
selectedOpenWindow = cellWithStep(step)
|
|
||||||
if isFirstSummon {
|
if isFirstSummon {
|
||||||
isFirstSummon = false
|
isFirstSummon = false
|
||||||
let workItem = DispatchWorkItem {
|
let workItem = DispatchWorkItem {
|
||||||
self.computeOpenWindows()
|
self.computeOpenWindows()
|
||||||
self.thumbnailsPanel!.computeThumbnails()
|
self.thumbnailsPanel!.computeThumbnails()
|
||||||
self.thumbnailsPanel!.highlightThumbnail(step)
|
self.cycleSelection(step)
|
||||||
self.showCenteredPanel(self.thumbnailsPanel!)
|
self.showCenteredPanel(self.thumbnailsPanel!)
|
||||||
}
|
}
|
||||||
workItems.append(workItem)
|
workItems.append(workItem)
|
||||||
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + Preferences.windowDisplayDelay!, execute: workItem)
|
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + Preferences.windowDisplayDelay!, execute: workItem)
|
||||||
} else {
|
} else {
|
||||||
self.thumbnailsPanel!.highlightThumbnail(step)
|
self.cycleSelection(step)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ class ThumbnailsPanel: NSPanel, NSCollectionViewDataSource, NSCollectionViewDele
|
|||||||
return .zero
|
return .zero
|
||||||
}
|
}
|
||||||
|
|
||||||
func highlightThumbnail(_ step: Int) {
|
func highlightCell(_ step: Int) {
|
||||||
collectionView_!.selectItems(at: [IndexPath(item: application!.selectedOpenWindow, section: 0)], scrollPosition: .top)
|
collectionView_!.selectItems(at: [IndexPath(item: application!.selectedOpenWindow, section: 0)], scrollPosition: .top)
|
||||||
collectionView_!.deselectItems(at: [IndexPath(item: application!.cellWithStep(-step), section: 0)])
|
collectionView_!.deselectItems(at: [IndexPath(item: application!.cellWithStep(-step), section: 0)])
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user