Repository navigation
feature: add scratchpad feature for dropdown window support - #334
Granitosaurus wants to merge 9 commits into
Conversation
toggle-scratchpad <app_id> <command> hides or shows the window with that app_id, spawning <command> when none exists. A hidden window stays mapped with its client, size and pin site, so showing it again is one frame at the same place with no animation. Hiding reuses the deferred-adopt hidden state: the window joins scratchpad_hidden, which root_hidden_by_deferred_adopt now also consults, so rendering, hit-testing, focus and IPC already skip it. Hidden windows get the off-screen frame-callback heartbeat so clients keep running. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The pinned walks (content, chrome, resize margin, decoration) never consulted the hidden state, so a stowed pinned scratchpad kept catching pointer events at its old site. Skip it in all four, and cover the unplug paths (survivor rehome, last-output placeholder) with tests. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A scratchpad is respawned by its own binding, so a stand-in restored for it after a restart is only in the way, and toggling then spawns a second window beside it. Resolve restore_windows to false for any app a toggle-scratchpad keybinding names, on both the save and the load side. An explicit restore_windows rule still wins. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…eload release, spawn debounce Toggle now acts on every window with the app_id plus transient children, ignores a window that has not had its first placement, applies a fullscreen/maximize requested while stowed, debounces repeat spawns, and releases stowed windows whose binding vanished on config reload. Any binding kind marks a scratchpad app for session restore. scratchpad_hidden joins debug_counters. Fix the config reference example that split the default keybinding table. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
I ran extensive review for edge case hunt and it did come up with several tiny edge case issues that I fixed. I'm working on formalizing this PR body next with my introduction for this feature. |
…show The action guard ends fullscreen before the toggle runs; remember which window that was and queue its fullscreen so show re-enters it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
ok ready for review. been running this for some time now and haven't noticed any regressions. |
A pinned scratchpad kept the pin of the output it was created on, so stowing on one display and showing from another brought it back on the first. Showing now rebinds the pin to the active output, keeping the screen position. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
after using this for a week I'm very happy with this feature. |
Scaling the frame centre pushed a large window off a smaller output and the clamp flattened it against the edge. Keep the share of free space (output minus frame) on each axis instead. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Initial WIP
Working on a scratchpad feature for enabling pinned toggled windows like a dropdown-like terminal similar to Yakuake
2026-11-07_14-47-51.mp4
In the video above I have a dropdown kitty terminal that I hide/unhide with
meta + wkey. The window preserves its location, dimensions and contents between hide/unhide.Goals:
Add
toggle-scratchpad: stow a window and bring it back, no animationtoggle-scratchpad <app_id> <command>is a new bindable action. One keypress:<command>when no window with thatapp_idexists,That makes a Yakuake/Quake-style dropdown terminal possible without any external script:
2026-11-08_14-19-19.mp4
Why it matters: driftwm has no minimize or hide, so scripts can only fake this by moving the window off screen (pin, unpin,
msg move, re-pin). That path runs the pin/unpin animation machinery, so the window visibly resizes and creeps into place, and the dance is slow. A compositor-side stow avoids all of that.Behaviour details:
2026-11-08_14-22-34.mp4
2026-11-08_14-23-46.mp4
zoom-to-fitand focus-nearest, because all of those already honour the shared "hidden" predicate (details below).app_idis matched exactly. All windows with thatapp_id(e.g. a mail client's compose windows) and their transient dialogs are stowed and shown together. Intended forpinned_to_screenwindows (see limitations).2026-11-08_16-58-21.mp4
restore_windows = truewindow rule on the app overrides that.Related: #333 fixes an existing bug (scroll over a pinned window is dropped when a suspended stand-in is beneath it) that this feature makes easy to hit. Independent of this PR; this one does not depend on it.
Known limitations (deliberately out of scope)
reassign_orphaned_pinnedclamps each pin into the surviving output and overwrites the stored site, so it is not restored when the original output returns. A stowed scratchpad inherits that (it follows its pin to the survivor and shows normally, just at the clamped spot). Fixes would be either remembering the pre-clamp site per output or percentage-based placement in window rules. Happy to follow up separately if wanted.msg screenshot windowand idle inhibitors treat a stowed window.focus,move,pinandsuspendverbs refuse stowed windows via the existing deferred-adopt guards, so their error text ("mid-relaunch") is misleading for a stowed window.hidden_by_deferred_adoptalthough it now means "stowed or deferred". A rename touches ~28 call sites, so I left it for a separate commit if you want it.FRAME_CALLBACK_THROTTLE), so a terminal keeps rendering, at heartbeat rate instead of full speed.Implementation and architecture
(For reviewers, future maintainers and automated tooling.)
Design in one paragraph
A stowed window is not unmapped. It stays on the stage with its client, size, z-slot and pin site untouched. Stowing adds its root surface to a new list,
DriftWm::scratchpad_hidden, and the existing "mapped but invisible" predicate used for first-commit deferred adopts is extended to also report true for those surfaces. Every site that already skips such windows (render, canvas hit-testing, focus, fit/zoom, placement, persistence, IPC guards) therefore skips stowed windows. Reusing the predicate also reuses its semantics: placement suppression and the fullscreen/maximize queue, which the toggle accounts for (it never stows a window before its first placement, and it applies the queued request on show). The four pinned hit-test walks did not consult the predicate and are fixed below. Showing removes the surface from the list, cancels any in-flight window animation, then raises and focuses, so it reappears in one frame at its saved place.Reasoning for reuse over a new stage-level flag: the deferred-adopt predicate already has ~28 audited call sites covering exactly "drawn nowhere, out of every canvas relation, but alive". A parallel flag would need the same sites threaded, and any missed site would leak.
State
scratchpad_hidden: Vec<WlSurface>src/state/mod.rs, init insrc/state/init.rsdeferred_adoptions.src/state/suspended.rs:root_hidden_by_deferred_adopt/hidden_by_deferred_adoptscratchpad_hiddenmembers. The fast-path guard now checks both lists are empty.cleanup_surface_stateinsrc/state/window_lifecycle.rsAction and config
Action::ToggleScratchpad { app_id, command }src/config/types.rstoggle-scratchpad <app_id> <command...>(both required)src/config/parse.rs, plusACTION_NAMESand the exhaustiveaction_nametest helpersrc/input/actions.rscallsDriftWm::toggle_scratchpadconfig.reference.tomlentry and example;docs/config.mdregenerated withUPDATE_CONFIG_DOCS=1 cargo test docs_config_md_is_up_to_dateThe action is not in
runs_during_fullscreen, so like other window actions it exits fullscreen first.Session restore (
src/config/mod.rs,src/state/session_store.rs)A restored stand-in for a scratchpad app is useless (the binding respawns the app) and the toggle would then spawn a second window next to it, since it only matches live windows. So
Config::is_scratchpad_app(app_id)is true when any binding (key, tap, mouse, gesture or touch gesture) holdstoggle-scratchpadfor thatapp_id, andrestore_windowsresolves tofalsefor such apps, on both sides:resolve_restore_windowsskips their live windows when building the envelope;resolve_restore_windows_for_recordleaves their saved records unmaterialized (carried forward inert, like any other excluded record).Precedence: an explicit
restore_windowswindow rule > scratchpad default (off) >[session] restore_windows. An app toggled only viadriftwm msg action toggle-scratchpad ...has no binding and gets no implicit exclusion.The toggle (
src/state/scratchpad.rs, new)toggle_scratchpad(app_id, command):app_id_or_class()equalsapp_idexactly (stricter than the IPC selector's case-insensitive substring match), plus, transitively, windows whosexdg_toplevelparent is in the group.spawn_command(command, child_env)(same no-cursor-reveal path asspawn), unless the sameapp_idwas spawned in the last 3 s (scratchpad_spawns).pending_center(no first placement yet) -> do nothing.cancel_window_animation,apply_queued_geometry_request(a fullscreen/maximize asked for while stowed), thenraise_and_focuseach. No re-map and no pin/unpin, so no animation entry is ever created and the pin site is untouched.cancel_window_animation, drop from the focus history, and if one held focus, give focus to the most recent history entry that is not stowed (or clear focus if none).release_unreachable_scratchpads, run after a config reload, shows again any stowed window (and its children) whoseapp_idno binding toggles any more.Hit-testing fix for pinned windows (
src/input/mod.rs)The canvas walks already skipped hidden windows, but the four pinned (screen-space) walks did not:
pinned_topmost_under,pinned_window_under,pinned_decoration_underandpinned_resize_margin_under. Without a fix a stowed pinned window stayed an invisible click-catcher and resize-cursor trigger at its old site. Each now skips windows for whichhidden_by_deferred_adoptis true. The regression test fails without this change.Frame callbacks (
src/render/lifecycle.rs)post_rendercomputeson_screenper window to choose between render-rate frame callbacks and the throttled off-screen heartbeat. A stowed window is forced toon_screen = false, so its client keeps receiving the heartbeat (a terminal keeps processing output) without being treated as drawn. Rendering itself skips it through the shared predicate.Hotplug
Stowed windows stay pinned, so
reassign_orphaned_pinnedandsync_pinned_locsapply to them unchanged: unplugging the output they were pinned to rehomes the pin onto the survivor (clamped), and the last-output placeholder swap rehomes it onto the new output. Both paths are covered by tests (see below). The position-memory limitation above comes from the same code.Tests (
src/tests/scratchpad.rs, new, 15 tests; 3 more insrc/tests/session_restore.rs)app_idwindows and a transient dialog hide and show togetherscratchpad_hiddenis part ofdebug_counters, so the fixture's teardown check covers itIn
session_restore.rs:restore_windows = truerule overrides the scratchpad defaultcargo fmt --check,cargo clippy --all-targets -- -D warningsandcargo test -- --include-ignored --skip soakall pass locally.Verification
Run as the author's daily-driver compositor on NixOS (udev backend, 3440x1440 monitor plus a 2880x1800 laptop panel at scale 2.0), with a pinned kitty and a pinned Thunderbird as scratchpads.
Checked by hand on that setup:
app_id);Covered by the automated tests, not checked by eye: click-through of a stowed window (all four pinned hit-test walks), the last-output-removed placeholder path, the first-placement guard, the spawn debounce, a fullscreen requested while stowed, config-reload release, and the mouse/gesture/touch binding kinds for the session-restore exclusion.
Neither tested nor checked by eye: exclusion from the overview (
zoom-to-fit), Alt+Tab and focus-nearest. That relies on those paths honouring the shared hidden predicate, which I read in the code but did not exercise.Suggested follow-ups (not in this PR)
hidden_by_deferred_adopt/root_hidden_by_deferred_adoptto something neutral such ashidden/root_hidden.position/sizein window rules.