dsh-gufa-code 1.3.198 → 1.3.200

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client.js CHANGED
@@ -16,7 +16,7 @@ const GUFA_NS = 'gufa-code'
16
16
  const G = {}
17
17
  G.NS = GUFA_NS
18
18
  /** 客户端构建标记(排查页面是否加载了新代码时看标题栏) */
19
- G.BUILD = '1.3.198'
19
+ G.BUILD = '1.3.200'
20
20
  G.PANEL_ID = 'gufa-code'
21
21
  /** 从哪个工作区点进来的(工作区菜单/节点按钮写入,App 启动时消费)。 */
22
22
  G.pendingEntryWorkspace = null
@@ -75,6 +75,7 @@ constexpr UINT_PTR kTimerSelftest = 6;
75
75
  constexpr UINT_PTR kTimerPageProbe = 7;
76
76
  constexpr UINT_PTR kTimerRetry = 8;
77
77
  constexpr UINT_PTR kTimerControllerWatchdog = 9;
78
+ constexpr UINT_PTR kTimerForwardShow = 10;
78
79
 
79
80
  constexpr int kMenuExit = 1;
80
81
  constexpr int kMenuResetFrame = 2;
@@ -94,6 +95,8 @@ constexpr int kControllerWatchdogMs = 12000;
94
95
  const COLORREF kBackgroundColor = RGB(13, 15, 19);
95
96
 
96
97
  HINSTANCE g_instance = nullptr;
98
+ class FloatApp;
99
+ FloatApp* g_activeFloatApp = nullptr;
97
100
  std::wstring g_logPath;
98
101
  /* 崩溃兜底:记录被隐藏的 DSH 窗口,异常退出前尽量恢复(全局变量便于崩溃过滤器访问) */
99
102
  std::vector<HWND> g_crashRestoreWindows;
@@ -973,6 +976,8 @@ class FloatApp {
973
976
  void OnFollowTimer();
974
977
  void ApplyFollowFrame();
975
978
  void ApplyClickThrough();
979
+ void ForwardMouseToUnderlying(UINT message, const MSLLHOOKSTRUCT* info);
980
+ static LRESULT CALLBACK LowLevelMouseProc(int code, WPARAM wparam, LPARAM lparam);
976
981
  void OnHideDshTimer();
977
982
  void HideDshWindows();
978
983
  void RestoreDshWindows();
@@ -1044,8 +1049,11 @@ class FloatApp {
1044
1049
  bool suppressWindowDestroy_ = false;
1045
1050
  bool hideDshDone_ = false;
1046
1051
  bool clickThrough_ = false;
1047
- bool clickThroughLayered_ = false;
1048
1052
  bool clickThroughHotkey_ = false;
1053
+ HHOOK mouseHook_ = nullptr;
1054
+ bool mouseHookInstalled_ = false;
1055
+ HWND forwardedTarget_ = nullptr;
1056
+ bool forwardedLeftDown_ = false;
1049
1057
  };
1050
1058
 
1051
1059
  namespace {
@@ -1091,6 +1099,7 @@ static void ShowFloatContextMenu(HWND owner, FloatApp* app) {
1091
1099
  }
1092
1100
 
1093
1101
  FloatApp::~FloatApp() {
1102
+ if (g_activeFloatApp == this) g_activeFloatApp = nullptr;
1094
1103
  if (hostProcess_ != nullptr) {
1095
1104
  CloseHandle(hostProcess_);
1096
1105
  hostProcess_ = nullptr;
@@ -1362,10 +1371,9 @@ bool FloatApp::CreateMainWindow() {
1362
1371
  bool FloatApp::CreateHostWindow(const RECT& rect, bool composition) {
1363
1372
  hostingMode_ = composition ? HostingMode::Composition : HostingMode::Windowed;
1364
1373
  DWORD extendedStyle = WS_EX_TOPMOST | WS_EX_TOOLWINDOW;
1365
- /* 透明 + 鼠标穿透的正确组合:WS_EX_LAYERED 与 DirectComposition 可以共存;
1366
- WS_EX_NOREDIRECTIONBITMAP 与 LAYERED 语义冲突会出白色矩形,而且 NORD 本身
1367
- 不实现穿透(HTTRANSPARENT 又只在同线程生效)。 */
1368
- if (composition) extendedStyle |= WS_EX_LAYERED;
1374
+ /* 透明视觉继续用 NORD + DComp(per-pixel alpha 正确);穿透改为鼠标钩子转发,
1375
+ 不再用 LAYERED 改变窗口合成路径(否则透明白底/黑底,摸鱼透明度会乱)。 */
1376
+ if (composition) extendedStyle |= WS_EX_NOREDIRECTIONBITMAP;
1369
1377
  const DWORD style = WS_POPUP | WS_THICKFRAME | WS_CLIPCHILDREN;
1370
1378
  hwnd_ = CreateWindowExW(extendedStyle, kMainWindowClass, kWindowTitle, style, rect.left,
1371
1379
  rect.top, rect.right - rect.left, rect.bottom - rect.top, nullptr,
@@ -1375,12 +1383,10 @@ bool FloatApp::CreateHostWindow(const RECT& rect, bool composition) {
1375
1383
  static_cast<unsigned long>(GetLastError()));
1376
1384
  return false;
1377
1385
  }
1386
+ g_activeFloatApp = this;
1378
1387
  LogFmt(L"main-window-created composition=%d rect=(%ld,%ld)-(%ld,%ld) dpi=%u",
1379
1388
  composition ? 1 : 0, static_cast<long>(rect.left), static_cast<long>(rect.top),
1380
1389
  static_cast<long>(rect.right), static_cast<long>(rect.bottom), WindowDpi(hwnd_));
1381
- if (composition) {
1382
- SetLayeredWindowAttributes(hwnd_, 0, 255, LWA_ALPHA);
1383
- }
1384
1390
  if (RegisterHotKey(hwnd_, kHotkeyClickThrough, MOD_CONTROL | MOD_ALT | MOD_SHIFT, 'G')) {
1385
1391
  clickThroughHotkey_ = true;
1386
1392
  Log(L"click-through-hotkey=registered Ctrl+Alt+Shift+G");
@@ -1818,6 +1824,12 @@ void FloatApp::OnTimer(UINT_PTR timerId) {
1818
1824
  hideDshDone_ = true;
1819
1825
  OnHideDshTimer();
1820
1826
  break;
1827
+ case kTimerForwardShow:
1828
+ KillTimer(hwnd_, kTimerForwardShow);
1829
+ if (!exiting_ && !payload_.ciProbe && hwnd_ != nullptr && IsWindowVisible(hwnd_) == FALSE) {
1830
+ ShowWindow(hwnd_, SW_SHOWNOACTIVATE);
1831
+ }
1832
+ break;
1821
1833
  case kTimerControllerWatchdog:
1822
1834
  KillTimer(hwnd_, kTimerControllerWatchdog);
1823
1835
  if (!exiting_ && !controllerReady_) {
@@ -2537,29 +2549,127 @@ void FloatApp::ToggleClickThrough() {
2537
2549
 
2538
2550
  void FloatApp::ApplyClickThrough() {
2539
2551
  if (hwnd_ == nullptr) return;
2540
- LONG_PTR exStyle = GetWindowLongPtrW(hwnd_, GWL_EXSTYLE);
2541
- /* 跨进程穿透只有 WS_EX_LAYERED | WS_EX_TRANSPARENT 有效:
2542
- - NORD 窗口不受 WS_EX_TRANSPARENT 影响;
2543
- - WM_NCHITTEST→HTTRANSPARENT 只在同线程窗口间下传,跨进程会吞掉点击。
2544
- 所以 composition 窗口改成 LAYERED + DComp,穿透只翻转 TRANSPARENT 位。 */
2545
- LONG_PTR next = clickThrough_ ? (exStyle | WS_EX_TRANSPARENT | WS_EX_LAYERED)
2546
- : (exStyle & ~static_cast<LONG_PTR>(WS_EX_TRANSPARENT));
2547
- if ((next & WS_EX_LAYERED) != 0 && (exStyle & WS_EX_LAYERED) == 0) {
2548
- SetLayeredWindowAttributes(hwnd_, 0, 255, LWA_ALPHA);
2549
- }
2550
- clickThroughLayered_ = (next & WS_EX_LAYERED) != 0;
2551
- if (next != exStyle) {
2552
- SetWindowLongPtrW(hwnd_, GWL_EXSTYLE, next);
2553
- SetWindowPos(hwnd_, nullptr, 0, 0, 0, 0,
2554
- SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
2555
- }
2556
- int childCount = 0;
2557
- EnumChildWindows(hwnd_, CountChildWindow, reinterpret_cast<LPARAM>(&childCount));
2558
- EnumChildWindows(hwnd_, SetChildClickThrough, clickThrough_ ? 1 : 0);
2559
- LogFmt(L"click-through=%d mode=%s layered=%d styleTransparent=%d children=%d", clickThrough_ ? 1 : 0,
2552
+ /* 保持 NORD+DComp 的 per-pixel 透明,不切 LAYERED。
2553
+ 穿透通过 WH_MOUSE_LL 钩子把鼠标消息转发给下层窗口实现(跨进程唯一不破坏透明的方式):
2554
+ - 点击/滚轮:临时隐藏自身 → WindowFromPoint 找下层窗口 → 显示自身 → SendMessage 转发;
2555
+ - 左键按住拖动期间保持隐藏,松开后恢复,drag 直接作用在下层 App。 */
2556
+ if (clickThrough_ && !mouseHookInstalled_) {
2557
+ mouseHook_ = SetWindowsHookExW(WH_MOUSE_LL, LowLevelMouseProc, g_instance, 0);
2558
+ mouseHookInstalled_ = mouseHook_ != nullptr;
2559
+ if (!mouseHookInstalled_) {
2560
+ LogFmt(L"click-through-hook=register-failed err=%lu", static_cast<unsigned long>(GetLastError()));
2561
+ clickThrough_ = false;
2562
+ }
2563
+ } else if (!clickThrough_ && mouseHookInstalled_) {
2564
+ if (mouseHook_ != nullptr) UnhookWindowsHookEx(mouseHook_);
2565
+ mouseHook_ = nullptr;
2566
+ mouseHookInstalled_ = false;
2567
+ forwardedTarget_ = nullptr;
2568
+ forwardedLeftDown_ = false;
2569
+ if (IsWindowVisible(hwnd_) == FALSE) ShowWindow(hwnd_, SW_SHOWNOACTIVATE);
2570
+ }
2571
+ LogFmt(L"click-through=%d mode=%s hook=%d", clickThrough_ ? 1 : 0,
2560
2572
  hostingMode_ == HostingMode::Composition ? L"composition" : L"windowed",
2561
- clickThroughLayered_ ? 1 : 0,
2562
- (GetWindowLongPtrW(hwnd_, GWL_EXSTYLE) & WS_EX_TRANSPARENT) != 0 ? 1 : 0, childCount);
2573
+ mouseHookInstalled_ ? 1 : 0);
2574
+ }
2575
+
2576
+ void FloatApp::ForwardMouseToUnderlying(UINT message, const MSLLHOOKSTRUCT* info) {
2577
+ if (hwnd_ == nullptr || info == nullptr) return;
2578
+ const POINT screenPoint = info->pt;
2579
+ auto sendToTarget = [&](HWND target, UINT msg, WPARAM wparam, LPARAM lparam) {
2580
+ if (target == nullptr) return;
2581
+ DWORD_PTR result = 0;
2582
+ SendMessageTimeoutW(target, msg, wparam, lparam, SMTO_ABORTIFHUNG, 200, &result);
2583
+ };
2584
+ auto findTarget = [&]() -> HWND {
2585
+ const bool wasVisible = IsWindowVisible(hwnd_) != FALSE;
2586
+ if (wasVisible) ShowWindow(hwnd_, SW_HIDE);
2587
+ HWND target = WindowFromPoint(screenPoint);
2588
+ if (wasVisible) ShowWindow(hwnd_, SW_SHOWNOACTIVATE);
2589
+ if (target == hwnd_ || (target != nullptr && IsChild(hwnd_, target))) return nullptr;
2590
+ return target;
2591
+ };
2592
+ auto clientLParam = [&](HWND target) -> LPARAM {
2593
+ POINT clientPoint = screenPoint;
2594
+ ScreenToClient(target, &clientPoint);
2595
+ return MAKELPARAM(static_cast<short>(clientPoint.x), static_cast<short>(clientPoint.y));
2596
+ };
2597
+ switch (message) {
2598
+ case WM_LBUTTONDOWN:
2599
+ forwardedTarget_ = findTarget();
2600
+ if (forwardedTarget_ == nullptr) return;
2601
+ forwardedLeftDown_ = true;
2602
+ if (IsWindowVisible(hwnd_) != FALSE) ShowWindow(hwnd_, SW_HIDE);
2603
+ sendToTarget(forwardedTarget_, WM_LBUTTONDOWN, MK_LBUTTON, clientLParam(forwardedTarget_));
2604
+ return;
2605
+ case WM_MOUSEMOVE:
2606
+ if (!forwardedLeftDown_ || forwardedTarget_ == nullptr) return;
2607
+ sendToTarget(forwardedTarget_, WM_MOUSEMOVE, MK_LBUTTON, clientLParam(forwardedTarget_));
2608
+ return;
2609
+ case WM_LBUTTONUP:
2610
+ if (!forwardedLeftDown_ || forwardedTarget_ == nullptr) return;
2611
+ sendToTarget(forwardedTarget_, WM_LBUTTONUP, 0, clientLParam(forwardedTarget_));
2612
+ forwardedTarget_ = nullptr;
2613
+ forwardedLeftDown_ = false;
2614
+ if (IsWindowVisible(hwnd_) == FALSE) ShowWindow(hwnd_, SW_SHOWNOACTIVATE);
2615
+ return;
2616
+ case WM_RBUTTONDOWN:
2617
+ case WM_RBUTTONUP:
2618
+ case WM_MBUTTONDOWN:
2619
+ case WM_MBUTTONUP:
2620
+ case WM_MOUSEWHEEL:
2621
+ case WM_MOUSEHWHEEL: {
2622
+ HWND target = findTarget();
2623
+ if (target == nullptr) return;
2624
+ const LPARAM clientPos = clientLParam(target);
2625
+ WPARAM wparam = 0;
2626
+ if (message == WM_MOUSEWHEEL || message == WM_MOUSEHWHEEL) {
2627
+ wparam = static_cast<WPARAM>(static_cast<short>(HIWORD(info->mouseData)));
2628
+ sendToTarget(target, message, wparam, MAKELPARAM(screenPoint.x, screenPoint.y));
2629
+ return;
2630
+ }
2631
+ if (message == WM_RBUTTONDOWN) wparam = MK_RBUTTON;
2632
+ if (message == WM_MBUTTONDOWN) wparam = MK_MBUTTON;
2633
+ sendToTarget(target, message, wparam, clientPos);
2634
+ return;
2635
+ }
2636
+ default:
2637
+ return;
2638
+ }
2639
+ }
2640
+
2641
+ LRESULT CALLBACK FloatApp::LowLevelMouseProc(int code, WPARAM wparam, LPARAM lparam) {
2642
+ if (code < 0) return CallNextHookEx(nullptr, code, wparam, lparam);
2643
+ FloatApp* app = g_activeFloatApp;
2644
+ if (app == nullptr || app->hwnd_ == nullptr || !app->clickThrough_) return CallNextHookEx(nullptr, code, wparam, lparam);
2645
+ const MSLLHOOKSTRUCT* info = reinterpret_cast<const MSLLHOOKSTRUCT*>(lparam);
2646
+ if (info == nullptr) return CallNextHookEx(nullptr, code, wparam, lparam);
2647
+ RECT rect = {};
2648
+ if (!GetWindowRect(app->hwnd_, &rect)) return CallNextHookEx(nullptr, code, wparam, lparam);
2649
+ const bool inside = info->pt.x >= rect.left && info->pt.x < rect.right && info->pt.y >= rect.top && info->pt.y < rect.bottom;
2650
+ if (!inside) return CallNextHookEx(nullptr, code, wparam, lparam);
2651
+ /* 关键:WM_MOUSEMOVE 绝对不能返回 1(吞掉移动事件会让系统鼠标“卡死”)。
2652
+ 穿透实现为把按钮/滚轮消息转发给下层窗口;移动事件只在左键按住拖动时转发,但仍放行。 */
2653
+ switch (wparam) {
2654
+ case WM_MOUSEMOVE:
2655
+ if (app->forwardedLeftDown_) app->ForwardMouseToUnderlying(WM_MOUSEMOVE, info);
2656
+ return CallNextHookEx(nullptr, code, wparam, lparam);
2657
+ case WM_LBUTTONDOWN:
2658
+ app->ForwardMouseToUnderlying(WM_LBUTTONDOWN, info);
2659
+ return 1;
2660
+ case WM_LBUTTONUP:
2661
+ app->ForwardMouseToUnderlying(WM_LBUTTONUP, info);
2662
+ return 1;
2663
+ case WM_RBUTTONDOWN:
2664
+ case WM_RBUTTONUP:
2665
+ case WM_MBUTTONDOWN:
2666
+ case WM_MBUTTONUP:
2667
+ case WM_MOUSEWHEEL:
2668
+ app->ForwardMouseToUnderlying(static_cast<UINT>(wparam), info);
2669
+ return 1;
2670
+ default:
2671
+ return CallNextHookEx(nullptr, code, wparam, lparam);
2672
+ }
2563
2673
  }
2564
2674
 
2565
2675
  void FloatApp::StopFollowing() {
@@ -2578,6 +2688,11 @@ void FloatApp::DoGracefulExit() {
2578
2688
  return;
2579
2689
  }
2580
2690
  Log(L"graceful-exit-start");
2691
+ if (mouseHookInstalled_) {
2692
+ if (mouseHook_ != nullptr) UnhookWindowsHookEx(mouseHook_);
2693
+ mouseHook_ = nullptr;
2694
+ mouseHookInstalled_ = false;
2695
+ }
2581
2696
  if (clickThroughHotkey_ && hwnd_ != nullptr) {
2582
2697
  UnregisterHotKey(hwnd_, kHotkeyClickThrough);
2583
2698
  clickThroughHotkey_ = false;
@@ -2598,6 +2713,11 @@ void FloatApp::DoGracefulExit() {
2598
2713
  }
2599
2714
 
2600
2715
  void FloatApp::OnWindowDestroyed() {
2716
+ if (mouseHookInstalled_) {
2717
+ if (mouseHook_ != nullptr) UnhookWindowsHookEx(mouseHook_);
2718
+ mouseHook_ = nullptr;
2719
+ mouseHookInstalled_ = false;
2720
+ }
2601
2721
  if (clickThroughHotkey_ && hwnd_ != nullptr) {
2602
2722
  UnregisterHotKey(hwnd_, kHotkeyClickThrough);
2603
2723
  clickThroughHotkey_ = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-gufa-code",
3
- "version": "1.3.198",
3
+ "version": "1.3.200",
4
4
  "description": "古法编程 · AI 辅助:一键把 DSH 主面板变成 VS Code 风格 IDE(Monaco 编辑器、文件树、Git、SSH、真实终端 + 右侧官方会话);主张亲手写、每个改动心中有数,AI 是助理、你是第一责任人",
5
5
  "icon": "icon.svg",
6
6
  "keywords": [