Exemplo n.º 1
0
//_______________________________________________________
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
}
Exemplo n.º 2
0
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(&registry, &Registry::interfacesAnnounced, &app,
        [&registry, &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, &registry, dpmsManager));
                QFrame *hline = new QFrame;
                hline->setFrameShape(QFrame::HLine);
                layout->addWidget(hline);
            }

            window.setLayout(layout);
            window.show();
        }, Qt::QueuedConnection
    );
    registry.setup();

    return app.exec();
}