From 71c55f7414db6d94d929a2463c86ad20c21ea579 Mon Sep 17 00:00:00 2001 From: RobertBeekman Date: Tue, 20 Oct 2026 09:47:42 +0200 Subject: [PATCH] Core - Fix default headset layouts and the z-index of devices placed by the auto-arrange fallback - Headsets with 2 or 4 LEDs get their default layout, the files are named "... LEDs headset.xml" - Devices placed by the auto-arrange fallback get the z-index of their type --- .../Services/DeviceServiceTests.cs | 23 ++++++++----------- .../Models/Surface/Layout/ArtemisLayout.cs | 4 ++-- .../Storage/Models/SurfaceArrangementType.cs | 2 ++ 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/Artemis.Core.Tests/Services/DeviceServiceTests.cs b/src/Artemis.Core.Tests/Services/DeviceServiceTests.cs index 2de585117..3e7ab284c 100644 --- a/src/Artemis.Core.Tests/Services/DeviceServiceTests.cs +++ b/src/Artemis.Core.Tests/Services/DeviceServiceTests.cs @@ -60,21 +60,16 @@ public class DeviceServiceTests : ServiceTestBase } [Theory] - [InlineData("Artemis 1 LED headset.xml", true)] - [InlineData("Artemis 2 LEDs headset.xml", false)] - [InlineData("Artemis 4 LEDs headset.xml", false)] - public void AddDeviceProvider_GivesHeadsetsTheDefaultLayoutForTheirNumberOfLeds(string layoutFile, bool getsLayout) + [InlineData("Artemis 1 LED headset.xml")] + [InlineData("Artemis 2 LEDs headset.xml")] + [InlineData("Artemis 4 LEDs headset.xml")] + public void AddDeviceProvider_GivesHeadsetsTheDefaultLayoutForTheirNumberOfLeds(string layoutFile) { AddDeviceProvider(Path.Combine(AppContext.BaseDirectory, "DefaultLayouts", "Artemis", "Headset", layoutFile)); - // Pinned as-is: the default headset layouts are looked up as "Artemis 2 LED headset.xml" and "Artemis 4 LED - // headset.xml", but the files are named "... LEDs headset.xml", so headsets with 2 or more LEDs get no default - // layout (the device service logs it as an invalid layout) ArtemisDevice headset = Devices.Devices.Single(); - if (getsLayout) - headset.Layout!.IsDefaultLayout.ShouldBeTrue(); - else - headset.Layout.ShouldBeNull(); + headset.Layout!.IsDefaultLayout.ShouldBeTrue(); + headset.Layout.FilePath.ShouldEndWith(layoutFile); } [Fact] @@ -294,9 +289,9 @@ public class DeviceServiceTests : ServiceTestBase // There's no fan to place the LED strip next to, so it goes 10 to the right of everything else (strip.X, strip.Y).ShouldBe((10 + 441 + 10f, 0f)); - // Pinned as-is: only devices placed by one of their type's own rules get the z-index of their type. LED strips - // normally get 2, but placed by the fallback (no fan to place it next to) it keeps the 1 every new device starts with - strip.ZIndex.ShouldBe(1); + // Placed by the fallback, the LED strip still gets the z-index of its type + keyboard.ZIndex.ShouldBe(1); + strip.ZIndex.ShouldBe(2); } [Fact] diff --git a/src/Artemis.Core/Models/Surface/Layout/ArtemisLayout.cs b/src/Artemis.Core/Models/Surface/Layout/ArtemisLayout.cs index 20309d906..a92b9c144 100644 --- a/src/Artemis.Core/Models/Surface/Layout/ArtemisLayout.cs +++ b/src/Artemis.Core/Models/Surface/Layout/ArtemisLayout.cs @@ -164,8 +164,8 @@ public class ArtemisLayout if (device.Leds.Count == 1) return new ArtemisLayout(Path.Combine(DefaultLayoutPath, "Headset", "Artemis 1 LED headset.xml")); if (device.Leds.Count == 2) - return new ArtemisLayout(Path.Combine(DefaultLayoutPath, "Headset", "Artemis 2 LED headset.xml")); - return new ArtemisLayout(Path.Combine(DefaultLayoutPath, "Headset", "Artemis 4 LED headset.xml")); + return new ArtemisLayout(Path.Combine(DefaultLayoutPath, "Headset", "Artemis 2 LEDs headset.xml")); + return new ArtemisLayout(Path.Combine(DefaultLayoutPath, "Headset", "Artemis 4 LEDs headset.xml")); } return null; diff --git a/src/Artemis.Core/Services/Storage/Models/SurfaceArrangementType.cs b/src/Artemis.Core/Services/Storage/Models/SurfaceArrangementType.cs index b2a3e24d8..761648ee0 100644 --- a/src/Artemis.Core/Services/Storage/Models/SurfaceArrangementType.cs +++ b/src/Artemis.Core/Services/Storage/Models/SurfaceArrangementType.cs @@ -54,6 +54,8 @@ internal class SurfaceArrangementType ) {SurfaceArrangement = SurfaceArrangement}; fallback.Apply(devicesToArrange, devices); AppliedConfiguration = fallback; + foreach (ArtemisDevice artemisDevice in devicesToArrange) + artemisDevice.ZIndex = ZIndex; } public Point GetEdge(HorizontalArrangementPosition horizontalPosition, VerticalArrangementPosition verticalPosition)