Skip to content

Commit

Permalink
Decorations: Adjust windows rect to have resize area outside frame
Browse files Browse the repository at this point in the history
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
  • Loading branch information
weisJ committed Aug 22, 2021
1 parent b57d03d commit c190762
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion windows/src/main/cpp/Decorations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);

Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit c190762

Please sign in to comment.