diff --git a/CMakeLists.txt b/CMakeLists.txt index c321632b7c..e54f9712cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,7 +78,6 @@ find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS GlobalAccel I18n IdleTime - Notifications Package Plasma WidgetsAddons @@ -335,6 +334,7 @@ include(CMakeDependentOption) option(KWIN_BUILD_DECORATIONS "Enable building of KWin decorations." ON) option(KWIN_BUILD_KCMS "Enable building of KWin configuration modules." ON) +option(KWIN_BUILD_NOTIFICATIONS "Enable building of KWin with knotifications support" ON) option(KWIN_BUILD_SCREENLOCKER "Enable building of KWin lockscreen functionality" ON) option(KWIN_BUILD_TABBOX "Enable building of KWin Tabbox functionality" ON) cmake_dependent_option(KWIN_BUILD_ACTIVITIES "Enable building of KWin with kactivities support" ON "KF5Activities_FOUND" OFF) @@ -391,6 +391,10 @@ add_feature_info("SCHED_RESET_ON_FORK" pkg_check_modules(PipeWire IMPORTED_TARGET libpipewire-0.3>=0.3.29) add_feature_info(PipeWire PipeWire_FOUND "Required for Wayland screencasting") +if (KWIN_BUILD_NOTIFICATIONS) + find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Notifications) +endif() + if (KWIN_BUILD_SCREENLOCKER) find_package(KScreenLocker CONFIG REQUIRED) set_package_properties(KScreenLocker PROPERTIES diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index db010259c6..bd61713167 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -175,7 +175,6 @@ target_link_libraries(kwin KF5::GlobalAccel KF5::GlobalAccelPrivate KF5::I18n - KF5::Notifications KF5::Package KF5::Plasma KF5::QuickAddons @@ -208,6 +207,10 @@ target_link_libraries(kwin Threads::Threads ) +if (KWIN_BUILD_NOTIFICATIONS) + target_link_libraries(kwin KF5::Notifications) +endif() + kconfig_add_kcfg_files(kwin settings.kcfgc rulesettings.kcfgc @@ -341,7 +344,9 @@ if (PipeWire_FOUND) endif() install(FILES kwin.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR} RENAME ${KWIN_NAME}.kcfg) -install(FILES kwin.notifyrc DESTINATION ${KDE_INSTALL_KNOTIFY5RCDIR} RENAME ${KWIN_NAME}.notifyrc) +if (KWIN_BUILD_NOTIFICATIONS) + install(FILES kwin.notifyrc DESTINATION ${KDE_INSTALL_KNOTIFY5RCDIR} RENAME ${KWIN_NAME}.notifyrc) +endif() install( FILES org.kde.KWin.VirtualDesktopManager.xml diff --git a/src/composite.cpp b/src/composite.cpp index c7ac7145ad..eba2cca2d3 100644 --- a/src/composite.cpp +++ b/src/composite.cpp @@ -6,6 +6,7 @@ SPDX-License-Identifier: GPL-2.0-or-later */ +#include #include "composite.h" #include "abstract_output.h" #include "cursorview_opengl.h" @@ -45,7 +46,9 @@ #include #include +#if KWIN_BUILD_NOTIFICATIONS #include +#endif #include #include @@ -630,7 +633,9 @@ void Compositor::composite(RenderLoop *renderLoop) { if (m_backend->checkGraphicsReset()) { qCDebug(KWIN_CORE) << "Graphics reset occurred"; +#if KWIN_BUILD_NOTIFICATIONS KNotification::event(QStringLiteral("graphicsreset"), i18n("Desktop effects were restarted due to a graphics reset")); +#endif reinitialize(); return; } @@ -837,7 +842,9 @@ void X11Compositor::suspend(X11Compositor::SuspendReason reason) i18n("Desktop effects have been suspended by another application.
" "You can resume using the '%1' shortcut.", shortcuts.first().toString(QKeySequence::NativeText)); +#if KWIN_BUILD_NOTIFICATIONS KNotification::event(QStringLiteral("compositingsuspendeddbus"), message); +#endif } } stop(); diff --git a/src/config-kwin.h.cmake b/src/config-kwin.h.cmake index 4c55cec955..f708d6ed18 100644 --- a/src/config-kwin.h.cmake +++ b/src/config-kwin.h.cmake @@ -1,6 +1,7 @@ #define KWIN_PLUGIN_VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}" #cmakedefine01 KWIN_BUILD_DECORATIONS +#cmakedefine01 KWIN_BUILD_NOTIFICATIONS #cmakedefine01 KWIN_BUILD_SCREENLOCKER #cmakedefine01 KWIN_BUILD_TABBOX #cmakedefine01 KWIN_BUILD_ACTIVITIES diff --git a/src/effects/screenshot/CMakeLists.txt b/src/effects/screenshot/CMakeLists.txt index 04ec6102bf..5fa3a65004 100644 --- a/src/effects/screenshot/CMakeLists.txt +++ b/src/effects/screenshot/CMakeLists.txt @@ -16,7 +16,6 @@ target_link_libraries(kwin4_effect_screenshot PRIVATE kwineffects kwinglutils - KF5::Notifications KF5::Service KF5::I18n @@ -24,6 +23,10 @@ target_link_libraries(kwin4_effect_screenshot PRIVATE Qt::DBus ) +if (KWIN_BUILD_NOTIFICATIONS) + target_link_libraries(kwin4_effect_screenshot PRIVATE KF5::Notifications) +endif() + ecm_qt_declare_logging_category(kwin4_effect_screenshot HEADER screenshotlogging.h IDENTIFIER KWIN_SCREENSHOT diff --git a/src/effects/screenshot/screenshotdbusinterface1.cpp b/src/effects/screenshot/screenshotdbusinterface1.cpp index 1bc056c9db..7d00156bcd 100644 --- a/src/effects/screenshot/screenshotdbusinterface1.cpp +++ b/src/effects/screenshot/screenshotdbusinterface1.cpp @@ -5,12 +5,15 @@ SPDX-License-Identifier: GPL-2.0-or-later */ +#include #include "screenshotdbusinterface1.h" #include "screenshotlogging.h" #include "utils/serviceutils.h" #include +#if KWIN_BUILD_NOTIFICATIONS #include +#endif #include #include @@ -468,10 +471,13 @@ static QString saveTempImage(const QImage &image) } image.save(&temp); temp.close(); + qCInfo(KWIN_SCREENSHOT) << "Screenshot saved to" << temp.fileName(); +#if KWIN_BUILD_NOTIFICATIONS KNotification::event(KNotification::Notification, i18nc("Notification caption that a screenshot got saved to file", "Screenshot"), i18nc("Notification with path to screenshot file", "Screenshot saved to %1", temp.fileName()), QStringLiteral("spectacle")); +#endif return temp.fileName(); } diff --git a/src/xwl/xwayland.cpp b/src/xwl/xwayland.cpp index 611053df64..b2edc1a981 100644 --- a/src/xwl/xwayland.cpp +++ b/src/xwl/xwayland.cpp @@ -8,6 +8,7 @@ SPDX-License-Identifier: GPL-2.0-or-later */ +#include #include "xwayland.h" #include "cursor.h" #include "databridge.h" @@ -27,7 +28,9 @@ #include "xwaylandsocket.h" #include +#if KWIN_BUILD_NOTIFICATIONS #include +#endif #include #include @@ -347,7 +350,9 @@ void Xwayland::handleXwaylandFinished(int exitCode, QProcess::ExitStatus exitSta void Xwayland::handleXwaylandCrashed() { +#if KWIN_BUILD_NOTIFICATIONS KNotification::event(QStringLiteral("xwaylandcrash"), i18n("Xwayland has crashed")); +#endif m_resetCrashCountTimer->stop(); switch (options->xwaylandCrashPolicy()) {