Commit Graph
257 Commits
Author SHA1 Message Date
LGUG2Z 95ec707852 fix(window): ask the window server to bring an application to the front
Focusing a window activated its application with NSRunningApplication,
which from a background process reaches the window server as a request
stamped with the time komorebi started. Once the user has typed or
clicked since, the window server turns it away as expired ("Rejecting
expired request") and the application that was in front stays there:
focus moves in komorebi, the border, which only marks the window that
has the keyboard, stays unfocused, and the keys keep going to the
terminal that `komorebic focus` was run from.

Ask the window server directly first, with the request marked as the
user's, which is what clicking a window does. The two private symbols
it takes are looked up when first wanted and not linked, so that macOS
taking one away leaves komorebi starting and focusing as it did, with
one warning. A window server that refuses three times in a row is not
asked again, and a process without a serial number is left to the
usual way without counting against it.
2026-10-27 19:56:20 -07:00
LGUG2Z 2d06e68b48 fix(monitor): show a workspace's windows all at once when switching
Switching workspace hides the windows of the others and restores the
windows of the one that is wanted, one window at a time, each through
the accessibility API and each as slow as the app it belongs to. The
handler took 260 to 430 ms in a recording, and frames taken in the
middle of it show both workspaces on screen together: with Zed and Zen
gone, two WezTerm windows from the old workspace still up and Beeper
and Discord from the new one not there yet.

Workspace::update already batches its window moves with SLSDisableUpdate
and SLSReenableUpdate so that they appear together. Hiding and restoring
did not. BatchedUpdates holds the screen back until it is dropped, which
an early return does too, so an error cannot leave it frozen, and
load_focused_workspace keeps one for the hiding and the restoring. The
wallpaper, which can generate a theme, is put up after it is dropped,
which is why Workspace::restore is split into the windows and the
wallpaper. restore does what it did.

The screen does not change at all for as long as it is held, which is
now the length of the switch. How the private SkyLight calls behave
when it is held for that long, and whether it is long enough to notice,
was not tried on a screen.
2026-10-27 18:46:16 -07:00
LGUG2Z 407a011b5e fix(process_event): follow focus only while the app is still in front
komorebi brings an app to the front with activateWithOptions and then
hears about it from NSWorkspace and the accessibility API some time
later, 0.8 to 1.7 s in a recording, by which time it has often brought
another app to the front. The FocusChange handler took every such
notification at its word, which had two effects:

- focus moved back to the app that had had it, so Left, Left landed on
  the window in between rather than the one two along
- the app of a window on a workspace that is not showing made the
  workspace reconciliator switch to that workspace, which undid a
  workspace change that had been asked for a moment earlier

The handler now asks which app is in front and does not follow a
notification about any other. The last notification that is followed
is always about the app that really is in front, so the state ends up
where the system is. Notifications about an app that is not in front
still go through the rest of the handler, and nothing is ignored when
the accessibility API will not say what is in front.

Found in a recording of the installed build at db1c18b. That the
notifications are late and that the OS front process had moved on was
read off the OS trace; the change itself is tested only for the
decision, and was not tried on a screen.
2026-10-27 18:44:46 -07:00
LGUG2Z 7129778086 chore(deps): cargo update 2026-10-27 12:41:58 -07:00
LGUG2Z db1c18b5b6 fix(wm): make drag-to-resize follow the dragged edge
Dragging a tile's edge was unreliable: long drags were dropped, the
divider next to a different window drifted by a few points, and in
recordings made with komorebi-recorder a drag to the left shrank the tile
instead of growing it. This fixes the causes that were found there.

Resize bounds: bump komorebi-layouts and komorebi-themes to
LGUG2Z/komorebi@f08aa55, where DefaultLayout::resize only accumulates and
no longer refuses any adjustment larger than half of the container's own
size. resize_window now grants the largest amount that keeps every tile
at least a tenth of the work area (or as large as it already is), found
by bisection, instead of all or nothing. Keyboard resizing goes through
the same path. RUSTSEC-2024-0449 is ignored in deny.toml, as upstream
does in the same bump.

The dragged container: ResizeStart records the rect of the dragged window
once, since AXWindowResized fires again all through a drag, and ResizeEnd
hands it to the new WindowManager::resize_by_drag along with the rect the
window ended in. That resizes the container of the dragged window instead
of the focused one, for each edge that moved, instead of guessing the
edges from the difference to latest_layout (which made apps that snap to
a grid of cells resize edges that nobody touched).

Where the drag began: AXWindowResized is first reported after the edge
has moved, and handlers run one at a time, so the rect recorded as the
start can already be 22 points into the drag, or be the rect the drag
ended in. An edge that ended up more than 32 points from its tile is
measured from its tile edge; every other edge from the recorded start.

The reaper: it re-tiled the focused workspace on every mouse-up and
key-up to find windows that had gone away. That ran as soon as the button
went up, ahead of the ResizeEnd queued behind slower handlers, so the
window was back on its tile when ResizeEnd read where it had been dropped
and the drag was measured backwards. It now only looks for windows that
no longer exist and reaps them, without moving any window.

The tests reproduce each of these, including the numbers from the
recordings: a first step of 22 points, a drag already over when it was
first seen, and a mouse-up that must leave the layout alone.
2026-10-27 12:27:40 -07:00
LGUG2Z bdf10452f1 feat(wm): add monocle_focus_behaviour to gate monocle cycling
LGUG2Z/komorebi@5f629e1 made directional focus cycle the monocle
container in the underlying ring. Useful on a single monitor, but
undesired when focusing across monitors — the focus stays trapped on the
monocle workspace instead of crossing the boundary.

This commit adds a new top-level monocle_focus_behaviour option with two
variants, Cycle (the post-5f629e1f behaviour) and NoOp (the pre-5f629e1f
behaviour, now the default), along with a ToggleMonocleFocusBehaviour
socket message and corresponding komorebic subcommands to flip between
them at runtime.
2026-05-04 19:06:39 -07:00
LGUG2Z 0cc4ca7f67 docs(nix): update options 2026-05-03 11:13:42 -07:00
LGUG2Z 2b4760db1a feat(wm): add global layout_defaults for per-layout default options
This commit migrates this feature as it was implemented in
LGUG2Z/komorebi@24c0ce0b1d by @CtByte.
2026-05-03 11:04:20 -07:00
LGUG2Z 7e54fed8de feat(wm): add threshold-based layout_options_rules for workspaces
This commit migrates this feature as it was implemented in
LGUG2Z/komorebi@d6b17bbc7c by @CtByte.
2026-05-03 10:50:15 -07:00
LGUG2Z d8b0c2964a docs(nix): update options 2026-05-02 14:39:34 -07:00
LGUG2Z 41f338dea3 chore(deps): cargo update 2026-05-01 17:11:27 -07:00
LGUG2Z 323be43556 fix(wm): keep mouse on monocle when toggling w/ mff
This commit fixes a bug where, when toggling on monocle mode, the cursor
would go to the configured hiding corner.

Thanks to ziggee on Discord for pointing this out because I hadn't
noticed it despite using monocle mode all the time!
2026-04-09 20:55:07 -07:00
LGUG2Z 742543188d feat(wm): add dynamic work area offsets
This commit migrates this features as it was implemented in
LGUG2Z/komorebi@d3779e5a74 and
LGUG2Z/komorebi@53c81c4596.
2026-03-29 15:29:50 -07:00
LGUG2Z a17a39ea3b feat(bar): add storage_display_name option
This commit implements this feature as it was added in
LGUG2Z/komorebi@c84fa50fc9.
2026-03-29 15:22:29 -07:00
LGUG2Z 24878dc3a4 feat(wm): cycle monocle container when focusing in direction
The commit migrates this feature as it was added in
LGUG2Z/komorebi@5f629e1f1a.
2026-03-09 16:14:53 -07:00
LGUG2Z b4e12d8c39 chore(dev): begin v0.1.1 2026-03-01 17:46:39 -08:00
LGUG2Z 64341e29a2 chore(release): v0.1.0 2026-03-01 17:13:36 -08:00
LGUG2Z 4398cce054 chore(deps): bump komorebi-layouts for flip axis fixes
This commit pulls in the fixes from
komorebi@634a3e7f3b9f4f7d8108fd5cb86889ad6bebac0f.
2026-03-01 09:20:56 -08:00
LGUG2Z 5a37f6357d fix(bar): avoid bobbing when switching between populated/empty workspaces
This was debugged by Lando Calrissian on Discord who submitted this text
patch. The rest of this commit message is from Lando's investigation
summary shared on Discord:

The left panel in komorebi-bar uses `Align2::LEFT_CENTER` anchor, which
vertically centers the panel content within the bar. When switching
between workspaces with windows (icons) and empty workspaces (text
labels only), the content height differed by ~1-2px, causing the
vertical center point to shift - resulting in visible "bobbing" of the
workspace indicators.

The height inconsistency occurred because:

1. `show_icons()` wrapped content in a Frame with inner_margin
2. `show_fallback_icon()` had NO Frame wrapper
3. `show_label()` had NO Frame wrapper and used default text height

Fix:

1. Wrap `show_fallback_icon()` in the same Frame with inner_margin as
   show_icons
2. Wrap `show_label()` in the same Frame with inner_margin as show_icons
3. Add `ui.set_min_height(self.icon_size.y)` to show_label to ensure the
   label has the same minimum height as icons
4. Change show_label from static to instance method (&self) to access
   icon_size

This ensures all three rendering functions produce consistent content
height, preventing the LEFT_CENTER anchor from shifting when workspace
content changes.
2026-02-16 10:17:38 -08:00
LGUG2Z 1c699ed4c4 perf(bar): reduce cpu usage by sticking to logical pixels
This was debugged by Lando Calrissian on Discord who submitted this text
patch. The rest of this commit message is from Lando's investigation
summary shared on Discord:

Every frame, the update() method checks if egui's window rect matches
the stored size_rect. The comparison code multiplied egui's outer_rect
(which is in logical pixels) by scale_factor, producing physical pixel
values (e.g., 3584x40 on a 2x Retina display). But size_rect stores
logical pixel values (1792x20). These can never match on a HiDPI
display, so every frame:

1. `size_rect != current_rect` evaluates to `true`
2. `position_bar()` is called, sending `ViewportCommand::OuterPosition`
   and `ViewportCommand::InnerSize`
3. Each `send_viewport_cmd` internally calls `request_repaint()` in egui
4. egui schedules another frame → go to step 1

Result: 120fps continuous rendering, consuming ~12% CPU.

Debugging Method:

Instrumented the code with frame counters, FPS tracking, and repaint
cause logging. Systematically disabled components (repaint thread,
komorebi notifications, widget rendering) to isolate the cause. Traced
egui's repaint causes to context.rs:3853 (send_viewport_cmd_to), then
found the size_rect mismatch firing 1112 times in 10 seconds.

Fix:

Removed the erroneous scale_factor multiplication from the rect
comparison, since outer_rect already reports in logical pixels — the
same coordinate space as size_rect.

Result:

┌────────────┬───────────┬───────────────────┐
│   Metric   │  Before   │       After       │
├────────────┼───────────┼───────────────────┤
│ CPU (idle) │ 12-13%    │ 0.0-0.1%          │
├────────────┼───────────┼───────────────────┤
│ Frames/sec │ 120       │ ~1 (timer-driven) │
├────────────┼───────────┼───────────────────┤
│ CPU spikes │ Up to 20% │ None observed     │
└────────────┴───────────┴───────────────────┘
2026-02-16 10:13:15 -08:00
LGUG2Z 9087d68742 feat(cli): new layout-ratios command
This commit is largely lift and shift of LGUG2Z/komorebi@c165172:

The implementation adds a new layout-ratio CLI command to komorebi that
allows users to dynamically set column and row ratios for layouts at
runtime via komorebic layout-ratio --columns 0.3 0.4 --rows 0.5.

A public validate_ratios function was added to komorebi-layouts that
clamps ratio values between 0.1 and 0.9, truncates when the cumulative
sum would reach or exceed 1.0, and limits to a maximum of 5 ratios. This
function is shared between config file deserialization and the new CLI
command, ensuring consistent validation behavior.

The SocketMessage enum in komorebi/src/core/mod.rs has a new
LayoutRatios variant. The handler in process_command.rs uses the shared
validate_ratios function to process the ratios before applying them to
the focused workspace's layout options.

When the CLI command is called without any arguments, it prints a
helpful message instead of returning an error.
2026-02-13 17:03:55 -08:00
LGUG2Z 0e120a7b35 fix(bar): remove the leaky docstring on left_widgets 2026-02-13 17:03:55 -08:00
LGUG2Z a11138ec91 feat(wm): add layout_options with ratios support
This commit adds parity with the layout_options and ratio support added
to LGUG2Z/komorebi@22e8a79833 by @CtByte,
which is largely integrated into komorebi for Mac through the importing
of the new komorebi-layouts crate.
2026-02-13 17:03:51 -08:00
LGUG2Z ceba46f878 refactor(layouts): migrate to komorebi-layouts crate
This commit migrates to the new komorebi-layouts crate exposed in the
LGUG2Z/komorebi repository, significantly reducing duplication and
change maintenance between the two komorebi implementations.
2026-02-07 14:50:20 -08:00
LGUG2Z 6e324b63cc feat(cli): add --bar flag to enable-autostart cmd
This commit ensures that the komorebi-bar can also be autostarted,
matching the behaviour of the komorebic enable-autostart command on
Windows.
2026-02-06 17:15:48 -08:00
LGUG2Z e19c47a569 chore(deps): cargo update 2026-02-06 17:09:27 -08:00
LGUG2Z 3ef2377040 docs(quickstart): enable fewer widgets in the bar's example config 2026-02-06 17:08:51 -08:00
LGUG2Z 6f318b7df8 chore(deps): cargo update 2026-02-02 13:06:08 -08:00
LGUG2Z cbe18e6fe1 ci(github): only run actions on the private repo 2026-02-01 11:45:50 -08:00
LGUG2Z 8de0215b36 docs(readme): add homebrew install command for public snapshot 2026-02-01 11:42:16 -08:00
LGUG2Z 15bc697a1a docs(readme): update wm event subscriptions section 2026-02-01 11:40:13 -08:00
LGUG2Z 7fcc647b86 docs(schema): add asc schema for macos 2026-01-30 20:34:11 -08:00
LGUG2Z ebbd9eee35 docs(readme): prepare to make repo public 2026-01-30 11:35:30 -08:00
LGUG2Z 72ec96c2f6 chore(deps): cargo update 2026-01-27 18:16:19 -08:00
LGUG2Z 1192a103d2 fix(wm): distinguish separate windows from tabs for tabbed apps
When Finder is configured as a tabbed application, opening multiple
separate Finder windows (not tabs within the same window) prevented
focusing between those windows using komorebic focus commands.

The tab detection logic uses geometry comparison (tab_rect == main_rect)
to determine if a window event represents a tab change. This fails when
separate windows from the same application have identical geometry after
tiling, causing them to be incorrectly treated as tabs within a single
window.

This commit adds window ID verification as an additional requirement for
tab detection. For Show events, both geometry AND window IDs must match
for the event to be classified as a tab (preventing new container
creation). For FocusChange events, we verify the stored element's window
ID matches the container's stored ID to confirm legitimate tab switches
within the same window.

The geometry check is preserved to maintain existing tab detection, but
now requires window ID confirmation to prevent false positives when
separate windows happen to share identical positions and dimensions.

Additionally, this commit fixes the Window::focus() function for tabbed
applications to prefer using the stored element when valid, only falling
back to main_window() when the element is invalid (tab was closed). This
allows focusing specific windows even for tabbed applications instead of
always focusing the main/frontmost window.
2026-01-27 18:12:23 -08:00
LGUG2Z b5215a2842 feat(config): expose tabbed and titleless apps via asc
This commit removes the hardcoded entries in TABBED_APPLICATIONS for
Finder and Ghostty, and instead leaves this for users to source either
through their own configs using the "tabbed_applications" config option
or via an ASC file.

There is a slight discrepancy in the two schemas as the personal config
file will accept an Exe string identifying the app, whereas the ASC goes
with a full MatchingRule to keep the ASC consistent.

However, for both tabbed and titleless application options as exposed on
the ASC schema, when read in komorebi it will only accept
MatchingRule::Simple with an Exe identifier.
2026-01-27 17:50:44 -08:00
LGUG2Z 5bb1295a3b fix(wm): clamp layouts to work area boundaries
Resize adjustments can cause container layouts to overflow beyond the
monitor's work area boundaries, bleeding into adjacent monitors.

This happens because the resize adjustment system modifies container
dimensions without validating that the final calculated positions stay
within the monitor's bounds.

On multi-monitor setups (e.g. ultrawide + MacBook display), a large
resize adjustment on one container can push adjacent containers past the
monitor edge, making them visible on the neighboring display.

This commit adds boundary clamping after layout calculation but before
padding is applied. If a layout's calculated position exceeds the work
area bounds (horizontally or vertically), we clamp it to stay within the
monitor's usable space.

Additionally, a unit test validates that layouts with aggressive resize
adjustments (matching the reported issue) are properly clamped to
prevent overflow.
2026-01-20 14:24:05 -08:00
LGUG2Z 08794ba317 fix(wm): prevent ws reconciliation when closing last ws window
When the last window on a workspace is closed, macOS automatically
activates another app (often on a different workspace). This app's focus
event triggers workspace reconciliation, switching the user away from
the now-empty workspace they (presumably) intended to stay on.

The issue is a race condition: by the time we try to activate Finder to
prevent the unwanted focus change, the other app's activation event has
already been queued and will still get processed.

This commit enusres that we skip reconciliation when the current
workspace is empty; this indicates the user just closed the last window
and should stay on that workspace, not follow workspace focus to
wherever macOS arbitrarily activates an app.

Additionally, we activate Finder when a workspace becomes empty to match
native macOS behavior (clicking on empty desktop activates Finder
without opening a window).
2026-01-12 13:39:52 -08:00
LGUG2Z 7c1ab9a6cc fix(wm): handle ghost tiles from electron apps hijacking cmd+w
Some Electron apps like Discord hijack CMD+W to send
`AXApplicationHidden` instead of properly closing/destroying the window.

This causes ghost tiles because the window still exists in the
accessibility API with valid geometry even though it is no longer
visible on the screen.

When `AXApplicationHidden` fires for an app with exactly 1 window, we
now force-reap that window by passing an empty `valid_window_ids` list.

This treats single- window hide events as closes, which is the correct
behavior for apps that hijack CMD+W. Apps with multiple windows continue
to use normal orphan reaping.

I'm still not sure if this is too broad; we may need to use an allowlist
approach for this if it causes changes with other apps.
2026-01-12 13:20:41 -08:00
LGUG2Z 63409addb1 build(nix): remove mkdocs from devshell 2026-01-12 12:54:38 -08:00
LGUG2Z d91e14bd71 build(just): consolidate schemapub target 2026-01-04 21:11:28 -08:00
LGUG2Z 321bfb129c chore(deps): flake.lock: Update
Flake lock file updates:

• Updated input 'crane':
    'github:ipetkov/crane/2b3a5a88d852575758e1eb6ac9ee677fcd633fc1' (2025-12-05)
  → 'github:ipetkov/crane/7d59256814085fd9666a2ae3e774dc5ee216b630' (2026-01-03)
• Updated input 'flake-parts':
    'github:hercules-ci/flake-parts/2cccadc7357c0ba201788ae99c4dfa90728ef5e0' (2025-11-21)
  → 'github:hercules-ci/flake-parts/a34fae9c08a15ad73f295041fec82323541400a9' (2025-12-15)
• Updated input 'flake-parts/nixpkgs-lib':
    'github:nix-community/nixpkgs.lib/719359f4562934ae99f5443f20aa06c2ffff91fc' (2025-10-29)
  → 'github:nix-community/nixpkgs.lib/2075416fcb47225d9b68ac469a5c4801a9c4dd85' (2025-12-14)
• Updated input 'git-hooks-nix':
    'github:cachix/git-hooks.nix/b68b780b69702a090c8bb1b973bab13756cc7a27' (2025-12-16)
  → 'github:cachix/git-hooks.nix/f0927703b7b1c8d97511c4116eb9b4ec6645a0fa' (2026-01-01)
• Updated input 'git-hooks-nix/flake-compat':
    'github:edolstra/flake-compat/f387cd2afec9419c8ee37694406ca490c3f34ee5' (2025-10-27)
  → 'github:NixOS/flake-compat/5edf11c44bc78a0d334f6334cdaf7d60d732daab' (2025-12-29)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/a672be65651c80d3f592a89b3945466584a22069' (2025-12-05)
  → 'github:NixOS/nixpkgs/16c7794d0a28b5a37904d55bcca36003b9109aaa' (2026-01-02)
• Updated input 'rust-overlay':
    'github:oxalica/rust-overlay/086fd19a68e80fcc8a298e9df4674982e4c498a6' (2025-12-06)
  → 'github:oxalica/rust-overlay/1d3f83babdd21e16bf5cfe0f1efcb4f49ee1bc2c' (2026-01-05)
• Updated input 'treefmt-nix':
    'github:numtide/treefmt-nix/5b4ee75aeefd1e2d5a1cc43cf6ba65eba75e83e4' (2025-11-12)
  → 'github:numtide/treefmt-nix/d56486eb9493ad9c4777c65932618e9c2d0468fc' (2026-01-03)
2026-01-04 20:35:21 -08:00
LGUG2Z 6b8ad3c0bd chore(deps): cargo update 2026-01-04 20:20:28 -08:00
LGUG2Z 8453c428dd feat(cli): add dedicated permissions command
This commit adds a dedicated `komorebic permissions` command so that
users can quickly open the relevant Permissions dialogs in System
Settings at any time (i.e. after upgrades).
2026-01-04 19:57:20 -08:00
LGUG2Z 10c0d4215b fix(cli): update enable-autostart to run at load + specify log paths
This commit updates the plist generated by `komorebic enable-autostart`
to add RunAtLoad = true and paths in /tmp/ for StandardOutPath and
StandardErrorPath.
2026-01-04 19:52:25 -08:00
LGUG2Z 8b4604d47e fix(border): maintain config compat with windows opts
This commit adds a 7px border offset adjustment to the BORDER_OFFSET
value wherever it is used to maintain config compatibility with komorebi
for Windows.

Windows has stupid 7px invisible borders around every app window which
have to be taken into account when setting the values for these options,
but this is not the case on macOS.

However, if we don't replicate the factoring in of those invisible
borders into our offset calculations, the same border config on Windows
and macOS looks vastly different.
2026-01-04 19:40:40 -08:00
LGUG2Z c23bf462cb feat(bar): make explicit monitor config optional
This commit makes the monitor configuration option for the komorebi-bar
optional, defaulting to index 0. Additionally, the automatic work area
adjustment has been re-enabled for displays where are not built-in
Macbook displays.
2026-01-04 14:29:21 -08:00
LGUG2Z aac1e9ecf2 build(just): start using vararg build/install target variants 2026-01-03 11:39:26 -08:00
LGUG2Z 41001da1f0 refactor(bar): inline defaults in schemars attrs 2026-01-03 11:30:40 -08:00
LGUG2Z ca94a57dd5 feat(bar): render at notch level on macbooks
This commit uses raw-window-handle to access the NSWindow of the bar and
set the window level to `kCGBackstopMenuLevel` (-20), positioning the
bar behind the menu bar, and at the same level as the notch on Macbook
screens.

This approach means the bar occupies space already excluded from the
work area by the menu bar, so the automatic work area offset calculation
is no longer needed and has been commented out. (I think... Need to
validate this on regular non-Macbook external displays...)

The explicit user-configured `work_area_offset` option is preserved for
users who want more flexibility.
2026-01-03 10:13:17 -08:00