summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBłażej Szczygieł <spaz16@wp.pl>2016-03-24 23:50:24 +0100
committerBłażej Szczygieł <spaz16@wp.pl>2016-09-12 08:38:06 +0000
commit3b8df0ea44b048b8fcc4317ffdfd074e2547a95e (patch)
treed95f2e05ebc62ca0744091c3ebd2e164297fdf91 /tests
parent66fcd0cf6674fa96ede7776ca3afa786499a07ad (diff)
QtWidgets: Send show/hide event to children on restore/minimize
Child widgets should get the show/hide event when the TLW changes its state, because child widgets are also visible or invisible. This restores the Qt4 behavior (fixes the Qt4->Qt5 regression). Restoring/minimizing the TLW now sends the spontaneous show/hide event. Show events are now handled also in the expose event handler in the QWidgetWindow class, because the show event must occur before the expose event to avoid possible flicker e.g. the OpenGL content. This can happen e.g. on XCB platform. If the "WindowStateChange" event occur before the expose event (e.g. Windows platform) then the code in expose event handler will be ignored to prevent event duplications. Added autotest. Task-number: QTBUG-50589 Change-Id: Ie9a9329b1f29bff876de28d5948d0d5fb6bc1f05 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp48
1 files changed, 43 insertions, 5 deletions
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index b7c152603c..34a1835413 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -294,6 +294,7 @@ private slots:
void showHideEvent_data();
void showHideEvent();
void showHideEventWhileMinimize();
+ void showHideChildrenWhileMinimize_QTBUG50589();
void lostUpdatesOnHide();
@@ -4078,19 +4079,30 @@ class ShowHideEventWidget : public QWidget
{
public:
int numberOfShowEvents, numberOfHideEvents;
+ int numberOfSpontaneousShowEvents, numberOfSpontaneousHideEvents;
ShowHideEventWidget(QWidget *parent = 0)
- : QWidget(parent), numberOfShowEvents(0), numberOfHideEvents(0)
+ : QWidget(parent)
+ , numberOfShowEvents(0), numberOfHideEvents(0)
+ , numberOfSpontaneousShowEvents(0), numberOfSpontaneousHideEvents(0)
{ }
void create()
{ QWidget::create(); }
- void showEvent(QShowEvent *)
- { ++numberOfShowEvents; }
+ void showEvent(QShowEvent *e)
+ {
+ ++numberOfShowEvents;
+ if (e->spontaneous())
+ ++numberOfSpontaneousShowEvents;
+ }
- void hideEvent(QHideEvent *)
- { ++numberOfHideEvents; }
+ void hideEvent(QHideEvent *e)
+ {
+ ++numberOfHideEvents;
+ if (e->spontaneous())
+ ++numberOfSpontaneousHideEvents;
+ }
};
void tst_QWidget::showHideEvent_data()
@@ -4182,6 +4194,32 @@ void tst_QWidget::showHideEventWhileMinimize()
QTRY_COMPARE(widget.numberOfShowEvents, showEventsBeforeMinimize + 1);
}
+void tst_QWidget::showHideChildrenWhileMinimize_QTBUG50589()
+{
+ const QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration();
+ if (!pi->hasCapability(QPlatformIntegration::MultipleWindows)
+ || !pi->hasCapability(QPlatformIntegration::NonFullScreenWindows)
+ || !pi->hasCapability(QPlatformIntegration::WindowManagement)) {
+ QSKIP("This test requires window management capabilities");
+ }
+
+ QWidget parent;
+ ShowHideEventWidget child(&parent);
+
+ parent.setWindowTitle(QTest::currentTestFunction());
+ parent.resize(m_testWidgetSize);
+ centerOnScreen(&parent);
+ parent.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&parent));
+
+ const int showEventsBeforeMinimize = child.numberOfSpontaneousShowEvents;
+ const int hideEventsBeforeMinimize = child.numberOfSpontaneousHideEvents;
+ parent.showMinimized();
+ QTRY_COMPARE(child.numberOfSpontaneousHideEvents, hideEventsBeforeMinimize + 1);
+ parent.showNormal();
+ QTRY_COMPARE(child.numberOfSpontaneousShowEvents, showEventsBeforeMinimize + 1);
+}
+
void tst_QWidget::update()
{
#ifdef Q_OS_OSX