KWin is the compositor and window manager of the KDOS desktop. It owns the display and the input
devices; it places, decorates and draws every window; and it runs the effects, the window switcher,
the global shortcuts and the lock screen. KDOS does not fork it. The kwin port builds Plasma’s own
release, and what makes it KDOS’s is:
kdos-appbox writes for boxes (a box is the container a sandboxed application
runs in; see the glossary).This chapter is the reference for all of that. Read it to find out why a window behaves as it does on KDOS, before changing a KDOS default or one of the patches, or when debugging the compositor. Using windows day to day is in The desktop and the rules KWin is configured to follow are in The window model; everything KWin does that is not mentioned here is upstream’s and is documented by KDE.
Why KDOS patches KWin rather than forking it, and where the line between the two falls, is argued in Decisions.
On KDOS KWin runs only as kwin_wayland, a Wayland compositor. There is no X11 session and no
kwin_x11; X11 programs are served by Xwayland, which KWin starts itself (see
Xwayland).
Two copies run on a machine with somebody logged in:
| Copy | Started by | Command |
|---|---|---|
| The login screen’s | SDDM, from CompositorCommand in /etc/sddm.conf.d/00-kdos.conf |
kwin_wayland --no-global-shortcuts --no-lockscreen --inputmethod plasma-keyboard --locale1 |
| The session’s | startplasma-wayland, through kwin_wayland_wrapper |
kwin_wayland --xwayland with the session’s options |
The login screen’s copy has no global shortcuts, no lock screen and no Xwayland. It starts
plasma-keyboard as its input method, so the greeter has an on-screen keyboard: KWin shows it when
the password field is touched, and the footer’s Virtual Keyboard button shows and hides it for a
mouse. --locale1 takes its keyboard layouts from org.freedesktop.locale1, which
kdos-settingsd serves, so the greeter types in the layout the
machine was installed with; with more than one, the footer’s layout button switches between them.
Both buttons are D-Bus calls to this KWin (org.kde.KWin /VirtualKeyboard, org.kde.keyboard)
on the greeter’s session bus, the one user service the sddm account gets (see
Session).
The session’s copy runs under kwin_wayland_wrapper, which holds the Wayland socket. When KWin
exits with anything but a clean shutdown, the wrapper starts it again, and the session’s clients
reconnect to the new compositor instead of dying with it. After its eleventh crash in a session the
wrapper gives up, the session ends and SDDM’s login screen comes back. The count does not reset with
time, however far apart the crashes come; only a restart KWin asks for itself resets it.
plasmashell is the exception to reconnecting: it exits when its compositor goes away, and the KDOS kded module starts it again a few seconds later (see How plasmashell is kept running).
There is no crash dialog. KDOS builds no crash handler, and the core-file limit is the kernel’s
default of zero, so a KWin crash leaves a line in the session log and the kernel’s
potentially unexpected fatal signal line in /var/log/messages, and no core file. To collect a
core, start the program from a shell that has run ulimit -c unlimited.
KWin asks for real-time scheduling (SCHED_RR, at the lowest real-time priority) for the threads
that read input and commit frames, so a busy machine does not stall the pointer. It is allowed to
by the rtprio 1 limit in /etc/security/limits.d/30-kdos.conf, which pam_limits applies at
every login. Upstream’s install grants the same right through a file capability on the binary,
which does not survive KDOS’s package archive, so the limit is the only route. Without it KWin
logs Failed to gain real time thread priority and composites at normal priority.
The kwin port builds KWin 6.8.2 with its X11 window management on, for Xwayland, and makes each
optional feature KDOS relies on a requirement of the configure rather than something CMake drops
in silence: activities, emulated input through libei (the RemoteDesktop and InputCapture portals,
KDE Connect’s remote input), the zoom’s AT-SPI focus and caret trackers, the handbooks of
the settings pages, screencasting through PipeWire and game controllers through libevdev. Every
flag, and the reason for it, is in the port’s own note,
ports/core/kde/kwin/kfs.md, which KDOS from Scratch
renders as the port’s page; the note is the authority, and this chapter does not repeat it.
KWin’s systemd user unit is removed from the package, since KDOS runs no systemd. KWin is not
linked to a session library either: its build looks for libsystemd.pc, which elogind does not
install, so the systemd watchdog and the systemd sandbox check are compiled out. The only thing
that marks a client as sandboxed is the security-context tag described under
Boxes at the compositor.
The port carries three patches, applied in this order. Each opens with a Subject: line, and the
port’s note describes each in full.
| Patch | Subject | What it does |
|---|---|---|
sandbox-policy.patch |
wayland: deny desktop-shell globals to sandboxed clients unless granted | Widens the set of interfaces a box may not bind, and lets a box’s profile grant named sets back (below) |
sandbox-badge.patch |
Expose a window’s sandbox engine, app id and instance id | Hands the box a window came from to the decoration, so the title bar can mark it (below) |
kdos-crt.patch |
Add the kdos_crt full-screen CRT effect | Builds the CRT pass of Phosphor mode into KWin (below) |
sandbox-badge.patch needs the patches of the same name in the kdecoration and breeze ports;
against an unpatched kdecoration KWin does not compile. The two sandbox patches are offered
upstream. kdos-crt.patch is KDOS’s own and is rebased at every Plasma minor release.
KWin reads its configuration through KConfig’s cascade. For each file the first directory that sets a key wins:
~/.config, where System Settings writes a person’s own choices.~/.config/kdedefaults, where the global theme in force writes its defaults./usr/share/kdos/xdg-vm, put at the front of XDG_CONFIG_DIRS only in a session that runs in
a virtual machine, and /usr/share/kdos/xdg-live, only on the live medium./etc/xdg, which belongs to the machine’s administrator./usr/share/kdos/xdg, KDOS’s defaults.KDOS’s KWin defaults are all in /usr/share/kdos/xdg, the bottom of the cascade, so a setting
changed in System Settings always outranks them, and an administrator overrides one for every
account by setting the same key in /etc/xdg. The two exceptions, both described below, are the
global shortcuts, which KWin reads only from the person’s own file, and the box colour rules, which
kdos-appbox writes into the person’s kwinrulesrc.
kwinrc/usr/share/kdos/xdg/kwinrc sets five things:
| Group | Keys | What they do |
|---|---|---|
[Desktops] |
Number=4, Rows=1, Name_1…Name_4 = main, www, hack, misc, and a fixed Id_<n> for each |
Four virtual desktops in one row. The ids are fixed because KWin restores a window to its desktop by id, and an id generated at each login would scatter a restored session onto desktop 1 |
[TabBox] |
ApplicationsMode=1 |
Alt+Tab lists applications, not windows: one entry per application, its most recent window (KWin’s OneWindowPerApplication) |
[Effect-zoom] |
EnableTextCaretTracking=true |
The zoom follows the text cursor as well as the pointer (Accessibility) |
[Plugins] |
krohnkiteEnabled=false |
The bundled auto-tiler is installed and off (Tiling) |
[Wayland] |
InputMethod=/usr/share/applications/org.fcitx.Fcitx5.desktop |
KWin starts fcitx5 as the session’s input method and restarts it if it dies; nothing else starts it |
Every global theme KDOS ships, one per accent, adds the rest of KWin’s look through
~/.config/kdedefaults when it is applied:
| Group | Keys |
|---|---|
[org.kde.kdecoration2] |
library=org.kde.breeze, theme=Breeze, and no border size, so KWin takes the size Breeze recommends: none. A window has no side or bottom border, and its edges resize through the margins Breeze keeps for the pointer outside the frame |
[WindowSwitcher] |
LayoutName=thumbnail_grid |
[Windows] |
Placement=Centered |
So a window opens centred on the screen and Alt+Tab shows a grid of thumbnails. The title-bar
buttons are KWin’s own arrangement: the window menu on the left, and minimise, maximise and close
on the right. Each global theme’s layout defaults (contents/layouts/defaults in the theme
package) name that arrangement as ButtonsOnLeft=M and ButtonsOnRight=IAX, so applying a global
theme writes them into ~/.config/kdedefaults/kwinrc beside the keys above, and a person’s own
button layout in ~/.config/kwinrc still wins. The global themes are described in
Theming.
The decoration is Breeze’s, configured by /usr/share/kdos/xdg/breezerc:
Square corners and the accent outline are SquareCorners and OutlineHighlight, two keys the
breeze port’s square-corners.patch adds. An inactive window’s outline is Breeze’s usual mix of
the frame and text colours.
The title bar takes its colours from the [Colors:Header] set of the colour scheme in force,
which KWin uses in place of [WM] whenever a scheme has one. The outline takes the window
palette’s link colour, which every KDOS scheme holds at the accent itself (the selection colour is
darker on a dark accent, so it cannot serve). Both therefore follow all eight accents with nothing
regenerated, and a window rule that forces a colour scheme on one window (a box’s colour,
below) tints that window’s title bar the same way. When Breeze cannot be loaded
KWin falls back to Aurorae, so a window keeps a frame.
AnimationDurationFactor=0.5 in the distribution’s kdeglobals makes every KWin animation half
KDE’s length. 0 turns animation off, which every KDOS effect honours as reduced motion. The
Animation speed slider in System Settings writes the same key to ~/.config/kdeglobals.
KDOS keeps KDE’s default chords, gives three of them a different job, and adds chords KDE leaves free:
| Chord | Does | KDE’s default |
|---|---|---|
| Meta+Q | Close the window, beside Alt+F4 | The activity switcher, which KDOS ships no interface for |
| Meta+F1, Meta+/ | The key card (below) | Meta+F1 switches to desktop 1, which keeps Ctrl+F1 |
| Meta+Space | KRunner, beside Alt+Space, Alt+F2 and the Search key | — |
| Meta+Return | Konsole, beside Ctrl+Alt+T | — |
| Meta+Shift+T | Turn auto-tiling on or off | — |
| Meta+Ctrl+Shift+N | Night Light on, warm at once and all day, or off: kdos toggle night-light |
— |
| Spectacle on the whole screen | — | |
| Shift+Print | Spectacle on a rectangle, beside Meta+Shift+Print and Meta+Shift+S | Spectacle’s whole desktop |
| Alt+Print | Record a rectangle, beside Meta+Shift+R and Meta+R | — |
| Meta+Shift+M, E, B, U, C, G, W | Run or raise a terminal program (below) | — |
Meta+Shift+T and Meta+Ctrl+Shift+N are desktop entries in /usr/share/kglobalaccel/, installed by
kdos-tools, so each is a kdos verb with a key; KWin’s own Suspend/Resume Night Light action
stays without one. Phosphor mode has no chord. The eight chords the bundled auto-tiler would claim
(Meta+L, Meta+D, Meta+T, Meta+., Meta+I, Meta+R, Meta+Shift+R and Meta+Return) are bound to
nothing for it, so turning tiling on can never take the lock key, the terminal key or System
Settings’ key from the session; a person binds any of them on the Shortcuts page.
KGlobalAccel, which lives inside KWin, reads only ~/.config/kglobalshortcutsrc and never a copy
in an XDG directory. KDOS’s chords are kept in /usr/share/kdos/xdg/kglobalshortcutsrc, and
/usr/share/kdos/xdg/plasma-workspace/env/kdos-shortcuts.sh, which startplasma sources before
KWin starts, copies each entry into the person’s file once:
$XDG_STATE_HOME/kdos/kglobalshortcutsrc.seeded, so a chord a person resets to KDE’s default
stays reset at the next login.kglobalshortcutsrc in /etc/xdg is read as a layer above KDOS’s, so an administrator can
change a chord for every new account.Every chord KDOS ships passes testing/chordcheck.py, which holds it against KDE’s compiled-in
defaults, every installed desktop entry’s X-KDE-Shortcuts and fcitx5’s hotkeys. A script that is
off but named under [Plugins] in a KDOS kwinrc, as the auto-tiler is, counts as KDOS’s: a chord
it would take from a binding already in force fails the check until the shipped
kglobalshortcutsrc unbinds it.
A new account’s first login runs every upgrade step KDE ships for kconf_update, KDE’s
configuration-migration tool, while KWin and plasmashell are already running. Two of those steps
would undo what that same login sets up:
kwin-6.1-remove-gridview-expose-shortcuts deletes the Present Windows actions to drop
Plasma 5’s keys. Run at a first login, it deletes the actions the Window View effect has just
registered, so Meta+F9, Meta+F10 and Meta+F7 would do nothing until the next login.migrate-calendar-plugins empties and rewrites the panels file in the same
second as the desk’s first layout, and plasmashell can save over it, leaving the panels without
the settings the desk wrote (see How a desk is laid out)./usr/share/kdos/xdg/kconf_updaterc records both steps as already done. kconf_update reads its
record along XDG_CONFIG_DIRS, so no account runs them, and a new account has nothing either step
would migrate.
fcitx5, the input-method framework, would otherwise switch input-method groups on Meta+Space, the
KRunner chord. /etc/xdg/fcitx5/config moves that switch to Meta+Alt+Space (and
Meta+Alt+Shift+Space backwards). KWin sees a chord before any application does, so without the move
fcitx5’s switch would stop working with no message.
The key card is a full-screen, searchable list of every global shortcut the session holds, grouped into Windows, Desktops, Launch, KDOS, Accessibility and System.
An action with several keys lists them in the same order in every session: its default keys
first, then the chord with fewer modifier keys (Meta, Ctrl, Alt, Shift, Num; the Plus key is a
key, so Meta++ has one modifier), then plain text order, which does not depend on the language.
The spoken “kwin-effect-kdos-keys, a KWin effect written in QML and installed to
/usr/share/kwin/effects/kdos_keys/.
Each time it opens it asks kglobalacceld over D-Bus for every component’s shortcuts with their
current keys, so a chord changed on the Shortcuts page is on the card the next time it opens. The
grouping is groups.conf, a table of component and action patterns read top to bottom and
compiled into the card at build time; the same table is installed as
/usr/share/kdos/keycard-groups.conf so kdos help --keys prints the chords the way the card
groups them. The build, and testing/selftest.sh, fail when a chord KDOS ships falls only to the
table’s fallback group.
kglobalacceld keeps reporting a KWin script’s keys after the script is unloaded. The card asks KWin which scripts are loaded each time it opens and leaves out the rows of one that is off, so the auto-tiler’s keys appear only while tiling is on. kglobalacceld sends only the first key of a multi-key sequence, so a sequence such as Meta+K, Meta+L shows as Meta+K. A QML effect loads whatever the renderer, so the card opens under software rendering too.
kwin-script-kdos-runraise gives seven terminal programs a key each. The key raises the program’s
window when one is open and opens one in Konsole when none is; pressed again from one of its
windows, it moves to the next.
| Key | Program |
|---|---|
| Meta+Shift+M | mc, files |
| Meta+Shift+E | aerc, mail |
| Meta+Shift+B | lynx, the web |
| Meta+Shift+U | rmpc, music |
| Meta+Shift+C | ikhal, the calendar |
| Meta+Shift+G | iamb, chat |
| Meta+Shift+W | micro, the editor |
Konsole gives every window the same application id, org.kde.konsole, so the script finds a
program’s window by its caption instead. It opens a window with
konsole --hold -p tabtitle=<program> -e <program>, and it also matches Konsole’s own
<dir> : <program> title, so a window opened some other way is found too.
--hold keeps the window open after the program exits. A program that cannot start (rmpc with no
MPD music server running, iamb with no configuration) therefore leaves its error on screen. A
window held after a normal quit keeps its caption, and the key raises it until it is closed.
A KWin script cannot start a program, so each program has a desktop entry with no key of its own
in /usr/share/kglobalaccel/, and the script opens a window by invoking that entry’s _launch
action. On System Settings’ Shortcuts page the entries are listed as “
Only lynx is on the installation medium. The other six install with
sudo kdos update install mc aerc rmpc khal iamb micro; ikhal comes with khal. Until a program
is installed its key opens a Konsole window titled after the program and holding a shell: Konsole’s
“could not find” line comes before the shell’s greeting, which scrolls it out of view.
On Wayland a program cannot place its own window. kwin-script-kdos-window-memory, on by default,
makes a program’s window open where its last one closed, at the same size, and maximised if it
closed maximised. It keeps one place per application id, at most 200, in
$XDG_STATE_HOME/kdos/window-memory, written through a temporary file and a rename.
What it records is the rectangle the window floats at. It reads a window’s maximised and full-screen state only after the commit that carries it, because KWin reports the new frame before it updates that state.
It leaves these windows alone:
Exclude
replaces the list).A window rule that forces a position always wins.
When it restores a window:
For a window it has no record of:
The size a window closes at is recorded, so a size the person picks wins from the next launch on.
kwinrc [Script-kdos_window_memory] |
Default | Effect |
|---|---|---|
Exclude |
built in | A comma-separated list of application ids that replaces the built-in list |
RememberDesktop |
false |
Also move a window back to the virtual desktop it closed on |
The script is turned off on System Settings’ KWin Scripts page.
Windows float. Dragged to a screen edge a window takes half the screen, dragged to a corner a quarter, and Meta+T opens KWin’s tile editor, where each virtual desktop keeps its own layout of custom tiles. All of that is KWin’s own and on by default.
Automatic tiling is Krohnkite, a KWin script from the krohnkite port, installed and off
([Plugins] krohnkiteEnabled=false). Three things turn it on or off, and all three write the same
key and ask KWin to reconfigure, which loads or unloads the script:
kdos tiling on|off|toggle, and Meta+Shift+T, a desktop entry in /usr/share/kglobalaccel/
that runs kdos tiling toggle.kdos desk tiling turns it on, and the other two desks turn it off
(The desks).A boxed application’s windows reach KWin through a Wayland socket that tells KWin which box they
came from. The box’s launcher runs kdos-boxsock, which binds a socket in the box’s private
runtime directory, $XDG_RUNTIME_DIR/kdos/box/<box>/, and registers it with KWin through the
wp_security_context_v1 protocol: the launcher’s id as the application id, the box as the
instance id, and the engine io.kdos.appbox+private or io.kdos.appbox+tagged. Every client that
connects on that socket is tagged by KWin itself and never sees the tag, so it cannot drop or
forge it.
The engine’s suffix records which boundary held for the launch. +private is a confined box: its
private runtime directory holds no session Wayland socket (wayland-1), no unfiltered session bus
(the box gets a filtered proxy of it instead) and no X11 display, so the tagged socket is the only Wayland socket the boxed program can reach. +tagged is a box
whose windows carry the tag but which has some other way past it. A launch that cannot get the
tagged socket at all is refused with the reason rather than started untagged. kdos-boxsock is
described in
The daemons and the launch path in
kdos-appbox.
KWin gives every window of a tagged client the tag’s application id as its own, unless the
window’s id already starts with it. That is how the Task Manager and the application menu match a
boxed window to its launcher, app.<id>.desktop, which kdos-appbox genlaunchers writes.
Upstream KWin refuses a tagged client seven interfaces: window management
(org_kde_plasma_window_management), fake input, screencasting, activation feedback, the
lock-screen overlay, data control (clipboard managers’ access to every clipboard) and the
security-context manager itself. sandbox-policy.patch also refuses it the layer shell, output
management and external brightness, DRM leases, DPMS, the Plasma shell surface, screen edges, the
keyboard state and virtual-desktop management: interfaces through which a program reaches the rest
of the desktop rather than its own windows.
A box gets named sets of them back through the grant key of its profile,
~/.config/kdos/boxes/<box>.conf, which KWin reads once per client for the engine
io.kdos.appbox (with any +<state> suffix) and no other:
| Grant | Opens |
|---|---|
window-list |
Window management (the list of every window, and acting on them), activation feedback and virtual-desktop management |
fake-input |
Emulated pointer and key events |
screencast |
Streaming outputs and windows |
data-control |
Every clipboard, as a clipboard manager sees it |
layer-shell |
Panels, docks and overlays |
output-management |
Changing the displays’ modes and layout, their brightness, and DRM leases |
dpms |
Turning displays off and on |
plasma-shell |
Plasma’s shell surface, which places a window anywhere, screen edges and the keyboard state |
input-method |
Nothing: the input-method interfaces stay with the input method KWin starts |
The security-context manager and the lock-screen overlay are never granted. A box granted
fake-input or window-list can act on the whole desktop, which is what the grant is for. The
profile file and the rest of its keys are in kdos-appbox, and System Settings’
Boxes page edits it. What the tag does and does not protect is in
The security model.
sandbox-badge.patch gives each window three constant properties read from its client’s security
context, sandboxEngine, sandboxAppId and sandboxInstanceId, and hands them to the decoration.
Breeze, with its own patch, draws a small box before the caption of a sandboxed window, in the
caption’s colour:
| Engine suffix | Badge |
|---|---|
+private |
A solid box: the box’s private runtime directory held |
+tagged |
A dashed box: only the tag held |
+unconfined |
A warning triangle, drawn for any engine ending +unconfined. Nothing on KDOS registers one: kdos-appbox refuses a launch it cannot tag |
A window with no security context has no badge. An X11 window always reads as unsandboxed,
because its surface belongs to Xwayland. The Task Manager’s tooltip names the
box as well (“In box: www”), from the plasma-workspace and plasma-desktop patches of the same
name, which read the launcher’s X-KDOS-Box key.
A box’s colour is its security domain. For each box, kdos-appbox writes one window
rule into ~/.config/kwinrulesrc, a group named kdos-box-<box>, which matches every window whose
application id is <box> or <box>.<stem> and forces decocolor to the colour scheme
KDOS<Accent> of the box’s colour, or KDOSBox for a box with none. The title bar of a
window KWin decorates (a server-side-decorated window) then wears that colour.
KDOSBox is grey, with title bars lighter than any accent’s: 36% of the way from its background
to its text when active and 28% when inactive, where an accent’s sit at 7% and at its deep shade.
The default accent is itself nearly grey, so a neutral box at an accent’s own mix would look like a
host window. kdos-theme refuses to write a KDOSBox whose title bars measure under 1.5:1 contrast
against any accent’s.
A program that draws its own title bar (a client-side-decorated window) takes no decoration colour, and KWin 6.8 has no rule that outlines such a window instead.
Only the kdos-box-* groups are kdos-appbox’s: every other rule in the file, including the
person’s own, is kept as it was, and KDOS’s rules are listed after the person’s. A new account’s
kwinrulesrc comes from /etc/skel with the rules for the boxes the medium carries.
Phosphor mode makes the screen look like a CRT in the current accent: a pass over every output,
CRT motion for windows, the login, the lock screen and logout, and with the bone or paper accent a
switch to the phosphor accent. It is off for every new account and has no chord. kdos phosphor
on, the Look page of the welcome tour and System Settings’ KDOS Look
page turn it on; kdos phosphor off puts back every key it changed, as the person’s own file had
it. The command is described in The kdos command, and what the mode changes in
the rest of the look in Theming. Why it is opt-in is in
Decisions.
Phosphor mode needs GPU rendering. Under a software renderer (llvmpipe, softpipe, the Software
Rasterizer) the CRT pass refuses to load, kdos phosphor on refuses before it writes anything, and
the welcome tour’s switch is disabled with the reason. A virtual machine with a plain display
renders in software; make run-hw and the rig’s --gl run KWin on the host’s GPU.
kdos_crt is a built-in effect that kdos-crt.patch adds to KWin. It paints each output into an
offscreen texture and draws it back through one fragment shader:
It is built in rather than shipped as a plugin because KWin refuses an effect built outside it against any other KWin release, point releases included, while a built-in effect is a static plugin it never checks.
kwinrc [Effect-kdos_crt] |
Range | Default | subtle |
retro |
|---|---|---|---|---|
Strength |
0–100 | 55 | 55 | 55 |
Scanlines |
0–100 | 0 | 0 | 60 |
Curve |
0–100 | 0 | 0 | 30 |
Fullscreen |
true, false |
false |
A preset is only a set of values for the three numbers; nothing stores which one was picked.
kdos phosphor preset subtle|retro writes them, and the effect’s own settings page,
kwin_kdos_crt_config, shows whichever preset the values match, or Custom. The effect is on when
[Plugins] kdos_crtEnabled=true.
The pass decides per output and per frame. qdbus6 org.kde.KWin /Effects debug kdos_crt prints its
state and each output’s last verdict:
| Verdict | Meaning |
|---|---|
pass |
The frame went through the shader |
capture |
A screenshot, a screencast or the colour picker: these get the plain picture, so a capture keeps true pixels |
off |
The effect is not running on this output |
refused (hdr) |
An HDR output: the shader’s arithmetic assumes white at 1.0 |
exempt (fullscreen) |
With Fullscreen=false, the active window is full screen on this output, which goes back to direct scanout, so a game or a video keeps it |
aside (zoom) |
Zoom or the magnifier is on: a magnified picture is read without scanlines |
cooldown |
A run-time failure put this output on the plain picture for a while, 5 seconds doubling to 60 and reset by a frame that passes |
While the pass runs on an output, that output gives up direct scanout and the hardware cursor plane: the pointer is drawn into the picture and curves with it, and every frame is composited whole. That is the mode’s cost in power and latency.
The effect also moves the whole screen:
| Motion | When | Length |
|---|---|---|
| Degauss | The colour scheme’s accent changes | One pulse of at most 400 ms, never more than three a second |
| Collapse | The session locks or quits | About 350 ms to a bright line, then 100 ms to a dot |
| Unfold | The lock screen comes up, or a collapse is undone | The collapse, backwards |
Nothing the effect does may leave a session black. After a collapse the screen stays dark only
until a deadline (2 seconds for a lock, 30 for a logout, 10 for a collapse asked for over D-Bus),
and then the picture comes back whatever is on it. A stronger hold replaces a weaker one and never
the reverse, so a lock during a logout cannot unfold the logout. AnimationDurationFactor=0 turns
off the degauss and the collapse; the still pass is not motion and stays.
The power-down is exported as io.kdos.Crt1 at /io/kdos/Crt1 on the session bus name
org.kde.KWin, with the methods Collapse, Unfold and Degauss and the property Phase
(live, collapsing, dark or unfolding). kdos phosphor collapse|unfold|degauss calls them.
kdos-kwin-motion holds three KWin effects written in JavaScript, each a package under
/usr/share/kwin/effects/:
| Effect | Does | Replaces |
|---|---|---|
kdos_unfold |
A window opens out of a hairline across its middle, and closes by folding to a line and pinching to a dot | Scale, Fade and Glide step aside for it, because it takes each window’s open and close grabs |
kdos_login |
When KSplash closes, the desktop opens out of a line across the splash, with a hot seam on the edge of the opening | KWin’s login |
kdos_quit |
While the session quits, each window folds away, and the desktop is held on screen until KWin exits | KWin’s sessionquit |
All three are switched on and off with the CRT pass by kdos phosphor, which also turns KWin’s
login and sessionquit off while the mode is on. They are switched on only after kdos_crt has
loaded, which also refuses a software renderer by name, so they are seen only with GPU rendering.
Every duration goes through KWin’s animation time, so AnimationDurationFactor scales it. A
scripted effect has no tie to KWin’s C++ interface, so a KWin release does not break them: a change
in the scripting interface shows as a script error in the session log and a window that opens
without the motion.
KWIN_KDOS_CRT_DUMP=<prefix> in KWin’s environment writes the pass’s input and output once, as
<prefix>-in.png and <prefix>-out.png; KWIN_KDOS_CRT_DUMP_FRAME=<n> waits for the n-th passed
frame. The variable is read only from KWin’s own environment, so no client can use it to capture
the screen. KWIN_EFFECTS_FORCE_ANIMATIONS=1 lets the effect load on a software renderer, for a
test and nothing else.
KWin draws the lock screen; kscreenlocker decides when, PowerDevil decides when the screen dims and turns off, and elogind owns suspend and the lid.
| Event | Default | Set in |
|---|---|---|
| The screen dims | 5 minutes idle, on mains power | /usr/share/kdos/xdg/powerdevilrc, [AC][Display] |
| The screen locks | 10 minutes idle, with a 5-second grace in which a key or a move unlocks without a password | /usr/share/kdos/xdg/kscreenlockerrc, [Daemon] |
| The screen turns off | 15 minutes idle, on mains power | powerdevilrc |
| On battery | PowerDevil’s own shorter timers | — |
| After a resume | The screen is locked | kscreenlockerrc, LockOnResume=true |
| Meta+L | Locks now | KDE’s default |
In a virtual machine /usr/share/kdos/xdg-vm turns off the timed lock, both screen timers, idle
suspend and the lid’s suspend, because a guest that locks, blanks or sleeps reads from outside as
one that has stopped; Meta+L and lock-on-resume still lock. PowerDevil’s own virtual-machine check
asks systemd’s manager on the system bus, which KDOS does not run, so without these keys it would
sleep a guest after 15 idle minutes like bare metal. On the live medium /usr/share/kdos/xdg-live
turns the timed lock off. Both set the lock timeout to zero as well as turning auto-lock off, so
System Settings → Screen Locking reads “Never” there.
The lock screen’s layout is the Plasma shell’s own. Its clock and media controls are shown, and its
wallpaper is the accent’s, which kdos theme moves while it still names a KDOS-* wallpaper. A
password is checked through the PAM service kde, which includes the system’s system-auth stack;
a fingerprint through kde-fingerprint. The lid’s action, suspend and the inhibitor PowerDevil
takes are elogind’s and PowerDevil’s, configured as
Administration describes.
The accessibility aids are KWin’s own plugins and System Settings’ Accessibility page: zoom and the
magnifier, sticky, slow and bounce keys, mouse keys, dwell click, colour-blindness correction and
colour inversion. KWin’s zoom follows the pointer and, through [Effect-zoom]
EnableTextCaretTracking=true in the shipped kwinrc, the text cursor, which it learns
from the input method’s text-input protocol. It does not follow the keyboard focus: on Wayland KWin
leaves its AT-SPI focus and caret trackers off unless KWIN_WAYLAND_ZOOM_FORCE_LEGACY_FOCUS_TRACKING
or KWIN_WAYLAND_ZOOM_FORCE_LEGACY_TEXT_CARET_TRACKING is set in its environment, because their
blocking D-Bus calls can stall the compositor. Colour inversion’s Meta+Ctrl+I and Meta+Ctrl+U work
once the Invert effect is turned on under Desktop Effects; it is off by default. The on-screen keyboard is chosen on
the Virtual Keyboard page; KDOS’s default input method is fcitx5, which KWin starts (see
kwinrc).
Phosphor mode stands aside while zoom or the magnifier runs, and the welcome tour does not offer it while a screen reader or a magnifier is on. How the desktop reads aloud and what a boxed application’s assistive stack sees is in Accessibility.
KWin starts Xwayland the first time an X11 client connects, and gives it DISPLAY. No X server runs
before that, and the login screen’s copy of KWin starts none. KWin listens on the display’s sockets
in /tmp/.X11-unix, which it does not create: rcS makes it at boot, root-owned with mode 1777
(see Mount points that must be right),
and without it KWin starts no Xwayland and the session has no DISPLAY. Before it takes the X11
window-manager selections, KWin runs every file in /etc/xdg/Xwayland-session.d with DISPLAY set,
in name order, and then plasma-workspace’s plasma-setup-xwayland. An X11 window is managed like
any other, but its surface is Xwayland’s, so it carries no box tag and no sandbox badge; how an X11
program in a box is given a display is in kdos-appbox. Why Xwayland is the only X
server is in Principles.
| What | How |
|---|---|
| The log | KWin writes to the session’s standard error, which SDDM keeps in ~/.local/share/sddm/wayland-session.log |
| Everything KWin knows about itself | qdbus6 org.kde.KWin /KWin supportInformation: version, compositing backend and renderer, every option, loaded effects and scripts, outputs |
| Windows, surfaces and input as KWin sees them | qdbus6 org.kde.KWin /KWin showDebugConsole |
| One effect’s state | qdbus6 org.kde.KWin /Effects debug <effect>, for example kdos_crt |
| Frame rate | qdbus6 org.kde.KWin /Effects org.kde.kwin.Effects.loadEffect showfps, and unloadEffect showfps to take it away; KWin marks the effect internal, so Desktop Effects does not list it |
| A loaded KWin script | qdbus6 org.kde.KWin /Scripting isScriptLoaded <id> |
| Restart the compositor without logging out | kwin_wayland --replace from a terminal in the session, or qdbus6 org.kde.KWin /KWin replace; the wrapper keeps the socket and every window reconnects |
A KWin that keeps crashing ends the session at its eleventh crash; the session log and the kernel’s
fatal signal lines in /var/log/messages are the record. Whether the session renders on the GPU is in supportInformation’s compositing
section, and it decides whether Phosphor mode can run.
The three patches live beside the recipe in ports/core/kde/kwin/. A Plasma minor release is the
moment they are rebased: unpack the new tarball, apply each with patch -p1, fix what does not
apply, regenerate the patch and keep its Subject: header. The kdecoration, breeze,
plasma-workspace and plasma-desktop sandbox-badge patches move with sandbox-badge.patch.
Rebuild with make build BUILD_ARGS="--phases 50_desktop --rebuild kwin".
KDOS’s own KWin plugins are ports under src/desktop/: kdos-kwin-motion,
kwin-effect-kdos-keys, kwin-script-kdos-runraise and kwin-script-kdos-window-memory. They are
JavaScript and QML packages, so a KWin release rebuilds none of them; their QML tests run under
testing/plasmatest.sh in the development container, which also installs every KWin package with
kpackagetool6 into a scratch root. testing/quick.sh puts a rebuilt package onto a booted ISO
and restarts what reads it: KWin is replaced for a compiled effect, a QML effect or a QML script,
because a loaded plugin or QML type is never reloaded in place, and a JavaScript effect or script
is unloaded and loaded again. Writing a new effect, script or other desktop component is in
Writing desktop software.
Part IV — Programs, chapter 21. Previous: 20. The programs · Contents · Next: 22. The Plasma shell