Skip to content

Commit

Permalink
Reduce workspace switching flicker
Browse files Browse the repository at this point in the history
Previously, workspace switch might flicker a bit upon changing to a
higher number. This could be observed by switching repeatedly between
first and second workspace, for example. 2->1 does not flicker, but 1->2
sometimes shows desktop. This commit fixes the issue: visible workspaces
are first unhidden, and then invisible ones are hidden.

closes nikitabobko#275
  • Loading branch information
ilyaluk authored and nikitabobko committed Jun 12, 2024
1 parent 30b09ea commit f649909
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions Sources/AppBundle/refresh.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,15 @@ private func refreshFocusedWorkspaceBasedOnFocusedWindow() { // todo drop. It sh
}

private func layoutWorkspaces() {
for workspace in Workspace.all {
if workspace.isVisible {
// todo no need to unhide tiling windows (except for keeping hide/unhide state variables invariants)
workspace.allLeafWindowsRecursive.forEach { ($0 as! MacWindow).unhideViaEmulation() } // todo as!
} else {
workspace.allLeafWindowsRecursive.forEach { ($0 as! MacWindow).hideViaEmulation() } // todo as!
}
// to reduce flicker, first unhide visible workspaces, then hide invisible ones
for workspace in Workspace.all where workspace.isVisible {
// todo no need to unhide tiling windows (except for keeping hide/unhide state variables invariants)
workspace.allLeafWindowsRecursive.forEach { ($0 as! MacWindow).unhideViaEmulation() } // todo as!
}
for workspace in Workspace.all where !workspace.isVisible {
workspace.allLeafWindowsRecursive.forEach { ($0 as! MacWindow).hideViaEmulation() } // todo as!
}

for monitor in monitors {
monitor.activeWorkspace.layoutWorkspace()
}
Expand Down

0 comments on commit f649909

Please sign in to comment.