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.
This commit ensures that the various default values that the different
Option<T> config properties can be unwrapped to are encoded by schemars
so that they can be picked up by docgen and nixgen.
This commit removes some Windows-only schema opts from StaticConfig and
updates the justfile to start generating content for the new Starlight
documentation site.
This commit adds a nix-darwin module for komorebi and komorebi-bar,
exposed via `darwinModules.default` and `darwinModules.komorebi`.
The module provides the following options:
* `services.komorebi.enable`: enables the komorebi launchd agent
* `services.komorebi.config`: typed Nix configuration (defaults to example
config)
* `services.komorebi.configFile`: path to a JSON config file (validated
against schema)
* `services.komorebi.logLevel`: log verbosity level
* `services.komorebi.applicationSpecificConfiguration`: fetches
app-specific configs from remote GitHub repositories at pinned
revisions
* `services.komorebi-bar.enable`: enables komorebi-bar launchd agent(s)
* `services.komorebi-bar.bars.<name>`: named bar instances, one per
monitor
* `services.komorebi-bar.bars.<name>.config`: typed Nix configuration per
bar
* `services.komorebi-bar.bars.<name>.configFile`: path to a JSON config
file per bar
The applicationSpecificConfiguration option supports multiple sources,
allowing users to combine the upstream default from
LGUG2Z/komorebi-application-specific-configuration with their own
personal overrides from other repositories.
When configFile is specified, the JSON file is validated against the
flake's version of the schema before being passed to the binary.
A new flake check, `darwin-module-validation`, validates the module
options and exercises the configFile validation against the example
JSON files loaded into `komorebic` for the `quickstart` cmd.
This commit adds NixOS module option generation for komorebi and
komorebi-bar configurations, along with a nix and JSONSchema validation
test harness that runs as part of `nix flake check`.
`schemars-nixgen` (same as `schemars-docgen`, not sure if I'm gonna
release this...) generates strongly-typed Nix option definitions from
the generated JSONSchema files, allowing users to write type-checked Nix
configurations that map directly to the config files.
This will eventually be plugged into a nix-darwin module which I have
yet to start writing.
This commit improves the scrolling layout animation by dynamically
choosing the window hiding position based on which side of the viewport
the window is scrolling out of.
Previously, all hidden windows went to the same corner (based on the
global window_hiding_position setting), causing jarring animations when
windows scrolled back into view from the opposite side of the screen.
Now windows scrolling off the left edge hide to the bottom-left, and
windows scrolling off the right edge hide to the bottom-right. This
ensures windows animate back in from the side they scrolled out to.
This commit prevents the event channel from being flooded with
AXWindowMoved and AXWindowResized notifications during window
animations.
Previously, every frame of an animation would trigger macOS
accessibility notifications, which were then converted to MoveEnd and
ResizeEnd events. With a 60 FPS animation, this meant ~15 events per
window per animation, quickly filling the bounded channel (capacity 20)
and causing "channel is full; dropping notification" warnings.
The fix removes kAXWindowMovedNotification and kAXWindowResizedNotification
from the window's observer in pre_render() before the animation starts,
then restores them in post_render() after the animation completes. This
stops notifications at the source rather than filtering them later.
This commit optimizes the objc2 dependency tree by disabling default
features and enabling only the minimal set of features actually used
by the codebase. This reduces compilation time and dependency bloat.
I was meant to do this earlier but during the initial implementation it was
easier to just pull in everything. Now that we are getting ready for a public
release it's time to improve on this.
I ended up:
* Removing unused direct dependencies:
- objc2-core-services
- objc2-core-video
* Setting `default-features = false` on all objc2 crates and added only
the specific features required for the types and methods used
* Updating objc2, objc2-app-kit, objc2-foundation,
objc2-application-services, objc2-core-foundation, objc2-core-graphics,
and objc2-quartz-core with minimal feature sets
After all those changes, the following transitive dependencies are no longer
pulled in: objc2-metal, objc2-core-image, objc2-core-data, objc2-cloud-kit,
objc2-core-text, and loads of unused Foundation/AppKit class bindings.
Some before and after numbers:
| Metric | Before | After | Change |
|---------------------------------|---------|---------|----------|
| objc2 dep lines (komorebi) | 84 | 50 | -40.5% |
| objc2 dep lines (komorebi-bar) | 91 | 59 | -35.2% |
| Dependency tree (komorebi) | 973 | 917 | -5.8% |
| Dependency tree (komorebi-bar) | 1181 | 1131 | -4.2% |
| Clean build time | 3m 05s | 2m 21s | -23.8% |
The almost 24% reduction in clean build time is a big win!
This commit adds window movement animations to komorebi for macOS,
maintaining configuration API compatibility with komorebi for Windows.
The animation system is adapted from the Windows implementation but uses
macOS-specific APIs for screen update batching and accessibility
control, and borrows heavily from the implementation details of
animations in rift.
In order to have decent performance, there are some calls to private
APIS. For this reason, the animation feature will be marked as "UNSAFE".
UNSAFE features should be expected to break between major operating
system updates, and depending on which way I want to go, may only
support one major macOS version at a time (i.e. they will not have a
backwards compatibility guarantee with previous versions of macOS).
This currently look awful when used with the Scrolling layout, but looks
relatively good with other layouts. As with Windows, the animations
when two windows of very different sizes change position aren't great.
Some high level notes on the implementation:
* Uses the private SkyLight framework for screen update batching via
SLSDisableUpdate/SLSReenableUpdate - these APIs prevent visual flicker
by compositing all window position changes at once rather than updating
each window individually during layout operations
* AnimationEngine runs animations in background threads with frame-based
timing, supporting cancellation when new animations are triggered for
the same window
* MovementRenderDispatcher implements the RenderDispatcher trait to
interpolate window positions using configurable easing functions
* All 30+ easing styles from the Windows implementation are supported,
including standard CSS-style functions and CubicBezier for custom curves
* Enhanced User Interface (AXEnhancedUserInterface) is temporarily
disabled during window positioning operations for better performance
* The Transparency animation prefix is not supported on macOS as there
is no equivalent to the Win32 transparency feature
This feature is off-by-default and can be enabled in the static config
or via komorebic commands (animation, animation-duration, animation-fps,
animation-style).
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.
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()`.
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.
This commit was originally contributed as faed6ec by LGUG2Z/komorebi by
@CtByte
This commit changes the way how the default interface and network
activity is loaded by spawning a new thread on each request. This way
the main thread is not blocked by this process.
There has been instances where getting the default interface blocked the
egui ui thread, resulting in a frozen bar.
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.