Expand description
The window policy interface a window manager implements for the compositor. The window policy interface: what a window manager decides for the compositor.
The capture compositor (wayland::frontend) owns the protocol state of every window and
renders what is on each output; it decides nothing about where a window goes, which one has
focus, or what a key chord means. Those decisions belong to a [WindowPolicy] installed
through crate::Compositor::install_window_policy: the compositor hands it an [Event] at
each decision point and applies the [Command]s it answers with. Without a policy the
compositor keeps its own behavior, every window fullscreen on its output and no frame drawn,
so a session that nests another compositor or runs one application is exactly what it was.
The interface is deliberately free of Smithay types: a window is a [WindowId], geometry
an integer [Rect] in the compositor’s logical layout coordinates, and a frame or a menu a
raster [Image] the policy drew and the compositor presents, so the same policy drives an
X11 server through another backend with the same model. Images are premultiplied RGBA in
physical pixels at the output’s scale, the format both tiny-skia produces and the renderers
import without conversion.
The policy runs on the compositor thread, inside the handlers that call it, so it must never
block; a long task (a pipe menu’s command) is run on a thread of its own and its result
applied on a later event. A panic in the policy is caught at the boundary
(frontend::AppState::policy): the compositor drops the policy, logs the panic, and carries
on with its own behavior, so a window-manager bug degrades the desktop rather than ending
the stream.
Structs§
- Desktop
View - The desktop as the policy holds it at one moment: what a consumer needs to say where every window is and which one a click at a point reaches.
- Extents
- The thickness of a frame around a client area, in logical pixels.
- Frame
- A window’s server-side frame: the border it adds around the client area and the parts that paint it. The compositor hit-tests nothing here; the policy keeps its own map of what a point on the frame means.
- Frame
Part - One drawn part of a window’s frame, placed relative to the client area’s top-left corner.
- Image
- A raster the policy drew: premultiplied RGBA,
width * 4bytes a row, in physical pixels atscalelogical pixels to one. - KeyEvent
- One key event, already resolved through the seat’s keymap.
- Modifiers
- The modifiers held with a key or a button.
- Output
Info - One output of the layout.
- Pointer
Event - One pointer event in logical layout coordinates.
- Rect
- An integer rectangle in logical layout coordinates.
- Size
- A size in logical pixels.
- Size
Hints - Size constraints a client published (
WM_NORMAL_HINTS, xdg min and max size). - States
- The xdg states a configure carries, which the compositor also publishes to taskbars.
- Transform
- A per-frame transform an effect applies to a window as it is presented: the client area is
drawn at
rectinstead of its configured geometry, which scales it, blended atalpha, and its frame parts follow it at the same scale. AClosetransform names a window the compositor no longer has: it applies to the ghost the compositor kept of it, and the ghost is dropped when the transform is cleared. - Under
- What the compositor found under the pointer, for the policy’s own hit test to combine with: a layer surface on the top or overlay layers takes the pointer ahead of every window and its frame, a window’s client area stands below the policy’s frames and menus.
- Window
Info - Everything the policy knows about a window, sent when it appears and again when any of it changes.
- Window
View - One window as the policy holds it, for a consumer that describes the desktop.
Enums§
- Command
- What the policy tells the compositor to do.
- Decoration
- What a client said about who decorates it.
- Effect
Kind - What an effect is for, so a backend that cannot scale a live window (an X server) still knows what to show: a minimize or a restore moves the empty frame, a map, a resize, or a close shows the window as it stands, a shade hides the client under its title bar.
- Event
- A decision point the compositor hands the policy.
- Pointer
Kind - What the pointer did.
- Request
- A request a client or a shell made of its window through a protocol.
- Resize
Edge - One edge or corner a resize pulls, in xdg-shell’s numbering.
- Verdict
- What a policy decides about an input event.
- Window
Kind - The protocol a window arrived through.
- Window
Type - What a window is for, from
_NET_WM_WINDOW_TYPEor the xdg role.
Constants§
- EFFECT_
FRAME - The interval between effect frames when no capture paces them: a frame at 60 Hz.
Traits§
- Window
Policy - A window manager’s decisions for the compositor; see the module documentation.