From 333f641622c795a4b826d2d48aeabd5b5eab6e90 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Fri, 17 Aug 2012 14:19:36 +0300 Subject: Fix in-process QAxServers inside modal windows. The main window of in-process QAxServers doesn't have QWindow parent, but it does have native parent that is part of the native window tree of the application. The lack of Qt parent makes embedded controls look like toplevel windows, which causes problems e.g. with modality. Introduced new optional method QPlatformWindow::isEmbedded() to detect if a window is an embedded window and utilized it in proper places during modality handling. Task-number: QTBUG-26871 Change-Id: Iac9a51dae06b8fc15410de7838857e203e4275b8 Reviewed-by: Andreas Holzammer Reviewed-by: Joerg Bornemann --- src/gui/kernel/qguiapplication.cpp | 9 +++++++-- src/gui/kernel/qplatformwindow.cpp | 13 +++++++++++++ src/gui/kernel/qplatformwindow.h | 1 + 3 files changed, 21 insertions(+), 2 deletions(-) (limited to 'src/gui/kernel') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 85297dda1c..5f4cbce73b 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -604,8 +604,13 @@ QWindowList QGuiApplication::topLevelWindows() const QWindowList &list = QGuiApplicationPrivate::window_list; QWindowList topLevelWindows; for (int i = 0; i < list.size(); i++) { - if (!list.at(i)->parent()) - topLevelWindows.prepend(list.at(i)); + if (!list.at(i)->parent()) { + // Top windows of embedded QAxServers do not have QWindow parents, + // but they are not true top level windows, so do not include them. + const bool embedded = list.at(i)->handle() && list.at(i)->handle()->isEmbedded(0); + if (!embedded) + topLevelWindows.prepend(list.at(i)); + } } return topLevelWindows; } diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index d79884a1db..748a7825b6 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -174,6 +174,19 @@ bool QPlatformWindow::isActive() const return false; } +/*! + Returns true if the window is a descendant of an embedded non-Qt window. + Example of an embedded non-Qt window is the parent window of an in-process QAxServer. + + If \a parentWindow is nonzero, only check if the window is embedded in the + specified \a parentWindow. +*/ +bool QPlatformWindow::isEmbedded(const QPlatformWindow *parentWindow) const +{ + Q_UNUSED(parentWindow); + return false; +} + /*! Requests setting the window state of this surface to \a type. Returns the actual state set. diff --git a/src/gui/kernel/qplatformwindow.h b/src/gui/kernel/qplatformwindow.h index a6a519e6fd..e27851830e 100644 --- a/src/gui/kernel/qplatformwindow.h +++ b/src/gui/kernel/qplatformwindow.h @@ -103,6 +103,7 @@ public: virtual bool isExposed() const; virtual bool isActive() const; + virtual bool isEmbedded(const QPlatformWindow *parentWindow) const; virtual void propagateSizeHints(); -- cgit v1.2.3