mirror of
https://github.com/mpv-player/mpv
synced 2024-11-03 03:19:24 +01:00
win32: fix hit test using client rc instead window
windowrc in vo_w32_state is actually client size, for hit test we need proper window size. When border is disabled those sizes are the same, but when only title bar is disabled it is not. Reduce the hit area to more sane values when the border is not drawn to minimize amount of covered client area in borderless mode.
This commit is contained in:
parent
242066a5ef
commit
6dafc44ed0
@ -222,38 +222,42 @@ static LRESULT borderless_nchittest(struct vo_w32_state *w32, int x, int y)
|
|||||||
if (IsMaximized(w32->window))
|
if (IsMaximized(w32->window))
|
||||||
return HTCLIENT;
|
return HTCLIENT;
|
||||||
|
|
||||||
POINT mouse = { x, y };
|
RECT rc;
|
||||||
ScreenToClient(w32->window, &mouse);
|
if (!GetWindowRect(w32->window, &rc))
|
||||||
|
return HTNOWHERE;
|
||||||
|
|
||||||
// The horizontal frame should be the same size as the vertical frame,
|
POINT frame = {GetSystemMetrics(SM_CXSIZEFRAME),
|
||||||
// since the NONCLIENTMETRICS structure does not distinguish between them
|
GetSystemMetrics(SM_CYSIZEFRAME)};
|
||||||
int frame_size = GetSystemMetrics(SM_CXFRAME) +
|
if (w32->opts->border) {
|
||||||
GetSystemMetrics(SM_CXPADDEDBORDER);
|
frame.x += GetSystemMetrics(SM_CXPADDEDBORDER);
|
||||||
// The diagonal size handles are slightly wider than the side borders
|
frame.y += GetSystemMetrics(SM_CXPADDEDBORDER);
|
||||||
int diagonal_width = frame_size * 2 + GetSystemMetrics(SM_CXBORDER);
|
if (!w32->opts->title_bar)
|
||||||
|
rc.top -= GetSystemMetrics(SM_CXPADDEDBORDER);
|
||||||
|
}
|
||||||
|
InflateRect(&rc, -frame.x, -frame.y);
|
||||||
|
|
||||||
// Hit-test top border
|
// Hit-test top border
|
||||||
if (mouse.y < frame_size) {
|
if (y < rc.top) {
|
||||||
if (mouse.x < diagonal_width)
|
if (x < rc.left)
|
||||||
return HTTOPLEFT;
|
return HTTOPLEFT;
|
||||||
if (mouse.x >= rect_w(w32->windowrc) - diagonal_width)
|
if (x > rc.right)
|
||||||
return HTTOPRIGHT;
|
return HTTOPRIGHT;
|
||||||
return HTTOP;
|
return HTTOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hit-test bottom border
|
// Hit-test bottom border
|
||||||
if (mouse.y >= rect_h(w32->windowrc) - frame_size) {
|
if (y > rc.bottom) {
|
||||||
if (mouse.x < diagonal_width)
|
if (x < rc.left)
|
||||||
return HTBOTTOMLEFT;
|
return HTBOTTOMLEFT;
|
||||||
if (mouse.x >= rect_w(w32->windowrc) - diagonal_width)
|
if (x > rc.right)
|
||||||
return HTBOTTOMRIGHT;
|
return HTBOTTOMRIGHT;
|
||||||
return HTBOTTOM;
|
return HTBOTTOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hit-test side borders
|
// Hit-test side borders
|
||||||
if (mouse.x < frame_size)
|
if (x < rc.left)
|
||||||
return HTLEFT;
|
return HTLEFT;
|
||||||
if (mouse.x >= rect_w(w32->windowrc) - frame_size)
|
if (x > rc.right)
|
||||||
return HTRIGHT;
|
return HTRIGHT;
|
||||||
return HTCLIENT;
|
return HTCLIENT;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user