Skip to content

Commit

Permalink
fix: main window would sometimes appear after a delay (closes #1096)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwouis committed Sep 4, 2021
1 parent 9d2fd76 commit 8ab0e61
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/logic/Windows.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/ui/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) -> ()? {
Expand Down

0 comments on commit 8ab0e61

Please sign in to comment.