From 2ac50ac15621e303adbf6c35cbc2456f7ae5dd2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 25 Nov 2016 15:02:55 +0100 Subject: Split QPlatformWindow::isEmbedded into isAncestorOf to separate concerns MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The function was doing two things, both checking window ancestry and whether or the window was a direct child of non-Qt window. The former has now been split of in a QPlatformWindow::isAncestorOf(), which simplifies the code in e.g. QApplicationPrivate::isWindowBlocked(). Change-Id: I259a190e03ef8def23356005474eeeee74c9ae89 Reviewed-by: Miikka Heikkinen Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qplatformwindow.cpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'src/gui/kernel/qplatformwindow.cpp') 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; } -- cgit v1.2.3