diff options
author | James Ross-Gowan <rossymiles@gmail.com> | 2016-07-03 16:56:52 +1000 |
---|---|---|
committer | James Ross-Gowan <rossymiles@gmail.com> | 2016-07-03 21:58:29 +1000 |
commit | 06219c7f880225fdcd23885f1e9363821064012e (patch) | |
tree | 119ea0dba78308d7777f9dc51e32e1e231567d19 | |
parent | 5d47f9a565ced0ecabf36bc394a8271c027cff88 (diff) |
w32_common: make WM_NCHITTEST simpler and more accurate
This makes the geometry of the sizing borders more like the ones in
Windows 10. It also fixes an off-by-one error that made the right and
bottom borders thinner than the left and top borders, which made it
difficult to resize the window when using the Windows 7 classic theme
(because it has pretty thin sizing borders to begin with.)
-rw-r--r-- | video/out/w32_common.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/video/out/w32_common.c b/video/out/w32_common.c index c29fc51dc8..e78e94157a 100644 --- a/video/out/w32_common.c +++ b/video/out/w32_common.c @@ -341,38 +341,36 @@ static LRESULT borderless_nchittest(struct vo_w32_state *w32, int x, int y) POINT mouse = { x, y }; ScreenToClient(w32->window, &mouse); + // 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); // The diagonal size handles are slightly wider than the side borders - int handle_width = GetSystemMetrics(SM_CXSMSIZE) + - GetSystemMetrics(SM_CXBORDER); + int diagonal_width = frame_size * 2 + GetSystemMetrics(SM_CXBORDER); // Hit-test top border - int frame_height = GetSystemMetrics(SM_CYFRAME) + - GetSystemMetrics(SM_CXPADDEDBORDER); - if (mouse.y < frame_height) { - if (mouse.x < handle_width) + if (mouse.y < frame_size) { + if (mouse.x < diagonal_width) return HTTOPLEFT; - if (mouse.x > w32->dw - handle_width) + if (mouse.x >= w32->dw - diagonal_width) return HTTOPRIGHT; return HTTOP; } // Hit-test bottom border - if (mouse.y > w32->dh - frame_height) { - if (mouse.x < handle_width) + if (mouse.y >= w32->dh - frame_size) { + if (mouse.x < diagonal_width) return HTBOTTOMLEFT; - if (mouse.x > w32->dw - handle_width) + if (mouse.x >= w32->dw - diagonal_width) return HTBOTTOMRIGHT; return HTBOTTOM; } // Hit-test side borders - int frame_width = GetSystemMetrics(SM_CXFRAME) + - GetSystemMetrics(SM_CXPADDEDBORDER); - if (mouse.x < frame_width) + if (mouse.x < frame_size) return HTLEFT; - if (mouse.x > w32->dw - frame_width) + if (mouse.x >= w32->dw - frame_size) return HTRIGHT; - return HTCLIENT; } |