diff --git a/StarterNG/Application/SettingsStore.cs b/StarterNG/Application/SettingsStore.cs index 5f4c0ed..008f99e 100644 --- a/StarterNG/Application/SettingsStore.cs +++ b/StarterNG/Application/SettingsStore.cs @@ -382,7 +382,7 @@ public sealed class SettingsStore if (string.Equals(a[i], b[i], StringComparison.OrdinalIgnoreCase)) continue; if (double.TryParse(a[i], NumberStyles.Float, CultureInfo.InvariantCulture, out double x) && - double.TryParse(b[i], NumberStyles.Float, CultureInfo.InvariantCulture, out double y) && x == y) + double.TryParse(b[i], NumberStyles.Float, CultureInfo.InvariantCulture, out double y) && x.Equals(y)) continue; if (Bool(a[i]) is { } p && p == Bool(b[i])) continue; diff --git a/StarterNG/Infrastructure/Monitors.cs b/StarterNG/Infrastructure/Monitors.cs index e0fe588..898d850 100644 --- a/StarterNG/Infrastructure/Monitors.cs +++ b/StarterNG/Infrastructure/Monitors.cs @@ -138,15 +138,24 @@ public static class Monitors // ── Linux: the connected RandR outputs, as x11_monitor.c of GLFW names them ── + // A line of xrandr is short; one that takes longer than this to match is no report of monitors. + private static readonly TimeSpan MatchTimeout = TimeSpan.FromSeconds(1); + private static readonly Regex Output = new( - @"^(\S+) connected (primary )?(\d+)x(\d+)\+(\d+)\+(\d+)", RegexOptions.CultureInvariant); + @"^(\S+) connected (primary )?(\d+)x(\d+)\+(\d+)\+(\d+)", RegexOptions.CultureInvariant, MatchTimeout); // A mode line under an output: the rate in use is the one marked with a star. - private static readonly Regex CurrentRate = new(@"^\s+\S+.*?\s(\d+(?:\.\d+)?)\*", RegexOptions.CultureInvariant); + private static readonly Regex CurrentRate = new(@"^\s+\S+.*?\s(\d+(?:\.\d+)?)\*", RegexOptions.CultureInvariant, MatchTimeout); + + // Where distributions put xrandr: run from there, not from whatever PATH finds first. + private static readonly string[] XrandrPlaces = { "/usr/bin/xrandr", "/usr/local/bin/xrandr", "/bin/xrandr" }; private static IReadOnlyList FromXrandr() { - using var process = Process.Start(new ProcessStartInfo("xrandr", "--query") + string? xrandr = Array.Find(XrandrPlaces, System.IO.File.Exists); + if (xrandr is null) + return Array.Empty(); + using var process = Process.Start(new ProcessStartInfo(xrandr, "--query") { RedirectStandardOutput = true, RedirectStandardError = true, diff --git a/StarterNG/Infrastructure/Settings/SettingsSerializer.cs b/StarterNG/Infrastructure/Settings/SettingsSerializer.cs index f0ceebb..b7ec0a6 100644 --- a/StarterNG/Infrastructure/Settings/SettingsSerializer.cs +++ b/StarterNG/Infrastructure/Settings/SettingsSerializer.cs @@ -443,7 +443,7 @@ public sealed class SettingsSerializer return tokens.Length >= 2 && TryParseMouseScale(tokens[0], out _) && TryParseMouseScale(tokens[1], out double y) && - Math.Abs(y) == SimulatorSettings.MouseScaleY; + Math.Abs(y).Equals(SimulatorSettings.MouseScaleY); } private static bool TryParseMouseScale(string token, out double scale) => diff --git a/StarterNG/Views/TrainsetRow.cs b/StarterNG/Views/TrainsetRow.cs index 90969f1..1a7c4d8 100644 --- a/StarterNG/Views/TrainsetRow.cs +++ b/StarterNG/Views/TrainsetRow.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using Avalonia; using Avalonia.Automation; @@ -84,7 +85,7 @@ internal static class TrainsetRow scroller.ScrollChanged += (_, _) => { double below = scroller.Extent.Width > scroller.Viewport.Width + 0.5 ? ScrollBarLane : 0; - if (strip.Margin.Bottom != below) + if (Math.Abs(strip.Margin.Bottom - below) > 0.1) strip.Margin = new Thickness(0, 0, 0, below); }; return scroller;