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.
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 │
└────────────┴───────────┴───────────────────┘
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.
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.
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.
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.
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.
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.
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).
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.
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).
This commit updates the plist generated by `komorebic enable-autostart`
to add RunAtLoad = true and paths in /tmp/ for StandardOutPath and
StandardErrorPath.
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.
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.
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.
Some apps like Raycast do dumb stuff like reporting empty strings as
titles to the system. If your app doesn't have a title, don't give it an
empty string as a title!
This commit adds an explicit string emptiness check on titles when
evaluating windows for management eligibility.
This commit exposes configs for titleless (i.e. MS Edge installed apps)
and tabbed (i.e. Ghostty) applications. Ghostty is no longer hard coded
as a tabbed application and should be added via config.
This commit disables animations on stacking operations because it's just
too much of a headache. Additionally, the borders get screwed up
sometimes on unstacking, so we'll just go nuclear and destroy and
recreate them on an unstack or unstack-all op.
This commit fixes the stupidest of stupid bugs. Column width
calculations on the Scrolling layout should take the number of windows
into account, especially when lower than the configured column count.
This commit ensures that we detect tabbed applications appropriately
when they are in monocle mode when handling FocusChange so that
switching tabs doesn't break monocle mode or the layout it has been
toggled on from.
This commit ensures that when focusing back to a tabbed application, we
use the current main window element instead of the stored element which
may point to a stale tab, and we also update the stored window element
when the user switches tabs, so that borders can update correctly.
The Acessibility API does not reliably fire AXWindowMoved and
AXWindowResized notifications after the mouse button is released,
causing drag-to-swap and drag-to-resize operations to fail.
This sends manual MoveEnd and ResizeEnd events from the input
event listener when LeftMouseUp is detected, ensuring these
operations complete reliably.
Resizing windows while dragging doesn't really work and has been noted
in the known-issues.md file.
When closing a window with CMD+W, the AXUIElementDestroyed notification
has an empty title. We need to add an is_destroyed override for these
AXUIElementDestroyed notifications without a title so that they can be
processed.
This commit also fixes a race condition exposed by the above fix where
the reaper thread sometimes removes the window before the reap function
tries to remove it during event processing. When this happens, we can
just ignore the error and continue instead of propagating it up and
interrupting the event processing loop until the user's next manual
interaction with another window.
Centralized both KomorebiTheme and KomobarTheme in the komorebi-themes
module in komorebi for Windows.
This commit removes the duplicated references in komorebi for Mac and
just pulls in those; now we only have to update the docs in one place.
Regenerated all the schemas after pulling in the changes.