Skip to content

Commit

Permalink
fix: don't show ui on fast trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
louis.pontoise authored and lwouis committed Mar 10, 2020
1 parent b8d6bc9 commit f8e1b00
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions alt-tab-macos/ui/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class App: NSApplication, NSApplicationDelegate, NSWindowDelegate {
Windows.focusedWindowIndex = 0
Windows.cycleFocusedWindowIndex(step)
refreshOpenUi()
thumbnailsPanel?.show()
if uiWorkShouldBeDone { thumbnailsPanel?.show() }
} else {
debugPrint("showUiOrCycleSelection: !isFirstSummon")
cycleSelection(step)
Expand All @@ -103,7 +103,7 @@ class App: NSApplication, NSApplicationDelegate, NSWindowDelegate {
func refreshOpenUi() {
guard appIsBeingUsed else { return }
let currentScreen = Screen.preferred() // fix screen between steps since it could change (e.g. mouse moved to another screen)
if uiWorkShouldBeDone { thumbnailsPanel!.refreshCollectionView(currentScreen); debugPrint("refreshCollectionView") }
if uiWorkShouldBeDone { thumbnailsPanel!.refreshCollectionView(currentScreen, uiWorkShouldBeDone); debugPrint("refreshCollectionView") }
if uiWorkShouldBeDone { thumbnailsPanel!.highlightCell(); debugPrint("highlightCellAt") }
if uiWorkShouldBeDone { Screen.repositionPanel(thumbnailsPanel!, currentScreen, .appleCentered); debugPrint("repositionPanel") }
}
Expand Down
18 changes: 9 additions & 9 deletions alt-tab-macos/ui/ThumbnailsPanel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ class ThumbnailsPanel: NSPanel, NSCollectionViewDataSource, NSCollectionViewDele
}
}

func refreshCollectionView(_ currentScreen: NSScreen) {
self.currentScreen = currentScreen
(collectionView_.collectionViewLayout as! CollectionViewCenterFlowLayout).currentScreen = currentScreen
collectionView_!.setFrameSize(Screen.thumbnailPanelMaxSize(currentScreen))
collectionView_!.reloadData()
collectionView_!.layoutSubtreeIfNeeded()
setContentSize(NSSize(width: collectionView_!.frame.size.width + Preferences.windowPadding * 2, height: collectionView_!.frame.size.height + Preferences.windowPadding * 2))
backgroundView!.setFrameSize(frame.size)
collectionView_!.setFrameOrigin(NSPoint(x: Preferences.windowPadding, y: Preferences.windowPadding))
func refreshCollectionView(_ currentScreen: NSScreen, _ uiWorkShouldBeDone: Bool) {
if uiWorkShouldBeDone { self.currentScreen = currentScreen }
if uiWorkShouldBeDone { (collectionView_.collectionViewLayout as! CollectionViewCenterFlowLayout).currentScreen = currentScreen }
if uiWorkShouldBeDone { collectionView_!.setFrameSize(Screen.thumbnailPanelMaxSize(currentScreen)) }
if uiWorkShouldBeDone { collectionView_!.reloadData() }
if uiWorkShouldBeDone { collectionView_!.layoutSubtreeIfNeeded() }
if uiWorkShouldBeDone { setContentSize(NSSize(width: collectionView_!.frame.size.width + Preferences.windowPadding * 2, height: collectionView_!.frame.size.height + Preferences.windowPadding * 2)) }
if uiWorkShouldBeDone { backgroundView!.setFrameSize(frame.size) }
if uiWorkShouldBeDone { collectionView_!.setFrameOrigin(NSPoint(x: Preferences.windowPadding, y: Preferences.windowPadding)) }
}
}

0 comments on commit f8e1b00

Please sign in to comment.