2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2016-06-02 15:53:44 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
|
2016-06-02 15:53:44 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2016-06-02 15:53:44 +00:00
|
|
|
#include "kwin_wayland_test.h"
|
2020-03-04 07:55:26 +00:00
|
|
|
#include "abstract_client.h"
|
2021-08-31 07:03:05 +00:00
|
|
|
#include "abstract_output.h"
|
2016-06-02 15:53:44 +00:00
|
|
|
#include "platform.h"
|
2016-09-15 19:03:40 +00:00
|
|
|
#include "cursor.h"
|
2016-08-30 11:04:10 +00:00
|
|
|
#include "screens.h"
|
2021-08-25 15:12:50 +00:00
|
|
|
#include "virtualdesktops.h"
|
2016-06-02 15:53:44 +00:00
|
|
|
#include "wayland_server.h"
|
|
|
|
#include "workspace.h"
|
|
|
|
#include <KWayland/Client/connection_thread.h>
|
|
|
|
#include <KWayland/Client/compositor.h>
|
|
|
|
#include <KWayland/Client/event_queue.h>
|
|
|
|
#include <KWayland/Client/plasmashell.h>
|
|
|
|
#include <KWayland/Client/registry.h>
|
|
|
|
#include <KWayland/Client/shm_pool.h>
|
|
|
|
#include <KWayland/Client/surface.h>
|
|
|
|
|
|
|
|
using namespace KWin;
|
|
|
|
using namespace KWayland::Client;
|
|
|
|
|
2016-09-15 12:17:48 +00:00
|
|
|
Q_DECLARE_METATYPE(KWin::Layer)
|
|
|
|
|
2016-06-02 15:53:44 +00:00
|
|
|
static const QString s_socketName = QStringLiteral("wayland_test_kwin_plasma_surface-0");
|
|
|
|
|
|
|
|
class PlasmaSurfaceTest : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
private Q_SLOTS:
|
|
|
|
void initTestCase();
|
|
|
|
void init();
|
|
|
|
void cleanup();
|
|
|
|
|
|
|
|
void testRoleOnAllDesktops_data();
|
|
|
|
void testRoleOnAllDesktops();
|
2016-06-17 06:32:15 +00:00
|
|
|
void testAcceptsFocus_data();
|
|
|
|
void testAcceptsFocus();
|
2016-06-02 15:53:44 +00:00
|
|
|
|
2016-09-15 19:03:40 +00:00
|
|
|
void testPanelWindowsCanCover_data();
|
|
|
|
void testPanelWindowsCanCover();
|
2016-08-30 11:04:10 +00:00
|
|
|
void testOSDPlacement();
|
2017-10-12 18:33:30 +00:00
|
|
|
void testOSDPlacementManualPosition();
|
2016-09-15 12:17:48 +00:00
|
|
|
void testPanelTypeHasStrut_data();
|
|
|
|
void testPanelTypeHasStrut();
|
2016-10-12 13:09:52 +00:00
|
|
|
void testPanelActivate_data();
|
|
|
|
void testPanelActivate();
|
2016-08-09 11:50:29 +00:00
|
|
|
|
2016-06-02 15:53:44 +00:00
|
|
|
private:
|
|
|
|
KWayland::Client::Compositor *m_compositor = nullptr;
|
|
|
|
PlasmaShell *m_plasmaShell = nullptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
void PlasmaSurfaceTest::initTestCase()
|
|
|
|
{
|
2020-03-04 07:55:26 +00:00
|
|
|
qRegisterMetaType<KWin::AbstractClient *>();
|
2020-07-07 09:32:29 +00:00
|
|
|
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
|
|
|
|
QVERIFY(applicationStartedSpy.isValid());
|
2016-06-02 15:53:44 +00:00
|
|
|
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
|
2020-12-09 13:06:15 +00:00
|
|
|
QVERIFY(waylandServer()->init(s_socketName));
|
2016-06-02 15:53:44 +00:00
|
|
|
kwinApp()->start();
|
2020-07-07 09:32:29 +00:00
|
|
|
QVERIFY(applicationStartedSpy.wait());
|
2016-06-02 15:53:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PlasmaSurfaceTest::init()
|
|
|
|
{
|
2016-12-03 13:31:14 +00:00
|
|
|
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::PlasmaShell));
|
2016-06-30 11:32:54 +00:00
|
|
|
m_compositor = Test::waylandCompositor();
|
|
|
|
m_plasmaShell = Test::waylandPlasmaShell();
|
2016-09-15 19:03:40 +00:00
|
|
|
|
2020-04-02 16:18:01 +00:00
|
|
|
KWin::Cursors::self()->mouse()->setPos(640, 512);
|
2016-06-02 15:53:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PlasmaSurfaceTest::cleanup()
|
|
|
|
{
|
2016-06-30 11:32:54 +00:00
|
|
|
Test::destroyWaylandConnection();
|
2016-06-02 15:53:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PlasmaSurfaceTest::testRoleOnAllDesktops_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<PlasmaShellSurface::Role>("role");
|
|
|
|
QTest::addColumn<bool>("expectedOnAllDesktops");
|
|
|
|
|
|
|
|
QTest::newRow("Desktop") << PlasmaShellSurface::Role::Desktop << true;
|
|
|
|
QTest::newRow("Panel") << PlasmaShellSurface::Role::Panel << true;
|
|
|
|
QTest::newRow("OSD") << PlasmaShellSurface::Role::OnScreenDisplay << true;
|
|
|
|
QTest::newRow("Normal") << PlasmaShellSurface::Role::Normal << false;
|
2016-06-17 07:46:16 +00:00
|
|
|
QTest::newRow("Notification") << PlasmaShellSurface::Role::Notification << true;
|
2016-06-28 11:25:15 +00:00
|
|
|
QTest::newRow("ToolTip") << PlasmaShellSurface::Role::ToolTip << true;
|
2019-05-02 08:29:38 +00:00
|
|
|
QTest::newRow("CriticalNotification") << PlasmaShellSurface::Role::CriticalNotification << true;
|
2016-06-02 15:53:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PlasmaSurfaceTest::testRoleOnAllDesktops()
|
|
|
|
{
|
2019-08-30 21:36:58 +00:00
|
|
|
// this test verifies that a XdgShellClient is set on all desktops when the role changes
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface(Test::createSurface());
|
2016-06-02 15:53:44 +00:00
|
|
|
QVERIFY(!surface.isNull());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.data()));
|
2016-06-02 15:53:44 +00:00
|
|
|
QVERIFY(!shellSurface.isNull());
|
|
|
|
QScopedPointer<PlasmaShellSurface> plasmaSurface(m_plasmaShell->createSurface(surface.data()));
|
|
|
|
QVERIFY(!plasmaSurface.isNull());
|
|
|
|
|
|
|
|
// now render to map the window
|
2016-07-01 07:54:44 +00:00
|
|
|
AbstractClient *c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
2016-06-02 15:53:44 +00:00
|
|
|
QVERIFY(c);
|
2016-07-01 07:54:44 +00:00
|
|
|
QCOMPARE(workspace()->activeClient(), c);
|
2016-06-02 15:53:44 +00:00
|
|
|
|
|
|
|
// currently the role is not yet set, so the window should not be on all desktops
|
|
|
|
QCOMPARE(c->isOnAllDesktops(), false);
|
|
|
|
|
|
|
|
// now let's try to change that
|
|
|
|
QSignalSpy onAllDesktopsSpy(c, &AbstractClient::desktopChanged);
|
|
|
|
QVERIFY(onAllDesktopsSpy.isValid());
|
|
|
|
QFETCH(PlasmaShellSurface::Role, role);
|
|
|
|
plasmaSurface->setRole(role);
|
|
|
|
QFETCH(bool, expectedOnAllDesktops);
|
|
|
|
QCOMPARE(onAllDesktopsSpy.wait(), expectedOnAllDesktops);
|
|
|
|
QCOMPARE(c->isOnAllDesktops(), expectedOnAllDesktops);
|
|
|
|
|
|
|
|
// let's create a second window where we init a little bit different
|
|
|
|
// first creating the PlasmaSurface then the Shell Surface
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface2(Test::createSurface());
|
2016-06-02 15:53:44 +00:00
|
|
|
QVERIFY(!surface2.isNull());
|
|
|
|
QScopedPointer<PlasmaShellSurface> plasmaSurface2(m_plasmaShell->createSurface(surface2.data()));
|
|
|
|
QVERIFY(!plasmaSurface2.isNull());
|
|
|
|
plasmaSurface2->setRole(role);
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface2(Test::createXdgToplevelSurface(surface2.data()));
|
2016-06-02 15:53:44 +00:00
|
|
|
QVERIFY(!shellSurface2.isNull());
|
2017-02-07 18:18:18 +00:00
|
|
|
auto c2 = Test::renderAndWaitForShown(surface2.data(), QSize(100, 50), Qt::blue);
|
|
|
|
QVERIFY(c2);
|
|
|
|
QVERIFY(c != c2);
|
|
|
|
|
|
|
|
QCOMPARE(c2->isOnAllDesktops(), expectedOnAllDesktops);
|
2016-06-02 15:53:44 +00:00
|
|
|
}
|
|
|
|
|
2016-06-17 06:32:15 +00:00
|
|
|
void PlasmaSurfaceTest::testAcceptsFocus_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<PlasmaShellSurface::Role>("role");
|
|
|
|
QTest::addColumn<bool>("wantsInput");
|
|
|
|
QTest::addColumn<bool>("active");
|
|
|
|
|
|
|
|
QTest::newRow("Desktop") << PlasmaShellSurface::Role::Desktop << true << true;
|
|
|
|
QTest::newRow("Panel") << PlasmaShellSurface::Role::Panel << true << false;
|
|
|
|
QTest::newRow("OSD") << PlasmaShellSurface::Role::OnScreenDisplay << false << false;
|
|
|
|
QTest::newRow("Normal") << PlasmaShellSurface::Role::Normal << true << true;
|
2016-06-17 07:46:16 +00:00
|
|
|
QTest::newRow("Notification") << PlasmaShellSurface::Role::Notification << false << false;
|
2016-06-28 11:25:15 +00:00
|
|
|
QTest::newRow("ToolTip") << PlasmaShellSurface::Role::ToolTip << false << false;
|
2019-05-02 08:29:38 +00:00
|
|
|
QTest::newRow("CriticalNotification") << PlasmaShellSurface::Role::CriticalNotification << false << false;
|
2016-06-17 06:32:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PlasmaSurfaceTest::testAcceptsFocus()
|
|
|
|
{
|
|
|
|
// this test verifies that some surface roles don't get focus
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface(Test::createSurface());
|
2016-06-17 06:32:15 +00:00
|
|
|
QVERIFY(!surface.isNull());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.data()));
|
2016-06-17 06:32:15 +00:00
|
|
|
QVERIFY(!shellSurface.isNull());
|
|
|
|
QScopedPointer<PlasmaShellSurface> plasmaSurface(m_plasmaShell->createSurface(surface.data()));
|
|
|
|
QVERIFY(!plasmaSurface.isNull());
|
|
|
|
QFETCH(PlasmaShellSurface::Role, role);
|
|
|
|
plasmaSurface->setRole(role);
|
|
|
|
|
|
|
|
// now render to map the window
|
2016-07-01 07:54:44 +00:00
|
|
|
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
2016-06-17 06:32:15 +00:00
|
|
|
|
|
|
|
QVERIFY(c);
|
|
|
|
QTEST(c->wantsInput(), "wantsInput");
|
|
|
|
QTEST(c->isActive(), "active");
|
|
|
|
}
|
|
|
|
|
2016-08-30 11:04:10 +00:00
|
|
|
void PlasmaSurfaceTest::testOSDPlacement()
|
|
|
|
{
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface(Test::createSurface());
|
2016-08-30 11:04:10 +00:00
|
|
|
QVERIFY(!surface.isNull());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.data()));
|
2016-08-30 11:04:10 +00:00
|
|
|
QVERIFY(!shellSurface.isNull());
|
|
|
|
QScopedPointer<PlasmaShellSurface> plasmaSurface(m_plasmaShell->createSurface(surface.data()));
|
|
|
|
QVERIFY(!plasmaSurface.isNull());
|
|
|
|
plasmaSurface->setRole(PlasmaShellSurface::Role::OnScreenDisplay);
|
|
|
|
|
|
|
|
// now render and map the window
|
|
|
|
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
|
|
|
|
|
|
|
QVERIFY(c);
|
|
|
|
QCOMPARE(c->windowType(), NET::OnScreenDisplay);
|
|
|
|
QVERIFY(c->isOnScreenDisplay());
|
2020-06-02 13:00:56 +00:00
|
|
|
QCOMPARE(c->frameGeometry(), QRect(1280 / 2 - 100 / 2, 2 * 1024 / 3 - 50 / 2, 100, 50));
|
2016-08-30 11:04:10 +00:00
|
|
|
|
|
|
|
// change the screen size
|
|
|
|
QSignalSpy screensChangedSpy(screens(), &Screens::changed);
|
|
|
|
QVERIFY(screensChangedSpy.isValid());
|
|
|
|
const QVector<QRect> geometries{QRect(0, 0, 1280, 1024), QRect(1280, 0, 1280, 1024)};
|
2018-03-19 11:05:57 +00:00
|
|
|
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs",
|
2016-08-30 11:04:10 +00:00
|
|
|
Qt::DirectConnection,
|
2018-03-19 11:05:57 +00:00
|
|
|
Q_ARG(int, 2),
|
2016-08-30 11:04:10 +00:00
|
|
|
Q_ARG(QVector<QRect>, geometries));
|
|
|
|
QVERIFY(screensChangedSpy.wait());
|
2020-12-20 13:15:57 +00:00
|
|
|
QCOMPARE(screensChangedSpy.count(), 2);
|
2021-08-31 07:03:05 +00:00
|
|
|
const auto outputs = kwinApp()->platform()->enabledOutputs();
|
|
|
|
QCOMPARE(outputs.count(), 2);
|
|
|
|
QCOMPARE(outputs[0]->geometry(), geometries[0]);
|
|
|
|
QCOMPARE(outputs[1]->geometry(), geometries[1]);
|
2016-08-30 11:04:10 +00:00
|
|
|
|
2020-06-02 13:00:56 +00:00
|
|
|
QCOMPARE(c->frameGeometry(), QRect(1280 / 2 - 100 / 2, 2 * 1024 / 3 - 50 / 2, 100, 50));
|
2016-12-18 09:39:04 +00:00
|
|
|
|
|
|
|
// change size of window
|
2020-02-05 09:28:50 +00:00
|
|
|
QSignalSpy frameGeometryChangedSpy(c, &AbstractClient::frameGeometryChanged);
|
|
|
|
QVERIFY(frameGeometryChangedSpy.isValid());
|
2016-12-18 09:39:04 +00:00
|
|
|
Test::render(surface.data(), QSize(200, 100), Qt::red);
|
2020-02-05 09:28:50 +00:00
|
|
|
QVERIFY(frameGeometryChangedSpy.wait());
|
2020-06-02 13:00:56 +00:00
|
|
|
QCOMPARE(c->frameGeometry(), QRect(1280 / 2 - 200 / 2, 2 * 1024 / 3 - 100 / 2, 200, 100));
|
2016-08-30 11:04:10 +00:00
|
|
|
}
|
|
|
|
|
2017-10-12 18:33:30 +00:00
|
|
|
void PlasmaSurfaceTest::testOSDPlacementManualPosition()
|
|
|
|
{
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface(Test::createSurface());
|
2017-10-12 18:33:30 +00:00
|
|
|
QVERIFY(!surface.isNull());
|
|
|
|
QScopedPointer<PlasmaShellSurface> plasmaSurface(m_plasmaShell->createSurface(surface.data()));
|
|
|
|
QVERIFY(!plasmaSurface.isNull());
|
|
|
|
plasmaSurface->setRole(PlasmaShellSurface::Role::OnScreenDisplay);
|
|
|
|
|
|
|
|
plasmaSurface->setPosition(QPoint(50, 70));
|
|
|
|
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.data()));
|
2017-10-12 18:33:30 +00:00
|
|
|
QVERIFY(!shellSurface.isNull());
|
|
|
|
|
|
|
|
// now render and map the window
|
|
|
|
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
|
|
|
|
|
|
|
QVERIFY(c);
|
2020-11-27 08:41:13 +00:00
|
|
|
QVERIFY(!c->isPlaceable());
|
2017-10-12 18:33:30 +00:00
|
|
|
QCOMPARE(c->windowType(), NET::OnScreenDisplay);
|
|
|
|
QVERIFY(c->isOnScreenDisplay());
|
2019-09-27 10:01:10 +00:00
|
|
|
QCOMPARE(c->frameGeometry(), QRect(50, 70, 100, 50));
|
2017-10-12 18:33:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-09-15 12:17:48 +00:00
|
|
|
void PlasmaSurfaceTest::testPanelTypeHasStrut_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<PlasmaShellSurface::PanelBehavior>("panelBehavior");
|
|
|
|
QTest::addColumn<bool>("expectedStrut");
|
|
|
|
QTest::addColumn<QRect>("expectedMaxArea");
|
|
|
|
QTest::addColumn<KWin::Layer>("expectedLayer");
|
|
|
|
|
2020-09-09 09:54:44 +00:00
|
|
|
QTest::newRow("always visible - xdgWmBase") << PlasmaShellSurface::PanelBehavior::AlwaysVisible << true << QRect(0, 50, 1280, 974) << KWin::DockLayer;
|
|
|
|
QTest::newRow("autohide - xdgWmBase") << PlasmaShellSurface::PanelBehavior::AutoHide << false << QRect(0, 0, 1280, 1024) << KWin::AboveLayer;
|
|
|
|
QTest::newRow("windows can cover - xdgWmBase") << PlasmaShellSurface::PanelBehavior::WindowsCanCover << false << QRect(0, 0, 1280, 1024) << KWin::NormalLayer;
|
|
|
|
QTest::newRow("windows go below - xdgWmBase") << PlasmaShellSurface::PanelBehavior::WindowsGoBelow << false << QRect(0, 0, 1280, 1024) << KWin::AboveLayer;
|
2016-09-15 12:17:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PlasmaSurfaceTest::testPanelTypeHasStrut()
|
|
|
|
{
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface(Test::createSurface());
|
2016-09-15 12:17:48 +00:00
|
|
|
QVERIFY(!surface.isNull());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<QObject> shellSurface(Test::createXdgToplevelSurface(surface.data()));
|
2016-09-15 12:17:48 +00:00
|
|
|
QVERIFY(!shellSurface.isNull());
|
|
|
|
QScopedPointer<PlasmaShellSurface> 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);
|
|
|
|
|
2021-08-25 15:12:50 +00:00
|
|
|
// the panel is on the first output and the current desktop
|
|
|
|
AbstractOutput *output = kwinApp()->platform()->enabledOutputs().constFirst();
|
|
|
|
VirtualDesktop *desktop = VirtualDesktopManager::self()->currentDesktop();
|
|
|
|
|
2016-09-15 12:17:48 +00:00
|
|
|
QVERIFY(c);
|
|
|
|
QCOMPARE(c->windowType(), NET::Dock);
|
|
|
|
QVERIFY(c->isDock());
|
2019-09-27 10:01:10 +00:00
|
|
|
QCOMPARE(c->frameGeometry(), QRect(0, 0, 100, 50));
|
2016-09-15 12:17:48 +00:00
|
|
|
QTEST(c->hasStrut(), "expectedStrut");
|
2021-08-25 15:12:50 +00:00
|
|
|
QTEST(workspace()->clientArea(MaximizeArea, output, desktop), "expectedMaxArea");
|
2016-09-15 12:17:48 +00:00
|
|
|
QTEST(c->layer(), "expectedLayer");
|
|
|
|
}
|
|
|
|
|
2016-09-15 19:03:40 +00:00
|
|
|
void PlasmaSurfaceTest::testPanelWindowsCanCover_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<QRect>("panelGeometry");
|
|
|
|
QTest::addColumn<QRect>("windowGeometry");
|
|
|
|
QTest::addColumn<QPoint>("triggerPoint");
|
|
|
|
|
|
|
|
QTest::newRow("top-full-edge") << QRect(0, 0, 1280, 30) << QRect(0, 0, 200, 300) << QPoint(100, 0);
|
|
|
|
QTest::newRow("top-left-edge") << QRect(0, 0, 1000, 30) << QRect(0, 0, 200, 300) << QPoint(100, 0);
|
|
|
|
QTest::newRow("top-right-edge") << QRect(280, 0, 1000, 30) << QRect(1000, 0, 200, 300) << QPoint(1000, 0);
|
|
|
|
QTest::newRow("bottom-full-edge") << QRect(0, 994, 1280, 30) << QRect(0, 724, 200, 300) << QPoint(100, 1023);
|
|
|
|
QTest::newRow("bottom-left-edge") << QRect(0, 994, 1000, 30) << QRect(0, 724, 200, 300) << QPoint(100, 1023);
|
|
|
|
QTest::newRow("bottom-right-edge") << QRect(280, 994, 1000, 30) << QRect(1000, 724, 200, 300) << QPoint(1000, 1023);
|
|
|
|
QTest::newRow("left-full-edge") << QRect(0, 0, 30, 1024) << QRect(0, 0, 200, 300) << QPoint(0, 100);
|
|
|
|
QTest::newRow("left-top-edge") << QRect(0, 0, 30, 800) << QRect(0, 0, 200, 300) << QPoint(0, 100);
|
|
|
|
QTest::newRow("left-bottom-edge") << QRect(0, 200, 30, 824) << QRect(0, 0, 200, 300) << QPoint(0, 250);
|
|
|
|
QTest::newRow("right-full-edge") << QRect(1250, 0, 30, 1024) << QRect(1080, 0, 200, 300) << QPoint(1279, 100);
|
|
|
|
QTest::newRow("right-top-edge") << QRect(1250, 0, 30, 800) << QRect(1080, 0, 200, 300) << QPoint(1279, 100);
|
|
|
|
QTest::newRow("right-bottom-edge") << QRect(1250, 200, 30, 824) << QRect(1080, 0, 200, 300) << QPoint(1279, 250);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlasmaSurfaceTest::testPanelWindowsCanCover()
|
|
|
|
{
|
|
|
|
// this test verifies the behavior of a panel with windows can cover
|
|
|
|
// triggering the screen edge should raise the panel.
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface(Test::createSurface());
|
2016-09-15 19:03:40 +00:00
|
|
|
QVERIFY(!surface.isNull());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.data()));
|
2016-09-15 19:03:40 +00:00
|
|
|
QVERIFY(!shellSurface.isNull());
|
|
|
|
QScopedPointer<PlasmaShellSurface> plasmaSurface(m_plasmaShell->createSurface(surface.data()));
|
|
|
|
QVERIFY(!plasmaSurface.isNull());
|
|
|
|
plasmaSurface->setRole(PlasmaShellSurface::Role::Panel);
|
|
|
|
QFETCH(QRect, panelGeometry);
|
|
|
|
plasmaSurface->setPosition(panelGeometry.topLeft());
|
|
|
|
plasmaSurface->setPanelBehavior(PlasmaShellSurface::PanelBehavior::WindowsCanCover);
|
|
|
|
|
|
|
|
// now render and map the window
|
|
|
|
auto panel = Test::renderAndWaitForShown(surface.data(), panelGeometry.size(), Qt::blue);
|
|
|
|
|
2021-08-25 15:12:50 +00:00
|
|
|
// the panel is on the first output and the current desktop
|
|
|
|
AbstractOutput *output = kwinApp()->platform()->enabledOutputs().constFirst();
|
|
|
|
VirtualDesktop *desktop = VirtualDesktopManager::self()->currentDesktop();
|
|
|
|
|
2016-09-15 19:03:40 +00:00
|
|
|
QVERIFY(panel);
|
|
|
|
QCOMPARE(panel->windowType(), NET::Dock);
|
|
|
|
QVERIFY(panel->isDock());
|
2019-09-27 10:01:10 +00:00
|
|
|
QCOMPARE(panel->frameGeometry(), panelGeometry);
|
2016-09-15 19:03:40 +00:00
|
|
|
QCOMPARE(panel->hasStrut(), false);
|
2021-08-25 15:12:50 +00:00
|
|
|
QCOMPARE(workspace()->clientArea(MaximizeArea, output, desktop), QRect(0, 0, 1280, 1024));
|
2016-09-15 19:03:40 +00:00
|
|
|
QCOMPARE(panel->layer(), KWin::NormalLayer);
|
|
|
|
|
|
|
|
// create a Window
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface2(Test::createSurface());
|
2016-09-15 19:03:40 +00:00
|
|
|
QVERIFY(!surface2.isNull());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface2(Test::createXdgToplevelSurface(surface2.data()));
|
2016-09-15 19:03:40 +00:00
|
|
|
QVERIFY(!shellSurface2.isNull());
|
|
|
|
|
|
|
|
QFETCH(QRect, windowGeometry);
|
|
|
|
auto c = Test::renderAndWaitForShown(surface2.data(), windowGeometry.size(), Qt::red);
|
|
|
|
|
|
|
|
QVERIFY(c);
|
|
|
|
QCOMPARE(c->windowType(), NET::Normal);
|
|
|
|
QVERIFY(c->isActive());
|
|
|
|
QCOMPARE(c->layer(), KWin::NormalLayer);
|
|
|
|
c->move(windowGeometry.topLeft());
|
2019-09-27 10:01:10 +00:00
|
|
|
QCOMPARE(c->frameGeometry(), windowGeometry);
|
2016-09-15 19:03:40 +00:00
|
|
|
|
|
|
|
auto stackingOrder = workspace()->stackingOrder();
|
|
|
|
QCOMPARE(stackingOrder.count(), 2);
|
|
|
|
QCOMPARE(stackingOrder.first(), panel);
|
|
|
|
QCOMPARE(stackingOrder.last(), c);
|
|
|
|
|
|
|
|
QSignalSpy stackingOrderChangedSpy(workspace(), &Workspace::stackingOrderChanged);
|
|
|
|
QVERIFY(stackingOrderChangedSpy.isValid());
|
|
|
|
// trigger screenedge
|
|
|
|
QFETCH(QPoint, triggerPoint);
|
2020-04-02 16:18:01 +00:00
|
|
|
KWin::Cursors::self()->mouse()->setPos(triggerPoint);
|
2020-09-24 01:53:38 +00:00
|
|
|
QVERIFY(stackingOrderChangedSpy.wait());
|
2016-09-15 19:03:40 +00:00
|
|
|
QCOMPARE(stackingOrderChangedSpy.count(), 1);
|
|
|
|
stackingOrder = workspace()->stackingOrder();
|
|
|
|
QCOMPARE(stackingOrder.count(), 2);
|
|
|
|
QCOMPARE(stackingOrder.first(), c);
|
|
|
|
QCOMPARE(stackingOrder.last(), panel);
|
|
|
|
}
|
|
|
|
|
2016-10-12 13:09:52 +00:00
|
|
|
void PlasmaSurfaceTest::testPanelActivate_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<bool>("wantsFocus");
|
|
|
|
QTest::addColumn<bool>("active");
|
|
|
|
|
|
|
|
QTest::newRow("no focus") << false << false;
|
|
|
|
QTest::newRow("focus") << true << true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlasmaSurfaceTest::testPanelActivate()
|
|
|
|
{
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface(Test::createSurface());
|
2016-10-12 13:09:52 +00:00
|
|
|
QVERIFY(!surface.isNull());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.data()));
|
2016-10-12 13:09:52 +00:00
|
|
|
QVERIFY(!shellSurface.isNull());
|
|
|
|
QScopedPointer<PlasmaShellSurface> plasmaSurface(m_plasmaShell->createSurface(surface.data()));
|
|
|
|
QVERIFY(!plasmaSurface.isNull());
|
|
|
|
plasmaSurface->setRole(PlasmaShellSurface::Role::Panel);
|
|
|
|
QFETCH(bool, wantsFocus);
|
|
|
|
plasmaSurface->setPanelTakesFocus(wantsFocus);
|
|
|
|
|
|
|
|
auto panel = Test::renderAndWaitForShown(surface.data(), QSize(100, 200), Qt::blue);
|
|
|
|
|
|
|
|
QVERIFY(panel);
|
|
|
|
QCOMPARE(panel->windowType(), NET::Dock);
|
|
|
|
QVERIFY(panel->isDock());
|
|
|
|
QFETCH(bool, active);
|
|
|
|
QCOMPARE(panel->dockWantsInput(), active);
|
|
|
|
QCOMPARE(panel->isActive(), active);
|
|
|
|
}
|
|
|
|
|
2016-06-02 15:53:44 +00:00
|
|
|
WAYLANDTEST_MAIN(PlasmaSurfaceTest)
|
|
|
|
#include "plasma_surface_test.moc"
|