From 9b5711d3124622b1f1b18500d442c76492da877a Mon Sep 17 00:00:00 2001
From: chunhualin1 <chunhualin1@lenovo.com>
Date: 星期一, 17 八月 2026 16:52:33 +0800
Subject: [PATCH] 优化llm插件及bug修复

---
 src/Moli.Desktop/Interop/Win32InteropService.cs |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/Moli.Desktop/Interop/Win32InteropService.cs b/src/Moli.Desktop/Interop/Win32InteropService.cs
index 1b56207..512cf03 100644
--- a/src/Moli.Desktop/Interop/Win32InteropService.cs
+++ b/src/Moli.Desktop/Interop/Win32InteropService.cs
@@ -190,15 +190,25 @@
         var styleFlag = unchecked((uint)flag);
         var currentStyle = unchecked((uint)current);
         var updated = enabled ? currentStyle | styleFlag : currentStyle & ~styleFlag;
-        NativeMethods.SetWindowLongPtr(hwnd, NativeMethods.GwlExStyle, new IntPtr(updated));
-        var error = NativeMethods.GetLastError();
-        if (error != 0)
+        if (updated == currentStyle)
         {
-            _diagnostics.Record(
-                DiagnosticSeverity.Warning,
-                DiagnosticCodes.Win32InteropFailed,
-                $"{operation} failed.",
-                new Dictionary<string, string> { ["hwnd"] = hwnd.ToString("X"), ["error"] = error.ToString() });
+            return;
+        }
+
+        NativeMethods.SetWindowLongPtr(hwnd, NativeMethods.GwlExStyle, new IntPtr(unchecked((int)updated)));
+        // Extended-style changes (especially WS_EX_TRANSPARENT) do not reliably update hit-testing
+        // until the frame is refreshed. Without this, clearing click-through in edit/safe-input
+        // mode can leave the window visually present but permanently unclickable.
+        if (!NativeMethods.SetWindowPos(
+            hwnd,
+            IntPtr.Zero,
+            0,
+            0,
+            0,
+            0,
+            NativeMethods.SwpNoMove | NativeMethods.SwpNoSize | NativeMethods.SwpNoZOrder | NativeMethods.SwpNoActivate | NativeMethods.SwpFrameChanged))
+        {
+            RecordWin32Failure($"{operation}.SetWindowPos", hwnd);
         }
     }
 

--
Gitblit v1.9.1