autotests: Introduce own idle inhibit v1 helpers
Non-core wrappers in kwayland are deprecated. qtwaylandscanner needs to be used instead for generating client-side wrappers.
This commit is contained in:
parent
b9b58b6e66
commit
b6dd7c5860
4 changed files with 68 additions and 32 deletions
|
@ -27,6 +27,10 @@ ecm_add_qtwayland_client_protocol(KWinIntegrationTestFramework_SOURCES
|
|||
PROTOCOL ${WaylandProtocols_DATADIR}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml
|
||||
BASENAME xdg-decoration-unstable-v1
|
||||
)
|
||||
ecm_add_qtwayland_client_protocol(KWinIntegrationTestFramework_SOURCES
|
||||
PROTOCOL ${WaylandProtocols_DATADIR}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml
|
||||
BASENAME idle-inhibit-unstable-v1
|
||||
)
|
||||
add_library(KWinIntegrationTestFramework STATIC ${KWinIntegrationTestFramework_SOURCES})
|
||||
target_link_libraries(KWinIntegrationTestFramework
|
||||
Qt::Test
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include "wayland_server.h"
|
||||
#include "workspace.h"
|
||||
|
||||
#include <KWayland/Client/idleinhibit.h>
|
||||
#include <KWayland/Client/surface.h>
|
||||
|
||||
#include <KWaylandServer/display.h>
|
||||
|
@ -56,7 +55,7 @@ void TestIdleInhibition::initTestCase()
|
|||
|
||||
void TestIdleInhibition::init()
|
||||
{
|
||||
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::IdleInhibition));
|
||||
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::IdleInhibitV1));
|
||||
|
||||
}
|
||||
|
||||
|
@ -81,8 +80,8 @@ void TestIdleInhibition::testInhibit()
|
|||
QScopedPointer<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.data()));
|
||||
|
||||
// now create inhibition on window
|
||||
QScopedPointer<IdleInhibitor> inhibitor(Test::waylandIdleInhibitManager()->createInhibitor(surface.data()));
|
||||
QVERIFY(inhibitor->isValid());
|
||||
QScopedPointer<Test::IdleInhibitorV1> inhibitor(Test::createIdleInhibitorV1(surface.data()));
|
||||
QVERIFY(inhibitor);
|
||||
|
||||
// render the client
|
||||
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
||||
|
@ -97,7 +96,7 @@ void TestIdleInhibition::testInhibit()
|
|||
QVERIFY(!idle->isInhibited());
|
||||
|
||||
// inhibit again and destroy window
|
||||
Test::waylandIdleInhibitManager()->createInhibitor(surface.data(), surface.data());
|
||||
QScopedPointer<Test::IdleInhibitorV1> inhibitor2(Test::createIdleInhibitorV1(surface.data()));
|
||||
QVERIFY(inhibitedSpy.wait());
|
||||
QVERIFY(idle->isInhibited());
|
||||
|
||||
|
@ -129,8 +128,8 @@ void TestIdleInhibition::testDontInhibitWhenNotOnCurrentDesktop()
|
|||
QVERIFY(!shellSurface.isNull());
|
||||
|
||||
// Create the inhibitor object.
|
||||
QScopedPointer<IdleInhibitor> inhibitor(Test::waylandIdleInhibitManager()->createInhibitor(surface.data()));
|
||||
QVERIFY(inhibitor->isValid());
|
||||
QScopedPointer<Test::IdleInhibitorV1> inhibitor(Test::createIdleInhibitorV1(surface.data()));
|
||||
QVERIFY(inhibitor);
|
||||
|
||||
// Render the client.
|
||||
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
||||
|
@ -186,8 +185,8 @@ void TestIdleInhibition::testDontInhibitWhenMinimized()
|
|||
QVERIFY(!shellSurface.isNull());
|
||||
|
||||
// Create the inhibitor object.
|
||||
QScopedPointer<IdleInhibitor> inhibitor(Test::waylandIdleInhibitManager()->createInhibitor(surface.data()));
|
||||
QVERIFY(inhibitor->isValid());
|
||||
QScopedPointer<Test::IdleInhibitorV1> inhibitor(Test::createIdleInhibitorV1(surface.data()));
|
||||
QVERIFY(inhibitor);
|
||||
|
||||
// Render the client.
|
||||
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
||||
|
@ -235,8 +234,8 @@ void TestIdleInhibition::testDontInhibitWhenUnmapped()
|
|||
QVERIFY(surfaceConfigureRequestedSpy.isValid());
|
||||
|
||||
// Create the inhibitor object.
|
||||
QScopedPointer<IdleInhibitor> inhibitor(Test::waylandIdleInhibitManager()->createInhibitor(surface.data()));
|
||||
QVERIFY(inhibitor->isValid());
|
||||
QScopedPointer<Test::IdleInhibitorV1> inhibitor(Test::createIdleInhibitorV1(surface.data()));
|
||||
QVERIFY(inhibitor);
|
||||
|
||||
// Map the client.
|
||||
QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded);
|
||||
|
@ -316,8 +315,8 @@ void TestIdleInhibition::testDontInhibitWhenLeftCurrentDesktop()
|
|||
QVERIFY(!shellSurface.isNull());
|
||||
|
||||
// Create the inhibitor object.
|
||||
QScopedPointer<IdleInhibitor> inhibitor(Test::waylandIdleInhibitManager()->createInhibitor(surface.data()));
|
||||
QVERIFY(inhibitor->isValid());
|
||||
QScopedPointer<Test::IdleInhibitorV1> inhibitor(Test::createIdleInhibitorV1(surface.data()));
|
||||
QVERIFY(inhibitor);
|
||||
|
||||
// Render the client.
|
||||
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
// Qt
|
||||
#include <QtTest>
|
||||
|
||||
#include "qwayland-idle-inhibit-unstable-v1.h"
|
||||
#include "qwayland-wlr-layer-shell-unstable-v1.h"
|
||||
#include "qwayland-text-input-unstable-v3.h"
|
||||
#include "qwayland-xdg-decoration-unstable-v1.h"
|
||||
|
@ -26,7 +27,6 @@ namespace Client
|
|||
class AppMenuManager;
|
||||
class ConnectionThread;
|
||||
class Compositor;
|
||||
class IdleInhibitManager;
|
||||
class Output;
|
||||
class PlasmaShell;
|
||||
class PlasmaWindowManagement;
|
||||
|
@ -247,13 +247,26 @@ protected:
|
|||
void zxdg_toplevel_decoration_v1_configure(uint32_t mode) override;
|
||||
};
|
||||
|
||||
class IdleInhibitManagerV1 : public QtWayland::zwp_idle_inhibit_manager_v1
|
||||
{
|
||||
public:
|
||||
~IdleInhibitManagerV1() override;
|
||||
};
|
||||
|
||||
class IdleInhibitorV1 : public QtWayland::zwp_idle_inhibitor_v1
|
||||
{
|
||||
public:
|
||||
IdleInhibitorV1(IdleInhibitManagerV1 *manager, KWayland::Client::Surface *surface);
|
||||
~IdleInhibitorV1() override;
|
||||
};
|
||||
|
||||
enum class AdditionalWaylandInterface {
|
||||
Seat = 1 << 0,
|
||||
Decoration = 1 << 1,
|
||||
PlasmaShell = 1 << 2,
|
||||
WindowManagement = 1 << 3,
|
||||
PointerConstraints = 1 << 4,
|
||||
IdleInhibition = 1 << 5,
|
||||
IdleInhibitV1 = 1 << 5,
|
||||
AppMenu = 1 << 6,
|
||||
ShadowManager = 1 << 7,
|
||||
XdgDecorationV1 = 1 << 8,
|
||||
|
@ -291,7 +304,6 @@ KWayland::Client::ServerSideDecorationManager *waylandServerSideDecoration();
|
|||
KWayland::Client::PlasmaShell *waylandPlasmaShell();
|
||||
KWayland::Client::PlasmaWindowManagement *waylandWindowManagement();
|
||||
KWayland::Client::PointerConstraints *waylandPointerConstraints();
|
||||
KWayland::Client::IdleInhibitManager *waylandIdleInhibitManager();
|
||||
KWayland::Client::AppMenuManager *waylandAppMenuManager();
|
||||
KWayland::Client::OutputManagement *waylandOutputManagement();
|
||||
KWayland::Client::TextInputManager *waylandTextInputManager();
|
||||
|
@ -333,6 +345,7 @@ XdgPopup *createXdgPopupSurface(KWayland::Client::Surface *surface, XdgSurface *
|
|||
CreationSetup configureMode = CreationSetup::CreateAndConfigure);
|
||||
|
||||
XdgToplevelDecorationV1 *createXdgToplevelDecorationV1(XdgToplevel *toplevel, QObject *parent = nullptr);
|
||||
IdleInhibitorV1 *createIdleInhibitorV1(KWayland::Client::Surface *surface);
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include <KWayland/Client/compositor.h>
|
||||
#include <KWayland/Client/connection_thread.h>
|
||||
#include <KWayland/Client/event_queue.h>
|
||||
#include <KWayland/Client/idleinhibit.h>
|
||||
#include <KWayland/Client/registry.h>
|
||||
#include <KWayland/Client/plasmashell.h>
|
||||
#include <KWayland/Client/plasmawindowmanagement.h>
|
||||
|
@ -208,6 +207,21 @@ void XdgToplevelDecorationV1::zxdg_toplevel_decoration_v1_configure(uint32_t m)
|
|||
emit configureRequested(mode(m));
|
||||
}
|
||||
|
||||
IdleInhibitManagerV1::~IdleInhibitManagerV1()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
IdleInhibitorV1::IdleInhibitorV1(IdleInhibitManagerV1 *manager, KWayland::Client::Surface *surface)
|
||||
: QtWayland::zwp_idle_inhibitor_v1(manager->create_inhibitor(*surface))
|
||||
{
|
||||
}
|
||||
|
||||
IdleInhibitorV1::~IdleInhibitorV1()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
static struct {
|
||||
ConnectionThread *connection = nullptr;
|
||||
EventQueue *queue = nullptr;
|
||||
|
@ -226,7 +240,7 @@ static struct {
|
|||
QThread *thread = nullptr;
|
||||
QVector<Output*> outputs;
|
||||
QVector<OutputDevice*> outputDevices;
|
||||
IdleInhibitManager *idleInhibit = nullptr;
|
||||
IdleInhibitManagerV1 *idleInhibitManagerV1 = nullptr;
|
||||
AppMenuManager *appMenu = nullptr;
|
||||
XdgDecorationManagerV1 *xdgDecorationManagerV1 = nullptr;
|
||||
TextInputManager *textInputManager = nullptr;
|
||||
|
@ -384,6 +398,13 @@ bool setupWaylandConnection(AdditionalWaylandInterfaces flags)
|
|||
return;
|
||||
}
|
||||
}
|
||||
if (flags & AdditionalWaylandInterface::IdleInhibitV1) {
|
||||
if (interface == zwp_idle_inhibit_manager_v1_interface.name) {
|
||||
s_waylandConnection.idleInhibitManagerV1 = new IdleInhibitManagerV1();
|
||||
s_waylandConnection.idleInhibitManagerV1->init(*registry, name, version);
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
QSignalSpy allAnnounced(registry, &Registry::interfacesAnnounced);
|
||||
|
@ -459,13 +480,6 @@ bool setupWaylandConnection(AdditionalWaylandInterfaces flags)
|
|||
return false;
|
||||
}
|
||||
}
|
||||
if (flags.testFlag(AdditionalWaylandInterface::IdleInhibition)) {
|
||||
s_waylandConnection.idleInhibit = registry->createIdleInhibitManager(registry->interface(Registry::Interface::IdleInhibitManagerUnstableV1).name,
|
||||
registry->interface(Registry::Interface::IdleInhibitManagerUnstableV1).version);
|
||||
if (!s_waylandConnection.idleInhibit->isValid()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (flags.testFlag(AdditionalWaylandInterface::AppMenu)) {
|
||||
s_waylandConnection.appMenu = registry->createAppMenuManager(registry->interface(Registry::Interface::AppMenu).name, registry->interface(Registry::Interface::AppMenu).version);
|
||||
if (!s_waylandConnection.appMenu->isValid()) {
|
||||
|
@ -504,8 +518,8 @@ void destroyWaylandConnection()
|
|||
s_waylandConnection.xdgShell = nullptr;
|
||||
delete s_waylandConnection.shadowManager;
|
||||
s_waylandConnection.shadowManager = nullptr;
|
||||
delete s_waylandConnection.idleInhibit;
|
||||
s_waylandConnection.idleInhibit = nullptr;
|
||||
delete s_waylandConnection.idleInhibitManagerV1;
|
||||
s_waylandConnection.idleInhibitManagerV1 = nullptr;
|
||||
delete s_waylandConnection.shm;
|
||||
s_waylandConnection.shm = nullptr;
|
||||
delete s_waylandConnection.queue;
|
||||
|
@ -590,11 +604,6 @@ PointerConstraints *waylandPointerConstraints()
|
|||
return s_waylandConnection.pointerConstraints;
|
||||
}
|
||||
|
||||
IdleInhibitManager *waylandIdleInhibitManager()
|
||||
{
|
||||
return s_waylandConnection.idleInhibit;
|
||||
}
|
||||
|
||||
AppMenuManager* waylandAppMenuManager()
|
||||
{
|
||||
return s_waylandConnection.appMenu;
|
||||
|
@ -845,6 +854,17 @@ XdgToplevelDecorationV1 *createXdgToplevelDecorationV1(XdgToplevel *toplevel, QO
|
|||
return new XdgToplevelDecorationV1(manager, toplevel, parent);
|
||||
}
|
||||
|
||||
IdleInhibitorV1 *createIdleInhibitorV1(KWayland::Client::Surface *surface)
|
||||
{
|
||||
IdleInhibitManagerV1 *manager = s_waylandConnection.idleInhibitManagerV1;
|
||||
if (!manager) {
|
||||
qWarning() << "Could not create an idle_inhibitor_v1 because idle_inhibit_manager_v1 global is not bound";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new IdleInhibitorV1(manager, surface);
|
||||
}
|
||||
|
||||
bool waitForWindowDestroyed(AbstractClient *client)
|
||||
{
|
||||
QSignalSpy destroyedSpy(client, &QObject::destroyed);
|
||||
|
|
Loading…
Reference in a new issue