diff options
author | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2012-07-06 13:10:10 +0300 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-06 13:02:21 +0200 |
commit | dff58b47a786a84dc5145a73171be2c3db688fe1 (patch) | |
tree | b31056be9dd5522c2d6d40617d32ec83a21d4e33 /src | |
parent | 596df8e4d31fb7a9f36a71091ab6b9eb2c320a5a (diff) | |
download | qtactiveqt-dff58b47a786a84dc5145a73171be2c3db688fe1.tar.gz |
Fix embedding ActiveQt servers based on native widgets like QGLWidget
Embedding a QGLWidget based server caused QGLWidget to be shown on
a separate toplevel widget. This happened because it is a native widget
and therefore creates a platform window before it is shown, so
_q_embedded_native_parent_handle parameter we use to indicate embedded
windows got set too late and consequently QGLWidget's window didn't
know it was supposed to be embedded.
Fixed by setting the parent in WM_SHOWWINDOW handler in these cases,
and setting the window frameless, which makes platform plugin
re-determine correct native flags for the window, now also taking the
fact that the widget is embedded into account.
Task-number: QTBUG-26438
Change-Id: Id159d864376f773775114c8f00088ce90186b65a
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/activeqt/control/qaxserverbase.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/activeqt/control/qaxserverbase.cpp b/src/activeqt/control/qaxserverbase.cpp index cfc47e8..1108660 100644 --- a/src/activeqt/control/qaxserverbase.cpp +++ b/src/activeqt/control/qaxserverbase.cpp @@ -64,6 +64,7 @@ #include <olectl.h> #include <private/qcoreapplication_p.h> #include <qwindow.h> +#include <qpa/qplatformnativeinterface.h> #include "qaxfactory.h" #include "qaxbindable.h" @@ -1370,8 +1371,23 @@ LRESULT QT_WIN_CALLBACK QAxServerBase::ActiveXProc(HWND hWnd, UINT uMsg, WPARAM // Set this property on window to pass the native handle to platform plugin, // so that it can create the window with proper flags instead of thinking // it is toplevel. - if (widgetWindow) + if (widgetWindow) { widgetWindow->setProperty("_q_embedded_native_parent_handle", WId(that->m_hWnd)); + + // If embedded widget is native, such as QGLWidget, it may have already created + // a window before now, probably as an undesired toplevel. In that case set the + // proper parent window and set the window frameless to position it correctly. + if (widgetWindow + && that->qt.widget->testAttribute(Qt::WA_WState_Created) + && !that->qt.widget->isVisible()) { + HWND h = static_cast<HWND>(QGuiApplication::platformNativeInterface()-> + nativeResourceForWindow("handle", widgetWindow)); + if (h) + ::SetParent(h, that->m_hWnd); + Qt::WindowFlags flags = widgetWindow->windowFlags(); + widgetWindow->setWindowFlags(Qt::FramelessWindowHint); + } + } that->qt.widget->raise(); that->qt.widget->move(0, 0); } |