Repository navigation
Conversation
* Animate windows as they move between tiles Until now every reflow snapped windows straight to their new positions. With the new "Animate window movement" setting turned on, windows glide to their new tiles instead. Amethyst takes a picture of each window that is about to move, shows those pictures exactly where the windows are, and slides the pictures to their destinations using the system's own compositor, which keeps the motion smooth no matter how slow the apps are. Meanwhile the real windows are moved and resized behind a frozen backdrop of the screen, out of sight. Once an app has redrawn its window at the new size, Amethyst takes a fresh picture and dissolves it into the sliding one, so the picture that lands is the real final rendering rather than a stretched old one. At the end the overlay fades away over windows that already look exactly like it. Along the way this handles special cases: apps that refuse the size or position they are given (System Settings, or anything that will not sit under the menu bar) get their pictures steered to where the window actually ends up; apps that repaint slowly are retried, and any window that never repaints in time dissolves gently at the handoff instead of cutting; windows that overhang a display edge are captured whole through ScreenCaptureKit; and windows caught mid-animation are pinned to the screen animating them so another screen's reflow cannot grab them. Smooth animation needs the Screen Recording permission. Amethyst asks for it once and, until it is granted (or on macOS 13 and earlier), falls back to moving the real windows, first resizing them in place and then gliding their positions through per-app writers so one slow app never holds the others back. Reduce Motion turns animation off. Settings: "animate-windows" (off by default), "window-animation-duration" (0.3 s by default), and an optional "toggle-animate-windows" hotkey with a HUD. Two private SkyLight functions are used, both resolved at runtime with automatic fallback if they ever go missing. * Keep the reflow overlay alive until its panel is taken down The overlay removed its panel from a fade-completion block that only held a weak reference to itself, but the reflow operation dropped the last strong reference as soon as it asked for the fade. By the time the fade finished the overlay was gone, the panel was never removed, and every animated reflow leaked an invisible panel holding the backdrop and window images. The completion now retains the overlay until teardown, and a test shows an overlay, drops it, and checks that no panel survives the fade. * Always take the reflow overlay down when the operation exits early A reflow that arrived after the glide had finished, during the last waits before the handoff, cancelled the operation at a checkpoint that simply returned. The overlay's fade had not been requested yet, so the panel stayed on screen at full opacity, in the in-place mode an opaque frozen picture of the screen, until the app was relaunched. The operation's cleanup now removes the overlay on any exit that did not hand it off through the fade. A test cancels an operation at its placement write and checks the overlay is removed. * Tolerate windows whose frame cannot be read during an animation An accessibility frame read fails when an app is hung or a window has gone, and Silica reports that as the null rect with infinite coordinates. The animation did arithmetic on it: rounding produced NaN, and the after-settle diagnostic converted NaN to an integer, which traps and crashed the app on any reflow with such a window. The same values could reach Core Animation and the capture sizes. Every live frame read now goes through one validating helper. A window unreadable at the start is left to the settle pass, one that becomes unreadable keeps its target, the diagnostic skips it, and the capture refuses unusable sizes. Tests cover all three. * Ignore only the animation's own window moves in the drag handlers To keep an animation's frame writes from being mistaken for user drags, the move and resize handlers dropped every notification while any screen had a reflow in progress. With animation that spans most of a second, and pressing on an unfocused window starts one, so drag-to-swap and mouse resizing were silently lost. The handlers now ask the registry of in-flight windows and ignore only notifications about windows the animation is moving; every other window's move is a gesture, as before. The unused reflow-in-progress flags are gone. * Let in-flight animations release a window Amethyst moves elsewhere A throw to another screen or Space issued while the source screen's animation was running was undone: the animation still listed the window and wrote its old tile back at settle or cancellation, and the in-flight registry kept the window pinned to the source so the destination's layout left it out. Relocating a window now hands it off: its registry claim is dropped, and an animation checks ownership before every write, the settle, and cancellation placement, hiding the proxy of any window handed off mid-glide. A test covers the hand-off during a glide. * Report a claimed window's animating screen while it is parked Parked snapshot mode moves windows beyond every display, where the geometric screen lookup finds nothing. Every screen-dependent path still asked that lookup directly, so during an animation a hotkey, a focus notification, or toggle-float for a parked window was silently dropped. A window claimed by an animation now reports the screen animating it from its own screen accessor, and only windows not in flight are located geometrically. A test covers the lookup of an attached screen by identifier. * Take the reflow overlay down even if the fade never reports completion Teardown ran only from the Core Animation completion, which the render server does not always deliver. A fallback timer now takes the panel down at the fade's length plus half a second if the completion has not, guarded to run once, and the test asserts that the pending fade keeps the overlay alive until then. * Leave windows at their tiles when an animation is cancelled Cancellation used to move the real windows to wherever their pictures were, so the next animation could continue seamlessly. When the reflow that cancelled it then did nothing, because tiling was turned off, the Floating layout was chosen, or a Space change bailed out, the windows stayed stranded at mid-animation positions; in the in-place mode they were even pulled back from destinations they already occupied. The real windows now stay at, or are placed at, valid tiles, and continuity comes from the registry instead: the cancelled animation records where each picture was last seen and a follow-up animation within a second starts its pictures there. Tests cover both. * Keep the focused window on screen from one shared rule The rule that shifts the focused window on screen when its app keeps a larger size than assigned was copied into the animation twice and missed in the in-place mode, so a proxy there was steered and recaptured overhanging the screen edge while the settle moved the real window back, a visible jump every reflow. The fallback glide's copy clamped with the requested size rather than the kept one, so it never engaged. FrameAssignment now owns the rule and all four sites use it; the fallback glide adopts the kept sizes after its in-place resize. Tests cover a focused window with a minimum width at the screen edge in both modes. The overlay panel test no longer pumps the main run loop from a main-queue block, which starved the very completions it waited for. * Only correct windows whose application has applied their frame The correction that runs after the glide waited briefly for the applications, ignored whether the wait succeeded, and then read back every remaining window. A window whose write was still pending reported its old frame, so its proxy was steered back toward where it started and the real window was sent there too before the settle finally moved it to its tile. The final correction now, like the glide, skips windows whose writer is still busy. A test uses a real writer with a slow window and checks that no correction is issued. * Aim a non-resizable window's proxy at its own size A window that cannot be resized is only ever moved, but its proxy was aimed at the full tile. In-place mode corrected that by reading the window back; parked mode read back only resized windows, so a fixed- size window's proxy stretched to the tile and popped at the handoff. The proxy is now aimed at the tile's position with the window's own size from the start, kept on screen if focused, in every mode. The test window model takes only the position when it is not resizable, and a parked-mode test covers the case. * Quiesce the writers before the settle and never drop a queued resize If an application's writer outlasted the drain timeout, the settle pass ran and the accessibility flag was restored while an intermediate frame was still queued, which then landed after the settle and left the window off its tile. And because a writer keeps one queued write per window, a position-only placement could replace a queued resize, so a parked window was placed at its old size. Queued writes are now discarded and in-flight ones awaited before the settle, and a move that replaces a queued resize keeps the size. Tests cover both. * Treat a glide that never reports completion as finished, not cancelled If Core Animation never signalled the end of the glide, because the display was asleep or the main thread stalled, the watchdog took the cancellation exit: windows were moved to approximate frames, the overlay was cut, and the exact settle and the fade were skipped while the reflow was reported as applied. The watchdog now logs and carries on to placement, settle, and fade like a normal completion. A test runs an animation that never completes and checks the windows land on their exact tiles. * Do not dissolve proxies into captures that cannot be verified Windows that overhang their display are captured through ScreenCaptureKit, which scales its output to the requested size. Such a capture never reveals that the application has not redrawn yet, so a mid-glide dissolve could blend the proxy into stale content. Skip the dissolve for those windows and let their proxies linger at the handoff, where they fade into the real window. * Track enhanced user interface suppression per application The AXEnhancedUserInterface flag belongs to an application, but each window recorded on its own whether it had cleared the flag for an animation. When windows of one application animated on two screens at once, the first screen to finish restored the flag while the other was still moving its windows. Count animating windows per application instead: the first window to begin clears the flag and only the last window to end restores it, both under a lock so concurrent screens cannot interleave. * Leave toggle-animate-windows unbound in the sample config A literal false for a command in the user's config file marks the command as overridden, which breaks its binding and removes any shortcut recorded in Preferences on every launch. Show the command as a commented placeholder like the other unbound commands so a copied sample leaves recorded shortcuts alone. * Share one display enumeration and overlap rule Three places each carried their own copy of "which display overlaps this rectangle most", and two of them plus the parking origin each enumerated the active displays on their own. Move both into ActiveDisplays and have the capture routing, backdrop display choice, pixel-scale lookup and parking origin use it. * Share one in-flight window-list fetch in the backdrop capturer The launch-time warm-up and the on-demand path each fetched ScreenCaptureKit's window list with their own code, and neither knew the other was running, so a reflow arriving during the warm-up started a second identical fetch and a timed-out fetch discarded its result. Keep a single in-flight fetch that both paths join, and cache its result whenever it completes. * Log animation events through one helper Four sites wrote the same message twice, once to the app's logger and once to the unified log, each with its own copy of the text, and four more reached only the unified log. Route every site through a helper that sends a single message to both channels. * Count only visible overlay panels The counter is documented as the panels on screen, but it also counted closed panels that AppKit had not yet freed, so the teardown test depended on deallocation timing outside the overlay's control. * Issue window frames through one helper Six places walked the participants, built per-application write batches, recorded each window's last issued frame and dispatched, each by hand, and two of them were the same code apart from the wait afterwards. Fold the walk into an issue helper that takes a closure choosing each window's frame, and share the target-position pass between the glide handoff and cancellation. * Fold Reduce Motion into the window animation rule The screen manager combined the animate-windows setting with the system's Reduce Motion setting inline, so the launch-time warm-up checked only the setting and the rule could not be unit-tested. Give the configuration a shouldAnimateWindowMovement predicate with a replaceable Reduce Motion hook and use it for both the reflow gate and the warm-up. The stored setting stays separate because the toggle and the HUD report it. * Always invoke pending overlay completions and wait on semaphores The overlay could drop a completion on cancel or silently replace one with a correction's, and the operation only coped through its wait timeouts. Call every accepted completion exactly once, including when the panel comes down, and wait on semaphores rather than dispatch groups so a completion that never arrives costs nothing more than the bounded wait. * Settle windows the animation never claimed The settle pass applied frames only to windows this operation had claimed, but only participants are claimed. A window left out of the animation because its frame could not be read was therefore never settled in production, unlike in a non-animated reflow. Settle a window when it is still ours or was never claimed, keeping handed-off participants excluded, and give the covering test a screen identifier so it exercises that rule. * Check ownership again when a queued frame is applied Ownership was checked only when a frame was queued. With a slow application, a placement queued before the user threw the window to another screen was still applied afterwards and dragged the window back. Ask the operation whether the window may still be touched immediately before each write. * Bring a parked window back on screen before throwing it A window thrown to another Space while the animation had it parked beyond every display stayed there for good: the hand-off stopped the animation from touching it, Silica's drag-based Space move could not take hold of it, and a window on no display is never tiled again. Record each claimed window's destination, count frames in flight through the registry, have a hand-off wait for those to land, and put a window that is still off every display at its destination before moving it. * Place windows at their tiles on every cancel of the fallback glide A cancel between the in-place resize and the glide, or during the wait for a slow application after it, returned without placing the windows, leaving them resized at their old positions or one frame short of their tiles. Send both exits through the same abandon step the mid-glide cancel uses. * Hide a handed-off proxy by opacity alone Hiding a proxy removed its animation, which snapped it to its target, faded it over Core Animation's default quarter second, and counted as the end of the newest batch of motion while other proxies were still moving. Set the layer's opacity to zero instead, and start the final fade from the current opacity so a hidden proxy does not reappear during it. * Clamp the focused window on its live focus when settling The shared clamp guards on the layout-time focus snapshot, but the settle already decides on live focus, so a window that took focus after the layout was planned was resized yet not shifted on screen. Split the pure clamp out and apply it inside the settle's live-focus check, as the original code did. * Count animation registrations per window Each window kept a single flag saying it had registered its application's enhanced user interface suppression, so when a window was thrown to another screen mid-animation the second screen could not register and the first screen's end restored the flag while the second was still moving it. Keep one entry per registration instead, under a lock, so the two balance out. * Ignore animation claims by a screen that is no longer attached The window-list filter pinned windows to their animating screen even after that display was unplugged, so the reconfiguration reflow on the remaining screen left those windows out until the dead animation released them, and nothing reflowed after that. Honor a claim only while its screen is attached, as the window's own screen lookup already does. * Do not remember picture positions for handed-off windows An abandoned animation recorded where every picture was, including those of windows thrown elsewhere mid-glide, so the adopting screen's next animation started such a picture from a stale spot on the old screen. Record positions only for windows the operation still owns. * Keep the requested size until a slow application applies its resize After the in-place resize the operation read every window's size back, even when the application had not applied the resize within the wait, so the focused window's on-screen clamp used the stale size and the glide stopped short of its tile for the settle to jump. Read the size back only once the window's writer is idle, and make the drain timeout injectable for tests. * Skip late refinements once the glide has stalled When the render server stopped reporting, the operation still requested the late corrections and final dissolve after giving up on the glide, then waited out each of their timeouts, adding over a second to a reflow that was already late. Return after the stall instead; nothing on screen can move or report back until the render server resumes. * Keep the reflow overlay on the Space it was made on The panel joined every Space and stood still through Space switches, so a switch made mid-animation left the old Space's frozen picture over the new one and hid the transition until the cancelled animation took it down. A reflow only runs on the active Space, so the default single-Space behavior is what it needs. * Show the Screen Recording hint once, and long enough to read The hint accompanied every first permission request of a launch, but macOS prompts only once ever, so after a denial the hint came back on every launch for six tenths of a second. Remember that it was shown, and keep it up for four seconds the one time it is. * Leave the layout-name flash out of screen capture A layout change flashes the layout's name and starts an animated reflow, whose backdrop captured the flash and then covered the real panel, so the name sat frozen for the whole animation. Exclude the panel from capture. * Give fake windows unique identifiers The test double drew its window identifier at random from one to a thousand, and the animation code keys its registry, captures and remembered positions on that identifier, so two windows in one fixture could collide and confuse the hand-off, capture-verification and last-seen tests. Number fakes from a process-wide counter instead. * Gate the writer tests on the apply hook instead of a sleep Two tests queued frames behind one "in flight" after a five-millisecond sleep, assuming the writer's thread had already picked the first frame up. Hold that frame inside the writer's apply-time hook until the others are queued, so the tests no longer depend on scheduling. * Let a frame assignment be given its configuration The final frame applied margins and minimum sizes from the shared configuration, which in tests is the host app's real preferences, so the settle tests that compare against fixed rectangles depended on whoever ran them. Take the configuration as a parameter, defaulting to the shared one, and give the test fixture a blank one. * Skip the screen-dependent tests cleanly without a display Five overlay tests indexed the first attached screen unguarded, which crashes the test process on a headless machine, and the screen-identifier test failed there even for its display-free half. Take the primary screen through a helper that skips the test when there is none, and run the display-free check before the skip. * Test the in-glide recapture and retry paths The fake overlay ended the glide at the first refinement, so dissolving a corrected window inside the glide and retrying a stale recapture inside it never ran under test. Let a test end the glide on demand and cover both. * Replace assertions that could not fail Two duration bounds held by construction, one cancel flag was never touched by its test, and one line asserted Foundation's Operation semantics. Pin the mid-glide dissolve to the time the glide has left instead, drop the rest, and check the bundled defaults file rather than a blank store for the animation setting's default. * Resolve capture requests by window identifier in the fakes Four fake capture routines picked the window by its position in the request list, or guessed it from the request count, so a recapture of a single window or a different order would have returned the wrong window's size. Look the window up by the request's identifier through a fixture helper. * Park test windows at distinct heights The parking test's windows and parking spot all sat at zero vertically, so the assertion that a parked window keeps its own vertical position could not tell it from the parking spot's. Give that test windows at two non-zero heights. * Drop two trailing sleeps the operation already covers Two tests with a slow fake application slept after the operation returned, once to let the writer finish and once to catch a late write, but the operation waits for its writers before settling and before returning, so nothing is in flight by then. Remove 2.2 seconds of sleeping. * Cover writer isolation, failed recaptures, pixel density and expiry Four branches had no test: one writer per application, a recapture that returns nothing, the freshness check at a Retina density, and the one-second life of a cancelled animation's remembered positions. Let a fake window name its application and add a test for each. * Describe the code rather than its history in comments Comments across the animation code compared the current behavior with earlier versions, justified choices against alternatives, or narrated the bug a line was there to prevent. Say what the code does instead.
A window capture the window server does not answer blocks its thread until the system gives up on it thirty seconds later. Captures used to run with one thread per window and no limit of their own, so a stalled window server left every reflow waiting thirty seconds before it fell back to moving the real windows, and dozens of blocked threads starved the hotkey handlers that share the thread pool. SkyLight captures now go through a gate: at most sixteen run at once, a batch is given up after one second, and after a batch has timed out captures are refused for fifteen seconds so the reflows that follow fall back immediately. The gate writes a line to the animation log when it pauses captures and when it resumes them.
Contributor
Author
|
Apple window server sometimes stalls and block window captures, so I need to add a resilient alternative so Amethyst doesn't jam up behind the Window Server and look like it broke. |
…ndows # Conflicts: # Amethyst.xcodeproj/project.pbxproj # Amethyst/Preferences/UserConfiguration.swift
…ndows # Conflicts: # Amethyst/Preferences/GeneralPreferencesViewController.xib # Amethyst/Preferences/UserConfiguration.swift
The "Start with tiling disabled" checkbox shared its row with the separator and the Maximum Window Count stepper. The section is one row taller, its rows move up by one, and that checkbox takes the row above the separator.
The duration field could be read but not edited, and unlike the other number fields in the pane it had no stepper. It is now editable and has a stepper that moves it in steps of 0.05 seconds within its range.
Brings in placing a window on the screen that shows its Space (ianyh#1899), the start-with-tiling-disabled checkbox on its own row (ianyh#1901) and the margin-independent custom layout tests (ianyh#1902). In AXWindow.screen() the screen owning an animation of the window is checked first, then the display holding the whole frame, the display of the window's Space, and finally the display showing most of it.
Contributor
Author
|
conflicts resolved. |
The animation and capture lines go through the logger the rest of the app uses instead of a log category of their own: the timing summaries, the size diagnostic and an unavailable snapshot as debugging detail, and a glide that never reported completion, a failed recapture, a window not redrawn at hand-off, and a paused or resumed window capture as warnings. A release build writes these lines to the system log according to the Debug tab's logging preferences (ianyh#1907), or when started with --log, and nowhere otherwise.
Owner
|
I appreciate the work you have done here, but, unfortunately, I don't think I can merge it for two reasons.
|
Contributor
Author
|
That's a fair design decision, but I have to say I love it. I'm running a version that has it and it makes it much clearer (to me) anyway where the windows are going when they switch. |
djp3
added a commit
to djp3/Amethyst
that referenced
this pull request
Nov 3, 2026
… and the project clean-up
djp3
added a commit
to djp3/Amethyst
that referenced
this pull request
Nov 5, 2026
* commit '1a7c8ac4512ec5a850778e5ab53387365903448e': (27 commits) Bump the version to 0.24.3-djp3.18 Update the fork notice for the closed ianyh#1888, the merged ianyh#1890 and the project clean-up Remove stale CocoaPods, MASShortcut and search-path leftovers from the Xcode project Cap the Wide layout's main pane count at the number of windows (ianyh#1904) Keep the BSP tree whole when removing a window (ianyh#1890) Remove MASShortcut (ianyh#1908) Bump the version to 0.24.3-djp3.17 Record a window's screen only when a layout places it Bump the version to 0.24.3-djp3.16 Describe the drag hand-over fixes and the logging preferences in the fork notice Log the drag hand-over's decisions Log animation through the app's logger Log adoption through the app's logger Log skipped reflows through the app's logger Turn warnings and errors on by default Add Debug preferences for writing to the system log Write the --log output to the system log under the app's subsystem Hold the focus reflow while the left mouse button is down Decide the drag hand-over with a tested value Tile a window on the screen it was dragged to ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Animate windows as they move between tiles
Until now every reflow snapped windows straight to their new positions. With the new "Animate window movement" setting turned on, windows glide to their new tiles instead. It is off by default.
Amethyst takes a picture of each window that is about to move, shows those pictures exactly where the windows are, and slides the pictures to their destinations using the system's own compositor, which keeps the motion smooth no matter how slow the apps are. Meanwhile the real windows are moved and resized behind a frozen backdrop of the screen, out of sight. Once an app has redrawn its window at the new size, Amethyst takes a fresh picture and dissolves it into the sliding one, so the picture that lands is the real final rendering rather than a stretched old one. At the end the overlay fades away over windows that already look exactly like it.
Along the way this handles the awkward cases:
Smooth animation needs the Screen Recording permission. Amethyst asks for it once, shows a one-time hint, and until it is granted (or on macOS 13 and earlier) falls back to moving the real windows: first resizing them in place, then gliding their positions through per-app writers so one slow app never holds the others back. Reduce Motion turns animation off. Either way the end state of a reflow is identical to a non-animated one, because the final frame still goes through
FrameAssignment.perform(withWindow:), focused-window peeking included.Settings
animate-windows, off by default: the General preferences checkbox, the YAML key, or thetoggle-animate-windowshotkey, which is unbound by default and shows a HUD.window-animation-duration, 0.3 s by default, clamped to 0.05 to 1.0.Under the hood
Each screen's reflow becomes one
AnimatedReflowOperationon the existing serial queue, so cancellation and the completion operation behave as before. It picks one of three strategies per reflow:Two private SkyLight functions are used,
SLSMainConnectionIDandSLSHWCaptureWindowList, both resolved at runtime withdlsym; if either is missing the operation falls back to the accessibility glide. ScreenCaptureKit is weak-linked and every use sits behind an availability check, so the deployment target is unchanged. A process-wide registry tracks which screen is animating each window; the window-list filters, the window's own screen lookup, the drag handlers, and the throw commands consult it. Per-applicationAXEnhancedUserInterfacesuppression stays cleared for as long as any of the application's windows is animating.Verification
Known limitations
--log, and nowhere otherwise.Files
New:
Layout/AnimatedReflowOperation.swift,Layout/WindowCapture.swift,Layout/BackdropCapture.swift,View/ReflowAnimationOverlay.swift, and their tests.Touched:
ScreenManager,WindowManager,Windows,Window,Screen,ReflowOperation,UserConfiguration,HotKeyManager,LayoutNameWindow, the General preferences xib,default.amethyst, the sample config, and the configuration docs.