From 15335a2b37a1ba7a0ef2cfcd15f0900694f0225c Mon Sep 17 00:00:00 2001 From: qiannian Date: Sun, 14 Jun 2026 19:54:47 +0800 Subject: [PATCH] app: [Windows] restore double-click restore for custom title bars Keep custom move areas mapped to HTCAPTION even when the window is maximized so custom title bars preserve the standard Windows behavior where double-click restores the window. Signed-off-by: Elias Naur --- app/os_windows.go | 54 +++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/app/os_windows.go b/app/os_windows.go index 70aace2d..84261e67 100644 --- a/app/os_windows.go +++ b/app/os_windows.go @@ -494,34 +494,32 @@ func getModifiers() key.Modifiers { // hitTest returns the non-client area hit by the point, needed to // process WM_NCHITTEST. func (w *window) hitTest(x, y int) uintptr { - if w.config.Mode != Windowed { - // Only windowed mode should allow resizing. - return windows.HTCLIENT - } - // Check for resize handle before system actions; otherwise it can be impossible to - // resize a custom-decorations window when the system move area is flush with the - // edge of the window. - top := y <= w.borderSize.Y - bottom := y >= w.config.Size.Y-w.borderSize.Y - left := x <= w.borderSize.X - right := x >= w.config.Size.X-w.borderSize.X - switch { - case top && left: - return windows.HTTOPLEFT - case top && right: - return windows.HTTOPRIGHT - case bottom && left: - return windows.HTBOTTOMLEFT - case bottom && right: - return windows.HTBOTTOMRIGHT - case top: - return windows.HTTOP - case bottom: - return windows.HTBOTTOM - case left: - return windows.HTLEFT - case right: - return windows.HTRIGHT + if w.config.Mode == Windowed { + // Check for resize handle before system actions; otherwise it can be impossible to + // resize a custom-decorations window when the system move area is flush with the + // edge of the window. + top := y <= w.borderSize.Y + bottom := y >= w.config.Size.Y-w.borderSize.Y + left := x <= w.borderSize.X + right := x >= w.config.Size.X-w.borderSize.X + switch { + case top && left: + return windows.HTTOPLEFT + case top && right: + return windows.HTTOPRIGHT + case bottom && left: + return windows.HTBOTTOMLEFT + case bottom && right: + return windows.HTBOTTOMRIGHT + case top: + return windows.HTTOP + case bottom: + return windows.HTBOTTOM + case left: + return windows.HTLEFT + case right: + return windows.HTRIGHT + } } p := f32.Pt(float32(x), float32(y)) if a, ok := w.w.ActionAt(p); ok && a == system.ActionMove {