summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qplatformwindow.cpp27
-rw-r--r--src/gui/kernel/qplatformwindow.h3
-rw-r--r--src/gui/kernel/qwindow.cpp9
3 files changed, 30 insertions, 9 deletions
diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp
index bcd3e830dd..70e2c22ee1 100644
--- a/src/gui/kernel/qplatformwindow.cpp
+++ b/src/gui/kernel/qplatformwindow.cpp
@@ -192,15 +192,30 @@ bool QPlatformWindow::isActive() const
}
/*!
- Returns \c 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.
+ Returns \c true if the window is an ancestor of the given \a child.
- If \a parentWindow is nonzero, only check if the window is embedded in the
- specified \a parentWindow.
+ Platform overrides should iterate the native window hierarchy of the child,
+ to ensure that ancestary is reflected even with native windows in the window
+ hierarchy.
*/
-bool QPlatformWindow::isEmbedded(const QPlatformWindow *parentWindow) const
+bool QPlatformWindow::isAncestorOf(const QPlatformWindow *child) const
+{
+ for (const QPlatformWindow *parent = child->parent(); parent; parent = child->parent()) {
+ if (parent == this)
+ return true;
+ }
+
+ return false;
+}
+
+/*!
+ Returns \c true if the window is a child of a non-Qt window.
+
+ A embedded window has no parent platform window as reflected
+ though parent(), but will have a native parent window.
+*/
+bool QPlatformWindow::isEmbedded() const
{
- Q_UNUSED(parentWindow);
return false;
}
diff --git a/src/gui/kernel/qplatformwindow.h b/src/gui/kernel/qplatformwindow.h
index dcee4d2d84..d7fdbb156e 100644
--- a/src/gui/kernel/qplatformwindow.h
+++ b/src/gui/kernel/qplatformwindow.h
@@ -102,7 +102,8 @@ public:
virtual bool isExposed() const;
virtual bool isActive() const;
- virtual bool isEmbedded(const QPlatformWindow *parentWindow = 0) const;
+ virtual bool isAncestorOf(const QPlatformWindow *child) const;
+ virtual bool isEmbedded() const;
virtual QPoint mapToGlobal(const QPoint &pos) const;
virtual QPoint mapFromGlobal(const QPoint &pos) const;
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index 93edfe6331..5a27b19101 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -1300,8 +1300,13 @@ bool QWindow::isAncestorOf(const QWindow *child, AncestorMode mode) const
if (child->parent() == this || (mode == IncludeTransients && child->transientParent() == this))
return true;
- if (child->parent(mode) && isAncestorOf(child->parent(mode), mode))
- return true;
+ if (QWindow *parent = child->parent(mode)) {
+ if (isAncestorOf(parent, mode))
+ return true;
+ } else if (handle() && child->handle()) {
+ if (handle()->isAncestorOf(child->handle()))
+ return true;
+ }
return false;
}