Respect the WindowDoesNotAcceptFocus flag

When the window is requested to be made active then it should check if
the window accepts focus or not. If it does not then it should ensure
it informs the underlying system that it does not accept the activate
event.

Change-Id: I3e6533be792d8bdbb2bfcdf3b9c1a93e2c67c75a
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
Andy Shaw 2013-11-26 07:23:13 +01:00 committed by The Qt Project
parent b808461854
commit 434b37323a
3 changed files with 14 additions and 1 deletions

View File

@ -73,6 +73,7 @@ enum WindowsEventType // Simplify event types
ExposeEvent = WindowEventFlag + 1, ExposeEvent = WindowEventFlag + 1,
ActivateWindowEvent = WindowEventFlag + 2, ActivateWindowEvent = WindowEventFlag + 2,
DeactivateWindowEvent = WindowEventFlag + 3, DeactivateWindowEvent = WindowEventFlag + 3,
MouseActivateWindowEvent = WindowEventFlag + 4,
LeaveEvent = WindowEventFlag + 5, LeaveEvent = WindowEventFlag + 5,
CloseEvent = WindowEventFlag + 6, CloseEvent = WindowEventFlag + 6,
ShowEvent = WindowEventFlag + 7, ShowEvent = WindowEventFlag + 7,
@ -131,6 +132,8 @@ inline QtWindows::WindowsEventType windowsEventType(UINT message, WPARAM wParamI
case WM_ACTIVATEAPP: case WM_ACTIVATEAPP:
return (int)wParamIn ? return (int)wParamIn ?
QtWindows::ActivateApplicationEvent : QtWindows::DeactivateApplicationEvent; QtWindows::ActivateApplicationEvent : QtWindows::DeactivateApplicationEvent;
case WM_MOUSEACTIVATE:
return QtWindows::MouseActivateWindowEvent;
case WM_ACTIVATE: case WM_ACTIVATE:
return LOWORD(wParamIn) == WA_INACTIVE ? return LOWORD(wParamIn) == WA_INACTIVE ?
QtWindows::DeactivateWindowEvent : QtWindows::ActivateWindowEvent; QtWindows::DeactivateWindowEvent : QtWindows::ActivateWindowEvent;

View File

@ -928,6 +928,10 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
return true; return true;
#ifndef Q_OS_WINCE #ifndef Q_OS_WINCE
case QtWindows::ActivateWindowEvent: case QtWindows::ActivateWindowEvent:
if (platformWindow->window()->flags() & Qt::WindowDoesNotAcceptFocus) {
*result = LRESULT(MA_NOACTIVATE);
return true;
}
#ifndef QT_NO_TABLETEVENT #ifndef QT_NO_TABLETEVENT
if (!d->m_tabletSupport.isNull()) if (!d->m_tabletSupport.isNull())
d->m_tabletSupport->notifyActivate(); d->m_tabletSupport->notifyActivate();
@ -936,6 +940,12 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
if (const QWindow *modalWindow = QGuiApplication::modalWindow()) if (const QWindow *modalWindow = QGuiApplication::modalWindow())
QWindowsWindow::baseWindowOf(modalWindow)->alertWindow(); QWindowsWindow::baseWindowOf(modalWindow)->alertWindow();
break; break;
case QtWindows::MouseActivateWindowEvent:
if (platformWindow->window()->flags() & Qt::WindowDoesNotAcceptFocus) {
*result = LRESULT(MA_NOACTIVATE);
return true;
}
break;
#endif #endif
#ifndef QT_NO_CONTEXTMENU #ifndef QT_NO_CONTEXTMENU
case QtWindows::ContextMenu: case QtWindows::ContextMenu:

View File

@ -1188,7 +1188,7 @@ void QWindowsWindow::hide_sys() const
if (flags & Qt::Popup) if (flags & Qt::Popup)
ShowWindow(m_data.hwnd, SW_HIDE); ShowWindow(m_data.hwnd, SW_HIDE);
else else
SetWindowPos(m_data.hwnd,0, 0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER); SetWindowPos(m_data.hwnd,0, 0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);
} }
} }