This commit introduces a little hack to emit a WindowManagerEvent::Show
every time the input event listener callback is triggered.
This is needed because some apps like Ghostty and Safari do not trigger
any events when a tab is split out into an independent window.
To keep things a little cleaner, a new SystemNotification::Manual
variant has been added which takes a ManualNotification variant.
The idea is to be able to use one of these whenever we manually emit a
notification to the window manager event listener to hopefully save my
sanity when we have to debug something in the future.
This commit implements some fixes (still not ideal) to handle the
closing of the 1st tab of an application which uses native tabs.
When the 1st tab is destroyed, the window AXUIElement gets rendered
invalid, so we have to reap that window, and then emit our own Show
event for the tab that is becoming the new 1st tab and set that as the
window.
There is an edge case now where if this happens while the window is
floating, our emitted show event will result in that window being
integrated into the layout rather than staying tiling, but I think this
is better than having a completely janky workspace and possibly having
to restart komorebi.
This commit adds a global list of user-define-able applications which
use native tabs (I'll expose a config option for later). This is used to
improve handling of tabs.
I have tested with Ghostty and Finder. It's possible to add tabs with
cmd+t, close them with cmd+w, and also to drag them into their own
windows.
It's also possible to cmd+n to create a new window instance in Finder,
but when doing this with Ghostty, it doesn't emit an event (I think this
is a bug in Ghostty, since it works fine with Finder).
This commit adds logs written to files in the app's datadir, which can
then be tailed by the komorebic log command. temp_dir() was being weird
so I just stuck with DATA_DIR.
This commit adds window ID tracking like we do in komorebi for Windows
and fixes a bunch of bugs that were happening when a window on another
workspace was focused either via the Dock or cmd+tab, and also a bug in
workspace rules where on launch, a window would not respect workspace
rules due to another workaround that had been added to make Apple apps
work nicely.
This commit does some wrangling of the ioreg output to enrich monitors
with product names and serial number IDs, the latter of which is very
important to maintain compatibility with komorebi for Windows.
I can't get the equivalent of device and device_id on macOS, but these
are legacy things in komorebi for Windows so I think I'll leave them
out.
To verify monitor information, SocketMessage::MonitorInformation has
been implemented.
This commit implements the State, GlobalState and VisibleWindows
SocketMessage variants. These are the first of the SocketMessage
variants send by komorebic which receive a reply which is printed out to
the console.
I think the next thing to do will probably be to get the extended
display info so that the MonitorInformation variant can be handled too.
This commit migrates everything needed to get to the point where I can
load my existing Windows komorebi.json file and have the key parts
working as expected (workspace rules, manage rules, ignore rules,
floating applications etc.)
A lot of lift and shift, some wrangling things to work with the subtle
changes in this codebase, but overall I'm very happy with this.
This commit adds a reaper module which gets notified whenever an
AXUIElement is invalid (so far this is notified when a set_position call
on a Window fails), and an input event listener which somewhat coarsely
emits an event whenever a mouse-up or key-up is registered.
This is to handle Apple applications like Notes and Mail which don't
fire any events at all when a window is closed.
Pretty gross. Will see if this can be improved in the future.
Got some weird behaviour when calculating the work area offset when
resuming from sleep so I bit the bullet and added an AtomicBool flag
that gets set when we need to call into NSScreen to get the correct work
area and size after a display resizes.
The flag gets checked in the same loop on the main thread which is
checking for ctrl-c signals.
This commit adds a display reconfiguration listener which emits
notifications to a monitor reconciliator module which operates on a
background thread.
So far I'm only handling the resize notification because I have to
change the scaling when I'm recording devlogs and I don't want to have
to restart komorebi every time I do that.
This commit adds a listener for the NotificationCenter of the
SharedWorkspace, which allows us to be notified of acts like new app
creation, app termination (different from app window destruction),
application hides and application unhides, among many others.
There are a lot of the AppKit notifications which can be registered with
observers on the notification center; for now I have just modeled the
AppKitWorkspaceNotification enum which seems to hold the most
interesting notifications for our use case.
NSWorkspaceDidLaunchApplicationNotification and
NSWorkspaceDidTerminateApplicationNotification are now hooked in to the
Show and Destroy WindowManagerEvents, but I still need to think about
how to hook in the events around hiding and unhiding as these are
temporary/reversible actions which operate across multiple application
windows, unlike minimize/restore which only operate on one application
window at a time.
This commit standardizes the codebase to disallow usage of the raw eyre!
macro for creating errors, instead using ok_or_eyre() when constructing
ad-hoc errors from Result and Option types, and otherwise using the
bail! macro in response to failed boolean conditions.
Instead of erroring out when a window position can't be set due to the
AXUIElement no longer existing, log a warning and let the invalid
application window reaper clean it up.
OBS Studio is not observable when starting komorebi, so this changes
Application.observe to set a new field is_observable to false if
registering the observer fails instead of erroring out.
This allows the wm initialization to continue instead of crashing.
This commit implements the CycleFocusWindow, CycleMoveWindow, StackAll,
UnstackAll, FocusStackWindow and CycleStackIndex SocketMessage variants.
Largely a code migration from komorebi.
This commit implements the MoveContainerToLastWorkspace,
SendContainerToLastWorkspace, MoveContainerToMonitorNumber,
CycleMoveContainerToMonitor, MoveContainerToWorkspaceNumber,
MoveContainerToNamedWorkspace, CycleMoveContainerToWorkspace,
SendContainerToMonitorNumber, CycleSendContainerToMonitor,
SendContainerToWorkspaceNumber, CycleSendContainerToWorkspace,
SendContainerToMonitorWorkspaceNumber,
MoveContainerToMonitorWorkspaceNumber, SendContainerToNamedWorkspace,
CycleMoveWorkspaceToMonitor, MoveWorkspaceToMonitorNumber, and
SwapWorkspacesToMonitorNumber SocketMessage variants.
This is primarily a lift-and-shift from komorebi.
I still have no idea if the monitor-related stuff works as expected.
I need to figure out how to construct a light Window from a window_id to
be able to call move_to_area() when moving a container to another
monitor.
This commit implements the CycleFocusMonitor, CycleFocusWorkspace,
CycleFocusEmptyWorkspace, FocusMonitorNumber, FocusMonitorAtCursor,
FocusLastWorkspace, CloseWorkspace, FocusWorkspaceNumbers,
FocusMonitorWorkspaceNumber and FocusNamedWorkspace SocketMessage
variants.
Largely a lift-and-shift from komorebi.
Had to implement some utility functions in MacosApi to retrieve a
monitor ID from the current cursor position.
None of the monitor-related system code has been tested on macOS since I
only have a single monitor to work with right now.
This commit implements the ToggleWorkspaceWindowContainerBehaviour,
ToggleWorkspaceFloatOverride, ToggleLock, ToggleFloat, ToggleMonocle,
ToggleWindowContainerBehaviour, ToggleFloatOverride,
ToggleCrossMonitorMoveBehaviour, ToggleTiling and
ToggleWindowBasedWorkAreaOffset SocketMessage variants.
Again mostly a lift-and-shift from komorebi.
ToggleMaximizeWindow can be implemented later once I figure out how
maximized windows are handled in macOS.
Another lift and shift from komorebi to add support for the CycleLayout
and FlipLayout SocketMessage variants. Trying to get through all of the
main workspace-related interactive commands.
This commit migrates the code from komorebi required to implement the
ResizeWindowEdge, ResizeWindowAxis, Retile and
RetileWithResizeDimensions SocketMessage variants, as well as the
related komorebic commands to emit those SocketMessages.
This commit implements some of the basic plumbing needed to handle
SocketMessage::ToggleWorkspaceLayer and SocketMessage::ToggleFloat.
I've commented out a bunch of the raise/lower functions for now because
I haven't had time to learn about how changing z-ordering on macOS works
yet.
Even so, this is fairly functional, and it's possible to move floating
windows across workspaces, toggle the workspace layer, move floating
windows by the resize delta, and change focus between floating windows.
I ended up moving the window restore positions to a global map because
storing/updating this kind of state on the Window properly will be a
pain because hide/restore now require mut self refs and that leads to
needing to clone sometimes.
I can't use monocle mode without this feature. Migrated all the relevant
code over from komorebi. Values are hardcoded to now for my preferences.
After I bring over the rest of the Workspace stuff I should look at
bringing in the static config.
This commit migrates the code around Monocle containers from komorebi
and implements everything needed to handle SocketMessage::ToggleMonocle
in the wm and send the SocketMessage from komorebic.
I think I should spend time implementing as many Workspace features as I
can before I turn my attention to anything else, because hunting for
where to re-introduce the monocle code I had previously omitted to get
everything compiling was quite tedious and I'm sure I've probably missed
things.
This commit migrates the code needed from komorebi to implement basic
workspace support.
The FocusWorkspaceNumber, MoveContainerToWorkspaceNumber and
SendContainerToWorkspaceNumber SocketMessage variants have been
implemented in process_command, and the commands to emit those
SocketMessage variants have been added to komorebic.
I took a stab at improving the code for hiding the windows by moving
them as off-screen as possible by taking inspiration of Aerospace's
approach of trying to leave only 1px of them visible.
Right now this always looks to put the hidden windows off-screen on the
left side of the screen.
This commit adds support for the StackWindow, UnstackWindow and
CycleStack SocketCommands. The code is largely just migrated from
komorebi.
It looks like there isn't a public API which can be used to hide
individual windows, either via AXUIElement or something constructed
using the window id.
For now I'm just moving the stacked window off the screen and this works
well enough. I also added some cleanup which ensures that when the
process exits, windows which are off-screen will be restored to their
last known position.
This commit adds a WindowManagerEvent enum and a channel to send and
receive variants of it on.
The skeleton of process_event has been migrated from komorebi and a few
basic implementations of handlers for core events like FocusChange,
Show, Destroy, Minimize and Restore have been added.
Due to the way the window observers work, in komorebi for Mac we'll need
to keep track of minimized Windows so that we don't drop their observers
(otherwise we won't receive a notification when they are restored).
Most of the code added in this commit around modifying state in response
to these events has been migrated from komorebi.
This commit migrates another bunch of code from komorebi to start
implementing inter-process communication using Unix domain sockets.
For this commit a small subsection of the SocketMessage with maximum
utility has been migrated: FocusWindow, MoveWindow, ChangeLayout, and
TogglePause.
This includes migrating their handlers in process_command, and setting
up a UnixListener when creating a WindowManager instance.
To be able to test this functionality I also implemented a basic
skeleton of komorebic and migrated the komorebi-client library.
There are some random fixes included here now that we are listening to a
UnixListener on a separate thread, which includes wrapping structs from
the objc2 crate which don't have Send and Sync implemented, so that they
can be implemented in the komorebi lib.
I also took the time to figure out how to calculate a monitor's work
area size, excluding the dock and the menu bar, and started to split out
Workspace and Monitor into their own modules.
It looks like a lot of changes but most if this is just pulling in stuff
from the Windows implementation.
This commit migrates big chunks of code from komorebi for Windows which
deal with state related to the Workspace struct, Layouts and the
Arrangement trait.
Layout remains an enum, but only the Layout::Default variant with
DefaultLayout has been migrated because there are no plans to support
EOL features in komorebi for Mac (custom layouts).
The code for updating the layout in main.rs has been moved to
Workspace.update, which is now called from main.rs instead.
As part of this initial migration of code, this project has been
restructured a little to match the layout of komorebi for Windows to
minimize my own confusion.