fix: main window would sometimes appear after a delay (closes #1096)

This commit is contained in:
Louis Pontoise
2021-09-04 23:27:55 +09:00
committed by lwouis
parent 9d2fd763e2
commit 8ab0e615c8
2 changed files with 8 additions and 4 deletions
+7 -3
View File
@@ -100,9 +100,13 @@ class Windows {
static func voiceOverFocusedWindow() {
guard App.app.appIsBeingUsed && App.app.thumbnailsPanel.isKeyWindow else { return }
let window = ThumbnailsView.recycledViews[focusedWindowIndex]
if window.window_ != nil && window.window != nil {
App.app.thumbnailsPanel.makeFirstResponder(window)
// it seems that sometimes makeFirstResponder is called before the view is visible
// and it creates a delay in showing the main window; calling it with some delay seems to work around this
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(10)) {
let window = ThumbnailsView.recycledViews[focusedWindowIndex]
if window.window_ != nil && window.window != nil {
App.app.thumbnailsPanel.makeFirstResponder(window)
}
}
}
+1 -1
View File
@@ -217,10 +217,10 @@ class App: AppCenterApplication, NSApplicationDelegate {
thumbnailsPanel.thumbnailsView.updateItemsAndLayout(currentScreen)
guard appIsBeingUsed else { return }
thumbnailsPanel.setContentSize(thumbnailsPanel.thumbnailsView.frame.size)
Windows.voiceOverFocusedWindow() // at this point ThumbnailViews are assigned to the window, and ready
thumbnailsPanel.display()
guard appIsBeingUsed else { return }
currentScreen.repositionPanel(thumbnailsPanel, .appleCentered)
Windows.voiceOverFocusedWindow() // at this point ThumbnailViews are assigned to the window, and ready
}
private func refreshSpecificWindows(_ windowsToUpdate: [Window]?, _ currentScreen: NSScreen) -> ()? {