DesktopNativeOwner class

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

public sealed class DesktopNativeOwner : INativePickerOwner

Inherits or implements INativePickerOwner.

Binds native platform services to one open embedded Desktop window.

Remarks

Pass the owner to a platform provider, for example WindowsPlatformProvider.CreateFileDialogs(owner), LinuxPlatformProvider.CreateFileDialogs(owner) on Linux with GTK 3, or PortalPlatformProvider.CreateFileDialogs(Gtk4PlatformProvider.CreatePortalWindowOwner(owner)) with GTK 4 (LinuxPlatformProvider parents through GTK 3 and must not be used with a GTK 4 window). The owner belongs to the DesktopWindow it was created for: it becomes unavailable when that window closes or the surface opens a replacement, and a replacement window needs a new owner. The native handle is passed only to callbacks running on the window's native thread and must not outlive them. DesktopNativeOwner.IsAvailable is false for any window without native dispatch, for example an installed-browser presentation or a custom window host without a native handle. Create and dispose owner-bound services while the window is open.

Constructors

DesktopNativeOwner

public DesktopNativeOwner(DesktopWindow window)

Creates an owner for window.

Parameters

window

The Desktop window whose native thread runs provider callbacks.

Properties

Generation

public Guid Generation { get; }

The verified presentation generation, shared with its lifetime.

Remarks

Each owner has its own generation; an owner never follows a replacement window.

Documentation from INativePickerOwner.Generation.

IsAvailable

public bool IsAvailable { get; }

Whether the provider can currently show dialogs.

Remarks

true while the window is the surface's current embedded window, is open, and supports native dispatch.

Documentation from INativePickerOwner.IsAvailable.

Window

public DesktopWindow Window { get; }

Gets the Desktop window this owner belongs to.

Methods

CheckAccess

public bool CheckAccess()

Gets whether the caller is running on the window's native thread.

InvokeAsync

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

Revalidates owner identity and dispatches on its native thread. The handle cannot escape the callback.

Exceptions

OwnerClosedException

The window closed or was replaced before the callback started.

Documentation from INativePickerOwner.InvokeAsync.