mirror of
https://github.com/mpv-player/mpv
synced 2024-11-14 22:48:35 +01:00
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.)
This commit is contained in:
parent
5d47f9a565
commit
06219c7f88
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user