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 |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/Moli.Desktop/Layout/LayoutManager.cs b/src/Moli.Desktop/Layout/LayoutManager.cs
index a8013c3..f2215d9 100644
--- a/src/Moli.Desktop/Layout/LayoutManager.cs
+++ b/src/Moli.Desktop/Layout/LayoutManager.cs
@@ -122,7 +122,7 @@
             ClickThrough = patch.ClickThrough ?? layout.ClickThrough,
             Scale = patch.Scale ?? layout.Scale,
             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