2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2017-11-16 20:48:19 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2017 Martin Flöser <mgraesslin@kde.org>
|
2017-11-16 20:48:19 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2017-11-16 20:48:19 +00:00
|
|
|
#include "kwin_wayland_test.h"
|
2022-03-23 10:13:38 +00:00
|
|
|
|
[autotests] Fix failing autotests
Summary:
After recent output-related changes testIdleInhibition and
testColorCorrectionNightColor started failing with the following output:
❯ dbus-run-session bin/testIdleInhibition
********* Start testing of TestIdleInhibition *********
Config: Using QtTest library 5.13.0, Qt 5.13.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 9.1.0)
QFATAL : TestIdleInhibition::initTestCase() ASSERT: "mode.size.isValid()" in file /home/vlad/Workspace/KDE/src/frameworks/kwayland/src/server/outputdevice_interface.cpp, line 188
FAIL! : TestIdleInhibition::initTestCase() Received a fatal error.
Loc: [Unknown file(0)]
Totals: 0 passed, 1 failed, 0 skipped, 0 blacklisted, 13ms
********* Finished testing of TestIdleInhibition ********
Apparently, they both don't initialize virtual outputs properly.
Reviewers: #kwin, romangg
Reviewed By: #kwin, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23539
2019-08-28 16:05:59 +00:00
|
|
|
#include "platform.h"
|
2021-08-12 14:16:08 +00:00
|
|
|
#include "virtualdesktops.h"
|
2022-04-22 09:27:33 +00:00
|
|
|
#include "wayland/display.h"
|
|
|
|
#include "wayland/idle_interface.h"
|
2017-11-16 20:48:19 +00:00
|
|
|
#include "wayland_server.h"
|
2022-04-22 17:39:12 +00:00
|
|
|
#include "window.h"
|
2017-11-16 20:48:19 +00:00
|
|
|
#include "workspace.h"
|
|
|
|
|
|
|
|
#include <KWayland/Client/surface.h>
|
|
|
|
|
|
|
|
using namespace KWin;
|
|
|
|
using namespace KWayland::Client;
|
2020-04-29 15:18:41 +00:00
|
|
|
using KWaylandServer::IdleInterface;
|
2017-11-16 20:48:19 +00:00
|
|
|
|
|
|
|
static const QString s_socketName = QStringLiteral("wayland_test_kwin_idle_inhbition_test-0");
|
|
|
|
|
|
|
|
class TestIdleInhibition : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
private Q_SLOTS:
|
|
|
|
void initTestCase();
|
|
|
|
void init();
|
|
|
|
void cleanup();
|
|
|
|
|
|
|
|
void testInhibit();
|
2018-12-04 09:32:37 +00:00
|
|
|
void testDontInhibitWhenNotOnCurrentDesktop();
|
|
|
|
void testDontInhibitWhenMinimized();
|
|
|
|
void testDontInhibitWhenUnmapped();
|
|
|
|
void testDontInhibitWhenLeftCurrentDesktop();
|
2017-11-16 20:48:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void TestIdleInhibition::initTestCase()
|
|
|
|
{
|
2022-04-22 17:39:12 +00:00
|
|
|
qRegisterMetaType<KWin::Window *>();
|
2017-11-16 20:48:19 +00:00
|
|
|
|
2020-07-07 09:32:29 +00:00
|
|
|
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
|
|
|
|
QVERIFY(applicationStartedSpy.isValid());
|
[autotests] Fix failing autotests
Summary:
After recent output-related changes testIdleInhibition and
testColorCorrectionNightColor started failing with the following output:
❯ dbus-run-session bin/testIdleInhibition
********* Start testing of TestIdleInhibition *********
Config: Using QtTest library 5.13.0, Qt 5.13.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 9.1.0)
QFATAL : TestIdleInhibition::initTestCase() ASSERT: "mode.size.isValid()" in file /home/vlad/Workspace/KDE/src/frameworks/kwayland/src/server/outputdevice_interface.cpp, line 188
FAIL! : TestIdleInhibition::initTestCase() Received a fatal error.
Loc: [Unknown file(0)]
Totals: 0 passed, 1 failed, 0 skipped, 0 blacklisted, 13ms
********* Finished testing of TestIdleInhibition ********
Apparently, they both don't initialize virtual outputs properly.
Reviewers: #kwin, romangg
Reviewed By: #kwin, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23539
2019-08-28 16:05:59 +00:00
|
|
|
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
|
2020-12-09 13:06:15 +00:00
|
|
|
QVERIFY(waylandServer()->init(s_socketName));
|
[autotests] Fix failing autotests
Summary:
After recent output-related changes testIdleInhibition and
testColorCorrectionNightColor started failing with the following output:
❯ dbus-run-session bin/testIdleInhibition
********* Start testing of TestIdleInhibition *********
Config: Using QtTest library 5.13.0, Qt 5.13.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 9.1.0)
QFATAL : TestIdleInhibition::initTestCase() ASSERT: "mode.size.isValid()" in file /home/vlad/Workspace/KDE/src/frameworks/kwayland/src/server/outputdevice_interface.cpp, line 188
FAIL! : TestIdleInhibition::initTestCase() Received a fatal error.
Loc: [Unknown file(0)]
Totals: 0 passed, 1 failed, 0 skipped, 0 blacklisted, 13ms
********* Finished testing of TestIdleInhibition ********
Apparently, they both don't initialize virtual outputs properly.
Reviewers: #kwin, romangg
Reviewed By: #kwin, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23539
2019-08-28 16:05:59 +00:00
|
|
|
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2));
|
2017-11-16 20:48:19 +00:00
|
|
|
|
|
|
|
kwinApp()->start();
|
2020-07-07 09:32:29 +00:00
|
|
|
QVERIFY(applicationStartedSpy.wait());
|
2021-05-08 00:08:22 +00:00
|
|
|
Test::initWaylandWorkspace();
|
2017-11-16 20:48:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestIdleInhibition::init()
|
|
|
|
{
|
2021-05-13 19:59:22 +00:00
|
|
|
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::IdleInhibitV1));
|
2017-11-16 20:48:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestIdleInhibition::cleanup()
|
|
|
|
{
|
|
|
|
Test::destroyWaylandConnection();
|
2018-12-04 09:32:37 +00:00
|
|
|
|
|
|
|
VirtualDesktopManager::self()->setCount(1);
|
|
|
|
QCOMPARE(VirtualDesktopManager::self()->count(), 1u);
|
2017-11-16 20:48:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestIdleInhibition::testInhibit()
|
|
|
|
{
|
2022-03-23 10:13:38 +00:00
|
|
|
auto idle = waylandServer()->display()->findChild<IdleInterface *>();
|
2017-11-16 20:48:19 +00:00
|
|
|
QVERIFY(idle);
|
|
|
|
QVERIFY(!idle->isInhibited());
|
|
|
|
QSignalSpy inhibitedSpy(idle, &IdleInterface::inhibitedChanged);
|
|
|
|
QVERIFY(inhibitedSpy.isValid());
|
|
|
|
|
|
|
|
// now create window
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface(Test::createSurface());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.data()));
|
2017-11-16 20:48:19 +00:00
|
|
|
|
|
|
|
// now create inhibition on window
|
2021-05-13 19:59:22 +00:00
|
|
|
QScopedPointer<Test::IdleInhibitorV1> inhibitor(Test::createIdleInhibitorV1(surface.data()));
|
|
|
|
QVERIFY(inhibitor);
|
2018-11-28 22:55:44 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// render the window
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
|
|
|
QVERIFY(window);
|
2018-11-28 22:55:44 +00:00
|
|
|
|
2017-11-16 20:48:19 +00:00
|
|
|
// this should inhibit our server object
|
|
|
|
QVERIFY(idle->isInhibited());
|
|
|
|
|
|
|
|
// deleting the object should uninhibit again
|
|
|
|
inhibitor.reset();
|
|
|
|
QVERIFY(inhibitedSpy.wait());
|
|
|
|
QVERIFY(!idle->isInhibited());
|
|
|
|
|
|
|
|
// inhibit again and destroy window
|
2021-05-13 19:59:22 +00:00
|
|
|
QScopedPointer<Test::IdleInhibitorV1> inhibitor2(Test::createIdleInhibitorV1(surface.data()));
|
2017-11-16 20:48:19 +00:00
|
|
|
QVERIFY(inhibitedSpy.wait());
|
|
|
|
QVERIFY(idle->isInhibited());
|
|
|
|
|
|
|
|
shellSurface.reset();
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(Test::waitForWindowDestroyed(window));
|
2017-11-16 20:48:19 +00:00
|
|
|
QTRY_VERIFY(!idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 4);
|
|
|
|
}
|
|
|
|
|
2018-12-04 09:32:37 +00:00
|
|
|
void TestIdleInhibition::testDontInhibitWhenNotOnCurrentDesktop()
|
|
|
|
{
|
|
|
|
// This test verifies that the idle inhibitor object is not honored when
|
|
|
|
// the associated surface is not on the current virtual desktop.
|
|
|
|
|
|
|
|
VirtualDesktopManager::self()->setCount(2);
|
|
|
|
QCOMPARE(VirtualDesktopManager::self()->count(), 2u);
|
|
|
|
|
|
|
|
// Get reference to the idle interface.
|
|
|
|
auto idle = waylandServer()->display()->findChild<IdleInterface *>();
|
|
|
|
QVERIFY(idle);
|
|
|
|
QVERIFY(!idle->isInhibited());
|
|
|
|
QSignalSpy inhibitedSpy(idle, &IdleInterface::inhibitedChanged);
|
|
|
|
QVERIFY(inhibitedSpy.isValid());
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Create the test window.
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface(Test::createSurface());
|
2018-12-04 09:32:37 +00:00
|
|
|
QVERIFY(!surface.isNull());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.data()));
|
2018-12-04 09:32:37 +00:00
|
|
|
QVERIFY(!shellSurface.isNull());
|
|
|
|
|
|
|
|
// Create the inhibitor object.
|
2021-05-13 19:59:22 +00:00
|
|
|
QScopedPointer<Test::IdleInhibitorV1> inhibitor(Test::createIdleInhibitorV1(surface.data()));
|
|
|
|
QVERIFY(inhibitor);
|
2018-12-04 09:32:37 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Render the window.
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
|
|
|
QVERIFY(window);
|
2018-12-04 09:32:37 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// The test window should be only on the first virtual desktop.
|
|
|
|
QCOMPARE(window->desktops().count(), 1);
|
|
|
|
QCOMPARE(window->desktops().first(), VirtualDesktopManager::self()->desktops().first());
|
2018-12-04 09:32:37 +00:00
|
|
|
|
|
|
|
// This should inhibit our server object.
|
|
|
|
QVERIFY(idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 1);
|
|
|
|
|
|
|
|
// Switch to the second virtual desktop.
|
|
|
|
VirtualDesktopManager::self()->setCurrent(2);
|
|
|
|
|
|
|
|
// The surface is no longer visible, so the compositor don't have to honor the
|
|
|
|
// idle inhibitor object.
|
|
|
|
QVERIFY(!idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 2);
|
|
|
|
|
|
|
|
// Switch back to the first virtual desktop.
|
|
|
|
VirtualDesktopManager::self()->setCurrent(1);
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// The test window became visible again, so the compositor has to honor the idle
|
2018-12-04 09:32:37 +00:00
|
|
|
// inhibitor object back again.
|
|
|
|
QVERIFY(idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 3);
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Destroy the test window.
|
2018-12-04 09:32:37 +00:00
|
|
|
shellSurface.reset();
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(Test::waitForWindowDestroyed(window));
|
2018-12-04 09:32:37 +00:00
|
|
|
QTRY_VERIFY(!idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestIdleInhibition::testDontInhibitWhenMinimized()
|
|
|
|
{
|
|
|
|
// This test verifies that the idle inhibitor object is not honored when the
|
|
|
|
// associated surface is minimized.
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
// Get reference to the idle interface.
|
2018-12-04 09:32:37 +00:00
|
|
|
auto idle = waylandServer()->display()->findChild<IdleInterface *>();
|
|
|
|
QVERIFY(idle);
|
|
|
|
QVERIFY(!idle->isInhibited());
|
|
|
|
QSignalSpy inhibitedSpy(idle, &IdleInterface::inhibitedChanged);
|
|
|
|
QVERIFY(inhibitedSpy.isValid());
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Create the test window.
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface(Test::createSurface());
|
2018-12-04 09:32:37 +00:00
|
|
|
QVERIFY(!surface.isNull());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.data()));
|
2018-12-04 09:32:37 +00:00
|
|
|
QVERIFY(!shellSurface.isNull());
|
|
|
|
|
|
|
|
// Create the inhibitor object.
|
2021-05-13 19:59:22 +00:00
|
|
|
QScopedPointer<Test::IdleInhibitorV1> inhibitor(Test::createIdleInhibitorV1(surface.data()));
|
|
|
|
QVERIFY(inhibitor);
|
2018-12-04 09:32:37 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Render the window.
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
|
|
|
QVERIFY(window);
|
2018-12-04 09:32:37 +00:00
|
|
|
|
|
|
|
// This should inhibit our server object.
|
|
|
|
QVERIFY(idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 1);
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Minimize the window, the idle inhibitor object should not be honored.
|
|
|
|
window->minimize();
|
2018-12-04 09:32:37 +00:00
|
|
|
QVERIFY(!idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 2);
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Unminimize the window, the idle inhibitor object should be honored back again.
|
|
|
|
window->unminimize();
|
2018-12-04 09:32:37 +00:00
|
|
|
QVERIFY(idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 3);
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Destroy the test window.
|
2018-12-04 09:32:37 +00:00
|
|
|
shellSurface.reset();
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(Test::waitForWindowDestroyed(window));
|
2018-12-04 09:32:37 +00:00
|
|
|
QTRY_VERIFY(!idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestIdleInhibition::testDontInhibitWhenUnmapped()
|
|
|
|
{
|
|
|
|
// This test verifies that the idle inhibitor object is not honored by KWin
|
2022-04-23 19:51:16 +00:00
|
|
|
// when the associated window is unmapped.
|
2018-12-04 09:32:37 +00:00
|
|
|
|
2020-05-07 14:29:41 +00:00
|
|
|
// Get reference to the idle interface.
|
2018-12-04 09:32:37 +00:00
|
|
|
auto idle = waylandServer()->display()->findChild<IdleInterface *>();
|
|
|
|
QVERIFY(idle);
|
|
|
|
QVERIFY(!idle->isInhibited());
|
|
|
|
QSignalSpy inhibitedSpy(idle, &IdleInterface::inhibitedChanged);
|
|
|
|
QVERIFY(inhibitedSpy.isValid());
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Create the test window.
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface(Test::createSurface());
|
2018-12-04 09:32:37 +00:00
|
|
|
QVERIFY(!surface.isNull());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.data()));
|
2018-12-04 09:32:37 +00:00
|
|
|
QVERIFY(!shellSurface.isNull());
|
2021-05-11 05:26:51 +00:00
|
|
|
QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested);
|
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.isValid());
|
2018-12-04 09:32:37 +00:00
|
|
|
|
|
|
|
// Create the inhibitor object.
|
2021-05-13 19:59:22 +00:00
|
|
|
QScopedPointer<Test::IdleInhibitorV1> inhibitor(Test::createIdleInhibitorV1(surface.data()));
|
|
|
|
QVERIFY(inhibitor);
|
2018-12-04 09:32:37 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Map the window.
|
2022-04-23 08:33:23 +00:00
|
|
|
QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
|
|
|
|
QVERIFY(windowAddedSpy.isValid());
|
2020-05-07 14:29:41 +00:00
|
|
|
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
2022-04-23 08:33:23 +00:00
|
|
|
QVERIFY(windowAddedSpy.isEmpty());
|
|
|
|
QVERIFY(windowAddedSpy.wait());
|
|
|
|
QCOMPARE(windowAddedSpy.count(), 1);
|
2022-04-23 19:51:16 +00:00
|
|
|
Window *window = windowAddedSpy.last().first().value<Window *>();
|
|
|
|
QVERIFY(window);
|
|
|
|
QCOMPARE(window->readyForPainting(), true);
|
2020-05-07 14:29:41 +00:00
|
|
|
|
|
|
|
// The compositor will respond with a configure event when the surface becomes active.
|
2021-05-11 05:26:51 +00:00
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 1);
|
2018-12-04 09:32:37 +00:00
|
|
|
|
|
|
|
// This should inhibit our server object.
|
|
|
|
QVERIFY(idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 1);
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Unmap the window.
|
2018-12-04 09:32:37 +00:00
|
|
|
surface->attachBuffer(Buffer::Ptr());
|
2021-09-03 17:54:03 +00:00
|
|
|
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(Test::waitForWindowDestroyed(window));
|
2018-12-04 09:32:37 +00:00
|
|
|
|
2020-05-07 14:29:41 +00:00
|
|
|
// The surface is no longer visible, so the compositor doesn't have to honor the
|
2018-12-04 09:32:37 +00:00
|
|
|
// idle inhibitor object.
|
|
|
|
QVERIFY(!idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 2);
|
|
|
|
|
2020-05-07 14:29:41 +00:00
|
|
|
// Tell the compositor that we want to map the surface.
|
2021-09-03 17:54:03 +00:00
|
|
|
surface->commit(KWayland::Client::Surface::CommitFlag::None);
|
2020-05-07 14:29:41 +00:00
|
|
|
|
|
|
|
// The compositor will respond with a configure event.
|
2021-05-11 05:26:51 +00:00
|
|
|
QVERIFY(surfaceConfigureRequestedSpy.wait());
|
|
|
|
QCOMPARE(surfaceConfigureRequestedSpy.count(), 2);
|
2020-05-07 14:29:41 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Map the window.
|
2018-12-04 09:32:37 +00:00
|
|
|
Test::render(surface.data(), QSize(100, 50), Qt::blue);
|
2022-04-23 08:33:23 +00:00
|
|
|
QVERIFY(windowAddedSpy.wait());
|
|
|
|
QCOMPARE(windowAddedSpy.count(), 2);
|
2022-04-23 19:51:16 +00:00
|
|
|
window = windowAddedSpy.last().first().value<Window *>();
|
|
|
|
QVERIFY(window);
|
|
|
|
QCOMPARE(window->readyForPainting(), true);
|
2018-12-04 09:32:37 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// The test window became visible again, so the compositor has to honor the idle
|
2018-12-04 09:32:37 +00:00
|
|
|
// inhibitor object back again.
|
|
|
|
QVERIFY(idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 3);
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Destroy the test window.
|
2018-12-04 09:32:37 +00:00
|
|
|
shellSurface.reset();
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(Test::waitForWindowDestroyed(window));
|
2018-12-04 09:32:37 +00:00
|
|
|
QTRY_VERIFY(!idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestIdleInhibition::testDontInhibitWhenLeftCurrentDesktop()
|
|
|
|
{
|
|
|
|
// This test verifies that the idle inhibitor object is not honored by KWin
|
|
|
|
// when the associated surface leaves the current virtual desktop.
|
|
|
|
|
|
|
|
VirtualDesktopManager::self()->setCount(2);
|
|
|
|
QCOMPARE(VirtualDesktopManager::self()->count(), 2u);
|
|
|
|
|
|
|
|
// Get reference to the idle interface.
|
|
|
|
auto idle = waylandServer()->display()->findChild<IdleInterface *>();
|
|
|
|
QVERIFY(idle);
|
|
|
|
QVERIFY(!idle->isInhibited());
|
|
|
|
QSignalSpy inhibitedSpy(idle, &IdleInterface::inhibitedChanged);
|
|
|
|
QVERIFY(inhibitedSpy.isValid());
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Create the test window.
|
2021-09-03 17:54:03 +00:00
|
|
|
QScopedPointer<KWayland::Client::Surface> surface(Test::createSurface());
|
2018-12-04 09:32:37 +00:00
|
|
|
QVERIFY(!surface.isNull());
|
2021-05-11 05:26:51 +00:00
|
|
|
QScopedPointer<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.data()));
|
2018-12-04 09:32:37 +00:00
|
|
|
QVERIFY(!shellSurface.isNull());
|
|
|
|
|
|
|
|
// Create the inhibitor object.
|
2021-05-13 19:59:22 +00:00
|
|
|
QScopedPointer<Test::IdleInhibitorV1> inhibitor(Test::createIdleInhibitorV1(surface.data()));
|
|
|
|
QVERIFY(inhibitor);
|
2018-12-04 09:32:37 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Render the window.
|
|
|
|
auto window = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
|
|
|
QVERIFY(window);
|
2018-12-04 09:32:37 +00:00
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// The test window should be only on the first virtual desktop.
|
|
|
|
QCOMPARE(window->desktops().count(), 1);
|
|
|
|
QCOMPARE(window->desktops().first(), VirtualDesktopManager::self()->desktops().first());
|
2018-12-04 09:32:37 +00:00
|
|
|
|
|
|
|
// This should inhibit our server object.
|
|
|
|
QVERIFY(idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 1);
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Let the window enter the second virtual desktop.
|
|
|
|
window->enterDesktop(VirtualDesktopManager::self()->desktops().at(1));
|
2018-12-04 09:32:37 +00:00
|
|
|
QCOMPARE(inhibitedSpy.count(), 1);
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// If the window leaves the first virtual desktop, then the associated idle
|
2018-12-04 09:32:37 +00:00
|
|
|
// inhibitor object should not be honored.
|
2022-04-23 19:51:16 +00:00
|
|
|
window->leaveDesktop(VirtualDesktopManager::self()->desktops().at(0));
|
2018-12-04 09:32:37 +00:00
|
|
|
QVERIFY(!idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 2);
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// If the window enters the first desktop, then the associated idle inhibitor
|
2018-12-04 09:32:37 +00:00
|
|
|
// object should be honored back again.
|
2022-04-23 19:51:16 +00:00
|
|
|
window->enterDesktop(VirtualDesktopManager::self()->desktops().at(0));
|
2018-12-04 09:32:37 +00:00
|
|
|
QVERIFY(idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 3);
|
|
|
|
|
2022-04-23 19:51:16 +00:00
|
|
|
// Destroy the test window.
|
2018-12-04 09:32:37 +00:00
|
|
|
shellSurface.reset();
|
2022-04-23 19:51:16 +00:00
|
|
|
QVERIFY(Test::waitForWindowDestroyed(window));
|
2018-12-04 09:32:37 +00:00
|
|
|
QTRY_VERIFY(!idle->isInhibited());
|
|
|
|
QCOMPARE(inhibitedSpy.count(), 4);
|
|
|
|
}
|
|
|
|
|
2017-11-16 20:48:19 +00:00
|
|
|
WAYLANDTEST_MAIN(TestIdleInhibition)
|
|
|
|
#include "idle_inhibition_test.moc"
|