path: root/src
diff options
authorDominik Haumann <>2018-01-29 19:38:49 +0100
committerDominik Haumann <>2018-02-02 10:40:21 +0000
commit1f0c22844811d71fae69ee6b103bbfc5e750ca90 (patch)
treef152222ca3b67552d50dbd763978991ad2de071c /src
parentb44df9937e4b15596b994f8e20822b83ac4bed29 (diff)
Fix window activation in QWindowsWindow::setCustomMargins()
Currently, code paths that call QWindowsWindow:setCustomMargins() automatically also activate the window (=give the window focus). The reason for this is the call of SetWindowPos (Windows API) without the flag SWP_NOACTIVATE. From the Windows API documentation about SetWindowPos() about the flag SWP_NOACTIVATE: Does not activate the window. If this flag is not set, the window is activated and moved to the top of either the topmost or non-topmost group (depending on the setting of the hWndInsertAfter parameter). It seems the flag SWP_NOACTIVATE is accidentally missing in the call of SetWindowPos() in setCustomMargins(), especially since the flag is present in pretty much all other calls of SetWindowPos(). The obvious fix is to add the flag SWP_NOACTIVATE to the call of SetWindowPos() in setCustomMargins(). So far, this issue exists for a long time, an was possibly introduced with commit f5fd5346038, where setCustomMargins() was initially added. Change-Id: Id3f058f8762df17eb3f033ab0b3e1791283937fc Reviewed-by: Friedemann Kleint <>
Diffstat (limited to 'src')
1 files changed, 1 insertions, 1 deletions
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 402009c70d..c1aeecf0ab 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -2401,7 +2401,7 @@ void QWindowsWindow::setCustomMargins(const QMargins &newCustomMargins)
qCDebug(lcQpaWindows) << __FUNCTION__ << oldCustomMargins << "->" << newCustomMargins
<< currentFrameGeometry << "->" << newFrame;
- SetWindowPos(m_data.hwnd, 0, newFrame.x(), newFrame.y(), newFrame.width(), newFrame.height(), SWP_NOZORDER | SWP_FRAMECHANGED);
+ SetWindowPos(m_data.hwnd, 0, newFrame.x(), newFrame.y(), newFrame.width(), newFrame.height(), SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOACTIVATE);