From cc477e9ca6781f093fb802d15e3540ed4ef49cac Mon Sep 17 00:00:00 2001 From: Chris Waldon Date: Tue, 22 Aug 2023 10:40:45 -0400 Subject: [PATCH] app: [Windows] ensure custom window decorations allow resize This commit fixes a platform inconsistency that prevented custom-decorated windows from being resizable on edges where their custom decorations placed a draggable system.ActionInputOp. The prior behavior always checked for this action type before checking if the cursor was potentially in a window resize area, which meant that for windows with material.Decorations, it was impossible to resize those windows from their top edge. The system.ActionMove handler would always win. This is not the case on platforms like macOS, so this commit makes the behavior consistent by prioritizing resize over drag. Signed-off-by: Chris Waldon --- app/os_windows.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/os_windows.go b/app/os_windows.go index c9d98b62..cc5ca2e5 100644 --- a/app/os_windows.go +++ b/app/os_windows.go @@ -451,23 +451,18 @@ func (w *window) hitTest(x, y int) uintptr { if w.config.Mode == Fullscreen { return windows.HTCLIENT } - p := f32.Pt(float32(x), float32(y)) - if a, ok := w.w.ActionAt(p); ok && a == system.ActionMove { - return windows.HTCAPTION - } 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 { - default: - fallthrough - case !top && !bottom && !left && !right: - return windows.HTCLIENT case top && left: return windows.HTTOPLEFT case top && right: @@ -485,6 +480,11 @@ func (w *window) hitTest(x, y int) uintptr { case right: return windows.HTRIGHT } + p := f32.Pt(float32(x), float32(y)) + if a, ok := w.w.ActionAt(p); ok && a == system.ActionMove { + return windows.HTCAPTION + } + return windows.HTCLIENT } func (w *window) pointerButton(btn pointer.Buttons, press bool, lParam uintptr, kmods key.Modifiers) {