From b059c9138872900ab42847f46797dce676f77dff Mon Sep 17 00:00:00 2001 From: messypy Date: Mon, 27 Jul 2026 23:45:09 +0900 Subject: [PATCH] Enable custom window control buttons --- cmd/vrc_osc_gui/window_windows.go | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/cmd/vrc_osc_gui/window_windows.go b/cmd/vrc_osc_gui/window_windows.go index 5e1cb4f..0e07709 100644 --- a/cmd/vrc_osc_gui/window_windows.go +++ b/cmd/vrc_osc_gui/window_windows.go @@ -140,6 +140,7 @@ var hwndNoZOrder uintptr = 0x0004 var hwndNoSize uintptr = 0x0001 var hwndNoActivate uintptr = 0x0010 var hwndShowWindow uintptr = 0x0040 +var swMinimize uintptr = 6 var swRestore uintptr = 9 var swHideControl uintptr = 0 var swShowControl uintptr = 5 @@ -794,8 +795,25 @@ func runNativeGUI(initialTab string) error { width = rc.Right } } - if x >= width-42 && x <= width-22 && y >= 12 && y <= 32 { - guiLog("close button ignored to keep GUI visible") + switch { + case pointInHeaderDot(x, y, width-92, 22): + guiLog("window control minimize") + if showWindowProc != nil { + showWindowProc.Call(hwnd, swMinimize) + } + return 0 + case pointInHeaderDot(x, y, width-62, 22): + guiLog("window control topmost toggle") + app.topMost = !app.topMost + saveGUISettings(&app) + applyTopMost(hwnd, &app) + if invalidateRectProc != nil { + invalidateRectProc.Call(hwnd, 0, 1) + } + return 0 + case pointInHeaderDot(x, y, width-32, 22): + guiLog("window control close") + postQuitMessage.Call(0) return 0 } releaseCapture.Call() @@ -898,7 +916,8 @@ func runNativeGUI(initialTab string) error { postQuitMessage.Call(0) return 0 case wmCloseGUI: - guiLog("wmClose ignored to keep GUI visible") + guiLog("wmClose received") + postQuitMessage.Call(0) return 0 } ret, _, _ := defWindowProc.Call(hwnd, uintptr(message), wParam, lParam) @@ -1732,6 +1751,10 @@ func paintMainWindow(hwnd uintptr, app *guiApp) uintptr { return 0 } +func pointInHeaderDot(x, y, cx, cy int32) bool { + return x >= cx-11 && x <= cx+11 && y >= cy-11 && y <= cy+11 +} + func paintFooter(hdc uintptr, rc winRect, app *guiApp) { if app == nil { return