From f8e1b009855b6c9aa2efebf4dd6a5fa715702b0d Mon Sep 17 00:00:00 2001 From: "louis.pontoise" Date: Tue, 14 Jan 2020 19:13:02 +0900 Subject: [PATCH] fix: don't show ui on fast trigger --- alt-tab-macos/ui/App.swift | 4 ++-- alt-tab-macos/ui/ThumbnailsPanel.swift | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/alt-tab-macos/ui/App.swift b/alt-tab-macos/ui/App.swift index 01dc7a2b7..0132b66be 100644 --- a/alt-tab-macos/ui/App.swift +++ b/alt-tab-macos/ui/App.swift @@ -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) @@ -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") } } diff --git a/alt-tab-macos/ui/ThumbnailsPanel.swift b/alt-tab-macos/ui/ThumbnailsPanel.swift index c39677e86..32d00a175 100644 --- a/alt-tab-macos/ui/ThumbnailsPanel.swift +++ b/alt-tab-macos/ui/ThumbnailsPanel.swift @@ -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)) } } }