public static class DesktopPlatformServices Selects the native platform-service provider for the running Desktop backend.
Remarks
Applications that open windows with OpenWindowAsync on RunicDesktopHost call DesktopPlatformServiceCollectionExtensions.AddRunicPlatformServices instead and take IWindowPlatformServices or IFileDialogs in a ViewModel constructor. The explicit providers, such as WindowsPlatformProvider, remain available for custom composition.
Properties
CurrentProvider
public static DesktopPlatformProvider CurrentProvider { get; } Gets the provider for the operating system and the Linux toolkit this process has started.
Remarks
On Linux the toolkit is the one the embedded Desktop window host claimed for the process, so a GTK 4 process never selects the GTK 3 provider. Before any embedded window starts a toolkit, Linux reports DesktopPlatformProvider.None.
Methods
AnnounceAsync
public static ValueTask<PlatformResult<PlatformUnit>> AnnounceAsync(IRunicWindow window, string message, DesktopAnnouncementPriority priority = (DesktopAnnouncementPriority)0, CancellationToken cancellationToken = default) Asks the screen reader to announce a message for an open Runic Window, such as the result of an action.
Parameters
windowThe open Window, on any host.
messageThe text to speak, in the page's language.
priorityDesktopAnnouncementPriority.Polite, the default, waits for what the screen reader is saying;DesktopAnnouncementPriority.Assertiveinterrupts it.cancellationTokenCancels before the request reaches the window.
Exceptions
ArgumentExceptionmessageis empty or white space.InvalidOperationExceptionThe Window has not opened.
Remarks
The embedded window announces through the platform's accessibility API, as DesktopWindow.AnnounceAsync describes; WebKitGTK reports no ARIA live region to Orca, so on Linux this is how a page's status reaches a screen reader. A Window without an embedded window reports PlatformUnavailableReason.OwnerUnavailable: an installed browser after a fallback, a Window served under RUNIC_APPLICATION_SERVE_ONLY=1, or one on another host; a live region in the page reaches the screen reader there. A closed window reports PlatformUnavailableReason.OwnerClosed, and a custom window host without DesktopWindowCapabilities.Announcements PlatformUnavailableReason.BackendUnavailable. A ViewModel takes IWindowPlatformServices and calls its IWindowPlatformServices.AnnounceAsync, which works on every host, or takes DesktopWindowPlatformServices and calls its DesktopWindowPlatformServices.AnnounceAsync.
AttachWindowServices
public static DesktopWindowServices AttachWindowServices(DesktopWindow window, IServiceProvider windowServices, WindowContentSession? content = null) Gives the per-window services of a DI scope the window and content session the application opened itself, as RunicDesktopHost does for the Windows it opens.
Parameters
windowThe open window, embedded or an installed browser after a fallback.
windowServicesThe window's services: a scope of a provider with
AddRunicWindowService()and, for dialogs and the clipboard,AddRunicPlatformServices(). The application creates and disposes it.contentThe window's content session on a
DesktopBridgeTransportofwindow's surface, ornull. Without it the locale, the page connections and the appearance push are not attached, and presentation changes are raised on the thread that reports them.
Returns
The binding, which ends when the window closes or when it is disposed.
Exceptions
InvalidOperationExceptionThe window is closed, or the scope is already bound to a Window that
OpenWindowAsyncopened or attached to a window.ArgumentExceptioncontentdoes not servewindow's surface.
Remarks
Call it once the window is open. ViewModels that the scope resolved before keep their services: the scope's IRunicWindowPresentation, IRunicWindowLocale, IRunicConnections and platform services are the objects that are attached, so they follow the window from then on. It attaches:
IRunicWindowPresentation, with the results of aRunicDesktopHostWindow; its changes arrive in turns of the session's model context.IRunicWindowLocale, which follows and sets the session's locale; the native layout direction and the language of the pages the surface serves itself follow it.- The
appearance/1push of the desktop's appearance (IDesktopSettings), when only this computer can reach the window's pages, as for aRunicDesktopHostWindow: never for a host withDesktopNetworkExposure.AllInterfaces. IRunicConnections, which lists the session's page connections.DesktopWindowPlatformServices(IWindowPlatformServices: dialogs, the clipboard, file access), bound to the window'sDesktopNativeOwner.IRunicWindowContext.RequestCloseAsync, which callsDesktopWindow.RequestCloseAsync, so the window'sDesktopWindowOptions.ConfirmCloseAsyncdecides.IRunicWindowContext.Windowstaysnull: there is noIRunicWindow.
The layout direction follows the locale unless the window opened with a direction of its own, other than DesktopLayoutDirection.Default and other than the one of the session's locale. The web view's language stays the one DesktopWindowOptions.Language gave it. A scope without AddRunicWindowService() attaches the services it has; DesktopWindowServices.Presentation still presents the window. It never disposes the scope, the session or the window. Any thread may call it.
CreateApplications
public static IDesktopApplications CreateApplications() Creates the desktop's application database: content types, installed applications, default applications and icons.
Returns
An application database; it holds no native resources between requests and needs no disposal.
Remarks
Linux reads the freedesktop.org desktop entries, shared MIME-info database, mimeapps.list and icon themes directly, with either toolkit and without loading GTK or GIO. Windows uses the shell's file and protocol associations, where only the user can change a default; macOS uses Launch Services through NSWorkspace and uniform type identifiers. It needs no window or event loop. Elsewhere every request reports PlatformUnavailableReason.ProviderNotConfigured. DesktopPlatformServiceCollectionExtensions.AddRunicPlatformServices registers one instance for the application.
CreateApplications
public static IDesktopApplications CreateApplications(string applicationId) Creates the desktop's application database for the application identified by applicationId.
Parameters
applicationIdThe application's identity, as for
DesktopPlatformServices.CreateNotifications: on Linux the reverse-DNS ID of its installed desktop entry, which the portal registers when a request first connects to it, as notifications do; on Windows its AppUserModelID. The Windows and macOS providers do not use it today.
Returns
An application database; it holds no native resources between requests and needs no disposal.
Exceptions
ArgumentExceptionapplicationIdis empty or not a valid ID on this operating system.
Remarks
Otherwise the same as DesktopPlatformServices.CreateApplications, which DesktopPlatformServiceCollectionExtensions.AddRunicPlatformServices also registers; to register this one, add it to the services before calling that method. On Linux a portal request then reports portal-identity-registration-failed when no matching desktop entry is installed; during development use DesktopPlatformServices.CreateApplications.
CreateFileBookmarks
public static IDesktopFileBookmarks CreateFileBookmarks() Creates file bookmarks, which keep access to files across launches, from the provider for the operating system.
Returns
File bookmarks; they hold no native resources between requests and need no disposal.
Remarks
macOS creates security-scoped bookmarks inside the App Sandbox and ordinary bookmarks outside it; Windows and Linux, where a path keeps its access, use the path itself. It needs no window. DesktopPlatformServiceCollectionExtensions.AddRunicPlatformServices registers one instance for the application.
CreateFileTransfers
public static IDesktopFileTransfers CreateFileTransfers() Creates file copy and move with progress, cancellation and conflict decisions.
Returns
File transfers; they hold no native resources between requests and need no disposal.
Remarks
Every operating system uses the managed engine from LocalFileTransfers.Create. It needs no window. DesktopPlatformServiceCollectionExtensions.AddRunicPlatformServices registers one instance for the application.
CreateGlobalShortcuts
public static IDesktopGlobalShortcuts CreateGlobalShortcuts(string? applicationId = null) Creates the application's global shortcuts from the provider for the operating system.
Parameters
applicationIdOn Linux the reverse-DNS ID of the installed desktop entry, under which the desktop keeps the user's bindings;
nulluses the identity the desktop portal infers.
Returns
Global shortcuts that the caller disposes at shutdown.
Remarks
Linux binds through the desktop's GlobalShortcuts portal, where the user assigns the keys in the desktop's settings and DesktopGlobalShortcut.PreferredShortcut is a suggestion; a desktop without that portal reports PlatformUnavailableReason.BackendUnavailable. Windows registers each key with RegisterHotKey on a thread of its own, and macOS with Carbon's RegisterEventHotKey once the Desktop event loop runs, reporting PlatformUnavailableReason.BackendUnavailable without that loop; both ignore applicationId. Creating them registers nothing; the first IDesktopGlobalShortcuts.BindAsync does. Other platforms report PlatformUnavailableReason.ProviderNotConfigured. DesktopPlatformServiceCollectionExtensions.AddRunicPlatformServices registers one instance for the application.
CreateInhibition
public static IDesktopInhibition CreateInhibition(string? applicationId = null) Creates idle-power inhibition for the application from the provider for the operating system.
Parameters
applicationIdOn Linux the reverse-DNS ID of the installed desktop entry, which identifies the application to the portal;
nulllets the portal infer it. Windows and macOS ignore it.
Returns
Application-scoped inhibition; each lease it acquires is released by disposing the lease.
Exceptions
ArgumentExceptionapplicationIdis not a valid ID on this operating system.
Remarks
Nothing is inhibited until IDesktopInhibition.AcquireAsync. Windows creates a power request and macOS an IOKit power assertion; neither needs a window or the Desktop event loop. Linux asks the xdg-desktop-portal Inhibit interface with either toolkit, without loading GTK, and sends no parent window, so the request belongs to the application rather than to a window and works for a host without a native owner. Elsewhere, or where the Windows provider does not support the running version, every acquisition reports PlatformUnavailableReason.ProviderNotConfigured. DesktopPlatformServiceCollectionExtensions.AddRunicPlatformServices registers one instance for the application.
CreateLoginStartup
public static IDesktopLoginStartup CreateLoginStartup(string? applicationId = null) Creates login startup for the application from the provider for the operating system.
Parameters
applicationIdThe application's ID: on Linux the reverse-DNS ID of its installed desktop entry, which names the autostart entry; on Windows the name of its Run value.
nullleaves login startup unconfigured, except inside a Flatpak or Snap sandbox, where the desktop portal knows the application. macOS uses the bundle and ignores it.
Remarks
Nothing is registered until IDesktopLoginStartup.EnableAsync, which an application calls only when the user asks. Linux writes an XDG autostart entry, or asks the Background portal inside a sandbox; Windows writes the user's Run key. macOS 13 and later registers the application bundle as a login item with SMAppService, which starts it without the request's arguments; a login item waiting for the user's approval reports PlatformFailureCode.PermissionDenied, and a process outside an application bundle, or an earlier macOS, reports PlatformUnavailableReason.BackendUnavailable. DesktopPlatformServiceCollectionExtensions.AddRunicPlatformServices registers one instance for the application.
CreateNetworkStatus
public static IDesktopNetworkStatus CreateNetworkStatus() Creates the computer's network status for the operating system: online, metered and captive portal.
Returns
Application-scoped network status that the caller disposes at shutdown.
Remarks
Windows reads the Network List Manager's connectivity hint (Windows 10 version 2004 and later), whose check also finds captive portals; macOS follows Network.framework's path monitor, which has no captive-portal check, so its connectivity is DesktopNetworkConnectivity.Unknown while a network is available. Linux asks the NetworkMonitor desktop portal, with either toolkit and without loading GTK, and NetworkManager on the system bus where no portal answers. It needs no window. DesktopPlatformServiceCollectionExtensions.AddRunicPlatformServices registers one instance for the application.
CreateNotifications
public static IDesktopNotifications CreateNotifications(string? applicationId = null) Creates the desktop's notifications from the provider for the operating system.
Parameters
applicationIdThe application's identity: on Windows its AppUserModelID, which the application registers with the shell; on Linux the reverse-DNS ID of its installed desktop entry (
org.example.Appfororg.example.App.desktop). macOS uses the bundle identifier and ignores it.nullon Linux lets the portal infer the identity from the desktop session, which suits development; on Windows it leaves notifications unconfigured.
Returns
Application-scoped notifications that the caller disposes at shutdown.
Exceptions
ArgumentExceptionapplicationIdis not a valid ID on this operating system.
Remarks
Windows sends toasts, macOS UserNotifications once the Desktop event loop runs, and Linux xdg-desktop-portal notifications with either toolkit, without loading GTK. Creating them sends nothing and connects to nothing; the first request does. Without an applicationId on Windows, elsewhere, or where the Windows provider does not support the running version, every request reports PlatformUnavailableReason.ProviderNotConfigured. DesktopPlatformServiceCollectionExtensions.AddRunicPlatformServices registers one instance for the application.
CreateOpenRegistration
public static IDesktopOpenRegistration CreateOpenRegistration(string applicationId) Creates the registration of the application's URL schemes and file types with the desktop, for the current user, from the provider for the operating system.
Parameters
applicationIdThe application's ID, as for
DesktopPlatformServices.CreateLoginStartup: on Linux the reverse-DNS ID that names the desktop entry the registration writes; on Windows the prefix of the file types' ProgIDs and the name under which Settings lists the application. macOS registers the running bundle and ignores it.
Exceptions
ArgumentExceptionapplicationIdis empty or not a valid ID on this operating system.
Remarks
Nothing is written until IDesktopOpenRegistration.RegisterAsync, which an application calls when the user agrees; it never makes the application the default. macOS checks that the bundle's Info.plist declares each item and registers the bundle with Launch Services; Linux writes a desktop entry and MIME definitions in XDG_DATA_HOME (PortalApplication.CreateOpenRegistration); Windows writes the user's HKEY_CURRENT_USER\Software\Classes keys and lists the application in Settings, Default apps. A packaged or sandboxed process, whose package declares what it opens, reports PlatformUnavailableReason.BackendUnavailable; elsewhere every request reports PlatformUnavailableReason.ProviderNotConfigured. DesktopPlatformServiceCollectionExtensions.AddRunicPlatformServices registers one instance for the application.
CreateOpenRequests
public static IDesktopOpenRequests CreateOpenRequests(DesktopOpenOptions options, IApplicationInstance? instance = null, ApplicationLaunch? launch = null) Creates the requests to open files and URLs that the application registered with the desktop, from the provider for the operating system.
Parameters
optionsThe URL schemes and files the application registered.
instanceThe running instance from
ApplicationInstance.ClaimAsync, whose later launches carry files and URLs;nullwithout single instance.launchThis process's launch, usually
ApplicationLaunch.FromProcess.
Returns
Open requests to dispose when the application ends.
Remarks
Linux and Windows start the application with the files or URL as arguments, so requests come from launch and from the later launches the instance receives. macOS sends open events to the running application instead, and the arguments of launches from a terminal also count. On macOS, create it on the main thread before the first window or status icon, as MacOSPlatformProvider.CreateOpenRequests requires. It is not registered by DesktopPlatformServiceCollectionExtensions.AddRunicPlatformServices, because it needs the instance and must exist before the first window; register the instance this returns.
CreatePowerEvents
public static IDesktopPowerEvents CreatePowerEvents() Creates the computer's sleep, wake, session lock and battery events.
Remarks
Windows follows WM_POWERBROADCAST and WTSRegisterSessionNotification on a hidden window of its own, macOS NSWorkspace's sleep and wake notifications, the screen lock notifications and IOKit's power source, and Linux logind's PrepareForSleep and session lock, UPower's OnBattery and the power-saver profile on the system bus, with either toolkit and without loading GTK. It needs no window. Under RUNIC_APPLICATION_SERVE_ONLY=1, whose Windows are shown in a browser that may run on another computer, it reports PlatformUnavailableReason.BackendUnavailable. DesktopPlatformServiceCollectionExtensions.AddRunicPlatformServices registers one instance for the application, which decides on first use, so RunicDesktopHostOptions.ServeOnly of the host built on that provider counts too and a headless server opens no system bus watches.
CreateRecentDocuments
public static IDesktopRecentDocuments CreateRecentDocuments() Creates the application's recent documents, which the desktop lists for reopening.
Remarks
macOS adds them to Open Recent and the Dock menu (NSDocumentController, on the main thread that Runic Desktop's event loop serves), Windows to Recent items and the application's Jump List (SHAddToRecentDocs), and Linux to the freedesktop.org recently-used.xbel that GTK and KDE read, with either toolkit and without loading GTK. The same as DesktopHost.AddRecentDocumentAsync and ClearRecentDocumentsAsync, with their outcome. It needs no window. Under RUNIC_APPLICATION_SERVE_ONLY=1, whose Windows are shown in a browser that may run on another computer, every request reports PlatformUnavailableReason.BackendUnavailable. The instance that DesktopPlatformServiceCollectionExtensions.AddRunicPlatformServices registers decides on first use, so RunicDesktopHostOptions.ServeOnly and RunicDesktopHostOptions.Guest (hosted mode) of the host built on that provider count too, and it names the application by its application ID on Linux when one is given. DesktopPlatformServiceCollectionExtensions.AddRunicPlatformServices registers one instance for the application.
CreateSecretStore
public static IDesktopSecretStore CreateSecretStore() Creates secret storage in the user's credential store from the provider for the operating system.
Returns
A secret store; it holds no native resources between requests and needs no disposal.
Remarks
Linux uses the desktop's Secret Service, such as GNOME Keyring or KeePassXC, with either toolkit and without loading GTK; Windows uses Credential Manager and macOS the user's login keychain. It needs no window and connects to nothing until the first request. Elsewhere every request reports PlatformUnavailableReason.ProviderNotConfigured. DesktopPlatformServiceCollectionExtensions.AddRunicPlatformServices registers one instance for the application.
CreateSecretStore
public static IDesktopSecretStore CreateSecretStore(string applicationId) Creates secret storage for the application identified by applicationId.
Parameters
applicationIdThe application's identity, as for
DesktopPlatformServices.CreateNotifications: on Linux the reverse-DNS ID of its installed desktop entry, which the provider's portal requests and diagnostics carry; on Windows its AppUserModelID. The Windows and macOS stores do not use it today, and Linux stores secrets the same way with or without it, so secrets stored throughDesktopPlatformServices.CreateSecretStorestay readable.
Returns
A secret store; it holds no native resources between requests and needs no disposal.
Exceptions
ArgumentExceptionapplicationIdis empty or not a valid ID on this operating system.
Remarks
Otherwise the same as DesktopPlatformServices.CreateSecretStore, which DesktopPlatformServiceCollectionExtensions.AddRunicPlatformServices also registers; to register this one, add it to the services before calling that method.
CreateSecretStore
public static IDesktopSecretStore CreateSecretStore(string? applicationId, DesktopSecretStoreOptions options) Creates secret storage with options, for the application identified by applicationId when it is not null.
Parameters
applicationIdThe application's identity, as for
DesktopPlatformServices.CreateSecretStore, ornullas forDesktopPlatformServices.CreateSecretStore.optionsStore-wide choices: non-interactive requests, a required encrypted Secret Service session on Linux and the macOS data-protection keychain. Each provider's
CreateSecretStore(DesktopSecretStoreOptions)documents their effect.
Returns
A secret store; it holds no native resources between requests and needs no disposal.
Exceptions
ArgumentNullExceptionoptionsisnull.ArgumentExceptionapplicationIdis empty or not a valid ID on this operating system.
Remarks
Otherwise the same as DesktopPlatformServices.CreateSecretStore. DesktopPlatformServiceCollectionExtensions.AddRunicPlatformServices registers the store with default options; to register this one, add it to the services before calling that method.
CreateSettings
public static IDesktopSettings CreateSettings() Creates the desktop's appearance preferences from the provider for the operating system.
Returns
Application-scoped preferences that the caller disposes at shutdown.
Remarks
Windows reads its settings, macOS reads AppKit once the Desktop event loop runs, and Linux reads xdg-desktop-portal with either toolkit, without loading GTK. Elsewhere, or where the Windows provider does not support the running version, every read reports PlatformUnavailableReason.ProviderNotConfigured. DesktopPlatformServiceCollectionExtensions.AddRunicPlatformServices registers one instance for the application.
CreateStatusIcon
public static IDesktopStatusIcon CreateStatusIcon(string? applicationId = null) Creates the application's status icon from the provider for the operating system.
Parameters
applicationIdOn Linux the reverse-DNS ID of the installed desktop entry, used as the icon's ID;
nulluses the process name.
Returns
A status icon that the caller disposes at shutdown.
Remarks
Linux registers a StatusNotifierItem with the desktop's status area (Plasma, Waybar's tray, or GNOME with the AppIndicator extension) without loading GTK. Windows adds a notification-area icon with Shell_NotifyIcon from RGBA images, ignoring theme names, and adds it again when Explorer restarts. Creating it connects to nothing; the first IDesktopStatusIcon.ShowAsync does. macOS shows an NSStatusItem in the menu bar once the Desktop event loop runs, and reports PlatformUnavailableReason.BackendUnavailable without that loop; it ignores applicationId. DesktopPlatformServiceCollectionExtensions.AddRunicPlatformServices registers one instance for the application.
CreateThumbnails
public static IDesktopThumbnails CreateThumbnails() Creates thumbnails of files from the provider for the operating system.
Returns
Thumbnails; they need no disposal.
Remarks
Linux reads the freedesktop.org thumbnail cache and, on a miss, asks the session's org.freedesktop.thumbnails.Thumbnailer1 service, such as Tumbler, with either toolkit and without loading GTK; GNOME and KDE run no such service, so there only thumbnails their file managers cached are returned. Windows uses the shell's thumbnail providers and macOS Quick Look. It needs no window. Elsewhere every request reports PlatformUnavailableReason.ProviderNotConfigured. DesktopPlatformServiceCollectionExtensions.AddRunicPlatformServices registers one instance for the application.
CreateTrash
public static IDesktopTrash CreateTrash() Creates the user's trash from the provider for the operating system.
Returns
A trash; it holds no native resources between requests and needs no disposal.
Remarks
Linux follows the freedesktop.org Trash specification, with the Trash portal inside Flatpak or Snap, with either toolkit and without loading GTK; Windows uses the Recycle Bin and macOS the Trash. It needs no window. Elsewhere every request reports PlatformUnavailableReason.ProviderNotConfigured. DesktopPlatformServiceCollectionExtensions.AddRunicPlatformServices registers one instance for the application.
CreateVolumes
public static IDesktopVolumes CreateVolumes() Creates the desktop's storage volumes from the provider for the operating system.
Returns
Application-scoped volumes that the caller disposes at shutdown.
Remarks
Linux lists, mounts, unmounts and ejects volumes through UDisks2 on the system bus, with either toolkit and without loading GTK; UDisks2 asks Polkit for authorization and may show a prompt. It needs no window and connects to nothing until the first request. Windows lists volumes through the volume management API and ejects a drive as "Safely Remove Hardware" does; it mounts volumes itself, so mounting and unmounting report PlatformUnavailableReason.BackendUnavailable. macOS uses Disk Arbitration, as Finder does. DesktopPlatformServiceCollectionExtensions.AddRunicPlatformServices registers one instance for the application.
ExportApplicationAsync
public static ValueTask<PlatformResult<IAsyncDisposable>> ExportApplicationAsync(string applicationId, IApplicationInstance instance, CancellationToken cancellationToken = default) Serves the desktop's D-Bus activation of the application (org.freedesktop.Application) on Linux, so the desktop delivers activations and opened files to the running instance without starting a process.
Parameters
applicationIdThe reverse-DNS ID of the installed desktop entry, which names the application's bus name and object path.
instanceThe running instance from
ApplicationInstance.ClaimAsync: each activation arrives as one of its launches, and open requests created for it take the files and URLs.cancellationTokenCancels before the bus name is owned.
Returns
The export to dispose when the application ends, which releases the bus name, as PortalApplication.ExportApplicationAsync describes; every other operating system reports PlatformUnavailableReason.BackendUnavailable.
Exceptions
ArgumentExceptionapplicationIdis empty or not a valid ID on this operating system.
ForApplication
public static IApplicationPlatformServices ForApplication() Gets the application's platform services, which need no window: open URIs and files, and reveal files.
Returns
The one instance of the process; it needs no disposal.
Remarks
DesktopPlatformServiceCollectionExtensions.AddRunicPlatformServices registers it as IApplicationPlatformServices, so a service without a window takes it in its constructor; code that runs before the container exists calls this method. It works before the first window opens, with every window closed, behind a status icon, and for Windows served under RunicDesktopHostOptions.ServeOnly, where the window services report PlatformUnavailableReason.OwnerUnavailable. Open a served Window in the user's browser: if (RunicDesktopHost.GetSurface(window) is { } surface)
await DesktopPlatformServices.ForApplication().FileLauncher.LaunchUriAsync(surface.Url);
The launcher has the URI policy and results of IDesktopFileLauncher. Windows hands files and URIs to the shell on an STA thread of the application's own; Linux asks the desktop portal (OpenURI) without a parent window, with either toolkit or none; macOS asks NSWorkspace on the main thread, which the Desktop event loop runs. DesktopFileOperation.ChooseApplication shows the platform's chooser without a parent. Prefer a Window's IDesktopFileLauncher while it is shown, so the desktop can place a chooser over it. Elsewhere every operation reports PlatformUnavailableReason.ProviderNotConfigured.
ForWindow
public static DesktopWindowPlatformServices ForWindow(DesktopNativeOwner owner) Creates platform services for an open Desktop window, using DesktopPlatformServices.CurrentProvider.
Parameters
ownerThe window's native owner.
Returns
Services the caller disposes before the window's event loop stops; disposal releases acquired file access.
Remarks
A window without native dispatch, such as an installed browser after an embedded-window fallback, gets services that report PlatformUnavailableReason.OwnerUnavailable, except for file dialogs with OwnerPolicy.PreferOwner, which it shows without an owner (PlatformCapabilityIds.DialogsUnowned); a native window whose toolkit has no provider reports PlatformUnavailableReason.ProviderNotConfigured.
ForWindowPresentation
public static IRunicWindowPresentation ForWindowPresentation(DesktopWindow window) Gets the IRunicWindowPresentation of a DesktopWindow the application opened itself, for ViewModels without a Window scope, as WpfPlatformServices.ForWindowPresentation does for a WPF window.
Parameters
windowA window the application opened with
DesktopSurface.OpenWindowAsync.
Returns
The same object for every call with window. Its requests give the results that the presentation of a RunicDesktopHost Window gives for the same window.
Remarks
Pass it to the ViewModels of that window, for example through the ViewModel's constructor. A ViewModel that a DI scope with AddRunicWindowService() resolves takes the scope's own presentation instead, once DesktopPlatformServices.AttachWindowServices attached the scope to the window.
The activity and color-scheme changes are raised on the thread that reports them, one at a time and in order. A handler that throws is logged and does not stop the others. Once the window closes, requests report PlatformUnavailableReason.OwnerClosed and the activity is RunicWindowActivity.Closed. Any thread may call it.
GetDesktopWindow
public static DesktopWindow? GetDesktopWindow(IRunicWindow window) Gets the Desktop window that presents an open Runic Window, without naming its ViewModel type.
Parameters
windowThe Window, on any host. It must have opened; it may have closed since.
Returns
The DesktopBridgeWindow.Window of IRunicWindow.Host: the embedded window, or the installed browser after a fallback (DesktopWindow.Browser tells which). null for a Window on another host, such as CS-WebUI, and for one served under RUNIC_APPLICATION_SERVE_ONLY=1, which has no presentation.
Exceptions
InvalidOperationExceptionThe Window has not opened.
Remarks
For example, to hide the window, subscribe to DesktopWindow.Closed or read DesktopWindow.Capabilities. After the window closes it is the closed presentation until the Window is disposed. RunicDesktopHost.GetSurface returns the surface the same way.
GetLaunch
public static ApplicationLaunch GetLaunch(IEnumerable<string> arguments) This process's launch, with the files and URLs the operating system activated it with.
Parameters
argumentsThe process's arguments, as
Mainreceives them.
Returns
The launch to pass to ApplicationInstance.ClaimAsync and DesktopPlatformServices.CreateOpenRequests.
Remarks
The same as ApplicationLaunch.FromProcess, except in an MSIX package on Windows, where the activation's protocol URI or files (several at once in one process) become arguments too (WindowsPlatformProvider.GetLaunch).
GetWindowState
public static PlatformResult<DesktopWindowState> GetWindowState(IRunicWindow window) Gets the bounds, maximized and full-screen state of an open Runic Window, or of a closed one as it last was, to save its DesktopWindowState.Placement for the next start.
Parameters
windowThe Window, on any host. It must have opened; it may have closed since.
Returns
The state of the Window's embedded Desktop window: DesktopWindow.State of DesktopBridgeWindow.Window. After the window has closed, until the Window is disposed, it is the last state before closing, so save it after WaitForCloseAsync returns.
Exceptions
InvalidOperationExceptionThe Window has not opened.
Remarks
A Window without a native owner reports PlatformUnavailableReason.OwnerUnavailable, as DesktopPlatformServices.PresentAsync does: one on CS-WebUI or another host, one served under RUNIC_APPLICATION_SERVE_ONLY=1, and an installed browser opened after an embedded-window fallback. An embedded window whose host reports no state, a custom window host without IDesktopWindowStateHost, reports PlatformUnavailableReason.BackendUnavailable.
To restore it, return the saved placement from RunicDesktopHost.Placement. For every change while the window is open, subscribe to DesktopWindow.StateChanged of the presentation.
PresentAsync
public static ValueTask<PlatformResult<PlatformUnit>> PresentAsync(DesktopNativeOwner owner, DesktopActivationContext? context = null, CancellationToken cancellationToken = default) Asks the desktop to bring an open Desktop window to the front, for example for a second launch.
Parameters
ownerThe window's native owner.
contextThe activation token or startup ID that lets the desktop grant focus, such as
ApplicationLaunch.PlatformContextof a forwarded launch.cancellationTokenCancels before the request reaches the window.
Remarks
The desktop decides whether to grant focus; without a context many Wayland compositors only mark the window as wanting attention. Linux presents GTK 3 and GTK 4 windows. Windows restores a minimized window or shows a hidden one, and brings it to the foreground when the desktop allows it, as it does for the running instance after ApplicationInstance.ClaimAsync forwards a launch; when Windows refuses, the taskbar button flashes and the result is PlatformFailureCode.PermissionDenied. macOS orders the window front, also a hidden or minimized one, and activates the application, cooperatively on macOS 14 and later, where a forwarding launch yields to it, and otherwise as the user's request; when macOS keeps another application active, the result is PlatformFailureCode.PermissionDenied. It needs no context. A window without native dispatch, such as an installed browser, reports PlatformUnavailableReason.OwnerUnavailable, and a closed one PlatformUnavailableReason.OwnerClosed.
PresentAsync
public static ValueTask<PlatformResult<PlatformUnit>> PresentAsync(IRunicWindow window, DesktopActivationContext? context = null, CancellationToken cancellationToken = default) Asks the desktop to bring an open Runic Window to the front, for example for a second launch.
Parameters
windowThe open Window, on any host.
contextThe activation token or startup ID that lets the desktop grant focus, such as
ApplicationLaunch.PlatformContextof a forwarded launch.cancellationTokenCancels before the request reaches the window.
Exceptions
InvalidOperationExceptionThe Window has not opened.
Remarks
A Window on RunicDesktopHost is presented as DesktopPlatformServices.PresentAsync presents its DesktopBridgeWindow.NativeOwner. A Window without a native owner reports PlatformUnavailableReason.OwnerUnavailable: one served under RUNIC_APPLICATION_SERVE_ONLY=1, which has no presentation, or one on another host.