From 7d93b585789f680e09f7d100a2b1ba1a2a182f56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 15 Sep 2016 14:17:48 +0200 Subject: [PATCH] Fix whether a panel is supposed to have a strut in ShellClient Summary: The PanelBehavior was incorrectly mapped to hasStrut resulting in too many modes creating a strut for the panel. CCBUG: 368499 Reviewers: #kwin, #plasma_on_wayland Subscribers: plasma-devel, kwin Tags: #plasma_on_wayland, #kwin Differential Revision: https://phabricator.kde.org/D2788 --- autotests/integration/plasma_surface_test.cpp | 48 +++++++++++++++++++ shell_client.cpp | 2 +- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/autotests/integration/plasma_surface_test.cpp b/autotests/integration/plasma_surface_test.cpp index 3ff802236d..07a3d10839 100644 --- a/autotests/integration/plasma_surface_test.cpp +++ b/autotests/integration/plasma_surface_test.cpp @@ -35,6 +35,8 @@ along with this program. If not, see . using namespace KWin; using namespace KWayland::Client; +Q_DECLARE_METATYPE(KWin::Layer) + static const QString s_socketName = QStringLiteral("wayland_test_kwin_plasma_surface-0"); class PlasmaSurfaceTest : public QObject @@ -52,6 +54,8 @@ private Q_SLOTS: void testDesktopIsOpaque(); void testOSDPlacement(); + void testPanelTypeHasStrut_data(); + void testPanelTypeHasStrut(); private: ConnectionThread *m_connection = nullptr; @@ -235,5 +239,49 @@ void PlasmaSurfaceTest::testOSDPlacement() QCOMPARE(c->geometry(), QRect(590, 649, 100, 50)); } +void PlasmaSurfaceTest::testPanelTypeHasStrut_data() +{ + QTest::addColumn("type"); + QTest::addColumn("panelBehavior"); + QTest::addColumn("expectedStrut"); + QTest::addColumn("expectedMaxArea"); + QTest::addColumn("expectedLayer"); + + QTest::newRow("always visible - wlShell") << Test::ShellSurfaceType::WlShell << PlasmaShellSurface::PanelBehavior::AlwaysVisible << true << QRect(0, 50, 1280, 974) << KWin::DockLayer; + QTest::newRow("always visible - xdgShellV5") << Test::ShellSurfaceType::XdgShellV5 << PlasmaShellSurface::PanelBehavior::AlwaysVisible << true << QRect(0, 50, 1280, 974) << KWin::DockLayer; + QTest::newRow("autohide - wlShell") << Test::ShellSurfaceType::WlShell << PlasmaShellSurface::PanelBehavior::AutoHide << false << QRect(0, 0, 1280, 1024) << KWin::AboveLayer; + QTest::newRow("autohide - xdgShellV5") << Test::ShellSurfaceType::XdgShellV5 << PlasmaShellSurface::PanelBehavior::AutoHide << false << QRect(0, 0, 1280, 1024) << KWin::AboveLayer; + QTest::newRow("windows can cover - wlShell") << Test::ShellSurfaceType::WlShell << PlasmaShellSurface::PanelBehavior::WindowsCanCover << false << QRect(0, 0, 1280, 1024) << KWin::NormalLayer; + QTest::newRow("windows can cover - xdgShellV5") << Test::ShellSurfaceType::XdgShellV5 << PlasmaShellSurface::PanelBehavior::WindowsCanCover << false << QRect(0, 0, 1280, 1024) << KWin::NormalLayer; + QTest::newRow("windows go below - wlShell") << Test::ShellSurfaceType::WlShell << PlasmaShellSurface::PanelBehavior::WindowsGoBelow << false << QRect(0, 0, 1280, 1024) << KWin::DockLayer; + QTest::newRow("windows go below - xdgShellV5") << Test::ShellSurfaceType::XdgShellV5 << PlasmaShellSurface::PanelBehavior::WindowsGoBelow << false << QRect(0, 0, 1280, 1024) << KWin::DockLayer; +} + +void PlasmaSurfaceTest::testPanelTypeHasStrut() +{ + QScopedPointer surface(Test::createSurface()); + QVERIFY(!surface.isNull()); + QFETCH(Test::ShellSurfaceType, type); + QScopedPointer shellSurface(Test::createShellSurface(type, surface.data())); + QVERIFY(!shellSurface.isNull()); + QScopedPointer plasmaSurface(m_plasmaShell->createSurface(surface.data())); + QVERIFY(!plasmaSurface.isNull()); + plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); + plasmaSurface->setPosition(QPoint(0, 0)); + QFETCH(PlasmaShellSurface::PanelBehavior, panelBehavior); + plasmaSurface->setPanelBehavior(panelBehavior); + + // now render and map the window + auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); + + QVERIFY(c); + QCOMPARE(c->windowType(), NET::Dock); + QVERIFY(c->isDock()); + QCOMPARE(c->geometry(), QRect(0, 0, 100, 50)); + QTEST(c->hasStrut(), "expectedStrut"); + QTEST(workspace()->clientArea(MaximizeArea, 0, 0), "expectedMaxArea"); + QTEST(c->layer(), "expectedLayer"); +} + WAYLANDTEST_MAIN(PlasmaSurfaceTest) #include "plasma_surface_test.moc" diff --git a/shell_client.cpp b/shell_client.cpp index 3f8e6ec2b7..1b4fd849c6 100644 --- a/shell_client.cpp +++ b/shell_client.cpp @@ -1062,7 +1062,7 @@ bool ShellClient::hasStrut() const if (m_plasmaShellSurface->role() != PlasmaShellSurfaceInterface::Role::Panel) { return false; } - return m_plasmaShellSurface->panelBehavior() != PlasmaShellSurfaceInterface::PanelBehavior::WindowsGoBelow; + return m_plasmaShellSurface->panelBehavior() == PlasmaShellSurfaceInterface::PanelBehavior::AlwaysVisible; } void ShellClient::updateIcon()