DesktopWindow class

Namespace Runic.Desktop · Runic.Desktop 0.7.0-preview.5

public sealed class DesktopWindow : IAsyncDisposable

Inherits or implements IAsyncDisposable.

Represents one installed-browser or embedded-WebView presentation of a surface.

Properties

Browser

public BrowserKind Browser { get; }

Gets the presentation that opened.

Remarks

For a BrowserKind.Any or BrowserKind.ChromiumBased request this is the concrete browser that was launched, or BrowserKind.Any when it could not be identified.

Capabilities

public DesktopWindowCapabilities Capabilities { get; }

Gets the platform-window operations the open window supports.

Remarks

Only embedded windows report capabilities; installed browsers and closed windows report DesktopWindowCapabilities.None.

FellBack

public bool FellBack { get; }

Gets whether the embedded WebView was unavailable and the browser fallback opened instead.

IsOpen

public bool IsOpen { get; }

Gets whether this is the surface's current window and its browser process or embedded window is still open.

NativeHandle

public nint NativeHandle { get; }

Gets the native top-level handle of an open embedded window, or zero for an installed browser or closed window.

ProcessId

public ulong ProcessId { get; }

Gets the installed browser's process identifier, or zero for an embedded or closed window.

RequestedBrowser

public BrowserKind RequestedBrowser { get; }

Gets the presentation requested by DesktopWindowOptions.Browser.

SupportsNativeDispatch

public bool SupportsNativeDispatch { get; }

Whether this live embedded owner supports native-thread callbacks.

Methods

CheckNativeAccess

public bool CheckNativeAccess()

Whether the caller is executing on the live native owner's thread.

CloseAsync

public ValueTask CloseAsync()

Forcibly closes this window without awaiting confirmation. Use RequestCloseAsync for user actions.

DispatchNativeAsync

public ValueTask DispatchNativeAsync(Action<nint> action, CancellationToken cancellationToken = default)

Runs native work on this owner's thread. Cancellation prevents queued work; a running callback is awaited to completion. No native handle may outlive this window.

DisposeAsync

public ValueTask DisposeAsync()

Forcibly closes the window, like DesktopWindow.CloseAsync.

FocusAsync

public Task FocusAsync(CancellationToken cancellationToken = default)

Activates the window and gives it keyboard focus.

Parameters

cancellationToken

Cancels waiting for the window and the queued native operation.

Returns

A task that completes when the window has been focused.

Exceptions

ObjectDisposedException

The surface is disposed, or this window is closed or was replaced.

DesktopException

The window lacks the required capability (window-capability-unavailable).

OperationCanceledException

cancellationToken was cancelled.

Remarks

Requires DesktopWindowCapabilities.Focus.

MinimizeAsync

public Task MinimizeAsync(CancellationToken cancellationToken = default)

Minimizes the window.

Parameters

cancellationToken

Cancels waiting for the window and the queued native operation.

Returns

A task that completes when the window has been minimized.

Exceptions

ObjectDisposedException

The surface is disposed, or this window is closed or was replaced.

DesktopException

The window lacks the required capability (window-capability-unavailable).

OperationCanceledException

cancellationToken was cancelled.

Remarks

Requires DesktopWindowCapabilities.Minimize.

MoveAsync

public ValueTask MoveAsync(uint x, uint y, CancellationToken cancellationToken = default)

Moves the window to a screen position.

Parameters

x

The new horizontal position in pixels.

y

The new vertical position in pixels.

cancellationToken

Cancels waiting for the window and the queued native operation.

Returns

A task that completes when the window has been moved.

Exceptions

ObjectDisposedException

The surface is disposed, or this window is closed or was replaced.

DesktopException

The window lacks the required capability (window-capability-unavailable).

OperationCanceledException

cancellationToken was cancelled.

Remarks

Requires DesktopWindowCapabilities.Move.

RequestCloseAsync

public ValueTask<bool> RequestCloseAsync(CancellationToken cancellationToken = default)

Requests closing, awaiting the same confirmation as the native close button.

Remarks

Cancelling the caller stops its wait, without cancelling another caller's shared decision.

ResizeAsync

public ValueTask ResizeAsync(uint width, uint height, CancellationToken cancellationToken = default)

Resizes the window.

Parameters

width

The new width in pixels.

height

The new height in pixels.

cancellationToken

Cancels waiting for the window and the queued native operation.

Returns

A task that completes when the window has been resized.

Exceptions

ObjectDisposedException

The surface is disposed, or this window is closed or was replaced.

DesktopException

The window lacks the required capability (window-capability-unavailable).

OperationCanceledException

cancellationToken was cancelled.

Remarks

Requires DesktopWindowCapabilities.Resize.

ToggleMaximizedAsync

public Task ToggleMaximizedAsync(CancellationToken cancellationToken = default)

Maximizes the window, or restores it when it is already maximized.

Parameters

cancellationToken

Cancels waiting for the window and the queued native operation.

Returns

A task that completes when the window state has changed.

Exceptions

ObjectDisposedException

The surface is disposed, or this window is closed or was replaced.

DesktopException

The window lacks the required capability (window-capability-unavailable).

OperationCanceledException

cancellationToken was cancelled.

Remarks

Requires DesktopWindowCapabilities.Maximize.

WaitForClose

public void WaitForClose(CancellationToken cancellationToken = default)

Blocks until this presentation closes while servicing platform window events.