From cf40cded1708bb303be4a404b7aceddd196e1d46 Mon Sep 17 00:00:00 2001
From: Moli <13026959681@163.com>
Date: 星期三, 29 七月 2026 20:58:14 +0800
Subject: [PATCH] v1.0

---
 src/Moli.Desktop/Layout/LayoutManager.cs |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/Moli.Desktop/Layout/LayoutManager.cs b/src/Moli.Desktop/Layout/LayoutManager.cs
index 5485c25..f2215d9 100644
--- a/src/Moli.Desktop/Layout/LayoutManager.cs
+++ b/src/Moli.Desktop/Layout/LayoutManager.cs
@@ -83,7 +83,7 @@
             ClickThrough = plugin.Manifest.DefaultLayout.ClickThrough,
             Opacity = Clamp(plugin.Manifest.DefaultLayout.Opacity, MinOpacity, MaxOpacity),
             Scale = Clamp(plugin.Manifest.DefaultLayout.Scale, MinScale, MaxScale),
-            DisplayPriority = plugin.Manifest.DefaultLayout.DisplayPriority
+            DisplayLayer = plugin.Manifest.DefaultLayout.DisplayLayer
         };
 
         lock (_gate)
@@ -121,8 +121,8 @@
             Opacity = patch.Opacity ?? layout.Opacity,
             ClickThrough = patch.ClickThrough ?? layout.ClickThrough,
             Scale = patch.Scale ?? layout.Scale,
-            DisplayPriority = patch.DisplayPriority ?? layout.DisplayPriority
-        });
+            DisplayLayer = patch.DisplayLayer ?? layout.DisplayLayer
+        }, allowLocked: IsUnlockPatch(patch));
     }
 
     public IReadOnlyList<WidgetLayout> ReconcileMonitors(IReadOnlyList<MonitorInfo> monitors)
@@ -168,7 +168,7 @@
         }
     }
 
-    private OperationResult<WidgetLayout> Mutate(WidgetInstanceId instanceId, Func<WidgetLayout, WidgetLayout> update)
+    private OperationResult<WidgetLayout> Mutate(WidgetInstanceId instanceId, Func<WidgetLayout, WidgetLayout> update, bool allowLocked = false)
     {
         lock (_gate)
         {
@@ -179,7 +179,7 @@
             }
 
             var current = _document.Instances[index];
-            if (current.IsLocked)
+            if (current.IsLocked && !allowLocked)
             {
                 return OperationResult<WidgetLayout>.Failure("WidgetLayoutLocked", $"Widget layout {instanceId} is locked.");
             }
@@ -256,4 +256,14 @@
 
     private static double Clamp(double value, double min, double max)
         => Math.Min(Math.Max(value, min), max);
+
+    private static bool IsUnlockPatch(WidgetLayoutPatch patch)
+        => patch.IsLocked == false &&
+           patch.Bounds is null &&
+           patch.MonitorId is null &&
+           patch.IsVisible is null &&
+           patch.Opacity is null &&
+           patch.ClickThrough is null &&
+           patch.Scale is null &&
+           patch.DisplayLayer is null;
 }

--
Gitblit v1.9.1