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.
| Component | Role | Interface |
|---|---|---|
| DRM and KMS | Mode setting and page flips | Kernel graphics API |
| libinput | Keyboard, pointer and touch events | Input library |
| OpenGL renderer | Composites window buffers | EGL and GBM |
| XWayland | Runs legacy X11 clients | X11 protocol |
| Plasma shell | Panels, desktop and launchers | KDE Wayland protocols |
| PipeWire portal | Screen sharing and capture | xdg-desktop-portal |
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.
| Aspect | KWin on X11 | KWin on Wayland |
|---|---|---|
| Display server | X.Org Server | KWin itself |
| Mixed DPI monitors | One global scale | Per-output fractional scaling |
| Variable refresh rate | Limited, single screen | Per output |
| HDR and color management | Not supported | Supported on capable outputs |
| Window isolation | Clients can spy on each other | Clients are isolated |
| Crash behavior | Applications survive a restart | Applications reconnect if supported |
| Development focus | Maintenance | Active development |
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.
| Compositor | Desktop | Window model | Configuration style |
|---|---|---|---|
| KWin | KDE Plasma | Stacking with tiling aids | GUI settings, rules and scripts |
| Mutter | GNOME | Stacking | Minimal, extensions via GNOME Shell |
| Sway | Standalone | Manual tiling | Text file compatible with i3 |
| Hyprland | Standalone | Dynamic tiling | Text file with animations |
| cosmic-comp | COSMIC | Stacking and auto-tiling | GUI settings |
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.
| Symptom | Likely cause | Typical fix |
|---|---|---|
| Blurry X11 applications | XWayland apps scaled as bitmaps | Let legacy apps scale themselves |
| Stutter on high refresh screens | Driver or VRR conflict | Update drivers, test VRR per output |
| Black screen after login | OpenGL initialization failure | Check the journal, try another driver |
| Global shortcut ignored | Application expects X11 grabs | Use the portal or KDE shortcut settings |
| High compositor CPU | Heavy effects or software rendering | Disable blur, verify the GPU renderer |
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.