KWin

On this page 7

KWin is the window manager and compositor of the KDE Plasma workspace, responsible for placing, decorating and drawing application windows and for handling input on the Linux desktop. On X11 it runs as a compositing window manager on top of the X.Org Server, while in a Wayland session it is the display server itself, talking directly to the kernel graphics and input subsystems.

KWin is one of the most feature-rich compositors in the free desktop ecosystem. It combines traditional stacking window management with scriptable tiling, a large set of visual effects, multi-monitor handling with fractional scaling, and support for modern display features such as variable refresh rate and HDR output.

How KWin works as a Wayland compositor

In a Wayland session, KWin owns the screen, the keyboard and the pointer. It opens the graphics devices through DRM and KMS, the kernel mode-setting interfaces, receives input events through libinput, and renders the final image of all windows with OpenGL or a software fallback. Applications draw into their own buffers and hand them to KWin, which composites them into one frame and schedules page flips in step with the display refresh.

Because KWin is the only process that sees every window, it enforces security boundaries that X11 never had. A Wayland client cannot read the contents of other windows or inject keystrokes into them. Screen capture and remote input therefore go through xdg-desktop-portal and PipeWire, where the user grants permission explicitly.

Legacy X11 applications still run through XWayland, an X server that KWin launches on demand and manages as a special client. KWin also implements many Wayland protocol extensions, both standard ones from freedesktop.org and KDE-specific ones used by the Plasma shell for panels, notifications and window thumbnails.

The following table summarizes the main components that KWin coordinates in a Wayland session.

ComponentRoleInterface
DRM and KMSMode setting and page flipsKernel graphics API
libinputKeyboard, pointer and touch eventsInput library
OpenGL rendererComposites window buffersEGL and GBM
XWaylandRuns legacy X11 clientsX11 protocol
Plasma shellPanels, desktop and launchersKDE Wayland protocols
PipeWire portalScreen sharing and capturexdg-desktop-portal
Main components of a KWin Wayland session

KWin on X11 compared with KWin on Wayland

KWin historically began as an X11 window manager and later added compositing; the Wayland mode became the default session of Plasma 6. KDE has since split the code into kwin_wayland and a separate kwin_x11 package, so the two modes now evolve at different speeds, with new features landing primarily on Wayland.

AspectKWin on X11KWin on Wayland
Display serverX.Org ServerKWin itself
Mixed DPI monitorsOne global scalePer-output fractional scaling
Variable refresh rateLimited, single screenPer output
HDR and color managementNot supportedSupported on capable outputs
Window isolationClients can spy on each otherClients are isolated
Crash behaviorApplications survive a restartApplications reconnect if supported
Development focusMaintenanceActive development
Differences between the X11 and Wayland modes of KWin

The crash behavior row matters in practice. On X11, a KWin restart only removes decorations briefly. On Wayland, a compositor crash used to terminate every application, but Qt and KDE applications now support automatic crash recovery, reconnecting to a restarted KWin without losing their state.

Window management, effects and scripting

KWin is a stacking window manager at its core, with overlapping windows, focus policies, virtual desktops and per-window rules. Window rules let an administrator force properties such as position, size, desktop, opacity or a missing title bar for windows that match a class or title, which is useful for kiosks and multi-monitor workstations.

Visual behavior is implemented as effects, such as Overview, wobbly windows, blur behind translucent panels, zoom and color filters for accessibility. Effects are written in C++ or as QML and JavaScript effects, and many are optional. KWin scripts in JavaScript or QML can react to window events and rearrange windows, which is how community projects add dynamic tiling layouts on top of the built-in quick tiling and custom tile editor.

  • Quick tiling snaps a window to a half or quarter of the screen.
  • Custom tile layouts divide each screen into user-defined zones.
  • Window rules store per-application overrides in kwinrulesrc.
  • Scripts and effects are installed per user or system-wide.

How KWin compares with other compositors

KWin occupies a position between minimal tiling compositors and the more restrained design of GNOME. It exposes many settings and extension points, while Mutter, the GNOME compositor, keeps configuration minimal and moves customization into shell extensions.

CompositorDesktopWindow modelConfiguration style
KWinKDE PlasmaStacking with tiling aidsGUI settings, rules and scripts
MutterGNOMEStackingMinimal, extensions via GNOME Shell
SwayStandaloneManual tilingText file compatible with i3
HyprlandStandaloneDynamic tilingText file with animations
cosmic-compCOSMICStacking and auto-tilingGUI settings
KWin compared with other Linux compositors

For users who want tiling without leaving Plasma, KWin scripts are the practical route. For users who prefer a keyboard-only environment configured entirely in text files, a dedicated tiling window manager such as Sway usually fits better.

Troubleshooting and practical configuration

Most KWin problems trace back to graphics drivers, scaling or effects. KWin provides diagnostic tools that make the cause visible: qdbus org.kde.KWin /KWin supportInformation prints the active backend, renderer, outputs and loaded effects, and the KWin debug console shows windows, input events and Wayland surfaces live.

SymptomLikely causeTypical fix
Blurry X11 applicationsXWayland apps scaled as bitmapsLet legacy apps scale themselves
Stutter on high refresh screensDriver or VRR conflictUpdate drivers, test VRR per output
Black screen after loginOpenGL initialization failureCheck the journal, try another driver
Global shortcut ignoredApplication expects X11 grabsUse the portal or KDE shortcut settings
High compositor CPUHeavy effects or software renderingDisable blur, verify the GPU renderer
Common KWin symptoms, causes and fixes

Configuration lives in plain files such as ~/.config/kwinrc, so changes can be deployed by configuration management across many workstations. After editing them, qdbus org.kde.KWin /KWin reconfigure applies the settings without logging out.

Understanding it simply

KWin is the part of the KDE Plasma desktop that arranges and draws all the windows you see. When you drag, resize, minimize or switch a window, KWin does the work and decides what appears on the screen.

Think of it as a stage manager in a theater. Each application is an actor that prepares its own costume, but the stage manager decides where everyone stands, who is in front, and how the lights look. Without KWin, the applications would still run, but nothing would put them neatly on the screen.

Applied in practice

A university IT team equips a design lab with workstations that each drive a 27-inch 4K monitor next to an older 24-inch 1080p display. Under the previous X11 session, the team had to choose one global scale, so text looked tiny on one screen or oversized on the other.

After moving the lab to a Plasma Wayland session, the administrators set 150 percent scaling on the 4K output and 100 percent on the second display, and KWin renders each window sharply at the right size as it moves between screens. They also deploy a window rule through kwinrulesrc that opens the color-calibrated image viewer full screen on the 4K monitor. Support tickets about unreadable text drop to nearly zero during the first semester.