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/Windows/WidgetWindow.cs | 44 +++++++++++++++++++++++++++++++++++++++++---
1 files changed, 41 insertions(+), 3 deletions(-)
diff --git a/src/Moli.Desktop/Windows/WidgetWindow.cs b/src/Moli.Desktop/Windows/WidgetWindow.cs
index 8fe0a6e..ed232bc 100644
--- a/src/Moli.Desktop/Windows/WidgetWindow.cs
+++ b/src/Moli.Desktop/Windows/WidgetWindow.cs
@@ -33,6 +33,7 @@
private readonly Border _editBorder;
private readonly Border _resizeGrip;
private WidgetLayout _layout;
+ private double? _requestedHeight;
private bool _editMode;
private bool _safeInputMode;
private Point? _dragStart;
@@ -62,7 +63,7 @@
AllowsTransparency = true;
Background = Brushes.Transparent;
ShowInTaskbar = false;
- Topmost = true;
+ Topmost = false;
SizeToContent = SizeToContent.Manual;
var root = new Grid { Background = Brushes.Transparent };
@@ -98,6 +99,10 @@
public WidgetInstanceId InstanceId => _layout.InstanceId;
+ public WidgetLayout CurrentLayout => _layout;
+
+ public string HostId => _webView.HostId;
+
public async Task LoadAsync(CancellationToken cancellationToken = default)
{
ApplyLayout(_layout, _editMode, _safeInputMode);
@@ -123,11 +128,26 @@
Left = layout.Bounds.X;
Top = layout.Bounds.Y;
Width = layout.Bounds.Width;
- Height = layout.Bounds.Height;
+ Height = Math.Max(layout.Bounds.Height, _requestedHeight ?? layout.Bounds.Height);
Opacity = Math.Clamp(layout.Opacity, 0.1, 1.0);
Visibility = layout.IsVisible ? Visibility.Visible : Visibility.Hidden;
+ Topmost = layout.DisplayLayer == DisplayLayer.GlobalTop;
_editBorder.Visibility = editMode ? Visibility.Visible : Visibility.Collapsed;
_resizeGrip.Visibility = editMode && !layout.IsLocked ? Visibility.Visible : Visibility.Collapsed;
+ ApplyWin32Styles();
+ }
+
+ public void ApplyRequestedSize(double? width, double? height)
+ {
+ if (width is > 0)
+ {
+ Width = Math.Max(LayoutManager.MinWidth, width.Value);
+ }
+
+ _requestedHeight = height is > 0 && height.Value > _layout.Bounds.Height
+ ? height.Value
+ : null;
+ Height = Math.Max(_layout.Bounds.Height, _requestedHeight ?? _layout.Bounds.Height);
ApplyWin32Styles();
}
@@ -240,7 +260,8 @@
IsVisible = _layout.IsVisible,
IsLocked = _layout.IsLocked,
Opacity = _layout.Opacity,
- ClickThrough = _layout.ClickThrough
+ ClickThrough = _layout.ClickThrough,
+ DisplayLayer = _layout.DisplayLayer
};
private void ApplyWin32Styles()
@@ -256,6 +277,23 @@
_interop.SetToolWindow(hwnd, true);
_interop.SetLayered(hwnd, true, ToAlpha(_layout.Opacity));
_interop.SetClickThrough(hwnd, !_editMode && !_safeInputMode && _layout.ClickThrough);
+ switch (_layout.DisplayLayer)
+ {
+ case DisplayLayer.Desktop:
+ Topmost = false;
+ _interop.MoveToDesktopLayer(hwnd, DesktopLayerMode.WorkerW, _layout.Bounds);
+ break;
+ case DisplayLayer.GlobalTop:
+ _interop.RestoreTopLevelWindow(hwnd);
+ Topmost = true;
+ break;
+ case DisplayLayer.AppTop:
+ case DisplayLayer.Normal:
+ default:
+ _interop.RestoreTopLevelWindow(hwnd);
+ Topmost = false;
+ break;
+ }
}
catch (Exception ex)
{
--
Gitblit v1.9.1