Fix QWindowsWindow::requestActivateWindow()

QWindowsWindow::requestActivateWindow() does not work correct if
QWindowsWindowFunctions::AlwaysActivateWindow is passed as a parameter
to QWindowsWindowFunctions::setWindowActivationBehavior().
When the calling process is not the active process, only the taskbar
entry is flashed. It is not correct. The window should be always
activated, even when the calling process is not the active process.

Task-number: QTBUG-37435
Task-number: QTBUG-14062
Change-Id: I7a321d7bac744a7776278210b1b5a2fd4288aa43
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
bb10
Sergiy Korobov 2018-06-05 14:27:52 +03:00 committed by Sergiy Korobov (Viking Software)
parent 2b8287b666
commit 7b79798275
1 changed files with 9 additions and 0 deletions

View File

@ -2201,6 +2201,15 @@ void QWindowsWindow::requestActivateWindow()
foregroundThread = GetWindowThreadProcessId(foregroundWindow, NULL);
if (foregroundThread && foregroundThread != currentThread)
attached = AttachThreadInput(foregroundThread, currentThread, TRUE) == TRUE;
if (attached) {
if (!window()->flags().testFlag(Qt::WindowStaysOnBottomHint)
&& !window()->flags().testFlag(Qt::WindowStaysOnTopHint)
&& window()->type() != Qt::ToolTip) {
const UINT swpFlags = SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER;
SetWindowPos(m_data.hwnd, HWND_TOPMOST, 0, 0, 0, 0, swpFlags);
SetWindowPos(m_data.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, swpFlags);
}
}
}
}
SetForegroundWindow(m_data.hwnd);