Vixen
dd8b0a81
csharp
public interface IPlatform

Everything the operating system does for us, behind one object.

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

Remarks

One implementation per platform, chosen by the app head at boot and put in the ServiceRegistry. Nothing above this assembly has a #if ANDROID: code that needs to know what it is running on asks Capabilities, which is a runtime question with a runtime answer, and gets a fallback path rather than a compile error on five of the six targets.

Threading. The platform is owned by the thread that created it. Every member here except Post on the queue behind PumpEvents must be called from that thread, because the underlying APIs demand it — Win32 messages are delivered to the thread that created the window, and AppKit refuses to touch a window from anywhere but the main thread. That is a restriction of the operating systems, not a simplification of ours, and hiding it behind a lock would make it a deadlock instead of an exception.

Fields and properties (15)

  • string Name

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

  • PlatformCapabilities Capabilities

    What this platform can do.

  • IReadOnlyList<IWindow> Windows

    Every window that exists now, in creation order.

  • IDisplayInfo Displays

    The displays.

  • SystemColorScheme ColorScheme

    Whether the user has asked the operating system for a light or a dark appearance.

  • SystemAccessibility Accessibility

    Which accessibility settings the user has turned on.

  • SystemAccent Accent

    The accent colour the user picked in the operating system's settings.

  • IFileSystemHost FileSystem

    Where this platform keeps files.

  • IClipboard Clipboard

    The system clipboard.

  • INativeDialogs Dialogs

    Native pickers and message boxes.

  • ILifecycle Lifecycle

    The process's lifecycle.

  • IInputSource Input

    Raw input devices and their state.

  • ITextInput TextInput

    Text entry and the IME.

  • IPowerInfo Power

    Battery and thermal state.

  • IProcessorTopology Processors

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

Methods (4)

  • IWindow CreateWindow(in WindowOptions options)

    Creates a window.

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

    Finds a window by the id its events carry.

  • ReadOnlySpan<PlatformEvent> PumpEvents()

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

  • bool TryOpenUrl(string url)

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

Used by (25)

  • AppBuilderVixen.App.Hosting
  • AppServicesVixen.App.Hosting
  • DesktopPlatformVixen.Platform.Desktop
  • HeadlessPlatformVixen.Platform.Headless
  • IPlatformFactoryVixen.App.Hosting
  • PlatformClipboardVixen.Platform.Ui
  • PlatformExtensionsVixen.Platform
  • PlatformReachTestsVixen.Ui.Desktop.Tests
  • PlatformWindowHostVixen.Platform.Ui
  • UiApplicationVixen.Ui.Desktop
  • UiApplicationOptionsVixen.Ui.Desktop
  • VixenApplicationVixen.App.Hosting
  • AppBackendTestsVixen.App.Tests
  • CountingFactoryVixen.App.Tests
  • EditorHostVixen.Editor.Host
  • EditorServicesVixen.Editor.App
  • FactoryVixen.App
  • HeadlessFlagTestsVixen.App.Tests
  • PinningPlatformVixen.App.Tests
  • PlatformHostVixen.App
  • PresentingPlatformVixen.App.Tests
  • StoppingGameVixen.App.Tests
  • TestAppTestsVixen.App.Tests
  • VixenApplicationTestsVixen.App.Tests
  • WindowPlacementVixen.Editor.Host