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 <simon.hausmann@digia.com>
This commit is contained in:
Tor Arne Vestbø 2013-12-11 14:35:48 +01:00 committed by The Qt Project
parent 848c5d01e2
commit 18b7015e86
5 changed files with 27 additions and 22 deletions

View File

@ -2147,6 +2147,26 @@ void QWindowPrivate::maybeQuitOnLastWindowClosed()
}
QWindow *QWindowPrivate::topLevelWindow() const
{
Q_Q(const QWindow);
QWindow *window = const_cast<QWindow *>(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.

View File

@ -122,6 +122,8 @@ public:
return offset;
}
QWindow *topLevelWindow() const;
virtual QWindow *eventReceiver() { Q_Q(QWindow); return q; }
void updateVisibility();

View File

@ -44,6 +44,9 @@
#include <QtGui/QGuiApplication>
#include <QtGui/QWindow>
#include <QtGui/QScreen>
#include <QtGui/private/qwindow_p.h>
#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<QIOSWindow *>(focusWindow->handle())->topLevelWindow();
return topLevel->windowState() == Qt::WindowFullScreen;
return qt_window_private(focusWindow)->topLevelWindow()->windowState() == Qt::WindowFullScreen;
}
@end

View File

@ -87,8 +87,6 @@ public:
WId winId() const { return WId(m_view); };
QWindow *topLevelWindow() const;
private:
void applyGeometry(const QRect &rect);

View File

@ -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