Skip to content

armgit / Filee

Public Imported from GitHub
0

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.

feat(linux): fix cross-platform build, add Wayland unit tests, and update notices and placement docs

mahaveergurjarf6a34b120460
diff --git a/Directory.Packages.props b/Directory.Packages.props
index ec8addbe..5ec34bcd 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -12,8 +12,6 @@
<PackageVersion Include="Avalonia" Version="$(AvaloniaVersion)" />
<PackageVersion Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
<PackageVersion Include="Avalonia.Wayland" Version="$(AvaloniaVersion)" />
- <PackageVersion Include="Avalonia.Skia" Version="$(AvaloniaVersion)" />
- <PackageVersion Include="Avalonia.HarfBuzz" Version="$(AvaloniaVersion)" />
<PackageVersion Include="Avalonia.Themes.Fluent" Version="$(AvaloniaVersion)" />
<PackageVersion Include="Avalonia.Controls.ColorPicker" Version="$(AvaloniaVersion)" />
<PackageVersion Include="Avalonia.Headless" Version="$(AvaloniaVersion)" />
diff --git a/THIRD-PARTY-NOTICES.md b/THIRD-PARTY-NOTICES.md
index 2e63361c..512f75c0 100644
--- a/THIRD-PARTY-NOTICES.md
+++ b/THIRD-PARTY-NOTICES.md
@@ -8,6 +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 |
| 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/installer/linux/INSTALL.txt b/installer/linux/INSTALL.txt
index 9c34e8dd..32f6b9fa 100644
--- a/installer/linux/INSTALL.txt
+++ b/installer/linux/INSTALL.txt
@@ -42,8 +42,9 @@ libwayland-client0 on Ubuntu). To turn it on:
qdbus6 org.kde.KWin /KWin reconfigure
After updating Filee, upgrade the installed script the same way, with
--upgrade instead of --install, then run the reconfigure line again.
- For Hyprland: Add the floating window rule in ~/.config/hypr/hyprland.conf (or hyprland.lua):
+ For Hyprland: Add the floating and placement window rules in ~/.config/hypr/hyprland.conf (or hyprland.lua):
windowrulev2 = float, title:^(Filee Donut)$
+ windowrulev2 = move cursor -50% -50%, title:^(Filee Donut)$
windowrulev2 = noborder, title:^(Filee Donut)$
windowrulev2 = noshadow, title:^(Filee Donut)$
windowrulev2 = noblur, title:^(Filee Donut)$
diff --git a/src/Filee.App/Filee.App.csproj b/src/Filee.App/Filee.App.csproj
index 68a5d6a4..fee2ef10 100644
--- a/src/Filee.App/Filee.App.csproj
+++ b/src/Filee.App/Filee.App.csproj
@@ -35,11 +35,14 @@
<PackageReference Include="SharpHook" />
</ItemGroup>
+ <PropertyGroup>
+ <FileeNativeWayland Condition="$(RuntimeIdentifier.StartsWith('linux')) Or ('$(RuntimeIdentifier)' == '' And $([MSBuild]::IsOSPlatform('Linux')))">true</FileeNativeWayland>
+ <DefineConstants Condition="'$(FileeNativeWayland)' == 'true'">$(DefineConstants);FILEE_NATIVE_WAYLAND</DefineConstants>
+ </PropertyGroup>
+
<!-- Linux-only Wayland packages to keep Windows and macOS binaries small -->
- <ItemGroup Condition="$([MSBuild]::IsOSPlatform('Linux'))">
+ <ItemGroup Condition="'$(FileeNativeWayland)' == 'true'">
<PackageReference Include="Avalonia.Wayland" />
- <PackageReference Include="Avalonia.Skia" />
- <PackageReference Include="Avalonia.HarfBuzz" />
</ItemGroup>
<ItemGroup>
diff --git a/src/Filee.App/Program.cs b/src/Filee.App/Program.cs
index 6b9caa8f..dd93cbb7 100644
--- a/src/Filee.App/Program.cs
+++ b/src/Filee.App/Program.cs
@@ -275,16 +275,21 @@ internal static class Program
public static AppBuilder BuildAvaloniaApp()
{
var builder = AppBuilder.Configure<App>();
- if (OperatingSystem.IsLinux()
- && string.Equals(Environment.GetEnvironmentVariable("FILEE_USE_WAYLAND"), "1", StringComparison.Ordinal)
- && !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("WAYLAND_DISPLAY")))
+#if FILEE_NATIVE_WAYLAND
+ if (Filee.Platform.Linux.LinuxPlatformServices.IsNativeWaylandRequested(
+ OperatingSystem.IsLinux(),
+ Environment.GetEnvironmentVariable("FILEE_USE_WAYLAND"),
+ Environment.GetEnvironmentVariable("WAYLAND_DISPLAY")))
{
- builder.UseWayland().UseSkia().UseHarfBuzz();
+ builder.UseWayland();
}
else
{
builder.UsePlatformDetect();
}
+#else
+ builder.UsePlatformDetect();
+#endif
if (OperatingSystem.IsMacOS())
builder = builder.With(new MacOSPlatformOptions { ShowInDock = PreloadedStore?.Settings.ShowInDock ?? true });
diff --git a/src/Filee.App/Services/RadialController.cs b/src/Filee.App/Services/RadialController.cs
index 9640b836..129f376e 100644
--- a/src/Filee.App/Services/RadialController.cs
+++ b/src/Filee.App/Services/RadialController.cs
@@ -222,7 +222,10 @@ 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 (OperatingSystem.IsLinux() && string.Equals(Environment.GetEnvironmentVariable("FILEE_USE_WAYLAND"), "1", StringComparison.Ordinal))
+ if (Filee.Platform.Linux.LinuxPlatformServices.IsNativeWaylandRequested(
+ OperatingSystem.IsLinux(),
+ Environment.GetEnvironmentVariable("FILEE_USE_WAYLAND"),
+ Environment.GetEnvironmentVariable("WAYLAND_DISPLAY")))
{
window.Closed += (_, _) =>
{
diff --git a/src/Filee.Platform.Linux/LinuxPlatformServices.cs b/src/Filee.Platform.Linux/LinuxPlatformServices.cs
index ff2f2a2d..a34cc1bd 100644
--- a/src/Filee.Platform.Linux/LinuxPlatformServices.cs
+++ b/src/Filee.Platform.Linux/LinuxPlatformServices.cs
@@ -27,20 +27,29 @@ 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()
+ && IsSupportedWaylandCompositor(
+ Environment.GetEnvironmentVariable("XDG_CURRENT_DESKTOP"),
+ Environment.GetEnvironmentVariable("HYPRLAND_INSTANCE_SIGNATURE"))
&& CanReadInputDevices();
- private static bool IsSupportedWaylandCompositor()
+ /// <summary>Decides whether the Wayland compositor supports positioning the donut at the cursor.</summary>
+ public static bool IsSupportedWaylandCompositor(string? xdgCurrentDesktop, string? hyprlandSignature)
{
- var desktop = Environment.GetEnvironmentVariable("XDG_CURRENT_DESKTOP") ?? "";
+ var desktop = xdgCurrentDesktop ?? "";
if (desktop.Split(':').Contains("KDE", StringComparer.OrdinalIgnoreCase))
return true;
if (desktop.Split(':').Contains("Hyprland", StringComparer.OrdinalIgnoreCase)
- || !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("HYPRLAND_INSTANCE_SIGNATURE")))
+ || !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()
{
try
diff --git a/tests/Filee.Platform.Tests/WaylandDecisionTests.cs b/tests/Filee.Platform.Tests/WaylandDecisionTests.cs
new file mode 100644
index 00000000..244200c5
--- /dev/null
+++ b/tests/Filee.Platform.Tests/WaylandDecisionTests.cs
@@ -0,0 +1,45 @@
+using System.Runtime.Versioning;
+using Filee.Platform.Linux;
+
+namespace Filee.Platform.Tests;
+
+[SupportedOSPlatform("linux")]
+public sealed class WaylandDecisionTests
+{
+ [Theory]
+ [InlineData("KDE", null, true)]
+ [InlineData("kde", null, true)]
+ [InlineData("KDE:GNOME", null, true)]
+ [InlineData("Hyprland", null, true)]
+ [InlineData("hyprland", null, true)]
+ [InlineData(null, "instance_12345", true)]
+ [InlineData("", "instance_12345", true)]
+ [InlineData("GNOME", null, false)]
+ [InlineData("sway", null, false)]
+ [InlineData("XFCE", null, false)]
+ [InlineData(null, null, false)]
+ [InlineData("", "", false)]
+ public void IsSupportedWaylandCompositor_Recognizes_Supported_Desktops(
+ string? xdgCurrentDesktop, string? hyprlandSignature, bool expected)
+ {
+ var result = LinuxPlatformServices.IsSupportedWaylandCompositor(xdgCurrentDesktop, hyprlandSignature);
+ Assert.Equal(expected, result);
+ }
+
+ [Theory]
+ [InlineData(true, "1", "wayland-0", true)]
+ [InlineData(true, "1", "wayland-1", true)]
+ [InlineData(false, "1", "wayland-0", false)] // Not Linux
+ [InlineData(true, null, "wayland-0", false)] // Switch unset
+ [InlineData(true, "", "wayland-0", false)] // Switch empty
+ [InlineData(true, "0", "wayland-0", false)] // Switch 0
+ [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(
+ bool isLinux, string? fileeUseWayland, string? waylandDisplay, bool expected)
+ {
+ var result = LinuxPlatformServices.IsNativeWaylandRequested(isLinux, fileeUseWayland, waylandDisplay);
+ Assert.Equal(expected, result);
+ }
+}