KWin
Loading...
Searching...
No Matches
test_layershellv1_interface.cpp
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#include <QSignalSpy>
8#include <QTest>
9#include <QThread>
10
11#include "wayland/compositor.h"
12#include "wayland/display.h"
14#include "wayland/surface.h"
15#include "wayland/xdgshell.h"
16
17#include "KWayland/Client/compositor.h"
18#include "KWayland/Client/connection_thread.h"
19#include "KWayland/Client/event_queue.h"
20#include "KWayland/Client/registry.h"
21#include "KWayland/Client/surface.h"
22
23#include "qwayland-wlr-layer-shell-unstable-v1.h"
24#include "qwayland-xdg-shell.h"
25
28
29using namespace KWin;
30
31class LayerShellV1 : public QtWayland::zwlr_layer_shell_v1
32{
33public:
34 ~LayerShellV1() override
35 {
36 destroy();
37 }
38};
39
40class LayerSurfaceV1 : public QtWayland::zwlr_layer_surface_v1
41{
42public:
43 ~LayerSurfaceV1() override
44 {
45 destroy();
46 }
47};
48
49class XdgShell : public QtWayland::xdg_wm_base
50{
51public:
53 {
54 destroy();
55 }
56};
57
58class XdgSurface : public QtWayland::xdg_surface
59{
60public:
62 {
63 destroy();
64 }
65};
66
67class XdgPositioner : public QtWayland::xdg_positioner
68{
69public:
71 {
72 destroy();
73 }
74};
75
76class XdgPopup : public QtWayland::xdg_popup
77{
78public:
80 {
81 destroy();
82 }
83};
84
85class TestLayerShellV1Interface : public QObject
86{
87 Q_OBJECT
88
89public:
91
92private Q_SLOTS:
93 void initTestCase();
94 void testDesiredSize();
95 void testScope();
96 void testAnchor_data();
97 void testAnchor();
98 void testMargins();
99 void testExclusiveZone();
100 void testExclusiveEdge_data();
101 void testExclusiveEdge();
102 void testLayer_data();
103 void testLayer();
104 void testPopup();
105
106private:
107 KWayland::Client::ConnectionThread *m_connection;
108 KWayland::Client::EventQueue *m_queue;
109 KWayland::Client::Compositor *m_clientCompositor;
110
111 QThread *m_thread;
112 KWin::Display m_display;
113 CompositorInterface *m_serverCompositor;
114 LayerShellV1 *m_clientLayerShell = nullptr;
115 LayerShellV1Interface *m_serverLayerShell = nullptr;
116 XdgShell *m_clientXdgShell = nullptr;
117 XdgShellInterface *m_serverXdgShell = nullptr;
118};
119
120static const QString s_socketName = QStringLiteral("kwin-wayland-server-layer-shell-v1-test-0");
121
122void TestLayerShellV1Interface::initTestCase()
123{
124 m_display.addSocketName(s_socketName);
125 m_display.start();
126 QVERIFY(m_display.isRunning());
127
128 m_serverLayerShell = new LayerShellV1Interface(&m_display, this);
129 m_serverXdgShell = new XdgShellInterface(&m_display, this);
130 m_serverCompositor = new CompositorInterface(&m_display, this);
131
132 m_connection = new KWayland::Client::ConnectionThread;
133 QSignalSpy connectedSpy(m_connection, &KWayland::Client::ConnectionThread::connected);
134 m_connection->setSocketName(s_socketName);
135
136 m_thread = new QThread(this);
137 m_connection->moveToThread(m_thread);
138 m_thread->start();
139
140 m_connection->initConnection();
141 QVERIFY(connectedSpy.wait());
142 QVERIFY(!m_connection->connections().isEmpty());
143
144 m_queue = new KWayland::Client::EventQueue(this);
145 QVERIFY(!m_queue->isValid());
146 m_queue->setup(m_connection);
147 QVERIFY(m_queue->isValid());
148
149 auto registry = new KWayland::Client::Registry(this);
150 connect(registry, &KWayland::Client::Registry::interfaceAnnounced, this, [this, registry](const QByteArray &interface, quint32 id, quint32 version) {
151 if (interface == QByteArrayLiteral("zwlr_layer_shell_v1")) {
152 m_clientLayerShell = new LayerShellV1();
153 m_clientLayerShell->init(*registry, id, version);
154 }
155 if (interface == QByteArrayLiteral("xdg_wm_base")) {
156 m_clientXdgShell = new XdgShell();
157 m_clientXdgShell->init(*registry, id, version);
158 }
159 });
160 QSignalSpy allAnnouncedSpy(registry, &KWayland::Client::Registry::interfaceAnnounced);
161 QSignalSpy compositorSpy(registry, &KWayland::Client::Registry::compositorAnnounced);
162 QSignalSpy shmSpy(registry, &KWayland::Client::Registry::shmAnnounced);
163 registry->setEventQueue(m_queue);
164 registry->create(m_connection->display());
165 QVERIFY(registry->isValid());
166 registry->setup();
167 QVERIFY(allAnnouncedSpy.wait());
168
169 m_clientCompositor = registry->createCompositor(compositorSpy.first().first().value<quint32>(), compositorSpy.first().last().value<quint32>(), this);
170 QVERIFY(m_clientCompositor->isValid());
171}
172
174{
175 if (m_clientXdgShell) {
176 delete m_clientXdgShell;
177 m_clientXdgShell = nullptr;
178 }
179 if (m_clientLayerShell) {
180 delete m_clientLayerShell;
181 m_clientLayerShell = nullptr;
182 }
183 if (m_queue) {
184 delete m_queue;
185 m_queue = nullptr;
186 }
187 if (m_thread) {
188 m_thread->quit();
189 m_thread->wait();
190 delete m_thread;
191 m_thread = nullptr;
192 }
193 m_connection->deleteLater();
194 m_connection = nullptr;
195}
196
197void TestLayerShellV1Interface::testDesiredSize()
198{
199 // Create a test wl_surface object.
200 QSignalSpy serverSurfaceCreatedSpy(m_serverCompositor, &CompositorInterface::surfaceCreated);
201 std::unique_ptr<KWayland::Client::Surface> clientSurface(m_clientCompositor->createSurface(this));
202 QVERIFY(serverSurfaceCreatedSpy.wait());
203 SurfaceInterface *serverSurface = serverSurfaceCreatedSpy.first().first().value<SurfaceInterface *>();
204 QVERIFY(serverSurface);
205
206 // Create a test wlr_layer_surface_v1 object.
207 std::unique_ptr<LayerSurfaceV1> clientShellSurface(new LayerSurfaceV1);
208 clientShellSurface->init(m_clientLayerShell->get_layer_surface(*clientSurface, nullptr, LayerShellV1::layer_top, QStringLiteral("test")));
209 QSignalSpy layerSurfaceCreatedSpy(m_serverLayerShell, &LayerShellV1Interface::surfaceCreated);
210 QVERIFY(layerSurfaceCreatedSpy.wait());
211 auto serverShellSurface = layerSurfaceCreatedSpy.last().first().value<LayerSurfaceV1Interface *>();
212 QVERIFY(serverShellSurface);
213
214 clientShellSurface->set_size(10, 20);
215 clientSurface->commit(KWayland::Client::Surface::CommitFlag::None);
216
217 QSignalSpy desiredSizeChangedSpy(serverShellSurface, &LayerSurfaceV1Interface::desiredSizeChanged);
218 QVERIFY(desiredSizeChangedSpy.wait());
219
220 QCOMPARE(serverShellSurface->desiredSize(), QSize(10, 20));
221}
222
223void TestLayerShellV1Interface::testScope()
224{
225 // Create a test wl_surface object.
226 QSignalSpy serverSurfaceCreatedSpy(m_serverCompositor, &CompositorInterface::surfaceCreated);
227 std::unique_ptr<KWayland::Client::Surface> clientSurface(m_clientCompositor->createSurface(this));
228 QVERIFY(serverSurfaceCreatedSpy.wait());
229 SurfaceInterface *serverSurface = serverSurfaceCreatedSpy.first().first().value<SurfaceInterface *>();
230 QVERIFY(serverSurface);
231
232 // Create a test wlr_layer_surface_v1 object.
233 std::unique_ptr<LayerSurfaceV1> clientShellSurface(new LayerSurfaceV1);
234 clientShellSurface->init(m_clientLayerShell->get_layer_surface(*clientSurface, nullptr, LayerShellV1::layer_top, QStringLiteral("foobar")));
235 clientShellSurface->set_size(100, 50);
236 QSignalSpy layerSurfaceCreatedSpy(m_serverLayerShell, &LayerShellV1Interface::surfaceCreated);
237 QVERIFY(layerSurfaceCreatedSpy.wait());
238 auto serverShellSurface = layerSurfaceCreatedSpy.last().first().value<LayerSurfaceV1Interface *>();
239 QVERIFY(serverShellSurface);
240
241 QCOMPARE(serverShellSurface->scope(), QStringLiteral("foobar"));
242}
243
244void TestLayerShellV1Interface::testAnchor_data()
245{
246 QTest::addColumn<int>("anchor");
247 QTest::addColumn<Qt::Edge>("expected");
248
249 QTest::addRow("left") << int(QtWayland::zwlr_layer_surface_v1::anchor_left) << Qt::LeftEdge;
250 QTest::addRow("right") << int(QtWayland::zwlr_layer_surface_v1::anchor_right) << Qt::RightEdge;
251 QTest::addRow("top") << int(QtWayland::zwlr_layer_surface_v1::anchor_top) << Qt::TopEdge;
252 QTest::addRow("bottom") << int(QtWayland::zwlr_layer_surface_v1::anchor_bottom) << Qt::BottomEdge;
253}
254
255void TestLayerShellV1Interface::testAnchor()
256{
257 // Create a test wl_surface object.
258 QSignalSpy serverSurfaceCreatedSpy(m_serverCompositor, &CompositorInterface::surfaceCreated);
259 std::unique_ptr<KWayland::Client::Surface> clientSurface(m_clientCompositor->createSurface(this));
260 QVERIFY(serverSurfaceCreatedSpy.wait());
261 SurfaceInterface *serverSurface = serverSurfaceCreatedSpy.first().first().value<SurfaceInterface *>();
262 QVERIFY(serverSurface);
263
264 // Create a test wlr_layer_surface_v1 object.
265 std::unique_ptr<LayerSurfaceV1> clientShellSurface(new LayerSurfaceV1);
266 clientShellSurface->init(m_clientLayerShell->get_layer_surface(*clientSurface, nullptr, LayerShellV1::layer_top, QStringLiteral("test")));
267 QSignalSpy layerSurfaceCreatedSpy(m_serverLayerShell, &LayerShellV1Interface::surfaceCreated);
268 QVERIFY(layerSurfaceCreatedSpy.wait());
269 auto serverShellSurface = layerSurfaceCreatedSpy.last().first().value<LayerSurfaceV1Interface *>();
270 QVERIFY(serverShellSurface);
271
272 QFETCH(int, anchor);
273 QFETCH(Qt::Edge, expected);
274
275 clientShellSurface->set_anchor(anchor);
276 clientShellSurface->set_size(100, 50);
277 clientSurface->commit(KWayland::Client::Surface::CommitFlag::None);
278
279 QSignalSpy anchorChangedSpy(serverShellSurface, &LayerSurfaceV1Interface::anchorChanged);
280 QVERIFY(anchorChangedSpy.wait());
281
282 QCOMPARE(serverShellSurface->anchor(), expected);
283}
284
285void TestLayerShellV1Interface::testMargins()
286{
287 // Create a test wl_surface object.
288 QSignalSpy serverSurfaceCreatedSpy(m_serverCompositor, &CompositorInterface::surfaceCreated);
289 std::unique_ptr<KWayland::Client::Surface> clientSurface(m_clientCompositor->createSurface(this));
290 QVERIFY(serverSurfaceCreatedSpy.wait());
291 SurfaceInterface *serverSurface = serverSurfaceCreatedSpy.first().first().value<SurfaceInterface *>();
292 QVERIFY(serverSurface);
293
294 // Create a test wlr_layer_surface_v1 object.
295 std::unique_ptr<LayerSurfaceV1> clientShellSurface(new LayerSurfaceV1);
296 clientShellSurface->init(m_clientLayerShell->get_layer_surface(*clientSurface, nullptr, LayerShellV1::layer_top, QStringLiteral("test")));
297 QSignalSpy layerSurfaceCreatedSpy(m_serverLayerShell, &LayerShellV1Interface::surfaceCreated);
298 QVERIFY(layerSurfaceCreatedSpy.wait());
299 auto serverShellSurface = layerSurfaceCreatedSpy.last().first().value<LayerSurfaceV1Interface *>();
300 QVERIFY(serverShellSurface);
301
302 clientShellSurface->set_margin(10, 20, 30, 40);
303 clientShellSurface->set_size(100, 50);
304 clientSurface->commit(KWayland::Client::Surface::CommitFlag::None);
305
306 QSignalSpy marginsChangedSpy(serverShellSurface, &LayerSurfaceV1Interface::marginsChanged);
307 QVERIFY(marginsChangedSpy.wait());
308
309 QCOMPARE(serverShellSurface->margins(), QMargins(40, 10, 20, 30));
310}
311
312void TestLayerShellV1Interface::testExclusiveZone()
313{
314 // Create a test wl_surface object.
315 QSignalSpy serverSurfaceCreatedSpy(m_serverCompositor, &CompositorInterface::surfaceCreated);
316 std::unique_ptr<KWayland::Client::Surface> clientSurface(m_clientCompositor->createSurface(this));
317 QVERIFY(serverSurfaceCreatedSpy.wait());
318 SurfaceInterface *serverSurface = serverSurfaceCreatedSpy.first().first().value<SurfaceInterface *>();
319 QVERIFY(serverSurface);
320
321 // Create a test wlr_layer_surface_v1 object.
322 std::unique_ptr<LayerSurfaceV1> clientShellSurface(new LayerSurfaceV1);
323 clientShellSurface->init(m_clientLayerShell->get_layer_surface(*clientSurface, nullptr, LayerShellV1::layer_top, QStringLiteral("test")));
324 QSignalSpy layerSurfaceCreatedSpy(m_serverLayerShell, &LayerShellV1Interface::surfaceCreated);
325 QVERIFY(layerSurfaceCreatedSpy.wait());
326 auto serverShellSurface = layerSurfaceCreatedSpy.last().first().value<LayerSurfaceV1Interface *>();
327 QVERIFY(serverShellSurface);
328
329 clientShellSurface->set_exclusive_zone(10);
330 clientShellSurface->set_size(100, 50);
331 clientSurface->commit(KWayland::Client::Surface::CommitFlag::None);
332
333 QSignalSpy exclusiveZoneChangedSpy(serverShellSurface, &LayerSurfaceV1Interface::exclusiveZoneChanged);
334 QVERIFY(exclusiveZoneChangedSpy.wait());
335
336 QCOMPARE(serverShellSurface->exclusiveZone(), 10);
337}
338
339void TestLayerShellV1Interface::testExclusiveEdge_data()
340{
341 QTest::addColumn<int>("anchor");
342 QTest::addColumn<Qt::Edge>("expected");
343
344 QTest::addRow("left (singular)") << int(QtWayland::zwlr_layer_surface_v1::anchor_left) << Qt::LeftEdge;
345
346 QTest::addRow("left (triplet)") << (QtWayland::zwlr_layer_surface_v1::anchor_bottom | QtWayland::zwlr_layer_surface_v1::anchor_left
347 | QtWayland::zwlr_layer_surface_v1::anchor_top)
348 << Qt::LeftEdge;
349
350 QTest::addRow("right (singular)") << int(QtWayland::zwlr_layer_surface_v1::anchor_right) << Qt::RightEdge;
351
352 QTest::addRow("right (triplet)") << (QtWayland::zwlr_layer_surface_v1::anchor_top | QtWayland::zwlr_layer_surface_v1::anchor_right
353 | QtWayland::zwlr_layer_surface_v1::anchor_bottom)
354 << Qt::RightEdge;
355
356 QTest::addRow("top (singular)") << int(QtWayland::zwlr_layer_surface_v1::anchor_top) << Qt::TopEdge;
357
358 QTest::addRow("top (triplet)") << (QtWayland::zwlr_layer_surface_v1::anchor_left | QtWayland::zwlr_layer_surface_v1::anchor_top
359 | QtWayland::zwlr_layer_surface_v1::anchor_right)
360 << Qt::TopEdge;
361
362 QTest::addRow("bottom (singular)") << int(QtWayland::zwlr_layer_surface_v1::anchor_bottom) << Qt::BottomEdge;
363
364 QTest::addRow("bottom (triplet)") << (QtWayland::zwlr_layer_surface_v1::anchor_right | QtWayland::zwlr_layer_surface_v1::anchor_bottom
365 | QtWayland::zwlr_layer_surface_v1::anchor_left)
366 << Qt::BottomEdge;
367
368 QTest::addRow("all") << (QtWayland::zwlr_layer_surface_v1::anchor_left | QtWayland::zwlr_layer_surface_v1::anchor_right
369 | QtWayland::zwlr_layer_surface_v1::anchor_top | QtWayland::zwlr_layer_surface_v1::anchor_bottom)
370 << Qt::Edge();
371}
372
373void TestLayerShellV1Interface::testExclusiveEdge()
374{
375 // Create a test wl_surface object.
376 QSignalSpy serverSurfaceCreatedSpy(m_serverCompositor, &CompositorInterface::surfaceCreated);
377 std::unique_ptr<KWayland::Client::Surface> clientSurface(m_clientCompositor->createSurface(this));
378 QVERIFY(serverSurfaceCreatedSpy.wait());
379 SurfaceInterface *serverSurface = serverSurfaceCreatedSpy.first().first().value<SurfaceInterface *>();
380 QVERIFY(serverSurface);
381
382 // Create a test wlr_layer_surface_v1 object.
383 std::unique_ptr<LayerSurfaceV1> clientShellSurface(new LayerSurfaceV1);
384 clientShellSurface->init(m_clientLayerShell->get_layer_surface(*clientSurface, nullptr, LayerShellV1::layer_top, QStringLiteral("test")));
385 QSignalSpy layerSurfaceCreatedSpy(m_serverLayerShell, &LayerShellV1Interface::surfaceCreated);
386 QVERIFY(layerSurfaceCreatedSpy.wait());
387 auto serverShellSurface = layerSurfaceCreatedSpy.last().first().value<LayerSurfaceV1Interface *>();
388 QVERIFY(serverShellSurface);
389
390 QFETCH(int, anchor);
391 QFETCH(Qt::Edge, expected);
392
393 clientShellSurface->set_exclusive_zone(10);
394 clientShellSurface->set_size(100, 50);
395 clientShellSurface->set_anchor(anchor);
396 clientSurface->commit(KWayland::Client::Surface::CommitFlag::None);
397
398 QSignalSpy anchorChangedSpy(serverShellSurface, &LayerSurfaceV1Interface::anchorChanged);
399 QVERIFY(anchorChangedSpy.wait());
400
401 QCOMPARE(serverShellSurface->exclusiveEdge(), expected);
402}
403
404void TestLayerShellV1Interface::testLayer_data()
405{
406 QTest::addColumn<int>("layer");
407 QTest::addColumn<LayerSurfaceV1Interface::Layer>("expected");
408
409 QTest::addRow("overlay") << int(QtWayland::zwlr_layer_shell_v1::layer_overlay) << LayerSurfaceV1Interface::OverlayLayer;
410 QTest::addRow("top") << int(QtWayland::zwlr_layer_shell_v1::layer_top) << LayerSurfaceV1Interface::TopLayer;
411 QTest::addRow("bottom") << int(QtWayland::zwlr_layer_shell_v1::layer_bottom) << LayerSurfaceV1Interface::BottomLayer;
412 QTest::addRow("background") << int(QtWayland::zwlr_layer_shell_v1::layer_background) << LayerSurfaceV1Interface::BackgroundLayer;
413}
414
415void TestLayerShellV1Interface::testLayer()
416{
417 // Create a test wl_surface object.
418 QSignalSpy serverSurfaceCreatedSpy(m_serverCompositor, &CompositorInterface::surfaceCreated);
419 std::unique_ptr<KWayland::Client::Surface> clientSurface(m_clientCompositor->createSurface(this));
420 QVERIFY(serverSurfaceCreatedSpy.wait());
421 SurfaceInterface *serverSurface = serverSurfaceCreatedSpy.first().first().value<SurfaceInterface *>();
422 QVERIFY(serverSurface);
423
424 // Create a test wlr_layer_surface_v1 object.
425 std::unique_ptr<LayerSurfaceV1> clientShellSurface(new LayerSurfaceV1);
426 clientShellSurface->init(m_clientLayerShell->get_layer_surface(*clientSurface, nullptr, LayerShellV1::layer_top, QStringLiteral("test")));
427 QSignalSpy layerSurfaceCreatedSpy(m_serverLayerShell, &LayerShellV1Interface::surfaceCreated);
428 QVERIFY(layerSurfaceCreatedSpy.wait());
429 auto serverShellSurface = layerSurfaceCreatedSpy.last().first().value<LayerSurfaceV1Interface *>();
430 QVERIFY(serverShellSurface);
431
432 QFETCH(int, layer);
433 QFETCH(LayerSurfaceV1Interface::Layer, expected);
434
435 clientShellSurface->set_layer(layer);
436 clientShellSurface->set_size(100, 50);
437 clientSurface->commit(KWayland::Client::Surface::CommitFlag::None);
438
439 QSignalSpy committedSpy(serverSurface, &SurfaceInterface::committed);
440 QVERIFY(committedSpy.wait());
441
442 QCOMPARE(serverShellSurface->layer(), expected);
443}
444
445void TestLayerShellV1Interface::testPopup()
446{
447 // Create a test wl_surface object for the panel.
448 QSignalSpy serverPanelSurfaceCreatedSpy(m_serverCompositor, &CompositorInterface::surfaceCreated);
449 std::unique_ptr<KWayland::Client::Surface> clientPanelSurface(m_clientCompositor->createSurface(this));
450 QVERIFY(serverPanelSurfaceCreatedSpy.wait());
451 SurfaceInterface *serverPanelSurface = serverPanelSurfaceCreatedSpy.last().first().value<SurfaceInterface *>();
452 QVERIFY(serverPanelSurface);
453
454 // Create a test wlr_layer_surface_v1 object for the panel..
455 std::unique_ptr<LayerSurfaceV1> clientPanelShellSurface(new LayerSurfaceV1);
456 clientPanelShellSurface->init(m_clientLayerShell->get_layer_surface(*clientPanelSurface, nullptr, LayerShellV1::layer_top, QStringLiteral("panel")));
457 clientPanelShellSurface->set_size(100, 50);
458 QSignalSpy layerSurfaceCreatedSpy(m_serverLayerShell, &LayerShellV1Interface::surfaceCreated);
459 QVERIFY(layerSurfaceCreatedSpy.wait());
460 auto serverPanelShellSurface = layerSurfaceCreatedSpy.last().first().value<LayerSurfaceV1Interface *>();
461 QVERIFY(serverPanelShellSurface);
462
463 // Create a wl_surface object for the popup.
464 std::unique_ptr<KWayland::Client::Surface> clientPopupSurface(m_clientCompositor->createSurface(this));
465 QVERIFY(serverPanelSurfaceCreatedSpy.wait());
466 SurfaceInterface *serverPopupSurface = serverPanelSurfaceCreatedSpy.last().first().value<SurfaceInterface *>();
467 QVERIFY(serverPopupSurface);
468
469 // Create an xdg_surface object for the popup.
470 std::unique_ptr<XdgSurface> clientXdgSurface(new XdgSurface);
471 clientXdgSurface->init(m_clientXdgShell->get_xdg_surface(*clientPopupSurface));
472
473 // Create an xdg_positioner object for the popup.
474 std::unique_ptr<::XdgPositioner> positioner(new ::XdgPositioner);
475 positioner->init(m_clientXdgShell->create_positioner());
476 positioner->set_size(100, 100);
477 positioner->set_anchor_rect(0, 0, 10, 10);
478
479 // Create an xdg_popup surface.
480 std::unique_ptr<XdgPopup> clientXdgPopup(new XdgPopup);
481 clientXdgPopup->init(clientXdgSurface->get_popup(nullptr, positioner->object()));
482
483 // Wait for the server side to catch up.
484 QSignalSpy popupCreatedSpy(m_serverXdgShell, &XdgShellInterface::popupCreated);
485 QVERIFY(popupCreatedSpy.wait());
486 XdgPopupInterface *serverPopupShellSurface = popupCreatedSpy.last().first().value<XdgPopupInterface *>();
487 QVERIFY(serverPopupShellSurface);
488 QCOMPARE(serverPopupShellSurface->parentSurface(), nullptr);
489
490 // Make the xdg_popup surface a child of the panel.
491 clientPanelShellSurface->get_popup(clientXdgPopup->object());
492
493 // Commit the initial state of the xdg_popup surface.
494 clientPopupSurface->commit(KWayland::Client::Surface::CommitFlag::None);
495 QSignalSpy initializeRequestedSpy(serverPopupShellSurface, &XdgPopupInterface::initializeRequested);
496 QVERIFY(initializeRequestedSpy.wait());
497
498 // The popup should be a transient for the panel.
499 QCOMPARE(serverPopupShellSurface->parentSurface(), serverPanelSurface);
500}
501
502QTEST_GUILESS_MAIN(TestLayerShellV1Interface)
503
504#include "test_layershellv1_interface.moc"
void surfaceCreated(KWin::SurfaceInterface *surface)
Class holding the Wayland server display loop.
Definition display.h:34
bool addSocketName(const QString &name=QString())
Definition display.cpp:68
bool isRunning() const
Definition display.cpp:144
bool start()
Definition display.cpp:92
void surfaceCreated(LayerSurfaceV1Interface *surface)
Resource representing a wl_surface.
Definition surface.h:80
SurfaceInterface * parentSurface() const
Definition xdgshell.cpp:786
void popupCreated(XdgPopupInterface *popup)
Q_DECLARE_METATYPE(KWin::SwitchEvent::State)
KWayland::Client::Registry * registry
constexpr int version