forge
Explore
Log in

Don't you dare go Hollow

niri

Clone
★ 0

0 watching0 forksRustGPL-3.012.1 MiB9d8f4f8Ivan Molodetskikh1 month ago2997 commits

Window-Effects.md87 lines, 4.6 KiBHistoryRawDownload
1### Overview
2
3<sup>Since: 26.04</sup>
4
5You can apply background effects to windows and layer-shell surfaces.
6These include blur, xray, saturation, and noise.
7They can be enabled in the `background-effect {}` section of [window]./Configuration:-Window-Rules.md#background-effect or [layer]./Configuration:-Layer-Rules.md#background-effect rules.
8
9![Screenshot with blur]./img/blur.png
10
11The window needs to be semitransparent for you to see the background effect (otherwise it's fully covered by the opaque window).
12Focus ring and border can also cover the background effect, see [this FAQ entry]./FAQ.md#why-are-transparent-windows-tinted-why-is-the-borderfocus-ring-showing-up-through-semitransparent-windows for how to change this.
13
14### Blur
15
16Windows and layer surfaces can request their background to be blurred via the [`ext-background-effect` protocol]https://wayland.app/protocols/ext-background-effect-v1.
17In this case, the application will usually offer some "background blur" setting that you'll need to enable in its configuration.
18
19You can also enable blur on the niri side with the `blur true` background effect window rule:
20
21```kdl
22// Enable blur behind the Alacritty terminal.
23window-rule {
24 match app-id="^Alacritty$"
25
26 background-effect {
27 blur true
28 }
29}
30
31// Enable blur behind the fuzzel launcher.
32layer-rule {
33 match namespace="^launcher$"
34
35 background-effect {
36 blur true
37 }
38}
39```
40
41Blur enabled via the window rule will follow the window corner radius set via [`geometry-corner-radius`]./Configuration:-Window-Rules.md#geometry-corner-radius.
42On the other hand, blur enabled through `ext-background-effect` will exactly follow the shape requested by the window.
43If the window or layer has clientside rounded corners or other complex shape, it should set a corresponding blur shape through `ext-background-effect`, then it will get correctly shaped background blur without any manual niri configuration.
44
45Windows can also blur their pop-up menus using `ext-background-effect`.
46On the niri side, you can do it with a `popups` block inside [`window-rule`]./Configuration:-Window-Rules.md#popups and [`layer-rule`]./Configuration:-Layer-Rules.md#popups.
47See those wiki pages for examples and limitations.
48
49Global blur settings are configured in the [`blur {}` config section]./Configuration:-Miscellaneous.md#blur and apply to all background blur.
50
51### Xray
52
53Xray makes the window background "see through" to your wallpaper, ignoring any other windows below.
54You can enable it with `xray true` background effect [window]./Configuration:-Window-Rules.md#background-effect or [layer]./Configuration:-Layer-Rules.md#background-effect rule.
55
56Xray is automatically enabled by default if any other background effect (like blur) is active.
57This is because it's much more efficient: with xray active, niri only needs to blur the background once, and then can reuse this blurred version with no extra work (since the wallpaper changes very rarely).
58
59If you have an animated wallpaper, xray will still have to recompute blur every frame, but that happens once and shared among all windows, rather than recomputed separately for each window.
60
61#### Non-xray effects (experimental)
62
63You can disable xray with `xray false` background effect window rule.
64This gives you the normal kind of blur where everything below a window is blurred.
65Keep in mind that non-xray blur and other non-xray effects are more expensive as niri has to recompute them any time you move the window, or the contents underneath change.
66
67> [!WARNING]
68> Non-xray effects are currently experimental because they have some known limitations.
69>
70> - They disappear during window open/close animations and while dragging a tiled window.
71> Fixing this requires a refactor to the niri rendering code to defer offscreen rendering, and possibly other refactors.
72
73### Implementation notes
74
75The `ext-background-effect` protocol supports any wl_surface.
76We currently implement it only for toplevels, layer surfaces, and pop-ups, which should cover the vast majority of what's actually used by applications.
77
78For pop-ups, effects default to *non-xray* because pop-ups generally appear on top of windows.
79
80In particular, the following surface types don't support `ext-background-effect`.
81They can be implemented as the need arises.
82
83- Subsurfaces. Would require implementing `clip-to-geometry` support for background effects.
84- Lock surfaces. Not useful as it would just show our red locked session background.
85- Cursor and drag-and-drop icon.
86The main challenge here will be screencasts where the cursor is rendered separately.
87This is problematic because non-xray effects require rendering the whole scene in one go rather than separately.