Vixen
02b45cc4
csharp
public sealed class DesktopPlatform

Windows, Linux and macOS, through one SDL implementation.

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

Remarks

One implementation for all three, because SDL already absorbed the differences that matter for windowing, input, gamepads, clipboard text and IME. What it does not cover — file pickers, clipboard images and application-defined formats, thread affinity, thermal state — comes from Vixen.Platform.Windows, .Linux or .MacOS through an IPlatformSupplement, chosen at construction and turned off with UseNativeSupplement. Nothing above this assembly has to know which one it got: the services arrive through the same interfaces either way, and Capabilities is what says whether the pickers are real.

Owned by the thread that constructed it. That is SDL's rule and the operating systems' beneath it, not a simplification of ours.

Fields and properties (13)

  • public string Name

    A name for logs and crash reports: "Desktop (macOS)", "Headless".

  • public PlatformCapabilities Capabilities

    What SDL can do here, decided at construction from what it reports rather than from the operating system's name.

  • public IReadOnlyList<IWindow> Windows

    Every window that exists now, in creation order.

  • public IDisplayInfo Displays

    The displays.

  • public IFileSystemHost FileSystem

    Where this platform keeps files.

  • public IClipboard Clipboard

    The system clipboard.

  • public INativeDialogs Dialogs

    Native pickers and message boxes.

  • public ILifecycle Lifecycle

    The process's lifecycle.

  • public IInputSource Input

    Raw input devices and their state.

  • public ITextInput TextInput

    Text entry and the IME.

  • public IPowerInfo Power

    Battery and thermal state.

  • public IProcessorTopology Processors

    How many processors there are, and whether threads may be pinned to them.

  • public string VideoDriver

    Which video driver SDL chose: "windows", "cocoa", "wayland", "x11".

Methods (7)

  • public DesktopPlatform()

    Starts SDL and builds the platform.

  • public DesktopPlatform(DesktopPlatformOptions options)

    Creates the platform.

  • public IWindow CreateWindow(in WindowOptions options)

    Creates a window.

  • public bool TryGetWindow(uint id, out IWindow? window)

    Finds a window by the id its events carry.

  • public ReadOnlySpan<PlatformEvent> PumpEvents()

    Collects everything the OS has to say and returns it, in the order it happened.

  • public bool TryOpenUrl(string url)

    Opens a URL in whatever the user has set as their handler for it.

  • public void Dispose()

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

Used by (10)

  • ProgramHelloUi
  • ProgramPbrShowcase
  • ProgramHelloTriangle
  • ProgramVideoPlayback
  • ProgramVirtualGeometry
  • DesktopGlContextTestsVixen.Platform.Desktop.Tests
  • DesktopPlatformTestsVixen.Platform.Desktop.Tests
  • DesktopSupplementTestsVixen.Platform.Desktop.Tests
  • PlatformHostVixen.App
  • ProgramVixen.Editor.Host