diff options
author | Richard Moe Gustavsen <richard.gustavsen@digia.com> | 2012-10-09 10:52:44 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-10-17 09:39:01 +0200 |
commit | d6588d20518e6e33fdd5433d8af733657060b11e (patch) | |
tree | ffb5bcde2eec08a9cb0e4a3122c2efdcf362e822 /src/widgets | |
parent | c5b766638ac8cef1acebb97d5952485f5dc846ad (diff) |
QPlatformWindow: change API for QPlatformWindow::setWindowState
The current implementation requests the platform window to set
the window state if it can, and return the actual window state
back.
The problem with this approach is that the platform window is created
as late as possible, so a call to QWindow::setWindowState would in
many (most?) cases never be forwarded to the platform window (instead,
the platform window is responsible to check the current window state
upon creation). As such, the window state might be left unsynched with
the platform window.
This patch suggests removing the return value from
QPlatformWindow::setWindowState. This will at least be consistent, so
that setting/getting state would produce the same result independent of
delayed window creation. If needed, we can later add new API to
QPlatformIntegration or QPlatformWindow for querying supported/actual
window state.
Change-Id: Ie43f56169656854a765ce88b47a808f8f3d51bb4
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com>
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/kernel/qwidget_p.h | 2 | ||||
-rw-r--r-- | src/widgets/kernel/qwidget_qpa.cpp | 73 |
2 files changed, 0 insertions, 75 deletions
diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index c3a1d27709..8aba276966 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -803,8 +803,6 @@ public: static bool qt_widget_rgn(QWidget *, short, RgnHandle, bool); void registerTouchWindow(bool enable = true); #endif - void setMaxWindowState_helper(); - void setFullScreenSize_helper(); bool stealKeyboardGrab(bool grab); bool stealMouseGrab(bool grab); }; diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp index e7564261f9..2950c19768 100644 --- a/src/widgets/kernel/qwidget_qpa.cpp +++ b/src/widgets/kernel/qwidget_qpa.cpp @@ -586,33 +586,6 @@ void QWidgetPrivate::hide_sys() window->setVisible(false); } -void QWidgetPrivate::setMaxWindowState_helper() -{ - Q_Q(QWidget); - - const uint old_state = data.in_set_window_state; - data.in_set_window_state = 1; - - const QRect desktop = qApp->desktop()->availableGeometry(qApp->desktop()->screenNumber(q)); - q->setGeometry(desktop); - - data.in_set_window_state = old_state; -} - -void QWidgetPrivate::setFullScreenSize_helper() -{ - Q_Q(QWidget); - - const uint old_state = data.in_set_window_state; - data.in_set_window_state = 1; - - const QRect screen = qApp->desktop()->screenGeometry(qApp->desktop()->screenNumber(q)); - q->move(screen.topLeft()); - q->resize(screen.size()); - - data.in_set_window_state = old_state; -} - Qt::WindowState effectiveState(Qt::WindowStates state) { if (state & Qt::WindowMinimized) @@ -635,7 +608,6 @@ void QWidget::setWindowState(Qt::WindowStates newstate) data->window_state = newstate; data->in_set_window_state = 1; - bool needShow = false; Qt::WindowState newEffectiveState = effectiveState(newstate); Qt::WindowState oldEffectiveState = effectiveState(oldstate); if (isWindow() && newEffectiveState != oldEffectiveState) { @@ -649,54 +621,9 @@ void QWidget::setWindowState(Qt::WindowStates newstate) Q_ASSERT(windowHandle()); windowHandle()->setWindowState(newEffectiveState); - bool supported = windowHandle()->windowState() == newEffectiveState; - - if (!supported) { - const bool wasResized = testAttribute(Qt::WA_Resized); - const bool wasMoved = testAttribute(Qt::WA_Moved); - - // undo the effects of the old emulated state - if (oldEffectiveState == Qt::WindowFullScreen) { - setParent(0, d->topData()->savedFlags); - needShow = true; - } else if (oldEffectiveState == Qt::WindowMinimized) { - needShow = true; - } - - // emulate the new window state - if (newEffectiveState == Qt::WindowMinimized) { - //### not ideal... - hide(); - needShow = false; - } else if (newEffectiveState == Qt::WindowFullScreen) { - d->topData()->savedFlags = windowFlags(); - setParent(0, Qt::FramelessWindowHint | (windowFlags() & Qt::WindowStaysOnTopHint)); - d->setFullScreenSize_helper(); - raise(); - needShow = true; - } else if (newEffectiveState == Qt::WindowMaximized) { - createWinId(); - d->setMaxWindowState_helper(); - } else if (newEffectiveState == Qt::WindowNoState) { - // reset old geometry - QRect r = d->topData()->normalGeometry; - if (r.width() >= 0) { - d->topData()->normalGeometry = QRect(0,0,-1,-1); - setGeometry(r); - } - } - - // setWindowState() is not an explicit move/resize, same as the supported == true - // case - setAttribute(Qt::WA_Resized, wasResized); - setAttribute(Qt::WA_Moved, wasMoved); - } } data->in_set_window_state = 0; - if (needShow) - setVisible(true); - if (newstate & Qt::WindowActive) activateWindow(); |