mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-21 02:01:55 +07:00
933ffcb229
Historic commit description log: The MRU actions `focus-window-mru-previous` and `focus-window-mru-next` are used to navigate windows in most-recently-used or least-recently-used order. Whenever a window is focused, it records a timestamp that be used to sort windows in MRU order. This timestamp is not updated immediately, but only after a small delay (lock-in period) to ensure that the focus wasn't transfered to another window in the meantime. This strategy avoids upsetting the MRU order with focus events generated by intermediate windows when moving between two non contiguous windows. The lock-in delay can be configured using the `focus-lockin-ms` configuration argument. Calling either of the `focus-window-mru` actions starts an MRU window traversal sequence if one isn't already in progress. When a sequence is in progress, focus timestamps are no longer updated. A traversal sequence ends when: - either the `Mod` key is released, the focus then stays on the chosen window and its timestamp is immediately refreshed, - or if the `Escape` key is pressed, the focus returns to the window that initially had the focus when the sequence was started. Rename WindowMRU fields Improve window close handling during MRU traversal When the focused window is closed during an MRU traversal, it moves to the previous window in MRU order instead of the default behavior. Removed dbg! calls Merge remote-tracking branch 'upstream/main' into window-mru Hardcode Alt-Tab/Alt-shift-Tab for MRU window nav - Add a `PRESET_BINDINGS` containing MRU navigation actions. `PRESET_BINDINGS` are overridden by user configuration so these remain available if the user needs them for another purpose - Releasing the `Alt` key ends any in-progress MRU window traversal Remove `focus-window-mru` actions from config These actions are configured in presets but no longer available for the bindings section of the configuration Cancel MRU traversal with Alt-Esc Had been forgotten in prior commit and was using `Mod` instead of `Alt` Rephrase some comments Fix Alt-Esc not cancelling window-mru Merge remote-tracking branch 'upstream/main' into window-mru Lock-in focus immediately on user interaction As per suggestion by @bbb651, focus is locked-in immediately if a window is interacted with, ie. receives key events or pointer clicks. This change is also an opportunity to make the lockin timer less aggresive. Merge remote-tracking branch 'upstream/main' into window-mru Simplify WindowMRU::new Now that there is a more general Niri::lockin_focus method, leverage it in WindowMRU. Replace Duration with Instant in WindowMRU timestamp Merge remote-tracking branch 'upstream/main' into window-mru Address PR comments - partial - Swapped meaning of next and previous for MRU traversal - Fixed comment that still referred to `Mod` as leader key for MRU traversal instead of `Alt` - Fixed doc comments that were missing a period - Stop using BinaryHeap in `WindowMRU::new()` - Replaced `WindowMRU::mru_with()` method with a simpler `advance()` - Simplified `Alt` key release handling code in `State::on_keyboard()` Simplify early-mru-commit logic No longer perform the mru-commit/lockin_focus in the next event loop callback. Instead it is handled directly when it is determined that an event (pointer or kbd) is forwarded to the active window. Handle PR comments - `focus_lockin` variables and configuration item renamed to `mru_commit`. - added the Esc key to `suppressed_keys` if it was used to cancel an MRU traversal. - removed `WindowMRU::mru_next` and `WindowMRU::mru_previous` methods as they didn't really provide more than the generic `WindowMRU::advance` method. - removed obsolete `Niri::event_forwarded_to_focused_client` boolean - added calls to `mru_commit()` (formerly `focus_lockin`) in: - `State::on_pointer_axis()` - `State::on_tablet_tool_axis()` - `State::on_tablet_tool_tip()` - `State::on_tablet_tool_proximity()` - `State::on_tablet_tool_button()` - `State::on_gesture_swipe_begin()` - `State::on_gesture_pinch_begin()` - `State::on_gesture_hold_begin()` - `State::on_touch_down()` Merge remote-tracking branch 'upstream/main' into window-mru Merge remote-tracking branch 'upstream/main' into window-mru Add MRU window navigation actions The MRU actions `focus-window-mru-previous` and `focus-window-mru-next` are used to navigate windows in most-recently-used or least-recently-used order. Whenever a window is focused, it records a timestamp that be used to sort windows in MRU order. This timestamp is not updated immediately, but only after a small delay (lock-in period) to ensure that the focus wasn't transfered to another window in the meantime. This strategy avoids upsetting the MRU order with focus events generated by intermediate windows when moving between two non contiguous windows. The lock-in delay can be configured using the `focus-lockin-ms` configuration argument. Calling either of the `focus-window-mru` actions starts an MRU window traversal sequence if one isn't already in progress. When a sequence is in progress, focus timestamps are no longer updated. A traversal sequence ends when: - either the `Mod` key is released, the focus then stays on the chosen window and its timestamp is immediately refreshed, - or if the `Escape` key is pressed, the focus returns to the window that initially had the focus when the sequence was started. Rename WindowMRU fields Improve window close handling during MRU traversal When the focused window is closed during an MRU traversal, it moves to the previous window in MRU order instead of the default behavior. Removed dbg! calls Merge remote-tracking branch 'upstream/main' into window-mru Hardcode Alt-Tab/Alt-shift-Tab for MRU window nav - Add a `PRESET_BINDINGS` containing MRU navigation actions. `PRESET_BINDINGS` are overridden by user configuration so these remain available if the user needs them for another purpose - Releasing the `Alt` key ends any in-progress MRU window traversal Remove `focus-window-mru` actions from config These actions are configured in presets but no longer available for the bindings section of the configuration Cancel MRU traversal with Alt-Esc Had been forgotten in prior commit and was using `Mod` instead of `Alt` Rephrase some comments Fix Alt-Esc not cancelling window-mru Merge remote-tracking branch 'upstream/main' into window-mru Lock-in focus immediately on user interaction As per suggestion by @bbb651, focus is locked-in immediately if a window is interacted with, ie. receives key events or pointer clicks. This change is also an opportunity to make the lockin timer less aggresive. Merge remote-tracking branch 'upstream/main' into window-mru Simplify WindowMRU::new Now that there is a more general Niri::lockin_focus method, leverage it in WindowMRU. Replace Duration with Instant in WindowMRU timestamp Merge remote-tracking branch 'upstream/main' into window-mru Address PR comments - partial - Swapped meaning of next and previous for MRU traversal - Fixed comment that still referred to `Mod` as leader key for MRU traversal instead of `Alt` - Fixed doc comments that were missing a period - Stop using BinaryHeap in `WindowMRU::new()` - Replaced `WindowMRU::mru_with()` method with a simpler `advance()` - Simplified `Alt` key release handling code in `State::on_keyboard()` Simplify early-mru-commit logic No longer perform the mru-commit/lockin_focus in the next event loop callback. Instead it is handled directly when it is determined that an event (pointer or kbd) is forwarded to the active window. Handle PR comments - `focus_lockin` variables and configuration item renamed to `mru_commit`. - added the Esc key to `suppressed_keys` if it was used to cancel an MRU traversal. - removed `WindowMRU::mru_next` and `WindowMRU::mru_previous` methods as they didn't really provide more than the generic `WindowMRU::advance` method. - removed obsolete `Niri::event_forwarded_to_focused_client` boolean - added calls to `mru_commit()` (formerly `focus_lockin`) in: - `State::on_pointer_axis()` - `State::on_tablet_tool_axis()` - `State::on_tablet_tool_tip()` - `State::on_tablet_tool_proximity()` - `State::on_tablet_tool_button()` - `State::on_gesture_swipe_begin()` - `State::on_gesture_pinch_begin()` - `State::on_gesture_hold_begin()` - `State::on_touch_down()` Merge remote-tracking branch 'upstream/main' into window-mru Merge remote-tracking branch 'upstream/main' into window-mru Include never focused windows in MRU list Remove mru_commit_ms from configurable options For now the value is hard-coded to 750ms Merge remote-tracking branch 'upstream/main' into HEAD Add hotkey_overlay_tile for PRESET_BINDINGS Merge remote-tracking branch 'origin/window-mru' into HEAD Merge remote-tracking branch 'upstream/main' into window-mru Merge remote-tracking branch 'upstream/main' into window-mru Merge remote-tracking branch 'upstream/main' into window-mru Firt shot an MruUi The UI doesn't actually do anything yet. For now it just puts up thumbnails for existing windows in MRU order. Added MRU texture cache + simplifications Working version Removed previous Mru code Tidy up Action names Added Home/End bindings Merge remote-tracking branch 'upstream/main' into window-mru-ui Add scope and filtering to Mru window navigation Feed todo list Merge remote-tracking branch 'upstream/main' into window-mru-ui Clippy: Boxed the focus ring The UI object doesn't get moved around much so it isn't clear if this actually important. Boxing keeps clippy happy because of the size difference between an Open vs a Closed MRU UI. Bump rust version to 1.83 Avoids getting yelled at by clippy for using features that weren't yet available in 1.80.1 Applied clippy lints Fix MruFilter::None conversion MruFilter variant was getting ignored cargo fmt Update rust tool chain in CI Had only been updated in Cargo.toml, this causes build failures on Github Support changing Mru modes with the Mru UI open Fix texture cache optimization When the Mru parameters were changed while the MruUI was open, the texture cache is rebuilt but attempts to reuse existing Textures that are still usable in the updated Mru list. The index of the retained texture could be miscalculated and resulted in the wrong texture being used for a given window Id. Make MruAdvance available as a Bind action For consistency, MruAdvance bindings are carried over when the MruUI is open. Merge remote-tracking branch 'upstream/main' into window-mru-ui Preset binds added as a source for MRU UI binds Surprisingly the status prior to the patch should have prevented the UI bindings to advance through the Mru list from working properly. Use iterators to find bindings This allows the caller, eg. `on_keyboard` to choose the full list of bindings that should be searched through by composing iterators. Prior to the change the PRESET_BINDINGS were always included regardless of caller. With this approach, `on_keyboard` can add in the MRU_UI- specific bindings if it detects that the MRU UI is open. Make scope and filter optional in mru-advance This avoids unexpected behavior when navigating MRU with a filter, e.g. App-Id, with arrow keys for instance, which would result in changing navigation to ignore the app-id filter. With the change, mru-advance has an optional scope and filter that allows a key bind to leave the current navigation mode unchanged. Add title under window thumbnails - Reworked the texture cache to use TextureBuffer-s instead of BakedBuffer. - Add convenience methods to access TextureCache content. Some tidying up. Fade title out if it doesn't fit in available size Add bindings to change the MruScope Fix panic rendering title when cairo surface was busy Also avoid interpreting markup in window titles. Bring branch in line with window-mru-ui-squashed Add navigation animation in MRU UI Only handles motion between thumbnails Add thumbnail close animation For now, the animation only tracks when the corresponding window is closed. Add animations on filter and scope changes Add open/close animation to MRU Ui Merge remote-tracking branch 'upstream/main' into window-mru-ui Fix animations on scope/filter changes Previous implementation would evict wrong textures from the cache. And get thumbnail animations wrong. Merge remote-tracking branch 'upstream/main' into window-mru-ui Fix panic on change of scope/filter when Mru list is empty. Add doc comment to method that could trigger a panic Simplify thumbnail ordering logic Improve scope/filter change animations - direction is no longer a factor when an Mru UI is opened (previously the first thumbnail would be the currently focused window when moving in the "forward" direction, and when moving in the "backward" direction the focused window would have its thumbnail last in the list. This made animations kind of confusing when switching scopes or filtering. The updated version always places the thumbnails in most recent focus order. So when the MRU UI is brought up in the "backward" direction, the last thumbnail in the MRU list starts selected. - closing animations no longer use the view referential, but use the output referential instead. This makes disappearing thumbnails appear stationary on screen even if the view is moving. This tends to look less confusing than the previous approach. Applied clippy lints Preserve scope during fwd/backward navigation Change preset keybinding declarations from const to static Add thumbnail selection animation This is still very much a work in progress: - the focus ring is not shown until the animation completes - if the tile is resized during the animation, the net effect looks pretty bad because proportions skip directly to those requested instead of transitioning smoothly. Both points should be addressed by using regular tile rendering to an OffscreenBuffer but I haven't much success there. Merge remote-tracking branch 'upstream/main' into window-mru-ui Fix niri-config parse test Use OffscreenBuffer to render ThumbnailSelection animation todo: fix thumbnail destination if the target workspace is being swapped. Handle workspace switch during thumbnail select animation Close Overview when MRU UI is opened Add configuration option to disable MRU UI Make mod-key for MRU UI configurable Avoid collecting MRU UI bindings on each input Bindings are cached when first accessed, the cache is invalidated whenever the configuration changes. Close MRU UI when Overview is opened Merge remote-tracking branch 'upstream/main' into window-mru-ui Fix MRU UI opened bindings always active Remove mru-advance from actions available for config keybind Because the MRU UI assumes that all key-bindings use the mod-key defined in for `recent-windows`, behavior can be disconcerting if arbitrary keybindings are allowed in the configuration (e.g. UI opens and immediately closes because the mod-key is not being held). Include focus timestamp in Window IPC messages Timestamps are serialized as time::SystemTime, which in JSON form is represented as *two* fields, secs and nanos. Merge remote-tracking branch 'upstream/main' into window-mru-ui Only do Thumbnail Select Anim if MRU UI stayed open long enough Threshold is hard coded in window_mru_ui.rs (250ms). Merge remote-tracking branch 'upstream/main' into window-mru-ui Add a few WindowMru tests Forward Mod-key release when closing MRU UI Merge remote-tracking branch 'upstream/main' into window-mru-ui Remove extraneous thumbnail motion on Mru filter change Fix missing alpha in Mru thumbnail open animation Add Mod+h and Mod+l bindings for MRU navigation Change CloseWindow binding in MRU to Mod+Shift+q Keep MRU UI on display it was initially opened on Bump up the MRU IU selection anim threshold Allow MRU thumbnail selection with mouse pointer Allow MRU thumbnail selection using touch Needs testing, Idk if this works for lack of a touchscreen. Fix missing fade-out animation for thumbnails on MRU UI close Merge remote-tracking branch 'upstream/main' into window-mru-ui Make thumbnail selection animation optional Merge remote-tracking branch 'upstream/main' into window-mru-ui Fix niri-config parse test case Add shortcut to cycle through MRU scopes - added MruCycleScope action to trigger cycling - added an indication panel to show the current scope - recall previous scope when opening the MRU UI Merge remote-tracking branch 'upstream/main' into window-mru-ui Improve MRU thumbnail scaling Prior to the commit, thumbnails were just 2x downscaling of their corresponding window. Now they are also scaled based on the relative height of the window on its output display. This avoids having a thumbnail taking up the entire screen on the display where the MRU UI is displayed. Merge remote-tracking branch 'upstream/main' into window-mru-ui Use resolved window rules for thumbnails Previously parameters such as the corner-radius didn't follow the general config and used an MRU UI specific default. Align thumbnail size and position to physical pixels clarify param names in generate_tile_texture Revert MSRV 1.83 Close MRU UI on click/touch outside of a thumbnail MRU - display window title under all thumbnails MRU - revert to pre-defined thumbnail corner radius MRU - Removed thumb title font size adjustment This didn't look as if it was necessary. (unscientific assesment) MRU - reverted to Mod+Q to quit selected thumbnail Merge remote-tracking branch 'upstream/main' into window-mru-ui MRU - Update focus ring when moving mouse over a thumbnail restore code that went missing switch focus timestamp to monotonic time We don't want the monotonicity of SystemClock here. Instant itself isn't serializable, but our monotonic clock timestamps are, and they are consistent across processes too. axe thumbnail close animation I'm still not quite convinced about it. Maybe we'll reintroduce it later with better architecture; for now though, it causes quite a bit of complexity. minor cleanups remove unnecessary option replace open animation with delay Avoids flashing the whole screen for quick Alt-Tabs. Duration taken from GNOME Shell. make mod key different in nested replace SelectedThumbnail with MappedId don't hide focus ring during alt tab wip refactor everything and render live windows rename some constants replace focus ring with background + border extract thumbnail constructors reimplement title fade with a shader reimplement ui fade out on closing fix preview scaling add min scale for very small windows add keyboard focus for mru fixes activating alt on target window revert/simplify pointer code changes fixes mouse not clamped to output when in alt-tab; should fix touch going through move touch handling to below screenshot ui remove unneeded touch overview grab code rename to mru.rs move mru tests into separate file also close mru when clicking on other outputs roll back no longer necessary event filtering rework mru keyboard binds convert some regular binds to MRU binds hide window title when blocked out verify that mru bind uses a keyboard key improve selection visibility & indicate urgency freeze alt-tab view on pointer motion add WindowFocusTimestampChanged event, separate struct for Timestamp minor cleanups scope panel fixes simplify scope cycling honor geometry corner radius don't trigger focus-follows-mouse in the MRU remove unnecessary argument cache backdrop buffers remove unnecessary mru close allow to screenshot the mru support bob offset improve mru redraws pass config instead of options add open-delay-ms option add highlight options rename window-mru-ui-open-close to recent-windows-close add preview options fix scope change and remove window delta anim improve unselected scope panel text contrast move panel back up so it doesn't overlap the screenshot one rename preview to previews in config render highlight background with focusring fix highlight pos rounding add highlight corner-radius setting remove allocation from inner render use offscreen for mru closing fade make scope only affect MRU open otherwise you can't change scope at runtime easily replace todo with fixme include title height in thumbnail under remove cloning from set scope/filter remove animate close todo update field name in mapped remove commented out closing thumbnails I decided not to do this for now. rename filter from None to All and skip in knuffel None is confusing with Option write docs make inactive urgent more prominent remove reopen from scartch todo explicitly mention app id in filter make scroll binds work in the mru add fixmes don't select next window when nothing is focused add missing anim config merge fixes replace click selection with pointer motion + confirm simplify close mru ui call rename mrucloserequest variants mru confirm fixes support tablet input mru commit cleanups remove most mru commit calls they didn't actualy do anything as implemented. If we want to bring them back we need to refactor a bit to join them with activate_window() call. make regular mouse binds also work in mru fixes fixes move types up fix tracy span
461 lines
13 KiB
Markdown
461 lines
13 KiB
Markdown
### Overview
|
||
|
||
Niri has several animations which you can configure in the same way.
|
||
Additionally, you can disable or slow down all animations at once.
|
||
|
||
Here's a quick glance at the available animations with their default values.
|
||
|
||
```kdl
|
||
animations {
|
||
// Uncomment to turn off all animations.
|
||
// You can also put "off" into each individual animation to disable it.
|
||
// off
|
||
|
||
// Slow down all animations by this factor. Values below 1 speed them up instead.
|
||
// slowdown 3.0
|
||
|
||
// Individual animations.
|
||
|
||
workspace-switch {
|
||
spring damping-ratio=1.0 stiffness=1000 epsilon=0.0001
|
||
}
|
||
|
||
window-open {
|
||
duration-ms 150
|
||
curve "ease-out-expo"
|
||
}
|
||
|
||
window-close {
|
||
duration-ms 150
|
||
curve "ease-out-quad"
|
||
}
|
||
|
||
horizontal-view-movement {
|
||
spring damping-ratio=1.0 stiffness=800 epsilon=0.0001
|
||
}
|
||
|
||
window-movement {
|
||
spring damping-ratio=1.0 stiffness=800 epsilon=0.0001
|
||
}
|
||
|
||
window-resize {
|
||
spring damping-ratio=1.0 stiffness=800 epsilon=0.0001
|
||
}
|
||
|
||
config-notification-open-close {
|
||
spring damping-ratio=0.6 stiffness=1000 epsilon=0.001
|
||
}
|
||
|
||
exit-confirmation-open-close {
|
||
spring damping-ratio=0.6 stiffness=500 epsilon=0.01
|
||
}
|
||
|
||
screenshot-ui-open {
|
||
duration-ms 200
|
||
curve "ease-out-quad"
|
||
}
|
||
|
||
overview-open-close {
|
||
spring damping-ratio=1.0 stiffness=800 epsilon=0.0001
|
||
}
|
||
|
||
recent-windows-close {
|
||
spring damping-ratio=1.0 stiffness=800 epsilon=0.001
|
||
}
|
||
}
|
||
```
|
||
|
||
### Animation Types
|
||
|
||
There are two animation types: easing and spring.
|
||
Each animation can be either an easing or a spring.
|
||
|
||
#### Easing
|
||
|
||
This is a relatively common animation type that changes the value over a set duration using an interpolation curve.
|
||
|
||
To use this animation, set the following parameters:
|
||
|
||
- `duration-ms`: duration of the animation in milliseconds.
|
||
- `curve`: the easing curve to use.
|
||
|
||
```kdl
|
||
animations {
|
||
window-open {
|
||
duration-ms 150
|
||
curve "ease-out-expo"
|
||
}
|
||
}
|
||
```
|
||
|
||
Currently, niri only supports five curves.
|
||
You can get a feel for them on pages like [easings.net](https://easings.net/).
|
||
|
||
- `ease-out-quad` <sup>Since: 0.1.5</sup>
|
||
- `ease-out-cubic`
|
||
- `ease-out-expo`
|
||
- `linear` <sup>Since: 0.1.6</sup>
|
||
- `cubic-bezier` <sup>Since: 25.08</sup>
|
||
A custom [cubic Bézier curve](https://www.w3.org/TR/css-easing-1/#cubic-bezier-easing-functions). You need to set 4 numbers defining the control points of the curve, for example:
|
||
```kdl
|
||
animations {
|
||
window-open {
|
||
// Same as CSS cubic-bezier(0.05, 0.7, 0.1, 1)
|
||
curve "cubic-bezier" 0.05 0.7 0.1 1
|
||
}
|
||
}
|
||
```
|
||
You can tweak the cubic-bezier parameters on pages like [easings.co](https://easings.co?curve=0.05,0.7,0.1,1).
|
||
|
||
#### Spring
|
||
|
||
Spring animations use a model of a physical spring to animate the value.
|
||
They notably feel better with touchpad gestures, because they take into account the velocity of your fingers as you release the swipe.
|
||
Springs can also oscillate / bounce at the end with the right parameters if you like that sort of thing, but they don't have to (and by default they mostly don't).
|
||
|
||
Due to springs using a physical model, the animation parameters are less obvious and generally should be tuned with trial and error.
|
||
Notably, you cannot directly set the duration.
|
||
You can use the [Elastic](https://flathub.org/apps/app.drey.Elastic) app to help visualize how the spring parameters change the animation.
|
||
|
||
A spring animation is configured like this, with three mandatory parameters:
|
||
|
||
```kdl
|
||
animations {
|
||
workspace-switch {
|
||
spring damping-ratio=1.0 stiffness=1000 epsilon=0.0001
|
||
}
|
||
}
|
||
```
|
||
|
||
The `damping-ratio` goes from 0.1 to 10.0 and has the following properties:
|
||
|
||
- below 1.0: underdamped spring, will oscillate in the end.
|
||
- above 1.0: overdamped spring, won't oscillate.
|
||
- 1.0: critically damped spring, comes to rest in minimum possible time without oscillations.
|
||
|
||
However, even with damping ratio = 1.0, the spring animation may oscillate if "launched" with enough velocity from a touchpad swipe.
|
||
|
||
> [!WARNING]
|
||
> Overdamped springs currently have some numerical stability issues and may cause graphical glitches.
|
||
> Therefore, setting `damping-ratio` above `1.0` is not recommended.
|
||
|
||
Lower `stiffness` will result in a slower animation more prone to oscillation.
|
||
|
||
Set `epsilon` to a lower value if the animation "jumps" at the end.
|
||
|
||
> [!TIP]
|
||
> The spring *mass* (which you can see in Elastic) is hardcoded to 1.0 and cannot be changed.
|
||
> Instead, change `stiffness` proportionally.
|
||
> E.g. increasing mass by 2× is the same as decreasing stiffness by 2×.
|
||
|
||
### Animations
|
||
|
||
Now let's go into more detail on the animations that you can configure.
|
||
|
||
#### `workspace-switch`
|
||
|
||
Animation when switching workspaces up and down, including after the vertical touchpad gesture (a spring is recommended).
|
||
|
||
```kdl
|
||
animations {
|
||
workspace-switch {
|
||
spring damping-ratio=1.0 stiffness=1000 epsilon=0.0001
|
||
}
|
||
}
|
||
```
|
||
|
||
#### `window-open`
|
||
|
||
Window opening animation.
|
||
|
||
This one uses an easing type by default.
|
||
|
||
```kdl
|
||
animations {
|
||
window-open {
|
||
duration-ms 150
|
||
curve "ease-out-expo"
|
||
}
|
||
}
|
||
```
|
||
|
||
##### `custom-shader`
|
||
|
||
<sup>Since: 0.1.6</sup>
|
||
|
||
You can write a custom shader for drawing the window during an open animation.
|
||
|
||
See [this example shader](./examples/open_custom_shader.frag) for a full documentation with several animations to experiment with.
|
||
|
||
If a custom shader fails to compile, niri will print a warning and fall back to the default, or previous successfully compiled shader.
|
||
When running niri as a systemd service, you can see the warnings in the journal: `journalctl -ef /usr/bin/niri`
|
||
|
||
> [!WARNING]
|
||
>
|
||
> Custom shaders do not have a backwards compatibility guarantee.
|
||
> I may need to change their interface as I'm developing new features.
|
||
|
||
Example: open will fill the current geometry with a solid gradient that gradually fades in.
|
||
|
||
```kdl
|
||
animations {
|
||
window-open {
|
||
duration-ms 250
|
||
curve "linear"
|
||
|
||
custom-shader r"
|
||
vec4 open_color(vec3 coords_geo, vec3 size_geo) {
|
||
vec4 color = vec4(0.0);
|
||
|
||
if (0.0 <= coords_geo.x && coords_geo.x <= 1.0
|
||
&& 0.0 <= coords_geo.y && coords_geo.y <= 1.0)
|
||
{
|
||
vec4 from = vec4(1.0, 0.0, 0.0, 1.0);
|
||
vec4 to = vec4(0.0, 1.0, 0.0, 1.0);
|
||
color = mix(from, to, coords_geo.y);
|
||
}
|
||
|
||
return color * niri_clamped_progress;
|
||
}
|
||
"
|
||
}
|
||
}
|
||
```
|
||
|
||
#### `window-close`
|
||
|
||
<sup>Since: 0.1.5</sup>
|
||
|
||
Window closing animation.
|
||
|
||
This one uses an easing type by default.
|
||
|
||
```kdl
|
||
animations {
|
||
window-close {
|
||
duration-ms 150
|
||
curve "ease-out-quad"
|
||
}
|
||
}
|
||
```
|
||
|
||
##### `custom-shader`
|
||
|
||
<sup>Since: 0.1.6</sup>
|
||
|
||
You can write a custom shader for drawing the window during a close animation.
|
||
|
||
See [this example shader](./examples/close_custom_shader.frag) for a full documentation with several animations to experiment with.
|
||
|
||
If a custom shader fails to compile, niri will print a warning and fall back to the default, or previous successfully compiled shader.
|
||
When running niri as a systemd service, you can see the warnings in the journal: `journalctl -ef /usr/bin/niri`
|
||
|
||
> [!WARNING]
|
||
>
|
||
> Custom shaders do not have a backwards compatibility guarantee.
|
||
> I may need to change their interface as I'm developing new features.
|
||
|
||
Example: close will fill the current geometry with a solid gradient that gradually fades away.
|
||
|
||
```kdl
|
||
animations {
|
||
window-close {
|
||
custom-shader r"
|
||
vec4 close_color(vec3 coords_geo, vec3 size_geo) {
|
||
vec4 color = vec4(0.0);
|
||
|
||
if (0.0 <= coords_geo.x && coords_geo.x <= 1.0
|
||
&& 0.0 <= coords_geo.y && coords_geo.y <= 1.0)
|
||
{
|
||
vec4 from = vec4(1.0, 0.0, 0.0, 1.0);
|
||
vec4 to = vec4(0.0, 1.0, 0.0, 1.0);
|
||
color = mix(from, to, coords_geo.y);
|
||
}
|
||
|
||
return color * (1.0 - niri_clamped_progress);
|
||
}
|
||
"
|
||
}
|
||
}
|
||
```
|
||
|
||
#### `horizontal-view-movement`
|
||
|
||
All horizontal camera view movement animations, such as:
|
||
|
||
- When a window off-screen is focused and the camera scrolls to it.
|
||
- When a new window appears off-screen and the camera scrolls to it.
|
||
- After a horizontal touchpad gesture (a spring is recommended).
|
||
|
||
```kdl
|
||
animations {
|
||
horizontal-view-movement {
|
||
spring damping-ratio=1.0 stiffness=800 epsilon=0.0001
|
||
}
|
||
}
|
||
```
|
||
|
||
#### `window-movement`
|
||
|
||
<sup>Since: 0.1.5</sup>
|
||
|
||
Movement of individual windows within a workspace.
|
||
|
||
Includes:
|
||
|
||
- Moving window columns with `move-column-left` and `move-column-right`.
|
||
- Moving windows inside a column with `move-window-up` and `move-window-down`.
|
||
- Moving windows out of the way upon window opening and closing.
|
||
- Window movement between columns when consuming/expelling.
|
||
|
||
This animation *does not* include the camera view movement, such as scrolling the workspace left and right.
|
||
|
||
```kdl
|
||
animations {
|
||
window-movement {
|
||
spring damping-ratio=1.0 stiffness=800 epsilon=0.0001
|
||
}
|
||
}
|
||
```
|
||
|
||
#### `window-resize`
|
||
|
||
<sup>Since: 0.1.5</sup>
|
||
|
||
Window resize animation.
|
||
|
||
Only manual window resizes are animated, i.e. when you resize the window with `switch-preset-column-width` or `maximize-column`.
|
||
Also, very small resizes (up to 10 pixels) are not animated.
|
||
|
||
```kdl
|
||
animations {
|
||
window-resize {
|
||
spring damping-ratio=1.0 stiffness=800 epsilon=0.0001
|
||
}
|
||
}
|
||
```
|
||
|
||
##### `custom-shader`
|
||
|
||
<sup>Since: 0.1.6</sup>
|
||
|
||
You can write a custom shader for drawing the window during a resize animation.
|
||
|
||
See [this example shader](./examples/resize_custom_shader.frag) for a full documentation with several animations to experiment with.
|
||
|
||
If a custom shader fails to compile, niri will print a warning and fall back to the default, or previous successfully compiled shader.
|
||
When running niri as a systemd service, you can see the warnings in the journal: `journalctl -ef /usr/bin/niri`
|
||
|
||
> [!WARNING]
|
||
>
|
||
> Custom shaders do not have a backwards compatibility guarantee.
|
||
> I may need to change their interface as I'm developing new features.
|
||
|
||
Example: resize will show the next (after resize) window texture right away, stretched to the current geometry.
|
||
|
||
```kdl
|
||
animations {
|
||
window-resize {
|
||
custom-shader r"
|
||
vec4 resize_color(vec3 coords_curr_geo, vec3 size_curr_geo) {
|
||
vec3 coords_tex_next = niri_geo_to_tex_next * coords_curr_geo;
|
||
vec4 color = texture2D(niri_tex_next, coords_tex_next.st);
|
||
return color;
|
||
}
|
||
"
|
||
}
|
||
}
|
||
```
|
||
|
||
#### `config-notification-open-close`
|
||
|
||
The open/close animation of the config parse error and new default config notifications.
|
||
|
||
This one uses an underdamped spring by default (`damping-ratio=0.6`) which causes a slight oscillation in the end.
|
||
|
||
```kdl
|
||
animations {
|
||
config-notification-open-close {
|
||
spring damping-ratio=0.6 stiffness=1000 epsilon=0.001
|
||
}
|
||
}
|
||
```
|
||
|
||
#### `exit-confirmation-open-close`
|
||
|
||
<sup>Since: 25.08</sup>
|
||
|
||
The open/close animation of the exit confirmation dialog.
|
||
|
||
This one uses an underdamped spring by default (`damping-ratio=0.6`) which causes a slight oscillation in the end.
|
||
|
||
```kdl
|
||
animations {
|
||
exit-confirmation-open-close {
|
||
spring damping-ratio=0.6 stiffness=500 epsilon=0.01
|
||
}
|
||
}
|
||
```
|
||
|
||
#### `screenshot-ui-open`
|
||
|
||
<sup>Since: 0.1.8</sup>
|
||
|
||
The open (fade-in) animation of the screenshot UI.
|
||
|
||
```kdl
|
||
animations {
|
||
screenshot-ui-open {
|
||
duration-ms 200
|
||
curve "ease-out-quad"
|
||
}
|
||
}
|
||
```
|
||
|
||
#### `overview-open-close`
|
||
|
||
<sup>Since: 25.05</sup>
|
||
|
||
The open/close zoom animation of the [Overview](./Overview.md).
|
||
|
||
```kdl
|
||
animations {
|
||
overview-open-close {
|
||
spring damping-ratio=1.0 stiffness=800 epsilon=0.0001
|
||
}
|
||
}
|
||
```
|
||
|
||
#### `recent-windows-close`
|
||
|
||
<sup>Since: next release</sup>
|
||
|
||
The close fade-out animation of the recent windows switcher.
|
||
|
||
```kdl
|
||
animations {
|
||
recent-windows-close {
|
||
spring damping-ratio=1.0 stiffness=800 epsilon=0.001
|
||
}
|
||
}
|
||
```
|
||
|
||
### Synchronized Animations
|
||
|
||
<sup>Since: 0.1.5</sup>
|
||
|
||
Sometimes, when two animations are meant to play together synchronized, niri will drive them both with the same configuration.
|
||
|
||
For example, if a window resize causes the view to move, then that view movement animation will also use the `window-resize` configuration (rather than the `horizontal-view-movement` configuration).
|
||
This is especially important for animated resizes to look good when using `center-focused-column "always"`.
|
||
|
||
As another example, resizing a window in a column vertically causes other windows to move up or down into their new position.
|
||
This movement will use the `window-resize` configuration, rather than the `window-movement` configuration, to keep the animations synchronized.
|
||
|
||
A few actions are still missing this synchronization logic, since in some cases it is difficult to implement properly.
|
||
Therefore, for the best results, consider using the same parameters for related animations (they are all the same by default):
|
||
|
||
- `horizontal-view-movement`
|
||
- `window-movement`
|
||
- `window-resize`
|