Commit Graph
133 Commits
Author SHA1 Message Date
LGUG2Z f6bfae3103 docs(schema): avoid duplicating display format enums in bar
This commit also addresses some clippy warnings.
2025-12-23 17:07:56 -08:00
LGUG2Z 1e71cb7d92 docs(schema): publish versioned schema docs to lgug2z.com 2025-12-23 12:00:13 -08:00
LGUG2Z 1cb3327395 chore(deps): bump schemars to 1.1 and netdev to 0.40 2025-12-21 10:00:55 -08:00
LGUG2Z 13635817c3 docs(schema): clarify that 'theme' takes priority over 'border_colours' 2025-12-20 22:21:19 -08:00
LGUG2Z 8dfc70e6d2 fix(wm): consume more appkit events and make border manager reconcile focus
This commit ensures that NSWorkspaceDidActivateApplicationNotification
and NSWorkspaceDidDeactivateApplicationNotification get emitted not just
for the loginwindow but for all apps with a valid name.

This helps us to catch events from windows which don't emit
AXWindowCreated consistently like Mail, Calendar, etc.

Additionally, if a window has been closed with cmd+w but the application
is still active, the border manager will pick a window container to mark
as the new focused window container, and call window.focus() on the
selected window to align the focus with the focused border color.
2025-12-15 20:31:24 -08:00
LGUG2Z dcef667811 fix(config): ensure pathext replaces ~ with $home 2025-11-30 11:53:41 -08:00
LGUG2Z 2ff76f0881 fix(wm): disable monocle mode if window is closed
This commit ensures that monocle mode will be automatically disabled if
the last window in a monocle container is closed.
2025-11-29 14:41:25 -08:00
LGUG2Z 6b980a0360 fix(border): close nswindow on main thread
This commit addresses a bug that was introduced/made visible in a5cbb4d.

The nixpkgs flake input (tracking nixpkgs-unstable) was updated from
github:NixOS/nixpkgs/f6b44b2401525650256b977063dbcf830f762369 to
github:NixOS/nixpkgs/0d59e0290eefe0f12512043842d7096c4070f30e and as a
result the version of AppKit being linked against jumped from
2022.44.149 to 2487.50.124.

Builds prior to a5cbb4d were building against macOS 13 (Ventura) era
frameworks due to the use of compatability stubs in nixpkgs, whereas the
nixpkgs-unstable update in a5cbb4d now links against the actual running
system's framework versions (in this case, macOS 15).

With github:NixOS/nixpkgs/f6b44b2401525650256b977063dbcf830f762369:

```
❯ otool -L target/debug/komorebi | grep -E 'AppKit|Foundation|CoreFoundation|libSystem'
        /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1775.118.101)
        /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 2022.44.149)
        /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1775.118.101)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.100.5)
```

With github:NixOS/nixpkgs/0d59e0290eefe0f12512043842d7096c4070f30e

```
❯ otool -L target/debug/komorebi | grep -E 'AppKit|Foundation|CoreFoundation|libSystem'
        /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 2420.0.0)
        /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 2487.50.124)
        /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 2420.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1345.100.2)
```

Somewhere between macOS 13 and macOS 15 Apple added stricter
thread-safety assertions in the AppKit framework, which resulted in the
calls to `NSWindow::close()` in border.rs to crash on an assertion
failure ("transaction must be valid")

```
* thread #9, stop reason = EXC_BREAKPOINT (code=1, subcode=0x19e543cc0)
    frame #0: 0x000000019e543cc0 AppKit`-[NSWMWindowCoordinator performTransactionUsingBlock:] + 752
AppKit`-[NSWMWindowCoordinator performTransactionUsingBlock:]:
->  0x19e543cc0 <+752>: brk    #0x1
    0x19e543cc4 <+756>: adrp   x0, 827
    0x19e543cc8 <+760>: add    x0, x0, #0x4ba ; "assertion failure: transaction must be valid"
    0x19e543ccc <+764>: bl     0x19e6eb58c    ; symbol stub for: _os_crash
Target 0: (komorebi) stopped.
(lldb) bt
* thread #9, stop reason = EXC_BREAKPOINT (code=1, subcode=0x19e543cc0)
  * frame #0: 0x000000019e543cc0 AppKit`-[NSWMWindowCoordinator performTransactionUsingBlock:] + 752
    frame #1: 0x000000019e372a00 AppKit`-[NSWindow(NSWMWindowManagement) window:didUpdateWithChangedProperties:] + 104
    frame #2: 0x000000027a366720 WindowManagement`-[_WMWindow performUpdatesUsingBlock:] + 100
    frame #3: 0x000000027a365714 WindowManagement`-[_WMWindow applyTags😷] + 712
    frame #4: 0x000000027a365cf8 WindowManagement`-[_WMWindow setVisible:] + 84
    frame #5: 0x000000019d91b064 AppKit`-[NSWindow _setVisible:] + 268
    frame #6: 0x000000019da16df0 AppKit`-[NSWindow _doWindowWillBecomeHidden] + 88
    frame #7: 0x000000019e3662e0 AppKit`-[NSWindow _reallyDoOrderWindowOutRelativeTo:] + 160
    frame #8: 0x000000019e366794 AppKit`-[NSWindow _reallyDoOrderWindow:] + 80
    frame #9: 0x000000019e3669e4 AppKit`-[NSWindow _doOrderWindow:] + 264
    frame #10: 0x000000019e360c84 AppKit`-[NSWindow _finishClosingWindow] + 444
    frame #11: 0x000000019daa6cc8 AppKit`-[NSWindow _close] + 380
    frame #12: 0x0000000100c3380c komorebi`_$LT$$LP$$RP$$u20$as$u20$objc2..encode..EncodeArguments$GT$::__invoke::h1be54296556f108b(msg_send_fn=(libobjc.A.dylib`objc_msgSend), receiver=0x0000000132e09ea0, sel=Sel @ 0x0000000170b58e38, (null)=<unavailable>) at encode.rs:433:26
    frame #13: 0x0000000100c30f84 komorebi`objc2::runtime::message_receiver::msg_send_primitive::send::h0de1c4d240a2223f(receiver=0x0000000132e09ea0, sel=Sel @ 0x0000000170b58e78, args=<unavailable>) at message_receiver.rs:172:18
    frame #14: 0x0000000100c2e904 komorebi`objc2::runtime::message_receiver::MessageReceiver::send_message::h86c04ca17a2b6faf(self=0x0000000132e09ea0, sel=Sel @ 0x0000000170b58ed0, args=<unavailable>) at message_receiver.rs:432:38
    frame #15: 0x0000000100b9b1bc komorebi`_$LT$MethodFamily$u20$as$u20$objc2..__macro_helpers..msg_send_retained..MsgSend$LT$Receiver$C$Return$GT$$GT$::send_message::h6cb30a52e558d44c(receiver=0x0000000132e09ea0, sel=Sel @ 0x0000000170b58f48, args=<unavailable>) at msg_send_retained.rs:35:28
    frame #16: 0x0000000100ba14b8 komorebi`objc2_app_kit::generated::__NSWindow::NSWindow::close::h34bc4ef6fc286b23(self=0x0000000132e09ea0) at extern_methods.rs:266:14
    frame #17: 0x00000001002b22f0 komorebi`komorebi::border_manager::border::Border::destroy::_$u7b$$u7b$closure$u7d$$u7d$::h61d54fa62ea0b107((null)=AutoreleasePool @ 0x0000000170b58fb8) at border.rs:161:35
```

To fix this, this commit ensures that the call to `NSWindow::close()` is
made on the main thread using `DispatchQueue::main().exec_sync()`.
2025-11-29 14:09:26 -08:00
LGUG2Z 48a21eba61 fix(wm): explicitly init and process nsapplication events
For reasons unknown, CFRunLoop::run_in_mode no longer processes
NSApplication events on Tahoe.

Display callbacks seem to now be more tightly coupled to the
NSApplication event loop, so we initialize NSApplication with
sharedApplication as early as possible to establish a window server
connection, and then in our main loop we poll app.nextEvent every 0.1s
for NSApplication events, which is where the
DisplayReconfigurationListener callback will finally kick in again.
2025-11-26 09:18:47 -08:00
LGUG2Z 1a7d1a4cf2 fix(wm): promoting a container shouldn't change resize dimensions
This commit was originally contributed as 31c969f to LGUG2Z/komorebi by
@alex-ds13

- When promoting a container it is using the
  `remove_focused_container()` and `insert_container_at_idx` functions
  which will remove the focused container size from `resize_dimensions`
  and then add the new container with size `None`. Then it was adding
  the previously stored size of the main container back to the first
  one. However this would result in at least 3 issues:

    1. We were removing the size from index 0, however when inserting it
       back on the primary_idx we might not add it to index 0, specially
       now that there could be locked containers so if container 0 is
       locked we would be adding it to the next container, which would
       result in the main container having no size information which
       would result in a recalculation on the next update and it would
       revert back to default, so if a user had resized their containers
       that information would be lost.

    2. We were removing the size from index 0. Then on
       `remove_focused_container` it would remove the size from the
       focused container index, but since we had already removed one
       size from the `resize_dimensions` that index would no longer
       match the actual focused container, so once again we would be
       losing information.

    3. Since we were removing the size of the focused container idx from
       `resize_dimensions` (albeit the wrong one as stated above), this
       would mean that the container that moved to that position would
       have no resize information so it would show up as if the main
       container was taking up half width of the area, ignoring any user
       resize, until the next workspace update was triggered.

- This commit completely ignores the `resize_dimensions` since promoting
  a container simply means moving one container from one position to the
  main one (usually index 0) and then shift all the rest to the "right".
  The existing `resize_dimensions` should be kept untouched. To do this
  we use the functions `remove_respecting_locks` and
  `insert_respecting_locks` on the containers themselves, which simply
  move the container and shifts the others which is precisely what we
  want.
2025-11-22 12:59:38 -08:00
LGUG2Z 66b8f838bd chore(deps): handle egui-related upgrades 2025-11-12 16:29:06 -08:00
LGUG2Z db8cf858ff build(nix): pull git rev info from flake inputs
This commit adds a new workspace crate, version, which is consumed by
komorebi and komorebic.

If either of those binaries are being built by
the Nix Flake, the git rev info will be pulled from inputs.self.rev
instead of querying the git repo, because the git files are not passed
to the derivation.

The build.rs for the version crate decides if the build is happening by
querying the shadow-rs build output for BRANCH, which will always be
empty when a "nix build" is running.

Cargo builds will use the standard git information retrieval mechanisms
in shadow-rs.

The information in both cases is exposed as version::LONG_VERSION, and
passed to clap as the string to return when either binary is called with
the --version flag.
2025-11-06 16:57:17 -08:00
LGUG2Z 6454393cb2 feat(wm): make promote-swap reversible
This commit makes the komorebic promote-swap command reversible by
storing the previous container index in the Workspace state.

If the current container index is the same as the layout's primary
index, and there is a previous promotion swap container index available,
the two containers at those indices will be swapped, effectively making
a second call to promote-swap an undo.
2025-11-04 13:14:32 -08:00
LGUG2Z b09e979af5 feat(wm): promote containers by swapping indices
This commit adds a new SocketMessage variant PromoteSwap and
corresponding komorebic promote-swap command.

PromoteSwap will also promote the focused window container to the
largest tile in the layout, but instead of removing the focused
container x from the Ring and inserting it into position 0, possibly
changing the positions of other windows between 0 and x, the indices x
and 0 in the Ring will be swapped directly.
2025-11-04 07:53:29 -08:00
LGUG2Z 4c0f34d7ef fix(wm): simplify stack-all command
Implements the equivalent of
https://github.com/LGUG2Z/komorebi/commit/18ee6678962bc31a39ce59fd4a1f6a9ee752ac5c

This commit makes the `stack-all` command simpler, by simply making a
`VecDeque` with all the tiled windows of the workspace, then it creates
a new container with that `VecDeque` and changes the workspace
containers to be just this new container which has all the windows in
it.

Then and only then do we focus and show the previously focused window
and hide all the rest.

This way we don't have a bunch of `FocusChange`/`Cloak`/`Uncloak` events
coming up which might conflict with each other when the user has
transparency and animations enabled.

With this commit, there will only be one focus event for the focused
window and one cloak event for each of the other windows.
2025-11-02 11:03:16 -08:00
LGUG2Z 34db2e2c90 feat(wm): add visual feedback for preselections
This commit adds visual feedback in the form of a ghost tile for
preselections made by the preselect-direction command.

A container with the id "PRESELECT" will be added to the workspace, and
replaced when the next manage-able window is spawned.

A new command, cancel-preselect has been added to remove both the
preselection index and the ghost tile if the user changes their mind.
2025-11-02 11:03:11 -08:00
LGUG2Z fe8dbca204 fix(wm): expand hack from 4d25d4e for chrome
This commit expands the hack introduced in 4d25d4e which deals with
inconsistent window titles returned by apps from different macOS APIs.
The same issue that was happening with Activity Monitor was also
happening with Google Chrome, so this hack has been updated to a more
general "contains" check.
2025-10-31 19:17:46 -07:00
LGUG2Z 3128968634 feat(wm): add direction preselection
This commit adds a new feature to preselect the direction of the next
spawned window with a corresponding komorebic preselect-direction
command which takes an OperationDirection.

If the OperationDirection is valid from the current position, it will be
stored in the Workspace state, and then read, applied, and deleted when
the next manage-able window is spawned.
2025-10-31 15:12:19 -07:00
LGUG2Z 29d9f9ecaa fix(wm): add ws reconciliator cooldown period
I was running komorebi on a MacBook Pro today and ended up quite quickly
being able to reproduce the ws switching loops that I thought I had
fixed (well, I still can't reproduce them on my Mac Mini).

This commit adds an additional cooldown period of 1s to
workspace_reconciliator::send_notification, which seems to do the trick
for me on the MacBook Pro.
2025-10-31 13:47:23 -07:00
LGUG2Z 270e0847c2 fix(wm): account for partially-shown scrolling windows
This commit makes some small tweaks to account for the hiding and
showing of partially visible windows on the Scrolling layout.

This can happen when resize dimensions have been applied which leaves
only a certain percentage of the window within the work area.

If a window is only partially within the work area, the call to hide
will silently fail.

In order to deal with this there is some jank added when hiding
workspaces and updating workspaces to see if we are leaving a Scrolling
workspace with a partially-visible window, and if we are, to reposition
that window to be fully on within the work area before hiding it.
2025-10-30 13:47:49 -07:00
LGUG2Z 2eea8b79a4 feat(wm): improve scrolling layout window hiding
This commit makes a small improvement to the Scrolling layout by hiding
windows to which layouts which are not contained within the horizontal
bounds of the work area would otherwise be applied.

This should also allow this layout to now be useable on configurations
using multiple monitors.
2025-10-30 07:23:50 -07:00
LGUG2Z 9711a00cd0 feat(cli): add feedback to the license cmd 2025-10-29 08:41:47 -07:00
LGUG2Z 9dbae50909 feat(wm): add a splash screen for mdm devices
A little nudge for people to do the right thing, 1990s vibes.
2025-10-28 18:25:05 -07:00
LGUG2Z 2ecc2819ec feat(wm): order borders relative to tracking windows 2025-10-27 09:22:46 -07:00
LGUG2Z e16a885a5e feat(config): add border radius option
This commit adds a border_radius configuratino option which defaults to
10, which matches the uniform radius on Sequoia. Tahoe is a mess, but
people can at least specify their own preferred border radius value now.
Eventually we should look up the radius of each individual window when
creating the borders like JankyBorders does (I think?)
2025-10-27 09:06:20 -07:00
LGUG2Z 4d25d4efb0 fix(wm): add hack to manage activity monitor on start
I was running into this a lot when debugging the WindowServer memory
ballooning issue fixed in the last commit - the title returned by
CGWindowListCopyWindowInfo and the title returned by kAXWindowsAttribute
for Activity Monitor differs, so when restarting komorebi, if Activity
Monitor is open, it wouldn't get managed.

Added a little hack as a workaround for now.
2025-10-26 19:51:29 -07:00
LGUG2Z 2e4660dc12 fix(wm): ensure border resource cleanups
This commit wraps the various lifecycle methods for border creation,
update and destruction in autoreleasepools to ensure that WindowServer
memory doesn't balloon.
2025-10-26 19:37:40 -07:00
LGUG2Z a2831d2b7f ci(github): run checks and build with nix 2025-10-20 16:09:19 -07:00
LGUG2Z 1abdf0a032 chore(deps): bump block2, netdev and which 2025-10-19 11:44:41 -07:00
LGUG2Z f848c1d8f0 feat(wm): add opt to constrain grid layout by rows
This commit adds a new LayoutOptions option, GridLayoutOptions,
currently with a single configurable "rows" opt which can be use to
constrain the grid by number of rows.
2025-10-17 16:29:58 -07:00
LGUG2Z c255772897 fix(wm): add generic window validity check to reaper
Calibre was being very weird and failing layout updates when a menu
button was clicked (#justcalibrethings) so I've added a final window
validity escape hatch check to the reaper for now.
2025-10-16 10:09:32 -07:00
LGUG2Z 791208a130 feat(wm): add opt to keep focused column centered on scrolling layout
This commit adds a new option under layout_options.scrolling -
"center_focused_column", which defaults to false. When

set to true, and when the number of scrolling columns is an odd number
>=3, komorebi will, if there are enough windows being managed on the
workspace, and if the focused window is not too close to either the
beginning or the end of the workspace ring, keep the focused window in a
centered position in the layout
2025-10-11 14:03:40 -07:00
LGUG2Z 5c663d2cea test(wm): migrate window manager test cases 2025-10-11 11:02:26 -07:00
LGUG2Z 7b65a24ea4 test(wm): migrate process command test cases 2025-10-11 10:52:53 -07:00
LGUG2Z ca9a624018 test(wm): migrate monitor test cases 2025-10-11 10:46:07 -07:00
LGUG2Z d08e0b0cd9 test(wm): migrate workspace test cases 2025-10-11 10:46:07 -07:00
LGUG2Z c819907a4d test(wm): migrate container test cases 2025-10-11 10:46:04 -07:00
LGUG2Z aa718bf6e9 fix(wm): delegate all cmd+tab focus changes to ws reconciliator
Mainly a cleanup PR - there were some subtle bugs introduced trying to
exclude the ManualNotification for cmd+tab focus changes, but since this
is all being delegated to the workspace reconciliator now, we can remove
those confusing matches! guards and that variant all together.
2025-10-10 09:56:09 -07:00
LGUG2Z 141eedfd60 fix(wm): preserve state on screen lock and unlock
Screen locking and unlocking is a bit weird in macOS because it's
implemented as a separate app which is activated and deactivated, so
unique events for screen lock and unlock are never emitted by the
system.

This commit encapsulates the logic to detect the relevant events on the
loginwindow into the creation of ScreenLock and ScreenUnlock
WindowManagerEvent variants.
2025-10-09 19:19:51 -07:00
LGUG2Z acee420bd3 feat(wm): implement ws reconciliator with source debouncing
Hello infinite workspace switching loop, my old friend.

Reimplemented the old workspace reconciliator from komorebi for Windows
with additional source debouncing and tested by furiously mashing alt-1
and alt+2 for 20s. No loop!
2025-10-09 16:54:14 -07:00
LGUG2Z 7bbad6539d fix(wm): ensure messages window close by click is handled
Stupid Apple stuff. Something was up with Messages leaving a ghost tile
when being closed by the red dot vs. cmd+w - this change fixes that, but
will probably break something else.
2025-10-07 18:41:46 -07:00
LGUG2Z ed2185a667 feat(config): add window hiding position behaviour
This commit adds a new monitor configuration option
"window_hiding_position", which takes an enum with the variants
BottomLeft and BottomRight.

Until now the behaviour had been hard-coded to hide windows at the
bottom left of every monitor.

If no value is given on a monitor configuration object, this option will
default to BottomLeft.
2025-10-07 16:46:40 -07:00
LGUG2Z 05e4222a23 refactor(rust): remove lots of unsafe blocks 2025-10-06 16:50:10 -07:00
LGUG2Z b02711e86d fix(wm): improve video fullscreen handling
This commit improves browser video fullscreen handling with borders. We
are now emitting an event for
AppKitWorkspaceNotification::NSWorkspaceActiveSpaceDidChangeNotification,
even though it doesn't have a pid, by passing a dummy 0 pid.

This is really stupid and I shouldn't do this.

This lets us act with more granularity in process_event to destroy or
redraw borders when entering or exiting browser video fullscreen.

In addition, the reaper has been updated to not reap fullscreen windows
so that they can be reintegrated into the layout without issue when
fullscreen is exited.
2025-10-06 15:00:40 -07:00
LGUG2Z 75373c2174 fix(bar): load app icons for focused window widget
This commit adds the icon path to WindowDetails and then uses that path
to look up and load the icon in komorebi-bar.
2025-10-01 11:19:43 -07:00
LGUG2Z c9eeaf3999 chore(deps): bump egui and eframe to 0.32 2025-09-30 18:50:22 -07:00
LGUG2Z c3a756cbde fix(bar): don't look up window titles at runtime
Doing runtime lookups via methods on Window in komorebi-bar won't work
because the AccessibilityObserver is not serialized and sent as part of
the notifications.

Instead, the notifications now take a snapshot of WindowDetails and
embed them so they can be read directly in komorebi-bar.
2025-09-30 15:54:15 -07:00
LGUG2Z 9777c55a1f feat(bar): migrate the komorebi-bar
This commit migrates the komorebi-bar from komorebi for Windows. Mostly
lifting and shifting code, exposing stuff we need in komorebi-client
etc.

A few widgets will need to be reworked completely so they have been
removed for now.

Mouse and command stuff also needs updating a little so that has also
been removed for now.
2025-09-30 15:14:30 -07:00
LGUG2Z 230acf3547 fix(client): wrap axobservers in an option to avoid deser crashes
This commit fixes a crash for subscribers who try to deserialize state
from notifications. Even though skip_deserializing is used on the
AccessibilityObserver, we still need a sane Default, so we wrap the
inner AXObserver in an Option and default to None.
2025-09-30 13:03:40 -07:00
LGUG2Z 801be91508 feat(wm): implement monitor/ws wallpapers
This commit implements per-monitor and per-workspace wallpapers and
integrates with the theme manager to optionally generate themes based on
the palette of the wallpaper image.

Mostly a lift-and-shift from komorebi for Windows.
2025-09-30 11:02:38 -07:00