summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qguiapplication.cpp
diff options
context:
space:
mode:
authorAxel Spoerl <axel.spoerl@qt.io>2022-10-28 15:23:41 +0200
committerAxel Spoerl <axel.spoerl@qt.io>2022-11-11 11:21:32 +0100
commit52dcd47850138ac257e3ad7e6eeae205bcff4aa6 (patch)
tree9956dc42b22bfff88db21ece78acb29ed168723f /src/gui/kernel/qguiapplication.cpp
parentb58876c296a5a87f50d5e554afc277e5bc752a16 (diff)
emit QWindow::windowStateChanged only when state has changed
Upon programmatic window state changes, windowStateChange was fired once in QWindow::setWindowStates and once when the visual state had been changed by the window interface. This patch adds if guards to ensure that the singal is fired only once. It adds a corresponding autotest to tst_QWindow. tst_QWidget::resizePropagation() is adapted to no longer expect double signal emission. Fixes: QTBUG-102478 Pick-to: 6.4 6.2 Change-Id: If093c0a883d76d8a676e4fab90db6b0676452267 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/gui/kernel/qguiapplication.cpp')
-rw-r--r--src/gui/kernel/qguiapplication.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 36030cac42..c721cfd802 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -2509,11 +2509,16 @@ void QGuiApplicationPrivate::processWindowStateChangedEvent(QWindowSystemInterfa
{
if (QWindow *window = wse->window.data()) {
QWindowPrivate *windowPrivate = qt_window_private(window);
- const auto newEffectiveState = QWindowPrivate::effectiveState(windowPrivate->windowState);
- QWindowStateChangeEvent e(wse->oldState);
+ const auto originalEffectiveState = QWindowPrivate::effectiveState(windowPrivate->windowState);
+
windowPrivate->windowState = wse->newState;
- emit window->windowStateChanged(newEffectiveState);
+ const auto newEffectiveState = QWindowPrivate::effectiveState(windowPrivate->windowState);
+ if (newEffectiveState != originalEffectiveState)
+ emit window->windowStateChanged(newEffectiveState);
+
windowPrivate->updateVisibility();
+
+ QWindowStateChangeEvent e(wse->oldState);
QGuiApplication::sendSpontaneousEvent(window, &e);
}
}