Core Infrastructure: - Add Dispatching folder with LinuxDispatcher, LinuxDispatcherProvider, LinuxDispatcherTimer - Add Native folder with P/Invoke wrappers (GTK, GLib, GDK, Cairo, WebKit) - Add GTK host window system with GtkHostWindow and GtkSkiaSurfaceWidget - Update LinuxApplication with GTK mode, theme handling, and icon support - Fix duplicate LinuxDispatcher in LinuxMauiContext Handlers: - Add GtkWebViewManager and GtkWebViewPlatformView for GTK WebView - Add FlexLayoutHandler and GestureManager - Update multiple handlers with ToViewHandler fix and missing mappers - Add MauiHandlerExtensions with ToViewHandler extension method Views: - Add SkiaContextMenu with hover, keyboard, and dark theme support - Add LinuxDialogService with context menu management - Add SkiaFlexLayout for flex container support - Update SkiaShell with RefreshTheme, MauiShell, ContentRenderer - Update SkiaWebView with SetMainWindow, ProcessGtkEvents - Update SkiaImage with LoadFromBitmap method Services: - Add AppInfoService, ConnectivityService, DeviceDisplayService, DeviceInfoService - Add GtkHostService, GtkContextMenuService, MauiIconGenerator Window: - Add CursorType enum and GtkHostWindow - Update X11Window with SetIcon, SetCursor methods Build: SUCCESS (0 errors) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
57 lines
1.6 KiB
C#
57 lines
1.6 KiB
C#
using System;
|
|
using Microsoft.Maui.Platform.Linux.Handlers;
|
|
using Microsoft.Maui.Platform.Linux.Window;
|
|
|
|
namespace Microsoft.Maui.Platform.Linux.Services;
|
|
|
|
/// <summary>
|
|
/// Singleton service that manages the GTK host window and WebView manager.
|
|
/// Provides centralized access to the GTK infrastructure for MAUI applications.
|
|
/// </summary>
|
|
public class GtkHostService
|
|
{
|
|
private static GtkHostService? _instance;
|
|
private GtkHostWindow? _hostWindow;
|
|
private GtkWebViewManager? _webViewManager;
|
|
|
|
public static GtkHostService Instance => _instance ??= new GtkHostService();
|
|
|
|
public GtkHostWindow? HostWindow => _hostWindow;
|
|
public GtkWebViewManager? WebViewManager => _webViewManager;
|
|
public bool IsInitialized => _hostWindow != null;
|
|
|
|
public event EventHandler<GtkHostWindow>? HostWindowCreated;
|
|
|
|
public void Initialize(string title, int width, int height)
|
|
{
|
|
if (_hostWindow == null)
|
|
{
|
|
_hostWindow = new GtkHostWindow(title, width, height);
|
|
_webViewManager = new GtkWebViewManager(_hostWindow);
|
|
HostWindowCreated?.Invoke(this, _hostWindow);
|
|
}
|
|
}
|
|
|
|
public GtkHostWindow GetOrCreateHostWindow(string title = "MAUI Application", int width = 800, int height = 600)
|
|
{
|
|
if (_hostWindow == null)
|
|
{
|
|
Initialize(title, width, height);
|
|
}
|
|
return _hostWindow!;
|
|
}
|
|
|
|
public void SetWindowIcon(string iconPath)
|
|
{
|
|
_hostWindow?.SetIcon(iconPath);
|
|
}
|
|
|
|
public void Shutdown()
|
|
{
|
|
_webViewManager?.Clear();
|
|
_webViewManager = null;
|
|
_hostWindow?.Dispose();
|
|
_hostWindow = null;
|
|
}
|
|
}
|