From 06219c7f880225fdcd23885f1e9363821064012e Mon Sep 17 00:00:00 2001 From: James Ross-Gowan Date: Sun, 3 Jul 2016 16:56:52 +1000 Subject: 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.) --- video/out/w32_common.c | 28 +++++++++++++--------------- 1 file 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; } -- cgit v1.2.3