基于WebView2实现的Win11桌面框架,利用插件自定义
Moli
2026-08-12 e2d07826ede5c1df0f884ef8a59e0a89c95b7d08
src/Moli.Desktop/Interop/BottomDesktopLayerStrategy.cs
@@ -1,5 +1,6 @@
using Moli.Desktop.Configuration;
using Moli.Desktop.Diagnostics;
using Moli.Desktop.Layout;
namespace Moli.Desktop.Interop;
@@ -17,16 +18,22 @@
    public bool IsSupported() => true;
    public bool TryAttachWallpaperWindow(IntPtr hwnd, MonitorInfo monitor, out string? error)
    public bool TryAttachDesktopWindow(IntPtr hwnd, MonitorInfo monitor, RectD bounds, out string? error)
    {
        error = null;
        var scale = monitor.Scale;
        var x = (int)(bounds.X * scale);
        var y = (int)(bounds.Y * scale);
        var w = (int)(bounds.Width * scale);
        var h = (int)(bounds.Height * scale);
        if (!NativeMethods.SetWindowPos(
            hwnd,
            NativeMethods.HwndBottom,
            (int)monitor.Bounds.X,
            (int)monitor.Bounds.Y,
            (int)monitor.Bounds.Width,
            (int)monitor.Bounds.Height,
            x,
            y,
            w,
            h,
            NativeMethods.SwpNoActivate | NativeMethods.SwpShowWindow))
        {
            error = $"SetWindowPos failed with {NativeMethods.GetLastError()}";