retile already forgot the resize adjustments of the layouts that are
made of splits, and the widths of the columns of the Scrolling layout
are the same kind of thing. The focused workspace of each monitor
gets its columns back to what scrolling-layout-columns gives, and the
focused column stays where it is unless it has to scroll.
The variant of retile that keeps resize dimensions keeps the widths.
A window whose top-left corner is past the left edge of the screen is
on no display, as far as CGGetDisplaysWithPoint is concerned. Looking
the display up from the corner then found nothing, and hide, the
scrolling rest and the slide back in all skipped the window without a
word. The Scrolling layout lets a column overhang the left edge, so a
column that scrolled out of view that way stayed on screen, and so did
a window of a workspace that was left while it overhung.
A workspace now takes the display from its monitor and hands it down
to Container::hide and Window::hide_on, and arrange_scrolling hands
it to hide_scrolling. A window that is parked remembers the display it
was parked on, so sliding it back in no longer looks at its target.
The lookup by position stays for callers that have no monitor, and is
total: the display under the corner when there is one, otherwise the
display with the most overlap, otherwise the nearest, and the main
display when the system reports none. Not finding a display to hide a
window on is logged as a warning, and which rest a window gets is
logged at trace.
Add a page on the Scrolling layout: how column widths work, when the
screen scrolls, what closing a window focuses, how resizing works, where
windows that are out of view go and why, and what is not done yet.
The Scrolling layout no longer shares the screen between however many
windows there are until `columns` of them exist. The count is how many
columns fit across the screen, which is how wide a new column is, so the
help says that, and not that it is the number of visible columns.
Closing a window moved focus to the container on its left, whatever had
focus and wherever the window was. A strip of columns knows better.
Focus goes back to the column that the closed one was opened next to,
with the viewport as it was, if nothing has moved focus since. Otherwise
it goes to the column that takes the closed one's place on the right. A
window that is closed without having focus no longer takes focus with
it.
The strip is told what there is just before the container goes, so that
it can answer. A workspace that has not laid out a strip yet moves focus
left as before.
A window that scrolled out of view in the Scrolling layout used to be sent
to a corner of the screen and hidden there. It now comes to rest at the
edge of the screen that it left by, with a sliver of it on screen, and
keeps its size and its height up the screen. Bringing it back is then a
matter of moving it, and it never has to be resized.
With animations on the window slides there and stays, where it used to
carry on into the corner. With animations off it is moved there at once,
so the layout behaves the same either way. Where the edge is next to
another display, and the window would be seen on it, it is still hidden
in the corner.
The marker that says a window is out of the way is now also cleared when
a window is put back without animating it. Only sliding a window in
cleared it, which was enough only while nothing set the marker unless
animations were on.
The Scrolling layout is now laid out by komorebi-scrolling instead of by
the layouts crate. A workspace in that layout keeps a ScrollingSpace next
to its containers, makes it match the containers and the focus whenever
the layout is calculated, and takes the rectangles from it. As a result:
- a window that opens gets the width of a column and no other column
changes width, where every column used to be resized to share the
viewport until there were as many as `columns`
- focusing a column that is already in view does not scroll the strip
- a column that has been resized keeps its width as windows come and go
- columns that were never resized follow the `columns` option, so
changing it, or crossing a threshold of layout_options_rules, still
lays them out again
Resizing changes the width of the focused column, by half of the delta
per edge as the other layouts do. A strip has no heights, so resizing a
height does nothing.
Windows that are partly in view keep their size and overhang the edge of
the screen, unless that would show them on another display, where they
are clamped to the work area as before.
What needs a Workspace is in the scrolling module, and what does not is
in komorebi_layouts::scrolling, which the model comes through. What only
the old Scrolling layout needed goes: the percentage override in
update(), laying the strip out again without resize adjustments in
hide(), the resize constraints, and the feedback of the unclamped
layout.
komorebi-layouts now carries the platform-free half of the Scrolling
layout: the model of a strip of columns, re-exported as
komorebi_layouts::scrolling::model, and what a host needs around it,
which is the layout options for the model, the placement of containers
in a work area, resizing a column or a tile, and the hand-over of column
records between workspaces.
The center_focused_column layout option of the Scrolling layout is one
of Never, Always and OnOverflow there, and a boolean is still read as
true for Always and false for Never. The two places here that said true
say Always, and the schema and the options for nix say so.
This is the revision of the feature/moar-scrolling branch of komorebi
that has them. It is pinned by revision until the branch is merged, and
komorebi-themes moves with it so that the repository is fetched once.
komorebi-scrolling has no license field, so deny.toml clarifies it as it
does the other crates of that repository.
The command only set the column count when the workspace had no layout
options at all, or already had scrolling options. A workspace with
options for something else (column_ratios, say) and no scrolling options
matched the second arm and was left unchanged, so the command silently
did nothing.
Move the logic to Workspace::set_scrolling_columns, which creates the
scrolling options when they are missing and keeps every other option,
and test all three cases.
The Scrolling layout works out which column is first in view from the
layout it produced last time. Workspace::update stored that layout after
clamping it to the work area, which pulls every off-screen column onto
the left edge, so the previous view always read as starting at column 0.
Once more windows were open than fit on screen, focusing left shifted the
whole strip by a column on every step instead of leaving it where it was.
Keep the layout as the algorithm produced it and feed that back for
Scrolling, both in Workspace::update and in resize_window. The clamp
becomes a function of its own so that the regression test runs the same
code as update().
An app is free to refuse a size, and many do: a window that will not get
narrower than some width stays that wide however it is asked. The animator is
the first to find out, when it looks at a window after a journey, and until now
it only re-sent the size and moved on, so a layout that places the next column
as if the window had the width it was given places it on top of the window that
did not.
The arrival module is new here. It is where whatever finds out that a window is
wider than it was told to be says so, from any thread and without the lock of
the window manager, for a layout to pick up the next time that it runs.
Say what every verification found to it, which keeps the windows that
turned out wider than they were told to be for the layout to pick up, and
forgets those that have taken their size since, so it is said every time and
whatever the answer. That includes the last attempt, where the window is looked
at again after it was last told to take its size, as nothing verifies it after
that and the attempts are given up on.
This is said from where the frame is read, not carried out of the state machine,
which has no business with anything global.
take_unfinished only knew about a journey that was to go on to somewhere else
afterwards and never got there. A window that slides out of view in the
Scrolling layout rests where it slid to and has nowhere to go afterwards, so a
slide that was cut short went unnoticed, and the window was left partly in view.
Count every journey that ends other than by the window being found where it was
sent: one that was grabbed or taken over, given up on because the app stopped
answering or the window was gone, or that never got to where it was sent in the
verifications that follow. A journey that settles is not cut short, and nobody
has to ask for the news to be kept within bounds.
Describe the duration, style and fps options, per-animation settings, and what
to expect from the animator: windows stay in step with each other, apps that are
slow to resize are sent sizes less often, and a window that is grabbed is let
go of.
Windows that scroll out of view were hidden with an instant jump to a corner of
the screen, and animated back in diagonally across it. With animations on, slide
them out sideways to the edge of the screen they left by, at the same height,
and park them in the corner once they are out of sight; and put a parked window
back at that edge before it slides in, so that it comes from where it left.
Windows that would be seen on a neighbouring display on the way fall back to the
instant hide, and a window that is stopped on its way out is hidden again rather
than left in view.
Without animations nothing changes.
hide, restore and the direct position and size writers wrote to a window while
an animation thread kept writing frames to it. Take the window over first, which
stops its animation and waits for what is already on its way to land, so that it
cannot land on top of what the caller writes next.
A window that is hidden while it is on its way somewhere is now restored to
where it was going, rather than to wherever it happened to be at the time.
The moves and resizes the animator makes are reported back to us like any
others. They used to be avoided by removing and re-adding the AX observers
around every animation, which cost four AX calls a window and still let some
through. Recognise them instead: a notification for any window of an app we are
moving, or have moved in the last 300ms, is an echo and is swallowed. With the
mouse down it is only taken for somebody grabbing the window, and the animation
let go of, if the window's origin is nowhere we put it, so that apps which snap
or clamp their size are not mistaken for a drag.
Once an app has had a window animated, the move and resize notifications that
arrive while the mouse is up are also throttled per window, so that an app that
will not stop reporting cannot fill the event channel and cost the window
manager real events such as focus changes.
Borders no longer ask a window where it is while it is being animated, as the
animator moves them. A drag cancels the animation of the window being dragged,
and what is known about a process is forgotten when it terminates, as a new
process may be given the same id.
Every animated window used to get a thread of its own that slept between frames,
so neighbouring windows moved out of step, a retarget had to wait for the old
thread to notice (a 125ms poll), every frame wrote both the position and the
size, and the app-side animation guard was applied to the window element, where
AXEnhancedUserInterface does not live, instead of the application element.
Move windows with the animator instead, and remove the thread-per-window engine
and the render dispatcher. Stacking operations suspend animations with a guard
instead of swapping the global flag, which was left off for good if the
operation failed, and the animator is shut down before the daemon puts every
window back where it found it.
The configuration is untouched: enabled, duration, style and fps, global or per
animation, are read exactly as before, and nothing is added to it. An fps of 0
no longer panics.
Run the state machine on one frame thread that steps every animated window on
the same clock, and hand the writes to a lane per app, which make them side by
side. The frame thread never talks to an app, and a frame is only started once
the last has been applied to every moving window, so that neighbouring windows
stay on the same frame and the gaps between them do not open and close. An app
that takes longer than a frame is not waited for.
Also expose the pieces the window manager needs around it: animation::motion_for
to read the configured duration and style for a kind of animation, and
animation::suspend to skip animations for as long as an operation runs, which
unlike turning the global setting off and on again puts everything back when the
operation fails part of the way through.
Nothing uses it yet.
Borders follow a window through their own AX observer, which asks the window
where it is over AX on the main thread for every notification, so a border lags
a window that is being moved a frame at a time. Add a way to hand a border the
frame a window has just been moved to instead, batched onto the main thread
once per turn with only the latest frame of each window applied.
The border state is held by the border thread while it creates borders, which
it does by waiting for the main thread, so it is only ever tried, never waited
for, from there; frames that find it busy are put back and tried again.
An app that moves its own windows, or is moved faster than it can report, can
send a notification for every frame, and the window manager's event channel is
small. throttle lets one through per window per interval. stats keeps just
enough of how an animation burst went to answer why it felt slow from the log:
how regular the frames were, and how long the apps took to apply them.
Keep the bookkeeping of an animation free of threads, clocks and macOS APIs, so
that it can be tested with a fake clock. step holds the maths, and tracks knows
which windows are in flight, where each is, where it is going, and what has to
be written to it next, in whole-frame steps that are handed back as commits for
a runtime to carry out:
- retargeting a window overwrites its target and carries on from where it is
- only the dimension that changed is written, and an app that is slow to apply
a size is sent them less often, so that it keeps moving in between
- where a window was last put is remembered, so that a window can be animated
without asking it where it is
- a finished window is verified, and re-sent if the app ignored the move
- work that is never reported on is given up on after a few seconds
- the notifications our own writes cause are recognised as echoes, by window
and by process, unless the mouse is down and the window's origin is nowhere
we put it, in which case somebody has grabbed it
AXEnhancedUserInterface makes an app animate every move and resize it is asked
to make over AX. It belongs to the application element, not to a window, and it
is shared by all of an application's windows, so turning it off has to be
reference counted per process, with the last window to finish putting it back.
Almost no app has it on, so an app that has been seen not to is left alone for
a while without being asked again.
Also add a messaging timeout helper, so that an app that has hung cannot hold a
caller for several seconds, and expose the application's own element.
notify_on_error needed a whole Window to decide whether a failed write meant
that the window was gone, but only used its id and its element. The tabbed
application check was also subsumed by the validity check that follows it: a
window whose element still answers is never reaped. Add notify_if_gone, which
takes just the id and the element, for writers that do not have a Window,
and have notify_on_error call it.
Workspace::update asked every window where it was, which is a round trip to
the app that owns it, before deciding what to do with it. The answer only
matters for a window that the layout would put entirely out of view, so ask
only then.
Bring the generated files back in line with the code on master.
- schema.json: add monocle_focus_behaviour and the MonocleFocusBehaviour
definition. schema.asc.json and schema.bar.json were already current.
- nix/komorebi-options.nix: add the monocle_focus_behaviour option.
nix/komorebi-bar-options.nix was already current.
- docs/cli: add the pages for layout-ratios, monocle-focus-behaviour,
permissions and toggle-monocle-focus-behaviour. Update 19 pages for
the --bar flag of enable-autostart, the per-value help of enum
arguments and reworded help text. Re-wrap 4 pages whose text did not
change.
How the files were made:
- schemars-nixgen writes the properties of an object in a different
order on every run, so the files are not regenerated whole. Only the
new option is added; the rest of a full run was checked to be the same
lines in another order.
- docgen on master writes a bare fence with no heading and "Usage: name",
where the pages in docs/cli have a "# name" heading and "Usage:
komorebic name". The pages keep the format they have.
- Pages are wrapped at 100 columns, the width docgen uses when it does
not write to a terminal, instead of the width of the terminal the old
pages were made in.
komorebi focuses one window of an application next to another of its
windows, and the application can be slow to say that window is the one
focused, or not say it at all. The border was decided on what the window
server reported, still the other window, so the focused window had none.
Count the window in the focused container as the one with the focus when
the window the window server reports is another window of the same
application that komorebi manages. The decision is a function with tests,
and the border manager traces what it decided for each container.
An application that comes to the front names its main window, which is
not necessarily the one komorebi focused. When it is another of the
application's windows, komorebi took it as a request to go there:
- parked on another workspace, the workspace reconciliator switched to
that workspace, so a focus command between windows of one application
changed workspace;
- beside the focused window on the workspace that is showing, its
container took the focus back, so the window komorebi had just focused
lost it.
Do neither when the notification is the application coming to the front
and one of its windows is the focused one here. Choosing a window of the
application is said with AXMainWindowChanged and is still followed. The
decisions are functions with tests.
Closing a laptop lid with an external display attached swaps one display
for another, so the monitor count is unchanged and the reconciliator
logged "reconciliation not required" while komorebi kept laying windows
out on the old display's work area. Compare the serial numbers as well as
the count and hand the unplugged monitor's workspaces to the display that
took its place.
The workspaces that are not showing kept the work area of the old display
too, so they were put away on a display that was gone and their windows
stayed in view. Refresh the work area of every workspace before putting
them away, and let a window that cannot be hidden not leave the ones
after it in view.
Resize notifications matched monitors by display id, which changes when a
display is reconnected, so they never updated anything and then re-laid
out the focused workspace once per device. Match by serial number, and
only re-lay out when a known monitor changed.
komorebi for Mac draws each border as an untitled, ordinary-level NSWindow owned by
the komorebi process. The Mac listing kept them but never set `border`, so a
recording gave an agent no way to tell a border from a window. They are now marked,
which lets `lag` compare a border with its window. `border_of` stays unset: a Mac
border does not name its window.