Skip to content

The compositor

Kestrel runs on its own build of Mutter 51 in kestrel/compositor: the upstream release at the commit in upstream.json, plus an ordered Git patch series. It builds next to the system’s Mutter and never replaces it.

  • Windows. Rounded corners that stay square where a maximized or tiled window meets the screen edge or another window, and on fullscreen windows so they keep direct scanout. A thin outline on every floating window, and a shadow around those that don’t draw their own. Floating windows are told they’re tiled while corners are square, so GTK, libadwaita, Chromium and Electron apps draw square corners and leave the shadow to the compositor. Title bars in Kestrel’s style for X11 apps and for Wayland apps that ask through xdg-decoration.
  • Glass. A dual Kawase blur with targets kept across frames, app glass that keeps its blur until what is behind it changes, the frosted wallpapers glass shows instead of blurring, the Maris, Niko and Rina materials, blue-noise grain, and kestrel_glass_v1 for apps to hear and ask for a material, all described under Glass.
  • The shell. Redraw clips that the shell can grow, desktop windows for live wallpapers, the transformed window groups behind the board, shortcuts the shell adds winning over built-in ones, drops from Wayland apps onto the shell’s own actors and file drags from the shell into apps, a signal before a monitor turns, and fragment shader chains over a whole display or a single actor for screen effects. Shell text with fractional glyph advances and grayscale antialiasing, drawn at a fractional scale’s own resolution so it stays sharp at 125% and 150%. Text and icons drawn one texel to a device pixel land on the same whole pixel a background with that edge starts on, so an icon centred on its button stays centred at any scale. The shell lays every icon out at a whole number of device pixels, so at 175% a 28 point icon is 47 pixels drawn as they are, not stretched over 46⅔.
  • Sandboxed apps. wp_security_context_v1, which Flatpak and Luft’s AppImage sandbox use to tag their apps’ connections. Mutter’s screen recording, remote control and display services refuse sandboxed callers, and so does every Mutter D-Bus interface not listed as open. App sandbox explains what each permission opens.
  • Protocols. ext-foreign-toplevel-list-v1, ext-image-copy-capture-v1 and the overlay layer of wlr-layer-shell for apps that may record windows (Recording windows), xdg-toplevel-icon-v1, wp_content_type_v1, ext-idle-notify-v1 with idle times of at least ten seconds for sandboxed apps, so no app can follow someone’s typing, and ext-data-control-v1 for password managers that clear what they copied.
  • Input. Touchpad scrolling at the touchpad’s scroll-speed, and at the fingers’ pace in Chromium-based apps, which would scroll twelve times too far. Palm rejection for pens on a touchscreen, every pen sample with its pressure for the shell’s own strokes, pen settings shared by every pen, and button actions that reach the shell as pen-action. Modifiers the shell can treat as used up while a shortcut made of them is held. Accelerator grabs that stay active while an app inhibits shortcuts, so shortcuts a person allowed an app to have still reach it over a game that holds the keyboard. A pointer-shaken signal on the cursor tracker, and a pointer the shell can draw larger, described under Shake to find the pointer. Virtual devices that act as pens or flip the tablet mode switch, for checks.
  • Display and focus. Variable refresh only for games, default display scales aimed at 110 DPI, settings from kestrel-settings in place of gnome-settings-daemon, recovery from GPU resets (GNOME/mutter!5247, by Toluwaleke Ogundipe), and windows that appear after you moved on opening behind and asking for attention.
  • Crashes. A Wayland socket inherited from kestrel-wrapper, so apps can reconnect after Kestrel crashes (Kestrel).

Glass comes in four materials, chosen per kind of surface in com.lantharos.kestrel.glass: taskbar, surfaces for Gust, panels, menus and dialogs and for apps’ transient surfaces, windows for app windows, and see-through for the glass behind see-through windows. All four are Niko unless people choose otherwise. blurs says whether Luca, Niko and Rina blur everything behind them or only the wallpaper, which they do unless people choose otherwise, and wallpaper-on-power-saver makes them blur only the wallpaper while the power saver is on. kestrel/ui/src/appearance/glass follows the settings and the power profile, sets each shell blur’s style and tells Mutter with meta_compositor_set_glass.

Luca blurs what is behind the glass with a dual Kawase pyramid in ClutterBlur. The area is halved two to six times, five taps a step, and brought back up to half its size, eight taps a step, so every pixel weighs in once and moving content doesn’t shimmer. The depth and the tap offset are matched to a Gaussian of the requested radius, so a radius of 30 looks as wide as it did as a Gaussian. Blur targets are pooled by depth and by size rounded up to 64 pixels, with the copy of the screen going straight into the first level, so resizing and the overview reuse them. A result costs about 45 µs of GPU time on a taskbar and 60 to 100 µs on a window sidebar.

  • Shell glass is ShellBlurEffect. It keeps a copy of what is behind it, refreshed only where the stage repainted and something below changed, and its blurred result at half size, which it draws again as one quad until something behind it changes.
  • App glass is the ext-background-effect-v1 blur in src/compositor/meta-background-*.c. Before each frame, a redraw clip filter looks at the actors below each glass window, as the shell does. Only when something there repainted under the glass, the stacking changed or the window moved does it add the glass to the redraw clip and blur again. Otherwise the window draws the blur it kept for that view. The blur reads only the glass and, for glass around an opaque sheet, the strip of the sheet within the blur’s reach of it, drawing each step of the pyramid only there. So the redraw clip never grows past that, other glass isn’t set off and what is under the rest of the window stays culled. Clones, such as the overview’s, draw their window’s kept blur, and windows that aren’t painted aren’t blurred.

Luca that blurs only the wallpaper shows the frosted wallpaper instead. FrostedWallpaper blurs each monitor’s wallpaper once, at a quarter of its size, and stores it on disk. Shell glass draws the piece of wallpaper under it with the same dimming, lift, saturation and corners as a live blur, and app glass with the same saturation and grain. Neither copies the screen, blurs or grows the redraw clip, so this glass costs one textured quad, however busy the screen behind it is.

Maris is drawn like Windows’ Mica: the desktop’s surface colour, from the wallpaper’s palette, over a much wider blur of the wallpaper, so only its colours are left and they shift as a window moves. It comes from a second frosted wallpaper, blurred with a radius of 300 and stored at a thirty-second of the monitor’s size. Each pixel of it first takes the luminosity of the surface colour and keeps its own hue and saturation, the luminosity blend of CSS and PDF, so the wallpaper tints the glass without ever making it lighter or darker. The surface colour then covers 80% of that in the dark style and 50% in the light style. Maris leaves out Luca’s dimming, lift and saturation. On shell glass the surface’s own background counts towards the share the surface colour covers.

The shell renders each frosted wallpaper only while something uses it: the blurred one while Luca or Niko blurs only the wallpaper, the wide one while any kind of surface is Maris or an app asks for it, and the clear one, the wallpaper unblurred at half size, while Rina blurs only the wallpaper. It hands the pieces to Mutter with meta_compositor_add_frosted_wallpaper, and the surface colour with meta_compositor_set_glass_surface, whose alpha is the share the colour covers and whose luminosity says how far the wallpaper takes the colour’s luminosity first. Shell glass and app glass both read them from there.

Niko is drawn like Windows’ Acrylic. It blurs what is behind the glass on Luca’s path with a radius of 60, twice Luca’s, and blurs only the wallpaper whenever blurs says so, from the same frosted wallpaper. Each pixel then takes the luminosity of the Niko tint, 96% of the way in the dark style and 85% in the light style, and the tint’s hue and saturation, the colour blend, 15% of the way in the dark style and not at all in the light style. A vivid wallpaper would still colour the glass through the luminosity blend, so Kestrel measures how colourful the wallpaper is, the mean chroma of its samples averaged three by three, and above 0.035 eases that through a soft knee toward 0.04. The colour blend then goes further by the same ratio, so the share of the wallpaper’s colour that is left shrinks with it; muted wallpapers stay below the knee and keep the shares above. The dark tint is the surface colour raised to the lightness of #2C2C2C, a little lighter than Luft’s surfaces, so the wallpaper’s colours show through it warmly while text keeps a contrast above 11:1; the light tint is the surface colour itself. A speckle of 2% noise from the grain tile replaces the grain. Since the tint already is the whole surface, shell glass cancels its surface’s own background, so the background drawn over it lands on the Niko colour. Niko costs what Luca costs, and as little as Luca that blurs only the wallpaper in the power saver.

The shell hands the tint over with meta_compositor_set_niko_tint, whose alpha is the share of the tint’s hue and whose luminosity is how far the blur takes its luminosity.

Rina is liquid glass: a thick, clear slab that bends what is behind it like a lens. Shell glass reads what is behind it unblurred: the backdrop the effect already captures for its blur, at full resolution, so no extra texture. It blurs that backdrop with a radius of 4, against Luca’s 30, and lays the blur over the bent picture as a light frost, 60% of it under the middle of the glass where text sits, easing out to none at the edge, so text under a menu doesn’t fight the text on it while the bend stays sharp. It keeps a little of Luca’s dimming, lift and saturation, and cancels 65% of its surface’s own background so more of what is behind shows.

The whole surface is a lens. Its thickness falls from the middle toward the outline as (1 − s³)^⅓, where s runs from 0 in the middle to 1 at the edge along a superellipse of power 4 fitted to the surface, so its contours turn smoothly toward the corners and straight lines behind the glass bow everywhere, not only near the rim. Snell’s law for a refractive index of 1.5 gives how far a ray turns at the slope there, weighted by how thick the glass is at that point, and every pixel samples that far outward along the slope. A swell over an ellipse fitted to the surface adds twice that reach times r²(1 − r²), where r runs from 0 in the middle to 1 at the edge, so lines through the middle bow visibly too while the edge stays strongest. Together they reach a little past 75% of the surface’s half short side and never much more than 24 pixels. On top of that, a bezel 60% as wide as the corner radius, between 10 and 18 pixels and never more than 30% of the short side, bends along the outline’s own normal with a squircle profile, (1 − (1 − x)⁴)^¼, reaching 60% of its width at the edge, so the rim shows a squeezed view of what lies just around the glass. Glass bends blue further than red, so the three colours are read at different offsets: green at the bend itself, blue 12% further and red 12% less, at most 4 pixels apart, which fringes every contrast and grows toward the edge with the bend. To have something to sample there, the backdrop and its blur cover the surface grown by that reach, and the effect’s paint volume and the area it watches for changes grow with it. Where the screen edge or another shell glass surface lying beside it is closer than the reach on a side, every offset toward that side shrinks by the same share, so the bend stays smooth and a panel never shows the taskbar island next to it. Edges against the screen edge count as the middle of a glass twice as large, so the full-width taskbar bends only toward its open edge.

The rim is a highlight 1.2 pixels wide, at least 1.5 device pixels at any scale, with a fifth of its strength trailing four times as far in. Light comes from the upper left at 45°. What faces it is the outline’s normal leaned toward where the pixel sits in the shape, its offset from the centre over the half size, weighted 1.5, so the rim also changes along straight edges where the normal alone would not. Its strength is the cube of how squarely that faces the light or faces away from it, at 60% on the far side, over a floor of 14%: the upper left corner is brightest and fades gradually along the top and the left edge, the lower right corner comes back softer, and the outline stays closed everywhere, on a tile as on a panel. The highlight has no colour of its own: it mixes the glass at that pixel 78% of the way toward the same colour at full brightness and 1.3 times its saturation, so it glows red-orange over red, warm over sand and grey-beige over fog, and only the brightest spot of a lit corner takes about a tenth of white on top. It never reads as a drawn stroke, and over light backdrops the glass turns up to 18% darker and that much more saturated just inside it where the highlight is weak, so the shape still reads. Edges that lie against the screen edge get no rim, so the full-width taskbar keeps its plain outline. Where the glass grazes the view, toward the outline of the surface and of each lens, it brightens toward white the way Fresnel reflection does, by Schlick’s (1 − cos θ)⁵ at the bezel’s slope, up to 30%.

Controls inside a Rina surface are glass too. shell_blur_effect_add_lens names a descendant of the surface, such as a quick settings tile, a notification group or Gust’s search field, and the surface’s own pass gives up to 16 of them a smaller bezel and rim of their own, shaped by their style’s corner radius, placed where the control is painted and clipped to the scroll view it sits in. A control’s lens and rim fade in over one device pixel at its outline, at any scale, so its corners are as smooth as the fill drawn over them, and Rina cuts its own surface’s corners over one device pixel too. A control costs the pass one bounds test per pixel and nothing else; the other materials ignore lenses.

Every pixel of Rina glass reads the unblurred backdrop three times, once per colour, and the blur once for the frost, where the blur shows; the lens and the light are arithmetic on the outline the pass already knows. The blur itself is far cheaper than Luca’s at this radius. Rina that blurs only the wallpaper reads a third frosted wallpaper, the wallpaper unblurred at half the monitor’s size, through the same pass and without frost. App glass keeps Luca’s blur, since app text sits on it, and doesn’t bend, since a bend along a long window edge reads as a fault in the glass: Mutter draws the same rim along the window’s rounded edges in the pass that draws its kept blur.

The bend of Rina started from Blur my Shell’s Liquid Glass effect, itself a port of liquid-ass by winaviation, which its author licensed under the GPL 3 for Blur my Shell and anyone who reuses it from there. Its profile and the way its colours spread follow the model of Glisse by Kelvin Zhang.

Clear app icons are glass in whatever material the surface under them shows. The icon asks for a StStyledIcon with layers set, which draws no colour: red holds the plate, green the glyph and blue how far the glyph goes from its shade to its ink. A ShellGlassIcon effect on the StIcon finds the nearest glass under it and calls shell_blur_effect_paint_layer, which draws the icon’s square through copies of that glass’s own pipelines, with the same uniforms and the blur it already made this frame, so Luca, Maris, Niko, Rina and their wallpaper variants all come out right without a blur of their own. A small addition to the copies reads the shapes: the plate, a rounded square known from its corner radius, and the glyph, whose edge and normal come from eight readings around each pixel, each bend what they show outward near their edge, tint it with the plate or ink colour and catch a rim of light from the upper left, and the glyph casts a soft shadow a little below it onto the plate. Over Rina, that bend adds to the lens’s own. An icon costs one draw the size of the icon, whatever the material. Away from glass, or over glass that is turned off, the effect paints the same shapes flat in the icon’s colours.

The final pass of every glass, shell or app, adds grain to hide banding: ±0.5%, half of that on black, from two lookups of a 64 pixel tile of blue noise (clutter_blur_node_get_grain) at each screen pixel, so it spreads like triangular dither and reads as a matte surface.

The lock screen’s backdrop is a frosted wallpaper of its own, made by LockBackdrop with FrostedWallpaper and stored on disk like the others: blurred with a radius of 90 at a quarter of the monitor’s size, dimmed in the dark style and washed with white in the light one. With lock-screen-fluted in com.lantharos.kestrel it is blurred with a radius of 8 at full size instead, and the blur’s final pass, a ShellBlurEffect made with fluted, draws it through upright ribs 27 logical pixels wide. Each rib samples the wallpaper across about three ribs’ width and mirrors it like a cylindrical lens, splitting red and blue a little toward its edges. The result keeps 85% of the wallpaper’s saturation and maps its lightness into 0.12 to 0.42 in the dark style and 0.72 to 0.94 in the light one, with a thin highlight left of each rib’s middle and shading toward its edges. That shading follows how different the wallpaper is across the rib, so flat areas such as a foggy sky keep only faint seams and don’t read as corrugated metal. All of it happens once, while the backdrop is made, so the lock screen costs one textured quad either way. The session sends the choice to the greeter service with the rest of the login style, and the login screen sets the same key from CurrentStyle for the person it shows.

kestrel_glass_v1 gives a surface with glass a glass object. Through it, an app says whether the glass is the base of a window or a transient surface such as a popover, a menu or a palette, which follows the choice for panels and menus, and can ask for a material instead of the person’s choice:

Preference Gets
user The material people chose for the role, the default
maris Maris, always
luca Luca, which blurs only the wallpaper whenever people’s glass does
niko Niko, which blurs only the wallpaper whenever people’s glass does
rina Rina, which blurs only the wallpaper whenever people’s glass does

The app hears which material its glass has through the material event, sent when the object is created and whenever it changes. Over Maris and Niko it draws no tint of its own, since they already are the whole surface; over Luca and Rina it does. Apps that speak only ext_background_effect_v1 get the person’s choice for app windows. Sabine speaks the protocol for its windows; Luft’s apps set it through GlassWindow’s backdrop, see Writing apps.

While something listens to pointer-shaken, the cursor tracker follows the pointer’s relative motion, or its position for devices without it. A stroke counts when it covers at least 40 logical pixels at 500 pixels a second or more and its ends lie at least 80% of the path apart, so arcs and circles don’t count. A turn is a reversal of more than 120° after at least 6 pixels, and once three counted strokes have turned within 600 ms, every further turn emits the signal. A pause of 100 ms, a sideways turn or a stroke that doesn’t count starts over. Motion is ignored while a button is held, the shell holds a grab, a window is moved, an app locks or confines the pointer, or the pointer is hidden.

meta_cursor_tracker_set_magnification() multiplies the pointer’s size and hotspot. Theme cursors load at the next whole multiple of the display scale times the magnification, so they are only scaled down, and each size is loaded once. The hardware cursor carries the larger pointer while it fits the cursor plane; beyond that, and for app cursors in GPU buffers, the cursor overlay draws it, redrawing only where the pointer was and is. The shell eases the magnification up to 4×, at most 128 logical pixels and at least 1.5×, holds it while the signal keeps coming and eases back 600 ms after the last. Pressing Ctrl, when people turned that on, plays the same enlargement once.

patches.py shake replays generated traces through the detector: mouse, touchpad and elliptic shakes have to count, swipes, circles, slow drawing, an overshoot, a tremor and scanning back and forth across the screen must not.

Terminal window
python3 kestrel/compositor/patches.py prepare # check out upstream and apply the series
# commit changes in kestrel/run/mutter-source
python3 kestrel/compositor/patches.py export # write the committed stack back to patches/
python3 kestrel/compositor/patches.py check # replay the series and compare trees
kestrel/compositor/build.sh

Keep each patch focused, with ordinary commits, fixups and rebases. prepare refuses to replace a checkout with uncommitted or unexported work, and keeps the previous head at refs/kestrel/previous; status shows the state of the checkout.

patches.py identity builds the series’ process identification against packages/identity/sandbox-cases.ini, the cases Luft’s own services are tested against too, so Mutter and the services judge every process alike. After a patch changes API the shell uses, regenerate Kestrel’s types.

patches.py trial latest shows beforehand which patches the new release already carries and which will conflict. Drop the patches whose change is in the release, then rebase the rest:

Terminal window
source_dir=kestrel/run/mutter-source
old_base=$(python3 -c 'import json; print(json.load(open("kestrel/compositor/upstream.json"))["revision"])')
new_tag=51.1
git -C "$source_dir" fetch origin "refs/tags/$new_tag:refs/tags/$new_tag"
git -C "$source_dir" rebase --onto "$new_tag" "$old_base" kestrel
# resolve conflicts, then git rebase --continue
python3 kestrel/compositor/patches.py export --base "$new_tag" --version "$new_tag"
python3 kestrel/compositor/patches.py check
kestrel/compositor/build.sh

The pinned base only changes when both --base and --version are given, and git rebase --abort restores the old stack. A Mutter ABI change also needs the engine build and the session’s library paths updated.

Every carried change costs work on each upstream release, and Fedora moves to new GNOME releases on its own schedule, so each change should either be on its way upstream or have a clear reason to stay.

Every Mutter patch has an Upstream-Status trailer in its commit message, so the status travels with it through rebases and exports:

Status Meaning
upstream URL The merge request or commit upstream that carries it, merged or still open, with an optional note
forwardable Nothing in it is specific to Luft, with an optional note on what to drop first
luft-only REASON Stays with Luft, with a short reason, such as an API only Kestrel’s shell uses
Terminal window
git commit --trailer "Upstream-Status: forwardable"
python3 kestrel/compositor/patches.py list # every patch's status and the totals
python3 kestrel/compositor/patches.py trial main latest

prepare, check and export refuse a patch without a valid status. trial applies the series to the given branches or tags, skips what doesn’t apply, and says which patches apply, need a 3-way merge, are already there or conflict. kestrel/compositor/upstream holds forwardable patches prepared as merge requests, one folder each, with the patches rebased onto Mutter’s main branch and a description.md. Once one is open, its patch’s status becomes upstream with the link, and the folder goes when it merges.

The engine in kestrel/engine started as GNOME Shell’s C code at the commit in kestrel/engine/upstream.json, and most files under src keep their GNOME Shell paths, so fixes to them can come over:

Terminal window
python3 kestrel/engine/upstream.py changes # GNOME Shell main, or a tag such as 52.0
python3 kestrel/engine/upstream.py show COMMIT | git apply -3 --directory=kestrel/engine

Add a commit to picked in upstream.json once it’s brought over or decided against, so it drops off the list. The patched packages in os/image/patches each have a README with the reason for every patch, and os/image/patches/trial.sh tries them on upstream’s main branch.

The Upstream patches workflow runs every Monday: it tries the Mutter series on Mutter main and its newest release, lists GNOME Shell changes for the engine, and tries the image’s patches on their main branches. It reports on the run’s summary page and never fails a build.

libinput ignores a pen’s touchscreen while the pen is near it, but the pens of most 2-in-1s only count as near while almost touching the glass. They leave whenever they lift between strokes, and the hand landing a moment later would tap whatever is under it. So the input thread keeps a short pen session for touches on the pen’s own screen:

Since the pen left A touch that starts… Is
Under 1.5 s, or the pen is near where the side of the hand rests Dropped
Under 1.5 s within 20 mm of that area Held up to 150 ms, then let through as a tap, a drag or a still press, or dropped while it creeps
1.5 s to 4.5 s where the side of the hand rests Held 450 ms, then let through unless the pen came back
Any time in the session within 50 mm of another touch the filter is holding or dropped Dropped, along with any held touch near it
After 4.5 s, on another screen, or anywhere else Let through at once

The area runs from 50 mm behind the tip to 140 mm ahead of it, and from 45 mm above it to 95 mm below, ahead meaning towards the writing hand’s side, which hand in com.lantharos.kestrel.pen sets. The numbers come from recordings in kestrel/tools/fixtures/pen, which the tablet:palm check replays for either hand. A new recording, made with sudo libinput debug-events while writing, becomes a fixture with bun kestrel/tools/pen/convert.ts RECORDING NAME TOUCHES. MUTTER_DEBUG=input logs every touch the filter judges.

Two switches in com.lantharos.kestrel.diagnostics log to the journal (journalctl --user -u kestrel.service): log-direct-scanout, when a display starts or stops showing a window’s buffer directly, and log-variable-refresh, whether a display’s refresh rate follows the window covering it, and why.

Terminal window
gsettings set com.lantharos.kestrel.diagnostics log-direct-scanout true
gsettings reset com.lantharos.kestrel.diagnostics log-direct-scanout