Skip to content

Commit

Permalink
fix: smoother behavior when summoned during a space transition
Browse files Browse the repository at this point in the history
  • Loading branch information
lwouis committed Sep 4, 2020
1 parent 66820a1 commit e6ded6c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/logic/Screen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Screen {
static func preferred() -> NSScreen {
switch Preferences.showOnScreen {
case .includingMouse: return withMouse() ?? NSScreen.main! // .main as fall-back
case .active: return NSScreen.main!
case .active: return NSScreen.main! // macOS bug: this will return screens[0] if the main screen shows a fullscreen app
case .includingMenubar: return NSScreen.screens.first!
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/ui/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class App: AppCenterApplication, NSApplicationDelegate {
guard appIsBeingUsed else { return }
thumbnailsPanel.thumbnailsView.updateItemsAndLayout(currentScreen)
guard appIsBeingUsed else { return }
thumbnailsPanel.setFrame(thumbnailsPanel.thumbnailsView.frame, display: false)
thumbnailsPanel.setContentSize(thumbnailsPanel.thumbnailsView.frame.size)
thumbnailsPanel.display()
guard appIsBeingUsed else { return }
Screen.repositionPanel(thumbnailsPanel, currentScreen, .appleCentered)
Expand Down Expand Up @@ -250,6 +250,8 @@ class App: AppCenterApplication, NSApplicationDelegate {
guard appIsBeingUsed else { return }
Applications.refreshBadges()
guard appIsBeingUsed else { return }
thumbnailsPanel.makeKeyAndOrderFront(nil) // workaround: without this, switching between 2 monitors make thumbnailPanel invisible
guard appIsBeingUsed else { return }
refreshOpenUi()
guard appIsBeingUsed else { return }
thumbnailsPanel.show()
Expand Down
5 changes: 2 additions & 3 deletions src/ui/FeedbackWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class FeedbackWindow: NSWindow {
var canBecomeKey_ = true
override var canBecomeKey: Bool { canBecomeKey_ }

override init(contentRect: NSRect, styleMask style: StyleMask, backing backingStoreType: BackingStoreType, defer flag: Bool) {
super.init(contentRect: .zero, styleMask: style, backing: backingStoreType, defer: flag)
convenience init() {
self.init(contentRect: .zero, styleMask: [.titled, .miniaturizable, .closable], backing: .buffered, defer: false)
setupWindow()
setupView()
}
Expand All @@ -19,7 +19,6 @@ class FeedbackWindow: NSWindow {
title = NSLocalizedString("Send feedback", comment: "")
hidesOnDeactivate = false
isReleasedWhenClosed = false
styleMask.insert([.miniaturizable, .closable])
}

private func setupView() {
Expand Down
4 changes: 3 additions & 1 deletion src/ui/main-window/ThumbnailsPanel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ class ThumbnailsPanel: NSPanel {
override var canBecomeKey: Bool { true }

convenience init() {
self.init(contentRect: .zero, styleMask: .nonactivatingPanel, backing: .buffered, defer: true)
self.init(contentRect: .zero, styleMask: .nonactivatingPanel, backing: .buffered, defer: false)
isFloatingPanel = true
updateFadeOutAnimation()
hidesOnDeactivate = false
hasShadow = false
titleVisibility = .hidden
backgroundColor = .clear
contentView!.addSubview(thumbnailsView)
preservesContentDuringLiveResize = false
disableSnapshotRestoration()
// 2nd highest level possible; this allows the app to go on top of context menus
// highest level is .screenSaver but makes drag and drop on top the main window impossible
level = .popUpMenu
Expand Down
5 changes: 2 additions & 3 deletions src/ui/preferences-window/PreferencesWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ class PreferencesWindow: NSWindow, NSToolbarDelegate {
var canBecomeKey_ = true
override var canBecomeKey: Bool { canBecomeKey_ }

override init(contentRect: NSRect, styleMask style: StyleMask, backing backingStoreType: BackingStoreType, defer flag: Bool) {
super.init(contentRect: .zero, styleMask: style, backing: backingStoreType, defer: flag)
convenience init() {
self.init(contentRect: .zero, styleMask: [.titled, .miniaturizable, .closable], backing: .buffered, defer: false)
setupWindow()
setupView()
}

private func setupWindow() {
isReleasedWhenClosed = false
hidesOnDeactivate = false
styleMask.insert([.miniaturizable, .closable])
addQuitButton()
}

Expand Down

0 comments on commit e6ded6c

Please sign in to comment.