diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,33 +20,38 @@ include(FeatureSummary) -find_package(PipeWire) -set_package_properties(PipeWire PROPERTIES - TYPE OPTIONAL - PURPOSE "Required for screencast portal" -) - -find_package(GBM) -set_package_properties(GBM PROPERTIES - TYPE OPTIONAL - PURPOSE "Required for screencast portal" -) - -find_package(Epoxy) -set_package_properties(Epoxy PROPERTIES DESCRIPTION "libepoxy" - URL "https://github.com/anholt/libepoxy" - TYPE OPTIONAL - PURPOSE "Required for screencast portal" -) - -if (PipeWire_FOUND AND GBM_FOUND AND Epoxy_FOUND) - set (SCREENCAST_ENABLED true) +if(DISABLE_WAYLAND_SUPPORT) + message(STATUS "Disabling Wayland support") + set(HAVE_WAYLAND_SUPPORT 0) else() - set (SCREENCAST_ENABLED false) + set(HAVE_WAYLAND_SUPPORT 1) +endif() +add_definitions(-DHAVE_WAYLAND_SUPPORT=${HAVE_WAYLAND_SUPPORT}) + +if(HAVE_WAYLAND_SUPPORT) + find_package(PipeWire) + set_package_properties(PipeWire PROPERTIES + TYPE REQUIRED + PURPOSE "Required for screencast portal" + ) + + find_package(GBM) + set_package_properties(GBM PROPERTIES + TYPE REQUIRED + PURPOSE "Required for screencast portal" + ) + + find_package(Epoxy) + set_package_properties(Epoxy PROPERTIES DESCRIPTION "libepoxy" + URL "https://github.com/anholt/libepoxy" + TYPE REQUIRED + PURPOSE "Required for screencast portal" + ) + + find_package(KF5 ${KF5_MIN_VERSION} REQUIRED + Wayland + ) endif() -add_definitions(-DSCREENCAST_ENABLED=${SCREENCAST_ENABLED}) - -add_feature_info ("Screencast portal" ${SCREENCAST_ENABLED} "Support for screen sharing") find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Core @@ -66,7 +71,6 @@ Kirigami2 Notifications Plasma - Wayland WidgetsAddons WindowSystem ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,7 +9,6 @@ account.cpp appchooser.cpp appchooserdialog.cpp - background.cpp desktopportal.cpp email.cpp filechooser.cpp @@ -25,9 +24,10 @@ userinfodialog.cpp ) -if (SCREENCAST_ENABLED) +if(HAVE_WAYLAND_SUPPORT) set (xdg_desktop_portal_kde_SRCS ${xdg_desktop_portal_kde_SRCS} + background.cpp screencast.cpp screencaststream.cpp screencastwidget.cpp @@ -67,16 +67,16 @@ KF5::I18n KF5::KIOFileWidgets KF5::Notifications - KF5::WaylandClient KF5::WidgetsAddons KF5::WindowSystem ) -if (SCREENCAST_ENABLED) +if (HAVE_WAYLAND_SUPPORT) target_link_libraries(xdg-desktop-portal-kde PipeWire::PipeWire ${Epoxy_LIBRARIES} - GBM::GBM) + GBM::GBM + KF5::WaylandClient) endif() install(TARGETS xdg-desktop-portal-kde DESTINATION ${KDE_INSTALL_LIBEXECDIR}) diff --git a/src/desktopportal.h b/src/desktopportal.h --- a/src/desktopportal.h +++ b/src/desktopportal.h @@ -27,19 +27,20 @@ #include "access.h" #include "account.h" #include "appchooser.h" -#include "background.h" #include "email.h" #include "filechooser.h" #include "inhibit.h" #include "notification.h" #include "print.h" -#if SCREENCAST_ENABLED -#include "screencast.h" -#include "remotedesktop.h" -#endif #include "screenshot.h" #include "settings.h" + +#if HAVE_WAYLAND_SUPPORT +#include "background.h" +#include "screencast.h" +#include "remotedesktop.h" #include "waylandintegration.h" +#endif class DesktopPortal : public QObject, public QDBusContext { @@ -52,18 +53,18 @@ AccessPortal *m_access; AccountPortal *m_account; AppChooserPortal *m_appChooser; - BackgroundPortal *m_background; EmailPortal *m_email; FileChooserPortal *m_fileChooser; InhibitPortal *m_inhibit; NotificationPortal *m_notification; PrintPortal *m_print; -#if SCREENCAST_ENABLED + ScreenshotPortal *m_screenshot; + SettingsPortal *m_settings; +#if HAVE_WAYLAND_SUPPORT + BackgroundPortal *m_background; ScreenCastPortal *m_screenCast; RemoteDesktopPortal *m_remoteDesktop; #endif - ScreenshotPortal *m_screenshot; - SettingsPortal *m_settings; }; #endif // XDG_DESKTOP_PORTAL_KDE_DESKTOP_PORTAL_H diff --git a/src/desktopportal.cpp b/src/desktopportal.cpp --- a/src/desktopportal.cpp +++ b/src/desktopportal.cpp @@ -38,13 +38,13 @@ { const QByteArray xdgCurrentDesktop = qgetenv("XDG_CURRENT_DESKTOP").toUpper(); if (xdgCurrentDesktop == "KDE") { +#if HAVE_WAYLAND_SUPPORT m_background = new BackgroundPortal(this); - m_screenshot = new ScreenshotPortal(this); -#if SCREENCAST_ENABLED m_screenCast = new ScreenCastPortal(this); m_remoteDesktop = new RemoteDesktopPortal(this); -#endif WaylandIntegration::init(); +#endif + m_screenshot = new ScreenshotPortal(this); } } diff --git a/src/waylandintegration.cpp b/src/waylandintegration.cpp --- a/src/waylandintegration.cpp +++ b/src/waylandintegration.cpp @@ -58,9 +58,7 @@ void WaylandIntegration::init() { -#if SCREENCAST_ENABLED globalWaylandIntegration->initDrm(); -#endif globalWaylandIntegration->initWayland(); } @@ -629,13 +627,12 @@ m_registry = new KWayland::Client::Registry(this); -#if SCREENCAST_ENABLED connect(m_registry, &KWayland::Client::Registry::fakeInputAnnounced, this, [this] (quint32 name, quint32 version) { m_fakeInput = m_registry->createFakeInput(name, version, this); }); connect(m_registry, &KWayland::Client::Registry::outputAnnounced, this, &WaylandIntegrationPrivate::addOutput); connect(m_registry, &KWayland::Client::Registry::outputRemoved, this, &WaylandIntegrationPrivate::removeOutput); -#endif + connect(m_registry, &KWayland::Client::Registry::plasmaWindowManagementAnnounced, this, [this] (quint32 name, quint32 version) { m_windowManagement = m_registry->createPlasmaWindowManagement(name, version, this); Q_EMIT waylandIntegration()->plasmaWindowManagementInitialized();