From ddd6889459bccf5015cd0c9629cdf4f4ce8fb8e1 Mon Sep 17 00:00:00 2001
From: Moli <13026959681@163.com>
Date: 星期一, 04 五月 2026 11:26:25 +0800
Subject: [PATCH] 优化Win+D隐藏的问题
---
samples/plugins/sample.audio-visualizer/plugin.json | 2
samples/plugins/sample.webview-test/plugin.json | 3
src/Moli.Desktop/Interop/WorkerWDesktopLayerStrategy.cs | 12
samples/plugins/sample.wallpaper/plugin.json | 3
src/Moli.Desktop/Management/ManagementWindow.xaml | 4
samples/plugins/sample.system-info/plugin.json | 3
src/Moli.Desktop.Tests/Configuration/JsonConfigurationServiceTests.cs | 29 ++
docs/product/llm-command-palette-plugin-prd.md | 394 ++++++++++++++++++++++++++++++
src/Moli.Desktop/Interop/Win32InteropService.cs | 19 +
src/Moli.Desktop.Tests/Interop/FakeWin32InteropService.cs | 16 +
src/Moli.Desktop.Tests/Layout/LayoutManagerTests.cs | 2
src/Moli.Desktop/Host/DefaultContentInstaller.cs | 2
docs/README.md | 1
samples/plugins/sample.clock/plugin.json | 3
docs/architecture/runtime-architecture.md | 16
src/Moli.Desktop/Interop/BottomDesktopLayerStrategy.cs | 12
src/Moli.Desktop/Layout/Geometry.cs | 21 +
docs/architecture/detailed-design.md | 10
src/Moli.Desktop.Tests/Plugins/PluginManagerTests.cs | 4
src/Moli.Desktop/Runtime/DesktopRuntimeCoordinator.cs | 2
src/Moli.Desktop/Assets/Moli.Desktop.ico | 0
src/Moli.Desktop/Configuration/ConfigurationDocuments.cs | 2
src/Moli.Desktop/Layout/LayoutManager.cs | 4
src/Moli.Desktop/Windows/WidgetWindow.cs | 24 +
docs/product/desktop-enhancement-prd.md | 28 +
docs/data/configuration-and-storage.md | 6
src/Moli.Desktop/Management/ManagementWindow.xaml.cs | 34 +
docs/qa/display-layer-acceptance-2026-05-03.md | 37 ++
src/Moli.Desktop/Plugins/PluginManifest.cs | 2
src/Moli.Desktop.Tests/Interop/Win32InteropContractTests.cs | 6
src/Moli.Desktop/Api/LocalApiModels.cs | 9
src/Moli.Desktop/Interop/IDesktopLayerStrategy.cs | 6
src/Moli.Desktop/Interop/IWin32InteropService.cs | 3
docs/qa/mvp-integration-handoff.md | 2
34 files changed, 651 insertions(+), 70 deletions(-)
diff --git a/docs/README.md b/docs/README.md
index 4da9b21..392374c 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -16,6 +16,7 @@
- [Windows 11 妗岄潰澧炲己搴旂敤 PRD](product/desktop-enhancement-prd.md)
- [Moli.Desktop 鐢ㄦ埛鎿嶄綔鎵嬪唽](product/user-manual.md)
+- [LLM 妗岄潰杈撳叆鎻掍欢 PRD](product/llm-command-palette-plugin-prd.md)
## 褰撳墠鏋舵瀯鏂囨。
diff --git a/docs/architecture/detailed-design.md b/docs/architecture/detailed-design.md
index ac74ad8..2825e70 100644
--- a/docs/architecture/detailed-design.md
+++ b/docs/architecture/detailed-design.md
@@ -462,8 +462,8 @@
绛栫暐椤哄簭锛�
-1. `WorkerWDesktopLayerStrategy`锛氬皾璇曞皢澹佺焊绐楀彛鎸傚埌 Explorer WorkerW銆�
-2. `BottomDesktopLayerStrategy`锛氶檷绾т负瑕嗙洊鐩爣鏄剧ず鍣ㄧ殑搴曞眰绐楀彛锛屽苟寮�鍚偣鍑荤┛閫忋��
+1. `WorkerWDesktopLayerStrategy`锛氬皾璇曞皢澹佺焊绐楀彛鍜� `desktop` 灞傜粍浠舵寕鍒� Explorer WorkerW锛屼娇妗岄潰鎻掍欢鍦� Win+D 鍚庝粛鐒舵樉绀恒��
+2. `BottomDesktopLayerStrategy`锛氶檷绾т负瑕嗙洊鐩爣鍖哄煙鐨勫簳灞傜獥鍙o紝骞跺紑鍚偣鍑荤┛閫忋��
閫夋嫨绛栫暐鍚庡啓鍏ヨ瘖鏂細
@@ -517,7 +517,7 @@
| `height` | `40` | 褰撳墠鏄剧ず鍣ㄩ珮搴� |
| `scale` | `0.5` | `3.0` |
| `opacity` | `0.1` | `1.0` |
-| `displayPriority` | `desktopLayer` | `appLayer` |
+| `displayLayer` | `desktop` | `global-top` |
浣嶇疆绾︽潫锛�
@@ -583,7 +583,7 @@
| `SetGlobalLocked(true)` | 鎵�鏈夌粍浠舵嫆缁濇嫋鎷界缉鏀� |
| `ReloadPlugins` | 閲嶆柊鎵弿鎻掍欢鐩綍锛屼繚鐣欏悓 id 缁勪欢甯冨眬 |
| `DisableWallpaper` | 鍏抽棴澹佺焊绐楀彛锛屼繚鐣欏绾搁厤缃� |
-| `UpdateWidgetLayout` | 鏍¢獙銆佸簲鐢ㄧ獥鍙c�佷繚瀛樺竷灞�銆佸箍鎾簨浠讹紝鍖呭惈 `displayPriority` 鏇存柊 |
+| `UpdateWidgetLayout` | 鏍¢獙銆佸簲鐢ㄧ獥鍙c�佷繚瀛樺竷灞�銆佸箍鎾簨浠讹紝鍖呭惈 `displayLayer` 鏇存柊 |
鎵�鏈夊懡浠ら兘閫氳繃 `DesktopRuntimeCoordinator` 杩涘叆锛屾墭鐩樸�佺鐞嗙獥鍙c�丠TTP API 涓嶇洿鎺ヨ皟鐢ㄥ簳灞傛湇鍔°��
@@ -702,7 +702,7 @@
| --- | --- |
| 鐘舵�� | 褰撳墠杩愯鐘舵�併�乄ebView2 Runtime銆丄PI 鐩戝惉銆佹樉绀哄櫒淇℃伅 |
| 澹佺焊 | 褰撳墠澹佺焊鎻掍欢銆佸惎鍋溿�侀噸杞姐�侀潤闊炽�佺偣鍑荤┛閫忋�佹樉绀哄櫒閫夋嫨銆佹湰鍦版枃浠堕�夋嫨 |
-| 缁勪欢 | 缁勪欢鍒楄〃銆佹樉绀洪殣钘忋�侀攣瀹氥�侀�忔槑搴︺�佺偣鍑荤┛閫忋�佹樉绀轰紭鍏堢骇銆佸彸閿紪杈戜綅缃�/澶у皬銆佹墦寮� `layout.json` |
+| 缁勪欢 | 缁勪欢鍒楄〃銆佹樉绀洪殣钘忋�侀攣瀹氥�侀�忔槑搴︺�佺偣鍑荤┛閫忋�佹樉绀哄眰绾с�佸彸閿紪杈戜綅缃�/澶у皬銆佹墦寮� `layout.json` |
| 鎻掍欢 | 鎻掍欢鎵弿缁撴灉銆乵anifest 閿欒銆佸惎鐢ㄧ鐢ㄣ�佸彸閿墦寮� `plugin.json` / `plugins.json` |
| 璇婃柇 | 鏃ュ織鎽樿銆侀敊璇垪琛ㄣ�佹墦寮�鏃ュ織鐩綍銆佷簩娆$‘璁ゆ仮澶嶉粯璁� |
diff --git a/docs/architecture/runtime-architecture.md b/docs/architecture/runtime-architecture.md
index c8808f5..5b38c64 100644
--- a/docs/architecture/runtime-architecture.md
+++ b/docs/architecture/runtime-architecture.md
@@ -117,8 +117,8 @@
### Widget Windows
- 姣忎釜缁勪欢瀹炰緥瀵瑰簲涓�涓嫭绔嬬粍浠剁獥鍙e拰涓�涓� WebView2 琛ㄩ潰銆�
-- 缁勪欢绐楀彛淇濆瓨鐙珛甯冨眬锛歚x`銆乣y`銆乣width`銆乣height`銆乣zIndex`銆乣scale`銆乣locked`銆乣visible`銆乣opacity`銆乣clickThrough`銆�
-- 缁勪欢绐楀彛淇濆瓨 `displayPriority`锛岀敤浜庤〃杈炬闈笂灞傘�佸浘鏍囦笂灞傘�佸簲鐢ㄤ笂灞備笁妗f樉绀烘剰鍥撅紱鍏蜂綋 Win32 灞傜骇鐢辩獥鍙f帶鍒跺櫒闄嶇骇澶勭悊銆�
+- 缁勪欢绐楀彛淇濆瓨鐙珛甯冨眬锛歚x`銆乣y`銆乣width`銆乣height`銆乣zIndex`銆乣scale`銆乣locked`銆乣visible`銆乣opacity`銆乣clickThrough`銆乣displayLayer`銆�
+- 缁勪欢绐楀彛淇濆瓨 `displayLayer`锛岀敤浜庤〃杈� `desktop`銆乣normal`銆乣app-top`銆乣global-top` 鍥涙。鏄剧ず鎰忓浘锛涘叿浣� Win32 灞傜骇鐢辩獥鍙f帶鍒跺櫒闄嶇骇澶勭悊銆�
- 缂栬緫妯″紡涓嬪涓诲眰鎺ョ鎷栨嫿鍜岀缉鏀捐緭鍏ワ紝骞舵殏鏃跺叧闂粍浠剁偣鍑荤┛閫忋��
- 闈炵紪杈戞ā寮忎笅鎸夌粍浠堕厤缃仮澶嶇偣鍑荤┛閫忓拰 Web 鍐呭浜や簰銆�
- 鍗曚釜缁勪欢鍔犺浇澶辫触鏃讹紝缁勪欢杩涘叆 `error` 鐘舵�侊紝瀹夸富缁х画杩愯銆�
@@ -399,15 +399,23 @@
甯冨眬鍧愭爣浠ユ樉绀哄櫒宸ヤ綔鍖虹殑 DIP 鍧愭爣淇濆瓨锛屾覆鏌撴椂鐢� `WindowManager` 鍜� WPF DPI 淇℃伅杞崲涓哄疄闄呭儚绱犮��
+鏄剧ず灞傜骇瑙e喅鏂规锛�
+
+- 鏁版嵁濂戠害缁熶竴浣跨敤 `displayLayer`锛屽彇鍊间粎鍏佽 `desktop`銆乣normal`銆乣app-top`銆乣global-top`銆�
+- `LayoutManager` 鍙礋璐d繚瀛樸�佹牎楠屽拰骞挎挱灞傜骇鎰忓浘锛屼笉鐩存帴鎿嶄綔 Win32銆�
+- `DesktopRuntimeCoordinator` 灏嗘洿鏂板悗鐨勫竷灞�閫氳繃 `IRuntimeSurfaceController` 涓嬪彂锛屼繚璇佺鐞嗙獥鍙c�丄PI 鍜屾墭鐩樺懡浠よ蛋鍚屼竴杩愯鏃惰矾寰勩��
+- `WidgetWindow` 鏄渶缁堢獥鍙h涓烘墽琛岀偣锛歚desktop` 浼樺厛鎸傝浇鍒� Explorer WorkerW 妗岄潰灞備互閬垮厤 Win+D 鏈�灏忓寲锛屽け璐ユ椂闄嶇骇鍒板簳灞傛櫘閫氱獥鍙o紱`normal` 浣跨敤鏅�� WPF 绐楀彛灞傜骇锛宍app-top` 淇濇寔鏈簲鐢ㄥ唴鐨勬櫘閫氱獥鍙f彁鍗囪涔夛紝`global-top` 鎵嶈缃叏灞� `Topmost`銆�
+- 濡傛灉鏌愬眰绾у彈 Windows 妗岄潰鐜闄愬埗鏃犳硶瀹屽叏绮剧‘琛ㄨ揪锛岀獥鍙f帶鍒跺櫒蹇呴』閫夋嫨鏇村畨鍏ㄧ殑闈炲叏灞�缃《琛屼负锛屽苟璁板綍璇婃柇銆�
+
绾︽潫瑙勫垯锛�
- `x`銆乣y` 涓嶅緱浣跨粍浠跺畬鍏ㄧЩ鍑虹洰鏍囨樉绀哄櫒宸ヤ綔鍖恒��
- `width`銆乣height` 蹇呴』鍦ㄦ彃浠堕粯璁ゅ�兼垨瀹夸富鍏ㄥ眬鏈�灏忔渶澶у�间箣闂淬��
-- `zIndex` 鍙湪妗岄潰缁勪欢灞傚唴閮ㄦ帓搴忥紝涓嶈法瓒婃櫘閫氬簲鐢ㄧ獥鍙c��
+- `zIndex` 鍙湪鍚屼竴鏄剧ず灞傜骇鍐呴儴鎺掑簭锛屼笉璺ㄨ秺 `displayLayer` 璇箟銆�
- `locked = true` 鏃舵嫆缁濇嫋鎷藉拰缂╂斁銆�
- `visible = false` 鏃剁獥鍙i殣钘忎絾甯冨眬淇濈暀銆�
- `clickThrough = true` 鏃剁敱 Win32 鎵╁睍鏍峰紡閫忎紶榧犳爣杈撳叆銆�
-- `displayPriority` 鏀寔 `desktopLayer`銆乣iconLayer`銆乣appLayer`锛孧VP 鍏堜互绐楀彛 Topmost 涓庢闈㈠眰绛栫暐缁勫悎瀹炵幇锛屽悗缁啀缁嗗寲 WorkerW/Explorer 鍥炬爣灞備箣闂寸殑绮剧‘鎺掑簭銆�
+- `displayLayer` 鏀寔 `desktop`銆乣normal`銆乣app-top`銆乣global-top`锛歚desktop` 鎸傚埌 WorkerW 妗岄潰灞傚苟鍦� Win+D 鍚庣户缁樉绀猴紝`normal` 閬靛惊鏅�氱獥鍙e眰绾э紝`app-top` 鍙湪鏈簲鐢ㄧ獥鍙h寖鍥村唴鎻愬崌锛宍global-top` 浣跨敤鍏ㄥ眬缃《骞惰姹傛墭鐩�/绠$悊绐楀彛鍙揩閫熸挙閿�銆�
### Audio Visualizer Plugin
diff --git a/docs/data/configuration-and-storage.md b/docs/data/configuration-and-storage.md
index bf23b14..cb884fc 100644
--- a/docs/data/configuration-and-storage.md
+++ b/docs/data/configuration-and-storage.md
@@ -124,7 +124,7 @@
"opacity": 1,
"clickThrough": true,
"scale": 1,
- "displayPriority": "iconLayer"
+ "displayLayer": "desktop"
}
]
}
@@ -162,7 +162,7 @@
"clickThrough": true,
"opacity": 1,
"scale": 1,
- "displayPriority": "iconLayer"
+ "displayLayer": "desktop"
},
"config": {}
}
@@ -181,7 +181,7 @@
| `defaultLayout.height` | `40..2160` |
| `defaultLayout.opacity` | `0.1..1.0` |
| `defaultLayout.scale` | `0.5..3.0` |
-| `defaultLayout.displayPriority` | `desktopLayer` / `iconLayer` / `appLayer` |
+| `defaultLayout.displayLayer` | `desktop` / `normal` / `app-top` / `global-top` |
鏈湴鍏ュ彛蹇呴』鐣欏湪鎻掍欢鐩綍鍐咃紝涓嶈兘閫氳繃鐩稿璺緞閫冮�稿埌鎻掍欢鏍圭洰褰曞銆�
diff --git a/docs/product/desktop-enhancement-prd.md b/docs/product/desktop-enhancement-prd.md
index d9fae84..305207e 100644
--- a/docs/product/desktop-enhancement-prd.md
+++ b/docs/product/desktop-enhancement-prd.md
@@ -64,6 +64,7 @@
- 浣滀负鐢ㄦ埛锛屾垜鍙互鎷栨嫿鍜岀缉鏀惧皬缁勪欢锛岃繖鏍峰畠鑳介�傞厤鎴戠殑妗岄潰甯冨眬銆�
- 浣滀负鐢ㄦ埛锛屾垜鍙互閿佸畾灏忕粍浠讹紝杩欐牱瀹冧笉浼氳璇Щ鍔ㄦ垨璇缉鏀俱��
- 浣滀负鐢ㄦ埛锛屾垜鍙互涓虹粍浠惰缃�忔槑搴﹀拰鐐瑰嚮绌块�忚涓猴紝杩欐牱瀹冨氨鍍忔闈㈡诞灞備竴鏍峰伐浣溿��
+- 浣滀负鐢ㄦ埛锛屾垜鍙互涓虹粍浠堕�夋嫨鏄剧ず灞傜骇锛岃繖鏍风粍浠跺彲浠ュ彧璐村湪妗岄潰銆佷綔涓烘櫘閫氱獥鍙c�佷粎鍦ㄦ湰搴旂敤鍐呯疆椤讹紝鎴栧叏灞�缃《銆�
### 鎻掍欢寮�鍙戜綋楠�
@@ -105,7 +106,15 @@
- 搴旂敤蹇呴』鏀寔浠� HTML/CSS/JS 鎻掍欢褰㈠紡瀹炵幇妗岄潰灏忕粍浠躲��
- 姣忎釜缁勪欢瀹炰緥蹇呴』杩愯鍦� WebView2 琛ㄩ潰涓��
- 搴旂敤蹇呴』鏀寔娣诲姞銆佺Щ闄ゃ�佹樉绀恒�侀殣钘忋�侀噸杞姐�佸惎鐢ㄥ拰绂佺敤缁勪欢銆�
-- 缁勪欢瀹炰緥蹇呴』鍏峰鐙珛甯冨眬鐘舵�侊細`x`銆乣y`銆乣width`銆乣height`銆乣zIndex`銆乣scale`銆乣locked`銆乣visible`銆乣opacity` 鍜� `clickThrough`銆�
+- 缁勪欢瀹炰緥蹇呴』鍏峰鐙珛甯冨眬鐘舵�侊細`x`銆乣y`銆乣width`銆乣height`銆乣zIndex`銆乣scale`銆乣locked`銆乣visible`銆乣opacity`銆乣clickThrough` 鍜� `displayLayer`銆�
+- `displayLayer` 蹇呴』鏀寔浠ヤ笅鏋氫妇鍊硷細
+ - `desktop`锛氬彧鏄剧ず鍦ㄦ闈紝涓嶇洊浣忔櫘閫氬簲鐢ㄧ獥鍙c��
+ - `normal`锛氭櫘閫氱獥鍙o紝閬靛惊绯荤粺榛樿绐楀彛灞傜骇銆�
+ - `app-top`锛氫粎鍦� Moli.Desktop 鏈簲鐢ㄧ獥鍙e拰缁勪欢鑼冨洿鍐呯疆椤讹紝涓嶈鐩栧叾浠栧簲鐢ㄧ殑缃《鍏崇郴銆�
+ - `global-top`锛氬叏灞�缃《锛屽厑璁歌鐩栧叾浠栧簲鐢ㄧ獥鍙c��
+- 澹佺焊绫诲唴瀹归粯璁や娇鐢� `desktop`锛涙櫘閫氫俊鎭被灏忕粍浠堕粯璁や娇鐢� `desktop` 鎴� `normal`锛涢渶瑕佽法搴旂敤鎻愰啋銆佹偓娴帶鍒舵垨婕旂ず鍦烘櫙鐨勭粍浠舵墠搴斾娇鐢� `app-top` 鎴� `global-top`銆�
+- 鐢ㄦ埛蹇呴』鑳藉鎸夌粍浠跺疄渚嬪垏鎹㈡樉绀哄眰绾э紝涓斿垏鎹㈢粨鏋滃繀椤绘寔涔呭寲銆�
+- `desktop` 灞傜粍浠跺繀椤诲湪鐢ㄦ埛瑙﹀彂 Win+D 鏄剧ず妗岄潰鍚庝粛淇濇寔鍙锛涚郴缁熶笉鏀寔 WorkerW 鎸傝浇鏃跺厑璁搁檷绾э紝浣嗗繀椤昏褰曡瘖鏂苟鍦� QA 璁板綍涓爣娉ㄨ鐜闄愬埗銆�
- 缁勪欢蹇呴』鏀寔鍦ㄧ紪杈戞ā寮忎笅鎷栨嫿鍜岀缉鏀俱��
- 宸查攣瀹氱粍浠跺繀椤绘嫆缁濇嫋鎷藉拰缂╂斁鎿嶄綔銆�
- 搴旂敤蹇呴』鏀寔鎸夌粍浠剁淮搴︾殑閰嶇疆銆�
@@ -133,7 +142,8 @@
"y": 100,
"locked": false,
"clickThrough": false,
- "opacity": 1.0
+ "opacity": 1.0,
+ "displayLayer": "desktop"
},
"config": {}
}
@@ -248,7 +258,8 @@
- 绠$悊绐楀彛搴旀敮鎸佸缁勪欢/鎻掍欢鍙抽敭鎿嶄綔锛屽寘鎷紪杈戠畝鍗曢厤缃�佹煡鐪嬫垨鎵撳紑瀵瑰簲 JSON 閰嶇疆鏂囦欢銆�
- 绠$悊绐楀彛搴旀敮鎸侀�夋嫨鏈湴澹佺焊鏂囦欢骞跺垏鎹㈠綋鍓嶅绾革紝鏂囦欢鏍煎紡鑷冲皯瑕嗙洊 `html`銆乣png`銆乣jpeg`銆乣gif` 鍜� `svg`銆�
- 绠$悊绐楀彛搴斿湪鍒锋柊鎸夐挳闄勮繎鎻愪緵鈥滄仮澶嶉粯璁も�濆叆鍙o紝骞跺湪鎵ц鍓嶈繘琛屼簩娆$‘璁ゃ��
-- 绠$悊绐楀彛搴旀敮鎸佽缃粍浠舵樉绀轰紭鍏堢骇锛氭闈笂灞傘�佸浘鏍囦笂灞傘�佸簲鐢ㄤ笂灞傘��
+- 绠$悊绐楀彛搴旀敮鎸佽缃粍浠舵樉绀哄眰绾э細`desktop`銆乣normal`銆乣app-top`銆乣global-top`銆�
+- 绠$悊绐楀彛鍦ㄧ敤鎴烽�夋嫨 `global-top` 鏃跺簲缁欏嚭鏄庣‘鎻愮ず锛岃鏄庤缁勪欢鍙兘瑕嗙洊鍏朵粬搴旂敤绐楀彛锛屽苟鎻愪緵蹇�熸仮澶嶄负 `desktop` 鎴� `normal` 鐨勫叆鍙c��
浼樺厛绾э細P1
@@ -336,6 +347,7 @@
- 杩愯鏃朵緷璧栵細Microsoft Edge WebView2 Runtime銆�
- 鏄剧ず琛屼负蹇呴』鑰冭檻 DPI 缂╂斁銆�
- 搴旂敤搴旀敮鎸佸鏄剧ず鍣ㄧ幆澧冦��
+- 涓嶅悓鏄剧ず灞傜骇蹇呴』鍦� DPI 缂╂斁銆佸鏄剧ず鍣ㄥ拰搴旂敤閲嶅惎鍚庝繚鎸佷竴鑷磋涔夛紱褰撶郴缁熸垨鏉冮檺闄愬埗瀵艰嚧鏌愬眰绾ф棤娉曞疄鐜版椂锛屽繀椤婚檷绾у埌鏇村畨鍏ㄧ殑灞傜骇骞惰褰曡瘖鏂��
### 瀹夊叏鎬�
@@ -364,7 +376,7 @@
| 浼樺厛绾� | 鑼冨洿 |
| --- | --- |
-| P0 | WPF 瀹夸富銆佹墭鐩樸�乄ebView2 澹佺焊銆佸皬缁勪欢杩愯鏃躲�佹嫋鎷�/缂╂斁/閿佸畾銆侀�忔槑/鐐瑰嚮绌块�忋�丣SON 鎸佷箙鍖栥�佽瘖鏂仮澶嶃�� |
+| P0 | WPF 瀹夸富銆佹墭鐩樸�乄ebView2 澹佺焊銆佸皬缁勪欢杩愯鏃躲�佹樉绀哄眰绾с�佹嫋鎷�/缂╂斁/閿佸畾銆侀�忔槑/鐐瑰嚮绌块�忋�丣SON 鎸佷箙鍖栥�佽瘖鏂仮澶嶃�� |
| P1 | 绠$悊绐楀彛銆佹彃浠剁敓鍛藉懆鏈熶簨浠躲�丠TTP/WebSocket API銆佸鏄剧ず鍣ㄦ敮鎸併�佹彃浠堕厤缃� UI銆佹湰鍦拌嚜鍔ㄥ寲 API銆� |
| P2 | 鍩轰簬 Postgres/Redis 鐨勫悓姝ユ垨杩滅▼鎺у埗銆佹彃浠跺競鍦恒�佹洿涓板瘜鐨勬潈闄愭ā鍨嬨�佸畨瑁呭寘/鏇存柊閫氶亾銆侀珮绾ф�ц兘鎺у埗銆� |
@@ -377,6 +389,7 @@
- 浠庢湰鍦扮洰褰曟垨杩滅▼ URL 鍔犺浇 1 涓� H5 澹佺焊銆�
- 浠庢湰鍦版彃浠剁洰褰曞姞杞藉涓皬缁勪欢瀹炰緥銆�
- 鎻掍欢 manifest 鏍¢獙銆�
+- 缁勪欢鏄剧ず灞傜骇鎺у埗锛歚desktop`銆乣normal`銆乣app-top`銆乣global-top`銆�
- 鎷栨嫿銆佺缉鏀俱�侀攣瀹氥�侀�忔槑搴﹀拰鐐瑰嚮绌块�忔帶鍒躲��
- 搴旂敤璁剧疆銆佹彃浠跺拰甯冨眬鐨� JSON 鎸佷箙鍖栥��
- HTTP API 涓� WebSocket 閫氶亾銆�
@@ -405,6 +418,12 @@
- 褰撶敤鎴风缉鏀剧粍浠跺悗閲嶆柊鍚姩搴旂敤鏃讹紝缁勪欢搴旀仮澶嶄繚瀛樺悗鐨勫昂瀵搞��
- 褰撶粍浠惰閿佸畾鏃讹紝鐢ㄦ埛灏濊瘯鎷栨嫿鎴栫缉鏀撅紝缁勪欢搴斾繚鎸佸浐瀹氥��
- 褰撶粍浠惰闅愯棌鏃讹紝閲嶆柊鍚姩搴旂敤鍚庯紝鍦ㄩ噸鏂板惎鐢ㄥ墠瀹冧粛搴斾繚鎸侀殣钘忋��
+- 褰撶粍浠惰缃负 `desktop` 鏃讹紝瀹冨簲鍙樉绀哄湪妗岄潰灞傦紝涓嶈鐩栨櫘閫氬簲鐢ㄧ獥鍙c��
+- 褰撶粍浠惰缃负 `desktop` 涓旂敤鎴锋寜涓� Win+D 鍚庯紝璇ョ粍浠跺簲浠嶆樉绀哄湪妗岄潰涓婏紝涓嶅簲鍍忔櫘閫氬簲鐢ㄧ獥鍙d竴鏍疯鏈�灏忓寲銆�
+- 褰撶粍浠惰缃负 `normal` 鏃讹紝瀹冨簲琛ㄧ幇涓烘櫘閫氱獥鍙o紝涓嶅己鍒剁疆椤躲��
+- 褰撶粍浠惰缃负 `app-top` 鏃讹紝瀹冨簲鍦� Moli.Desktop 鑷韩绠$悊绐楀彛鍜岀粍浠惰寖鍥村唴淇濇寔鏇撮珮灞傜骇锛屼絾涓嶆姠鍗犲叾浠栧簲鐢ㄧ殑鍏ㄥ眬缃《绐楀彛銆�
+- 褰撶粍浠惰缃负 `global-top` 鏃讹紝瀹冨簲淇濇寔鍏ㄥ眬缃《锛涚敤鎴峰繀椤昏兘閫氳繃鎵樼洏鎴栫鐞嗙獥鍙e揩閫熸挙閿�璇ョ姸鎬併��
+- 褰撳簲鐢ㄩ噸鍚悗锛岀粍浠舵樉绀哄眰绾у簲浠� JSON 甯冨眬鐘舵�佹仮澶嶃��
### 鎸佷箙鍖�
@@ -441,6 +460,7 @@
| --- | --- |
| 浜у搧鍚嶇О鍜屽寘鏍囪瘑 | `Moli.Desktop` |
| 澹佺焊灞備綅缃� | 浣嶄簬妗岄潰鍥炬爣涔嬪悗 |
+| 鏄剧ず灞傜骇鏋氫妇 | `desktop`銆乣normal`銆乣app-top`銆乣global-top` |
| MVP 鎻掍欢瀹夎鏂瑰紡 | 鍙厑璁镐粠鏈湴鐩綍瀹夎 |
| MVP 杩滅▼ URL | 鍏佽澹佺焊鍜屽皬缁勪欢浣跨敤杩滅▼ URL |
| MVP API 浼犺緭鏂瑰紡 | HTTP + WebSocket |
diff --git a/docs/product/llm-command-palette-plugin-prd.md b/docs/product/llm-command-palette-plugin-prd.md
new file mode 100644
index 0000000..f33af38
--- /dev/null
+++ b/docs/product/llm-command-palette-plugin-prd.md
@@ -0,0 +1,394 @@
+# PRD锛歀LM 妗岄潰杈撳叆鎻掍欢
+
+## 鏂囨。瀛樻斁
+
+鏈骇鍝侀渶姹傛枃妗e瓨鏀句簬锛�
+
+- `docs/product/llm-command-palette-plugin-prd.md`
+
+鍚庣画瀹炵幇灞傛枃妗e缓璁媶鍒嗗埌锛�
+
+- 鏋舵瀯涓庡涓昏兘鍔涳細`docs/architecture/`
+- 鎻掍欢 API 涓� LLM 娴佸紡鎺ュ彛锛歚docs/api/`
+- 鎻掍欢閰嶇疆涓庡瘑閽ュ瓨鍌ㄧ瓥鐣ワ細`docs/data/`
+- 鏍蜂緥鎻掍欢寮�鍙戜换鍔★細`docs/development/`
+- 妗岄潰浜や簰楠屾敹璁板綍锛歚docs/qa/`
+
+## 鑳屾櫙
+
+Moli.Desktop 宸插叿澶� WebView2 灏忕粍浠舵壙杞姐�侀�忔槑绐楀彛銆佹樉绀哄眰绾с�佸竷灞�鎸佷箙鍖栧拰鏈湴 API 鑳藉姏銆侺LM 妗岄潰杈撳叆鎻掍欢甯屾湜鎶婂父鐢ㄧ殑 AI 闂瓟鍏ュ彛鏀惧埌妗岄潰椤堕儴锛岀敤鎴锋棤闇�鎵撳紑娴忚鍣ㄦ垨瀹屾暣鑱婂ぉ绐楀彛锛屽氨鍙互鐩存帴杈撳叆闂銆侀�夋嫨妯″瀷锛屽苟浠ヨ交閲忔诞灞傛柟寮忔煡鐪嬫祦寮忓洖澶嶃��
+
+鎻掍欢瑙嗚鍙傝�冭緭鍏ユ鎴浘锛氭繁鑹插崐閫忔槑鍦嗚杈撳叆鏉°�佽交寰(鐮傝川鎰熴�佸乏渚х姸鎬佸浘鏍囥�佸眳涓《閮ㄥ竷灞�銆備氦浜掍笂搴斿儚妗岄潰鍛戒护闈㈡澘涓�鏍风洿鎺ャ�佸畨闈欍�佷綆鎵撴壈銆�
+
+## 鐩爣
+
+- 鎻愪緵涓�涓《閮ㄥ眳涓殑 LLM 杈撳叆鎻掍欢锛岄粯璁ゅ湪灞忓箷椤堕儴淇濈暀鍛煎惛绌洪殭銆�
+- 鏀寔鐢ㄦ埛杈撳叆鏂囨湰鍚庢寜鍥炶溅鎻愪氦锛屼笉鎻愪緵鐙珛鎻愪氦鎸夐挳銆�
+- 鏀寔鍦ㄨ緭鍏ユ鍙充晶宓屽叆妯″瀷涓嬫媺閫夋嫨銆�
+- 鏀寔澶氫釜 LLM 妯″瀷锛屾ā鍨嬫竻鍗曟潵鑷彃浠堕厤缃垨瀹夸富閰嶇疆銆�
+- 鏀寔璋冪敤 LLM 鎺ュ彛骞跺皢缁撴灉娴佸紡灞曠ず鍦ㄨ緭鍏ユ涓嬫柟銆�
+- 杈撳嚭鍖哄煙涓庤緭鍏ユ淇濇寔鍚屽銆佸悓瑙嗚椋庢牸锛屾渶澶ч珮搴︿笉瓒呰繃灞忓箷楂樺害鐨� `50%`銆�
+- 淇濇寔妗岄潰娴眰杞婚噺銆侀�忔槑銆佸彲璇汇�佸彲鎭㈠鎺у埗銆�
+
+## 闈炵洰鏍�
+
+- 涓嶅仛瀹屾暣澶氫細璇濊亰澶╁簲鐢ㄣ��
+- 涓嶅湪鎻掍欢鍐呭疄鐜拌处鍙蜂綋绯汇�佽璐圭鐞嗘垨澶嶆潅鐭ヨ瘑搴撱��
+- 涓嶅湪 MVP 涓敮鎸佹枃浠朵笂浼犮�佸浘鐗囩悊瑙c�佽闊宠緭鍏ユ垨澶氭ā鎬佽緭鍑恒��
+- 涓嶈姹傛浛浠g鐞嗙獥鍙f垨绯荤粺鎵樼洏鍏ュ彛銆�
+- 涓嶆妸 LLM API key 鏄庢枃鍐欏叆鎻掍欢鍓嶇婧愮爜銆�
+
+## 鐢ㄦ埛
+
+| 鐢ㄦ埛绫诲瀷 | 闇�姹� |
+| --- | --- |
+| 鏃ュ父鏁堢巼鐢ㄦ埛 | 甯屾湜鍦ㄦ闈笂蹇�熸彁闂�佹敼鍐欍�佺炕璇戞垨鎬荤粨锛屼笉鍒囨崲鍒版祻瑙堝櫒銆� |
+| 寮�鍙�/杩愮淮鐢ㄦ埛 | 甯屾湜蹇�熷悜涓嶅悓妯″瀷鎻愰棶锛屽苟鐪嬪埌娴佸紡缁撴灉鐢ㄤ簬涓存椂鍙傝�冦�� |
+| 鎻掍欢寮�鍙戣�� | 甯屾湜鏈変竴涓彲澶嶇敤鐨� LLM 鎻掍欢鏍蜂緥锛岃鐩栭厤缃�佹祦寮忚皟鐢ㄥ拰閫忔槑妗岄潰浣撻獙銆� |
+
+## 鐢ㄦ埛鏁呬簨
+
+- 浣滀负鐢ㄦ埛锛屾垜鍙互鍦ㄦ闈㈤《閮ㄧ洿鎺ヨ緭鍏ラ棶棰樺苟鎸夊洖杞︽彁浜わ紝杩欐牱鎴戣兘蹇�熷緱鍒� LLM 鍥炲銆�
+- 浣滀负鐢ㄦ埛锛屾垜鍙互鍦ㄨ緭鍏ユ鍙充晶鍒囨崲妯″瀷锛岃繖鏍锋垜鑳芥寜浠诲姟閫夋嫨鏇村揩鎴栨洿寮虹殑妯″瀷銆�
+- 浣滀负鐢ㄦ埛锛屾垜鍙互鍦ㄥ洖澶嶇敓鎴愭椂鐪嬪埌閫愭娴佸紡杈撳嚭锛岃繖鏍锋垜鐭ラ亾璇锋眰姝e湪杩涜銆�
+- 浣滀负鐢ㄦ埛锛屾垜鍙互缁х画缂栬緫杈撳叆鍐呭銆佸鍒惰緭鍑哄唴瀹规垨鎸� Escape 鏀惰捣缁撴灉锛岃繖鏍锋闈笉浼氳闀挎枃鏈暱鏈熷崰鎹��
+- 浣滀负鐢ㄦ埛锛屾垜鍙互閫氳繃绠$悊绐楀彛鎴栭厤缃垏鎹� API endpoint銆佹ā鍨嬪垪琛ㄥ拰榛樿妯″瀷锛岃繖鏍锋彃浠惰兘閫傞厤涓嶅悓 LLM 鏈嶅姟銆�
+
+## 鎻掍欢绫诲瀷
+
+- `type`: `widget`
+- 寤鸿鎻掍欢 id锛歚sample.llm-command-palette`
+- 榛樿鏄剧ず灞傜骇锛歚desktop`
+- 鎺ㄨ崘鍙�夋樉绀哄眰绾э細`app-top` 鎴� `global-top`
+- 榛樿鐐瑰嚮绌块�忥細`false`
+- 榛樿閿佸畾锛歚true`
+
+璇存槑锛�
+
+- 榛樿浣跨敤 `desktop`锛岄伩鍏嶈鐩栫敤鎴锋鍦ㄤ娇鐢ㄧ殑鏅�氬簲鐢ㄧ獥鍙c��
+- 濡傛灉鐢ㄦ埛甯屾湜瀹冨儚鍏ㄥ眬蹇嵎杈撳叆鏉′竴鏍疯鐩栧叾浠栫獥鍙o紝鍙湪绠$悊绐楀彛涓垏鎹㈠埌 `app-top` 鎴� `global-top`銆�
+- 鎻掍欢闇�瑕佹帴鏀堕敭鐩樿緭鍏ワ紝鍥犳杩愯鎬侀粯璁や笉鑳界偣鍑荤┛閫忋��
+
+## 榛樿甯冨眬
+
+鎻掍欢榛樿浣嶄簬涓绘樉绀哄櫒椤堕儴灞呬腑锛岄《閮ㄧ暀鍑鸿瑙夊懠鍚哥┖闅欍��
+
+寤鸿甯冨眬瑙勫垯锛�
+
+| 瀛楁 | 榛樿鍊� |
+| --- | --- |
+| `width` | `min(760, screenWidth * 0.72)` |
+| `height` | `72` |
+| `x` | `(screenWidth - width) / 2` |
+| `y` | `32` |
+| `locked` | `true` |
+| `clickThrough` | `false` |
+| `opacity` | `0.96` |
+| `displayLayer` | `desktop` |
+
+灞曞紑杈撳嚭鍚庯紝缁勪欢绐楀彛楂樺害鐢卞唴瀹归┍鍔紝浣嗗繀椤绘弧瓒筹細
+
+- 杈撳叆鏉¢珮搴︿繚鎸佺ǔ瀹氾紝涓嶅洜妯″瀷鍚嶇О鎴栫姸鎬佹枃鏈彉鍖栬�岃烦鍔ㄣ��
+- 杈撳嚭鍖哄煙瀹藉害涓庤緭鍏ユ潯涓�鑷淬��
+- 杈撳嚭鍖哄煙鏈�澶ч珮搴︿负 `screenHeight * 0.5`銆�
+- 杈撳嚭鍐呭瓒呰繃鏈�澶ч珮搴︽椂锛屼粎杈撳嚭鍖哄煙鍐呴儴婊氬姩銆�
+- 灞曞紑鍜屾敹璧蜂笉鏀瑰彉 `x` 涓� `width`銆�
+
+## 浜や簰璁捐
+
+### 杈撳叆鏉�
+
+- 杈撳叆鏉′负鍗曡浼樺厛锛岄暱鏂囨湰鍙湪杈惧埌瀹藉害鍚庤交寰楂樺埌鏈�澶� 3 琛屻��
+- 鍗犱綅鏂囨锛歚What can I help you with today?` 鎴栧悗缁湰鍦板寲涓轰腑鏂囥��
+- 宸︿晶灞曠ず鐘舵�佸浘鏍囷細
+ - 绌洪棽锛氬搧鐗屾垨鏄熻姃鍥炬爣銆�
+ - 璇锋眰涓細缁嗗皬鏃嬭浆鐘舵�併��
+ - 閿欒锛氫綆楗卞拰璀︾ず鐘舵�併��
+- 鍙充晶宓屽叆妯″瀷涓嬫媺锛屼笉鍗曠嫭鍗犵敤绗簩琛屻��
+- 妯″瀷涓嬫媺搴旀樉绀虹煭鍚嶇О锛屼緥濡� `GPT-5.4`銆乣DeepSeek`銆乣Local`锛屽畬鏁村悕绉板湪 tooltip 鎴栬彍鍗曚腑灞曠ず銆�
+- 杈撳叆妗嗕笉鎻愪緵鎻愪氦鎸夐挳锛屾寜 Enter 鎻愪氦銆�
+- Shift+Enter 鎻掑叆鎹㈣銆�
+- Escape 鍦ㄦ湁杈撳嚭鏃舵敹璧疯緭鍑猴紱鏃犺緭鍑烘椂娓呯┖褰撳墠杈撳叆鐒︾偣銆�
+
+### 鎻愪氦娴佺▼
+
+1. 鐢ㄦ埛杈撳叆鍐呭銆�
+2. 鐢ㄦ埛鎸� Enter銆�
+3. 鎻掍欢鍐荤粨鏈 prompt 蹇収骞跺紑濮嬭姹傘��
+4. 杈撳叆鏉″乏渚ц繘鍏ヨ姹備腑鐘舵�併��
+5. 杈撳嚭鍖哄煙浠庤緭鍏ユ搴曢儴灞曞紑銆�
+6. LLM token 鎸夋祦寮忓閲忚拷鍔犲埌杈撳嚭鍖恒��
+7. 瀹屾垚鍚庣姸鎬佸洖鍒扮┖闂诧紝骞朵繚鐣欑粨鏋溿��
+
+濡傛灉鐢ㄦ埛鍦ㄨ姹備腑鍐嶆鎸� Enter锛�
+
+- MVP 榛樿蹇界暐閲嶅鎻愪氦锛屽苟鍦ㄨ緭鍏ユ潯涓繚鎸佽姹備腑鐘舵�併��
+- 鍚庣画鐗堟湰鍙敮鎸佲�滃仠姝㈢敓鎴愨�濇垨鎺掗槦璇锋眰銆�
+
+### 杈撳嚭鍖哄煙
+
+- 杈撳嚭鍖哄煙绱ц创杈撳叆鏉″簳閮ㄥ睍寮�锛岃瑙変笂涓庤緭鍏ユ潯鍚屼竴濂楀崐閫忔槑纾ㄧ爞鏍峰紡銆�
+- 鍐呭浣跨敤鍙瀛楀彿锛屼笉浣跨敤杩囧ぇ鐨勮惀閿�寮忔爣棰樸��
+- 娴佸紡杈撳嚭鏃堕伩鍏嶆暣娈甸噸鎺掞紝鍏夋爣鎴栫姸鎬佺偣鍙嚭鐜板湪鏈熬銆�
+- 鏀寔鐢ㄦ埛閫変腑鏂囨湰鍜屽鍒躲��
+- 杈撳嚭瀹屾垚鍚庡彲鏄剧ず杞婚噺鎿嶄綔鍖猴細
+ - 澶嶅埗銆�
+ - 鏀惰捣銆�
+ - 閲嶆柊鐢熸垚銆�
+- 鎿嶄綔鍖轰娇鐢ㄥ浘鏍囨寜閽拰 tooltip锛屼笉浣跨敤澶у潡璇存槑鏂囧瓧銆�
+
+### 閿欒鐘舵��
+
+- API key 缂哄け銆乪ndpoint 涓嶅彲杈俱�佹ā鍨嬩笉鍙敤銆佽姹傝秴鏃跺拰娴佸紡瑙f瀽澶辫触蹇呴』灞曠ず鐭敊璇��
+- 閿欒淇℃伅鏄剧ず鍦ㄨ緭鍑哄尯鍩熷唴锛屼笉寮瑰嚭绯荤粺妯℃�佹銆�
+- 閿欒鏂囨湰搴斿寘鍚彲鎿嶄綔鏂瑰悜锛屼緥濡傗�滆鍦ㄦ彃浠堕厤缃腑妫�鏌� endpoint 鍜屽瘑閽モ�濄��
+
+## 瑙嗚璁捐
+
+### 澶栬
+
+- 杈撳叆鏉¤儗鏅細娣辫壊鍗婇�忔槑锛屼緥濡� `rgba(28, 26, 25, 0.72)`銆�
+- 浣跨敤 `backdrop-filter: blur(18px)`锛屽湪 WebView2 鏀寔涓嶈冻鏃堕檷绾т负鍗婇�忔槑绾壊銆�
+- 杈规涓轰綆瀵规瘮缁嗙嚎锛岄伩鍏嶄寒杈硅繃閲嶃��
+- 鍦嗚寤鸿 `18px` 鍒� `22px`锛屾帴杩戝弬鑰冨浘鐨勮兌鍥婂舰鎬併��
+- 闃村奖杞伙紝閬垮厤鍍忔櫘閫氱獥鍙e崱鐗囥��
+- 鏂囧瓧棰滆壊闇�瑕佹弧瓒虫殫鑹茶儗鏅彲璇绘�с��
+- 鍗犱綅鏂囧瓧浣跨敤浣庡姣旂伆鑹层��
+- 妯″瀷閫夋嫨鍖哄煙涓庤緭鍏ユ铻嶅悎锛屼笉鍋氱嫭绔嬬獊鍏�鎸夐挳銆�
+
+### 灏哄
+
+- 杈撳叆鏉¢珮搴﹀缓璁� `56px`銆�
+- 澶栧眰缁勪欢榛樿楂樺害 `72px`锛屽寘鍚槾褰卞拰瀹夊叏闂磋窛銆�
+- 妯悜 padding 寤鸿 `20px`銆�
+- 宸︿晶鍥炬爣灏哄 `18px` 鍒� `22px`銆�
+- 妯″瀷閫夋嫨鎺т欢鏈�灏忓搴� `112px`锛屾渶闀挎ā鍨嬪悕搴旂渷鐣ユ樉绀猴紝涓嶆拺寮�甯冨眬銆�
+
+### 鍔ㄦ晥
+
+- 杈撳嚭鍖哄煙灞曞紑鍜屾敹璧蜂娇鐢� `140ms` 鍒� `180ms` 鐨勮交閲忚繃娓°��
+- 娴佸紡杈撳嚭鍙拷鍔犲唴瀹癸紝涓嶅仛閫愬瓧澶稿紶鍔ㄧ敾銆�
+- 鐘舵�佸浘鏍囪姹備腑鍔ㄧ敾搴斾綆璋冿紝閬垮厤鎸佺画鍚稿紩娉ㄦ剰鍔涖��
+
+## 妯″瀷閰嶇疆
+
+鎻掍欢閰嶇疆搴旀敮鎸侊細
+
+```json
+{
+ "provider": "openai-compatible",
+ "endpoint": "https://api.example.com/v1/chat/completions",
+ "defaultModel": "gpt-5.4",
+ "models": [
+ {
+ "id": "gpt-5.4",
+ "label": "GPT-5.4",
+ "supportsStreaming": true
+ },
+ {
+ "id": "deepseek-chat",
+ "label": "DeepSeek",
+ "supportsStreaming": true
+ }
+ ],
+ "request": {
+ "temperature": 0.7,
+ "maxTokens": 2048,
+ "timeoutMs": 60000
+ }
+}
+```
+
+API key 涓嶅簲瀛樻斁鍦ㄥ墠绔� `index.html` 鎴栧叕寮�閰嶇疆涓�侻VP 寤鸿鐢卞涓绘彁渚涙湰鍦� LLM 浠g悊鑳藉姏锛屾彃浠跺彧鍚戝涓昏姹傛祦寮忕敓鎴愶紱濡傛灉鐭湡鐩存帴浠庢彃浠惰皟鐢ㄨ繙绋� OpenAI-compatible endpoint锛屽垯蹇呴』鍦ㄦ枃妗e拰绠$悊鐣岄潰涓槑纭彁绀哄瘑閽ユ毚闇查闄╋紝骞朵粎鐢ㄤ簬鏈湴涓汉娴嬭瘯銆�
+
+## 瀹夸富涓庢彃浠堕�氫俊
+
+寤鸿鏂板鎴栨墿灞曟彃浠� API锛�
+
+```javascript
+window.moliDesktop.llm.streamChat({
+ model: "gpt-5.4",
+ messages: [
+ { role: "user", content: "..." }
+ ],
+ options: {
+ temperature: 0.7,
+ maxTokens: 2048
+ }
+});
+```
+
+娴佸紡浜嬩欢寤鸿锛�
+
+```json
+{
+ "type": "llm.delta",
+ "requestId": "req_20260504_001",
+ "delta": "text"
+}
+```
+
+缁撴潫浜嬩欢锛�
+
+```json
+{
+ "type": "llm.completed",
+ "requestId": "req_20260504_001",
+ "usage": {
+ "inputTokens": 128,
+ "outputTokens": 512
+ }
+}
+```
+
+閿欒浜嬩欢锛�
+
+```json
+{
+ "type": "llm.error",
+ "requestId": "req_20260504_001",
+ "code": "ModelUnavailable",
+ "message": "Selected model is unavailable."
+}
+```
+
+## Manifest 绀轰緥
+
+```json
+{
+ "id": "sample.llm-command-palette",
+ "name": "LLM Command Palette",
+ "version": "1.0.0",
+ "type": "widget",
+ "entry": "index.html",
+ "description": "A translucent desktop prompt bar for streaming LLM responses.",
+ "author": "Moli.Desktop",
+ "permissions": [
+ "llm.stream",
+ "config.read"
+ ],
+ "defaultLayout": {
+ "width": 760,
+ "height": 72,
+ "x": 580,
+ "y": 32,
+ "locked": true,
+ "clickThrough": false,
+ "opacity": 0.96,
+ "displayLayer": "desktop"
+ },
+ "config": {
+ "provider": "openai-compatible",
+ "defaultModel": "gpt-5.4",
+ "models": []
+ }
+}
+```
+
+`x` 搴旂敱瀹夎鏃舵寜涓绘樉绀哄櫒瀹藉害閲嶇畻锛宮anifest 涓殑鍥哄畾鍊煎彧浣滀负 fallback銆�
+
+## 鍔熻兘闇�姹�
+
+### FR-LLM-01 椤堕儴杈撳叆缁勪欢
+
+- 鎻掍欢蹇呴』浠ユ闈㈠皬缁勪欢褰㈠紡鍔犺浇銆�
+- 鎻掍欢榛樿鏄剧ず鍦ㄤ富灞忛《閮ㄥ眳涓紝椤堕儴淇濈暀绾� `32px` 绌洪殭銆�
+- 鎻掍欢杈撳叆鏉″繀椤绘敮鎸佸崐閫忔槑鑳屾櫙鍜屽渾瑙掕瑙夈��
+- 鎻掍欢蹇呴』鑳藉湪 WebView2 閫忔槑鑳屾櫙涓嬩笌妗岄潰瑙嗚铻嶅悎銆�
+
+浼樺厛绾э細P1
+
+### FR-LLM-02 妯″瀷閫夋嫨
+
+- 鎻掍欢蹇呴』鍦ㄨ緭鍏ユ鍙充晶鎻愪緵妯″瀷涓嬫媺銆�
+- 妯″瀷涓嬫媺蹇呴』浠庨厤缃鍙栨ā鍨嬫竻鍗曘��
+- 妯″瀷鍒囨崲蹇呴』褰卞搷涓嬩竴娆℃彁浜ゃ��
+- 褰撳墠璇锋眰杩涜涓椂锛屾ā鍨嬪垏鎹笉寰楀奖鍝嶅凡鍙戝嚭鐨勮姹傘��
+
+浼樺厛绾э細P1
+
+### FR-LLM-03 鍥炶溅鎻愪氦
+
+- 鎻掍欢蹇呴』鏀寔 Enter 鎻愪氦銆�
+- 鎻掍欢涓嶆彁渚涚嫭绔嬫彁浜ゆ寜閽��
+- Shift+Enter 搴旇緭鍏ユ崲琛屻��
+- 绌鸿緭鍏ユ寜 Enter 涓嶅彂璧疯姹傘��
+
+浼樺厛绾э細P1
+
+### FR-LLM-04 娴佸紡杈撳嚭
+
+- 鎻愪氦鍚庯紝鎻掍欢蹇呴』鍦ㄨ緭鍏ユ搴曢儴灞曞紑杈撳嚭鍖哄煙銆�
+- 杈撳嚭鍖哄煙蹇呴』涓庤緭鍏ユ鍚屽銆�
+- 杈撳嚭鍖哄煙鏈�澶ч珮搴︿笉寰楄秴杩囧睆骞曢珮搴� `50%`銆�
+- LLM 鍥炲蹇呴』浠ユ祦寮忓閲忔柟寮忓睍绀恒��
+- 杈撳嚭瀹屾垚鍚庡繀椤讳繚鐣欑粨鏋滐紝鐩村埌鐢ㄦ埛鏀惰捣銆侀噸鏂版彁浜ゆ垨娓呯┖銆�
+
+浼樺厛绾э細P1
+
+### FR-LLM-05 閰嶇疆涓庡瘑閽�
+
+- 鎻掍欢蹇呴』鏀寔閰嶇疆 endpoint銆佹ā鍨嬪垪琛ㄣ�侀粯璁ゆā鍨嬪拰璇锋眰鍙傛暟銆�
+- API key 涓嶅緱鍐欐鍦ㄦ彃浠跺墠绔祫婧愪腑銆�
+- 濡傛灉瀹夸富鏆傛湭鎻愪緵瀵嗛挜瀹夊叏瀛樺偍锛孧VP 蹇呴』灏嗚鑳藉姏鏍囪涓哄彈闄愶紝骞舵彁渚涙竻鏅伴闄╂彁绀恒��
+
+浼樺厛绾э細P1
+
+### FR-LLM-06 閿欒涓庢仮澶�
+
+- 璇锋眰澶辫触鏃讹紝鎻掍欢蹇呴』鍦ㄨ緭鍑哄尯鍩熷睍绀虹煭閿欒銆�
+- 鐢ㄦ埛蹇呴』鍙互淇敼杈撳叆鍚庨噸鏂版彁浜ゃ��
+- 璇锋眰瓒呮椂銆佺綉缁滃け璐ャ�佹ā鍨嬩笉鍙敤鍜岄壌鏉冨け璐ュ繀椤绘湁涓嶅悓閿欒鐮佹垨鍙尯鍒嗘枃妗堛��
+
+浼樺厛绾э細P1
+
+## 闈炲姛鑳介渶姹�
+
+### 鎬ц兘
+
+- 鎻掍欢绌洪棽鏃朵笉搴旀寔缁秷鑰楁槑鏄� CPU銆�
+- 娴佸紡杈撳嚭鏃跺簲鑺傛祦 DOM 鏇存柊锛岄伩鍏嶆瘡涓� token 閮借Е鍙戞槀璐甸噸鎺掋��
+- 杈撳嚭鍐呭杈冮暱鏃讹紝鍙粴鍔ㄨ緭鍑哄尯鍩燂紝涓嶆敼鍙樻闈㈢獥鍙d綅缃��
+
+### 鍙敤鎬�
+
+- 杈撳叆鏉°�佹ā鍨嬩笅鎷夊拰杈撳嚭鏂囨湰鍦ㄦ繁鑹插崐閫忔槑鑳屾櫙涓婂繀椤绘竻鏅板彲璇汇��
+- 闀挎ā鍨嬪悕涓嶅緱鎾戝紑杈撳叆鏉°��
+- 杈撳嚭鍖哄煙涓嶅緱閬尅杈撳叆鏉°��
+- 杈撳叆銆佷笅鎷夈�佸鍒跺拰鏀惰捣鎿嶄綔搴旀敮鎸侀敭鐩樺彲杈俱��
+
+### 鍏煎鎬�
+
+- 鍦� WebView2 涓嶆敮鎸� `backdrop-filter` 鏃跺繀椤绘湁鍙闄嶇骇鏍峰紡銆�
+- 澶氭樉绀哄櫒鍦烘櫙涓嬶紝榛樿缁戝畾涓绘樉绀哄櫒锛涘悗缁彲閫氳繃甯冨眬绠$悊閫夋嫨鐩爣鏄剧ず鍣ㄣ��
+- DPI 缂╂斁鍙樺寲鍚庯紝鎻掍欢浠嶅簲灞呬腑骞朵繚鎸佽緭鍏ユ潯灏哄绋冲畾銆�
+
+### 瀹夊叏
+
+- 棣栫増鎻掍欢鏃犳矙绠遍殧绂伙紝浣� LLM 璇锋眰鑳藉姏蹇呴』閫氳繃鏄庣‘鏉冮檺澹版槑銆�
+- 瀹夸富浠g悊 LLM 璇锋眰鏃讹紝搴旈檺鍒舵彃浠跺彧鑳戒娇鐢ㄨ鍏佽鐨� endpoint 鍜屾ā鍨嬨��
+- 鏃ュ織涓嶅緱璁板綍瀹屾暣 API key銆�
+- 榛樿涓嶆妸鐢ㄦ埛杈撳叆鍐呭鍐欏叆鎸佷箙鍖栭厤缃��
+
+## 楠屾敹鏍囧噯
+
+- 褰撴彃浠堕娆″畨瑁呭苟鍚敤鏃讹紝杈撳叆鏉″嚭鐜板湪涓诲睆椤堕儴灞呬腑锛岄《閮ㄧ暀鏈夌害 `32px` 绌洪殭銆�
+- 褰撶敤鎴疯緭鍏ユ枃鏈苟鎸� Enter 鏃讹紝鎻掍欢鍙戣捣涓�娆� LLM 璇锋眰锛屼笖娌℃湁鎻愪氦鎸夐挳銆�
+- 褰撶敤鎴烽�夋嫨涓嶅悓妯″瀷鍚庡啀鎻愪氦鏃讹紝璇锋眰浣跨敤鏂版ā鍨嬨��
+- 褰� LLM 杩斿洖鍐呭鏃讹紝杈撳嚭鍖哄煙鍦ㄨ緭鍏ユ搴曢儴灞曞紑锛屽苟閫愭鏄剧ず娴佸紡鏂囨湰銆�
+- 褰撹緭鍑哄唴瀹硅秴杩囧睆骞曢珮搴� `50%` 鏃讹紝杈撳嚭鍖哄煙鍐呴儴婊氬姩锛屾彃浠朵笉浼氱户缁悜涓嬫棤闄愭墿寮犮��
+- 褰撶敤鎴锋寜 Escape 鏃讹紝宸插睍寮�杈撳嚭鍖哄煙鍙互鏀惰捣銆�
+- 褰� endpoint 涓嶅彲鐢ㄦ垨閴存潈澶辫触鏃讹紝杈撳嚭鍖哄煙灞曠ず鍙悊瑙i敊璇紝涓嶅鑷村涓诲穿婧冦��
+- 褰撳簲鐢ㄩ噸鍚悗锛屾彃浠朵綅缃�佸昂瀵搞�侀粯璁ゆā鍨嬪拰鏄剧ず灞傜骇浠庨厤缃仮澶嶃��
+- 褰撴彃浠跺浜庨粯璁� `desktop` 灞傛椂锛屽畠涓嶅簲瑕嗙洊鏅�氬簲鐢ㄧ獥鍙o紱鍒囨崲鍒� `global-top` 鏃跺繀椤诲彲閫氳繃鎵樼洏鎴栫鐞嗙獥鍙f仮澶嶃��
+
+## 寰呮緞娓呴棶棰�
+
+| 闂 | 寤鸿榛樿鍊� |
+| --- | --- |
+| MVP 鏄惁鐢卞涓讳唬鐞� LLM 璇锋眰 | 鏄紝閬垮厤 API key 鏆撮湶缁欐彃浠跺墠绔� |
+| 榛樿妯″瀷鍒楄〃鏉ユ簮 | 鎻掍欢閰嶇疆锛屽悗缁彲鐢辩鐞嗙獥鍙g紪杈� |
+| 鏄惁淇濈暀鍘嗗彶璁板綍 | MVP 涓嶄繚鐣欙紝浠呬繚鐣欏綋鍓嶇粨鏋� |
+| 鏄惁鏀寔鍋滄鐢熸垚 | MVP 鍙殏涓嶆敮鎸侊紝鍚庣画鏂板鍋滄鎸夐挳鎴� Escape 浜屾琛屼负 |
+| 鏄惁鍏ㄥ眬蹇嵎閿敜璧� | 鍚庣画鐗堟湰鑰冭檻锛屼緥濡� `Alt+Space` 鎴栫敤鎴疯嚜瀹氫箟蹇嵎閿� |
+
diff --git a/docs/qa/display-layer-acceptance-2026-05-03.md b/docs/qa/display-layer-acceptance-2026-05-03.md
new file mode 100644
index 0000000..2356513
--- /dev/null
+++ b/docs/qa/display-layer-acceptance-2026-05-03.md
@@ -0,0 +1,37 @@
+# Moli.Desktop 鏄剧ず灞傜骇鎺у埗楠屾敹璁板綍
+
+鏃ユ湡锛�2026-05-03
+
+## 楠屾敹鑼冨洿
+
+- 缁勪欢甯冨眬妯″瀷鏀寔 `displayLayer`銆�
+- 鏀寔鏋氫妇鍊硷細`desktop`銆乣normal`銆乣app-top`銆乣global-top`銆�
+- 鎻掍欢 manifest銆乣layout.json`銆佹湰鍦� API 鍝嶅簲鍜岀鐞嗙獥鍙d娇鐢ㄥ悓涓�瀛楁銆�
+- 绠$悊绐楀彛閫夋嫨 `global-top` 鍓嶅繀椤绘彁绀洪闄┿��
+- 鏍蜂緥鎻掍欢浣跨敤鏂扮殑 `displayLayer` 瀛楁锛屼笉鍐嶄娇鐢ㄦ棫 `displayPriority`銆�
+
+## 鑷姩鍖栫粨鏋�
+
+```powershell
+dotnet build .\Moli.Desktop.slnx
+dotnet test .\Moli.Desktop.slnx
+```
+
+缁撴灉锛�
+
+- 鏋勫缓閫氳繃锛�0 warning锛�0 error銆�
+- 娴嬭瘯閫氳繃锛�27 passed锛�0 failed銆�
+
+## 瑕嗙洊鐢ㄤ緥
+
+- `JsonConfigurationServiceTests.SaveAndLoadLayoutAsync_UsesDisplayLayerJsonNames`锛氶獙璇� `layout.json` 鍐欏叆鍜岃鍙� `displayLayer: app-top`銆�
+- `PluginManagerTests.ScanAsync_RecognizesValidPluginAndPersistsEnabledState`锛氶獙璇佹彃浠� manifest 鍙В鏋� `displayLayer: normal`銆�
+- `LayoutManagerTests.Update_ConstrainsSizeScaleOpacityAndVisibleArea`锛氶獙璇佽繍琛屾椂 patch 鍙洿鏂� `DisplayLayer.AppTop`銆�
+
+## 鎵嬪伐澶嶉獙椤�
+
+- 鍦ㄧ湡瀹� Windows 11 妗岄潰鐜鍒嗗埆鍒囨崲 `desktop`銆乣normal`銆乣app-top`銆乣global-top`锛岃瀵熺獥鍙i伄鎸¤涓恒��
+- 楠岃瘉 `desktop` 涓嶈鐩栨櫘閫氬簲鐢ㄧ獥鍙c��
+- 楠岃瘉 `desktop` 缁勪欢鍦ㄦ寜涓� Win+D 鍚庝粛鏄剧ず鍦ㄦ闈笂锛涜嫢 WorkerW 鎸傝浇澶辫触锛屽簲鍦ㄨ瘖鏂棩蹇椾腑鐪嬪埌闄嶇骇鍘熷洜銆�
+- 楠岃瘉 `global-top` 鍙鐩栧叾浠栧簲鐢ㄧ獥鍙o紝骞跺彲閫氳繃绠$悊绐楀彛鎴栨墭鐩樻仮澶嶄负瀹夊叏灞傜骇銆�
+- 楠岃瘉澶氭樉绀哄櫒鍜� DPI 缂╂斁涓嬪眰绾ц涔変繚鎸佷竴鑷淬��
diff --git a/docs/qa/mvp-integration-handoff.md b/docs/qa/mvp-integration-handoff.md
index 2e2acc3..47ccfb6 100644
--- a/docs/qa/mvp-integration-handoff.md
+++ b/docs/qa/mvp-integration-handoff.md
@@ -30,7 +30,7 @@
- 鎻掍欢鍒楄〃鍙抽敭鍙墦寮�鎻掍欢 `plugin.json` 鎴栧叏灞� `plugins.json`銆�
- 澹佺焊 tab 鍙�夋嫨 `html/png/jpeg/gif/svg` 鏂囦欢骞跺垏鎹负鐢ㄦ埛澹佺焊銆�
- 榛樿鎻掍欢鍖呭惈 `sample.audio-visualizer`锛岃瑙変负閫忔槑鑳屾櫙銆佸叏灞忓搴︾粏瀵嗛湏铏圭珫绾匡紝榛樿楂樺害涓嶈秴杩囧睆骞曢珮搴� `25%`锛岄粯璁や綅缃帴杩� `screenHeight * 2 / 3`銆�
-- 缁勪欢鏄剧ず浼樺厛绾у彲鍦ㄧ鐞嗙獥鍙e垏鎹负妗岄潰涓婂眰銆佸浘鏍囦笂灞傘�佸簲鐢ㄤ笂灞傘��
+- 缁勪欢鏄剧ず灞傜骇鍙湪绠$悊绐楀彛鍒囨崲涓� `desktop`銆乣normal`銆乣app-top`銆乣global-top`锛涢�夋嫨 `global-top` 鍓嶅繀椤诲嚭鐜扮‘璁ゆ彁绀恒��
- `GET /api/status` 杩斿洖杩愯鏃剁姸鎬佸拰 API 鐩戝惉鐘舵�併��
- `POST /api/edit-mode` 鍙�氳繃 JSON body 鎴栨棤 body 鍒囨崲缂栬緫妯″紡銆�
- `GET /ws/events` 鍙帴鏀� `widget.layoutChanged`銆乣app.statusChanged` 绛夎繍琛屾椂浜嬩欢銆�
diff --git a/samples/plugins/sample.audio-visualizer/plugin.json b/samples/plugins/sample.audio-visualizer/plugin.json
index d9a3484..2dd27c6 100644
--- a/samples/plugins/sample.audio-visualizer/plugin.json
+++ b/samples/plugins/sample.audio-visualizer/plugin.json
@@ -18,7 +18,7 @@
"clickThrough": true,
"opacity": 0.92,
"scale": 1,
- "displayPriority": "iconLayer"
+ "displayLayer": "desktop"
},
"config": {
"barCount": 256,
diff --git a/samples/plugins/sample.clock/plugin.json b/samples/plugins/sample.clock/plugin.json
index 2b33bf0..a441448 100644
--- a/samples/plugins/sample.clock/plugin.json
+++ b/samples/plugins/sample.clock/plugin.json
@@ -14,7 +14,8 @@
"locked": false,
"clickThrough": false,
"opacity": 0.92,
- "scale": 1.0
+ "scale": 1.0,
+ "displayLayer": "desktop"
},
"config": {
"hour12": false
diff --git a/samples/plugins/sample.system-info/plugin.json b/samples/plugins/sample.system-info/plugin.json
index e6241ba..f668ef2 100644
--- a/samples/plugins/sample.system-info/plugin.json
+++ b/samples/plugins/sample.system-info/plugin.json
@@ -14,7 +14,8 @@
"locked": false,
"clickThrough": false,
"opacity": 0.9,
- "scale": 1.0
+ "scale": 1.0,
+ "displayLayer": "desktop"
},
"config": {
"refreshSeconds": 5
diff --git a/samples/plugins/sample.wallpaper/plugin.json b/samples/plugins/sample.wallpaper/plugin.json
index 24b79f0..9584bc5 100644
--- a/samples/plugins/sample.wallpaper/plugin.json
+++ b/samples/plugins/sample.wallpaper/plugin.json
@@ -10,7 +10,8 @@
"width": 1920,
"height": 1080,
"opacity": 1.0,
- "clickThrough": true
+ "clickThrough": true,
+ "displayLayer": "desktop"
},
"config": {
"theme": "aurora"
diff --git a/samples/plugins/sample.webview-test/plugin.json b/samples/plugins/sample.webview-test/plugin.json
index faa1fc1..97b9836 100644
--- a/samples/plugins/sample.webview-test/plugin.json
+++ b/samples/plugins/sample.webview-test/plugin.json
@@ -14,7 +14,8 @@
"locked": false,
"clickThrough": false,
"opacity": 1.0,
- "scale": 1.0
+ "scale": 1.0,
+ "displayLayer": "normal"
},
"config": {
"label": "bridge-ready"
diff --git a/src/Moli.Desktop.Tests/Configuration/JsonConfigurationServiceTests.cs b/src/Moli.Desktop.Tests/Configuration/JsonConfigurationServiceTests.cs
index 32e47b0..25fc18b 100644
--- a/src/Moli.Desktop.Tests/Configuration/JsonConfigurationServiceTests.cs
+++ b/src/Moli.Desktop.Tests/Configuration/JsonConfigurationServiceTests.cs
@@ -2,6 +2,8 @@
using Moli.Desktop.Configuration;
using Moli.Desktop.Diagnostics;
using Moli.Desktop.Host;
+using Moli.Desktop.Layout;
+using Moli.Desktop.Plugins;
namespace Moli.Desktop.Tests.Configuration;
@@ -50,6 +52,33 @@
Assert.True(File.Exists(Path.Combine(paths.ConfigDirectory, "appsettings.json.bak")));
}
+ [Fact]
+ public async Task SaveAndLoadLayoutAsync_UsesDisplayLayerJsonNames()
+ {
+ var (service, paths, _) = CreateService();
+
+ await service.SaveLayoutAsync(new LayoutDocument
+ {
+ Instances =
+ [
+ new WidgetLayout
+ {
+ InstanceId = new WidgetInstanceId("widget-01"),
+ PluginId = new PluginId("sample.clock"),
+ MonitorId = new MonitorId("primary"),
+ Bounds = new RectD(0, 0, 320, 160),
+ DisplayLayer = DisplayLayer.AppTop
+ }
+ ]
+ });
+
+ var json = await File.ReadAllTextAsync(Path.Combine(paths.ConfigDirectory, "layout.json"));
+ Assert.Contains("\"displayLayer\": \"app-top\"", json);
+
+ var loaded = await service.LoadLayoutAsync();
+ Assert.Equal(DisplayLayer.AppTop, Assert.Single(loaded.Instances).DisplayLayer);
+ }
+
private static (JsonConfigurationService Service, DesktopPaths Paths, DiagnosticsService Diagnostics) CreateService()
{
var root = Path.Combine(Path.GetTempPath(), "Moli.Desktop.Tests", Guid.NewGuid().ToString("N"));
diff --git a/src/Moli.Desktop.Tests/Interop/FakeWin32InteropService.cs b/src/Moli.Desktop.Tests/Interop/FakeWin32InteropService.cs
index 069ee4c..0af2ed1 100644
--- a/src/Moli.Desktop.Tests/Interop/FakeWin32InteropService.cs
+++ b/src/Moli.Desktop.Tests/Interop/FakeWin32InteropService.cs
@@ -11,6 +11,8 @@
public bool NoActivateEnabled { get; private set; }
public byte Opacity { get; private set; } = 255;
public DesktopLayerMode? LayerMode { get; private set; }
+ public Moli.Desktop.Layout.RectD? LayerBounds { get; private set; }
+ public bool RestoredTopLevel { get; private set; }
public IntPtr GetWindowHandle(Window window) => new(42);
@@ -22,7 +24,19 @@
public void SetLayered(IntPtr hwnd, bool enabled, byte opacity) => Opacity = enabled ? opacity : (byte)255;
- public void MoveToDesktopLayer(IntPtr hwnd, DesktopLayerMode mode, MonitorInfo monitor) => LayerMode = mode;
+ public void MoveToDesktopLayer(IntPtr hwnd, DesktopLayerMode mode, MonitorInfo monitor)
+ {
+ LayerMode = mode;
+ LayerBounds = monitor.Bounds;
+ }
+
+ public void MoveToDesktopLayer(IntPtr hwnd, DesktopLayerMode mode, Moli.Desktop.Layout.RectD bounds)
+ {
+ LayerMode = mode;
+ LayerBounds = bounds;
+ }
+
+ public void RestoreTopLevelWindow(IntPtr hwnd) => RestoredTopLevel = true;
public void SetBottomMost(IntPtr hwnd) => LayerMode = DesktopLayerMode.BottomMost;
diff --git a/src/Moli.Desktop.Tests/Interop/Win32InteropContractTests.cs b/src/Moli.Desktop.Tests/Interop/Win32InteropContractTests.cs
index d4006ce..01c32f2 100644
--- a/src/Moli.Desktop.Tests/Interop/Win32InteropContractTests.cs
+++ b/src/Moli.Desktop.Tests/Interop/Win32InteropContractTests.cs
@@ -1,3 +1,5 @@
+using Moli.Desktop.Interop;
+
namespace Moli.Desktop.Tests.Interop;
public class Win32InteropContractTests
@@ -12,12 +14,16 @@
interop.SetToolWindow(hwnd, true);
interop.SetNoActivate(hwnd, true);
interop.SetLayered(hwnd, true, 128);
+ interop.MoveToDesktopLayer(hwnd, DesktopLayerMode.WorkerW, new Moli.Desktop.Layout.RectD(10, 20, 300, 120));
+ interop.RestoreTopLevelWindow(hwnd);
interop.SetBottomMost(hwnd);
Assert.True(interop.ClickThroughEnabled);
Assert.True(interop.ToolWindowEnabled);
Assert.True(interop.NoActivateEnabled);
Assert.Equal(128, interop.Opacity);
+ Assert.Equal(new Moli.Desktop.Layout.RectD(10, 20, 300, 120), interop.LayerBounds);
+ Assert.True(interop.RestoredTopLevel);
Assert.Single(interop.GetMonitors());
}
}
diff --git a/src/Moli.Desktop.Tests/Layout/LayoutManagerTests.cs b/src/Moli.Desktop.Tests/Layout/LayoutManagerTests.cs
index 3de75b6..7df03da 100644
--- a/src/Moli.Desktop.Tests/Layout/LayoutManagerTests.cs
+++ b/src/Moli.Desktop.Tests/Layout/LayoutManagerTests.cs
@@ -28,7 +28,7 @@
Assert.Equal(LayoutManager.MinHeight, result.Value.Bounds.Height);
Assert.Equal(LayoutManager.MaxScale, result.Value.Scale);
Assert.Equal(LayoutManager.MinOpacity, result.Value.Opacity);
- Assert.Equal(DisplayPriority.AppLayer, manager.Update(layout.InstanceId, new WidgetLayoutPatch { DisplayPriority = DisplayPriority.AppLayer }).Value?.DisplayPriority);
+ Assert.Equal(DisplayLayer.AppTop, manager.Update(layout.InstanceId, new WidgetLayoutPatch { DisplayLayer = DisplayLayer.AppTop }).Value?.DisplayLayer);
Assert.True(result.Value.Bounds.Right >= monitor.WorkArea.X + LayoutManager.MinVisibleDip);
Assert.True(result.Value.Bounds.Bottom >= monitor.WorkArea.Y + LayoutManager.MinVisibleDip);
}
diff --git a/src/Moli.Desktop.Tests/Plugins/PluginManagerTests.cs b/src/Moli.Desktop.Tests/Plugins/PluginManagerTests.cs
index 52bfcf0..9505347 100644
--- a/src/Moli.Desktop.Tests/Plugins/PluginManagerTests.cs
+++ b/src/Moli.Desktop.Tests/Plugins/PluginManagerTests.cs
@@ -19,6 +19,7 @@
var plugin = Assert.Single(plugins);
Assert.Equal(new PluginId("sample.clock"), plugin.Id);
Assert.Equal(PluginState.Enabled, plugin.State);
+ Assert.Equal(Moli.Desktop.Layout.DisplayLayer.Normal, plugin.Manifest.DefaultLayout.DisplayLayer);
var registry = await CreateConfiguration(paths).LoadPluginRegistryAsync();
Assert.Contains(registry.Plugins, item => item.Id == new PluginId("sample.clock") && item.State == PluginState.Enabled);
@@ -99,7 +100,8 @@
"height": 160,
"locked": false,
"clickThrough": false,
- "opacity": 1.0
+ "opacity": 1.0,
+ "displayLayer": "normal"
}
}
""");
diff --git a/src/Moli.Desktop/Api/LocalApiModels.cs b/src/Moli.Desktop/Api/LocalApiModels.cs
index 9ce3aa2..61b76bd 100644
--- a/src/Moli.Desktop/Api/LocalApiModels.cs
+++ b/src/Moli.Desktop/Api/LocalApiModels.cs
@@ -39,6 +39,7 @@
public double? Opacity { get; init; }
public bool? ClickThrough { get; init; }
public double? Scale { get; init; }
+ public DisplayLayer? DisplayLayer { get; init; }
public WidgetLayoutPatch ToPatch() => new()
{
@@ -48,7 +49,8 @@
IsLocked = IsLocked,
Opacity = Opacity,
ClickThrough = ClickThrough,
- Scale = Scale
+ Scale = Scale,
+ DisplayLayer = DisplayLayer
};
}
@@ -128,6 +130,8 @@
public bool IsLocked { get; init; }
public double Opacity { get; init; }
public bool ClickThrough { get; init; }
+ [JsonConverter(typeof(JsonStringEnumConverter<DisplayLayer>))]
+ public DisplayLayer DisplayLayer { get; init; }
public static WidgetResponse From(WidgetRuntimeState state) => new()
{
@@ -138,7 +142,8 @@
IsVisible = state.IsVisible,
IsLocked = state.IsLocked,
Opacity = state.Opacity,
- ClickThrough = state.ClickThrough
+ ClickThrough = state.ClickThrough,
+ DisplayLayer = state.DisplayLayer
};
}
diff --git a/src/Moli.Desktop/Assets/Moli.Desktop.ico b/src/Moli.Desktop/Assets/Moli.Desktop.ico
index 3d7e70e..d855ea4 100644
--- a/src/Moli.Desktop/Assets/Moli.Desktop.ico
+++ b/src/Moli.Desktop/Assets/Moli.Desktop.ico
Binary files differ
diff --git a/src/Moli.Desktop/Configuration/ConfigurationDocuments.cs b/src/Moli.Desktop/Configuration/ConfigurationDocuments.cs
index 174319b..fe4aa65 100644
--- a/src/Moli.Desktop/Configuration/ConfigurationDocuments.cs
+++ b/src/Moli.Desktop/Configuration/ConfigurationDocuments.cs
@@ -62,7 +62,7 @@
public double Opacity { get; init; } = 1;
public bool ClickThrough { get; init; } = true;
public double Scale { get; init; } = 1;
- public DisplayPriority DisplayPriority { get; init; } = DisplayPriority.IconLayer;
+ public DisplayLayer DisplayLayer { get; init; } = DisplayLayer.Desktop;
}
public sealed record LayoutDocument
diff --git a/src/Moli.Desktop/Host/DefaultContentInstaller.cs b/src/Moli.Desktop/Host/DefaultContentInstaller.cs
index c773075..b41fdad 100644
--- a/src/Moli.Desktop/Host/DefaultContentInstaller.cs
+++ b/src/Moli.Desktop/Host/DefaultContentInstaller.cs
@@ -171,7 +171,7 @@
ClickThrough = manifest.DefaultLayout.ClickThrough,
Opacity = manifest.DefaultLayout.Opacity,
Scale = manifest.DefaultLayout.Scale,
- DisplayPriority = manifest.DefaultLayout.DisplayPriority
+ DisplayLayer = manifest.DefaultLayout.DisplayLayer
});
changed = true;
}
diff --git a/src/Moli.Desktop/Interop/BottomDesktopLayerStrategy.cs b/src/Moli.Desktop/Interop/BottomDesktopLayerStrategy.cs
index 837c476..45e0692 100644
--- a/src/Moli.Desktop/Interop/BottomDesktopLayerStrategy.cs
+++ b/src/Moli.Desktop/Interop/BottomDesktopLayerStrategy.cs
@@ -1,5 +1,5 @@
-using Moli.Desktop.Configuration;
using Moli.Desktop.Diagnostics;
+using Moli.Desktop.Layout;
namespace Moli.Desktop.Interop;
@@ -17,16 +17,16 @@
public bool IsSupported() => true;
- public bool TryAttachWallpaperWindow(IntPtr hwnd, MonitorInfo monitor, out string? error)
+ public bool TryAttachDesktopWindow(IntPtr hwnd, RectD bounds, out string? error)
{
error = null;
if (!NativeMethods.SetWindowPos(
hwnd,
NativeMethods.HwndBottom,
- (int)monitor.Bounds.X,
- (int)monitor.Bounds.Y,
- (int)monitor.Bounds.Width,
- (int)monitor.Bounds.Height,
+ (int)bounds.X,
+ (int)bounds.Y,
+ (int)bounds.Width,
+ (int)bounds.Height,
NativeMethods.SwpNoActivate | NativeMethods.SwpShowWindow))
{
error = $"SetWindowPos failed with {NativeMethods.GetLastError()}";
diff --git a/src/Moli.Desktop/Interop/IDesktopLayerStrategy.cs b/src/Moli.Desktop/Interop/IDesktopLayerStrategy.cs
index d2ce85b..5397fe2 100644
--- a/src/Moli.Desktop/Interop/IDesktopLayerStrategy.cs
+++ b/src/Moli.Desktop/Interop/IDesktopLayerStrategy.cs
@@ -1,11 +1,11 @@
-using Moli.Desktop.Configuration;
+using Moli.Desktop.Layout;
namespace Moli.Desktop.Interop;
-/// <summary>Places a wallpaper window into a desktop-compatible layer.</summary>
+/// <summary>Places a rendered surface into a desktop-compatible layer.</summary>
public interface IDesktopLayerStrategy
{
string Name { get; }
bool IsSupported();
- bool TryAttachWallpaperWindow(IntPtr hwnd, MonitorInfo monitor, out string? error);
+ bool TryAttachDesktopWindow(IntPtr hwnd, RectD bounds, out string? error);
}
diff --git a/src/Moli.Desktop/Interop/IWin32InteropService.cs b/src/Moli.Desktop/Interop/IWin32InteropService.cs
index 3660f32..dc60356 100644
--- a/src/Moli.Desktop/Interop/IWin32InteropService.cs
+++ b/src/Moli.Desktop/Interop/IWin32InteropService.cs
@@ -1,5 +1,6 @@
using System.Windows;
using Moli.Desktop.Configuration;
+using Moli.Desktop.Layout;
namespace Moli.Desktop.Interop;
@@ -12,6 +13,8 @@
void SetNoActivate(IntPtr hwnd, bool enabled);
void SetLayered(IntPtr hwnd, bool enabled, byte opacity);
void MoveToDesktopLayer(IntPtr hwnd, DesktopLayerMode mode, MonitorInfo monitor);
+ void MoveToDesktopLayer(IntPtr hwnd, DesktopLayerMode mode, RectD bounds);
+ void RestoreTopLevelWindow(IntPtr hwnd);
void SetBottomMost(IntPtr hwnd);
IReadOnlyList<MonitorInfo> GetMonitors();
}
diff --git a/src/Moli.Desktop/Interop/Win32InteropService.cs b/src/Moli.Desktop/Interop/Win32InteropService.cs
index ad6a2af..bf066f9 100644
--- a/src/Moli.Desktop/Interop/Win32InteropService.cs
+++ b/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(
diff --git a/src/Moli.Desktop/Interop/WorkerWDesktopLayerStrategy.cs b/src/Moli.Desktop/Interop/WorkerWDesktopLayerStrategy.cs
index 21de1f7..39a33c3 100644
--- a/src/Moli.Desktop/Interop/WorkerWDesktopLayerStrategy.cs
+++ b/src/Moli.Desktop/Interop/WorkerWDesktopLayerStrategy.cs
@@ -1,5 +1,5 @@
-using Moli.Desktop.Configuration;
using Moli.Desktop.Diagnostics;
+using Moli.Desktop.Layout;
namespace Moli.Desktop.Interop;
@@ -17,7 +17,7 @@
public bool IsSupported() => NativeMethods.FindWindow("Progman", null) != IntPtr.Zero;
- public bool TryAttachWallpaperWindow(IntPtr hwnd, MonitorInfo monitor, out string? error)
+ public bool TryAttachDesktopWindow(IntPtr hwnd, RectD bounds, out string? error)
{
error = null;
var workerW = FindWorkerW();
@@ -45,10 +45,10 @@
if (!NativeMethods.SetWindowPos(
hwnd,
IntPtr.Zero,
- (int)monitor.Bounds.X,
- (int)monitor.Bounds.Y,
- (int)monitor.Bounds.Width,
- (int)monitor.Bounds.Height,
+ (int)bounds.X,
+ (int)bounds.Y,
+ (int)bounds.Width,
+ (int)bounds.Height,
NativeMethods.SwpNoZOrder | NativeMethods.SwpNoActivate | NativeMethods.SwpShowWindow))
{
error = $"SetWindowPos failed with {NativeMethods.GetLastError()}";
diff --git a/src/Moli.Desktop/Layout/Geometry.cs b/src/Moli.Desktop/Layout/Geometry.cs
index 9890e19..342204d 100644
--- a/src/Moli.Desktop/Layout/Geometry.cs
+++ b/src/Moli.Desktop/Layout/Geometry.cs
@@ -1,3 +1,4 @@
+using System.Text.Json.Serialization;
using Moli.Desktop.Plugins;
namespace Moli.Desktop.Layout;
@@ -23,11 +24,19 @@
public override string ToString() => Value;
}
-public enum DisplayPriority
+public enum DisplayLayer
{
- DesktopLayer,
- IconLayer,
- AppLayer
+ [JsonStringEnumMemberName("desktop")]
+ Desktop,
+
+ [JsonStringEnumMemberName("normal")]
+ Normal,
+
+ [JsonStringEnumMemberName("app-top")]
+ AppTop,
+
+ [JsonStringEnumMemberName("global-top")]
+ GlobalTop
}
public sealed record WidgetRuntimeState
@@ -40,7 +49,7 @@
public bool IsLocked { get; init; }
public double Opacity { get; init; } = 1;
public bool ClickThrough { get; init; } = true;
- public DisplayPriority DisplayPriority { get; init; } = DisplayPriority.IconLayer;
+ public DisplayLayer DisplayLayer { get; init; } = DisplayLayer.Desktop;
}
public sealed record WidgetLayoutPatch
@@ -52,5 +61,5 @@
public double? Opacity { get; init; }
public bool? ClickThrough { get; init; }
public double? Scale { get; init; }
- public DisplayPriority? DisplayPriority { get; init; }
+ public DisplayLayer? DisplayLayer { get; init; }
}
diff --git a/src/Moli.Desktop/Layout/LayoutManager.cs b/src/Moli.Desktop/Layout/LayoutManager.cs
index 5485c25..a8013c3 100644
--- a/src/Moli.Desktop/Layout/LayoutManager.cs
+++ b/src/Moli.Desktop/Layout/LayoutManager.cs
@@ -83,7 +83,7 @@
ClickThrough = plugin.Manifest.DefaultLayout.ClickThrough,
Opacity = Clamp(plugin.Manifest.DefaultLayout.Opacity, MinOpacity, MaxOpacity),
Scale = Clamp(plugin.Manifest.DefaultLayout.Scale, MinScale, MaxScale),
- DisplayPriority = plugin.Manifest.DefaultLayout.DisplayPriority
+ DisplayLayer = plugin.Manifest.DefaultLayout.DisplayLayer
};
lock (_gate)
@@ -121,7 +121,7 @@
Opacity = patch.Opacity ?? layout.Opacity,
ClickThrough = patch.ClickThrough ?? layout.ClickThrough,
Scale = patch.Scale ?? layout.Scale,
- DisplayPriority = patch.DisplayPriority ?? layout.DisplayPriority
+ DisplayLayer = patch.DisplayLayer ?? layout.DisplayLayer
});
}
diff --git a/src/Moli.Desktop/Management/ManagementWindow.xaml b/src/Moli.Desktop/Management/ManagementWindow.xaml
index 300b1ea..8a5ef92 100644
--- a/src/Moli.Desktop/Management/ManagementWindow.xaml
+++ b/src/Moli.Desktop/Management/ManagementWindow.xaml
@@ -63,8 +63,8 @@
<ComboBox x:Name="WidgetSelector" Width="260" DisplayMemberPath="InstanceId" Margin="0,0,8,0" />
<Button Content="鏄剧ず/闅愯棌" Width="96" Margin="0,0,8,0" Click="ToggleWidgetVisible_Click" />
<Button Content="閿佸畾/瑙i攣" Width="96" Margin="0,0,8,0" Click="ToggleWidgetLocked_Click" />
- <ComboBox x:Name="DisplayPrioritySelector" Width="132" Margin="0,0,8,0" />
- <Button Content="搴旂敤浼樺厛绾�" Width="104" Margin="0,0,8,0" Click="ApplyDisplayPriority_Click" />
+ <ComboBox x:Name="DisplayLayerSelector" Width="132" Margin="0,0,8,0" />
+ <Button Content="搴旂敤灞傜骇" Width="104" Margin="0,0,8,0" Click="ApplyDisplayLayer_Click" />
</WrapPanel>
<DataGrid x:Name="WidgetsGrid" AutoGenerateColumns="True" IsReadOnly="True">
<DataGrid.ContextMenu>
diff --git a/src/Moli.Desktop/Management/ManagementWindow.xaml.cs b/src/Moli.Desktop/Management/ManagementWindow.xaml.cs
index 08d0c55..1bee7d6 100644
--- a/src/Moli.Desktop/Management/ManagementWindow.xaml.cs
+++ b/src/Moli.Desktop/Management/ManagementWindow.xaml.cs
@@ -42,7 +42,7 @@
_apiStatus = apiStatus;
_paths = paths;
InitializeComponent();
- DisplayPrioritySelector.ItemsSource = Enum.GetValues<DisplayPriority>();
+ DisplayLayerSelector.ItemsSource = Enum.GetValues<DisplayLayer>();
_timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(2) };
_timer.Tick += async (_, _) => await RefreshAsync();
Loaded += async (_, _) =>
@@ -77,7 +77,7 @@
WidgetSelector.ItemsSource = widgets;
WidgetSelector.SelectedItem = widgets.FirstOrDefault(widget => widget.InstanceId == selected) ?? widgets.FirstOrDefault();
WidgetsGrid.ItemsSource = widgets;
- DisplayPrioritySelector.SelectedItem = (WidgetSelector.SelectedItem as WidgetRow)?.DisplayPriority ?? DisplayPriority.IconLayer;
+ DisplayLayerSelector.SelectedItem = (WidgetSelector.SelectedItem as WidgetRow)?.DisplayLayer ?? DisplayLayer.Desktop;
PluginsGrid.ItemsSource = _state.Plugins.Select(PluginRow.From).ToArray();
DiagnosticsGrid.ItemsSource = diagnostics.Select(DiagnosticRow.From).ToArray();
RecentDiagnosticsGrid.ItemsSource = diagnostics.Take(8).Select(DiagnosticRow.From).ToArray();
@@ -91,14 +91,28 @@
private async void ToggleSafeInput_Click(object sender, RoutedEventArgs e) => await ExecuteAsync(() => _runtime.SetSafeInputModeAsync(!(_state?.IsSafeInputMode ?? false)));
private async void ToggleGlobalLock_Click(object sender, RoutedEventArgs e) => await ExecuteAsync(() => _runtime.SetGlobalLockedAsync(!(_state?.IsGlobalLocked ?? false)));
private async void ReloadPlugins_Click(object sender, RoutedEventArgs e) => await ExecuteAsync(() => _runtime.ReloadPluginsAsync());
- private async void ApplyDisplayPriority_Click(object sender, RoutedEventArgs e)
+ private async void ApplyDisplayLayer_Click(object sender, RoutedEventArgs e)
{
- if (SelectedWidget() is not { } widget || DisplayPrioritySelector.SelectedItem is not DisplayPriority priority)
+ if (SelectedWidget() is not { } widget || DisplayLayerSelector.SelectedItem is not DisplayLayer layer)
{
return;
}
- await ExecuteWidgetAsync(widget.InstanceId, new WidgetLayoutPatch { DisplayPriority = priority });
+ if (layer == DisplayLayer.GlobalTop)
+ {
+ var choice = MessageBox.Show(
+ this,
+ "鍏ㄥ眬缃《浼氳璇ョ粍浠惰鐩栧叾浠栧簲鐢ㄧ獥鍙c�傜‘璁ょ户缁紵",
+ "鍏ㄥ眬缃《",
+ MessageBoxButton.YesNo,
+ MessageBoxImage.Warning);
+ if (choice != MessageBoxResult.Yes)
+ {
+ return;
+ }
+ }
+
+ await ExecuteWidgetAsync(widget.InstanceId, new WidgetLayoutPatch { DisplayLayer = layer });
}
private async void ToggleWidgetVisible_Click(object sender, RoutedEventArgs e)
@@ -138,7 +152,7 @@
{
var choice = MessageBox.Show(
this,
- "纭鎭㈠榛樿甯冨眬鍜屼氦浜掗厤缃紵姝ゆ搷浣滀細鏄剧ず骞惰В閿佺粍浠讹紝鎭㈠閫忔槑搴︺�佺偣鍑荤┛閫忓拰榛樿鏄剧ず浼樺厛绾с��",
+ "纭鎭㈠榛樿甯冨眬鍜屼氦浜掗厤缃紵姝ゆ搷浣滀細鏄剧ず骞惰В閿佺粍浠讹紝鎭㈠閫忔槑搴︺�佺偣鍑荤┛閫忓拰榛樿鏄剧ず灞傜骇銆�",
"鎭㈠榛樿",
MessageBoxButton.YesNo,
MessageBoxImage.Warning);
@@ -158,7 +172,7 @@
IsLocked = false,
Opacity = 1,
ClickThrough = true,
- DisplayPriority = DisplayPriority.IconLayer
+ DisplayLayer = DisplayLayer.Desktop
});
}
@@ -255,7 +269,7 @@
description = $"Loaded from {Path.GetFileName(fileName)}.",
author = "Moli.Desktop",
permissions = Array.Empty<string>(),
- defaultLayout = new { width = 1920, height = 1080, x = 0, y = 0, locked = true, clickThrough = true, opacity = 1, scale = 1 },
+ defaultLayout = new { width = 1920, height = 1080, x = 0, y = 0, locked = true, clickThrough = true, opacity = 1, scale = 1, displayLayer = "desktop" },
config = new { sourceFile = fileName, sourceType = extension.TrimStart('.') }
};
await File.WriteAllTextAsync(
@@ -335,7 +349,7 @@
private static string Html(string value) => System.Net.WebUtility.HtmlEncode(value);
- private sealed record WidgetRow(string InstanceId, string PluginId, string Bounds, string MonitorId, bool IsVisible, bool IsLocked, double Opacity, bool ClickThrough, DisplayPriority DisplayPriority)
+ private sealed record WidgetRow(string InstanceId, string PluginId, string Bounds, string MonitorId, bool IsVisible, bool IsLocked, double Opacity, bool ClickThrough, DisplayLayer DisplayLayer)
{
public static WidgetRow From(WidgetRuntimeState state)
=> new(
@@ -347,7 +361,7 @@
state.IsLocked,
state.Opacity,
state.ClickThrough,
- state.DisplayPriority);
+ state.DisplayLayer);
}
private sealed record PluginRow(string Id, string Name, string Type, string State, string? ErrorCode, string Entry)
diff --git a/src/Moli.Desktop/Plugins/PluginManifest.cs b/src/Moli.Desktop/Plugins/PluginManifest.cs
index c385caf..5801d98 100644
--- a/src/Moli.Desktop/Plugins/PluginManifest.cs
+++ b/src/Moli.Desktop/Plugins/PluginManifest.cs
@@ -13,7 +13,7 @@
public bool ClickThrough { get; init; }
public double Opacity { get; init; } = 1;
public double Scale { get; init; } = 1;
- public DisplayPriority DisplayPriority { get; init; } = DisplayPriority.IconLayer;
+ public DisplayLayer DisplayLayer { get; init; } = DisplayLayer.Desktop;
}
public sealed record PluginManifest
diff --git a/src/Moli.Desktop/Runtime/DesktopRuntimeCoordinator.cs b/src/Moli.Desktop/Runtime/DesktopRuntimeCoordinator.cs
index a2814df..33b594b 100644
--- a/src/Moli.Desktop/Runtime/DesktopRuntimeCoordinator.cs
+++ b/src/Moli.Desktop/Runtime/DesktopRuntimeCoordinator.cs
@@ -328,7 +328,7 @@
IsLocked = _isGlobalLocked || layout.IsLocked,
Opacity = layout.Opacity,
ClickThrough = _isEditMode || _isSafeInputMode ? false : layout.ClickThrough,
- DisplayPriority = layout.DisplayPriority
+ DisplayLayer = layout.DisplayLayer
};
private WidgetLayout ToSurfaceLayout(WidgetLayout layout)
diff --git a/src/Moli.Desktop/Windows/WidgetWindow.cs b/src/Moli.Desktop/Windows/WidgetWindow.cs
index bf349fb..18fecbc 100644
--- a/src/Moli.Desktop/Windows/WidgetWindow.cs
+++ b/src/Moli.Desktop/Windows/WidgetWindow.cs
@@ -62,7 +62,7 @@
AllowsTransparency = true;
Background = Brushes.Transparent;
ShowInTaskbar = false;
- Topmost = true;
+ Topmost = false;
SizeToContent = SizeToContent.Manual;
var root = new Grid { Background = Brushes.Transparent };
@@ -126,7 +126,7 @@
Height = layout.Bounds.Height;
Opacity = Math.Clamp(layout.Opacity, 0.1, 1.0);
Visibility = layout.IsVisible ? Visibility.Visible : Visibility.Hidden;
- Topmost = layout.DisplayPriority is DisplayPriority.IconLayer or DisplayPriority.AppLayer;
+ Topmost = layout.DisplayLayer == DisplayLayer.GlobalTop;
_editBorder.Visibility = editMode ? Visibility.Visible : Visibility.Collapsed;
_resizeGrip.Visibility = editMode && !layout.IsLocked ? Visibility.Visible : Visibility.Collapsed;
ApplyWin32Styles();
@@ -241,7 +241,8 @@
IsVisible = _layout.IsVisible,
IsLocked = _layout.IsLocked,
Opacity = _layout.Opacity,
- ClickThrough = _layout.ClickThrough
+ ClickThrough = _layout.ClickThrough,
+ DisplayLayer = _layout.DisplayLayer
};
private void ApplyWin32Styles()
@@ -257,6 +258,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