Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/transient_placement.cpp
Show First 20 Lines • Show All 226 Lines • ▼ Show 20 Line(s) | 215 | { | |||
---|---|---|---|---|---|
227 | QVERIFY(surface); | 227 | QVERIFY(surface); | ||
228 | auto parentShellSurface = Test::createXdgShellStableSurface(surface, Test::waylandCompositor()); | 228 | auto parentShellSurface = Test::createXdgShellStableSurface(surface, Test::waylandCompositor()); | ||
229 | QVERIFY(parentShellSurface); | 229 | QVERIFY(parentShellSurface); | ||
230 | auto parent = Test::renderAndWaitForShown(surface, parentSize, Qt::blue); | 230 | auto parent = Test::renderAndWaitForShown(surface, parentSize, Qt::blue); | ||
231 | QVERIFY(parent); | 231 | QVERIFY(parent); | ||
232 | 232 | | |||
233 | QVERIFY(!parent->isDecorated()); | 233 | QVERIFY(!parent->isDecorated()); | ||
234 | parent->move(parentPosition); | 234 | parent->move(parentPosition); | ||
235 | QCOMPARE(parent->geometry(), QRect(parentPosition, parentSize)); | 235 | QCOMPARE(parent->frameGeometry(), QRect(parentPosition, parentSize)); | ||
236 | 236 | | |||
237 | //create popup | 237 | //create popup | ||
238 | QFETCH(XdgPositioner, positioner); | 238 | QFETCH(XdgPositioner, positioner); | ||
239 | 239 | | |||
240 | Surface *transientSurface = Test::createSurface(Test::waylandCompositor()); | 240 | Surface *transientSurface = Test::createSurface(Test::waylandCompositor()); | ||
241 | QVERIFY(transientSurface); | 241 | QVERIFY(transientSurface); | ||
242 | 242 | | |||
243 | auto popup = Test::createXdgShellStablePopup(transientSurface, parentShellSurface, positioner, Test::waylandCompositor(), Test::CreationSetup::CreateOnly); | 243 | auto popup = Test::createXdgShellStablePopup(transientSurface, parentShellSurface, positioner, Test::waylandCompositor(), Test::CreationSetup::CreateOnly); | ||
244 | QSignalSpy configureRequestedSpy(popup, &XdgShellPopup::configureRequested); | 244 | QSignalSpy configureRequestedSpy(popup, &XdgShellPopup::configureRequested); | ||
245 | transientSurface->commit(Surface::CommitFlag::None); | 245 | transientSurface->commit(Surface::CommitFlag::None); | ||
246 | 246 | | |||
247 | configureRequestedSpy.wait(); | 247 | configureRequestedSpy.wait(); | ||
248 | QCOMPARE(configureRequestedSpy.count(), 1); | 248 | QCOMPARE(configureRequestedSpy.count(), 1); | ||
249 | QCOMPARE(configureRequestedSpy.first()[0].value<QRect>(), expectedRelativeGeometry); | 249 | QCOMPARE(configureRequestedSpy.first()[0].value<QRect>(), expectedRelativeGeometry); | ||
250 | popup->ackConfigure(configureRequestedSpy.first()[1].toUInt()); | 250 | popup->ackConfigure(configureRequestedSpy.first()[1].toUInt()); | ||
251 | 251 | | |||
252 | auto transient = Test::renderAndWaitForShown(transientSurface, positioner.initialSize(), Qt::red); | 252 | auto transient = Test::renderAndWaitForShown(transientSurface, positioner.initialSize(), Qt::red); | ||
253 | QVERIFY(transient); | 253 | QVERIFY(transient); | ||
254 | 254 | | |||
255 | QVERIFY(!transient->isDecorated()); | 255 | QVERIFY(!transient->isDecorated()); | ||
256 | QVERIFY(transient->hasTransientPlacementHint()); | 256 | QVERIFY(transient->hasTransientPlacementHint()); | ||
257 | QCOMPARE(transient->geometry(), expectedGeometry); | 257 | QCOMPARE(transient->frameGeometry(), expectedGeometry); | ||
258 | 258 | | |||
259 | QCOMPARE(configureRequestedSpy.count(), 1); // check that we did not get reconfigured | 259 | QCOMPARE(configureRequestedSpy.count(), 1); // check that we did not get reconfigured | ||
260 | } | 260 | } | ||
261 | 261 | | |||
262 | void TransientPlacementTest::testXdgPopupWithPanel() | 262 | void TransientPlacementTest::testXdgPopupWithPanel() | ||
263 | { | 263 | { | ||
264 | using namespace KWayland::Client; | 264 | using namespace KWayland::Client; | ||
265 | 265 | | |||
266 | QScopedPointer<Surface> surface{Test::createSurface()}; | 266 | QScopedPointer<Surface> surface{Test::createSurface()}; | ||
267 | QVERIFY(!surface.isNull()); | 267 | QVERIFY(!surface.isNull()); | ||
268 | QScopedPointer<XdgShellSurface> dockShellSurface{Test::createXdgShellStableSurface(surface.data(), surface.data())}; | 268 | QScopedPointer<XdgShellSurface> dockShellSurface{Test::createXdgShellStableSurface(surface.data(), surface.data())}; | ||
269 | QVERIFY(!dockShellSurface.isNull()); | 269 | QVERIFY(!dockShellSurface.isNull()); | ||
270 | QScopedPointer<PlasmaShellSurface> plasmaSurface(Test::waylandPlasmaShell()->createSurface(surface.data())); | 270 | QScopedPointer<PlasmaShellSurface> plasmaSurface(Test::waylandPlasmaShell()->createSurface(surface.data())); | ||
271 | QVERIFY(!plasmaSurface.isNull()); | 271 | QVERIFY(!plasmaSurface.isNull()); | ||
272 | plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); | 272 | plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); | ||
273 | plasmaSurface->setPosition(QPoint(0, screens()->geometry(0).height() - 50)); | 273 | plasmaSurface->setPosition(QPoint(0, screens()->geometry(0).height() - 50)); | ||
274 | plasmaSurface->setPanelBehavior(PlasmaShellSurface::PanelBehavior::AlwaysVisible); | 274 | plasmaSurface->setPanelBehavior(PlasmaShellSurface::PanelBehavior::AlwaysVisible); | ||
275 | 275 | | |||
276 | // now render and map the window | 276 | // now render and map the window | ||
277 | QVERIFY(workspace()->clientArea(PlacementArea, 0, 1) == workspace()->clientArea(FullScreenArea, 0, 1)); | 277 | QVERIFY(workspace()->clientArea(PlacementArea, 0, 1) == workspace()->clientArea(FullScreenArea, 0, 1)); | ||
278 | auto dock = Test::renderAndWaitForShown(surface.data(), QSize(1280, 50), Qt::blue); | 278 | auto dock = Test::renderAndWaitForShown(surface.data(), QSize(1280, 50), Qt::blue); | ||
279 | QVERIFY(dock); | 279 | QVERIFY(dock); | ||
280 | QCOMPARE(dock->windowType(), NET::Dock); | 280 | QCOMPARE(dock->windowType(), NET::Dock); | ||
281 | QVERIFY(dock->isDock()); | 281 | QVERIFY(dock->isDock()); | ||
282 | QCOMPARE(dock->geometry(), QRect(0, screens()->geometry(0).height() - 50, 1280, 50)); | 282 | QCOMPARE(dock->frameGeometry(), QRect(0, screens()->geometry(0).height() - 50, 1280, 50)); | ||
283 | QCOMPARE(dock->hasStrut(), true); | 283 | QCOMPARE(dock->hasStrut(), true); | ||
284 | QVERIFY(workspace()->clientArea(PlacementArea, 0, 1) != workspace()->clientArea(FullScreenArea, 0, 1)); | 284 | QVERIFY(workspace()->clientArea(PlacementArea, 0, 1) != workspace()->clientArea(FullScreenArea, 0, 1)); | ||
285 | 285 | | |||
286 | //create parent | 286 | //create parent | ||
287 | Surface *parentSurface = Test::createSurface(Test::waylandCompositor()); | 287 | Surface *parentSurface = Test::createSurface(Test::waylandCompositor()); | ||
288 | QVERIFY(parentSurface); | 288 | QVERIFY(parentSurface); | ||
289 | auto parentShellSurface = Test::createXdgShellStableSurface(parentSurface, Test::waylandCompositor()); | 289 | auto parentShellSurface = Test::createXdgShellStableSurface(parentSurface, Test::waylandCompositor()); | ||
290 | QVERIFY(parentShellSurface); | 290 | QVERIFY(parentShellSurface); | ||
291 | auto parent = Test::renderAndWaitForShown(parentSurface, {800, 600}, Qt::blue); | 291 | auto parent = Test::renderAndWaitForShown(parentSurface, {800, 600}, Qt::blue); | ||
292 | QVERIFY(parent); | 292 | QVERIFY(parent); | ||
293 | 293 | | |||
294 | QVERIFY(!parent->isDecorated()); | 294 | QVERIFY(!parent->isDecorated()); | ||
295 | parent->move({0, screens()->geometry(0).height() - 600}); | 295 | parent->move({0, screens()->geometry(0).height() - 600}); | ||
296 | parent->keepInArea(workspace()->clientArea(PlacementArea, parent)); | 296 | parent->keepInArea(workspace()->clientArea(PlacementArea, parent)); | ||
297 | QCOMPARE(parent->geometry(), QRect(0, screens()->geometry(0).height() - 600 - 50, 800, 600)); | 297 | QCOMPARE(parent->frameGeometry(), QRect(0, screens()->geometry(0).height() - 600 - 50, 800, 600)); | ||
298 | 298 | | |||
299 | Surface *transientSurface = Test::createSurface(Test::waylandCompositor()); | 299 | Surface *transientSurface = Test::createSurface(Test::waylandCompositor()); | ||
300 | QVERIFY(transientSurface); | 300 | QVERIFY(transientSurface); | ||
301 | XdgPositioner positioner(QSize(200,200), QRect(50,500, 200,200)); | 301 | XdgPositioner positioner(QSize(200,200), QRect(50,500, 200,200)); | ||
302 | 302 | | |||
303 | auto transientShellSurface = Test::createXdgShellStablePopup(transientSurface, parentShellSurface, positioner, Test::waylandCompositor()); | 303 | auto transientShellSurface = Test::createXdgShellStablePopup(transientSurface, parentShellSurface, positioner, Test::waylandCompositor()); | ||
304 | auto transient = Test::renderAndWaitForShown(transientSurface, positioner.initialSize(), Qt::red); | 304 | auto transient = Test::renderAndWaitForShown(transientSurface, positioner.initialSize(), Qt::red); | ||
305 | QVERIFY(transient); | 305 | QVERIFY(transient); | ||
306 | 306 | | |||
307 | QVERIFY(!transient->isDecorated()); | 307 | QVERIFY(!transient->isDecorated()); | ||
308 | QVERIFY(transient->hasTransientPlacementHint()); | 308 | QVERIFY(transient->hasTransientPlacementHint()); | ||
309 | 309 | | |||
310 | QCOMPARE(transient->geometry(), QRect(50, screens()->geometry(0).height() - 200 - 50, 200, 200)); | 310 | QCOMPARE(transient->frameGeometry(), QRect(50, screens()->geometry(0).height() - 200 - 50, 200, 200)); | ||
311 | 311 | | |||
312 | transientShellSurface->deleteLater(); | 312 | transientShellSurface->deleteLater(); | ||
313 | transientSurface->deleteLater(); | 313 | transientSurface->deleteLater(); | ||
314 | QVERIFY(Test::waitForWindowDestroyed(transient)); | 314 | QVERIFY(Test::waitForWindowDestroyed(transient)); | ||
315 | 315 | | |||
316 | // now parent to fullscreen - on fullscreen the panel is ignored | 316 | // now parent to fullscreen - on fullscreen the panel is ignored | ||
317 | QSignalSpy fullscreenSpy{parentShellSurface, &XdgShellSurface::configureRequested}; | 317 | QSignalSpy fullscreenSpy{parentShellSurface, &XdgShellSurface::configureRequested}; | ||
318 | QVERIFY(fullscreenSpy.isValid()); | 318 | QVERIFY(fullscreenSpy.isValid()); | ||
319 | parent->setFullScreen(true); | 319 | parent->setFullScreen(true); | ||
320 | QVERIFY(fullscreenSpy.wait()); | 320 | QVERIFY(fullscreenSpy.wait()); | ||
321 | parentShellSurface->ackConfigure(fullscreenSpy.first().at(2).value<quint32>()); | 321 | parentShellSurface->ackConfigure(fullscreenSpy.first().at(2).value<quint32>()); | ||
322 | QSignalSpy geometryShapeChangedSpy{parent, &XdgShellClient::geometryShapeChanged}; | 322 | QSignalSpy geometryShapeChangedSpy{parent, &XdgShellClient::geometryShapeChanged}; | ||
323 | QVERIFY(geometryShapeChangedSpy.isValid()); | 323 | QVERIFY(geometryShapeChangedSpy.isValid()); | ||
324 | Test::render(parentSurface, fullscreenSpy.first().at(0).toSize(), Qt::red); | 324 | Test::render(parentSurface, fullscreenSpy.first().at(0).toSize(), Qt::red); | ||
325 | QVERIFY(geometryShapeChangedSpy.wait()); | 325 | QVERIFY(geometryShapeChangedSpy.wait()); | ||
326 | QCOMPARE(parent->geometry(), screens()->geometry(0)); | 326 | QCOMPARE(parent->frameGeometry(), screens()->geometry(0)); | ||
327 | QVERIFY(parent->isFullScreen()); | 327 | QVERIFY(parent->isFullScreen()); | ||
328 | 328 | | |||
329 | // another transient, with same hints as before from bottom of window | 329 | // another transient, with same hints as before from bottom of window | ||
330 | transientSurface = Test::createSurface(Test::waylandCompositor()); | 330 | transientSurface = Test::createSurface(Test::waylandCompositor()); | ||
331 | QVERIFY(transientSurface); | 331 | QVERIFY(transientSurface); | ||
332 | 332 | | |||
333 | XdgPositioner positioner2(QSize(200,200), QRect(50,screens()->geometry(0).height()-100, 200,200)); | 333 | XdgPositioner positioner2(QSize(200,200), QRect(50,screens()->geometry(0).height()-100, 200,200)); | ||
334 | transientShellSurface = Test::createXdgShellStablePopup(transientSurface, parentShellSurface, positioner2, Test::waylandCompositor()); | 334 | transientShellSurface = Test::createXdgShellStablePopup(transientSurface, parentShellSurface, positioner2, Test::waylandCompositor()); | ||
335 | transient = Test::renderAndWaitForShown(transientSurface, positioner2.initialSize(), Qt::red); | 335 | transient = Test::renderAndWaitForShown(transientSurface, positioner2.initialSize(), Qt::red); | ||
336 | QVERIFY(transient); | 336 | QVERIFY(transient); | ||
337 | 337 | | |||
338 | QVERIFY(!transient->isDecorated()); | 338 | QVERIFY(!transient->isDecorated()); | ||
339 | QVERIFY(transient->hasTransientPlacementHint()); | 339 | QVERIFY(transient->hasTransientPlacementHint()); | ||
340 | 340 | | |||
341 | QCOMPARE(transient->geometry(), QRect(50, screens()->geometry(0).height() - 200, 200, 200)); | 341 | QCOMPARE(transient->frameGeometry(), QRect(50, screens()->geometry(0).height() - 200, 200, 200)); | ||
342 | } | 342 | } | ||
343 | 343 | | |||
344 | } | 344 | } | ||
345 | 345 | | |||
346 | WAYLANDTEST_MAIN(KWin::TransientPlacementTest) | 346 | WAYLANDTEST_MAIN(KWin::TransientPlacementTest) | ||
347 | #include "transient_placement.moc" | 347 | #include "transient_placement.moc" |