diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2016-10-24 18:35:32 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2016-10-27 15:29:17 +0000 |
commit | 9428bca72e472e5a331976e49a68b5484ccc5f88 (patch) | |
tree | 93615311f2c3177da818c17183ea06c9b0a19b03 /src/gui/kernel/qwindow.cpp | |
parent | d020af90927261ca729d4fcd8e42276da8fb1a34 (diff) |
QWindow: re-order siblings on raise() and lower()
Same behavior as QWidget, and allows platform plugins to maintain order of
native windows based on the QWindow hierarchy, instead of having to manually
keep track of window levels.
Change-Id: Iacc7e9ee2527f0737c9da6debc7cec101064f782
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'src/gui/kernel/qwindow.cpp')
-rw-r--r-- | src/gui/kernel/qwindow.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index edb65a2d4c..95e552cf5f 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -343,6 +343,30 @@ void QWindowPrivate::updateVisibility() emit q->visibilityChanged(visibility); } +void QWindowPrivate::updateSiblingPosition(SiblingPosition position) +{ + Q_Q(QWindow); + + if (!q->parent()) + return; + + QObjectList &siblings = q->parent()->d_ptr->children; + + const int siblingCount = siblings.size() - 1; + if (siblingCount == 0) + return; + + const int currentPosition = siblings.indexOf(q); + Q_ASSERT(currentPosition >= 0); + + const int targetPosition = position == PositionTop ? siblingCount : 0; + + if (currentPosition == targetPosition) + return; + + siblings.move(currentPosition, targetPosition); +} + inline bool QWindowPrivate::windowRecreationRequired(QScreen *newScreen) const { Q_Q(const QWindow); @@ -920,6 +944,9 @@ QIcon QWindow::icon() const void QWindow::raise() { Q_D(QWindow); + + d->updateSiblingPosition(QWindowPrivate::PositionTop); + if (d->platformWindow) d->platformWindow->raise(); } @@ -932,6 +959,9 @@ void QWindow::raise() void QWindow::lower() { Q_D(QWindow); + + d->updateSiblingPosition(QWindowPrivate::PositionBottom); + if (d->platformWindow) d->platformWindow->lower(); } |