summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowswindow.cpp
diff options
context:
space:
mode:
authorAndre de la Rocha <andre.rocha@qt.io>2017-11-20 17:04:00 +0100
committerAndre de la Rocha <andre.rocha@qt.io>2017-11-21 20:47:18 +0000
commit04da02743918d217fc8b760f679d7970a5965a2f (patch)
treedaa3d1db9b4dfeead3ad77fe3e92283b4b91ec36 /src/plugins/platforms/windows/qwindowswindow.cpp
parentb8e352ad378ce4ef7a517971533b02ec9c3768cb (diff)
Windows QPA: Detect a SetParent into a native window and set isEmbedded
Detecting that a Qt window has been reparented into a native window and setting isEmbedded automatically. While there is no specific message for the change in the parent window, a WM_WINDOWPOSCHANGING message indicating a change in the Z order is sent. We can recognize an embedding condition by detecting that our QWindow does not have another QWindow as a parent, but the HWND associated with it has another HWND as a parent, which is not the desktop window. This change should cover the use case where a Qt-based plugin must return a HWND to a host application, where the host application will then reparent the HWND as it sees fit, outside of Qt control. Task-number: QTBUG-64116 Change-Id: Iec417c0dd55ad68eff1ea75bb6f5b5495489c31e Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowswindow.cpp')
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 24eab2c662..8702ce7bab 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -2070,9 +2070,17 @@ void QWindowsWindow::propagateSizeHints()
bool QWindowsWindow::handleGeometryChangingMessage(MSG *message, const QWindow *qWindow, const QMargins &margins)
{
+ WINDOWPOS *windowPos = reinterpret_cast<WINDOWPOS *>(message->lParam);
+ if ((windowPos->flags & SWP_NOZORDER) == 0) {
+ if (QWindowsWindow *platformWindow = QWindowsWindow::windowsWindowOf(qWindow)) {
+ QWindow *parentWindow = qWindow->parent();
+ HWND parentHWND = GetAncestor(windowPos->hwnd, GA_PARENT);
+ HWND desktopHWND = GetDesktopWindow();
+ platformWindow->m_data.embedded = !parentWindow && parentHWND && (parentHWND != desktopHWND);
+ }
+ }
if (!qWindow->isTopLevel()) // Implement hasHeightForWidth().
return false;
- WINDOWPOS *windowPos = reinterpret_cast<WINDOWPOS *>(message->lParam);
if ((windowPos->flags & (SWP_NOCOPYBITS | SWP_NOSIZE)))
return false;
const QRect suggestedFrameGeometry(windowPos->x, windowPos->y,