From 0f99c7817404e377cd056578882b97874bdea15e Mon Sep 17 00:00:00 2001 From: David Capello Date: Thu, 7 Aug 2014 08:45:51 -0300 Subject: [PATCH] Win32: Return HTCLIENT when the mouse is above scrollbars but inside the client area --- src/she/alleg4/she_alleg4.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/she/alleg4/she_alleg4.cpp b/src/she/alleg4/she_alleg4.cpp index 3101731f3..1659779e7 100644 --- a/src/she/alleg4/she_alleg4.cpp +++ b/src/she/alleg4/she_alleg4.cpp @@ -325,15 +325,25 @@ static LRESULT CALLBACK wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpara case WM_NCHITTEST: { LRESULT result = ::CallWindowProc(base_wndproc, hwnd, msg, wparam, lparam); + gfx::Point pt(GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam)); + + RECT rc; + ::GetClientRect(hwnd, &rc); + ::MapWindowPoints(hwnd, NULL, (POINT*)&rc, 2); + gfx::Rect area(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top); + + //PRINTF("NCHITTEST: %d %d - %d %d %d %d - %s\n", pt.x, pt.y, area.x, area.y, area.w, area.h, area.contains(pt) ? "true": "false"); // We ignore scrollbars so if the mouse is above them, we return - // as it's in the window resize area. (Remember that we have - // scroll bars are enabled and visible to receive trackpad - // messages only.) - if (result == HTHSCROLL) - result = HTBOTTOM; - else if (result == HTVSCROLL) - result = HTRIGHT; + // as it's in the window client or resize area. (Remember that + // we have scroll bars are enabled and visible to receive + // trackpad messages only.) + if (result == HTHSCROLL) { + result = (area.contains(pt) ? HTCLIENT: HTBOTTOM); + } + else if (result == HTVSCROLL) { + result = (area.contains(pt) ? HTCLIENT: HTRIGHT); + } return result; }