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>
77 lines
2.0 KiB
C#
77 lines
2.0 KiB
C#
using System;
|
|
using Microsoft.Maui.Dispatching;
|
|
using Microsoft.Maui.Platform.Linux.Native;
|
|
|
|
namespace Microsoft.Maui.Platform.Linux.Dispatching;
|
|
|
|
public class LinuxDispatcher : IDispatcher
|
|
{
|
|
private static int _mainThreadId;
|
|
|
|
private static LinuxDispatcher? _mainDispatcher;
|
|
|
|
private static readonly object _lock = new object();
|
|
|
|
public static LinuxDispatcher? Main => _mainDispatcher;
|
|
|
|
public static bool IsMainThread => Environment.CurrentManagedThreadId == _mainThreadId;
|
|
|
|
public bool IsDispatchRequired => !IsMainThread;
|
|
|
|
public static void Initialize()
|
|
{
|
|
lock (_lock)
|
|
{
|
|
_mainThreadId = Environment.CurrentManagedThreadId;
|
|
_mainDispatcher = new LinuxDispatcher();
|
|
Console.WriteLine($"[LinuxDispatcher] Initialized on thread {_mainThreadId}");
|
|
}
|
|
}
|
|
|
|
public bool Dispatch(Action action)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(action, "action");
|
|
if (!IsDispatchRequired)
|
|
{
|
|
action();
|
|
return true;
|
|
}
|
|
GLibNative.IdleAdd(delegate
|
|
{
|
|
try
|
|
{
|
|
action();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine("[LinuxDispatcher] Error in dispatched action: " + ex.Message);
|
|
}
|
|
return false;
|
|
});
|
|
return true;
|
|
}
|
|
|
|
public bool DispatchDelayed(TimeSpan delay, Action action)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(action, "action");
|
|
GLibNative.TimeoutAdd((uint)Math.Max(0.0, delay.TotalMilliseconds), delegate
|
|
{
|
|
try
|
|
{
|
|
action();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine("[LinuxDispatcher] Error in delayed action: " + ex.Message);
|
|
}
|
|
return false;
|
|
});
|
|
return true;
|
|
}
|
|
|
|
public IDispatcherTimer CreateTimer()
|
|
{
|
|
return new LinuxDispatcherTimer(this);
|
|
}
|
|
}
|