1
0
mirror of https://invent.kde.org/network/krfb synced 2024-07-03 08:28:35 +00:00

New dep: KWindowSystem and support running in Wayland

This commit adds a new dependency - KWindowSystem, to help
with window system detection. If wayland is detected, then
preferred framebuffer plugin is switched to "pw" (pipewire).
This commit is contained in:
Alexey Min 2019-07-07 14:02:19 +03:00
parent 0cc47b9a06
commit 9828143609
3 changed files with 24 additions and 2 deletions

View File

@ -39,6 +39,7 @@ find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
Notifications Notifications
Wallet Wallet
WidgetsAddons WidgetsAddons
WindowSystem
XmlGui XmlGui
) )

View File

@ -101,6 +101,7 @@ target_link_libraries (krfb
KF5::Notifications KF5::Notifications
KF5::Wallet KF5::Wallet
KF5::WidgetsAddons KF5::WidgetsAddons
KF5::WindowSystem
KF5::XmlGui KF5::XmlGui
${LIBVNCSERVER_LIBRARIES} ${LIBVNCSERVER_LIBRARIES}
) )

View File

@ -25,6 +25,7 @@
#include <KDBusService> #include <KDBusService>
#include <KLocalizedString> #include <KLocalizedString>
#include <KMessageBox> #include <KMessageBox>
#include <KWindowSystem>
#include <QDebug> #include <QDebug>
#include <QPixmap> #include <QPixmap>
@ -69,6 +70,22 @@ static void checkOldX11PluginConfig() {
} }
} }
static void checkWaylandPluginConfig()
{
if (KrfbConfig::preferredFrameBufferPlugin() != QStringLiteral("pw")) {
qWarning() << "Wayland: Detected invalid configuration: "
"preferredFrameBufferPlugin is not pipewire: "
<< KrfbConfig::preferredFrameBufferPlugin();
KConfigSkeletonItem *config_item = KrfbConfig::self()->findItem(
QStringLiteral("preferredFrameBufferPlugin"));
if (config_item) {
config_item->setProperty(QStringLiteral("pw"));
KrfbConfig::self()->save();
qDebug() << "Wayland: Fixed preferredFrameBufferPlugin to \"pw\".";
}
}
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QApplication app(argc, argv); QApplication app(argc, argv);
@ -118,16 +135,19 @@ int main(int argc, char *argv[])
app.setQuitOnLastWindowClosed(false); app.setQuitOnLastWindowClosed(false);
if (QX11Info::isPlatformX11()) { if (KWindowSystem::isPlatformX11()) {
if (!checkX11Capabilities()) { if (!checkX11Capabilities()) {
return 1; return 1;
} }
// upgrade the configuration // upgrade the configuration
checkOldX11PluginConfig(); checkOldX11PluginConfig();
} else if (KWindowSystem::isPlatformWayland()) {
// check that default plugin in Wayland is PipeWire
checkWaylandPluginConfig();
} else { } else {
KMessageBox::error(nullptr, KMessageBox::error(nullptr,
i18n("Desktop Sharing is not running under an X11 Server. " i18n("Desktop Sharing is not running under an X11 Server or Wayland.\n"
"Other display servers are currently not supported."), "Other display servers are currently not supported."),
i18n("Desktop Sharing Error")); i18n("Desktop Sharing Error"));
return 1; return 1;