Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.
C# audio-converteravaloniabatch-conversionconvertercsharpdocument-converterdocx-to-pdfdotnetdrag-and-dropfile-conversionfile-converterheic-converterhwphwpximage-converterlinuxmacospdf-convertervideo-converterwindows
Wayland: decisions in a platform-neutral helper, NWayland link
KnifeLemon8b1874757bc7
diff --git a/THIRD-PARTY-NOTICES.md b/THIRD-PARTY-NOTICES.mdindex 33c3d6ed..95b3db47 100644--- a/THIRD-PARTY-NOTICES.md+++ b/THIRD-PARTY-NOTICES.md@@ -8,7 +8,7 @@ Each component remains under its own license.| Component | License | Project ||---|---|---|| Avalonia UI | MIT | https://github.com/AvaloniaUI/Avalonia |-| NWayland (used by Avalonia.Wayland) | MIT | https://github.com/Glavo/NWayland |+| NWayland (used by Avalonia.Wayland) | MIT | https://github.com/kekekeks/NWayland || CommunityToolkit.Mvvm | MIT | https://github.com/CommunityToolkit/dotnet || SharpHook (libuiohook) | MIT (libuiohook: GPL-3.0 with linking exception / LGPL-3.0) | https://github.com/TolikPylypchuk/SharpHook || Magick.NET / ImageMagick | Apache-2.0 / ImageMagick License | https://github.com/dlemstra/Magick.NET |diff --git a/src/Filee.App/Program.cs b/src/Filee.App/Program.csindex c1cc1471..7aa04f93 100644--- a/src/Filee.App/Program.cs+++ b/src/Filee.App/Program.cs@@ -276,19 +276,10 @@ internal static class Program{var builder = AppBuilder.Configure<App>();#if FILEE_NATIVE_WAYLAND- if (Filee.Platform.Linux.LinuxPlatformServices.IsNativeWaylandRequested(- OperatingSystem.IsLinux(),- Environment.GetEnvironmentVariable("FILEE_USE_WAYLAND"),- Environment.GetEnvironmentVariable("WAYLAND_DISPLAY")))- {- builder.UseWayland();- }- else- {- builder.UsePlatformDetect();- }+ // The native backend is only compiled into Linux builds and only used when asked for (FILEE_USE_WAYLAND=1).+ builder = Filee.Platform.Linux.WaylandSupport.NativeWaylandRequested ? builder.UseWayland() : builder.UsePlatformDetect();#else- builder.UsePlatformDetect();+ builder = builder.UsePlatformDetect();#endifif (OperatingSystem.IsMacOS())diff --git a/src/Filee.App/Services/RadialController.cs b/src/Filee.App/Services/RadialController.csindex 129f376e..659223aa 100644--- a/src/Filee.App/Services/RadialController.cs+++ b/src/Filee.App/Services/RadialController.cs@@ -222,10 +222,7 @@ public sealed class RadialController(// On native Wayland, hiding an xdg_toplevel surface causes the compositor to destroy its surface,// and re-showing raises an InvalidOperationException. Track Closed to re-create on the next gesture.- if (Filee.Platform.Linux.LinuxPlatformServices.IsNativeWaylandRequested(- OperatingSystem.IsLinux(),- Environment.GetEnvironmentVariable("FILEE_USE_WAYLAND"),- Environment.GetEnvironmentVariable("WAYLAND_DISPLAY")))+ if (Filee.Platform.Linux.WaylandSupport.NativeWaylandRequested){window.Closed += (_, _) =>{diff --git a/src/Filee.Platform.Linux/LinuxPlatformServices.cs b/src/Filee.Platform.Linux/LinuxPlatformServices.csindex a34cc1bd..15135396 100644--- a/src/Filee.Platform.Linux/LinuxPlatformServices.cs+++ b/src/Filee.Platform.Linux/LinuxPlatformServices.cs@@ -27,29 +27,11 @@ public sealed class LinuxPlatformServices : IPlatformServices// relatively there; a KWin script or Hyprland window rule places the donut at the cursor.private static readonly bool WaylandGestures = IsWaylandSession&& Environment.GetEnvironmentVariable("FILEE_WAYLAND_GESTURES") == "1"- && IsSupportedWaylandCompositor(+ && WaylandSupport.IsSupportedCompositor(Environment.GetEnvironmentVariable("XDG_CURRENT_DESKTOP"),Environment.GetEnvironmentVariable("HYPRLAND_INSTANCE_SIGNATURE"))&& CanReadInputDevices();- /// <summary>Decides whether the Wayland compositor supports positioning the donut at the cursor.</summary>- public static bool IsSupportedWaylandCompositor(string? xdgCurrentDesktop, string? hyprlandSignature)- {- var desktop = xdgCurrentDesktop ?? "";- if (desktop.Split(':').Contains("KDE", StringComparer.OrdinalIgnoreCase))- return true;- if (desktop.Split(':').Contains("Hyprland", StringComparer.OrdinalIgnoreCase)- || !string.IsNullOrEmpty(hyprlandSignature))- return true;- return false;- }-- /// <summary>Decides whether the native Wayland backend (Avalonia.Wayland) is opted into.</summary>- public static bool IsNativeWaylandRequested(bool isLinux, string? fileeUseWayland, string? waylandDisplay) =>- isLinux- && string.Equals(fileeUseWayland, "1", StringComparison.Ordinal)- && !string.IsNullOrEmpty(waylandDisplay);-private static bool CanReadInputDevices(){trydiff --git a/src/Filee.Platform.Linux/WaylandSupport.cs b/src/Filee.Platform.Linux/WaylandSupport.csnew file mode 100644index 00000000..f8504ce8--- /dev/null+++ b/src/Filee.Platform.Linux/WaylandSupport.cs@@ -0,0 +1,32 @@+// Decisions about Wayland that only depend on environment values, kept apart from the Linux services so the app can ask+// them on every platform and tests can feed them values.++namespace Filee.Platform.Linux;++public static class WaylandSupport+{+ /// <summary>+ /// Whether the native Wayland backend (Avalonia.Wayland) is opted into: on Linux, with <c>FILEE_USE_WAYLAND=1</c>+ /// and a Wayland display to connect to. Otherwise Filee runs through X11 or XWayland.+ /// </summary>+ public static bool IsNativeWaylandRequested(bool isLinux, string? fileeUseWayland, string? waylandDisplay) =>+ isLinux+ && string.Equals(fileeUseWayland, "1", StringComparison.Ordinal)+ && !string.IsNullOrEmpty(waylandDisplay);++ /// <summary><see cref="IsNativeWaylandRequested(bool, string?, string?)"/> for this process.</summary>+ public static bool NativeWaylandRequested => IsNativeWaylandRequested(OperatingSystem.IsLinux(),+ Environment.GetEnvironmentVariable("FILEE_USE_WAYLAND"), Environment.GetEnvironmentVariable("WAYLAND_DISPLAY"));++ /// <summary>+ /// Whether the compositor has a way to put the donut at the cursor: KDE Plasma (the KWin script) or Hyprland (a+ /// window rule), told by <c>XDG_CURRENT_DESKTOP</c> or <c>HYPRLAND_INSTANCE_SIGNATURE</c>.+ /// </summary>+ public static bool IsSupportedCompositor(string? xdgCurrentDesktop, string? hyprlandSignature)+ {+ var desktops = (xdgCurrentDesktop ?? "").Split(':');+ return desktops.Contains("KDE", StringComparer.OrdinalIgnoreCase)+ || desktops.Contains("Hyprland", StringComparer.OrdinalIgnoreCase)+ || !string.IsNullOrEmpty(hyprlandSignature);+ }+}diff --git a/tests/Filee.Platform.Tests/WaylandDecisionTests.cs b/tests/Filee.Platform.Tests/WaylandDecisionTests.csindex 244200c5..131ccb79 100644--- a/tests/Filee.Platform.Tests/WaylandDecisionTests.cs+++ b/tests/Filee.Platform.Tests/WaylandDecisionTests.cs@@ -1,9 +1,10 @@-using System.Runtime.Versioning;+// The Wayland decisions that only depend on environment values (#367): which compositors can place the donut, and+// when the native backend is used.+using Filee.Platform.Linux;namespace Filee.Platform.Tests;-[SupportedOSPlatform("linux")]public sealed class WaylandDecisionTests{[Theory]@@ -19,10 +20,10 @@ public sealed class WaylandDecisionTests[InlineData("XFCE", null, false)][InlineData(null, null, false)][InlineData("", "", false)]- public void IsSupportedWaylandCompositor_Recognizes_Supported_Desktops(+ public void KDE_and_Hyprland_can_place_the_donut(string? xdgCurrentDesktop, string? hyprlandSignature, bool expected){- var result = LinuxPlatformServices.IsSupportedWaylandCompositor(xdgCurrentDesktop, hyprlandSignature);+ var result = WaylandSupport.IsSupportedCompositor(xdgCurrentDesktop, hyprlandSignature);Assert.Equal(expected, result);}@@ -36,10 +37,10 @@ public sealed class WaylandDecisionTests[InlineData(true, "true", "wayland-0", false)] // Switch not "1"[InlineData(true, "1", null, false)] // No WAYLAND_DISPLAY[InlineData(true, "1", "", false)] // Empty WAYLAND_DISPLAY- public void IsNativeWaylandRequested_Requires_Linux_And_Switch_And_Display(+ public void The_native_backend_needs_Linux_the_switch_and_a_display(bool isLinux, string? fileeUseWayland, string? waylandDisplay, bool expected){- var result = LinuxPlatformServices.IsNativeWaylandRequested(isLinux, fileeUseWayland, waylandDisplay);+ var result = WaylandSupport.IsNativeWaylandRequested(isLinux, fileeUseWayland, waylandDisplay);Assert.Equal(expected, result);}}