Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/test_helpers.cpp
Show First 20 Lines • Show All 451 Lines • ▼ Show 20 Line(s) | 448 | { | |||
---|---|---|---|---|---|
452 | auto s = s_waylandConnection.shell->createSurface(surface, parent); | 452 | auto s = s_waylandConnection.shell->createSurface(surface, parent); | ||
453 | if (!s->isValid()) { | 453 | if (!s->isValid()) { | ||
454 | delete s; | 454 | delete s; | ||
455 | return nullptr; | 455 | return nullptr; | ||
456 | } | 456 | } | ||
457 | return s; | 457 | return s; | ||
458 | } | 458 | } | ||
459 | 459 | | |||
460 | XdgShellSurface *createXdgShellV5Surface(Surface *surface, QObject *parent) | 460 | XdgShellSurface *createXdgShellV5Surface(Surface *surface, QObject *parent, CreationSetup creationSetup) | ||
461 | { | 461 | { | ||
462 | if (!s_waylandConnection.xdgShellV5) { | 462 | if (!s_waylandConnection.xdgShellV5) { | ||
463 | return nullptr; | 463 | return nullptr; | ||
464 | } | 464 | } | ||
465 | auto s = s_waylandConnection.xdgShellV5->createSurface(surface, parent); | 465 | auto s = s_waylandConnection.xdgShellV5->createSurface(surface, parent); | ||
466 | if (!s->isValid()) { | 466 | if (!s->isValid()) { | ||
467 | delete s; | 467 | delete s; | ||
468 | return nullptr; | 468 | return nullptr; | ||
469 | } | 469 | } | ||
470 | if (creationSetup == CreationSetup::CreateAndConfigure) { | ||||
471 | initXdgShellSurface(surface, s); | ||||
472 | } | ||||
470 | return s; | 473 | return s; | ||
471 | } | 474 | } | ||
472 | 475 | | |||
473 | XdgShellSurface *createXdgShellV6Surface(Surface *surface, QObject *parent) | 476 | XdgShellSurface *createXdgShellV6Surface(Surface *surface, QObject *parent, CreationSetup creationSetup) | ||
474 | { | 477 | { | ||
475 | if (!s_waylandConnection.xdgShellV6) { | 478 | if (!s_waylandConnection.xdgShellV6) { | ||
476 | return nullptr; | 479 | return nullptr; | ||
477 | } | 480 | } | ||
478 | auto s = s_waylandConnection.xdgShellV6->createSurface(surface, parent); | 481 | auto s = s_waylandConnection.xdgShellV6->createSurface(surface, parent); | ||
479 | if (!s->isValid()) { | 482 | if (!s->isValid()) { | ||
480 | delete s; | 483 | delete s; | ||
481 | return nullptr; | 484 | return nullptr; | ||
482 | } | 485 | } | ||
486 | if (creationSetup == CreationSetup::CreateAndConfigure) { | ||||
487 | initXdgShellSurface(surface, s); | ||||
488 | } | ||||
483 | return s; | 489 | return s; | ||
484 | } | 490 | } | ||
485 | 491 | | |||
486 | XdgShellSurface *createXdgShellStableSurface(Surface *surface, QObject *parent) | 492 | XdgShellSurface *createXdgShellStableSurface(Surface *surface, QObject *parent, CreationSetup creationSetup) | ||
487 | { | 493 | { | ||
488 | if (!s_waylandConnection.xdgShellStable) { | 494 | if (!s_waylandConnection.xdgShellStable) { | ||
489 | return nullptr; | 495 | return nullptr; | ||
490 | } | 496 | } | ||
491 | auto s = s_waylandConnection.xdgShellStable->createSurface(surface, parent); | 497 | auto s = s_waylandConnection.xdgShellStable->createSurface(surface, parent); | ||
492 | if (!s->isValid()) { | 498 | if (!s->isValid()) { | ||
493 | delete s; | 499 | delete s; | ||
494 | return nullptr; | 500 | return nullptr; | ||
495 | } | 501 | } | ||
502 | if (creationSetup == CreationSetup::CreateAndConfigure) { | ||||
503 | initXdgShellSurface(surface, s); | ||||
504 | } | ||||
496 | return s; | 505 | return s; | ||
497 | } | 506 | } | ||
498 | 507 | | |||
499 | XdgShellPopup *createXdgShellStablePopup(Surface *surface, XdgShellSurface *parentSurface, const XdgPositioner &positioner, QObject *parent) | 508 | XdgShellPopup *createXdgShellStablePopup(Surface *surface, XdgShellSurface *parentSurface, const XdgPositioner &positioner, QObject *parent, CreationSetup creationSetup) | ||
500 | { | 509 | { | ||
501 | if (!s_waylandConnection.xdgShellStable) { | 510 | if (!s_waylandConnection.xdgShellStable) { | ||
502 | return nullptr; | 511 | return nullptr; | ||
503 | } | 512 | } | ||
504 | auto s = s_waylandConnection.xdgShellStable->createPopup(surface, parentSurface, positioner, parent); | 513 | auto s = s_waylandConnection.xdgShellStable->createPopup(surface, parentSurface, positioner, parent); | ||
505 | if (!s->isValid()) { | 514 | if (!s->isValid()) { | ||
506 | delete s; | 515 | delete s; | ||
507 | return nullptr; | 516 | return nullptr; | ||
508 | } | 517 | } | ||
518 | if (creationSetup == CreationSetup::CreateAndConfigure) { | ||||
519 | initXdgShellPopup(surface, s); | ||||
520 | } | ||||
509 | return s; | 521 | return s; | ||
510 | } | 522 | } | ||
511 | 523 | | |||
524 | void initXdgShellSurface(KWayland::Client::Surface *surface, KWayland::Client::XdgShellSurface *shellSurface) | ||||
525 | { | ||||
526 | //wait for configure | ||||
527 | QSignalSpy configureRequestedSpy(shellSurface, &KWayland::Client::XdgShellSurface::configureRequested); | ||||
528 | QVERIFY(configureRequestedSpy.isValid()); | ||||
529 | surface->commit(Surface::CommitFlag::None); | ||||
zzag: We don't want the frame callback. | |||||
530 | configureRequestedSpy.wait(); | ||||
531 | shellSurface->ackConfigure(configureRequestedSpy.last()[2].toInt()); | ||||
532 | } | ||||
533 | | ||||
534 | void initXdgShellPopup(KWayland::Client::Surface *surface, KWayland::Client::XdgShellPopup *shellPopup) | ||||
535 | { | ||||
536 | //wait for configure | ||||
537 | QSignalSpy configureRequestedSpy(shellPopup, &KWayland::Client::XdgShellPopup::configureRequested); | ||||
538 | QVERIFY(configureRequestedSpy.isValid()); | ||||
539 | surface->commit(Surface::CommitFlag::None); | ||||
540 | configureRequestedSpy.wait(); | ||||
541 | shellPopup->ackConfigure(configureRequestedSpy.last()[1].toInt()); | ||||
542 | } | ||||
543 | | ||||
544 | | ||||
512 | QObject *createShellSurface(ShellSurfaceType type, KWayland::Client::Surface *surface, QObject *parent) | 545 | QObject *createShellSurface(ShellSurfaceType type, KWayland::Client::Surface *surface, QObject *parent) | ||
513 | { | 546 | { | ||
514 | switch (type) { | 547 | switch (type) { | ||
515 | case ShellSurfaceType::WlShell: | 548 | case ShellSurfaceType::WlShell: | ||
516 | return createShellSurface(surface, parent); | 549 | return createShellSurface(surface, parent); | ||
517 | case ShellSurfaceType::XdgShellV5: | 550 | case ShellSurfaceType::XdgShellV5: | ||
518 | return createXdgShellV5Surface(surface, parent); | 551 | return createXdgShellV5Surface(surface, parent, CreationSetup::CreateAndConfigure); | ||
519 | case ShellSurfaceType::XdgShellV6: | 552 | case ShellSurfaceType::XdgShellV6: | ||
520 | return createXdgShellV6Surface(surface, parent); | 553 | return createXdgShellV6Surface(surface, parent, CreationSetup::CreateAndConfigure); | ||
521 | case ShellSurfaceType::XdgShellStable: | 554 | case ShellSurfaceType::XdgShellStable: | ||
522 | return createXdgShellStableSurface(surface, parent); | 555 | return createXdgShellStableSurface(surface, parent, CreationSetup::CreateAndConfigure); | ||
523 | default: | 556 | default: | ||
524 | Q_UNREACHABLE(); | 557 | Q_UNREACHABLE(); | ||
525 | return nullptr; | 558 | return nullptr; | ||
526 | } | 559 | } | ||
527 | } | 560 | } | ||
528 | 561 | | |||
562 | KWayland::Client::XdgShellSurface *createXdgShellSurface(ShellSurfaceType type, KWayland::Client::Surface *surface, QObject *parent, CreationSetup creationSetup) | ||||
563 | { | ||||
564 | switch (type) { | ||||
565 | case ShellSurfaceType::XdgShellV5: | ||||
566 | return createXdgShellV5Surface(surface, parent, creationSetup); | ||||
567 | case ShellSurfaceType::XdgShellV6: | ||||
568 | return createXdgShellV6Surface(surface, parent, creationSetup); | ||||
569 | case ShellSurfaceType::XdgShellStable: | ||||
570 | return createXdgShellStableSurface(surface, parent, creationSetup); | ||||
571 | default: | ||||
572 | return nullptr; | ||||
573 | } | ||||
574 | } | ||||
575 | | ||||
529 | bool waitForWindowDestroyed(AbstractClient *client) | 576 | bool waitForWindowDestroyed(AbstractClient *client) | ||
530 | { | 577 | { | ||
531 | QSignalSpy destroyedSpy(client, &QObject::destroyed); | 578 | QSignalSpy destroyedSpy(client, &QObject::destroyed); | ||
532 | if (!destroyedSpy.isValid()) { | 579 | if (!destroyedSpy.isValid()) { | ||
533 | return false; | 580 | return false; | ||
534 | } | 581 | } | ||
535 | return destroyedSpy.wait(); | 582 | return destroyedSpy.wait(); | ||
536 | } | 583 | } | ||
▲ Show 20 Lines • Show All 70 Lines • Show Last 20 Lines |
We don't want the frame callback.