diff --git a/Source/HedgeModManager.UI/HedgeModManager.UI.csproj b/Source/HedgeModManager.UI/HedgeModManager.UI.csproj index 22b5983..1b3adec 100644 --- a/Source/HedgeModManager.UI/HedgeModManager.UI.csproj +++ b/Source/HedgeModManager.UI/HedgeModManager.UI.csproj @@ -33,6 +33,7 @@ + diff --git a/Source/HedgeModManager.UI/Program.cs b/Source/HedgeModManager.UI/Program.cs index dff0c4d..4d698bd 100644 --- a/Source/HedgeModManager.UI/Program.cs +++ b/Source/HedgeModManager.UI/Program.cs @@ -210,7 +210,31 @@ public static string GetTagName() // Avalonia configuration, don't remove; also used by visual designer. public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure() - .UsePlatformDetect() + .UsePlatformDetectPreferWayland() .WithInterFont() .LogToTrace(); } + +internal static class LinuxPlatformDetector +{ + public static AppBuilder UsePlatformDetectPreferWayland(this AppBuilder builder) + { + if (!OperatingSystem.IsLinux()) + return builder.UsePlatformDetect(); + + if (IsWaylandSession()) + builder.UseWayland(); + else + builder.UseX11(); + + builder.UseSkia().UseHarfBuzz(); + return builder; + } + + private static bool IsWaylandSession() + => !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("WAYLAND_DISPLAY")) + || string.Equals( + Environment.GetEnvironmentVariable("XDG_SESSION_TYPE"), + "wayland", + StringComparison.OrdinalIgnoreCase); +} diff --git a/flatpak/io.github.hedge_dev.hedgemodmanager-autobuild.yml b/flatpak/io.github.hedge_dev.hedgemodmanager-autobuild.yml index a103dbb..f032c72 100644 --- a/flatpak/io.github.hedge_dev.hedgemodmanager-autobuild.yml +++ b/flatpak/io.github.hedge_dev.hedgemodmanager-autobuild.yml @@ -12,7 +12,8 @@ build-options: command: HedgeModManager.UI finish-args: - - --socket=x11 + - --socket=fallback-x11 + - --socket=wayland # UnleashedRecomp permissions - --filesystem=~/.config/UnleashedRecomp - --filesystem=~/.local/share/applications/UnleashedRecomp.desktop:ro diff --git a/flatpak/io.github.hedge_dev.hedgemodmanager.yml b/flatpak/io.github.hedge_dev.hedgemodmanager.yml index 1b06e01..1809060 100644 --- a/flatpak/io.github.hedge_dev.hedgemodmanager.yml +++ b/flatpak/io.github.hedge_dev.hedgemodmanager.yml @@ -12,7 +12,8 @@ build-options: command: HedgeModManager.UI finish-args: - - --socket=x11 + - --socket=fallback-x11 + - --socket=wayland # UnleashedRecomp permissions - --filesystem=~/.config/UnleashedRecomp - --filesystem=~/.local/share/applications/UnleashedRecomp.desktop:ro