本文整理汇总了C++中Registry::create方法的典型用法代码示例。如果您正苦于以下问题:C++ Registry::create方法的具体用法?C++ Registry::create怎么用?C++ Registry::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Registry
的用法示例。
在下文中一共展示了Registry::create方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initializeWayland
//_______________________________________________________
void WindowManager::initializeWayland()
{
#if BREEZE_HAVE_KWAYLAND
if( !Helper::isWayland() ) return;
if( _seat ) {
// already initialized
return;
}
using namespace KWayland::Client;
auto connection = ConnectionThread::fromApplication( this );
if( !connection ) {
return;
}
Registry *registry = new Registry( this );
registry->create( connection );
connect(registry, &Registry::interfacesAnnounced, this,
[registry, this] {
const auto interface = registry->interface( Registry::Interface::Seat );
if( interface.name != 0 ) {
_seat = registry->createSeat( interface.name, interface.version, this );
connect(_seat, &Seat::hasPointerChanged, this, &WindowManager::waylandHasPointerChanged);
}
}
);
registry->setup();
connection->roundtrip();
#endif
}
示例2: init
void InputStackingOrderTest::init()
{
using namespace KWayland::Client;
// setup connection
m_connection = new ConnectionThread;
QSignalSpy connectedSpy(m_connection, &ConnectionThread::connected);
QVERIFY(connectedSpy.isValid());
m_connection->setSocketName(s_socketName);
m_thread = new QThread(this);
m_connection->moveToThread(m_thread);
m_thread->start();
m_connection->initConnection();
QVERIFY(connectedSpy.wait());
m_queue = new EventQueue(this);
QVERIFY(!m_queue->isValid());
m_queue->setup(m_connection);
QVERIFY(m_queue->isValid());
Registry registry;
registry.setEventQueue(m_queue);
QSignalSpy compositorSpy(®istry, &Registry::compositorAnnounced);
QSignalSpy shmSpy(®istry, &Registry::shmAnnounced);
QSignalSpy shellSpy(®istry, &Registry::shellAnnounced);
QSignalSpy seatSpy(®istry, &Registry::seatAnnounced);
QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced);
QVERIFY(allAnnounced.isValid());
QVERIFY(shmSpy.isValid());
QVERIFY(shellSpy.isValid());
QVERIFY(compositorSpy.isValid());
QVERIFY(seatSpy.isValid());
registry.create(m_connection->display());
QVERIFY(registry.isValid());
registry.setup();
QVERIFY(allAnnounced.wait());
QVERIFY(!compositorSpy.isEmpty());
QVERIFY(!shmSpy.isEmpty());
QVERIFY(!shellSpy.isEmpty());
QVERIFY(!seatSpy.isEmpty());
m_compositor = registry.createCompositor(compositorSpy.first().first().value<quint32>(), compositorSpy.first().last().value<quint32>(), this);
QVERIFY(m_compositor->isValid());
m_shm = registry.createShmPool(shmSpy.first().first().value<quint32>(), shmSpy.first().last().value<quint32>(), this);
QVERIFY(m_shm->isValid());
m_shell = registry.createShell(shellSpy.first().first().value<quint32>(), shellSpy.first().last().value<quint32>(), this);
QVERIFY(m_shell->isValid());
m_seat = registry.createSeat(seatSpy.first().first().value<quint32>(), seatSpy.first().last().value<quint32>(), this);
QVERIFY(m_seat->isValid());
QSignalSpy hasPointerSpy(m_seat, &Seat::hasPointerChanged);
QVERIFY(hasPointerSpy.isValid());
QVERIFY(hasPointerSpy.wait());
screens()->setCurrent(0);
Cursor::setPos(QPoint(640, 512));
}
示例3: main
int main(int argc, char **argv)
{
qputenv("QT_QPA_PLATFORM", QByteArrayLiteral("wayland"));
QApplication app(argc, argv);
QWidget window;
ConnectionThread *connection = ConnectionThread::fromApplication();
Registry registry;
registry.create(connection);
QObject::connect(®istry, &Registry::interfacesAnnounced, &app,
[®istry, &window] {
const bool hasDpms = registry.hasInterface(Registry::Interface::Dpms);
QLabel *hasDpmsLabel = new QLabel(&window);
if (hasDpms) {
hasDpmsLabel->setText(QStringLiteral("Compositor provides a DpmsManager"));
} else {
hasDpmsLabel->setText(QStringLiteral("Compositor does not provid a DpmsManager"));
}
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(hasDpmsLabel);
QFrame *hline = new QFrame;
hline->setFrameShape(QFrame::HLine);
layout->addWidget(hline);
DpmsManager *dpmsManager = nullptr;
if (hasDpms) {
const auto dpmsData = registry.interface(Registry::Interface::Dpms);
dpmsManager = registry.createDpmsManager(dpmsData.name, dpmsData.version);
}
// get all Outputs
const auto outputs = registry.interfaces(Registry::Interface::Output);
for (auto o : outputs) {
layout->addLayout(setupOutput(o, ®istry, dpmsManager));
QFrame *hline = new QFrame;
hline->setFrameShape(QFrame::HLine);
layout->addWidget(hline);
}
window.setLayout(layout);
window.show();
}, Qt::QueuedConnection
);
registry.setup();
return app.exec();
}
示例4: setupWaylandIntegration
void MousepadPlugin::setupWaylandIntegration()
{
if (!QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) {
// not wayland
return;
}
using namespace KWayland::Client;
ConnectionThread *connection = ConnectionThread::fromApplication(this);
if (!connection) {
// failed to get the Connection from Qt
return;
}
Registry *registry = new Registry(this);
registry->create(connection);
connect(registry, &Registry::fakeInputAnnounced, this,
[this, registry] (quint32 name, quint32 version) {
m_waylandInput = registry->createFakeInput(name, version, this);
}
);
registry->setup();
}
示例5: testScreenAddRemove
void ScreenChangesTest::testScreenAddRemove()
{
// this test verifies that when a new screen is added it gets synced to Wayland
// first create a registry to get signals about Outputs announced/removed
Registry registry;
QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced);
QVERIFY(allAnnounced.isValid());
QSignalSpy outputAnnouncedSpy(®istry, &Registry::outputAnnounced);
QVERIFY(outputAnnouncedSpy.isValid());
QSignalSpy outputRemovedSpy(®istry, &Registry::outputRemoved);
QVERIFY(outputRemovedSpy.isValid());
registry.create(Test::waylandConnection());
QVERIFY(registry.isValid());
registry.setup();
QVERIFY(allAnnounced.wait());
// should be one output
QCOMPARE(screens()->count(), 1);
QCOMPARE(outputAnnouncedSpy.count(), 1);
const quint32 firstOutputId = outputAnnouncedSpy.first().first().value<quint32>();
QVERIFY(firstOutputId != 0u);
outputAnnouncedSpy.clear();
// let's announce a new output
QSignalSpy screensChangedSpy(screens(), &Screens::changed);
QVERIFY(screensChangedSpy.isValid());
const QVector<QRect> geometries{QRect(0, 0, 1280, 1024), QRect(1280, 0, 1280, 1024)};
QMetaObject::invokeMethod(kwinApp()->platform(), "outputGeometriesChanged",
Qt::DirectConnection,
Q_ARG(QVector<QRect>, geometries));
QVERIFY(screensChangedSpy.wait());
QCOMPARE(screensChangedSpy.count(), 1);
QCOMPARE(screens()->count(), 2);
QCOMPARE(screens()->geometry(0), geometries.at(0));
QCOMPARE(screens()->geometry(1), geometries.at(1));
// this should result in it getting announced, two new outputs are added...
QVERIFY(outputAnnouncedSpy.wait());
if (outputAnnouncedSpy.count() < 2) {
QVERIFY(outputAnnouncedSpy.wait());
}
QCOMPARE(outputAnnouncedSpy.count(), 2);
// ... and afterward the previous output gets removed
if (outputRemovedSpy.isEmpty()) {
QVERIFY(outputRemovedSpy.wait());
}
QCOMPARE(outputRemovedSpy.count(), 1);
QCOMPARE(outputRemovedSpy.first().first().value<quint32>(), firstOutputId);
// let's wait a little bit to ensure we don't get more events
QTest::qWait(100);
QCOMPARE(outputAnnouncedSpy.count(), 2);
QCOMPARE(outputRemovedSpy.count(), 1);
// let's create the output objects to ensure they are correct
QScopedPointer<Output> o1(registry.createOutput(outputAnnouncedSpy.first().first().value<quint32>(), outputAnnouncedSpy.first().last().value<quint32>()));
QVERIFY(o1->isValid());
QSignalSpy o1ChangedSpy(o1.data(), &Output::changed);
QVERIFY(o1ChangedSpy.isValid());
QVERIFY(o1ChangedSpy.wait());
QCOMPARE(o1->geometry(), geometries.at(0));
QScopedPointer<Output> o2(registry.createOutput(outputAnnouncedSpy.last().first().value<quint32>(), outputAnnouncedSpy.last().last().value<quint32>()));
QVERIFY(o2->isValid());
QSignalSpy o2ChangedSpy(o2.data(), &Output::changed);
QVERIFY(o2ChangedSpy.isValid());
QVERIFY(o2ChangedSpy.wait());
QCOMPARE(o2->geometry(), geometries.at(1));
// now let's try to remove one output again
outputAnnouncedSpy.clear();
outputRemovedSpy.clear();
screensChangedSpy.clear();
QSignalSpy o1RemovedSpy(o1.data(), &Output::removed);
QVERIFY(o1RemovedSpy.isValid());
QSignalSpy o2RemovedSpy(o2.data(), &Output::removed);
QVERIFY(o2RemovedSpy.isValid());
const QVector<QRect> geometries2{QRect(0, 0, 1280, 1024)};
QMetaObject::invokeMethod(kwinApp()->platform(), "outputGeometriesChanged",
Qt::DirectConnection,
Q_ARG(QVector<QRect>, geometries2));
QVERIFY(screensChangedSpy.wait());
QCOMPARE(screensChangedSpy.count(), 1);
QCOMPARE(screens()->count(), 1);
QCOMPARE(screens()->geometry(0), geometries2.at(0));
QVERIFY(outputAnnouncedSpy.wait());
QCOMPARE(outputAnnouncedSpy.count(), 1);
if (o1RemovedSpy.isEmpty()) {
QVERIFY(o1RemovedSpy.wait());
}
if (o2RemovedSpy.isEmpty()) {
QVERIFY(o2RemovedSpy.wait());
}
// now wait a bit to ensure we don't get more events
QTest::qWait(100);
QCOMPARE(outputAnnouncedSpy.count(), 1);
QCOMPARE(o1RemovedSpy.count(), 1);
//.........这里部分代码省略.........