public sealed record DesktopWindowOptions : IEquatable<DesktopWindowOptions> Configures one browser or embedded-WebView presentation.
Constructors
DesktopWindowOptions
public DesktopWindowOptions() No documentation.
Properties
AllowedPermissions
public DesktopPermissionGrant AllowedPermissions { get; init; } Gets the sensitive permissions granted to the presentation; none by default.
Browser
public BrowserKind Browser { get; init; } Gets the presentation: the platform's embedded WebView by default, or an installed browser.
Remarks
On Linux, the embedded WebView requires DesktopHostOptions.Linux to select a toolkit.
BrowserArguments
public string? BrowserArguments { get; init; } Gets additional command-line arguments for the browser or WebView2 runtime.
Remarks
The string is split like a command line and appended to the launch arguments. When set, installed browsers no longer receive Runic Desktop's default isolation flags. The macOS and GTK 3 embedded windows ignore it.
Centered
public bool Centered { get; init; } Gets whether the embedded window opens centered on the screen, replacing DesktopWindowOptions.X and DesktopWindowOptions.Y.
CloseDrainAsync
public Func<DesktopCloseDrainContext, CancellationToken, ValueTask>? CloseDrainAsync { get; init; } Gets the close drain: after a close was approved, the native window stays open and visible until this returns, and then closes without asking again. null, the default, closes the window at once.
Remarks
It runs once per window, on the thread pool, when the user's close, DesktopWindow.RequestCloseAsync or a quit's close guard has been approved (after DesktopWindowOptions.ConfirmCloseAsync, so a refusal changes nothing), and when the host shuts down (DesktopCloseReason.Shutdown). Wait here for the application's work that must not stop halfway, such as AcceptedWorkScope.WaitForAcceptedAsync: CloseDrainAsync = (_, ct) => new(work.WaitForAcceptedAsync(ct)). The window stays responsive meanwhile: it moves, minimizes and repaints, and its page stays connected. A second close by the user while it runs is ignored, and DesktopWindow.RequestCloseAsync returns true as soon as the close was approved.
The token is cancelled when the window is closed by force (DesktopWindow.CloseAsync, disposal), when the host's shutdown reaches DesktopHostOptions.ShutdownDrainTimeout, and when the host is disposed; the window then closes even if the callback has not returned. Cancellation ends only the visible phase: Runic cancels none of the application's work. An exception is logged (event 3022, WindowCloseDrainFailed) and the window closes.
The window must be able to refuse a close: the embedded window of every built-in host does (DesktopWindowCapabilities.CloseConfirmation). An installed browser cannot keep its window open: there the drain runs after the window is gone, and DesktopWindow.WaitForCloseAsync returns after it. The window then opens with the warning close-drain-unavailable.
ColorScheme
public DesktopColorScheme ColorScheme { get; init; } Gets the light or dark appearance of the embedded window, or DesktopColorScheme.NoPreference, the default, to follow the system.
Remarks
The page's prefers-color-scheme and the window's own title bar and controls follow it. The macOS window sets NSWindow.appearance to Aqua or Dark Aqua. The Windows window sets the WebView2 profile's preferred color scheme and the title bar's dark mode; WebView2 applies the scheme to the whole profile, so windows that share a DesktopWindowOptions.ProfilePath show the last one opened with a scheme. Without the option a Windows title bar follows the system's app mode (Settings > Personalization > Colors), also when it changes while the window is open, and a contrast theme's colours, while the page's prefers-color-scheme follows the system.
The GTK windows and installed browsers cannot set it per window: they ignore it, and DesktopHost.Validate reports color-scheme-unsupported. A custom window host receives it in DesktopWindowHostOptions.ColorScheme.
ConfirmCloseAsync
public Func<CancellationToken, ValueTask<bool>>? ConfirmCloseAsync { get; init; } Asynchronously approves a user close request. Requires the embedded window.
Remarks
A browser cannot keep its window open: an explicitly selected browser fails with close-confirmation-unavailable, and an DesktopPresentationPolicy.EmbeddedThenBrowser fallback opens without confirmation and reports close-confirmation-unavailable as a warning. Runs on the thread pool. Return false to keep the window open. Exceptions and cancellation deny closing. Concurrent requests share a decision. The token is cancelled when the window is forcibly closed. CloseAsync and disposal bypass confirmation; marshal native UI work to its owning thread.
Fallbacks
public IReadOnlyList<BrowserKind> Fallbacks { get; init; } Gets the presentations tried in order when the first one cannot open; empty by default.
Remarks
The window opens the first presentation, DesktopWindowOptions.Browser (or the embedded WebView under DesktopPresentationPolicy.EmbeddedThenBrowser), and, when that is unavailable or fails to start, each entry of this list in turn, for example [BrowserKind.ChromiumBased, BrowserKind.Firefox] after the embedded WebView. Under DesktopPresentationPolicy.EmbeddedThenBrowser a non-empty list replaces the single fallback browser; DesktopWindowOptions.Browser must then be BrowserKind.Embedded.
A presentation that opened but whose page never connected (connection-timeout) ends the chain, because the next one would load the same frontend. When every presentation fails, the window fails with a DesktopPresentationException whose DesktopPresentationException.Attempts lists why each one failed. An installed browser after the first presentation opens without DesktopWindowOptions.AllowedPermissions and without DesktopWindowOptions.ConfirmCloseAsync, as the DesktopPresentationPolicy.EmbeddedThenBrowser fallback does; an embedded WebView keeps both. The other options apply to every presentation. An entry may not repeat the first presentation or another entry.
Frameless
public bool Frameless { get; init; } Gets whether the embedded window opens without a title bar and border.
Height
public int Height { get; init; } Gets the initial window height in pixels. Defaults to 600.
Hidden
public bool Hidden { get; init; } Gets whether the presentation opens without a visible window.
Remarks
Embedded windows are created hidden; installed browsers run headless. DesktopWindow.FocusAsync shows a hidden embedded window and gives it focus; DesktopWindow has no other show or hide member.
HighContrast
public bool? HighContrast { get; init; } Gets whether the presentation reports a high-contrast theme to the page, or null to follow DesktopPlatform.IsHighContrast.
IconFile
public string? IconFile { get; init; } Gets the path of the embedded window's icon file, or null for the default icon.
Kiosk
public bool Kiosk { get; init; } Gets whether the presentation opens in full-screen kiosk mode without window decorations.
Language
public string? Language { get; init; } Gets the BCP 47 language of the embedded web view's own text, such as ar-EG, or null, the default, for the platform's.
Remarks
The language of the web view's built-in text, such as its context menu and form validation messages, its navigator.language and the Accept-Language it sends: WebView2's environment language on Windows and WebKitGTK's preferred languages on Linux. WebView2 takes the closest language it ships, such as ar for ar-EG, for its own text and navigator.language. macOS ignores it: WKWebView uses the application's preferred languages. A page still sets its own lang. Installed browsers ignore it.
WebView2 requires every window sharing a DesktopWindowOptions.ProfilePath to use the same language, as for DesktopWindowOptions.BrowserArguments: a second window with another language fails to open. Windows without a profile path get their own temporary profile.
LayoutDirection
public DesktopLayoutDirection LayoutDirection { get; init; } Gets the direction of the embedded window's native parts: DesktopLayoutDirection.Default, the default, keeps the platform's.
Remarks
DesktopLayoutDirection.RightToLeft mirrors the Windows window: its title bar, caption buttons and system menu (WS_EX_LAYOUTRTL); the WebView2 page keeps its own layout, which it sets with <html dir="rtl">. On Linux it sets the direction of the GTK window and of Runic's widgets in it. macOS ignores it: AppKit lays windows out for the application bundle's localization.
Choose it with the application's language, for example LayoutDirection = culture.TextInfo.IsRightToLeft ? DesktopLayoutDirection.RightToLeft : DesktopLayoutDirection.LeftToRight. Installed browsers ignore it.
MacOS
public MacOSWindowOptions MacOS { get; init; } Gets the macOS window's title bar options: a hidden or transparent title bar that keeps the traffic lights, and where they sit. Other platforms and installed browsers ignore them.
MenuBarPresentation
public DesktopMenuBarPresentation MenuBarPresentation { get; init; } Gets where the window shows the menu bar of DesktopHostOptions.MenuBar: DesktopMenuBarPresentation.Native, the default, shows it natively.
Remarks
DesktopMenuBarPresentation.Page leaves the bar to the page, which renders DesktopHost.MenuBar with its own components, and DesktopMenuBarPresentation.None shows no bar; with both the host still matches the items' shortcuts. A frameless or kiosk window shows no bar in the window. DesktopWindow.MenuBarPlacement reports where the bar went. An installed browser and a window host without DesktopWindowCapabilities.MenuBar show no native bar, and DesktopHost.Validate reports menu-bar-unsupported for a declared bar with this presentation.
MinimumHeight
public int? MinimumHeight { get; init; } Gets the minimum window height in pixels, or null for no minimum.
Remarks
Applies only together with DesktopWindowOptions.MinimumWidth, and only to embedded windows.
MinimumWidth
public int? MinimumWidth { get; init; } Gets the minimum window width in pixels, or null for no minimum.
Remarks
Applies only together with DesktopWindowOptions.MinimumHeight, and only to embedded windows.
Modality
public DesktopWindowModality Modality { get; init; } Gets whether the window blocks its DesktopWindowOptions.Owner while it is open. The default is DesktopWindowModality.None.
Remarks
DesktopWindowModality.Window needs an DesktopWindowOptions.Owner. The owner then takes no input, and ignores the user's close, while this window is shown: on Windows it is disabled (EnableWindow), on macOS the window is a sheet of the owner (AppKit queues a second sheet of one owner until the first ends), and on Linux the owner's GTK window is insensitive. A DesktopWindowOptions.Hidden window blocks its owner from its first show. Other windows of the application stay usable.
MonitorId
public string? MonitorId { get; init; } Gets the DesktopMonitor.Id of the monitor the embedded window opens on, centered on its work area, or null, the default, to let the platform choose.
Remarks
Takes the place of DesktopWindowOptions.X, DesktopWindowOptions.Y and DesktopWindowOptions.Centered. A DesktopWindowOptions.Placement with a position decides instead, so a restored window opens where it was. A monitor that is not connected leaves the choice to the platform, and a window shrinks to fit the monitor's work area. Requires DesktopWindowCapabilities.MonitorPlacement; on Wayland the GTK 4 window still opens a DesktopWindowPlacement.FullScreen placement on this monitor. Installed browsers ignore it.
Owner
public DesktopWindowOwner? Owner { get; init; } Gets the window this window belongs to, or null, the default, for a window of its own.
Remarks
An owned window stays above its owner and is not shown in the taskbar on its own: on Windows its owner is the owner's HWND, on macOS it is a child window of the owner's NSWindow (a sheet when it is window-modal), and on Linux it is transient_for the owner's GTK window. When the owner is a DesktopWindow (DesktopWindowOwner.FromWindow), a close the owner's DesktopWindowOptions.ConfirmCloseAsync decides, and a quit, first ask the confirmation of the windows it owns, innermost first; any other close of the owner closes them without asking. Hiding or showing the owner with DesktopWindow.SetVisibleAsync hides or shows them with it.
Only the embedded window applies it, on a host whose capabilities include DesktopWindowCapabilities.Ownership. An installed browser or another host ignores it and DesktopHost.Validate reports window-option-unsupported. An owner that is not open, or that is an installed browser, is ignored when the window opens and reported as window-owner-unavailable.
Placement
public DesktopWindowPlacement? Placement { get; init; } Gets a saved placement to restore, from DesktopWindowState.Placement, or null, the default, to open with DesktopWindowOptions.Width, DesktopWindowOptions.Height, DesktopWindowOptions.X, DesktopWindowOptions.Y and DesktopWindowOptions.Centered.
Remarks
A placement replaces DesktopWindowOptions.Width, DesktopWindowOptions.Height, DesktopWindowOptions.X, DesktopWindowOptions.Y and DesktopWindowOptions.Centered. An embedded window that reports DesktopWindowCapabilities.State keeps it on a monitor that exists now: when the saved bounds are not inside one monitor's work area (the screen without the taskbar, Dock or panels), for example because they were saved on an external monitor that is no longer connected, the window moves to the work area it overlaps most, or else to the nearest one, and shrinks to fit it. A placement without a position keeps the platform's choice of position and is only shrunk to fit. The window then opens maximized when DesktopWindowPlacement.Maximized is set, unless DesktopWindowOptions.Kiosk is set, and restores to the saved bounds.
A saved placement never fails the open: a zero width or height keeps DesktopWindowOptions.Width or DesktopWindowOptions.Height, a position with only one coordinate is ignored, and a size above 65535 is reduced to it. On Linux the position is restored on X11 only: on Wayland the compositor places every window, so the GTK 3 and GTK 4 windows restore the size, maximized and full-screen state there and ignore the position, which Wayland cannot set; a placement saved on Wayland has none. An installed browser opens with the saved size and position as it would with DesktopWindowOptions.Width, DesktopWindowOptions.Height, DesktopWindowOptions.X and DesktopWindowOptions.Y, without fitting them to a monitor or maximizing; DesktopHost.Validate reports the ignored maximized state.
PresentationPolicy
public DesktopPresentationPolicy PresentationPolicy { get; init; } Gets whether the window may fall back to an installed browser when the embedded WebView cannot open.
Remarks
Defaults to DesktopPresentationPolicy.RequestedOnly. With DesktopPresentationPolicy.EmbeddedThenBrowser, the embedded WebView is tried first and DesktopWindowOptions.Browser selects the fallback browser, where BrowserKind.Embedded means BrowserKind.Any. The fallback opens without DesktopWindowOptions.AllowedPermissions.
ProfileName
public string? ProfileName { get; init; } Gets the name of an existing Firefox profile to open.
Remarks
Only Firefox applies it, and only when DesktopWindowOptions.ProfilePath is not set.
ProfilePath
public string? ProfilePath { get; init; } Gets the browser profile directory, created when missing.
Remarks
Chromium-based browsers and WebView2 use it as their user-data directory, and Firefox as its profile. The macOS and GTK 3 embedded windows ignore it. When neither this nor DesktopWindowOptions.ProfileName is set, a fresh temporary profile is generated for the presentation.
ProxyServer
public string? ProxyServer { get; init; } Gets the proxy server passed to a Chromium-based browser, such as http://proxy:8080.
Remarks
Without it, Chromium-based browsers start with no proxy unless DesktopWindowOptions.BrowserArguments is set. Embedded windows use the system proxy, and Firefox ignores the option.
Resizable
public bool Resizable { get; init; } Gets whether the user can resize the embedded window. Defaults to true.
SpellChecking
public bool SpellChecking { get; init; } Gets whether the embedded window's spell checker marks misspelled words in the page's editable fields; true, the default.
Remarks
With the default, every platform checks the fields the HTML spellcheck attribute selects: text areas, text inputs and contenteditable elements, unless they or an ancestor have spellcheck="false". WebView2 and WKWebView do so on their own; on Linux, Runic turns WebKitGTK's spell checker on. The languages are the application's, DesktopHostOptions.SpellCheckingLanguages.
false keeps the native checker off in this window, for example for an editor that draws its own spelling marks: every document in the window starts with spellcheck="false" on its root element, which the page's fields inherit. An element with its own spellcheck="true" is still checked. WebView2, WKWebView and WebKitGTK have no switch for one window (the checkers of WebKitGTK and macOS belong to the process), so every platform applies the option this way. A window host applies it when it runs DesktopWindowHostOptions.DocumentStartScript, as every built-in host does. Installed browsers ignore it.
Transparent
public bool Transparent { get; init; } Gets whether the embedded window has a transparent background where the page does not paint.
WebContent
public DesktopWebContentPolicy WebContent { get; init; } Gets what the embedded window does with navigation away from the application, new windows, downloads and developer tools. Installed browsers do not apply it.
Width
public int Width { get; init; } Gets the initial window width in pixels. Defaults to 800.
X
public int? X { get; init; } Gets the initial horizontal screen position in pixels, or null to let the platform choose.
Remarks
Applies only together with DesktopWindowOptions.Y; DesktopWindowOptions.Centered takes precedence. Firefox ignores it, and installed browsers ignore a negative position. When unset, the Windows WebView2 window opens at (100, 100). Windows scales DesktopWindowOptions.Width and DesktopWindowOptions.Height for the monitor DPI, but not the position.
Y
public int? Y { get; init; } Gets the initial vertical screen position in pixels, or null to let the platform choose.
Remarks
Applies only together with DesktopWindowOptions.X; DesktopWindowOptions.Centered takes precedence. Firefox ignores it, and installed browsers ignore a negative position. When unset, the Windows WebView2 window opens at (100, 100). Windows scales DesktopWindowOptions.Width and DesktopWindowOptions.Height for the monitor DPI, but not the position.