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
This commit is contained in:
2026-01-01 06:22:48 -05:00
parent 1e84c6168a
commit 1f096c38dc
254 changed files with 49359 additions and 38457 deletions

View File

@@ -0,0 +1,22 @@
using System.Runtime.InteropServices;
namespace Microsoft.Maui.Platform.Linux.Interop;
[StructLayout(LayoutKind.Explicit)]
public struct ClientMessageData
{
[FieldOffset(0)]
public long L0;
[FieldOffset(8)]
public long L1;
[FieldOffset(16)]
public long L2;
[FieldOffset(24)]
public long L3;
[FieldOffset(32)]
public long L4;
}

View File

@@ -1,345 +1,260 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Runtime.InteropServices;
namespace Microsoft.Maui.Platform.Linux.Interop;
/// <summary>
/// P/Invoke bindings for WebKitGTK library.
/// WebKitGTK provides a full-featured web browser engine for Linux.
/// </summary>
public static class WebKitGtk
{
private const string WebKit2Lib = "libwebkit2gtk-4.1.so.0";
private const string GtkLib = "libgtk-3.so.0";
private const string GObjectLib = "libgobject-2.0.so.0";
private const string GLibLib = "libglib-2.0.so.0";
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void GCallback();
#region GTK Initialization
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void LoadChangedCallback(IntPtr webView, int loadEvent, IntPtr userData);
[DllImport(GtkLib, CallingConvention = CallingConvention.Cdecl)]
public static extern bool gtk_init_check(ref int argc, ref IntPtr argv);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate bool DecidePolicyCallback(IntPtr webView, IntPtr decision, int decisionType, IntPtr userData);
[DllImport(GtkLib, CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_main();
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void LoadFailedCallback(IntPtr webView, int loadEvent, IntPtr failingUri, IntPtr error, IntPtr userData);
[DllImport(GtkLib, CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_main_quit();
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void NotifyCallback(IntPtr webView, IntPtr paramSpec, IntPtr userData);
[DllImport(GtkLib, CallingConvention = CallingConvention.Cdecl)]
public static extern bool gtk_events_pending();
private const string WebKit2Lib = "libwebkit2gtk-4.1.so.0";
[DllImport(GtkLib, CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_main_iteration();
private const string GtkLib = "libgtk-3.so.0";
[DllImport(GtkLib, CallingConvention = CallingConvention.Cdecl)]
public static extern bool gtk_main_iteration_do(bool blocking);
private const string GObjectLib = "libgobject-2.0.so.0";
#endregion
private const string GLibLib = "libglib-2.0.so.0";
#region GTK Window
public const int WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS = 0;
[DllImport(GtkLib, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr gtk_window_new(int type);
public const int WEBKIT_COOKIE_POLICY_ACCEPT_NEVER = 1;
[DllImport(GtkLib, CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_window_set_default_size(IntPtr window, int width, int height);
public const int WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY = 2;
[DllImport(GtkLib, CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_window_set_decorated(IntPtr window, bool decorated);
public const int WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT = 0;
[DllImport(GtkLib, CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_window_move(IntPtr window, int x, int y);
public const int WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE = 1;
[DllImport(GtkLib, CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_window_resize(IntPtr window, int width, int height);
public const int WEBKIT_LOAD_STARTED = 0;
#endregion
public const int WEBKIT_LOAD_REDIRECTED = 1;
#region GTK Widget
public const int WEBKIT_LOAD_COMMITTED = 2;
[DllImport(GtkLib, CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_widget_show_all(IntPtr widget);
public const int WEBKIT_LOAD_FINISHED = 3;
[DllImport(GtkLib, CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_widget_show(IntPtr widget);
public const int WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION = 0;
[DllImport(GtkLib, CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_widget_hide(IntPtr widget);
public const int WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION = 1;
[DllImport(GtkLib, CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_widget_destroy(IntPtr widget);
public const int WEBKIT_POLICY_DECISION_TYPE_RESPONSE = 2;
[DllImport(GtkLib, CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_widget_set_size_request(IntPtr widget, int width, int height);
[DllImport("libgtk-3.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern bool gtk_init_check(ref int argc, ref IntPtr argv);
[DllImport(GtkLib, CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_widget_realize(IntPtr widget);
[DllImport("libgtk-3.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_main();
[DllImport(GtkLib, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr gtk_widget_get_window(IntPtr widget);
[DllImport("libgtk-3.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_main_quit();
[DllImport(GtkLib, CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_widget_set_can_focus(IntPtr widget, bool canFocus);
[DllImport("libgtk-3.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern bool gtk_events_pending();
#endregion
[DllImport("libgtk-3.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_main_iteration();
#region GTK Container
[DllImport("libgtk-3.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern bool gtk_main_iteration_do(bool blocking);
[DllImport(GtkLib, CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_container_add(IntPtr container, IntPtr widget);
[DllImport("libgtk-3.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr gtk_window_new(int type);
[DllImport(GtkLib, CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_container_remove(IntPtr container, IntPtr widget);
[DllImport("libgtk-3.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_window_set_default_size(IntPtr window, int width, int height);
#endregion
[DllImport("libgtk-3.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_window_set_decorated(IntPtr window, bool decorated);
#region GTK Plug (for embedding in X11 windows)
[DllImport("libgtk-3.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_window_move(IntPtr window, int x, int y);
[DllImport(GtkLib, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr gtk_plug_new(ulong socketId);
[DllImport("libgtk-3.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_window_resize(IntPtr window, int width, int height);
[DllImport(GtkLib, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong gtk_plug_get_id(IntPtr plug);
[DllImport("libgtk-3.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_widget_show_all(IntPtr widget);
#endregion
[DllImport("libgtk-3.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_widget_show(IntPtr widget);
#region WebKitWebView
[DllImport("libgtk-3.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_widget_hide(IntPtr widget);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr webkit_web_view_new();
[DllImport("libgtk-3.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_widget_destroy(IntPtr widget);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr webkit_web_view_new_with_context(IntPtr context);
[DllImport("libgtk-3.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_widget_set_size_request(IntPtr widget, int width, int height);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_web_view_load_uri(IntPtr webView, [MarshalAs(UnmanagedType.LPUTF8Str)] string uri);
[DllImport("libgtk-3.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_widget_realize(IntPtr widget);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_web_view_load_html(IntPtr webView,
[MarshalAs(UnmanagedType.LPUTF8Str)] string content,
[MarshalAs(UnmanagedType.LPUTF8Str)] string? baseUri);
[DllImport("libgtk-3.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr gtk_widget_get_window(IntPtr widget);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_web_view_reload(IntPtr webView);
[DllImport("libgtk-3.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_widget_set_can_focus(IntPtr widget, bool canFocus);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_web_view_stop_loading(IntPtr webView);
[DllImport("libgtk-3.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_container_add(IntPtr container, IntPtr widget);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_web_view_go_back(IntPtr webView);
[DllImport("libgtk-3.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void gtk_container_remove(IntPtr container, IntPtr widget);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_web_view_go_forward(IntPtr webView);
[DllImport("libgtk-3.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr gtk_plug_new(ulong socketId);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern bool webkit_web_view_can_go_back(IntPtr webView);
[DllImport("libgtk-3.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern ulong gtk_plug_get_id(IntPtr plug);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern bool webkit_web_view_can_go_forward(IntPtr webView);
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr webkit_web_view_new();
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr webkit_web_view_get_uri(IntPtr webView);
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr webkit_web_view_new_with_context(IntPtr context);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr webkit_web_view_get_title(IntPtr webView);
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_web_view_load_uri(IntPtr webView, [MarshalAs(UnmanagedType.LPUTF8Str)] string uri);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern double webkit_web_view_get_estimated_load_progress(IntPtr webView);
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_web_view_load_html(IntPtr webView, [MarshalAs(UnmanagedType.LPUTF8Str)] string content, [MarshalAs(UnmanagedType.LPUTF8Str)] string? baseUri);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern bool webkit_web_view_is_loading(IntPtr webView);
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_web_view_reload(IntPtr webView);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_web_view_run_javascript(IntPtr webView,
[MarshalAs(UnmanagedType.LPUTF8Str)] string script,
IntPtr cancellable,
IntPtr callback,
IntPtr userData);
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_web_view_stop_loading(IntPtr webView);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr webkit_web_view_run_javascript_finish(IntPtr webView,
IntPtr result,
out IntPtr error);
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_web_view_go_back(IntPtr webView);
#endregion
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_web_view_go_forward(IntPtr webView);
#region WebKitSettings
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern bool webkit_web_view_can_go_back(IntPtr webView);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr webkit_web_view_get_settings(IntPtr webView);
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern bool webkit_web_view_can_go_forward(IntPtr webView);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_settings_set_enable_javascript(IntPtr settings, bool enabled);
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr webkit_web_view_get_uri(IntPtr webView);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_settings_set_user_agent(IntPtr settings,
[MarshalAs(UnmanagedType.LPUTF8Str)] string userAgent);
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr webkit_web_view_get_title(IntPtr webView);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr webkit_settings_get_user_agent(IntPtr settings);
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern double webkit_web_view_get_estimated_load_progress(IntPtr webView);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_settings_set_enable_developer_extras(IntPtr settings, bool enabled);
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern bool webkit_web_view_is_loading(IntPtr webView);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_settings_set_javascript_can_access_clipboard(IntPtr settings, bool enabled);
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_web_view_run_javascript(IntPtr webView, [MarshalAs(UnmanagedType.LPUTF8Str)] string script, IntPtr cancellable, IntPtr callback, IntPtr userData);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_settings_set_enable_webgl(IntPtr settings, bool enabled);
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr webkit_web_view_run_javascript_finish(IntPtr webView, IntPtr result, out IntPtr error);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_settings_set_allow_file_access_from_file_urls(IntPtr settings, bool enabled);
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr webkit_web_view_get_settings(IntPtr webView);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_settings_set_allow_universal_access_from_file_urls(IntPtr settings, bool enabled);
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_settings_set_enable_javascript(IntPtr settings, bool enabled);
#endregion
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_settings_set_user_agent(IntPtr settings, [MarshalAs(UnmanagedType.LPUTF8Str)] string userAgent);
#region WebKitWebContext
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr webkit_settings_get_user_agent(IntPtr settings);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr webkit_web_context_get_default();
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_settings_set_enable_developer_extras(IntPtr settings, bool enabled);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr webkit_web_context_new();
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_settings_set_javascript_can_access_clipboard(IntPtr settings, bool enabled);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr webkit_web_context_get_cookie_manager(IntPtr context);
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_settings_set_enable_webgl(IntPtr settings, bool enabled);
#endregion
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_settings_set_allow_file_access_from_file_urls(IntPtr settings, bool enabled);
#region WebKitCookieManager
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_settings_set_allow_universal_access_from_file_urls(IntPtr settings, bool enabled);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_cookie_manager_set_accept_policy(IntPtr cookieManager, int policy);
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr webkit_web_context_get_default();
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_cookie_manager_set_persistent_storage(IntPtr cookieManager,
[MarshalAs(UnmanagedType.LPUTF8Str)] string filename,
int storage);
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr webkit_web_context_new();
// Cookie accept policies
public const int WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS = 0;
public const int WEBKIT_COOKIE_POLICY_ACCEPT_NEVER = 1;
public const int WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY = 2;
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr webkit_web_context_get_cookie_manager(IntPtr context);
// Cookie persistent storage types
public const int WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT = 0;
public const int WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE = 1;
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_cookie_manager_set_accept_policy(IntPtr cookieManager, int policy);
#endregion
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_cookie_manager_set_persistent_storage(IntPtr cookieManager, [MarshalAs(UnmanagedType.LPUTF8Str)] string filename, int storage);
#region WebKitNavigationAction
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr webkit_navigation_action_get_request(IntPtr action);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr webkit_navigation_action_get_request(IntPtr action);
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern int webkit_navigation_action_get_navigation_type(IntPtr action);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern int webkit_navigation_action_get_navigation_type(IntPtr action);
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr webkit_uri_request_get_uri(IntPtr request);
#endregion
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_policy_decision_use(IntPtr decision);
#region WebKitURIRequest
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_policy_decision_ignore(IntPtr decision);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr webkit_uri_request_get_uri(IntPtr request);
[DllImport("libwebkit2gtk-4.1.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_policy_decision_download(IntPtr decision);
#endregion
[DllImport("libgobject-2.0.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern ulong g_signal_connect_data(IntPtr instance, [MarshalAs(UnmanagedType.LPUTF8Str)] string detailedSignal, Delegate handler, IntPtr data, IntPtr destroyData, int connectFlags);
#region WebKitPolicyDecision
[DllImport("libgobject-2.0.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void g_signal_handler_disconnect(IntPtr instance, ulong handlerId);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_policy_decision_use(IntPtr decision);
[DllImport("libgobject-2.0.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void g_object_unref(IntPtr obj);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_policy_decision_ignore(IntPtr decision);
[DllImport("libglib-2.0.so.0", CallingConvention = CallingConvention.Cdecl)]
public static extern void g_free(IntPtr mem);
[DllImport(WebKit2Lib, CallingConvention = CallingConvention.Cdecl)]
public static extern void webkit_policy_decision_download(IntPtr decision);
public static string? PtrToStringUtf8(IntPtr ptr)
{
if (ptr == IntPtr.Zero)
{
return null;
}
return Marshal.PtrToStringUTF8(ptr);
}
#endregion
#region GObject Signal Connection
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void GCallback();
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void LoadChangedCallback(IntPtr webView, int loadEvent, IntPtr userData);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate bool DecidePolicyCallback(IntPtr webView, IntPtr decision, int decisionType, IntPtr userData);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void LoadFailedCallback(IntPtr webView, int loadEvent, IntPtr failingUri, IntPtr error, IntPtr userData);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void NotifyCallback(IntPtr webView, IntPtr paramSpec, IntPtr userData);
[DllImport(GObjectLib, CallingConvention = CallingConvention.Cdecl)]
public static extern ulong g_signal_connect_data(IntPtr instance,
[MarshalAs(UnmanagedType.LPUTF8Str)] string detailedSignal,
Delegate handler,
IntPtr data,
IntPtr destroyData,
int connectFlags);
[DllImport(GObjectLib, CallingConvention = CallingConvention.Cdecl)]
public static extern void g_signal_handler_disconnect(IntPtr instance, ulong handlerId);
[DllImport(GObjectLib, CallingConvention = CallingConvention.Cdecl)]
public static extern void g_object_unref(IntPtr obj);
#endregion
#region GLib Memory
[DllImport(GLibLib, CallingConvention = CallingConvention.Cdecl)]
public static extern void g_free(IntPtr mem);
#endregion
#region WebKit Load Events
public const int WEBKIT_LOAD_STARTED = 0;
public const int WEBKIT_LOAD_REDIRECTED = 1;
public const int WEBKIT_LOAD_COMMITTED = 2;
public const int WEBKIT_LOAD_FINISHED = 3;
#endregion
#region WebKit Policy Decision Types
public const int WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION = 0;
public const int WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION = 1;
public const int WEBKIT_POLICY_DECISION_TYPE_RESPONSE = 2;
#endregion
#region Helper Methods
/// <summary>
/// Converts a native UTF-8 string pointer to a managed string.
/// </summary>
public static string? PtrToStringUtf8(IntPtr ptr)
{
if (ptr == IntPtr.Zero)
return null;
return Marshal.PtrToStringUTF8(ptr);
}
/// <summary>
/// Processes pending GTK events without blocking.
/// </summary>
public static void ProcessGtkEvents()
{
while (gtk_events_pending())
{
gtk_main_iteration_do(false);
}
}
#endregion
public static void ProcessGtkEvents()
{
while (gtk_events_pending())
{
gtk_main_iteration_do(blocking: false);
}
}
}

442
Interop/X11.cs Normal file
View File

@@ -0,0 +1,442 @@
using System;
using System.CodeDom.Compiler;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.Marshalling;
namespace Microsoft.Maui.Platform.Linux.Interop;
internal static class X11
{
private const string LibX11 = "libX11.so.6";
private const string LibXext = "libXext.so.6";
public const int ZPixmap = 2;
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern IntPtr XOpenDisplay(IntPtr displayName);
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern int XCloseDisplay(IntPtr display);
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern int XDefaultScreen(IntPtr display);
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern IntPtr XRootWindow(IntPtr display, int screenNumber);
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern int XDisplayWidth(IntPtr display, int screenNumber);
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern int XDisplayHeight(IntPtr display, int screenNumber);
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern int XDefaultDepth(IntPtr display, int screenNumber);
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern IntPtr XDefaultVisual(IntPtr display, int screenNumber);
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern IntPtr XDefaultColormap(IntPtr display, int screenNumber);
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern int XFlush(IntPtr display);
[LibraryImport("libX11.so.6")]
[GeneratedCode("Microsoft.Interop.LibraryImportGenerator", "9.0.11.2809")]
[SkipLocalsInit]
public static int XSync(IntPtr display, [MarshalAs(UnmanagedType.Bool)] bool discard)
{
int _discard_native = (discard ? 1 : 0);
return __PInvoke(display, _discard_native);
[DllImport("libX11.so.6", EntryPoint = "XSync", ExactSpelling = true)]
static extern int __PInvoke(IntPtr __display_native, int __discard_native);
}
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern IntPtr XCreateSimpleWindow(IntPtr display, IntPtr parent, int x, int y, uint width, uint height, uint borderWidth, ulong border, ulong background);
[LibraryImport("libX11.so.6")]
[GeneratedCode("Microsoft.Interop.LibraryImportGenerator", "9.0.11.2809")]
[SkipLocalsInit]
public unsafe static IntPtr XCreateWindow(IntPtr display, IntPtr parent, int x, int y, uint width, uint height, uint borderWidth, int depth, uint windowClass, IntPtr visual, ulong valueMask, ref XSetWindowAttributes attributes)
{
IntPtr result;
fixed (XSetWindowAttributes* _attributes_native = &attributes)
{
result = __PInvoke(display, parent, x, y, width, height, borderWidth, depth, windowClass, visual, valueMask, _attributes_native);
}
return result;
[DllImport("libX11.so.6", EntryPoint = "XCreateWindow", ExactSpelling = true)]
static extern unsafe IntPtr __PInvoke(IntPtr __display_native, IntPtr __parent_native, int __x_native, int __y_native, uint __width_native, uint __height_native, uint __borderWidth_native, int __depth_native, uint __windowClass_native, IntPtr __visual_native, ulong __valueMask_native, XSetWindowAttributes* __attributes_native);
}
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern int XDestroyWindow(IntPtr display, IntPtr window);
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern int XMapWindow(IntPtr display, IntPtr window);
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern int XUnmapWindow(IntPtr display, IntPtr window);
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern int XMoveWindow(IntPtr display, IntPtr window, int x, int y);
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern int XResizeWindow(IntPtr display, IntPtr window, uint width, uint height);
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern int XMoveResizeWindow(IntPtr display, IntPtr window, int x, int y, uint width, uint height);
[LibraryImport("libX11.so.6", StringMarshalling = StringMarshalling.Utf8)]
[GeneratedCode("Microsoft.Interop.LibraryImportGenerator", "9.0.11.2809")]
[SkipLocalsInit]
public unsafe static int XStoreName(IntPtr display, IntPtr window, string windowName)
{
byte* ptr = default(byte*);
int num = 0;
Utf8StringMarshaller.ManagedToUnmanagedIn managedToUnmanagedIn = default(Utf8StringMarshaller.ManagedToUnmanagedIn);
try
{
Span<byte> buffer = stackalloc byte[Utf8StringMarshaller.ManagedToUnmanagedIn.BufferSize];
managedToUnmanagedIn.FromManaged(windowName, buffer);
ptr = managedToUnmanagedIn.ToUnmanaged();
return __PInvoke(display, window, ptr);
}
finally
{
managedToUnmanagedIn.Free();
}
[DllImport("libX11.so.6", EntryPoint = "XStoreName", ExactSpelling = true)]
static extern unsafe int __PInvoke(IntPtr __display_native, IntPtr __window_native, byte* __windowName_native);
}
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern int XRaiseWindow(IntPtr display, IntPtr window);
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern int XLowerWindow(IntPtr display, IntPtr window);
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern int XSelectInput(IntPtr display, IntPtr window, long eventMask);
[LibraryImport("libX11.so.6")]
[GeneratedCode("Microsoft.Interop.LibraryImportGenerator", "9.0.11.2809")]
[SkipLocalsInit]
public unsafe static int XNextEvent(IntPtr display, out XEvent eventReturn)
{
eventReturn = default(XEvent);
int result;
fixed (XEvent* _eventReturn_native = &eventReturn)
{
result = __PInvoke(display, _eventReturn_native);
}
return result;
[DllImport("libX11.so.6", EntryPoint = "XNextEvent", ExactSpelling = true)]
static extern unsafe int __PInvoke(IntPtr __display_native, XEvent* __eventReturn_native);
}
[LibraryImport("libX11.so.6")]
[GeneratedCode("Microsoft.Interop.LibraryImportGenerator", "9.0.11.2809")]
[SkipLocalsInit]
public unsafe static int XPeekEvent(IntPtr display, out XEvent eventReturn)
{
eventReturn = default(XEvent);
int result;
fixed (XEvent* _eventReturn_native = &eventReturn)
{
result = __PInvoke(display, _eventReturn_native);
}
return result;
[DllImport("libX11.so.6", EntryPoint = "XPeekEvent", ExactSpelling = true)]
static extern unsafe int __PInvoke(IntPtr __display_native, XEvent* __eventReturn_native);
}
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern int XPending(IntPtr display);
[LibraryImport("libX11.so.6")]
[GeneratedCode("Microsoft.Interop.LibraryImportGenerator", "9.0.11.2809")]
[SkipLocalsInit]
[return: MarshalAs(UnmanagedType.Bool)]
public unsafe static bool XCheckTypedWindowEvent(IntPtr display, IntPtr window, int eventType, out XEvent eventReturn)
{
eventReturn = default(XEvent);
int num;
fixed (XEvent* _eventReturn_native = &eventReturn)
{
num = __PInvoke(display, window, eventType, _eventReturn_native);
}
return num != 0;
[DllImport("libX11.so.6", EntryPoint = "XCheckTypedWindowEvent", ExactSpelling = true)]
static extern unsafe int __PInvoke(IntPtr __display_native, IntPtr __window_native, int __eventType_native, XEvent* __eventReturn_native);
}
[LibraryImport("libX11.so.6")]
[GeneratedCode("Microsoft.Interop.LibraryImportGenerator", "9.0.11.2809")]
[SkipLocalsInit]
public unsafe static int XSendEvent(IntPtr display, IntPtr window, [MarshalAs(UnmanagedType.Bool)] bool propagate, long eventMask, ref XEvent eventSend)
{
int _propagate_native = (propagate ? 1 : 0);
int result;
fixed (XEvent* _eventSend_native = &eventSend)
{
result = __PInvoke(display, window, _propagate_native, eventMask, _eventSend_native);
}
return result;
[DllImport("libX11.so.6", EntryPoint = "XSendEvent", ExactSpelling = true)]
static extern unsafe int __PInvoke(IntPtr __display_native, IntPtr __window_native, int __propagate_native, long __eventMask_native, XEvent* __eventSend_native);
}
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern ulong XKeycodeToKeysym(IntPtr display, int keycode, int index);
[LibraryImport("libX11.so.6")]
[GeneratedCode("Microsoft.Interop.LibraryImportGenerator", "9.0.11.2809")]
[SkipLocalsInit]
public unsafe static int XLookupString(ref XKeyEvent keyEvent, IntPtr bufferReturn, int bytesBuffer, out ulong keysymReturn, IntPtr statusInOut)
{
keysymReturn = 0uL;
int result;
fixed (ulong* _keysymReturn_native = &keysymReturn)
{
fixed (XKeyEvent* _keyEvent_native = &keyEvent)
{
result = __PInvoke(_keyEvent_native, bufferReturn, bytesBuffer, _keysymReturn_native, statusInOut);
}
}
return result;
[DllImport("libX11.so.6", EntryPoint = "XLookupString", ExactSpelling = true)]
static extern unsafe int __PInvoke(XKeyEvent* __keyEvent_native, IntPtr __bufferReturn_native, int __bytesBuffer_native, ulong* __keysymReturn_native, IntPtr __statusInOut_native);
}
[LibraryImport("libX11.so.6")]
[GeneratedCode("Microsoft.Interop.LibraryImportGenerator", "9.0.11.2809")]
[SkipLocalsInit]
public static int XGrabKeyboard(IntPtr display, IntPtr grabWindow, [MarshalAs(UnmanagedType.Bool)] bool ownerEvents, int pointerMode, int keyboardMode, ulong time)
{
int _ownerEvents_native = (ownerEvents ? 1 : 0);
return __PInvoke(display, grabWindow, _ownerEvents_native, pointerMode, keyboardMode, time);
[DllImport("libX11.so.6", EntryPoint = "XGrabKeyboard", ExactSpelling = true)]
static extern int __PInvoke(IntPtr __display_native, IntPtr __grabWindow_native, int __ownerEvents_native, int __pointerMode_native, int __keyboardMode_native, ulong __time_native);
}
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern int XUngrabKeyboard(IntPtr display, ulong time);
[LibraryImport("libX11.so.6")]
[GeneratedCode("Microsoft.Interop.LibraryImportGenerator", "9.0.11.2809")]
[SkipLocalsInit]
public static int XGrabPointer(IntPtr display, IntPtr grabWindow, [MarshalAs(UnmanagedType.Bool)] bool ownerEvents, uint eventMask, int pointerMode, int keyboardMode, IntPtr confineTo, IntPtr cursor, ulong time)
{
int _ownerEvents_native = (ownerEvents ? 1 : 0);
return __PInvoke(display, grabWindow, _ownerEvents_native, eventMask, pointerMode, keyboardMode, confineTo, cursor, time);
[DllImport("libX11.so.6", EntryPoint = "XGrabPointer", ExactSpelling = true)]
static extern int __PInvoke(IntPtr __display_native, IntPtr __grabWindow_native, int __ownerEvents_native, uint __eventMask_native, int __pointerMode_native, int __keyboardMode_native, IntPtr __confineTo_native, IntPtr __cursor_native, ulong __time_native);
}
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern int XUngrabPointer(IntPtr display, ulong time);
[LibraryImport("libX11.so.6")]
[GeneratedCode("Microsoft.Interop.LibraryImportGenerator", "9.0.11.2809")]
[SkipLocalsInit]
[return: MarshalAs(UnmanagedType.Bool)]
public unsafe static bool XQueryPointer(IntPtr display, IntPtr window, out IntPtr rootReturn, out IntPtr childReturn, out int rootX, out int rootY, out int winX, out int winY, out uint maskReturn)
{
rootReturn = (IntPtr)0;
childReturn = (IntPtr)0;
rootX = 0;
rootY = 0;
winX = 0;
winY = 0;
maskReturn = 0u;
int num;
fixed (uint* _maskReturn_native = &maskReturn)
{
fixed (int* _winY_native = &winY)
{
fixed (int* _winX_native = &winX)
{
fixed (int* _rootY_native = &rootY)
{
fixed (int* _rootX_native = &rootX)
{
fixed (IntPtr* _childReturn_native = &childReturn)
{
fixed (IntPtr* _rootReturn_native = &rootReturn)
{
num = __PInvoke(display, window, _rootReturn_native, _childReturn_native, _rootX_native, _rootY_native, _winX_native, _winY_native, _maskReturn_native);
}
}
}
}
}
}
}
return num != 0;
[DllImport("libX11.so.6", EntryPoint = "XQueryPointer", ExactSpelling = true)]
static extern unsafe int __PInvoke(IntPtr __display_native, IntPtr __window_native, IntPtr* __rootReturn_native, IntPtr* __childReturn_native, int* __rootX_native, int* __rootY_native, int* __winX_native, int* __winY_native, uint* __maskReturn_native);
}
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern int XWarpPointer(IntPtr display, IntPtr srcWindow, IntPtr destWindow, int srcX, int srcY, uint srcWidth, uint srcHeight, int destX, int destY);
[LibraryImport("libX11.so.6", StringMarshalling = StringMarshalling.Utf8)]
[GeneratedCode("Microsoft.Interop.LibraryImportGenerator", "9.0.11.2809")]
[SkipLocalsInit]
public unsafe static IntPtr XInternAtom(IntPtr display, string atomName, [MarshalAs(UnmanagedType.Bool)] bool onlyIfExists)
{
byte* ptr = default(byte*);
int num = 0;
nint num2 = 0;
Utf8StringMarshaller.ManagedToUnmanagedIn managedToUnmanagedIn = default(Utf8StringMarshaller.ManagedToUnmanagedIn);
try
{
num = (onlyIfExists ? 1 : 0);
Span<byte> buffer = stackalloc byte[Utf8StringMarshaller.ManagedToUnmanagedIn.BufferSize];
managedToUnmanagedIn.FromManaged(atomName, buffer);
ptr = managedToUnmanagedIn.ToUnmanaged();
return __PInvoke(display, ptr, num);
}
finally
{
managedToUnmanagedIn.Free();
}
[DllImport("libX11.so.6", EntryPoint = "XInternAtom", ExactSpelling = true)]
static extern unsafe IntPtr __PInvoke(IntPtr __display_native, byte* __atomName_native, int __onlyIfExists_native);
}
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern int XChangeProperty(IntPtr display, IntPtr window, IntPtr property, IntPtr type, int format, int mode, IntPtr data, int nelements);
[LibraryImport("libX11.so.6")]
[GeneratedCode("Microsoft.Interop.LibraryImportGenerator", "9.0.11.2809")]
[SkipLocalsInit]
public unsafe static int XGetWindowProperty(IntPtr display, IntPtr window, IntPtr property, long longOffset, long longLength, [MarshalAs(UnmanagedType.Bool)] bool delete, IntPtr reqType, out IntPtr actualTypeReturn, out int actualFormatReturn, out IntPtr nitemsReturn, out IntPtr bytesAfterReturn, out IntPtr propReturn)
{
actualTypeReturn = (IntPtr)0;
actualFormatReturn = 0;
nitemsReturn = (IntPtr)0;
bytesAfterReturn = (IntPtr)0;
propReturn = (IntPtr)0;
int _delete_native = (delete ? 1 : 0);
int result;
fixed (IntPtr* _propReturn_native = &propReturn)
{
fixed (IntPtr* _bytesAfterReturn_native = &bytesAfterReturn)
{
fixed (IntPtr* _nitemsReturn_native = &nitemsReturn)
{
fixed (int* _actualFormatReturn_native = &actualFormatReturn)
{
fixed (IntPtr* _actualTypeReturn_native = &actualTypeReturn)
{
result = __PInvoke(display, window, property, longOffset, longLength, _delete_native, reqType, _actualTypeReturn_native, _actualFormatReturn_native, _nitemsReturn_native, _bytesAfterReturn_native, _propReturn_native);
}
}
}
}
}
return result;
[DllImport("libX11.so.6", EntryPoint = "XGetWindowProperty", ExactSpelling = true)]
static extern unsafe int __PInvoke(IntPtr __display_native, IntPtr __window_native, IntPtr __property_native, long __longOffset_native, long __longLength_native, int __delete_native, IntPtr __reqType_native, IntPtr* __actualTypeReturn_native, int* __actualFormatReturn_native, IntPtr* __nitemsReturn_native, IntPtr* __bytesAfterReturn_native, IntPtr* __propReturn_native);
}
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern int XDeleteProperty(IntPtr display, IntPtr window, IntPtr property);
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern int XSetSelectionOwner(IntPtr display, IntPtr selection, IntPtr owner, ulong time);
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern IntPtr XGetSelectionOwner(IntPtr display, IntPtr selection);
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern int XConvertSelection(IntPtr display, IntPtr selection, IntPtr target, IntPtr property, IntPtr requestor, ulong time);
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern int XFree(IntPtr data);
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern IntPtr XCreateGC(IntPtr display, IntPtr drawable, ulong valueMask, IntPtr values);
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern int XFreeGC(IntPtr display, IntPtr gc);
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern int XCopyArea(IntPtr display, IntPtr src, IntPtr dest, IntPtr gc, int srcX, int srcY, uint width, uint height, int destX, int destY);
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern IntPtr XCreateFontCursor(IntPtr display, uint shape);
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern int XFreeCursor(IntPtr display, IntPtr cursor);
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern int XDefineCursor(IntPtr display, IntPtr window, IntPtr cursor);
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern int XUndefineCursor(IntPtr display, IntPtr window);
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern int XConnectionNumber(IntPtr display);
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern IntPtr XCreateImage(IntPtr display, IntPtr visual, uint depth, int format, int offset, IntPtr data, uint width, uint height, int bitmapPad, int bytesPerLine);
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern int XPutImage(IntPtr display, IntPtr drawable, IntPtr gc, IntPtr image, int srcX, int srcY, int destX, int destY, uint width, uint height);
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern int XDestroyImage(IntPtr image);
[DllImport("libX11.so.6", ExactSpelling = true)]
[LibraryImport("libX11.so.6")]
public static extern IntPtr XDefaultGC(IntPtr display, int screen);
}

36
Interop/XButtonEvent.cs Normal file
View File

@@ -0,0 +1,36 @@
using System;
namespace Microsoft.Maui.Platform.Linux.Interop;
public struct XButtonEvent
{
public int Type;
public ulong Serial;
public int SendEvent;
public IntPtr Display;
public IntPtr Window;
public IntPtr Root;
public IntPtr Subwindow;
public ulong Time;
public int X;
public int Y;
public int XRoot;
public int YRoot;
public uint State;
public uint Button;
public int SameScreen;
}

View File

@@ -0,0 +1,22 @@
using System;
namespace Microsoft.Maui.Platform.Linux.Interop;
public struct XClientMessageEvent
{
public int Type;
public ulong Serial;
public int SendEvent;
public IntPtr Display;
public IntPtr Window;
public IntPtr MessageType;
public int Format;
public ClientMessageData Data;
}

View File

@@ -0,0 +1,32 @@
using System;
namespace Microsoft.Maui.Platform.Linux.Interop;
public struct XConfigureEvent
{
public int Type;
public ulong Serial;
public int SendEvent;
public IntPtr Display;
public IntPtr Event;
public IntPtr Window;
public int X;
public int Y;
public int Width;
public int Height;
public int BorderWidth;
public IntPtr Above;
public int OverrideRedirect;
}

40
Interop/XCrossingEvent.cs Normal file
View File

@@ -0,0 +1,40 @@
using System;
namespace Microsoft.Maui.Platform.Linux.Interop;
public struct XCrossingEvent
{
public int Type;
public ulong Serial;
public int SendEvent;
public IntPtr Display;
public IntPtr Window;
public IntPtr Root;
public IntPtr Subwindow;
public ulong Time;
public int X;
public int Y;
public int XRoot;
public int YRoot;
public int Mode;
public int Detail;
public int SameScreen;
public int Focus;
public uint State;
}

14
Interop/XCursorShape.cs Normal file
View File

@@ -0,0 +1,14 @@
namespace Microsoft.Maui.Platform.Linux.Interop;
public static class XCursorShape
{
public const uint XC_left_ptr = 68u;
public const uint XC_hand2 = 60u;
public const uint XC_xterm = 152u;
public const uint XC_watch = 150u;
public const uint XC_crosshair = 34u;
}

34
Interop/XEvent.cs Normal file
View File

@@ -0,0 +1,34 @@
using System.Runtime.InteropServices;
namespace Microsoft.Maui.Platform.Linux.Interop;
[StructLayout(LayoutKind.Explicit, Size = 192)]
public struct XEvent
{
[FieldOffset(0)]
public int Type;
[FieldOffset(0)]
public XKeyEvent KeyEvent;
[FieldOffset(0)]
public XButtonEvent ButtonEvent;
[FieldOffset(0)]
public XMotionEvent MotionEvent;
[FieldOffset(0)]
public XConfigureEvent ConfigureEvent;
[FieldOffset(0)]
public XExposeEvent ExposeEvent;
[FieldOffset(0)]
public XClientMessageEvent ClientMessageEvent;
[FieldOffset(0)]
public XCrossingEvent CrossingEvent;
[FieldOffset(0)]
public XFocusChangeEvent FocusChangeEvent;
}

24
Interop/XEventMask.cs Normal file
View File

@@ -0,0 +1,24 @@
namespace Microsoft.Maui.Platform.Linux.Interop;
public static class XEventMask
{
public const long KeyPressMask = 1L;
public const long KeyReleaseMask = 2L;
public const long ButtonPressMask = 4L;
public const long ButtonReleaseMask = 8L;
public const long EnterWindowMask = 16L;
public const long LeaveWindowMask = 32L;
public const long PointerMotionMask = 64L;
public const long ExposureMask = 32768L;
public const long StructureNotifyMask = 131072L;
public const long FocusChangeMask = 2097152L;
}

28
Interop/XEventType.cs Normal file
View File

@@ -0,0 +1,28 @@
namespace Microsoft.Maui.Platform.Linux.Interop;
public static class XEventType
{
public const int KeyPress = 2;
public const int KeyRelease = 3;
public const int ButtonPress = 4;
public const int ButtonRelease = 5;
public const int MotionNotify = 6;
public const int EnterNotify = 7;
public const int LeaveNotify = 8;
public const int FocusIn = 9;
public const int FocusOut = 10;
public const int Expose = 12;
public const int ConfigureNotify = 22;
public const int ClientMessage = 33;
}

26
Interop/XExposeEvent.cs Normal file
View File

@@ -0,0 +1,26 @@
using System;
namespace Microsoft.Maui.Platform.Linux.Interop;
public struct XExposeEvent
{
public int Type;
public ulong Serial;
public int SendEvent;
public IntPtr Display;
public IntPtr Window;
public int X;
public int Y;
public int Width;
public int Height;
public int Count;
}

View File

@@ -0,0 +1,20 @@
using System;
namespace Microsoft.Maui.Platform.Linux.Interop;
public struct XFocusChangeEvent
{
public int Type;
public ulong Serial;
public int SendEvent;
public IntPtr Display;
public IntPtr Window;
public int Mode;
public int Detail;
}

36
Interop/XKeyEvent.cs Normal file
View File

@@ -0,0 +1,36 @@
using System;
namespace Microsoft.Maui.Platform.Linux.Interop;
public struct XKeyEvent
{
public int Type;
public ulong Serial;
public int SendEvent;
public IntPtr Display;
public IntPtr Window;
public IntPtr Root;
public IntPtr Subwindow;
public ulong Time;
public int X;
public int Y;
public int XRoot;
public int YRoot;
public uint State;
public uint Keycode;
public int SameScreen;
}

36
Interop/XMotionEvent.cs Normal file
View File

@@ -0,0 +1,36 @@
using System;
namespace Microsoft.Maui.Platform.Linux.Interop;
public struct XMotionEvent
{
public int Type;
public ulong Serial;
public int SendEvent;
public IntPtr Display;
public IntPtr Window;
public IntPtr Root;
public IntPtr Subwindow;
public ulong Time;
public int X;
public int Y;
public int XRoot;
public int YRoot;
public uint State;
public byte IsHint;
public int SameScreen;
}

View File

@@ -0,0 +1,36 @@
using System;
namespace Microsoft.Maui.Platform.Linux.Interop;
public struct XSetWindowAttributes
{
public IntPtr BackgroundPixmap;
public ulong BackgroundPixel;
public IntPtr BorderPixmap;
public ulong BorderPixel;
public int BitGravity;
public int WinGravity;
public int BackingStore;
public ulong BackingPlanes;
public ulong BackingPixel;
public int SaveUnder;
public long EventMask;
public long DoNotPropagateMask;
public int OverrideRedirect;
public IntPtr Colormap;
public IntPtr Cursor;
}

8
Interop/XWindowClass.cs Normal file
View File

@@ -0,0 +1,8 @@
namespace Microsoft.Maui.Platform.Linux.Interop;
public static class XWindowClass
{
public const uint InputOutput = 1u;
public const uint InputOnly = 2u;
}