From 1a4430e235fa5bca2e533898405e5b685d4b05db Mon Sep 17 00:00:00 2001 From: taqin Date: Sun, 12 Apr 2026 21:23:22 +0700 Subject: [PATCH] Fix window dragging - use ReleaseCapture + SendMessage for native drag - webkit-app-region doesn't work in WebView2, use Win API instead - Bind windowDrag() that calls ReleaseCapture + SendMessage(WM_NCLBUTTONDOWN) - Title bar onmousedown triggers native window drag behavior - stopPropagation on window control buttons to prevent drag on click - Window can now be dragged by clicking anywhere on the title bar Co-Authored-By: Claude Opus 4.6 (1M context) --- main.go | 13 +++++++++++-- ui/index.html | 10 +++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index 05b9560..020c9f2 100644 --- a/main.go +++ b/main.go @@ -28,8 +28,10 @@ var ( procGetWindowLong = user32.NewProc("GetWindowLongW") procSetWindowLong = user32.NewProc("SetWindowLongW") procSetWindowPos = user32.NewProc("SetWindowPos") - procPostMessage = user32.NewProc("PostMessageW") - procShowWindow = user32.NewProc("ShowWindow") + procPostMessage = user32.NewProc("PostMessageW") + procShowWindow = user32.NewProc("ShowWindow") + procReleaseCapture = user32.NewProc("ReleaseCapture") + procSendMessage = user32.NewProc("SendMessageW") ) const ( @@ -48,6 +50,8 @@ const ( swpNoZOrder = 0x0004 wmSysCommand = 0x0112 + wmNcLButtonDown = 0x00A1 + htCaption = 2 scMinimize = 0xF020 scMaximize = 0xF030 scRestore = 0xF120 @@ -125,6 +129,11 @@ func main() { removeWindowFrame(hwnd) // Bind window control functions for custom title bar buttons + // Drag: simulate title bar click to enable native window dragging + w.Bind("windowDrag", func() { + procReleaseCapture.Call() + procSendMessage.Call(hwnd, wmNcLButtonDown, htCaption, 0) + }) w.Bind("windowMinimize", func() { procPostMessage.Call(hwnd, wmSysCommand, scMinimize, 0) }) diff --git a/ui/index.html b/ui/index.html index d6deeed..74141b3 100644 --- a/ui/index.html +++ b/ui/index.html @@ -9,8 +9,8 @@
-
-
+
+
DRIVER BOOSTER @@ -24,13 +24,13 @@
- - -