From 1d0863049111926e0ff827cf17f3a7087d53c5c3 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Thu, 5 Dec 2019 12:51:22 +0100 Subject: Add client test for hiding the toplevel parent of a popup This used to cause undefined behavior. Task-number: QTBUG-80562 Change-Id: I0397b7b304f316616d2a713063bc5a634dc081bc Reviewed-by: Paul Olav Tvete --- tests/auto/client/xdgshell/tst_xdgshell.cpp | 45 +++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'tests/auto/client/xdgshell/tst_xdgshell.cpp') diff --git a/tests/auto/client/xdgshell/tst_xdgshell.cpp b/tests/auto/client/xdgshell/tst_xdgshell.cpp index d1c2882a0..2277bbb80 100644 --- a/tests/auto/client/xdgshell/tst_xdgshell.cpp +++ b/tests/auto/client/xdgshell/tst_xdgshell.cpp @@ -46,6 +46,7 @@ private slots: void popup(); void tooltipOnPopup(); void switchPopups(); + void hidePopupParent(); void pongs(); void minMaxSize(); void windowGeometry(); @@ -429,6 +430,50 @@ void tst_xdgshell::switchPopups() QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_xdgSurface->m_committedConfigureSerial); } +void tst_xdgshell::hidePopupParent() +{ + class Window : public QRasterWindow { + public: + void mousePressEvent(QMouseEvent *event) override + { + QRasterWindow::mousePressEvent(event); + m_popup.reset(new QRasterWindow); + m_popup->setTransientParent(this); + m_popup->setFlags(Qt::Popup); + m_popup->resize(100, 100); + m_popup->show(); + } + QScopedPointer m_popup; + }; + Window window; + window.resize(200, 200); + window.show(); + + QCOMPOSITOR_TRY_VERIFY(xdgToplevel()); + exec([=] { xdgToplevel()->sendCompleteConfigure(); }); + QCOMPOSITOR_TRY_VERIFY(xdgToplevel()->m_xdgSurface->m_committedConfigureSerial); + + exec([=] { + auto *surface = xdgToplevel()->surface(); + auto *p = pointer(); + auto *c = client(); + p->sendEnter(surface, {100, 100}); + p->sendFrame(c); + p->sendButton(c, BTN_LEFT, Pointer::button_state_pressed); + p->sendButton(c, BTN_LEFT, Pointer::button_state_released); + p->sendFrame(c); + }); + QCOMPOSITOR_TRY_VERIFY(xdgPopup()); + exec([=] { + xdgPopup()->sendConfigure(QRect(100, 100, 100, 100)); + xdgPopup()->m_xdgSurface->sendConfigure(); + }); + QCOMPOSITOR_TRY_VERIFY(xdgPopup()->m_xdgSurface->m_committedConfigureSerial); + + window.hide(); + QCOMPOSITOR_TRY_VERIFY(!xdgToplevel()); +} + void tst_xdgshell::pongs() { // Create and show a window to trigger shell integration initialzation, -- cgit v1.2.3