Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/struts_test.cpp
Show All 22 Lines | |||||
23 | #include "cursor.h" | 23 | #include "cursor.h" | ||
24 | #include "screenedge.h" | 24 | #include "screenedge.h" | ||
25 | #include "screens.h" | 25 | #include "screens.h" | ||
26 | #include "wayland_server.h" | 26 | #include "wayland_server.h" | ||
27 | #include "workspace.h" | 27 | #include "workspace.h" | ||
28 | #include "shell_client.h" | 28 | #include "shell_client.h" | ||
29 | #include <kwineffects.h> | 29 | #include <kwineffects.h> | ||
30 | 30 | | |||
31 | #include <KWayland/Client/connection_thread.h> | | |||
32 | #include <KWayland/Client/compositor.h> | 31 | #include <KWayland/Client/compositor.h> | ||
33 | #include <KWayland/Client/event_queue.h> | | |||
34 | #include <KWayland/Client/registry.h> | | |||
35 | #include <KWayland/Client/plasmashell.h> | 32 | #include <KWayland/Client/plasmashell.h> | ||
36 | #include <KWayland/Client/pointer.h> | | |||
37 | #include <KWayland/Client/server_decoration.h> | | |||
38 | #include <KWayland/Client/shell.h> | 33 | #include <KWayland/Client/shell.h> | ||
39 | #include <KWayland/Client/seat.h> | | |||
40 | #include <KWayland/Client/shm_pool.h> | | |||
41 | #include <KWayland/Client/surface.h> | 34 | #include <KWayland/Client/surface.h> | ||
42 | 35 | | |||
43 | #include <KDecoration2/Decoration> | 36 | #include <KDecoration2/Decoration> | ||
44 | 37 | | |||
45 | #include <netwm.h> | 38 | #include <netwm.h> | ||
46 | #include <xcb/xcb_icccm.h> | 39 | #include <xcb/xcb_icccm.h> | ||
47 | 40 | | |||
48 | namespace KWin | 41 | namespace KWin | ||
Show All 12 Lines | 49 | private Q_SLOTS: | |||
61 | void testWaylandStruts(); | 54 | void testWaylandStruts(); | ||
62 | void testMoveWaylandPanel(); | 55 | void testMoveWaylandPanel(); | ||
63 | void testWaylandMobilePanel(); | 56 | void testWaylandMobilePanel(); | ||
64 | void testX11Struts_data(); | 57 | void testX11Struts_data(); | ||
65 | void testX11Struts(); | 58 | void testX11Struts(); | ||
66 | void test363804(); | 59 | void test363804(); | ||
67 | 60 | | |||
68 | private: | 61 | private: | ||
69 | KWayland::Client::ConnectionThread *m_connection = nullptr; | | |||
70 | KWayland::Client::Compositor *m_compositor = nullptr; | 62 | KWayland::Client::Compositor *m_compositor = nullptr; | ||
71 | KWayland::Client::ServerSideDecorationManager *m_deco = nullptr; | | |||
72 | KWayland::Client::Seat *m_seat = nullptr; | | |||
73 | KWayland::Client::ShmPool *m_shm = nullptr; | | |||
74 | KWayland::Client::Shell *m_shell = nullptr; | | |||
75 | KWayland::Client::EventQueue *m_queue = nullptr; | | |||
76 | KWayland::Client::PlasmaShell *m_plasmaShell = nullptr; | 63 | KWayland::Client::PlasmaShell *m_plasmaShell = nullptr; | ||
77 | QThread *m_thread = nullptr; | | |||
78 | }; | 64 | }; | ||
79 | 65 | | |||
80 | void StrutsTest::initTestCase() | 66 | void StrutsTest::initTestCase() | ||
81 | { | 67 | { | ||
82 | qRegisterMetaType<KWin::ShellClient*>(); | 68 | qRegisterMetaType<KWin::ShellClient*>(); | ||
83 | qRegisterMetaType<KWin::AbstractClient*>(); | 69 | qRegisterMetaType<KWin::AbstractClient*>(); | ||
84 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | 70 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | ||
85 | QVERIFY(workspaceCreatedSpy.isValid()); | 71 | QVERIFY(workspaceCreatedSpy.isValid()); | ||
86 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | 72 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | ||
87 | QMetaObject::invokeMethod(kwinApp()->platform(), "setOutputCount", Qt::DirectConnection, Q_ARG(int, 2)); | 73 | QMetaObject::invokeMethod(kwinApp()->platform(), "setOutputCount", Qt::DirectConnection, Q_ARG(int, 2)); | ||
88 | waylandServer()->init(s_socketName.toLocal8Bit()); | 74 | waylandServer()->init(s_socketName.toLocal8Bit()); | ||
89 | 75 | | |||
90 | kwinApp()->start(); | 76 | kwinApp()->start(); | ||
91 | QVERIFY(workspaceCreatedSpy.wait()); | 77 | QVERIFY(workspaceCreatedSpy.wait()); | ||
92 | QCOMPARE(screens()->count(), 2); | 78 | QCOMPARE(screens()->count(), 2); | ||
93 | QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024)); | 79 | QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024)); | ||
94 | QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024)); | 80 | QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024)); | ||
95 | setenv("QT_QPA_PLATFORM", "wayland", true); | 81 | setenv("QT_QPA_PLATFORM", "wayland", true); | ||
96 | waylandServer()->initWorkspace(); | 82 | waylandServer()->initWorkspace(); | ||
97 | } | 83 | } | ||
98 | 84 | | |||
99 | void StrutsTest::init() | 85 | void StrutsTest::init() | ||
100 | { | 86 | { | ||
101 | using namespace KWayland::Client; | 87 | QVERIFY(Test::setupWaylandConnection(s_socketName, Test::AdditionalWaylandInterface::PlasmaShell)); | ||
102 | // setup connection | 88 | m_compositor = Test::waylandCompositor(); | ||
103 | m_connection = new ConnectionThread; | 89 | m_plasmaShell = Test::waylandPlasmaShell(); | ||
104 | QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected); | | |||
105 | QVERIFY(connectedSpy.isValid()); | | |||
106 | m_connection->setSocketName(s_socketName); | | |||
107 | | ||||
108 | m_thread = new QThread(this); | | |||
109 | m_connection->moveToThread(m_thread); | | |||
110 | m_thread->start(); | | |||
111 | | ||||
112 | m_connection->initConnection(); | | |||
113 | QVERIFY(connectedSpy.wait()); | | |||
114 | | ||||
115 | m_queue = new EventQueue(this); | | |||
116 | QVERIFY(!m_queue->isValid()); | | |||
117 | m_queue->setup(m_connection); | | |||
118 | QVERIFY(m_queue->isValid()); | | |||
119 | | ||||
120 | Registry registry; | | |||
121 | registry.setEventQueue(m_queue); | | |||
122 | QSignalSpy compositorSpy(®istry, &Registry::compositorAnnounced); | | |||
123 | QSignalSpy shmSpy(®istry, &Registry::shmAnnounced); | | |||
124 | QSignalSpy shellSpy(®istry, &Registry::shellAnnounced); | | |||
125 | QSignalSpy seatSpy(®istry, &Registry::seatAnnounced); | | |||
126 | QSignalSpy decorationSpy(®istry, &Registry::serverSideDecorationManagerAnnounced); | | |||
127 | QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced); | | |||
128 | QVERIFY(allAnnounced.isValid()); | | |||
129 | QVERIFY(shmSpy.isValid()); | | |||
130 | QVERIFY(shellSpy.isValid()); | | |||
131 | QVERIFY(compositorSpy.isValid()); | | |||
132 | QVERIFY(seatSpy.isValid()); | | |||
133 | QVERIFY(decorationSpy.isValid()); | | |||
134 | registry.create(m_connection->display()); | | |||
135 | QVERIFY(registry.isValid()); | | |||
136 | registry.setup(); | | |||
137 | QVERIFY(allAnnounced.wait()); | | |||
138 | QVERIFY(!compositorSpy.isEmpty()); | | |||
139 | QVERIFY(!shmSpy.isEmpty()); | | |||
140 | QVERIFY(!shellSpy.isEmpty()); | | |||
141 | QVERIFY(!seatSpy.isEmpty()); | | |||
142 | QVERIFY(!decorationSpy.isEmpty()); | | |||
143 | | ||||
144 | m_compositor = registry.createCompositor(compositorSpy.first().first().value<quint32>(), compositorSpy.first().last().value<quint32>(), this); | | |||
145 | QVERIFY(m_compositor->isValid()); | | |||
146 | m_shm = registry.createShmPool(shmSpy.first().first().value<quint32>(), shmSpy.first().last().value<quint32>(), this); | | |||
147 | QVERIFY(m_shm->isValid()); | | |||
148 | m_shell = registry.createShell(shellSpy.first().first().value<quint32>(), shellSpy.first().last().value<quint32>(), this); | | |||
149 | QVERIFY(m_shell->isValid()); | | |||
150 | m_seat = registry.createSeat(seatSpy.first().first().value<quint32>(), seatSpy.first().last().value<quint32>(), this); | | |||
151 | QVERIFY(m_seat->isValid()); | | |||
152 | m_deco = registry.createServerSideDecorationManager(decorationSpy.first().first().value<quint32>(), decorationSpy.first().last().value<quint32>()); | | |||
153 | QVERIFY(m_deco->isValid()); | | |||
154 | m_plasmaShell = registry.createPlasmaShell(registry.interface(Registry::Interface::PlasmaShell).name, | | |||
155 | registry.interface(Registry::Interface::PlasmaShell).version, | | |||
156 | this); | | |||
157 | QVERIFY(m_plasmaShell); | | |||
158 | QSignalSpy hasPointerSpy(m_seat, &Seat::hasPointerChanged); | | |||
159 | QVERIFY(hasPointerSpy.isValid()); | | |||
160 | QVERIFY(hasPointerSpy.wait()); | | |||
161 | 90 | | |||
162 | screens()->setCurrent(0); | 91 | screens()->setCurrent(0); | ||
163 | Cursor::setPos(QPoint(640, 512)); | 92 | Cursor::setPos(QPoint(640, 512)); | ||
93 | QVERIFY(waylandServer()->clients().isEmpty()); | ||||
164 | } | 94 | } | ||
165 | 95 | | |||
166 | void StrutsTest::cleanup() | 96 | void StrutsTest::cleanup() | ||
167 | { | 97 | { | ||
168 | delete m_compositor; | 98 | Test::destroyWaylandConnection(); | ||
169 | m_compositor = nullptr; | | |||
170 | delete m_deco; | | |||
171 | m_deco = nullptr; | | |||
172 | delete m_seat; | | |||
173 | m_seat = nullptr; | | |||
174 | delete m_shm; | | |||
175 | m_shm = nullptr; | | |||
176 | delete m_shell; | | |||
177 | m_shell = nullptr; | | |||
178 | delete m_plasmaShell; | | |||
179 | m_plasmaShell = nullptr; | | |||
180 | delete m_queue; | | |||
181 | m_queue = nullptr; | | |||
182 | if (m_thread) { | | |||
183 | m_connection->deleteLater(); | | |||
184 | m_thread->quit(); | | |||
185 | m_thread->wait(); | | |||
186 | delete m_thread; | | |||
187 | m_thread = nullptr; | | |||
188 | m_connection = nullptr; | | |||
189 | } | | |||
190 | while (!waylandServer()->clients().isEmpty()) { | | |||
191 | QCoreApplication::instance()->processEvents(QEventLoop::WaitForMoreEvents); | | |||
192 | } | | |||
193 | QVERIFY(waylandServer()->clients().isEmpty()); | | |||
194 | } | 99 | } | ||
195 | 100 | | |||
196 | void StrutsTest::testWaylandStruts_data() | 101 | void StrutsTest::testWaylandStruts_data() | ||
197 | { | 102 | { | ||
198 | QTest::addColumn<QVector<QRect>>("windowGeometries"); | 103 | QTest::addColumn<QVector<QRect>>("windowGeometries"); | ||
199 | QTest::addColumn<QRect>("screen0Maximized"); | 104 | QTest::addColumn<QRect>("screen0Maximized"); | ||
200 | QTest::addColumn<QRect>("screen1Maximized"); | 105 | QTest::addColumn<QRect>("screen1Maximized"); | ||
201 | QTest::addColumn<QRect>("workArea"); | 106 | QTest::addColumn<QRect>("workArea"); | ||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | 133 | { | |||
247 | // combined | 152 | // combined | ||
248 | QCOMPARE(workspace()->clientArea(WorkArea, 0, 1), QRect(0, 0, 2560, 1024)); | 153 | QCOMPARE(workspace()->clientArea(WorkArea, 0, 1), QRect(0, 0, 2560, 1024)); | ||
249 | QCOMPARE(workspace()->clientArea(FullArea, 0, 1), QRect(0, 0, 2560, 1024)); | 154 | QCOMPARE(workspace()->clientArea(FullArea, 0, 1), QRect(0, 0, 2560, 1024)); | ||
250 | 155 | | |||
251 | QFETCH(QVector<QRect>, windowGeometries); | 156 | QFETCH(QVector<QRect>, windowGeometries); | ||
252 | // create the panels | 157 | // create the panels | ||
253 | QSignalSpy windowCreatedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 158 | QSignalSpy windowCreatedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
254 | QVERIFY(windowCreatedSpy.isValid()); | 159 | QVERIFY(windowCreatedSpy.isValid()); | ||
160 | QHash<Surface*, ShellClient*> clients; | ||||
255 | for (auto it = windowGeometries.constBegin(), end = windowGeometries.constEnd(); it != end; it++) { | 161 | for (auto it = windowGeometries.constBegin(), end = windowGeometries.constEnd(); it != end; it++) { | ||
256 | const QRect windowGeometry = *it; | 162 | const QRect windowGeometry = *it; | ||
257 | Surface *surface = m_compositor->createSurface(m_compositor); | 163 | Surface *surface = Test::createSurface(m_compositor); | ||
258 | ShellSurface *shellSurface = m_shell->createSurface(surface, surface); | 164 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | ||
259 | Q_UNUSED(shellSurface) | 165 | Q_UNUSED(shellSurface) | ||
260 | PlasmaShellSurface *plasmaSurface = m_plasmaShell->createSurface(surface, surface); | 166 | PlasmaShellSurface *plasmaSurface = m_plasmaShell->createSurface(surface, surface); | ||
261 | plasmaSurface->setPosition(windowGeometry.topLeft()); | 167 | plasmaSurface->setPosition(windowGeometry.topLeft()); | ||
262 | plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); | 168 | plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); | ||
263 | 169 | | |||
264 | // map the window | 170 | // map the window | ||
265 | QImage img(windowGeometry.size(), QImage::Format_RGB32); | 171 | Test::render(surface, windowGeometry.size(), Qt::red, QImage::Format_RGB32); | ||
266 | img.fill(Qt::red); | | |||
267 | surface->attachBuffer(m_shm->createBuffer(img)); | | |||
268 | surface->damage(QRect(QPoint(0, 0), windowGeometry.size())); | | |||
269 | surface->commit(Surface::CommitFlag::None); | | |||
270 | 172 | | |||
271 | QVERIFY(windowCreatedSpy.wait()); | 173 | QVERIFY(windowCreatedSpy.wait()); | ||
272 | QCOMPARE(windowCreatedSpy.count(), 1); | 174 | QCOMPARE(windowCreatedSpy.count(), 1); | ||
273 | auto c = windowCreatedSpy.first().first().value<ShellClient*>(); | 175 | auto c = windowCreatedSpy.first().first().value<ShellClient*>(); | ||
274 | QVERIFY(c); | 176 | QVERIFY(c); | ||
275 | QVERIFY(!c->isActive()); | 177 | QVERIFY(!c->isActive()); | ||
276 | QCOMPARE(c->geometry(), windowGeometry); | 178 | QCOMPARE(c->geometry(), windowGeometry); | ||
277 | QVERIFY(c->isDock()); | 179 | QVERIFY(c->isDock()); | ||
278 | QVERIFY(c->hasStrut()); | 180 | QVERIFY(c->hasStrut()); | ||
279 | windowCreatedSpy.clear(); | 181 | windowCreatedSpy.clear(); | ||
182 | clients.insert(surface, c); | ||||
280 | } | 183 | } | ||
281 | 184 | | |||
282 | // some props are independent of struts - those first | 185 | // some props are independent of struts - those first | ||
283 | // screen 0 | 186 | // screen 0 | ||
284 | QCOMPARE(workspace()->clientArea(MovementArea, 0, 1), QRect(0, 0, 1280, 1024)); | 187 | QCOMPARE(workspace()->clientArea(MovementArea, 0, 1), QRect(0, 0, 1280, 1024)); | ||
285 | QCOMPARE(workspace()->clientArea(MaximizeFullArea, 0, 1), QRect(0, 0, 1280, 1024)); | 188 | QCOMPARE(workspace()->clientArea(MaximizeFullArea, 0, 1), QRect(0, 0, 1280, 1024)); | ||
286 | QCOMPARE(workspace()->clientArea(FullScreenArea, 0, 1), QRect(0, 0, 1280, 1024)); | 189 | QCOMPARE(workspace()->clientArea(FullScreenArea, 0, 1), QRect(0, 0, 1280, 1024)); | ||
287 | QCOMPARE(workspace()->clientArea(ScreenArea, 0, 1), QRect(0, 0, 1280, 1024)); | 190 | QCOMPARE(workspace()->clientArea(ScreenArea, 0, 1), QRect(0, 0, 1280, 1024)); | ||
288 | // screen 1 | 191 | // screen 1 | ||
289 | QCOMPARE(workspace()->clientArea(MovementArea, 1, 1), QRect(1280, 0, 1280, 1024)); | 192 | QCOMPARE(workspace()->clientArea(MovementArea, 1, 1), QRect(1280, 0, 1280, 1024)); | ||
290 | QCOMPARE(workspace()->clientArea(MaximizeFullArea, 1, 1), QRect(1280, 0, 1280, 1024)); | 193 | QCOMPARE(workspace()->clientArea(MaximizeFullArea, 1, 1), QRect(1280, 0, 1280, 1024)); | ||
291 | QCOMPARE(workspace()->clientArea(FullScreenArea, 1, 1), QRect(1280, 0, 1280, 1024)); | 194 | QCOMPARE(workspace()->clientArea(FullScreenArea, 1, 1), QRect(1280, 0, 1280, 1024)); | ||
292 | QCOMPARE(workspace()->clientArea(ScreenArea, 1, 1), QRect(1280, 0, 1280, 1024)); | 195 | QCOMPARE(workspace()->clientArea(ScreenArea, 1, 1), QRect(1280, 0, 1280, 1024)); | ||
293 | // combined | 196 | // combined | ||
294 | QCOMPARE(workspace()->clientArea(FullArea, 0, 1), QRect(0, 0, 2560, 1024)); | 197 | QCOMPARE(workspace()->clientArea(FullArea, 0, 1), QRect(0, 0, 2560, 1024)); | ||
295 | 198 | | |||
296 | // now verify the actual updated client areas | 199 | // now verify the actual updated client areas | ||
297 | QTEST(workspace()->clientArea(PlacementArea, 0, 1), "screen0Maximized"); | 200 | QTEST(workspace()->clientArea(PlacementArea, 0, 1), "screen0Maximized"); | ||
298 | QTEST(workspace()->clientArea(MaximizeArea, 0, 1), "screen0Maximized"); | 201 | QTEST(workspace()->clientArea(MaximizeArea, 0, 1), "screen0Maximized"); | ||
299 | QTEST(workspace()->clientArea(PlacementArea, 1, 1), "screen1Maximized"); | 202 | QTEST(workspace()->clientArea(PlacementArea, 1, 1), "screen1Maximized"); | ||
300 | QTEST(workspace()->clientArea(MaximizeArea, 1, 1), "screen1Maximized"); | 203 | QTEST(workspace()->clientArea(MaximizeArea, 1, 1), "screen1Maximized"); | ||
301 | QTEST(workspace()->clientArea(WorkArea, 0, 1), "workArea"); | 204 | QTEST(workspace()->clientArea(WorkArea, 0, 1), "workArea"); | ||
205 | | ||||
206 | // delete all surfaces | ||||
207 | for (auto it = clients.begin(); it != clients.end(); it++) { | ||||
208 | QSignalSpy destroyedSpy(it.value(), &QObject::destroyed); | ||||
209 | QVERIFY(destroyedSpy.isValid()); | ||||
210 | delete it.key(); | ||||
211 | QVERIFY(destroyedSpy.wait()); | ||||
212 | } | ||||
302 | } | 213 | } | ||
303 | 214 | | |||
304 | void StrutsTest::testMoveWaylandPanel() | 215 | void StrutsTest::testMoveWaylandPanel() | ||
305 | { | 216 | { | ||
306 | // this test verifies that repositioning a Wayland panel updates the client area | 217 | // this test verifies that repositioning a Wayland panel updates the client area | ||
307 | using namespace KWayland::Client; | 218 | using namespace KWayland::Client; | ||
308 | const QRect windowGeometry(0, 1000, 1280, 24); | 219 | const QRect windowGeometry(0, 1000, 1280, 24); | ||
309 | QScopedPointer<Surface> surface(m_compositor->createSurface()); | 220 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
310 | QScopedPointer<ShellSurface> shellSurface(m_shell->createSurface(surface.data())); | 221 | QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data())); | ||
311 | Q_UNUSED(shellSurface) | 222 | Q_UNUSED(shellSurface) | ||
312 | QScopedPointer<PlasmaShellSurface> plasmaSurface(m_plasmaShell->createSurface(surface.data())); | 223 | QScopedPointer<PlasmaShellSurface> plasmaSurface(m_plasmaShell->createSurface(surface.data())); | ||
313 | plasmaSurface->setPosition(windowGeometry.topLeft()); | 224 | plasmaSurface->setPosition(windowGeometry.topLeft()); | ||
314 | plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); | 225 | plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); | ||
315 | 226 | | |||
316 | QSignalSpy windowCreatedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 227 | QSignalSpy windowCreatedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
317 | QVERIFY(windowCreatedSpy.isValid()); | 228 | QVERIFY(windowCreatedSpy.isValid()); | ||
318 | 229 | | |||
319 | // map the window | 230 | // map the window | ||
320 | QImage img(windowGeometry.size(), QImage::Format_RGB32); | 231 | Test::render(surface.data(), windowGeometry.size(), Qt::red, QImage::Format_RGB32); | ||
321 | img.fill(Qt::red); | | |||
322 | surface->attachBuffer(m_shm->createBuffer(img)); | | |||
323 | surface->damage(QRect(QPoint(0, 0), windowGeometry.size())); | | |||
324 | surface->commit(Surface::CommitFlag::None); | | |||
325 | 232 | | |||
326 | QVERIFY(windowCreatedSpy.wait()); | 233 | QVERIFY(windowCreatedSpy.wait()); | ||
327 | QCOMPARE(windowCreatedSpy.count(), 1); | 234 | QCOMPARE(windowCreatedSpy.count(), 1); | ||
328 | auto c = windowCreatedSpy.first().first().value<ShellClient*>(); | 235 | auto c = windowCreatedSpy.first().first().value<ShellClient*>(); | ||
329 | QVERIFY(c); | 236 | QVERIFY(c); | ||
330 | QVERIFY(!c->isActive()); | 237 | QVERIFY(!c->isActive()); | ||
331 | QCOMPARE(c->geometry(), windowGeometry); | 238 | QCOMPARE(c->geometry(), windowGeometry); | ||
332 | QVERIFY(c->isDock()); | 239 | QVERIFY(c->isDock()); | ||
Show All 24 Lines | 261 | { | |||
357 | //First enable maxmizing policy | 264 | //First enable maxmizing policy | ||
358 | KConfigGroup group = kwinApp()->config()->group("Windows"); | 265 | KConfigGroup group = kwinApp()->config()->group("Windows"); | ||
359 | group.writeEntry("Placement", "Maximizing"); | 266 | group.writeEntry("Placement", "Maximizing"); | ||
360 | group.sync(); | 267 | group.sync(); | ||
361 | workspace()->slotReconfigure(); | 268 | workspace()->slotReconfigure(); | ||
362 | 269 | | |||
363 | // create first top panel | 270 | // create first top panel | ||
364 | const QRect windowGeometry(0, 0, 1280, 60); | 271 | const QRect windowGeometry(0, 0, 1280, 60); | ||
365 | QScopedPointer<Surface> surface(m_compositor->createSurface()); | 272 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
366 | QScopedPointer<ShellSurface> shellSurface(m_shell->createSurface(surface.data())); | 273 | QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data())); | ||
367 | Q_UNUSED(shellSurface) | 274 | Q_UNUSED(shellSurface) | ||
368 | QScopedPointer<PlasmaShellSurface> plasmaSurface(m_plasmaShell->createSurface(surface.data())); | 275 | QScopedPointer<PlasmaShellSurface> plasmaSurface(m_plasmaShell->createSurface(surface.data())); | ||
369 | plasmaSurface->setPosition(windowGeometry.topLeft()); | 276 | plasmaSurface->setPosition(windowGeometry.topLeft()); | ||
370 | plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); | 277 | plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); | ||
371 | 278 | | |||
372 | QSignalSpy windowCreatedSpy(waylandServer(), &WaylandServer::shellClientAdded); | 279 | QSignalSpy windowCreatedSpy(waylandServer(), &WaylandServer::shellClientAdded); | ||
373 | QVERIFY(windowCreatedSpy.isValid()); | 280 | QVERIFY(windowCreatedSpy.isValid()); | ||
374 | 281 | | |||
375 | // map the first panel | 282 | // map the first panel | ||
376 | QImage img(windowGeometry.size(), QImage::Format_RGB32); | 283 | Test::render(surface.data(), windowGeometry.size(), Qt::red, QImage::Format_RGB32); | ||
377 | img.fill(Qt::red); | | |||
378 | surface->attachBuffer(m_shm->createBuffer(img)); | | |||
379 | surface->damage(QRect(QPoint(0, 0), windowGeometry.size())); | | |||
380 | surface->commit(Surface::CommitFlag::None); | | |||
381 | 284 | | |||
382 | QVERIFY(windowCreatedSpy.wait()); | 285 | QVERIFY(windowCreatedSpy.wait()); | ||
383 | QCOMPARE(windowCreatedSpy.count(), 1); | 286 | QCOMPARE(windowCreatedSpy.count(), 1); | ||
384 | 287 | | |||
385 | auto c = windowCreatedSpy.first().first().value<ShellClient*>(); | 288 | auto c = windowCreatedSpy.first().first().value<ShellClient*>(); | ||
386 | QVERIFY(c); | 289 | QVERIFY(c); | ||
387 | QVERIFY(!c->isActive()); | 290 | QVERIFY(!c->isActive()); | ||
388 | QCOMPARE(c->geometry(), windowGeometry); | 291 | QCOMPARE(c->geometry(), windowGeometry); | ||
389 | QVERIFY(c->isDock()); | 292 | QVERIFY(c->isDock()); | ||
390 | QVERIFY(c->hasStrut()); | 293 | QVERIFY(c->hasStrut()); | ||
391 | windowCreatedSpy.clear(); | 294 | windowCreatedSpy.clear(); | ||
392 | 295 | | |||
393 | QCOMPARE(workspace()->clientArea(PlacementArea, 0, 1), QRect(0, 60, 1280, 964)); | 296 | QCOMPARE(workspace()->clientArea(PlacementArea, 0, 1), QRect(0, 60, 1280, 964)); | ||
394 | QCOMPARE(workspace()->clientArea(MaximizeArea, 0, 1), QRect(0, 60, 1280, 964)); | 297 | QCOMPARE(workspace()->clientArea(MaximizeArea, 0, 1), QRect(0, 60, 1280, 964)); | ||
395 | QCOMPARE(workspace()->clientArea(PlacementArea, 1, 1), QRect(1280, 0, 1280, 1024)); | 298 | QCOMPARE(workspace()->clientArea(PlacementArea, 1, 1), QRect(1280, 0, 1280, 1024)); | ||
396 | QCOMPARE(workspace()->clientArea(MaximizeArea, 1, 1), QRect(1280, 0, 1280, 1024)); | 299 | QCOMPARE(workspace()->clientArea(MaximizeArea, 1, 1), QRect(1280, 0, 1280, 1024)); | ||
397 | QCOMPARE(workspace()->clientArea(WorkArea, 0, 1), QRect(0, 60, 2560, 964)); | 300 | QCOMPARE(workspace()->clientArea(WorkArea, 0, 1), QRect(0, 60, 2560, 964)); | ||
398 | 301 | | |||
399 | // create another bottom panel | 302 | // create another bottom panel | ||
400 | const QRect windowGeometry2(0, 874, 1280, 150); | 303 | const QRect windowGeometry2(0, 874, 1280, 150); | ||
401 | QScopedPointer<Surface> surface2(m_compositor->createSurface()); | 304 | QScopedPointer<Surface> surface2(Test::createSurface()); | ||
402 | QScopedPointer<ShellSurface> shellSurface2(m_shell->createSurface(surface2.data())); | 305 | QScopedPointer<ShellSurface> shellSurface2(Test::createShellSurface(surface2.data())); | ||
403 | Q_UNUSED(shellSurface2) | 306 | Q_UNUSED(shellSurface2) | ||
404 | QScopedPointer<PlasmaShellSurface> plasmaSurface2(m_plasmaShell->createSurface(surface2.data())); | 307 | QScopedPointer<PlasmaShellSurface> plasmaSurface2(m_plasmaShell->createSurface(surface2.data())); | ||
405 | plasmaSurface2->setPosition(windowGeometry2.topLeft()); | 308 | plasmaSurface2->setPosition(windowGeometry2.topLeft()); | ||
406 | plasmaSurface2->setRole(PlasmaShellSurface::Role::Panel); | 309 | plasmaSurface2->setRole(PlasmaShellSurface::Role::Panel); | ||
407 | 310 | | |||
408 | QImage img2(windowGeometry2.size(), QImage::Format_RGB32); | 311 | Test::render(surface2.data(), windowGeometry2.size(), Qt::blue, QImage::Format_RGB32); | ||
409 | img2.fill(Qt::blue); | | |||
410 | surface2->attachBuffer(m_shm->createBuffer(img2)); | | |||
411 | surface2->damage(QRect(QPoint(0, 0), windowGeometry2.size())); | | |||
412 | surface2->commit(Surface::CommitFlag::None); | | |||
413 | 312 | | |||
414 | QVERIFY(windowCreatedSpy.wait()); | 313 | QVERIFY(windowCreatedSpy.wait()); | ||
415 | QCOMPARE(windowCreatedSpy.count(), 1); | 314 | QCOMPARE(windowCreatedSpy.count(), 1); | ||
416 | 315 | | |||
417 | auto c1 = windowCreatedSpy.first().first().value<ShellClient*>(); | 316 | auto c1 = windowCreatedSpy.first().first().value<ShellClient*>(); | ||
418 | QVERIFY(c1); | 317 | QVERIFY(c1); | ||
419 | QVERIFY(!c1->isActive()); | 318 | QVERIFY(!c1->isActive()); | ||
420 | QCOMPARE(c1->geometry(), windowGeometry2); | 319 | QCOMPARE(c1->geometry(), windowGeometry2); | ||
▲ Show 20 Lines • Show All 410 Lines • Show Last 20 Lines |