From c190762ffa82f9164ed31114988e940b18a89b9c Mon Sep 17 00:00:00 2001 From: weisj <31143295+weisJ@users.noreply.github.com> Date: Sun, 22 Aug 2021 22:53:36 +0200 Subject: [PATCH] Decorations: Adjust windows rect to have resize area outside frame We should give the os enough space outside the frame to handle the resize area itself. This avoids issues with scrollbars at the window edge etc. Fixes #266 --- windows/src/main/cpp/Decorations.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/windows/src/main/cpp/Decorations.cpp b/windows/src/main/cpp/Decorations.cpp index 86c914be3..6a17ced3a 100644 --- a/windows/src/main/cpp/Decorations.cpp +++ b/windows/src/main/cpp/Decorations.cpp @@ -49,6 +49,10 @@ static bool IsLeftMousePressed(WindowWrapper *wrapper) { } } +static inline int GetFrameSize() { + return GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXPADDEDBORDER); +} + static LRESULT HandleHitTest(WindowWrapper *wrapper, int x, int y) { if (wrapper->popup_menu) return HTCLIENT; @@ -67,7 +71,7 @@ static LRESULT HandleHitTest(WindowWrapper *wrapper, int x, int y) { * The horizontal frame should be the same size as the vertical frame, * since the NONCLIENTMETRICS structure does not distinguish between them */ - int frame_size = GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXPADDEDBORDER); + int frame_size = GetFrameSize(); // The diagonal size handles are wider than the frame int diagonal_width = frame_size * 2 + GetSystemMetrics(SM_CXBORDER); @@ -226,6 +230,12 @@ static void HandleNCCalcSize(WindowWrapper *wrapper, WPARAM wparam, LPARAM lpara * before WM_NCCALCSIZE modified it. This will make the client size the * same as the non-client size. */ + if (wrapper->resizable) { + int frame_size = GetFrameSize(); + nonclient.left += frame_size; + nonclient.right -= frame_size; + nonclient.bottom -= frame_size; + } *params.rect = nonclient; } }