From 834fcde7cf853c12f2028ccdb181c674c5347fb6 Mon Sep 17 00:00:00 2001 From: Ramez Ragaa Date: Thu, 23 Jan 2025 23:44:21 +0200 Subject: [PATCH 1/5] fix(linux): check for libXi before assuming XI2 support (cherry picked from commit f500cbfd5d8cd5e26d04caff054414c0fd4cb18b) --- .../X11XamlRootHost.XInput.cs | 30 +++++++++++++++++-- .../X11_Bindings/x11bindings_XLib.cs | 2 +- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/Uno.UI.Runtime.Skia.X11/X11XamlRootHost.XInput.cs b/src/Uno.UI.Runtime.Skia.X11/X11XamlRootHost.XInput.cs index 36016147761d..d96e8b5890e7 100644 --- a/src/Uno.UI.Runtime.Skia.X11/X11XamlRootHost.XInput.cs +++ b/src/Uno.UI.Runtime.Skia.X11/X11XamlRootHost.XInput.cs @@ -68,6 +68,8 @@ // https://github.com/AvaloniaUI/Avalonia/blob/e0127c610c38701c3af34f580273f6efd78285b5/src/Avalonia.X11/XI2Manager.cs using System; +using System.Runtime.InteropServices; +using Uno.Foundation.Logging; namespace Uno.WinUI.Runtime.Skia.X11; // Excerpt from the spec : @@ -117,13 +119,32 @@ private unsafe (XIVersion version, int opcode) GetXI2Details(IntPtr display) if (!XLib.XQueryExtension(display, "XInputExtension", out var _xi2Opcode, out _, out _)) { - _xi2Details = (XIVersion.Unsupported, _xi2Opcode); + return (_xi2Details = (XIVersion.Unsupported, _xi2Opcode)).Value; } var version = X11Helper.XGetExtensionVersion(display, "XInputExtension"); if (version->major_version != 2) { - _xi2Details = (XIVersion.Unsupported, _xi2Opcode); + if (this.Log().IsEnabled(LogLevel.Error)) + { + this.Log().LogError($"X server does not support X Input Extension 2. Falling back to the core protocol implementation for pointer inputs."); + } + return (_xi2Details = (XIVersion.Unsupported, _xi2Opcode)).Value; + } + + // Just because XI2 is supported, doesn't mean that libXi is present, so we check explicitly for it. + // https://github.com/unoplatform/private/issues/600 + if (NativeLibrary.TryLoad(XLib.libXInput, out var xiHandle)) + { + NativeLibrary.Free(xiHandle); + } + else + { + if (this.Log().IsEnabled(LogLevel.Error)) + { + this.Log().LogError($"X server supports X Input Extension 2, but libXi.so.6 was not found. Falling back to the core protocol implementation for pointer inputs."); + } + return (_xi2Details = (XIVersion.Unsupported, _xi2Opcode)).Value; } _xi2Details = version->minor_version switch @@ -136,6 +157,11 @@ private unsafe (XIVersion version, int opcode) GetXI2Details(IntPtr display) _ => throw new ArgumentException("XI2 version is not between 2.0 and 2.4. There should be no 2.5 or above.") }; + if (this.Log().IsEnabled(LogLevel.Information)) + { + this.Log().Info($"Using X Input Extension 2.{version->minor_version}."); + } + return _xi2Details.Value; } diff --git a/src/Uno.UI.Runtime.Skia.X11/X11_Bindings/x11bindings_XLib.cs b/src/Uno.UI.Runtime.Skia.X11/X11_Bindings/x11bindings_XLib.cs index 37cecfdcd9ee..be9bb834d54b 100644 --- a/src/Uno.UI.Runtime.Skia.X11/X11_Bindings/x11bindings_XLib.cs +++ b/src/Uno.UI.Runtime.Skia.X11/X11_Bindings/x11bindings_XLib.cs @@ -45,7 +45,7 @@ public unsafe static partial class XLib { private const string libX11 = "libX11.so.6"; private const string libX11Randr = "libXrandr.so.2"; - private const string libXInput = "libXi.so.6"; + internal const string libXInput = "libXi.so.6"; [LibraryImport(libX11)] public static partial IntPtr XOpenDisplay(IntPtr display); From 43f5c711164dca814be5a075f266047181789cc9 Mon Sep 17 00:00:00 2001 From: Ramez Ragaa <66218781+ramezgerges@users.noreply.github.com> Date: Fri, 24 Jan 2025 01:07:23 +0200 Subject: [PATCH 2/5] chore: add doc link in log message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jérôme Laban (cherry picked from commit 2701d3c77284ed4ee3fe4afa636f563bbfe26a45) --- src/Uno.UI.Runtime.Skia.X11/X11XamlRootHost.XInput.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Uno.UI.Runtime.Skia.X11/X11XamlRootHost.XInput.cs b/src/Uno.UI.Runtime.Skia.X11/X11XamlRootHost.XInput.cs index d96e8b5890e7..dafc1da8dfaf 100644 --- a/src/Uno.UI.Runtime.Skia.X11/X11XamlRootHost.XInput.cs +++ b/src/Uno.UI.Runtime.Skia.X11/X11XamlRootHost.XInput.cs @@ -127,7 +127,7 @@ private unsafe (XIVersion version, int opcode) GetXI2Details(IntPtr display) { if (this.Log().IsEnabled(LogLevel.Error)) { - this.Log().LogError($"X server does not support X Input Extension 2. Falling back to the core protocol implementation for pointer inputs."); + this.Log().LogError($"X server does not support X Input Extension 2. Falling back to the core protocol implementation for pointer inputs. (For more information see: https://aka.platform.uno/skia-desktop"); } return (_xi2Details = (XIVersion.Unsupported, _xi2Opcode)).Value; } From 2857d4472b02afd0d5c21a331ff9d1dd3c390915 Mon Sep 17 00:00:00 2001 From: Ramez Ragaa <66218781+ramezgerges@users.noreply.github.com> Date: Fri, 24 Jan 2025 01:07:33 +0200 Subject: [PATCH 3/5] chore: add doc link in log message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jérôme Laban (cherry picked from commit 211f7f78cc148185e693be45619fcd75d13a4a94) --- src/Uno.UI.Runtime.Skia.X11/X11XamlRootHost.XInput.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Uno.UI.Runtime.Skia.X11/X11XamlRootHost.XInput.cs b/src/Uno.UI.Runtime.Skia.X11/X11XamlRootHost.XInput.cs index dafc1da8dfaf..77c145bcaa04 100644 --- a/src/Uno.UI.Runtime.Skia.X11/X11XamlRootHost.XInput.cs +++ b/src/Uno.UI.Runtime.Skia.X11/X11XamlRootHost.XInput.cs @@ -142,7 +142,7 @@ private unsafe (XIVersion version, int opcode) GetXI2Details(IntPtr display) { if (this.Log().IsEnabled(LogLevel.Error)) { - this.Log().LogError($"X server supports X Input Extension 2, but libXi.so.6 was not found. Falling back to the core protocol implementation for pointer inputs."); + this.Log().LogError($"X server supports X Input Extension 2, but libXi.so.6 was not found. Falling back to the core protocol implementation for pointer inputs. For more information see: https://aka.platform.uno/skia-desktop"); } return (_xi2Details = (XIVersion.Unsupported, _xi2Opcode)).Value; } From cb4fad52096ed5ca59c1bf9c93b716e36d085c6d Mon Sep 17 00:00:00 2001 From: Ramez Ragaa <66218781+ramezgerges@users.noreply.github.com> Date: Fri, 24 Jan 2025 01:08:13 +0200 Subject: [PATCH 4/5] chore: info -> debug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jérôme Laban (cherry picked from commit 8b2fb653f4a48d304830b123801322aef742a4b8) --- src/Uno.UI.Runtime.Skia.X11/X11XamlRootHost.XInput.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Uno.UI.Runtime.Skia.X11/X11XamlRootHost.XInput.cs b/src/Uno.UI.Runtime.Skia.X11/X11XamlRootHost.XInput.cs index 77c145bcaa04..d5806ad73a60 100644 --- a/src/Uno.UI.Runtime.Skia.X11/X11XamlRootHost.XInput.cs +++ b/src/Uno.UI.Runtime.Skia.X11/X11XamlRootHost.XInput.cs @@ -157,9 +157,9 @@ private unsafe (XIVersion version, int opcode) GetXI2Details(IntPtr display) _ => throw new ArgumentException("XI2 version is not between 2.0 and 2.4. There should be no 2.5 or above.") }; - if (this.Log().IsEnabled(LogLevel.Information)) + if (this.Log().IsEnabled(LogLevel.Debug)) { - this.Log().Info($"Using X Input Extension 2.{version->minor_version}."); + this.Log().Debug($"Using X Input Extension 2.{version->minor_version}."); } return _xi2Details.Value; From dcaa662c3b0a75569b3d030bf936233b5c7eff26 Mon Sep 17 00:00:00 2001 From: Ramez Ragaa Date: Fri, 24 Jan 2025 01:12:18 +0200 Subject: [PATCH 5/5] chore: update docs (cherry picked from commit 715664559758ff39d03e6acbe4aa7e328ab5a998) --- .../includes/additional-linux-setup-inline.md | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/doc/articles/includes/additional-linux-setup-inline.md b/doc/articles/includes/additional-linux-setup-inline.md index 6ec3e77c4993..b74626be289f 100644 --- a/doc/articles/includes/additional-linux-setup-inline.md +++ b/doc/articles/includes/additional-linux-setup-inline.md @@ -1,19 +1,10 @@ -## [**Ubuntu 18.04**](#tab/ubuntu1804) - -- Install the required dependencies: - - ```bash - sudo apt update - sudo apt-get install mesa-utils libgl1-mesa-glx ttf-mscorefonts-installer dbus libfontconfig1 libxrandr2 - ``` - ## [**Ubuntu 20.04/22.04**](#tab/ubuntu2004) - Install the required dependencies: ```bash sudo apt update - sudo apt install mesa-utils libgl1-mesa-glx ttf-mscorefonts-installer dbus libfontconfig1 libxrandr2 + sudo apt install mesa-utils libgl1-mesa-glx ttf-mscorefonts-installer dbus libfontconfig1 libxrandr2 libxi-dev ``` ## [**ArchLinux 5.8.14 or later / Manjaro**](#tab/archlinux2004) @@ -27,7 +18,7 @@ - Install the necessary dependencies ```bash - sudo pacman -S dotnet-targeting-pack dotnet-sdk dotnet-host dotnet-runtime python ninja gn aspnet-runtime dbus libxrandr + sudo pacman -S dotnet-targeting-pack dotnet-sdk dotnet-host dotnet-runtime python ninja gn aspnet-runtime dbus libxrandr libxi ``` ---