public sealed record DesktopWindowState : IEquatable<DesktopWindowState> The bounds and state of an embedded window, as DesktopWindow.State last reported them.
Remarks
The values use the units that DesktopWindow.MoveAsync and DesktopWindow.ResizeAsync take on each platform, so a value read here moves or resizes the window back to the same place:
- Windows –
DesktopWindowState.XandDesktopWindowState.Yare the top-left corner of the frame in physical virtual-screen pixels;DesktopWindowState.WidthandDesktopWindowState.Heightare the outer frame in device-independent pixels (1/96 inch) at the window's monitor scale. - macOS – Points:
DesktopWindowState.XandDesktopWindowState.Yare the top-left corner of the frame, title bar included, measured right and down from the top-left corner of the primary screen (the one with the menu bar), so a screen above or left of it has negative coordinates;DesktopWindowState.WidthandDesktopWindowState.Heightare the content size, without the title bar. Runic 0.11 and earlier used AppKit's bottom-left origin; seeDesktopWindowPlacement.Origin. - Linux, GTK 3 – Logical pixels:
DesktopWindowState.XandDesktopWindowState.Yare the top-left corner of the frame as the window manager reports it;DesktopWindowState.WidthandDesktopWindowState.Heightare the content size, without decorations. On Wayland the position isnull: Wayland reports none. - Linux, GTK 4 –
DesktopWindowState.WidthandDesktopWindowState.Heightare the content size in logical pixels. On X11DesktopWindowState.XandDesktopWindowState.Yare the top-left corner of the visible frame in logical pixels, which Runic reads through Xlib; on Wayland the position isnull: GTK 4 has no position API there.
A minimized window keeps the state it had before it was minimized.
Constructors
DesktopWindowState
public DesktopWindowState() No documentation.
Properties
Bounds
public DesktopWindowBounds? Bounds { get; init; } Gets the window's frame in native units that round-trip exactly, the rectangle DesktopWindow.SetBoundsAsync takes, or null where the window does not report it (without DesktopWindowCapabilities.Bounds).
Remarks
DesktopWindowBounds lists the units. DesktopWindowState.X, DesktopWindowState.Y, DesktopWindowState.Width, DesktopWindowState.Height and DesktopWindowState.Placement keep theirs, so saved placements keep their meaning; on Windows, where those mix physical and device-independent pixels, use these bounds to move or grow a window by an exact amount. For a maximized or full-screen window they are the maximized or full-screen frame.
Height
public int Height { get; init; } Gets the current height; for a maximized or full-screen window, the maximized or full-screen height.
IsFullScreen
public bool IsFullScreen { get; init; } Gets whether the window is full-screen.
Remarks
A DesktopWindowOptions.Kiosk window is full-screen, as is a window after DesktopWindow.SetFullScreenAsync, and on macOS and Linux the user can also make a window full-screen. DesktopWindowState.Placement records it, so a window closed full-screen opens full-screen again.
IsMaximized
public bool IsMaximized { get; init; } Gets whether the window is maximized (zoomed on macOS).
IsSnapped
public bool IsSnapped { get; init; } Gets whether the desktop arranged the window against a screen edge or into a layout (snapped, tiled), where changing its bounds would break the arrangement. Not set while the window is maximized or full-screen.
Remarks
Best effort where the platform has no API for it:
- Windows:
IsWindowArrangedwhere user32 exports it; otherwise the window's bounds differ from its restored bounds (GetWindowPlacement) while it is not maximized, which is how Snap arranges a window. - macOS: no public API reports window tiling, so the frame is compared with the halves and quarters of its screen's visible frame, allowing for the margins of tiled windows. A window the user sized to a half of the screen by hand counts as snapped; a tiling arrangement of another shape does not.
- Linux: GTK's tiled state (
GDK_WINDOW_STATE_TILED,GDK_TOPLEVEL_STATE_TILED), which GNOME and KDE set on Wayland and Mutter on X11; on X11 also the visible frame compared with the halves and quarters of its monitor's work area, for window managers that tile without telling GTK.
MonitorId
public string? MonitorId { get; init; } Gets the DesktopMonitor.Id of the monitor that holds most of the window, or null where the host does not report it.
Placement
public DesktopWindowPlacement Placement { get; init; } Gets what to save to restore the window: its bounds when last neither maximized nor full-screen, and whether it is maximized or full-screen.
VisibleBounds
public DesktopWindowBounds? VisibleBounds { get; init; } Gets the frame the user sees, in the units of DesktopWindowState.Bounds, or null where the platform does not report it.
Remarks
Place a window flush against another window, or check that it fits a monitor's work area, with these bounds:
- Windows: the frame without the invisible resize borders of Windows 10 and 11 (
DWMWA_EXTENDED_FRAME_BOUNDS), about 7 device-independent pixels left, right and belowDesktopWindowState.Bounds. - macOS: the frame, which has no invisible border, so the same as
DesktopWindowState.Bounds. - Linux on X11: the window manager's frame around the window, decorations included (
_NET_FRAME_EXTENTS), without the shadow of GTK's client-side decorations; its size is larger than the content size ofDesktopWindowState.Boundsby the decorations. - Linux on Wayland:
null; Wayland reports neither the position nor the decorations.
Width
public int Width { get; init; } Gets the current width; for a maximized or full-screen window, the maximized or full-screen width.
X
public int? X { get; init; } Gets the current horizontal position, or null where the platform reports none.
Y
public int? Y { get; init; } Gets the current vertical position, or null where the platform reports none.