Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force active ID cache regen on space change after adding windows #954

Merged
merged 2 commits into from
Feb 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ class BinarySpacePartitioningLayout<Window: WindowType>: StatefulLayout<Window>

windowNode.windowID = otherWindowID
otherWindowNode.windowID = windowID
case .spaceChange, .unknown:
case .applicationDeactivate, .applicationActivate, .spaceChange, .layoutChange, .unknown:
break
}
}
Expand Down
14 changes: 5 additions & 9 deletions Amethyst/Managers/ScreenManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,7 @@ final class ScreenManager<Delegate: ScreenManagerDelegate>: NSObject, Codable {
if lastFocusedWindow == window {
lastFocusedWindow = nil
}
case .windowSwap:
break
case .spaceChange:
break
case .unknown:
case .windowSwap, .applicationActivate, .applicationDeactivate, .spaceChange, .layoutChange, .unknown:
break
}

Expand Down Expand Up @@ -217,17 +213,17 @@ final class ScreenManager<Delegate: ScreenManagerDelegate>: NSObject, Codable {
return
}
updater(layout)
setNeedsReflow(withWindowChange: .unknown)
setNeedsReflow(withWindowChange: .layoutChange)
}

func cycleLayoutForward() {
setCurrentLayoutIndex((currentLayoutIndex + 1) % layouts.count)
setNeedsReflow(withWindowChange: .unknown)
setNeedsReflow(withWindowChange: .layoutChange)
}

func cycleLayoutBackward() {
setCurrentLayoutIndex((currentLayoutIndex == 0 ? layouts.count : currentLayoutIndex) - 1)
setNeedsReflow(withWindowChange: .unknown)
setNeedsReflow(withWindowChange: .layoutChange)
}

func selectLayout(_ layoutString: String) {
Expand All @@ -236,7 +232,7 @@ final class ScreenManager<Delegate: ScreenManagerDelegate>: NSObject, Codable {
}

setCurrentLayoutIndex(layoutIndex)
setNeedsReflow(withWindowChange: .unknown)
setNeedsReflow(withWindowChange: .layoutChange)
}

private func setCurrentLayoutIndex(_ index: Int, changingSpace: Bool = false) {
Expand Down
9 changes: 4 additions & 5 deletions Amethyst/Managers/WindowManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ final class WindowManager<Application: ApplicationType>: NSObject, Codable {
}

fileprivate func activate(application: AnyApplication<Application>) {
markAllScreensForReflow(withChange: .unknown)
markAllScreensForReflow(withChange: .applicationActivate)
}

fileprivate func deactivate(application: AnyApplication<Application>) {
markAllScreensForReflow(withChange: .unknown)
markAllScreensForReflow(withChange: .applicationDeactivate)
}

fileprivate func remove(window: Window) {
Expand Down Expand Up @@ -249,9 +249,6 @@ final class WindowManager<Application: ApplicationType>: NSObject, Codable {
}

@objc func activeSpaceDidChange(_ notification: Notification) {
windows.regenerateActiveIDCache()
screens.updateSpaces()

for runningApplication in NSWorkspace.shared.runningApplications {
guard runningApplication.isManageable else {
continue
Expand All @@ -269,6 +266,8 @@ final class WindowManager<Application: ApplicationType>: NSObject, Codable {
}
}

screens.updateSpaces()
windows.regenerateActiveIDCache()
markAllScreensForReflow(withChange: .spaceChange)
}

Expand Down
3 changes: 3 additions & 0 deletions Amethyst/Model/Change.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ enum Change<Window: WindowType> {
case remove(window: Window)
case focusChanged(window: Window)
case windowSwap(window: Window, otherWindow: Window)
case applicationActivate
case applicationDeactivate
case spaceChange
case layoutChange
case unknown
}