Gtk4WindowHostFactory class

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

public sealed class Gtk4WindowHostFactory : ILinuxDesktopWindowHostFactory, IDesktopWindowHostFactory, IDesktopEventLoopWindowHostFactory

Inherits or implements ILinuxDesktopWindowHostFactory, IDesktopWindowHostFactory, IDesktopEventLoopWindowHostFactory.

Creates explicitly selected GTK 4 and WebKitGTK 6 window hosts.

Constructors

Gtk4WindowHostFactory

public Gtk4WindowHostFactory()

No documentation.

Properties

ApplicationId

public string? ApplicationId { get; init; }

Gets the reverse-DNS GTK application ID Gtk4WindowHostFactory.RunEventLoop uses, or null for the default.

Remarks

Inside Flatpak the default is the package ID, and an explicit ID must match it.

Backend

public LinuxEmbeddedBackend Backend { get; }

Gets the toolkit and WebKit ABI that this factory's window hosts load.

Documentation from ILinuxDesktopWindowHostFactory.Backend.

Capabilities

public DesktopWindowCapabilities Capabilities { get; }

Gets the operations advertised by this provider before opening.

Documentation from IDesktopWindowHostFactory.Capabilities.

IsSupported

public bool IsSupported { get; }

Gets whether the required platform runtime is available.

Documentation from IDesktopWindowHostFactory.IsSupported.

Methods

Create

public IDesktopWindowHost Create()

Creates a new, initially closed host.

Documentation from IDesktopWindowHostFactory.Create.

GetAvailabilityDiagnostics

public IReadOnlyList<DesktopDiagnostic> GetAvailabilityDiagnostics()

Reports each missing prerequisite while IDesktopWindowHostFactory.IsSupported is false.

Remarks

Reports linux-embedded-backend-conflict, gtk4-runtime-missing and webkitgtk6-runtime-missing together.

Documentation from IDesktopWindowHostFactory.GetAvailabilityDiagnostics.

PrepareEventLoop

public IReadOnlyList<DesktopDiagnostic> PrepareEventLoop()

Checks, on the thread that will run the loop, whether IDesktopEventLoopWindowHostFactory.RunEventLoop can start.

Returns

The reasons the loop cannot run, or an empty list when it can.

Remarks

Opens the GTK display with gtk_init_check on the main thread, because gtk_init would end the process when no display is available (an SSH session, a headless machine, or WSL without WSLg). When no display opens it returns gtk4-display-unavailable, and the factory is unsupported from then on.

Documentation from IDesktopEventLoopWindowHostFactory.PrepareEventLoop.

RunEventLoop

public int RunEventLoop(Func<Task<int>> application)

Runs application while the native toolkit owns the calling main thread.

Parameters

application

The application work. Windows from this factory can open while it runs.

Returns

The value returned by application.

Remarks

Runs the GTK 4 application lifetime of Gtk4Application with Gtk4WindowHostFactory.ApplicationId.

Documentation from IDesktopEventLoopWindowHostFactory.RunEventLoop.

ValidateOptions

public IReadOnlyList<DesktopDiagnostic> ValidateOptions(DesktopWindowHostOptions options)

Reports the requested window options this provider cannot apply, without creating a window.

Remarks

GTK 4 windows reject X, Y, Centered, Transparent, HighContrast, ProfilePath, BrowserArguments and IconFile.

Documentation from IDesktopWindowHostFactory.ValidateOptions.