How windows behave as desktop-app windows on Linux, and on macOS where the section says so.
Ordinary windows
PlatformApp.CreateWindow(WindowOptions) makes a decorated, movable, resizable window.
| Option | Wayland | X11 |
|---|---|---|
Title | xdg_toplevel.set_title | _NET_WM_NAME and WM_NAME |
AppId | xdg_toplevel.set_app_id, which the compositor matches to the app's .desktop file | WM_CLASS (instance and class) |
MinWidth..MaxHeight, Window.SetSizeLimits | set_min_size, set_max_size (a client-side title bar is added to the heights) | WM_NORMAL_HINTS |
Parent (dialog) | xdg_toplevel.set_parent | WM_TRANSIENT_FOR and the dialog window type |
Decorations | see below | Auto and ClientSide: the window manager; None: _MOTIF_WM_HINTS |
Window.Role tells ordinary windows, dialogs, overlays and popups apart; Window.Parent names the parent.
Frames on Wayland
DecorationPreference.Auto asks the compositor for server-side decorations (zxdg_decoration_manager_v1, bound at version 1) and follows its answer. If the compositor does not offer the protocol, or answers client_side, the platform layer draws a frame: a title bar (title, minimize, maximize/restore, close) and an invisible 8-pixel resize border, built from four wl_subsurfaces around the window's own surface, so the content, CPU or GPU drawn, is untouched. The frame needs wl_subcompositor; without it Window.Decoration is DecorationKind.None.
The frame hands moves and resizes to the compositor (xdg_toplevel.move and resize with the serial of the click), opens the window menu on a right click (show_window_menu), maximizes on a double click, and sets resize cursors through wp_cursor_shape_v1. Closing sends PlatformEventKind.WindowCloseRequested; the program decides.
DecorationPreference.ClientSide forces the client-side frame. PlatformOptions.UseServerDecorations = false does not bind the decoration protocol at all, which is how the no-manager path is exercised. Window.Decoration reports who draws the frame now.
The size a program sees (Window.Width, Height, WindowResized) is always the content area, below the title bar.
Overlays
WindowOptions.Overlay makes a keep-on-top window (OverlayOptions: layer, anchors, margins, exclusive zone, keyboard behaviour).
- Wayland: a
zwlr_layer_shell_v1surface, bound at version 4. LayerOverlayorTop; the compositor answers with the final size. If the compositor lacks the protocol,CreateWindowthrowsOverlayUnavailableException("zwlr_layer_shell_v1 not offered by the compositor ..."); withOverlayOptions.FallbackToToplevelit makes an ordinary window instead (RoleisToplevel). - X11: a window of type
_NET_WM_WINDOW_TYPE_DOCKwith_NET_WM_STATE_ABOVE,SKIP_TASKBARandSKIP_PAGER, placed from the anchors and margins on the screen. Anchoring to opposite edges stretches it. A positive exclusive zone along one edge sets_NET_WM_STRUT_PARTIAL. The keyboard setting is ignored.
Overlays have no frame (Decoration is None).
Popups
PlatformApp.CreatePopup(parent, PopupOptions) makes a menu, drop-down or tooltip attached to a rectangle of the parent (in the parent's pixels).
- Wayland: an
xdg_popupwith anxdg_positioner(anchor rectangle, anchor, gravity, offset, constraint adjustment). A popup may also belong to another popup or to an overlay (zwlr_layer_surface_v1.get_popup). WithGrabthe popup needs a recent click or key press in the app;popup_doneends it. Clicks inside the app's own windows are the app's input; a click outside them dismisses the popup. - X11: an override-redirect window placed by
PopupPlacement(the same arithmetic as the positioner, constrained to the screen) with an owner-events pointer grab; a press that no window of the app receives dismisses it. Keyboard input stays with the parent window.
Dismissal posts PlatformEventKind.PopupDismissed with the popup's window id, then closes the popup. Window.PositionInParent is where the system put the popup, relative to the parent's content area, in pixels.
macOS (Cocoa)
- Ordinary windows are titled
NSWindows: the system draws the frame (DecorationisServerSide;AutoandClientSideare the same here,Noneis borderless).Resizable = falsedrops the resize control.MinWidth..MaxHeightandSetSizeLimitssetcontentMinSizeandcontentMaxSize(pixels divided by the scale).AppIdhas no AppKit counterpart. - A dialog (
Parent) is a child window (addChildWindow:ordered:): above its parent, moving and minimizing with it. - An overlay is a borderless window at a window level:
OverlayisNSStatusWindowLevel,TopisNSFloatingWindowLevel. It is on every Space, shown beside full-screen windows, not movable, and placed from the anchors and margins on the main screen without AppKit moving it clear of the menu bar. WithKeyboard = Noneit never becomes the key window.ExclusiveZoneis ignored.CreateWindownever throwsOverlayUnavailableExceptionon macOS. - A popup is a borderless child window at
NSPopUpMenuWindowLevel, placed byPopupPlacementinside the parent screen's visible area, and never takes the keyboard. AppKit has no pointer grab, so withGrabthe loop watches the global mouse buttons (about 60 times a second, only while such a popup is open): a press that lands outside every window of the app postsPopupDismissedand closes the popup. A press in one of the app's own windows is the app's input. StartMove,StartResizeandShowWindowMenudo nothing: the system frame does its own moves.FillSolidsets the window layer's background colour, which shows wherever nothing has been presented.Activateof a popup throwsActivationUnavailableException.
Showing CPU pixels
Window.CanPresentPixels says whether a window can show an image drawn by the CPU, for a program with no usable graphics device (or one that asks for CPU drawing). Window.PresentPixels(bgra, width, height) takes the window's client area as 4 bytes per pixel in blue, green, red, unused order, top row first, and the unused byte is ignored: the picture is opaque.
| Backend | CanPresentPixels |
|---|---|
| Win32 | true (SetDIBitsToDevice; redrawn on WM_PAINT) |
| Wayland toplevel, layer-shell and popup windows | true, when the compositor offers wl_shm (always, by the core protocol) |
| X11, Cocoa, Android, iOS, browser | false; PresentPixels throws NotSupportedException |
On Wayland the image is copied into one of a few reusable wl_shm buffers (XRGB8888), attached, damaged and committed; nothing is allocated per picture. A buffer the compositor still holds (until its release event) is never drawn into, so a window cycles through two or three buffers, and a fourth is made only if the compositor keeps all of them. A picture of a new size drops the old-size buffers as they are released. The surface is sized to the picture: its logical size is the pixel size divided by the window's scale (through wp_viewport where offered, wl_surface.set_buffer_scale otherwise), so pass the window's pixel size (Window.Width and Window.Height, which follow WindowResized) for a window that fills exactly. A picture presented before the first configure is kept and appears with it. The compositor keeps showing the last committed buffer, so nothing is drawn on a timer or frame callback: call PresentPixels when the picture changes, and an idle window costs no CPU. A popup's picture is committed after its first configure, like a window's, and its position and dismissal (popup_done) are unchanged. A configure or a scale change recommits the last picture without copying it again; the program is told about the new size through WindowResized and presents a picture of that size.
Window icons
A desktop normally takes a window's icon from the application's installed launcher entry (on Linux a .desktop file named by the app id, with an icon in the icon theme). An application that runs without being installed, such as an AppImage launched directly, has none, and the system shows a placeholder. Window.SetIcon(images, name) gives the window its own icon: pass one or more IconImage pictures (straight RGBA, top row first); a single square picture also supplies the smaller standard sizes (16, 22, 24, 32, 48, 64, 128 and 256 pixels that are below it).
| Backend | SetIcon |
|---|---|
| Wayland toplevels | yes, through xdg_toplevel_icon_manager_v1 (staging protocol; KWin 6.6 offers it) with one wl_shm buffer per square picture and the themed name when given; applied with the toplevel's next commit |
| Wayland, a compositor without that protocol; popups and overlays | returns false: the icon comes from the installed launcher entry |
| X11 | yes, _NET_WM_ICON |
| Win32, Cocoa | returns false for now |
The same pictures go to the tray icon: TrayIcon.CreateAsync(connection, id, title, images) publishes them as the StatusNotifierItem IconPixmap (each size as width, height and ARGB bytes in network byte order) and SetIcon(images) changes them and emits NewIcon. With no themed name the item's IconName is empty, so the host has only the pictures to draw; with a name it may prefer the themed icon, and a host that cannot resolve the name may draw nothing, so give a name only when the theme has it. Plasma on KWin 6.6 drew the pictures with an unresolvable name set; do not depend on that elsewhere.
Several windows
Any number of ordinary windows can be open; every event carries its window id, and closing one leaves the others alone.
Moves and resizes started by the program
Window.StartMove(), StartResize(ResizeEdge) and ShowWindowMenu(x, y) call from a pointer-button-down handler. On Wayland they quote the serial of the latest button or key press. On X11 StartMove and StartResize send _NET_WM_MOVERESIZE; ShowWindowMenu does nothing there.
Bringing a window forward
Window.Activate(token) raises a window, un-minimizes it and gives it the keyboard. Window systems refuse a program that tries this unprompted, so the request carries proof that a user action started it.
- Wayland:
xdg_activation_v1. A token from the launcher (XDG_ACTIVATION_TOKEN, orActivationRequest.ActivationTokenwhen a second launch forwarded it) is used as it is. Without one, the platform layer asks the compositor for a token tied to the window's surface and the latest input serial and activates when it arrives; the compositor may still refuse a window that has had no recent input and show a taskbar hint instead. A compositor without the protocol makesActivatethrowActivationUnavailableExceptionwhoseRequirementisxdg_activation_v1. Popups cannot be activated. Wayland announces no minimized state, soIsMinimizedis true afterMinimize()and false again once the window is handed the focus. - X11: the token is a startup-notification id (
DESKTOP_STARTUP_ID), stored as_NET_STARTUP_ID. A minimized window is mapped again (ICCCM), then_NET_ACTIVE_WINDOWgoes to the root with source "application" and the time of the latest key or button press. With no window manager the window raises itself and takes the focus. - Win32:
ShowWindow(SW_RESTORE)andSetForegroundWindow. Windows only lets the foreground process, or one it permitted, do that, so the second launch callsWindowActivation.AllowForeground(firstInstanceProcessId)before it exits. If Windows still refuses, the call retries with the foreground thread's input queue attached for a moment. - Cocoa:
deminiaturize:,activateIgnoringOtherApps:andmakeKeyAndOrderFront:.
A second launch under a launcher inherits the token in its environment; SingleInstance.Acquire forwards it in platform_data (activation-token, desktop-startup-id) and the running instance passes request.ActivationToken to Activate.
Keeping a window on top
Window.SetKeepAbove(bool) is the toggle for an ordinary decorated window (not for overlays, which are placed with WindowOptions.Overlay). Window.KeepAbove is the state, and Window.CanKeepAbove says whether it can work right now. Where it cannot, SetKeepAbove throws KeepAboveUnavailableException (a PlatformException; Requirement names what is missing). Call all three on the UI thread.
- X11: the
_NET_WM_STATEclient message with_NET_WM_STATE_ABOVE(EWMH). It needs a window manager; without oneCanKeepAboveis false.KeepAboveis read back from the property, so a change the person makes in the window menu shows up. - Win32:
SetWindowPoswithHWND_TOPMOSTorHWND_NOTOPMOST, without moving, sizing or activating; the state read back is theWS_EX_TOPMOSTbit. - Cocoa: the window level, floating (3) or normal (0).
- Headless: the state only.
- Wayland:
xdg-toplevelhas no keep-above request, and there is no cross-compositor protocol for it. Under KWin, and only there, the platform layer uses KWin's scripting interface on the session bus (org.kde.KWin,/Scripting). Each change writes one small script intoXDG_RUNTIME_DIR, loads and runs it, waits for its report, then unloads it and deletes the file, all before the call returns, so nothing stays loaded. The script finds windows whoseresourceClassordesktopFileNameequals theWindowOptions.AppIdthe window was created with and sets or clears theirkeepAbove; it reads no title or size and writes no other property. KWin gives a client no way to name one of its own windows, so every window of the same app id changes together. The call blocks for the answer (normally milliseconds; at most 3 s, then it throws). It throws the typed error when the session bus has no KWin (any other compositor), when scripting is refused, or when KWin knows no window with the app id yet (ask again once the window is shown).CanKeepAboveasks the bus whether KWin is there.
Protocols
Bound versions: xdg_wm_base 5, zxdg_decoration_manager_v1 1, zwlr_layer_shell_v1 4, wl_subcompositor 1, wp_cursor_shape_manager_v1 1, xdg_activation_v1 1, xdg_toplevel_icon_manager_v1 1 (when offered). Tables are generated by tools/WaylandGen from tools/WaylandGen/protocols.