diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 3cf9481..63c8e96 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1839,8 +1839,19 @@ void QWindowsWindow::requestActivateWindow() // 'Active' state handling is based in focus since it needs to work for // child windows as well. if (m_data.hwnd) { + BOOL attached = FALSE; + + HWND foregroundWindow = GetForegroundWindow(); + DWORD foregroundThread = foregroundWindow ? GetWindowThreadProcessId(foregroundWindow, NULL) : 0; + DWORD currentThread = GetCurrentThreadId(); + if(foregroundThread && foregroundThread != currentThread) + attached = AttachThreadInput( foregroundThread, currentThread, TRUE); + SetForegroundWindow(m_data.hwnd); SetFocus(m_data.hwnd); + + if(attached) + AttachThreadInput( foregroundThread, currentThread, FALSE); } }