From 33c859ecad0903672d319e6707e0e122d6f1ae63 Mon Sep 17 00:00:00 2001 From: Miepee Date: Wed, 5 Apr 2023 15:14:15 +0200 Subject: [PATCH 1/2] initial webkit fix --- src/Eto.Gtk/NativeMethods.cs | 77 +++++++++++++++++++++++++++++++++++- src/Eto.Gtk/NativeMethods.tt | 25 ++++++++++++ 2 files changed, 101 insertions(+), 1 deletion(-) mode change 100755 => 100644 src/Eto.Gtk/NativeMethods.cs diff --git a/src/Eto.Gtk/NativeMethods.cs b/src/Eto.Gtk/NativeMethods.cs old mode 100755 new mode 100644 index 49cd61c0ff..2c31b71771 --- a/src/Eto.Gtk/NativeMethods.cs +++ b/src/Eto.Gtk/NativeMethods.cs @@ -1,4 +1,4 @@ - + using System; using System.Runtime.InteropServices; using System.Text; @@ -32,6 +32,31 @@ public struct FcFontSet static class NMWindows { + +#if NETCOREAPP + + static NMWindows() + { + NativeLibrary.SetDllImportResolver(typeof(NMWindows).Assembly, (name, assembly, path) => + { + // Use custom import resolver for libwebkit2gtk + // Try loading 4.1 first, if that fails, return to default handling + if (name == libwebkit) + { + IntPtr result = IntPtr.Zero; + if (!NativeLibrary.TryLoad("libwebkit2gtk-4.1.so.0", assembly, path, out result)) + { + return IntPtr.Zero; + } + + return result; + } + + return IntPtr.Zero; + }); + } +#endif + #if GTK2 const string plat = "win32-"; #elif GTK3 @@ -226,6 +251,31 @@ static class NMWindows static class NMLinux { + +#if NETCOREAPP + + static NMLinux() + { + NativeLibrary.SetDllImportResolver(typeof(NMLinux).Assembly, (name, assembly, path) => + { + // Use custom import resolver for libwebkit2gtk + // Try loading 4.1 first, if that fails, return to default handling + if (name == libwebkit) + { + IntPtr result = IntPtr.Zero; + if (!NativeLibrary.TryLoad("libwebkit2gtk-4.1.so.0", assembly, path, out result)) + { + return IntPtr.Zero; + } + + return result; + } + + return IntPtr.Zero; + }); + } +#endif + #if GTK2 const string plat = "x11-"; #elif GTK3 @@ -420,6 +470,31 @@ static class NMLinux static class NMMac { + +#if NETCOREAPP + + static NMMac() + { + NativeLibrary.SetDllImportResolver(typeof(NMMac).Assembly, (name, assembly, path) => + { + // Use custom import resolver for libwebkit2gtk + // Try loading 4.1 first, if that fails, return to default handling + if (name == libwebkit) + { + IntPtr result = IntPtr.Zero; + if (!NativeLibrary.TryLoad("libwebkit2gtk-4.1.so.0", assembly, path, out result)) + { + return IntPtr.Zero; + } + + return result; + } + + return IntPtr.Zero; + }); + } +#endif + #if GTK2 const string plat = "quartz-"; #elif GTK3 diff --git a/src/Eto.Gtk/NativeMethods.tt b/src/Eto.Gtk/NativeMethods.tt index a11c6e0bf4..89c61b7e0d 100755 --- a/src/Eto.Gtk/NativeMethods.tt +++ b/src/Eto.Gtk/NativeMethods.tt @@ -152,6 +152,31 @@ namespace Eto.GtkSharp static class <#= pclass[i] #> { + +#if NETCOREAPP + + static <#= pclass[i] #>() + { + NativeLibrary.SetDllImportResolver(typeof(<#= pclass[i] #>).Assembly, (name, assembly, path) => + { + // Use custom import resolver for libwebkit2gtk + // Try loading 4.1 first, if that fails, return to default handling + if (name == libwebkit) + { + IntPtr result = IntPtr.Zero; + if (!NativeLibrary.TryLoad("libwebkit2gtk-4.1.so.0", assembly, path, out result)) + { + return IntPtr.Zero; + } + + return result; + } + + return IntPtr.Zero; + }); + } +#endif + #if GTK2 const string plat = "<#= plat[i] #>"; #elif GTK3 From 4a16c9d02d8da91ce79461b8fbae972c1bbc383f Mon Sep 17 00:00:00 2001 From: Miepee Date: Fri, 19 May 2023 23:32:47 +0200 Subject: [PATCH 2/2] Make Eto GTK and Test compatible with net6 --- src/Eto.Gtk/Eto.Gtk.csproj | 2 +- src/Eto.Gtk/Forms/Controls/TextAreaHandler.cs | 1 + test/Eto.Test/Eto.Test.csproj | 2 +- test/Eto.Test/UnitTests/Forms/Controls/RichTextAreaTests.cs | 1 + test/Eto.Test/UnitTests/Forms/Controls/TextAreaTests.cs | 1 + test/Eto.Test/UnitTests/Forms/Controls/TextBoxTests.cs | 1 + .../UnitTests/Forms/Controls/TextChangingEventArgsTests.cs | 1 + 7 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Eto.Gtk/Eto.Gtk.csproj b/src/Eto.Gtk/Eto.Gtk.csproj index b39b1365bb..2e95e339ed 100755 --- a/src/Eto.Gtk/Eto.Gtk.csproj +++ b/src/Eto.Gtk/Eto.Gtk.csproj @@ -1,7 +1,7 @@ - netstandard2.0 + netstandard2.0;net6.0 True Eto.GtkSharp $(DefineConstants);GTK3;GTKCORE diff --git a/src/Eto.Gtk/Forms/Controls/TextAreaHandler.cs b/src/Eto.Gtk/Forms/Controls/TextAreaHandler.cs index 5291715502..8cd8fbbbd2 100644 --- a/src/Eto.Gtk/Forms/Controls/TextAreaHandler.cs +++ b/src/Eto.Gtk/Forms/Controls/TextAreaHandler.cs @@ -2,6 +2,7 @@ using Eto.Forms; using Eto.Drawing; using Eto.GtkSharp.Drawing; +using Range = Eto.Forms.Range; namespace Eto.GtkSharp.Forms.Controls { diff --git a/test/Eto.Test/Eto.Test.csproj b/test/Eto.Test/Eto.Test.csproj index e11ea093db..bc8a4c40f6 100644 --- a/test/Eto.Test/Eto.Test.csproj +++ b/test/Eto.Test/Eto.Test.csproj @@ -1,6 +1,6 @@  - netstandard2.0 + netstandard2.0;net6.0 true $(DefineConstants);PCL diff --git a/test/Eto.Test/UnitTests/Forms/Controls/RichTextAreaTests.cs b/test/Eto.Test/UnitTests/Forms/Controls/RichTextAreaTests.cs index 065511d4b1..6e51f3bd7c 100644 --- a/test/Eto.Test/UnitTests/Forms/Controls/RichTextAreaTests.cs +++ b/test/Eto.Test/UnitTests/Forms/Controls/RichTextAreaTests.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Text; using System.IO; +using Range = Eto.Forms.Range; namespace Eto.Test.UnitTests.Forms.Controls { diff --git a/test/Eto.Test/UnitTests/Forms/Controls/TextAreaTests.cs b/test/Eto.Test/UnitTests/Forms/Controls/TextAreaTests.cs index 33e5e5f451..bbbfd74e91 100644 --- a/test/Eto.Test/UnitTests/Forms/Controls/TextAreaTests.cs +++ b/test/Eto.Test/UnitTests/Forms/Controls/TextAreaTests.cs @@ -1,6 +1,7 @@ using System; using Eto.Forms; using NUnit.Framework; +using Range = Eto.Forms.Range; namespace Eto.Test.UnitTests.Forms.Controls { diff --git a/test/Eto.Test/UnitTests/Forms/Controls/TextBoxTests.cs b/test/Eto.Test/UnitTests/Forms/Controls/TextBoxTests.cs index f09f2501a4..0f369bcbb5 100644 --- a/test/Eto.Test/UnitTests/Forms/Controls/TextBoxTests.cs +++ b/test/Eto.Test/UnitTests/Forms/Controls/TextBoxTests.cs @@ -3,6 +3,7 @@ using Eto.Forms; using System.Threading.Tasks; using System.Collections.Generic; +using Range = Eto.Forms.Range; namespace Eto.Test.UnitTests.Forms.Controls { diff --git a/test/Eto.Test/UnitTests/Forms/Controls/TextChangingEventArgsTests.cs b/test/Eto.Test/UnitTests/Forms/Controls/TextChangingEventArgsTests.cs index c2fd384347..986d81ad28 100644 --- a/test/Eto.Test/UnitTests/Forms/Controls/TextChangingEventArgsTests.cs +++ b/test/Eto.Test/UnitTests/Forms/Controls/TextChangingEventArgsTests.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using Eto.Forms; using NUnit.Framework; +using Range = Eto.Forms.Range; namespace Eto.Test.UnitTests.Forms.Controls {