Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/struts_test.cpp
Show All 25 Lines | |||||
26 | #include "screens.h" | 26 | #include "screens.h" | ||
27 | #include "wayland_server.h" | 27 | #include "wayland_server.h" | ||
28 | #include "workspace.h" | 28 | #include "workspace.h" | ||
29 | #include "shell_client.h" | 29 | #include "shell_client.h" | ||
30 | #include <kwineffects.h> | 30 | #include <kwineffects.h> | ||
31 | 31 | | |||
32 | #include <KWayland/Client/compositor.h> | 32 | #include <KWayland/Client/compositor.h> | ||
33 | #include <KWayland/Client/plasmashell.h> | 33 | #include <KWayland/Client/plasmashell.h> | ||
34 | #include <KWayland/Client/shell.h> | | |||
35 | #include <KWayland/Client/surface.h> | 34 | #include <KWayland/Client/surface.h> | ||
36 | 35 | | |||
37 | #include <KDecoration2/Decoration> | 36 | #include <KDecoration2/Decoration> | ||
38 | 37 | | |||
39 | #include <netwm.h> | 38 | #include <netwm.h> | ||
40 | #include <xcb/xcb_icccm.h> | 39 | #include <xcb/xcb_icccm.h> | ||
41 | 40 | | |||
42 | namespace KWin | 41 | namespace KWin | ||
▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Line(s) | 145 | { | |||
168 | QCOMPARE(workspace()->restrictedMoveArea(-1), QRegion()); | 167 | QCOMPARE(workspace()->restrictedMoveArea(-1), QRegion()); | ||
169 | 168 | | |||
170 | QFETCH(QVector<QRect>, windowGeometries); | 169 | QFETCH(QVector<QRect>, windowGeometries); | ||
171 | // create the panels | 170 | // create the panels | ||
172 | QHash<Surface*, ShellClient*> clients; | 171 | QHash<Surface*, ShellClient*> clients; | ||
173 | for (auto it = windowGeometries.constBegin(), end = windowGeometries.constEnd(); it != end; it++) { | 172 | for (auto it = windowGeometries.constBegin(), end = windowGeometries.constEnd(); it != end; it++) { | ||
174 | const QRect windowGeometry = *it; | 173 | const QRect windowGeometry = *it; | ||
175 | Surface *surface = Test::createSurface(m_compositor); | 174 | Surface *surface = Test::createSurface(m_compositor); | ||
176 | ShellSurface *shellSurface = Test::createShellSurface(surface, surface); | 175 | XdgShellSurface *shellSurface = Test::createXdgShellStableSurface(surface, surface, Test::CreationSetup::CreateOnly); | ||
177 | Q_UNUSED(shellSurface) | | |||
178 | PlasmaShellSurface *plasmaSurface = m_plasmaShell->createSurface(surface, surface); | 176 | PlasmaShellSurface *plasmaSurface = m_plasmaShell->createSurface(surface, surface); | ||
179 | plasmaSurface->setPosition(windowGeometry.topLeft()); | 177 | plasmaSurface->setPosition(windowGeometry.topLeft()); | ||
180 | plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); | 178 | plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); | ||
179 | Test::initXdgShellSurface(surface, shellSurface); | ||||
181 | 180 | | |||
182 | // map the window | 181 | // map the window | ||
183 | auto c = Test::renderAndWaitForShown(surface, windowGeometry.size(), Qt::red, QImage::Format_RGB32); | 182 | auto c = Test::renderAndWaitForShown(surface, windowGeometry.size(), Qt::red, QImage::Format_RGB32); | ||
184 | 183 | | |||
185 | QVERIFY(c); | 184 | QVERIFY(c); | ||
186 | QVERIFY(!c->isActive()); | 185 | QVERIFY(!c->isActive()); | ||
187 | QCOMPARE(c->geometry(), windowGeometry); | 186 | QCOMPARE(c->geometry(), windowGeometry); | ||
188 | QVERIFY(c->isDock()); | 187 | QVERIFY(c->isDock()); | ||
Show All 34 Lines | |||||
223 | } | 222 | } | ||
224 | 223 | | |||
225 | void StrutsTest::testMoveWaylandPanel() | 224 | void StrutsTest::testMoveWaylandPanel() | ||
226 | { | 225 | { | ||
227 | // this test verifies that repositioning a Wayland panel updates the client area | 226 | // this test verifies that repositioning a Wayland panel updates the client area | ||
228 | using namespace KWayland::Client; | 227 | using namespace KWayland::Client; | ||
229 | const QRect windowGeometry(0, 1000, 1280, 24); | 228 | const QRect windowGeometry(0, 1000, 1280, 24); | ||
230 | QScopedPointer<Surface> surface(Test::createSurface()); | 229 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
231 | QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data())); | 230 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data(), surface.data(), Test::CreationSetup::CreateOnly)); | ||
232 | Q_UNUSED(shellSurface) | | |||
233 | QScopedPointer<PlasmaShellSurface> plasmaSurface(m_plasmaShell->createSurface(surface.data())); | 231 | QScopedPointer<PlasmaShellSurface> plasmaSurface(m_plasmaShell->createSurface(surface.data())); | ||
234 | plasmaSurface->setPosition(windowGeometry.topLeft()); | 232 | plasmaSurface->setPosition(windowGeometry.topLeft()); | ||
235 | plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); | 233 | plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); | ||
234 | Test::initXdgShellSurface(surface.data(), shellSurface.data()); | ||||
236 | 235 | | |||
237 | // map the window | 236 | // map the window | ||
238 | auto c = Test::renderAndWaitForShown(surface.data(), windowGeometry.size(), Qt::red, QImage::Format_RGB32); | 237 | auto c = Test::renderAndWaitForShown(surface.data(), windowGeometry.size(), Qt::red, QImage::Format_RGB32); | ||
239 | QVERIFY(c); | 238 | QVERIFY(c); | ||
240 | QVERIFY(!c->isActive()); | 239 | QVERIFY(!c->isActive()); | ||
241 | QCOMPARE(c->geometry(), windowGeometry); | 240 | QCOMPARE(c->geometry(), windowGeometry); | ||
242 | QVERIFY(c->isDock()); | 241 | QVERIFY(c->isDock()); | ||
243 | QVERIFY(c->hasStrut()); | 242 | QVERIFY(c->hasStrut()); | ||
Show All 23 Lines | 262 | { | |||
267 | KConfigGroup group = kwinApp()->config()->group("Windows"); | 266 | KConfigGroup group = kwinApp()->config()->group("Windows"); | ||
268 | group.writeEntry("Placement", "Maximizing"); | 267 | group.writeEntry("Placement", "Maximizing"); | ||
269 | group.sync(); | 268 | group.sync(); | ||
270 | workspace()->slotReconfigure(); | 269 | workspace()->slotReconfigure(); | ||
271 | 270 | | |||
272 | // create first top panel | 271 | // create first top panel | ||
273 | const QRect windowGeometry(0, 0, 1280, 60); | 272 | const QRect windowGeometry(0, 0, 1280, 60); | ||
274 | QScopedPointer<Surface> surface(Test::createSurface()); | 273 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
275 | QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data())); | 274 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data(), surface.data(), Test::CreationSetup::CreateOnly)); | ||
276 | Q_UNUSED(shellSurface) | | |||
277 | QScopedPointer<PlasmaShellSurface> plasmaSurface(m_plasmaShell->createSurface(surface.data())); | 275 | QScopedPointer<PlasmaShellSurface> plasmaSurface(m_plasmaShell->createSurface(surface.data())); | ||
278 | plasmaSurface->setPosition(windowGeometry.topLeft()); | 276 | plasmaSurface->setPosition(windowGeometry.topLeft()); | ||
279 | plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); | 277 | plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); | ||
278 | Test::initXdgShellSurface(surface.data(), shellSurface.data()); | ||||
280 | 279 | | |||
281 | // map the first panel | 280 | // map the first panel | ||
282 | auto c = Test::renderAndWaitForShown(surface.data(), windowGeometry.size(), Qt::red, QImage::Format_RGB32); | 281 | auto c = Test::renderAndWaitForShown(surface.data(), windowGeometry.size(), Qt::red, QImage::Format_RGB32); | ||
283 | QVERIFY(c); | 282 | QVERIFY(c); | ||
284 | QVERIFY(!c->isActive()); | 283 | QVERIFY(!c->isActive()); | ||
285 | QCOMPARE(c->geometry(), windowGeometry); | 284 | QCOMPARE(c->geometry(), windowGeometry); | ||
286 | QVERIFY(c->isDock()); | 285 | QVERIFY(c->isDock()); | ||
287 | QVERIFY(c->hasStrut()); | 286 | QVERIFY(c->hasStrut()); | ||
288 | 287 | | |||
289 | QCOMPARE(workspace()->clientArea(PlacementArea, 0, 1), QRect(0, 60, 1280, 964)); | 288 | QCOMPARE(workspace()->clientArea(PlacementArea, 0, 1), QRect(0, 60, 1280, 964)); | ||
290 | QCOMPARE(workspace()->clientArea(MaximizeArea, 0, 1), QRect(0, 60, 1280, 964)); | 289 | QCOMPARE(workspace()->clientArea(MaximizeArea, 0, 1), QRect(0, 60, 1280, 964)); | ||
291 | QCOMPARE(workspace()->clientArea(PlacementArea, 1, 1), QRect(1280, 0, 1280, 1024)); | 290 | QCOMPARE(workspace()->clientArea(PlacementArea, 1, 1), QRect(1280, 0, 1280, 1024)); | ||
292 | QCOMPARE(workspace()->clientArea(MaximizeArea, 1, 1), QRect(1280, 0, 1280, 1024)); | 291 | QCOMPARE(workspace()->clientArea(MaximizeArea, 1, 1), QRect(1280, 0, 1280, 1024)); | ||
293 | QCOMPARE(workspace()->clientArea(WorkArea, 0, 1), QRect(0, 60, 2560, 964)); | 292 | QCOMPARE(workspace()->clientArea(WorkArea, 0, 1), QRect(0, 60, 2560, 964)); | ||
294 | 293 | | |||
295 | // create another bottom panel | 294 | // create another bottom panel | ||
296 | const QRect windowGeometry2(0, 874, 1280, 150); | 295 | const QRect windowGeometry2(0, 874, 1280, 150); | ||
297 | QScopedPointer<Surface> surface2(Test::createSurface()); | 296 | QScopedPointer<Surface> surface2(Test::createSurface()); | ||
298 | QScopedPointer<ShellSurface> shellSurface2(Test::createShellSurface(surface2.data())); | 297 | QScopedPointer<XdgShellSurface> shellSurface2(Test::createXdgShellStableSurface(surface2.data(), surface2.data(), Test::CreationSetup::CreateOnly)); | ||
299 | Q_UNUSED(shellSurface2) | | |||
300 | QScopedPointer<PlasmaShellSurface> plasmaSurface2(m_plasmaShell->createSurface(surface2.data())); | 298 | QScopedPointer<PlasmaShellSurface> plasmaSurface2(m_plasmaShell->createSurface(surface2.data())); | ||
301 | plasmaSurface2->setPosition(windowGeometry2.topLeft()); | 299 | plasmaSurface2->setPosition(windowGeometry2.topLeft()); | ||
302 | plasmaSurface2->setRole(PlasmaShellSurface::Role::Panel); | 300 | plasmaSurface2->setRole(PlasmaShellSurface::Role::Panel); | ||
301 | Test::initXdgShellSurface(surface2.data(), shellSurface2.data()); | ||||
303 | 302 | | |||
304 | auto c1 = Test::renderAndWaitForShown(surface2.data(), windowGeometry2.size(), Qt::blue, QImage::Format_RGB32); | 303 | auto c1 = Test::renderAndWaitForShown(surface2.data(), windowGeometry2.size(), Qt::blue, QImage::Format_RGB32); | ||
305 | 304 | | |||
306 | QVERIFY(c1); | 305 | QVERIFY(c1); | ||
307 | QVERIFY(!c1->isActive()); | 306 | QVERIFY(!c1->isActive()); | ||
308 | QCOMPARE(c1->geometry(), windowGeometry2); | 307 | QCOMPARE(c1->geometry(), windowGeometry2); | ||
309 | QVERIFY(c1->isDock()); | 308 | QVERIFY(c1->isDock()); | ||
310 | QVERIFY(c1->hasStrut()); | 309 | QVERIFY(c1->hasStrut()); | ||
311 | 310 | | |||
312 | QCOMPARE(workspace()->clientArea(PlacementArea, 0, 1), QRect(0, 60, 1280, 814)); | 311 | QCOMPARE(workspace()->clientArea(PlacementArea, 0, 1), QRect(0, 60, 1280, 814)); | ||
313 | QCOMPARE(workspace()->clientArea(MaximizeArea, 0, 1), QRect(0, 60, 1280, 814)); | 312 | QCOMPARE(workspace()->clientArea(MaximizeArea, 0, 1), QRect(0, 60, 1280, 814)); | ||
314 | QCOMPARE(workspace()->clientArea(PlacementArea, 1, 1), QRect(1280, 0, 1280, 1024)); | 313 | QCOMPARE(workspace()->clientArea(PlacementArea, 1, 1), QRect(1280, 0, 1280, 1024)); | ||
315 | QCOMPARE(workspace()->clientArea(MaximizeArea, 1, 1), QRect(1280, 0, 1280, 1024)); | 314 | QCOMPARE(workspace()->clientArea(MaximizeArea, 1, 1), QRect(1280, 0, 1280, 1024)); | ||
316 | QCOMPARE(workspace()->clientArea(WorkArea, 0, 1), QRect(0, 60, 2560, 814)); | 315 | QCOMPARE(workspace()->clientArea(WorkArea, 0, 1), QRect(0, 60, 2560, 814)); | ||
316 | | ||||
317 | // Destroy test clients. | ||||
318 | shellSurface.reset(); | ||||
319 | QVERIFY(Test::waitForWindowDestroyed(c)); | ||||
320 | shellSurface2.reset(); | ||||
321 | QVERIFY(Test::waitForWindowDestroyed(c1)); | ||||
317 | } | 322 | } | ||
318 | 323 | | |||
319 | void StrutsTest::testX11Struts_data() | 324 | void StrutsTest::testX11Struts_data() | ||
320 | { | 325 | { | ||
321 | QTest::addColumn<QRect>("windowGeometry"); | 326 | QTest::addColumn<QRect>("windowGeometry"); | ||
322 | QTest::addColumn<int>("leftStrut"); | 327 | QTest::addColumn<int>("leftStrut"); | ||
323 | QTest::addColumn<int>("rightStrut"); | 328 | QTest::addColumn<int>("rightStrut"); | ||
324 | QTest::addColumn<int>("topStrut"); | 329 | QTest::addColumn<int>("topStrut"); | ||
▲ Show 20 Lines • Show All 638 Lines • Show Last 20 Lines |