diff --git a/autotests/integration/shell_client_test.cpp b/autotests/integration/shell_client_test.cpp --- a/autotests/integration/shell_client_test.cpp +++ b/autotests/integration/shell_client_test.cpp @@ -60,6 +60,8 @@ void testMaximizedToFullscreen(); void testWindowOpensLargerThanScreen_data(); void testWindowOpensLargerThanScreen(); + void testHidden_data(); + void testHidden(); }; void TestShellClient::initTestCase() @@ -544,5 +546,42 @@ QVERIFY(sizeChangeRequestedSpy.wait()); } +void TestShellClient::testHidden_data() +{ + QTest::addColumn("type"); + + QTest::newRow("wlShell") << Test::ShellSurfaceType::WlShell; + QTest::newRow("xdgShellV5") << Test::ShellSurfaceType::XdgShellV5; +} + +void TestShellClient::testHidden() +{ + // this test verifies that when hiding window it doesn't get shown + QScopedPointer surface(Test::createSurface()); + QFETCH(Test::ShellSurfaceType, type); + QScopedPointer shellSurface(Test::createShellSurface(type, surface.data())); + auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); + QVERIFY(c); + QVERIFY(c->isActive()); + QCOMPARE(workspace()->activeClient(), c); + QVERIFY(c->wantsInput()); + QVERIFY(c->wantsTabFocus()); + QVERIFY(c->isShown(true)); + + c->hideClient(true); + QVERIFY(!c->isShown(true)); + QVERIFY(!c->isActive()); + QVERIFY(c->wantsInput()); + QVERIFY(c->wantsTabFocus()); + + // unhide again + c->hideClient(false); + QVERIFY(c->isShown(true)); + QVERIFY(c->wantsInput()); + QVERIFY(c->wantsTabFocus()); + + //QCOMPARE(workspace()->activeClient(), c); +} + WAYLANDTEST_MAIN(TestShellClient) #include "shell_client_test.moc" diff --git a/shell_client.h b/shell_client.h --- a/shell_client.h +++ b/shell_client.h @@ -190,6 +190,7 @@ bool m_userNoBorder = false; bool m_fullScreen = false; bool m_transient = false; + bool m_hidden = false; bool m_internal; qreal m_opacity = 1.0; diff --git a/shell_client.cpp b/shell_client.cpp --- a/shell_client.cpp +++ b/shell_client.cpp @@ -623,12 +623,22 @@ bool ShellClient::isShown(bool shaded_is_shown) const { Q_UNUSED(shaded_is_shown) - return !m_closing && !m_unmapped && !isMinimized(); + return !m_closing && !m_unmapped && !isMinimized() && !m_hidden; } void ShellClient::hideClient(bool hide) { - Q_UNUSED(hide) + if (m_hidden == hide) { + return; + } + m_hidden = hide; + if (hide) { + addWorkspaceRepaint(visibleRect()); + workspace()->clientHidden(this); + emit windowHidden(this); + } else { + emit windowShown(this); + } } static bool changeMaximizeRecursion = false;