2025-12-19 09:30:16 +00: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.Handlers;
|
|
|
|
|
using Microsoft.Maui.Graphics;
|
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.Controls;
|
2025-12-19 09:30:16 +00:00
|
|
|
using SkiaSharp;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.Maui.Platform.Linux.Handlers;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Handler for Entry on Linux using Skia rendering.
|
|
|
|
|
/// Maps IEntry interface to SkiaEntry platform view.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class EntryHandler : ViewHandler<IEntry, SkiaEntry>
|
|
|
|
|
{
|
|
|
|
|
public static IPropertyMapper<IEntry, EntryHandler> Mapper = new PropertyMapper<IEntry, EntryHandler>(ViewHandler.ViewMapper)
|
|
|
|
|
{
|
|
|
|
|
[nameof(ITextInput.Text)] = MapText,
|
|
|
|
|
[nameof(ITextStyle.TextColor)] = MapTextColor,
|
|
|
|
|
[nameof(ITextStyle.Font)] = MapFont,
|
|
|
|
|
[nameof(ITextStyle.CharacterSpacing)] = MapCharacterSpacing,
|
|
|
|
|
[nameof(IPlaceholder.Placeholder)] = MapPlaceholder,
|
|
|
|
|
[nameof(IPlaceholder.PlaceholderColor)] = MapPlaceholderColor,
|
|
|
|
|
[nameof(ITextInput.IsReadOnly)] = MapIsReadOnly,
|
|
|
|
|
[nameof(ITextInput.MaxLength)] = MapMaxLength,
|
|
|
|
|
[nameof(ITextInput.CursorPosition)] = MapCursorPosition,
|
|
|
|
|
[nameof(ITextInput.SelectionLength)] = MapSelectionLength,
|
|
|
|
|
[nameof(IEntry.IsPassword)] = MapIsPassword,
|
|
|
|
|
[nameof(IEntry.ReturnType)] = MapReturnType,
|
|
|
|
|
[nameof(IEntry.ClearButtonVisibility)] = MapClearButtonVisibility,
|
2026-01-16 04:40:02 +00:00
|
|
|
[nameof(IEntry.IsTextPredictionEnabled)] = MapIsTextPredictionEnabled,
|
|
|
|
|
[nameof(IEntry.IsSpellCheckEnabled)] = MapIsSpellCheckEnabled,
|
2025-12-19 09:30:16 +00:00
|
|
|
[nameof(ITextAlignment.HorizontalTextAlignment)] = MapHorizontalTextAlignment,
|
|
|
|
|
[nameof(ITextAlignment.VerticalTextAlignment)] = MapVerticalTextAlignment,
|
|
|
|
|
[nameof(IView.Background)] = MapBackground,
|
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
|
|
|
["BackgroundColor"] = MapBackgroundColor,
|
2025-12-19 09:30:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public static CommandMapper<IEntry, EntryHandler> CommandMapper = new(ViewHandler.ViewCommandMapper)
|
|
|
|
|
{
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public EntryHandler() : base(Mapper, CommandMapper)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public EntryHandler(IPropertyMapper? mapper, CommandMapper? commandMapper = null)
|
|
|
|
|
: base(mapper ?? Mapper, commandMapper ?? CommandMapper)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override SkiaEntry CreatePlatformView()
|
|
|
|
|
{
|
|
|
|
|
return new SkiaEntry();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void ConnectHandler(SkiaEntry platformView)
|
|
|
|
|
{
|
|
|
|
|
base.ConnectHandler(platformView);
|
|
|
|
|
platformView.TextChanged += OnTextChanged;
|
|
|
|
|
platformView.Completed += OnCompleted;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void DisconnectHandler(SkiaEntry platformView)
|
|
|
|
|
{
|
|
|
|
|
platformView.TextChanged -= OnTextChanged;
|
|
|
|
|
platformView.Completed -= OnCompleted;
|
|
|
|
|
base.DisconnectHandler(platformView);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnTextChanged(object? sender, Platform.TextChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (VirtualView is null || PlatformView is null) return;
|
|
|
|
|
|
|
|
|
|
if (VirtualView.Text != e.NewTextValue)
|
|
|
|
|
{
|
|
|
|
|
VirtualView.Text = e.NewTextValue ?? string.Empty;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnCompleted(object? sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
VirtualView?.Completed();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapText(EntryHandler handler, IEntry entry)
|
|
|
|
|
{
|
|
|
|
|
if (handler.PlatformView is null) return;
|
|
|
|
|
|
|
|
|
|
if (handler.PlatformView.Text != entry.Text)
|
2025-12-21 13:26:56 -05:00
|
|
|
{
|
2025-12-19 09:30:16 +00:00
|
|
|
handler.PlatformView.Text = entry.Text ?? string.Empty;
|
2025-12-21 13:26:56 -05:00
|
|
|
handler.PlatformView.Invalidate();
|
|
|
|
|
}
|
2025-12-19 09:30:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapTextColor(EntryHandler handler, IEntry entry)
|
|
|
|
|
{
|
|
|
|
|
if (handler.PlatformView is null) return;
|
|
|
|
|
|
|
|
|
|
if (entry.TextColor is not null)
|
2026-01-16 04:40:02 +00:00
|
|
|
handler.PlatformView.TextColor = entry.TextColor;
|
2025-12-19 09:30:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapFont(EntryHandler handler, IEntry entry)
|
|
|
|
|
{
|
|
|
|
|
if (handler.PlatformView is null) return;
|
|
|
|
|
|
|
|
|
|
var font = entry.Font;
|
|
|
|
|
if (font.Size > 0)
|
2026-01-16 04:40:02 +00:00
|
|
|
handler.PlatformView.FontSize = font.Size;
|
2025-12-19 09:30:16 +00:00
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(font.Family))
|
|
|
|
|
handler.PlatformView.FontFamily = font.Family;
|
|
|
|
|
|
2026-01-16 04:40:02 +00:00
|
|
|
// Convert Font weight/slant to FontAttributes
|
|
|
|
|
FontAttributes attrs = FontAttributes.None;
|
|
|
|
|
if (font.Weight >= FontWeight.Bold)
|
|
|
|
|
attrs |= FontAttributes.Bold;
|
|
|
|
|
if (font.Slant == FontSlant.Italic || font.Slant == FontSlant.Oblique)
|
|
|
|
|
attrs |= FontAttributes.Italic;
|
|
|
|
|
handler.PlatformView.FontAttributes = attrs;
|
2025-12-19 09:30:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapCharacterSpacing(EntryHandler handler, IEntry entry)
|
|
|
|
|
{
|
|
|
|
|
if (handler.PlatformView is null) return;
|
2026-01-16 04:40:02 +00:00
|
|
|
handler.PlatformView.CharacterSpacing = entry.CharacterSpacing;
|
2025-12-19 09:30:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapPlaceholder(EntryHandler handler, IEntry entry)
|
|
|
|
|
{
|
|
|
|
|
if (handler.PlatformView is null) return;
|
|
|
|
|
handler.PlatformView.Placeholder = entry.Placeholder ?? string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapPlaceholderColor(EntryHandler handler, IEntry entry)
|
|
|
|
|
{
|
|
|
|
|
if (handler.PlatformView is null) return;
|
|
|
|
|
|
|
|
|
|
if (entry.PlaceholderColor is not null)
|
2026-01-16 04:40:02 +00:00
|
|
|
handler.PlatformView.PlaceholderColor = entry.PlaceholderColor;
|
2025-12-19 09:30:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapIsReadOnly(EntryHandler handler, IEntry entry)
|
|
|
|
|
{
|
|
|
|
|
if (handler.PlatformView is null) return;
|
|
|
|
|
handler.PlatformView.IsReadOnly = entry.IsReadOnly;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapMaxLength(EntryHandler handler, IEntry entry)
|
|
|
|
|
{
|
|
|
|
|
if (handler.PlatformView is null) return;
|
|
|
|
|
handler.PlatformView.MaxLength = entry.MaxLength;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapCursorPosition(EntryHandler handler, IEntry entry)
|
|
|
|
|
{
|
|
|
|
|
if (handler.PlatformView is null) return;
|
|
|
|
|
handler.PlatformView.CursorPosition = entry.CursorPosition;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapSelectionLength(EntryHandler handler, IEntry entry)
|
|
|
|
|
{
|
|
|
|
|
if (handler.PlatformView is null) return;
|
|
|
|
|
handler.PlatformView.SelectionLength = entry.SelectionLength;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapIsPassword(EntryHandler handler, IEntry entry)
|
|
|
|
|
{
|
|
|
|
|
if (handler.PlatformView is null) return;
|
|
|
|
|
handler.PlatformView.IsPassword = entry.IsPassword;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapReturnType(EntryHandler handler, IEntry entry)
|
|
|
|
|
{
|
|
|
|
|
// ReturnType affects keyboard behavior - stored for virtual keyboard integration
|
|
|
|
|
if (handler.PlatformView is null) return;
|
|
|
|
|
// handler.PlatformView.ReturnType = entry.ReturnType; // Would need property on SkiaEntry
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapClearButtonVisibility(EntryHandler handler, IEntry entry)
|
|
|
|
|
{
|
|
|
|
|
if (handler.PlatformView is null) return;
|
|
|
|
|
handler.PlatformView.ShowClearButton = entry.ClearButtonVisibility == ClearButtonVisibility.WhileEditing;
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-16 04:40:02 +00:00
|
|
|
public static void MapIsTextPredictionEnabled(EntryHandler handler, IEntry entry)
|
|
|
|
|
{
|
|
|
|
|
if (handler.PlatformView is null) return;
|
|
|
|
|
handler.PlatformView.IsTextPredictionEnabled = entry.IsTextPredictionEnabled;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapIsSpellCheckEnabled(EntryHandler handler, IEntry entry)
|
|
|
|
|
{
|
|
|
|
|
if (handler.PlatformView is null) return;
|
|
|
|
|
handler.PlatformView.IsSpellCheckEnabled = entry.IsSpellCheckEnabled;
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-19 09:30:16 +00:00
|
|
|
public static void MapHorizontalTextAlignment(EntryHandler handler, IEntry entry)
|
|
|
|
|
{
|
|
|
|
|
if (handler.PlatformView is null) return;
|
|
|
|
|
|
|
|
|
|
handler.PlatformView.HorizontalTextAlignment = entry.HorizontalTextAlignment switch
|
|
|
|
|
{
|
2026-01-16 04:40:02 +00:00
|
|
|
Microsoft.Maui.TextAlignment.Start => TextAlignment.Start,
|
|
|
|
|
Microsoft.Maui.TextAlignment.Center => TextAlignment.Center,
|
|
|
|
|
Microsoft.Maui.TextAlignment.End => TextAlignment.End,
|
|
|
|
|
_ => TextAlignment.Start
|
2025-12-19 09:30:16 +00:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapVerticalTextAlignment(EntryHandler handler, IEntry entry)
|
|
|
|
|
{
|
|
|
|
|
if (handler.PlatformView is null) return;
|
|
|
|
|
|
|
|
|
|
handler.PlatformView.VerticalTextAlignment = entry.VerticalTextAlignment switch
|
|
|
|
|
{
|
2026-01-16 04:40:02 +00:00
|
|
|
Microsoft.Maui.TextAlignment.Start => TextAlignment.Start,
|
|
|
|
|
Microsoft.Maui.TextAlignment.Center => TextAlignment.Center,
|
|
|
|
|
Microsoft.Maui.TextAlignment.End => TextAlignment.End,
|
|
|
|
|
_ => TextAlignment.Center
|
2025-12-19 09:30:16 +00:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapBackground(EntryHandler handler, IEntry entry)
|
|
|
|
|
{
|
|
|
|
|
if (handler.PlatformView is null) return;
|
|
|
|
|
|
|
|
|
|
if (entry.Background is SolidPaint solidPaint && solidPaint.Color is not null)
|
|
|
|
|
{
|
|
|
|
|
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor();
|
|
|
|
|
}
|
|
|
|
|
}
|
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
|
|
|
|
|
|
|
|
public static void MapBackgroundColor(EntryHandler handler, IEntry entry)
|
|
|
|
|
{
|
|
|
|
|
if (handler.PlatformView is null) return;
|
|
|
|
|
|
|
|
|
|
if (entry is Entry ve && ve.BackgroundColor != null)
|
|
|
|
|
{
|
2026-01-16 04:40:02 +00:00
|
|
|
handler.PlatformView.EntryBackgroundColor = ve.BackgroundColor;
|
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
|
|
|
}
|
|
|
|
|
}
|
2025-12-19 09:30:16 +00:00
|
|
|
}
|