Files
maui-linux/Handlers/GtkWebViewManager.cs
Dave Friedel 1f096c38dc Update with recovered code from VM binaries (Jan 1)
Recovered from decompiled OpenMaui.Controls.Linux.dll:
- SkiaShell.cs: FlyoutHeader, FlyoutFooter, scroll support (918 -> 1325 lines)
- X11Window.cs: Cursor support (XCreateFontCursor, XDefineCursor)
- All handlers with dark mode support
- All services with latest implementations
- LinuxApplication with theme change handling
2026-01-01 06:22:48 -05:00

62 lines
1.5 KiB
C#

using System.Collections.Generic;
using Microsoft.Maui.Platform.Linux.Window;
namespace Microsoft.Maui.Platform.Linux.Handlers;
public sealed class GtkWebViewManager
{
private readonly GtkHostWindow _host;
private readonly Dictionary<object, GtkWebViewPlatformView> _webViews = new Dictionary<object, GtkWebViewPlatformView>();
public GtkWebViewManager(GtkHostWindow host)
{
_host = host;
}
public GtkWebViewPlatformView CreateWebView(object key, int x, int y, int width, int height)
{
GtkWebViewPlatformView gtkWebViewPlatformView = new GtkWebViewPlatformView();
_webViews[key] = gtkWebViewPlatformView;
_host.AddWebView(gtkWebViewPlatformView.Widget, x, y, width, height);
return gtkWebViewPlatformView;
}
public void UpdateLayout(object key, int x, int y, int width, int height)
{
if (_webViews.TryGetValue(key, out GtkWebViewPlatformView value))
{
_host.MoveResizeWebView(value.Widget, x, y, width, height);
}
}
public GtkWebViewPlatformView? GetWebView(object key)
{
if (!_webViews.TryGetValue(key, out GtkWebViewPlatformView value))
{
return null;
}
return value;
}
public void RemoveWebView(object key)
{
if (_webViews.TryGetValue(key, out GtkWebViewPlatformView value))
{
_host.RemoveWebView(value.Widget);
value.Dispose();
_webViews.Remove(key);
}
}
public void Clear()
{
foreach (KeyValuePair<object, GtkWebViewPlatformView> webView in _webViews)
{
_host.RemoveWebView(webView.Value.Widget);
webView.Value.Dispose();
}
_webViews.Clear();
}
}