Vixen
02b45cc4
csharp
public sealed class HeadlessWindow

A window that nobody can see.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

It has a size, an id, a scale factor, focus, a lifecycle and an event stream — everything a window has except a picture. That is the point: the dedicated server and the golden-image test run the same frame loop the desktop build runs, and the no-window path is exercised on every test run rather than being written once for Phase 9 and found broken there.

Its state is also writable in a way a real window's is not, and deliberately: setting ClientSize here really does resize it and really does raise WindowResized, so a test can drive a swapchain-rebuild path without a display server. A real window would treat the same assignment as a request the window manager may refuse, which is why code that must know listens for the event on both.

Where it is not lenient, and why that matters. Every member but IsClosed throws once the window is closed, exactly as IWindow says and exactly as the desktop window does. IsVisible, IsFocused and IsMinimised used to answer instead. That looked harmless — a closed window is plainly not focused — but this is the stand-in every test uses, so being kinder than the real thing means the suite proves a property the shipped platforms do not have. It cost a crash on the way out of the Hello Triangle sample, which the suite reproduced the moment this was tightened and could not have caught before.

Fields and properties (19)

  • public uint Id

    This window's id, as it appears in WindowId.

  • public string Title

    The title bar text.

  • public Int2 ClientSize

    The client area's size in logical points.

  • public Int2 FramebufferSize

    The framebuffer's size in physical pixels — ClientSize times DpiScale, subject to the platform's rounding.

  • public Int2 Position

    The top-left corner in desktop coordinates.

  • public float DpiScale

    How many physical pixels there are per logical point.

  • public WindowMode Mode

    How the window relates to its display.

  • public bool IsResizable

    Whether the user may resize it.

  • public bool IsVisible
  • public bool IsFocused
  • public bool IsMinimised
  • public bool IsClosed

    Whether it has been disposed. Every other member throws once this is true.

  • public int DisplayIndex

    Always 0: a headless platform has no displays to be on.

  • public CursorMode CursorMode

    What the cursor does over it.

  • public CursorShape CursorShape

    Which stock cursor to draw over it.

  • public ISurface Surface

    The thing a graphics backend presents to.

  • public ReadOnlyMemory<byte> Icon

    The icon the window was last given, so a test can assert that an application set one.

  • public Int2 IconSize

    The size of Icon.

  • public int AttentionRequests

    How many times RequestAttention has been called.

Methods (11)

  • public void Show()

    Shows the window.

  • public void Hide()

    Hides the window without destroying it.

  • public void Focus()

    Asks for keyboard focus.

  • public void Centre()

    Does nothing: there is no display to be centred on.

  • public void RequestAttention()

    Asks the OS to draw attention to the window — a bouncing dock icon, a flashing taskbar button.

  • public void SetIcon(ReadOnlySpan<byte> pixels, Int2 size)

    Sets the window and taskbar icon from straight (non-premultiplied) RGBA8 pixels.

  • public void SetFocused(bool focused)

    Gives or takes keyboard focus, raising the matching event.

  • public void SetMinimised(bool minimised)

    Minimises or restores the window, raising the matching event.

  • public void SetDpiScale(float scale)

    Changes the scale factor, raising WindowDpiChanged.

  • public void RequestClose()

    Raises WindowCloseRequested without closing anything.

  • public void Dispose()

    Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Used by (5)

  • HeadlessPlatformVixen.Platform.Headless
  • HeadlessPlatformTestsVixen.Platform.Headless.Tests
  • HeadlessSurfaceVixen.Platform.Headless
  • PlatformExtensionsTestsVixen.Platform.Headless.Tests
  • VixenApplicationTestsVixen.App.Tests