截止撰文之日(2022年01月12日),wayland还没有一个稳定的标准协议用以获取窗口列表。但各wayland显示服务器,诸如kwin、mutter等都已各自制定了获取窗口列表的协议。下面将介绍kwin_wayland获取及控制应用窗口的方法。
引用库find_package(KF5Wayland) target_link_libraries(${PROJECT_NAME} KF5::WaylandClient)引用头文件
#include获取窗口列表#include #include
KWayland::Client::Registry *registry = new KWayland::Client::Registry(this); registry->create(KWayland::Client::ConnectionThread::fromApplication(this)); registry->setup(); connect(registry, &KWayland::Client::Registry::plasmaWindowManagementAnnounced, this, [=](quint32 name, quint32 version){ auto plasmaWindowManagement = registry->createPlasmaWindowManagement(name, version, this); plasmaWindowManagement->windows(); //窗口列表 connect(plasmaWindowManagement, &KWayland::Client::PlasmaWindowManagement::windowCreated, this, [=](KWayland::Client::PlasmaWindow *window){ //窗口创建 qDebug() << "KWayland::Client::PlasmaWindowManagement::windowCreated" << window->title(); }); }); //通过KWayland::Client::PlasmaWindow便可控制窗口联系方式
QQ群:236510798
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)