Commit Graph
41 Commits
Author SHA1 Message Date
LGUG2Z 658827fcd5 fix(lint): build errors with Report::msg, not the eyre! macro the workspace bans
The ban (`just lint`, and now the hygiene job) came from the macOS and KDE repositories and was
never applied to the Windows code, so the unified tree had sixteen uses of the macro: seven in
the Windows daemon, six in komorebi-core (written during the unification), one in the KDE
backend and two in the recorder. Each becomes eyre::Report::msg, with format! where the message
has arguments.
2026-11-05 16:13:37 -08:00
LGUG2Z 259575a1b3 build: route the workspace to crates/
The workspace members, the path dependencies, the include_str! and test
fixture paths, the recorder's indexed source keys, and the Nix source
filter and path literals follow the new layout. Cargo.lock is unchanged.
2026-11-05 15:03:27 -08:00
LGUG2Z 87fb8340d0 chore(repo): one workspace version, 0.2.0
Every package of the workspace now takes its version from [workspace.package]
(version.workspace = true) instead of its own number. The numbers before were
0.1.42 (Windows libraries and packages), 0.1.0 (KDE, the macOS version crate,
komorebi-shortcuts and the e2e guest crates) and 0.1.1 (macOS libraries); the
unified release is 0.2.0 for all of them.

Cargo.lock only changes the version of the workspace's own packages.

Not changed here: the version text in schema doc comments and the generated
schemas (next revision), and the shim packages, which are deleted later and
only pick up the number meanwhile.

Verified: cargo metadata --offline --locked succeeds.
2026-11-05 15:03:27 -08:00
LGUG2Z f4b4d0ff05 feat(core): the window, named-workspace and behaviour-toggle commands as shared functions
Adds to komorebi_core::command: move_window, focus_window,
cycle_focus_window (layer dispatch: tiling or floating function of the
host), preselect_direction, cancel_preselect, promote_window,
monitor_workspace_index_by_name, focus_named_workspace,
move_container_to_named_workspace(follow), and the three behaviour toggles
(toggle_window_container_behaviour, toggle_cross_monitor_move_behaviour,
toggle_monocle_focus_behaviour). The host traits are WindowCommandHost
(thin forwards to each daemon's direction functions plus
update_focused_workspace_layout) and BehaviourCommandHost (get and set of
three settings). The bodies are the text the router arms have on all three
daemons today. Nothing calls them yet: the daemons converge in the next
three revisions. No behaviour change.

Native tests on the recording stub host, each naming its commands.py
check (mirrors: commands / ...): 5 new tests, komorebi-core commands
test file 23 passed (was 18).
Verified: cargo test -p komorebi-core --features schemars all pass;
clippy -D warnings on komorebi-core all targets passes; format-all
--check clean.
2026-11-05 15:03:27 -08:00
LGUG2Z fab53bd1f8 refactor(core,kde,mac): the unmanaged-window gate of the router is the CommandHost::gate_message hook
Section 22.1 of core-model.md: KDE and macOS refuse every message before
the router's match while the focused window is not managed
(handle_unmanaged_window_behaviour); Windows gates inside 18 functions.
CommandHost gets a defaulted gate_message(&mut self, &SocketMessage)
that lets everything through (the Windows form, its impl is untouched);
the KDE and macOS impls call handle_unmanaged_window_behaviour and their
routers call the hook where they called the method, so behaviour is
identical per daemon. komorebi-core now depends on komorebi-protocol
(for SocketMessage; Cargo.lock gains that one edge).

This is the groundwork only: the router itself is still per daemon,
because a shared router needs WindowManager<P> in core (see the
struct-move analysis in core-model.md). No BEHAVIOUR change.
Verified: KDE cargo test -p komorebi-linux 670 passed, 0 failed; fake-CC
clippy -D warnings for the four macOS packages passes; cargo clippy -p
komorebi-windows -p komorebi-core --all-targets -D warnings passes;
tools/format-all --check clean. Not verified: KDE VM, macOS hand check
(no behaviour change expected).
2026-11-05 15:03:27 -08:00
LGUG2Z e70a0e4921 style(windows): format with the project's rustfmt settings (tools/format-all --apply --tree windows)
Pure formatting by the same nightly rustfmt invocation the nix fmt check uses (tools/format-all, edition 2024, the tree's rustfmt.toml). No code change. Applied last on the candidate because it touches many files other agents were editing. Verified: tools/format-all --check --tree windows passes afterwards; light gates (fast-check) after all three.
2026-11-05 15:03:27 -08:00
LGUG2Z 4263bf4793 chore(repo): combine the candidate 8 draft with kfw's Windows deep dedup and the nix fmt/deny fixes
Candidate 8 (second draft): cbc40c03 (cand7 + pointer-picks-monitor + thin-events note + bar wgpu fallback + macOS deep dedup) plus wip-u-win-deep (PlatformMonitorId alias, promote_focus_container_idx hook, the WindowManager hook list) and wip-u-fmt (tools/format-all, nix fmt over the nightly rustfmt, deny clarify entries for Windows and KDE). Conflicts, if any, are resolved here.
2026-11-05 15:03:26 -08:00
LGUG2Z 7a69f692ba chore(repo): combine candidate 7 with the pointer-picks-monitor change, the bar wgpu fallback and the macOS deep dedup (candidate 8, before kfw's Windows deep dedup)
Candidate 8 (draft): wip-cand7 plus wip-u-deep (which contains wip-u-ptr: shared focus_workspace_number(s), KDE and macOS get the pointer-picks-monitor preamble, the const removed, and the thin-events design note), wip-u-bar4 (eframe wgpu fallback for the Windows bar, scenario rules) and wip-u-mac-deep (ContainerExt removed, nine shared window_manager functions identical on KDE and macOS, five macOS router arms as named methods). Conflicts, if any, are resolved here.
2026-11-05 15:03:26 -08:00
LGUG2Z 176dc0a8ba test(core): make the command tests clean under clippy -D warnings
komorebi-core is in the workspace default-members since the review fixes, so a bare clippy --all-targets -D warnings now covers its test files. crates/komorebi-core/tests/commands.rs (wip-u-cmd) had two findings that only show there: an unused Result of new_container_for_window (now unwrap()ed: the stub window cannot fail) and a never-read field pointer_for_all (removed: the Windows switch is tested through the associated const in its own host type). No behaviour change; verified: cargo test -p komorebi-core and the Windows clippy (bare, default-members).
2026-11-05 15:03:26 -08:00
LGUG2Z 1944fd67c4 refactor(windows): promote-focus on a custom layout is a hook of WorkspacePlatform
The Windows promote_focus_to_front focused the first column of a custom layout
that has no primary column (first_container_idx(primary_idx().unwrap_or(0)))
where the shared primary_container_idx fails for it; this was one of the
Layout::Custom differences of core-model.md section 18. WorkspacePlatform gets
promote_focus_container_idx(layout) -> usize, defaulting to
primary_container_idx(layout).unwrap_or(0), so a shared promote_focus_to_front
can call it on every platform; the Windows platform overrides it with the exact
expression it had (default layouts 0, custom layouts the first container of the
primary column, else of column 0). window_manager.rs calls the hook. A core test
pins the default for the default layouts.

Not a behaviour change on Windows (the same expression, moved). KDE and macOS
see a new defaulted trait method only. Verified: tools/fast-check native (core
tests), bare Windows clippy -D warnings, KDE check + lib tests, macOS fake-CC
type-check PASS; e2e: commands (promote-focus), layouts (custom layout).
2026-11-05 15:03:26 -08:00
LGUG2Z 3e5475e7ef refactor(core,kde,windows,mac): remove CommandHost::POINTER_PICKS_THE_MONITOR_FOR_ALL
All three daemons now let the pointer pick the monitor for every shared
command that has the preamble, so the const has no reason left. The
shared functions always call focus_the_monitor_under_the_pointer; the
three CommandHost impls lose the const (Windows had it true already, so
nothing changes there). The core test of the switch becomes
the_pointer_picks_the_monitor_..._on_all_platforms. known-issues item 1
is marked resolved and core-model.md section 18 text is updated.

No behaviour change in this revision beyond the previous two.
Verified: komorebi-core tests all pass (command tests 18); KDE cargo test
-p komorebi-linux 670 passed, 0 failed; fake-CC clippy for the four macOS
packages passes; cargo clippy -p komorebi-windows --all-targets -D warnings
passes. Not verified: Windows tests or e2e (cannot run on Linux).
2026-11-05 15:03:26 -08:00
LGUG2Z 96332b2578 refactor(windows): PlatformMonitorId next to PlatformWindowId; monitor_idx_from_current_pos has KDE's text
komorebi-core gets pub type PlatformMonitorId<P> = <P as MonitorPlatform>::Id,
the monitor counterpart of PlatformWindowId (blocker 5 of core-model.md
section 18). The Windows daemon aliases it (window::PlatformMonitorId, the
shared MonitorId) and gets window::monitor_id_at_cursor() like KDE's, so
monitor_idx_from_current_pos reads: ask the monitor id at the cursor, compare
monitor.id == monitor_id, and only then the Windows-only stale-handle fallback
(WindowsApi::monitor(monitor_id.to_hmonitor())). Same calls as before
(cursor_pos, monitor_from_point), in the same order.

Not a behaviour change. kfde: the alias is generic over MonitorPlatform; KDE and
macOS can alias it the same way. Verified: tools/fast-check native (core
tests), bare Windows clippy -D warnings, KDE check + lib tests, macOS fake-CC
type-check PASS; e2e: commands (monitor-from-cursor commands), hotplug scenarios
if any.
2026-11-05 15:03:26 -08:00
LGUG2Z 4c15358f7b refactor(core,kde,windows,mac): FocusWorkspaceNumber and FocusWorkspaceNumbers are komorebi-core commands
komorebi_core::command gets focus_workspace_number (show a workspace unless
it is in front) and focus_workspace_numbers (show it on every other monitor,
then on the focused one), both with the pointer preamble when the host's
POINTER_PICKS_THE_MONITOR_FOR_ALL says so, over a new CommandHost method
show_workspace_on (focus the workspace of a monitor and load it, which the
daemons already did inline). The three daemons' arms call them (Windows keeps
its focus_workspace_numbers method as a wrapper) and implement
show_workspace_on. The const is unchanged: true for Windows, false for KDE and
macOS, so nothing changes yet; the next revisions flip it. Tests: the
Windows-switch test becomes a test of all five commands with the switch off and
on, and focus_workspace_number(s) are tested on the stub host (commands.py:
focus-workspace, focus-workspaces).

Verified: cargo test -p komorebi-core --features schemars --test commands: 18
passed; KDE cargo test -p komorebi-linux (lite env): 666 passed, 0 failed; fake-CC cargo
clippy -D warnings on the macOS packages: PASS; Windows cargo clippy -p
komorebi-windows --locked --all-targets -D warnings: PASS. Not run: Windows
tests, VM and Mac.
2026-11-05 15:03:26 -08:00
LGUG2Z 401ce9112a refactor(core): Workspace::hide_spot and hide_spot_on_display as methods
Convenience for the callers that have a workspace and no platform type to name
(the window manager functions, which are the same text on KDE and macOS): the
same as P::hide_spot(self) and P::hide_spot_on_display(self). Nothing calls them
yet in the KDE and Windows daemons; no behaviour change.

Verified: native cargo test -p komorebi-core passes; fast-check all trees PASS.
2026-11-05 15:03:26 -08:00
LGUG2Z 0bf26a6d14 feat(core): lock and unlock a container by index, with native tests
komorebi_core::set_container_locked is the body of the
LockMonitorWorkspaceContainer and UnlockMonitorWorkspaceContainer arms
(the two differ by the flag; the text is the same on all three daemons),
over a third small host trait ContainerCommandHost: CommandHost that has
monitors_mut. Tests: lock then unlock, a container index that is not there
is ignored and a missing monitor or workspace is an error.

Verified: cargo test -p komorebi-core --features schemars --test commands
(native): 16 passed, 0 failed. Not run: the daemons.
2026-11-05 15:03:26 -08:00
LGUG2Z 6e38ddc1f8 feat(core): the commands that move across workspaces and monitors, with native tests
Eight arms' worth of the router as functions of komorebi_core::command:
cycle_move_container_to_workspace (the move and the send arm, by follow),
cycle_focus_monitor, cycle_move_container_to_monitor (move and send),
focus_monitor_workspace_number and move_container_to_monitor_workspace_number
(move and send). They need five more operations of the window manager, in
a second trait MonitorCommandHost: CommandHost (mouse_follows_focus,
update_focused_workspace, direction_from_monitor_idx,
move_container_to_monitor, focused_workspace_idx), so the daemons that
implement only the first trait still compile. The text is the KDE text,
which Windows and macOS have byte for byte. tests/commands.rs mirrors the
e2e checks of commands.py: cycle-move-to-workspace and cycle-send-to-workspace,
cycle-monitor (the wrap), cycle-move-to-monitor and cycle-send-to-monitor,
focus-monitor-workspace, move-to-monitor-workspace and
send-to-monitor-workspace.

Verified: cargo test -p komorebi-core --features schemars (native): the
commands test file 14 passed, 0 failed (the rest of the crate unchanged).
Not run: the daemons (nothing calls the functions yet).
2026-11-05 15:03:26 -08:00
LGUG2Z 7b3f691194 feat(core): the first shared commands, over a CommandHost, with native tests
komorebi-core gets `command`: the workspace navigation commands as
functions generic over a CommandHost (the few window-manager operations
they build on: the monitors and the focused one, the monitor under the
pointer, focus_monitor, focus_workspace, move_container_to_workspace):
cycle_focus_workspace, cycle_focus_empty_workspace, close_workspace,
focus_last_workspace and move_container_to_last_workspace. The text is
KDE's (which is macOS's); the one platform difference, that Windows lets the
pointer pick the monitor first for cycle_focus_empty_workspace,
close_workspace and focus_last_workspace where KDE and macOS do not, is the
associated const CommandHost::POINTER_PICKS_THE_MONITOR_FOR_ALL (false by
default). Nothing uses them yet.

tests/commands.rs implements the host with a recording stub and mirrors the
e2e checks of commands.py (cycle-workspace, cycle-empty-workspace,
close-workspace, focus-last-workspace, move-to-last-workspace and
send-to-last-workspace): wrap-around, the pointer's monitor, which
workspaces close, going back and forth, follow and send, and the Windows
switch.

Verified: cargo test -p komorebi-core --features schemars (native): 30
unit + 9 command tests passed, 0 failed (and the other test files of the
crate). Not run: the daemons (nothing calls the functions yet).
2026-11-05 15:03:26 -08:00
LGUG2Z 97c21b9360 merge: wip-cand6
Merge of wip-cand5, wip-u-bugfix, wip-u-wm, wip-u-settings3, wip-u-repotools,
wip-u-nix3 and wip-u-e2e2unit.

Resolutions:
- docs/dev/macos-handcheck.md: every section is kept, in order. The bugfix
  agent's section F (bar clicks) and the settings agent's section (also
  headed F) both appended after E; the settings one is renamed G, text
  unchanged.
- komorebi-for-mac/komorebi/src/animation/mod.rs and static_config.rs: the
  formatting-only revision of wip-u-nix3 (76ab52da, import order) conflicts
  with the semantic edits of wip-u-settings3 (S4/S5). The files are taken
  from wip-u-settings3 as they are; the following style(macos) revision
  formats them again with the check's rustfmt invocation.

Verified: see the following revisions and the report.
2026-11-05 15:03:26 -08:00
LGUG2Z acbe816fb4 test(core): follow the rename of the floating-window hook to before_floating_removed
wip-u-coretests (written against the hook's old name after_floating_removed) and wip-u-core4 (which renamed it to before_floating_removed because it runs before the window leaves the ring) were merged in candidate 5; the stub platform and the expected hook logs now use the new name. No behaviour change: the order test already pinned 'before the removal'. Verified: cargo test -p komorebi-core (with and without the schemars feature).
2026-11-05 15:03:26 -08:00
LGUG2Z ba094355d4 chore(repo): combine the review fixes, new tests and docs (candidate 5)
Candidate 5: wip-cand4 plus kfw's review fixes (wip-u-fix5: revert of the subscriber write timeout and the hwnd writer thread, BAR_RUNNING tied to the message, dead-window HIDDEN_HWNDS cleanup, core in default-members), kfm's macOS registry fixes (wip-u-kfm3), kfde's hook rename and per-pass title-bar snapshot (wip-u-core4), the komorebi-core characterization tests (wip-u-coretests) and the docs (wip-u-docs). Conflicts, if any, are resolved here.
2026-11-05 15:03:26 -08:00
LGUG2Z 231e50b3fc test(core): tiling arithmetic of update_shared as native checks of the e2e layouts
The Windows e2e scenarios layouts (111 checks), flipping, layout_flip, padding,
closing, minimizing, floating, stacks, tiling and tiling_off assert where the
tiles of a workspace are. Since the consolidation every daemon gets those tiles
from komorebi-core's Workspace::update_shared, so they can be checked on the
stub platform on Linux (and on the Mac Mini for macOS) instead of in a guest.

crates/komorebi-core/tests/e2e_layouts.rs (6 tests) runs update_shared on a
StubPlatform workspace for the 8 layouts of the scenario, 1 to 8 containers and
three padding settings: one tile per container, inside the work area, not on
each other; workspace padding moves tiles 40 px in, container padding shrinks
every tile, and back as it was; each of the three flips equals the plain tiles
mirrored (as a set); removing a container (what a closed, minimized or floated
window does) leaves the others at least as much room; two containers, one a
stack of two, are two tiles; with tiling off nothing is placed in any layout.
Each test names the e2e checks it mirrors. They protect Windows, KDE and macOS
alike. Platform dependent: the stub adds no border and no frame adjustment, so
the Windows border of 7 px (windows_padding) and each daemon's own
adjust_layout stay e2e only, as does the OS frame matching the tile.

Verified: cargo test -p komorebi-core --test e2e_layouts, 6 passed (native
Linux; macOS crates run later on the Mini). No source change, no bug found.
2026-11-05 15:03:26 -08:00
LGUG2Z fa3ec1ba2e test(core): add the review's gaps: floating hook order, placement rules, hook defaults, key sets
Follow-up to the review of komorebi-core (S/review/core.md, F2 and F4 and its
untested-behaviours list); most of the list was already pinned, this adds the rest:
- the after_floating_removed hook is pinned to run BEFORE the window is taken out
  (it sees both windows and the old focus index), today's KDE/macOS order, although
  the trait doc says after; the stub now logs len and focus for the hook.
- resolve_placement_index with Rules maps (Single and Many matching, Secondary,
  no match falls back after the focused container); the stub gained a match id and a
  path (a window without a path never matches Rules: it falls back).
- the JSON key set of a default workspace, and of Windows and macOS monitors per extra.
- the documented defaults of every optional hook on a platform that overrides nothing
  (the KDE-shaped test platform), and that the default place hooks make update_shared fail.
- Monitor remove_workspace_by_idx at the length, and an old monitor file with a
  non-empty ring of workspaces missing optional keys.

Verified: cargo test -p komorebi-core 215 passed, 1 ignored (the known bug), and with
--features schemars 217 passed, 1 ignored; clippy --all-targets has no warning in the
crate. No non-test source changed.
2026-11-05 15:03:26 -08:00
LGUG2Z 38f1295251 test(core): pin the state JSON of the three daemons from real fixtures
tests/state_roundtrip.rs (15 tests) reads the monitors of the e2e fixtures
(Windows kfw-tiled, kfw-stack, kfw-float; KDE kfde-tiled, kfde-stack) into the
shared Monitor<P> with a platform shaped like each daemon (Windows: isize id,
optional serial number, the name/device_id/workspace_names extra; KDE: u32 id,
string serial number, no extra; macOS: window_hiding_position extra), writes
them again and compares the parsed JSON: every fixture is written as it was
read. Also pins that the corner is the last macOS monitor key and cannot be
omitted, that the workspace keys are the same whatever the platform, the exact
set of KDE monitor keys, and which keys an old state file may omit (23 optional
keys at monitor, workspace and container level, e.g. container locked and
workspace layout_options_rules) and which it may not (18 required keys,
including layer, work_area_offset_rules and apply_window_based_work_area_offset:
a file from before those existed does not load; pinned, not judged).

The fixtures are copied into tests/common/fixtures.rs as Rust text because the
nix source filters keep .rs files and drop .json; a test compares the copies with
e2e/lib/tests/fixtures when the checkout has them. The macOS fixture is NOT real
macOS output: it is kfde-tiled reshaped with jq to the macOS window and monitor
shape of the state_pin tests (no Mac here), and says so in its comment; replace
it with 'komorebic state' from a Mac when one is at hand.

Verified: cargo test -p komorebi-core (27 unit + 179 integration passed, 1
ignored) with and without --features schemars; cargo clippy -p komorebi-core
--all-targets has no warning in the crate. Windows clippy and macOS check not run:
the tests are portable crate tests and no platform source changed.
2026-11-05 15:03:26 -08:00
LGUG2Z 66fb7ef585 feat(core): update_shared has a begin_pass hook whose answer the hooks of the pass see
WorkspacePlatform::begin_pass(workspace) is called once per placement
pass, after the layout is computed and before the containers are placed,
and what it returns is handed to adjust_layout and place_container as
Placement::pass (Placement now carries that borrow). A platform that has
something to read once for the whole pass takes it here, so that two
containers of a pass cannot see two different values. The default returns
None. A test with the stub platform pins the order (once per pass, before
the placements) and that the hooks see the answer.

For reviewer finding F3 (S/review/core.md): the Windows title-bar tables
were read once per pass and the shared update read them once per
container; the Windows revision that follows uses this hook.

Verified: cargo test -p komorebi-core --features schemars (native): 30
passed, 0 failed. Not run: the daemons (the next revision builds them).
2026-11-05 15:03:26 -08:00
LGUG2Z f74e201f64 test(core): pin Monitor workspace management
tests/monitor_workspaces.rs (22 tests) over the recording stub platform:
ensure_workspace_count (grows with default workspaces, never shrinks, leaves
the focus), focus_workspace (last_focused_workspace bookkeeping including
focusing the focused one, creating every workspace up to a focused index past
the end, the empty monitor), the known workspace name (without a known name
names stay; with one only the focused workspace takes it, and an EXISTING
workspace's name is overwritten at every focus although the comment says
only at creation: pinned as it is, inherited from the Windows tree),
remove_workspace_by_idx (index not moved, past-the-end focuses idx-1 creating
workspaces, empty monitor gets a default one), remove_workspaces, add_container
with and without a workspace index and the error cases, the focused layout
only while tiling, and the JSON of last_focused_workspace and a round trip.

Verified: cargo test -p komorebi-core --test monitor_workspaces, 22 passed.
No non-test source changed.
2026-11-05 15:03:26 -08:00
LGUG2Z 3cc8ff63b3 fix(core): constrain the main container of the right-main vertical stack at index 0
enforce_resize_for_right_vertical_stack said "Zero is actually on the right"
but locked top, bottom and right of resize_dimensions[1], so the main
container (index 0, drawn on the right: arrangement.rs primary_left =
area.right - primary_width) was never constrained and the first stack
container could not be resized at all. Index 0 now loses top, bottom and
right (it can only grow to the left); the stack loop over [1..] is unchanged
(nothing in it goes left, first not up, last not down).

The test that pinned the buggy result is replaced by the previously ignored
test of the intended behaviour, un-ignored and extended to 1 to 4 tiles:
[l, rb], [l, rb, tr], [l, rb, trb, tr].

BEHAVIOUR (all three daemons share this function): resizing in the
right-main-vertical-stack layout changes. Gate: Windows e2e resize
scenarios; the ones that run in right-main-vertical-stack are none by name
(resize_commands uses the default layout; layouts.py and commands.py only
tile and cycle through right-main-vertical-stack), so a pointer or
resize-edge scenario in that layout would need adding.

Verified: cargo test -p komorebi-core, with and without --features schemars,
all pass; no e2e run.
2026-11-05 15:03:26 -08:00
LGUG2Z af501d2eb7 refactor(core): the floating-window hook is called before_floating_removed
Workspace::remove_floating_window calls the hook before it takes the
window out of the ring (the KDE and macOS originals move the focus to the
previous floating window first, and the focus index moves back by one
whatever the length), but the hook was named after_floating_removed and its
doc said after. Name and doc now say before; the behaviour is the one KDE
and macOS had. KDE's and macOS's implementations are renamed with it (the
only users; Windows keeps the no-op default). A stub test pins the order:
the hook sees both floating windows when one is removed.

Reviewer finding F2 (S/review/core.md). No behaviour change.

Verified: cargo test -p komorebi-core --features schemars (native): 30
passed, 0 failed; KDE cargo test -p komorebi-linux (lite env): 664
passed, 0 failed; Windows clippy --locked --all-targets -D warnings:
PASS; macOS fake-CC check: PASS. Not run: VM suites, Windows e2e.
2026-11-05 15:03:26 -08:00
LGUG2Z a1a18a7afc test(core): pin the hook order and arguments of Workspace::update_shared
tests/update_shared.rs (34 tests) over the recording stub: the exact call log
for plain tiling (begin_update, containers_pruned with the old focus index,
adjust_layout then place_container per container, end_update with the around
and viewport arguments, guard dropped last), monocle (place_monocle with the
work area less workspace, container, border offset and border width padding;
no end_update), maximized, monocle beating maximized, scrolling (adopt widths,
scrolling_layouts, hidden flags into place_container, again), empty, tile off,
a skipped begin_update, end_update returning Again (pass numbers, the places
repeated, begin and prune once). Error policy per hook: begin_update,
place_container, place_monocle, maximize_in_layout and end_update errors all
propagate; the guard is still dropped; a failing place_container leaves
latest_layout and the resize vector untouched while a failing end_update has
already kept the layout. Also the layout rules (highest threshold wins and
sticks), container behaviour rules (none reached clears it), work area offset
priority (rule, workspace, monitor; monocle counts as one), the window-based
offset limit, paddings (workspace Some(0) wins over the monitor), resize vector
resizing (not while monocle) and constraint enforcement before layout.

Verified: cargo test -p komorebi-core --test update_shared, 34 passed. No
non-test source changed.
2026-11-05 15:03:26 -08:00
LGUG2Z 8d881bc229 test(core): pin monocle, floating, layer and hide behaviour, and the resize constraints
tests/workspace_layers.rs (33 tests): monocle toggle, reintegration (index
restore, padding past the end), cycling and its wrap; new_floating_window from
a container, a stack, the monocle and the maximized window (unmaximize hook, the
failure leaving the window maximized); floating removal and the
after_floating_removed hook; the layer enum (default, Display, JSON) and that the
shared code never changes it; Workspace::hide order (floating from the back at the
window spot, containers at the display spot, maximized, monocle) with the error
policy: a floating or container window that will not hide is skipped, a maximized
one is an error that stops before the monocle.

tests/resize_constraints.rs (11 tests): the sides each default layout leaves
adjustable for 1..4 containers, None tiles, and no containers.

BUG FOUND (one ignored test): enforce_resize_for_right_vertical_stack indexes
resize_dimensions[1] where its own comment says zero is on the right, so the main
container is never constrained and the second may not be resized at all; this is
inherited unchanged from the Windows tree. The current behaviour is pinned by a
passing test and the intended one by an #[ignore = "bug: ..."] test.

Verified: cargo test -p komorebi-core --test workspace_layers --test
resize_constraints: 33 and 10 passed, 1 ignored. No non-test source changed.
2026-11-05 15:03:26 -08:00
LGUG2Z 92943f7cba test(core): pin Workspace container ring, placement, stacking and promote
tests/workspace_containers.rs (41 tests) over the recording stub: where a new
window goes (empty, after the focused container, scrolling hook index,
preselection, every initial placement rule incl. the 1-based index and its
fallback), resize-slot bookkeeping on insert and remove, locked containers
keeping their index on insert, swap and promote, the note_scrolling_departure
hook before a removal, the focus index after remove_container (idx-1 of the
FOCUSED container, not of the removed one), stacking (move_window_to_container)
and unstacking with the exact hide/restore call order and the hide spot passed,
focus by window, window lookup across containers, monocle, maximized and
floating windows, location_from_exe order, visible_windows order, directions
with and without layout flip, cycling and the pointer lookup.

Verified: cargo test -p komorebi-core --test workspace_containers, 41 passed.
No non-test source changed.
2026-11-05 15:03:26 -08:00
LGUG2Z d20432f087 test(core): add a recording stub platform and pin Container behaviour
Adds crates/komorebi-core/tests/common (StubWindow, StubPlatform): a
Clone-but-not-Copy window and a platform whose window operations and every
WorkspacePlatform and MonitorPlatform hook append a line to an ordered log,
with failure injection per operation (fail("hide 3"), fail("place_container")),
scripted end_update passes and a per-workspace hide spot kept in the platform
state the way macOS keeps its corner. The log and settings are thread-local
and every test starts with fresh().

tests/container_behaviour.rs pins Container<W> (24 tests): add/remove/focus
ordering, the focus index after removal at each position (it is idx-1 whatever
was focused, and dangles after an out-of-range removal), empty-container cases,
the order of hide_window calls (from the back, a failing window is skipped),
load_focused_window stopping at the first failure, the omitted window, restore,
locking and the JSON shape.

Verified: cargo test -p komorebi-core --test container_behaviour, 24 passed
(nix shell gcc, own target dir). No non-test source changed.
2026-11-05 15:03:26 -08:00
LGUG2Z 51afa8b135 feat(core): Workspace::update_shared with the hooks of the update skeleton
The shared half of update (core-model.md section 12) as
Workspace::update_shared: begin_update (Flow::Skip, or a guard held until
the end), the empty containers dropped and containers_pruned, the work
area, offsets and paddings, the layout and behaviour rules, then the tile
branch: place_monocle, maximize_in_layout, adopt_widths_before_layout and
adopt_actual_widths for a scrolling workspace, the layout (calculate, or
scrolling_layouts with the containers that rest hidden), adjust_layout and
place_container per container, latest_layout, and end_update, which can ask
for one more pass (Pass::Again), and the resize_dimensions resize. The
text is KDE's with the Windows pass loop in it; the hooks are the parts the
two daemons do differently. It is not called update so that a daemon keeps
its own update (macOS's, which has another shape, stays as it is); every
hook has a default so that MacosPlatform compiles unchanged, and the
defaults of the ones a daemon must provide fail. Placement carries what the
hooks of a pass need (the work areas, the paddings, the border, whether the
workspace scrolls, whether it has resize adjustments, whether a window is
maximized). Flow and Pass are the answers of begin_update and end_update.

A test with a stub platform pins the call order and the second pass.

Verified: cargo test -p komorebi-core --features schemars (native): 29
passed, 0 failed; Windows clippy --locked --all-targets -D warnings: PASS
(compiles the crate). Not run: the daemons (nothing calls update_shared
yet).
2026-11-05 10:30:05 -08:00
LGUG2Z e818868e02 refactor(core): the hide_spot hooks take the workspace, not its globals
The macOS corner is a property of the monitor that the workspace is on, which
the monitor gives the workspace when it updates its globals; macOS has
no field for it in the shared WorkspaceGlobals and keeps it in its
WorkspacePlatform::State, so the hooks need the workspace. hide_spot(&Workspace<P>)
and hide_spot_on_display(&Workspace<P>), called with self where they were called with
&self.globals; KDE and Windows do not override them (they return (), the
default), so nothing changes there; the test stub's two overrides follow.

Verified: native cargo test -p komorebi-core 26 passed; fast-check Windows
clippy -D warnings, KDE check + lib tests and macOS fake-CC type-check PASS. Not
verified: any run. Gates: none beyond the previous revision's (this changes no
call a daemon makes).
2026-11-05 10:30:05 -08:00
LGUG2Z 3baf1c1b39 refactor(core): hiding takes a HideSpot and says whether it worked (D-coord-7)
BEHAVIOUR for the shared signature; none intended on KDE or Windows. Needs
the Windows and KDE gates below.

ContainerWindow gets 'type HideSpot: Copy + Default' (() on KDE and Windows;
on macOS the monitor's corner and, when known, the display bounds) and its
four operations return eyre::Result: hide_window(spot), restore_window(),
hide_stacked(spot), restore_stacked(). Container::hide(omit, spot),
restore(), load_focused_window(spot) and add_window(window, spot) return
Result (hide logs a window that cannot be hidden and goes on, as macOS does;
the others propagate). WorkspacePlatform gets two hooks with a default of
Default::default(): hide_spot(&globals) (the spot of a window) and
hide_spot_on_display(&globals) (the containers of a workspace that is being
hidden; macOS passes the display there and not for its floating windows).
The eight shared workspace functions that hide (focus_container_by_window,
new_container_for_window, move_window_to_container,
new_container_for_focused_window, new_monocle_container,
reintegrate_monocle_container, new_container_for_floating_window,
new_floating_window) and hide take the spot from the hook; new_container_for_window
and hide now return Result.

KDE and Windows: their Window impls return Ok(()) and take (); about 90 call
sites pass () and drop the Ok (let _ = ...) or use ?; nothing is hidden or
restored with a different argument than before: the same backend().hide /
restore, hide_with_border(false) and restore_with_border(false) calls run in
the same order, the Result is always Ok. macOS: the Window impl hides with
hide_on(spot.position, spot.screen) and restores, skipping both under
cfg!(test) as the old container code did; its ContainerExt is unchanged until
the Workspace layer.

No silent bind: every shared function whose behaviour depends on the spot
changed its signature (an added argument, or a Result where there was
none), so any caller written for the old form is a compile error in all
three trees (the six unused-Result warnings it produced on each of KDE and
Windows were each fixed by hand-checked 'let _ ='). The four macOS-only
extension methods (add_window_at, load_focused_window_at, hide_on,
restore_focused_window) share no name with a core inherent method (checked: the
intersection of the two name lists is empty), so no inherent method can shadow one.

Core tests: a stub window records the spot it is given; new tests pin that
a floating window is hidden at hide_spot, the containers of a hidden workspace
at hide_spot_on_display, and that stacking passes hide_spot through
add_window and load_focused_window; the container tests assert the spot.

Verified: native cargo test -p komorebi-core 26 passed; fast-check: Windows
clippy --all-targets -D warnings PASS, KDE check + lib tests PASS, macOS fake-CC
type-check PASS; KDE cargo test -p komorebi-linux --no-fail-fast 672 passed, 0
failed. Not verified: Windows and macOS tests, any run. Verified on the Mini:
not yet.
Gates for the coordinator: Windows e2e: workspaces, stacking, monocle (the
commands scenario), floating (toggle-float), lifecycle, resize, scrolling,
borders; KDE VM fast tier plus the stack, workspace, monocle and float
scenarios. These exercise exactly the hide/restore/stack paths touched.
2026-11-05 10:30:05 -08:00
LGUG2Z 6fa0819605 refactor(core): a ContainerWindow is Clone, not Copy
Step 11(iii) prerequisite. The macOS Window holds retained Accessibility
references and cannot be Copy, so the bound of ContainerWindow is Clone.
KDE and Windows windows are still Copy; they satisfy it unchanged. The seven
places in komorebi-core/src/workspace.rs that copied a window out of a
borrowed Option (if let Some(window) = self.maximized_window) borrow it
instead (&self.maximized_window), and two places clone where the old text
used the value twice (new_maximized_window, new_maximized_window's
unmaximize hook). No behaviour change on KDE or Windows: a clone of a Copy
type is the copy.

Verified: native cargo test -p komorebi-core, fast-check: Windows clippy
--all-targets -D warnings PASS, KDE check + lib tests PASS (291 passed), macOS
fake-CC type-check PASS. Not run: Windows e2e (needed only if you want a
second look: no Windows window type changed).
2026-11-05 10:30:05 -08:00
LGUG2Z 74b9992e1c feat(core): Monitor<P> with the shared half of monitor.rs
komorebi-core gets Monitor<P: MonitorPlatform> (MonitorPlatform extends
WorkspacePlatform), moved from komorebi-for-kde/komorebi/src/monitor.rs
and made generic: the id and serial_number_id are the platform's
associated types (Id with serialize_id/deserialize_id hooks so each daemon
keeps writing its id as the plain number it always did; SerialNumber), and
the fields only a platform has are P::Extra, flattened into the monitor's
JSON (NoExtra for a platform with none). The schema is named Monitor.
The workspace accessors (impl_ring_elements! is not generic) are written
out, and eight functions move with them: focused_workspace_layout,
focused_workspace_name, new_workspace_idx, ensure_workspace_count,
remove_workspaces, remove_workspace_by_idx, add_container and
focus_workspace, the last taking the name the platform last knew for a
new workspace from the known_workspace_name hook (Windows keeps its
names in the extra fields). WorkspacePlatform now needs Clone, Debug and
PartialEq of the platform marker and ContainerWindow needs Debug, because
the derives on the generic structs ask for them.

One serde fact the tests pin: a flattened map is read through a buffer
that keeps its keys as strings, so an extra field with integer keys (the
Windows workspace_names) needs a deserialize_with that parses them; the
Windows converge must carry it.

Tests with stub platforms: the JSON of a monitor with flat extra fields
and the id as a number, a monitor without extra fields, the name hook of
focus_workspace, the schema name and flat properties.

Verified: cargo test -p komorebi-core --features schemars (native): 27
passed, 0 failed; Windows clippy --workspace --locked --all-targets
-D warnings: PASS. Not run: the daemons.
2026-10-31 13:17:50 -07:00
LGUG2Z dcd707c688 feat(core): promote_container, effective_layout_options, new_floating_window and hide are shared
Four more functions of the workspace move into komorebi-core, written
from the KDE text with three hooks that have defaults: primary_container_idx
(the layout's primary position; 0 for the default layouts, Windows
overrides it for custom layouts), unmaximize_window (KDE asks the
compositor, a no-op on Windows, as new_floating_window does there today)
and before_hide_containers (the KDE scrolling prelude of hide, returning
the resize adjustments to put back). effective_layout_options needs no
hook: a layout that is not one of the defaults has no default options,
which is the Windows custom-layout arm and an unreachable pattern on KDE.
Tests with the stub platform cover promote, new_floating_window and hide.
The daemons still have their own copies; the next revisions make them use
these.

Verified: cargo test -p komorebi-core --features schemars (native): 23
passed, 0 failed. Not run: the daemons.
2026-10-31 13:02:17 -07:00
LGUG2Z f225e51982 feat(core): Workspace<P> with the shared half of workspace.rs
komorebi-core gets Workspace<P: WorkspacePlatform>, moved from
komorebi-for-kde/komorebi/src/workspace.rs (KDE is the base), together
with WorkspaceLayer, WorkspaceWindowLocation, CachedLayoutDefault and the
two threshold helpers, and these 52 functions of its impl, whose text is
the same on both daemons (add_container_to_back/front, the container
focus and removal family, insert_container_at_idx, swap_containers,
preselect and monocle operations, new_container_for_window and
resolve_placement_index, location_from_exe, visible_windows, the
enforce_resize_* family, the window lookups, remove_floating_window and
the floating focus helpers, is_scrolling). They are generic over
P::Window (Container<P::Window>, PlatformWindowId<P>), and every private
function is pub so the daemons' own methods can call it. The accessors
the impl_ring_elements! macro made are written out.

WorkspacePlatform is the hook trait: Window (a WorkspaceWindow), State
(what only a platform keeps in a workspace; skipped in the JSON and the
schema), default_padding, foreground_window_id, cursor_position,
should_act_window and should_act_window_individual (the platform holds
the compiled regexes), the three scrolling lookups and
after_floating_removed (KDE refocuses a floating window). Default for
Workspace<P> is the KDE one with the padding from the hook. serde and
schemars bounds are on P::Window; the schema is named Workspace.

Not used by any daemon yet; the next revisions make each daemon use it.
Four tests with a stub platform cover new_container_for_window, the
focus, the JSON keys and the default.

Verified: cargo test -p komorebi-core --features schemars (native): 20
passed, 0 failed; Windows clippy --workspace --locked --all-targets
-D warnings: PASS (compiles the crate). Not run: the daemons.
2026-10-31 12:50:34 -07:00
LGUG2Z b2ba3847cb feat(core): WorkspaceWindow, what a workspace asks of a window
A supertrait of ContainerWindow with the four lookups the shared workspace
code makes (title, exe, class, path, each Option<String>), for the
functions that move into komorebi-core next. The crate's stub window
implements it and a test checks the four answers. Nothing uses it yet.

Verified: cargo test -p komorebi-core --features schemars (native): 16
passed, 0 failed. Not run: the daemons.
2026-10-31 12:32:31 -07:00
LGUG2Z 88afd37d36 feat(core): WorkspaceGlobals moves into komorebi-core
The plain data a monitor gives the workspaces it shows (padding, border
width and offset, work area, offsets, floating layer behaviour), moved
from komorebi-for-kde/komorebi/src/workspace.rs (the Windows struct is
the same nine fields with the same derives) into komorebi-core, with the
KDE doc comments and two unit tests. komorebi-core now depends on
komorebi-config (for FloatingLayerBehaviour, default features off) and
komorebi-layouts (for Rect); its schemars feature enables theirs. The
struct derives JsonSchema under the feature, as Windows' did; a workspace
skips the field when serialised and in its schema, so no schema changes.

No daemon uses it yet: the next two revisions converge KDE and Windows.

Verified: cargo test -p komorebi-core --features schemars (native): 15
passed, 0 failed. Not run: the daemons.
2026-10-31 12:14:35 -07:00
LGUG2Z caf24494a7 feat(core): komorebi-core with Container generic over the platform window
New crate crates/komorebi-core, a member of the root workspace (KDE and
macOS take it by path when they adopt it). It holds Container<W>, moved
from komorebi-for-kde/komorebi/src/container.rs (KDE is the base) and
made generic: W is any type that implements ContainerWindow, a small
trait for what the container asks of a platform window (its id, the
executable name, hide and restore, and the hide and restore that
load_focused_window uses, which on Windows leave the border alone).
Container keeps no Backend calls; hiding and restoring is the window's
own business.

The serialised form is unchanged: id, locked (which may be missing when
read, as on Windows), windows with elements and focused. The schemars
schema of Container<W> is named Container whatever W is
(schemars(rename)), so schema.json keeps its definition name; a test
checks it. The tests of container.rs that need no daemon moved with it,
over a stub window, plus tests for the JSON, the hide/restore calls and
the missing locked field.

No daemon uses it yet: the next revisions converge KDE and Windows.

Verified: cargo test -p komorebi-core --features schemars (native):
13 passed, 0 failed. Not run: Windows, KDE, macOS builds (nothing
depends on the crate yet).
2026-10-31 11:36:54 -07:00