summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2012-04-11 12:07:59 +0200
committerQt by Nokia <qt-info@nokia.com>2012-04-11 19:14:43 +0200
commitce84af7c9b57f7f8cef5d57c5486b1409e13bcdd (patch)
treeaba29eda227a82a802d4c6bbe9e3dfa4465b25e7
parent54f718e55287d0cfa7e7e53473b07ca68678e7f2 (diff)
Propagate window state changes to QWidget.
Apply the state in QWidgetWindow and send an event to the widget unless the code is triggered by QWidget::setWindowState(). Change-Id: Ibf2f4e730384e41636841b9216eecfdff35b7bcb Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
-rw-r--r--src/widgets/kernel/qwidgetwindow_qpa.cpp34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/widgets/kernel/qwidgetwindow_qpa.cpp b/src/widgets/kernel/qwidgetwindow_qpa.cpp
index 6dbd3c1f77..3cccc52311 100644
--- a/src/widgets/kernel/qwidgetwindow_qpa.cpp
+++ b/src/widgets/kernel/qwidgetwindow_qpa.cpp
@@ -454,10 +454,38 @@ void QWidgetWindow::handleWindowStateChangedEvent(QWindowStateChangeEvent *event
{
// QWindow does currently not know 'active'.
Qt::WindowStates eventState = event->oldState();
- if (m_widget->windowState() & Qt::WindowActive)
+ Qt::WindowStates widgetState = m_widget->windowState();
+ if (widgetState & Qt::WindowActive)
eventState |= Qt::WindowActive;
- QWindowStateChangeEvent widgetEvent(eventState);
- QGuiApplication::sendSpontaneousEvent(m_widget, &widgetEvent);
+
+ // Determine the new widget state, remember maximized/full screen
+ // during minimized.
+ switch (windowState()) {
+ case Qt::WindowNoState:
+ widgetState &= ~(Qt::WindowMinimized | Qt::WindowMaximized | Qt::WindowFullScreen);
+ break;
+ case Qt::WindowMinimized:
+ widgetState |= Qt::WindowMinimized;
+ break;
+ case Qt::WindowMaximized:
+ widgetState &= ~Qt::WindowFullScreen;
+ widgetState |= Qt::WindowMaximized;
+ break;
+ case Qt::WindowFullScreen:
+ widgetState &= ~Qt::WindowMaximized;
+ widgetState |= Qt::WindowFullScreen;
+ break;
+ case Qt::WindowActive: // Not handled by QWindow
+ break;
+ }
+
+ // Sent event if the state changed (that is, it is not triggered by
+ // QWidget::setWindowState(), which also sends an event to the widget).
+ if (widgetState != m_widget->data->window_state) {
+ m_widget->data->window_state = widgetState;
+ QWindowStateChangeEvent widgetEvent(eventState);
+ QGuiApplication::sendSpontaneousEvent(m_widget, &widgetEvent);
+ }
}
bool QWidgetWindow::nativeEvent(const QByteArray &eventType, void *message, long *result)