comctl32/combo: Subscribe to WM_MOUSELEAVE events.

Using WM_MOUSEMOVE events to determine whether the dropdown button is
hovered is unreliable and thus the dropdown button may stay in hovered
state even if mouse has left the window.

Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zhiyi Zhang 2021-03-03 14:48:53 +08:00 committed by Alexandre Julliard
parent 3c81ca8381
commit 161649e318
1 changed files with 20 additions and 0 deletions

View File

@ -1632,6 +1632,13 @@ static void COMBO_MouseMove( LPHEADCOMBO lphc, WPARAM wParam, LPARAM lParam )
}
}
static LRESULT COMBO_MouseLeave(LPHEADCOMBO lphc)
{
lphc->wState &= ~CBF_HOT;
RedrawWindow(lphc->self, &lphc->buttonRect, 0, RDW_INVALIDATE | RDW_UPDATENOW);
return 0;
}
static LRESULT COMBO_GetComboBoxInfo(const HEADCOMBO *lphc, COMBOBOXINFO *pcbi)
{
if (!pcbi || (pcbi->cbSize < sizeof(COMBOBOXINFO)))
@ -1871,6 +1878,7 @@ static LRESULT CALLBACK COMBO_WindowProc( HWND hwnd, UINT message, WPARAM wParam
case WM_MOUSEMOVE:
if (!IsRectEmpty(&lphc->buttonRect))
{
TRACKMOUSEEVENT event;
POINT pt;
pt.x = (short)LOWORD(lParam);
@ -1882,6 +1890,15 @@ static LRESULT CALLBACK COMBO_WindowProc( HWND hwnd, UINT message, WPARAM wParam
{
lphc->wState |= CBF_HOT;
RedrawWindow(hwnd, &lphc->buttonRect, 0, RDW_INVALIDATE | RDW_UPDATENOW);
event.cbSize = sizeof(TRACKMOUSEEVENT);
event.dwFlags = TME_QUERY;
if (!TrackMouseEvent(&event) || event.hwndTrack != hwnd || !(event.dwFlags & TME_LEAVE))
{
event.hwndTrack = hwnd;
event.dwFlags = TME_LEAVE;
TrackMouseEvent(&event);
}
}
}
else if (lphc->wState & CBF_HOT)
@ -1895,6 +1912,9 @@ static LRESULT CALLBACK COMBO_WindowProc( HWND hwnd, UINT message, WPARAM wParam
COMBO_MouseMove( lphc, wParam, lParam );
return TRUE;
case WM_MOUSELEAVE:
return COMBO_MouseLeave(lphc);
case WM_MOUSEWHEEL:
if (wParam & (MK_SHIFT | MK_CONTROL))
return DefWindowProcW(hwnd, message, wParam, lParam);