基于WebView2实现的Win11桌面框架,利用插件自定义
Moli
2026-05-04 ddd6889459bccf5015cd0c9629cdf4f4ce8fb8e1
src/Moli.Desktop/Interop/Win32InteropService.cs
@@ -45,6 +45,9 @@
    }
    public void MoveToDesktopLayer(IntPtr hwnd, DesktopLayerMode mode, MonitorInfo monitor)
        => MoveToDesktopLayer(hwnd, mode, monitor.Bounds);
    public void MoveToDesktopLayer(IntPtr hwnd, DesktopLayerMode mode, RectD bounds)
    {
        var candidates = mode == DesktopLayerMode.WorkerW
            ? _strategies.OrderBy(strategy => strategy is WorkerWDesktopLayerStrategy ? 0 : 1)
@@ -57,7 +60,7 @@
                continue;
            }
            if (strategy.TryAttachWallpaperWindow(hwnd, monitor, out var error))
            if (strategy.TryAttachDesktopWindow(hwnd, bounds, out var error))
            {
                return;
            }
@@ -74,6 +77,20 @@
        }
    }
    public void RestoreTopLevelWindow(IntPtr hwnd)
    {
        NativeMethods.SetParent(hwnd, IntPtr.Zero);
        var error = NativeMethods.GetLastError();
        if (error != 0)
        {
            _diagnostics.Record(
                DiagnosticSeverity.Warning,
                DiagnosticCodes.Win32InteropFailed,
                "RestoreTopLevelWindow failed.",
                new Dictionary<string, string> { ["hwnd"] = hwnd.ToString("X"), ["error"] = error.ToString() });
        }
    }
    public void SetBottomMost(IntPtr hwnd)
    {
        if (!NativeMethods.SetWindowPos(