From d806b996beab76cbc43ffa11bc38721fa19c9c81 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Thu, 24 Jun 2010 15:02:02 +0200 Subject: No more enter & leave events after a popup menu is closed on Windows We use the TrackMouseEvent() to keep track of enter and leave messages. Upon receiving a WM_MOUSELEAVE, the effect of that function call is over, we need to call it again if we need more messages. This was not done when we close a popup because of mouse click outside. Task-number: QTBUG-11582 Reviewed-by: Bradley T. Hughes --- src/gui/kernel/qapplication_win.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index 2a85fdc..ef719ca 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -3065,6 +3065,11 @@ bool QETWidget::translateMouseEvent(const MSG &msg) break; } } +#ifndef Q_OS_WINCE + static bool trackMouseEventLookup = false; + typedef BOOL (WINAPI *PtrTrackMouseEvent)(LPTRACKMOUSEEVENT); + static PtrTrackMouseEvent ptrTrackMouseEvent = 0; +#endif state = translateButtonState(msg.wParam, type, button); // button state const QPoint widgetPos = mapFromGlobal(QPoint(msg.pt.x, msg.pt.y)); QWidget *alienWidget = !internalWinId() ? this : childAt(widgetPos); @@ -3129,9 +3134,6 @@ bool QETWidget::translateMouseEvent(const MSG &msg) #ifndef Q_OS_WINCE if (curWin != 0) { - static bool trackMouseEventLookup = false; - typedef BOOL (WINAPI *PtrTrackMouseEvent)(LPTRACKMOUSEEVENT); - static PtrTrackMouseEvent ptrTrackMouseEvent = 0; if (!trackMouseEventLookup) { trackMouseEventLookup = true; ptrTrackMouseEvent = (PtrTrackMouseEvent)QLibrary::resolve(QLatin1String("comctl32"), "_TrackMouseEvent"); @@ -3245,6 +3247,21 @@ bool QETWidget::translateMouseEvent(const MSG &msg) qt_button_down = 0; } +#ifndef Q_OS_WINCE + if (type == QEvent::MouseButtonPress + && QApplication::activePopupWidget() != activePopupWidget + && ptrTrackMouseEvent + && curWin) { + // Since curWin is already the window we clicked on, + // we have to setup the mouse tracking here. + TRACKMOUSEEVENT tme; + tme.cbSize = sizeof(TRACKMOUSEEVENT); + tme.dwFlags = 0x00000002; // TME_LEAVE + tme.hwndTrack = curWin; // Track on window receiving msgs + tme.dwHoverTime = (DWORD)-1; // HOVER_DEFAULT + ptrTrackMouseEvent(&tme); + } +#endif if (type == QEvent::MouseButtonPress && QApplication::activePopupWidget() != activePopupWidget && replayPopupMouseEvent) { -- cgit v0.12