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