2025-12-21 13:26:56 -05:00
|
|
|
// Licensed to the .NET Foundation under one or more agreements.
|
|
|
|
|
// The .NET Foundation licenses this file to you under the MIT license.
|
|
|
|
|
|
|
|
|
|
using Microsoft.Maui.Controls;
|
|
|
|
|
using Microsoft.Maui.Handlers;
|
Major production merge: GTK support, context menus, and dispatcher fixes
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>
2026-01-01 11:19:58 -05:00
|
|
|
using Microsoft.Maui.Platform.Linux.Hosting;
|
2025-12-21 13:26:56 -05:00
|
|
|
using SkiaSharp;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.Maui.Platform.Linux.Handlers;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Handler for Frame on Linux using SkiaFrame.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class FrameHandler : ViewHandler<Frame, SkiaFrame>
|
|
|
|
|
{
|
|
|
|
|
public static IPropertyMapper<Frame, FrameHandler> Mapper =
|
|
|
|
|
new PropertyMapper<Frame, FrameHandler>(ViewMapper)
|
|
|
|
|
{
|
|
|
|
|
[nameof(Frame.BorderColor)] = MapBorderColor,
|
|
|
|
|
[nameof(Frame.CornerRadius)] = MapCornerRadius,
|
|
|
|
|
[nameof(Frame.HasShadow)] = MapHasShadow,
|
|
|
|
|
[nameof(Frame.BackgroundColor)] = MapBackgroundColor,
|
|
|
|
|
[nameof(Frame.Padding)] = MapPadding,
|
|
|
|
|
[nameof(Frame.Content)] = MapContent,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public FrameHandler() : base(Mapper)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public FrameHandler(IPropertyMapper? mapper)
|
|
|
|
|
: base(mapper ?? Mapper)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override SkiaFrame CreatePlatformView()
|
|
|
|
|
{
|
|
|
|
|
return new SkiaFrame();
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-01 17:08:52 -05:00
|
|
|
protected override void ConnectHandler(SkiaFrame platformView)
|
|
|
|
|
{
|
|
|
|
|
base.ConnectHandler(platformView);
|
|
|
|
|
if (VirtualView is View view)
|
|
|
|
|
{
|
|
|
|
|
platformView.MauiView = view;
|
|
|
|
|
}
|
|
|
|
|
platformView.Tapped += OnPlatformViewTapped;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void DisconnectHandler(SkiaFrame platformView)
|
|
|
|
|
{
|
|
|
|
|
platformView.Tapped -= OnPlatformViewTapped;
|
|
|
|
|
platformView.MauiView = null;
|
|
|
|
|
base.DisconnectHandler(platformView);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnPlatformViewTapped(object? sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (VirtualView is View view)
|
|
|
|
|
{
|
|
|
|
|
GestureManager.ProcessTap(view, 0.0, 0.0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-21 13:26:56 -05:00
|
|
|
public static void MapBorderColor(FrameHandler handler, Frame frame)
|
|
|
|
|
{
|
|
|
|
|
if (frame.BorderColor != null)
|
|
|
|
|
{
|
2026-01-16 05:31:21 +00:00
|
|
|
handler.PlatformView.Stroke = frame.BorderColor;
|
2025-12-21 13:26:56 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapCornerRadius(FrameHandler handler, Frame frame)
|
|
|
|
|
{
|
|
|
|
|
handler.PlatformView.CornerRadius = frame.CornerRadius;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapHasShadow(FrameHandler handler, Frame frame)
|
|
|
|
|
{
|
|
|
|
|
handler.PlatformView.HasShadow = frame.HasShadow;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapBackgroundColor(FrameHandler handler, Frame frame)
|
|
|
|
|
{
|
|
|
|
|
if (frame.BackgroundColor != null)
|
|
|
|
|
{
|
2026-01-17 03:10:29 +00:00
|
|
|
handler.PlatformView.BackgroundColor = frame.BackgroundColor;
|
2025-12-21 13:26:56 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapPadding(FrameHandler handler, Frame frame)
|
|
|
|
|
{
|
|
|
|
|
handler.PlatformView.SetPadding(
|
|
|
|
|
(float)frame.Padding.Left,
|
|
|
|
|
(float)frame.Padding.Top,
|
|
|
|
|
(float)frame.Padding.Right,
|
|
|
|
|
(float)frame.Padding.Bottom);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapContent(FrameHandler handler, Frame frame)
|
|
|
|
|
{
|
|
|
|
|
if (handler.PlatformView is null || handler.MauiContext is null) return;
|
|
|
|
|
|
|
|
|
|
handler.PlatformView.ClearChildren();
|
|
|
|
|
|
|
|
|
|
var content = frame.Content;
|
|
|
|
|
if (content != null)
|
|
|
|
|
{
|
|
|
|
|
// Create handler for content if it doesn't exist
|
|
|
|
|
if (content.Handler == null)
|
|
|
|
|
{
|
Major production merge: GTK support, context menus, and dispatcher fixes
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>
2026-01-01 11:19:58 -05:00
|
|
|
content.Handler = content.ToViewHandler(handler.MauiContext);
|
2025-12-21 13:26:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (content.Handler?.PlatformView is SkiaView skiaContent)
|
|
|
|
|
{
|
|
|
|
|
handler.PlatformView.AddChild(skiaContent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|