From 18b7015e86bf621df1f54beb474d67123e18f0ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 11 Dec 2013 14:35:48 +0100 Subject: [PATCH] Add QWindowPrivate::topLevelWindow() helper function Might be useful to expose to QWindow in 5.3, but for now it's private so it can be used by platform plugins. Change-Id: Iad96d7e249a7b85695668f8d7e8918164ec67442 Reviewed-by: Simon Hausmann --- src/gui/kernel/qwindow.cpp | 20 +++++++++++++++++++ src/gui/kernel/qwindow_p.h | 2 ++ .../platforms/ios/qiosviewcontroller.mm | 8 +++++--- src/plugins/platforms/ios/qioswindow.h | 2 -- src/plugins/platforms/ios/qioswindow.mm | 17 ---------------- 5 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 2e1d8f9976..4c74a0b834 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -2147,6 +2147,26 @@ void QWindowPrivate::maybeQuitOnLastWindowClosed() } +QWindow *QWindowPrivate::topLevelWindow() const +{ + Q_Q(const QWindow); + + QWindow *window = const_cast(q); + + while (window) { + QWindow *parent = window->parent(); + if (!parent) + parent = window->transientParent(); + + if (!parent) + break; + + window = parent; + } + + return window; +} + /*! Creates a local representation of a window created by another process or by using native libraries below Qt. diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h index 8d8fca3ce6..8ebbf5d508 100644 --- a/src/gui/kernel/qwindow_p.h +++ b/src/gui/kernel/qwindow_p.h @@ -122,6 +122,8 @@ public: return offset; } + QWindow *topLevelWindow() const; + virtual QWindow *eventReceiver() { Q_Q(QWindow); return q; } void updateVisibility(); diff --git a/src/plugins/platforms/ios/qiosviewcontroller.mm b/src/plugins/platforms/ios/qiosviewcontroller.mm index 0a6a00b753..2fe679fc20 100644 --- a/src/plugins/platforms/ios/qiosviewcontroller.mm +++ b/src/plugins/platforms/ios/qiosviewcontroller.mm @@ -44,6 +44,9 @@ #include #include #include + +#include + #include "qiosscreen.h" #include "qiosglobal.h" #include "qioswindow.h" @@ -105,11 +108,10 @@ if (hiddenFromPlist) return YES; QWindow *focusWindow = QGuiApplication::focusWindow(); - if (!focusWindow || !focusWindow->handle()) + if (!focusWindow) return [UIApplication sharedApplication].statusBarHidden; - QWindow *topLevel = static_cast(focusWindow->handle())->topLevelWindow(); - return topLevel->windowState() == Qt::WindowFullScreen; + return qt_window_private(focusWindow)->topLevelWindow()->windowState() == Qt::WindowFullScreen; } @end diff --git a/src/plugins/platforms/ios/qioswindow.h b/src/plugins/platforms/ios/qioswindow.h index 8a5eb589d2..fc99543aa6 100644 --- a/src/plugins/platforms/ios/qioswindow.h +++ b/src/plugins/platforms/ios/qioswindow.h @@ -87,8 +87,6 @@ public: WId winId() const { return WId(m_view); }; - QWindow *topLevelWindow() const; - private: void applyGeometry(const QRect &rect); diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index 7a0ff055ec..15a52e89ec 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -636,23 +636,6 @@ void QIOSWindow::setParent(const QPlatformWindow *parentWindow) } } -QWindow *QIOSWindow::topLevelWindow() const -{ - QWindow *window = this->window(); - while (window) { - QWindow *parent = window->parent(); - if (!parent) - parent = window->transientParent(); - - if (!parent) - break; - - window = parent; - } - - return window; -} - void QIOSWindow::requestActivateWindow() { // Note that several windows can be active at the same time if they exist in the same