From fdd4ae2ee5a43f19854bf443659917a6709f70b6 Mon Sep 17 00:00:00 2001 From: Gui-Yue Date: Mon, 12 Jun 2023 15:26:08 +0000 Subject: [PATCH] feat:upgrade to 5.103 * upgrade to 5.103 from upstream log: upgrade --- CMakeLists.txt | 40 +++- debian/changelog | 111 ++++++++- debian/control | 29 ++- debian/libkf5idletime-dev.install | 1 - debian/libkf5idletime5.install | 2 + debian/libkf5idletime5.symbols | 1 + debian/meta/cmake-ignore | 2 - debian/rules | 2 +- debian/salsa-ci.yml | 1 - debian/tests/testsuite | 3 - src/CMakeLists.txt | 2 +- src/abstractsystempoller.h | 5 +- src/kidletime.cpp | 56 +++-- src/kidletime.h | 4 +- src/plugins/CMakeLists.txt | 4 + src/plugins/osx/CMakeLists.txt | 2 +- src/plugins/wayland/CMakeLists.txt | 30 +++ src/plugins/wayland/poller.cpp | 226 ++++++++++++++++++ src/plugins/wayland/poller.h | 52 ++++ src/plugins/wayland/wayland.json | 3 + src/plugins/windows/CMakeLists.txt | 2 +- src/plugins/xscreensaver/CMakeLists.txt | 4 +- .../xscreensaver/xscreensaverbasedpoller.cpp | 17 +- src/plugins/xsync/CMakeLists.txt | 4 +- src/plugins/xsync/xsyncbasedpoller.cpp | 7 +- src/plugins/xsync/xsyncbasedpoller.h | 4 +- src/widgetbasedpoller.h | 4 +- 27 files changed, 543 insertions(+), 75 deletions(-) mode change 100644 => 100755 debian/libkf5idletime5.install delete mode 100644 debian/meta/cmake-ignore delete mode 100755 debian/tests/testsuite create mode 100644 src/plugins/wayland/CMakeLists.txt create mode 100644 src/plugins/wayland/poller.cpp create mode 100644 src/plugins/wayland/poller.h create mode 100644 src/plugins/wayland/wayland.json diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ea86e5..66c638b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,23 +1,28 @@ cmake_minimum_required(VERSION 3.16) -set(KF_VERSION "5.90.0") # handled by release scripts +set(KF_VERSION "5.103.0") # handled by release scripts project(KIdleTime VERSION ${KF_VERSION}) # ECM setup include(FeatureSummary) -find_package(ECM 5.90.0 NO_MODULE) +find_package(ECM 5.103.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) +include(KDEInstallDirs) +include(KDECMakeSettings) +include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) +include(KDEGitCommitHooks) include(CMakeFindFrameworks) include(CMakePackageConfigHelpers) include(ECMGenerateExportHeader) include(ECMQtDeclareLoggingCategory) include(ECMSetupVersion) include(ECMGenerateHeaders) +include(ECMDeprecationSettings) include(ECMAddQch) ecm_setup_version(PROJECT VARIABLE_PREFIX KIDLETIME @@ -25,12 +30,6 @@ ecm_setup_version(PROJECT VARIABLE_PREFIX KIDLETIME PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5IdleTimeConfigVersion.cmake" SOVERSION 5) -# Dependencies -include(KDEInstallDirs) -include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) -include(KDECMakeSettings) -include(KDEGitCommitHooks) - set(REQUIRED_QT_VERSION 5.15.2) find_package(Qt${QT_MAJOR_VERSION} ${REQUIRED_QT_VERSION} CONFIG REQUIRED Gui) @@ -41,13 +40,12 @@ endif() if(NOT APPLE) find_package(X11) find_package(XCB COMPONENTS XCB) + find_package(Qt${QT_MAJOR_VERSION}WaylandClient ${REQUIRED_QT_VERSION} CONFIG) endif() if(X11_FOUND) if (QT_MAJOR_VERSION STREQUAL "5") find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED X11Extras) - else() - # qtx11extras_p.h is in Qt6Gui, which implied by the Qt6Gui above endif() find_package(XCB COMPONENTS XCB SYNC) find_package(X11_XCB) @@ -79,12 +77,28 @@ else() set(HAVE_X11 FALSE) endif() +if(Qt5WaylandClient_FOUND) + find_package(QtWaylandScanner REQUIRED) + find_package(Wayland 1.9 REQUIRED Client) + find_package(PlasmaWaylandProtocols 1.6.0 CONFIG REQUIRED) + find_package(WaylandProtocols 1.27) + set_package_properties(WaylandProtocols PROPERTIES + TYPE REQUIRED + PURPOSE "Collection of Wayland protocols that add functionality not available in the Wayland core protocol" + URL "https://gitlab.freedesktop.org/wayland/wayland-protocols/" + ) +endif() + set(EXCLUDE_DEPRECATED_BEFORE_AND_AT 0 CACHE STRING "Control the range of deprecated API excluded from the build [default=0].") option(BUILD_QCH "Build API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)" OFF) add_feature_info(QCH ${BUILD_QCH} "API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)") -add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050f02) -add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x055900) + +ecm_set_disabled_deprecation_versions( + QT 5.15.2 + KF 5.97 +) + # Subdirectories add_subdirectory(src) add_subdirectory(examples) @@ -115,7 +129,7 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/KF5IdleTimeConfig.cmake" install(EXPORT KF5IdleTimeTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF5IdleTimeTargets.cmake NAMESPACE KF5:: ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kidletime_version.h - DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF} COMPONENT Devel) + DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF}/KIdleTime COMPONENT Devel) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/debian/changelog b/debian/changelog index 427c92e..5d307cc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,113 @@ -kidletime (5.90.0-1) UNRELEASED; urgency=medium +kidletime (5.103.0-2) unstable; urgency=medium - * update + * Team upload. + * Remove inactive Uploaders. + * Modernize building: + - add the dh-sequence-kf5 build dependency to use the kf5 addon + automatically + - add the dh-sequence-pkgkde-symbolshelper build dependency to use the + pkgkde_symbolshelper automatically + - drop the pkg-kde-tools build dependency, no more explicitly needed + - drop all the manually specified addons and buildsystem for dh + * Drop the unused leftovers of the 'testsuite' autpkgtest. + * Remove the unused debian/meta/ stuff. + * CI: enable again the blhc job. + * Fix building on non-Linux architectures, by limiting the Wayland support + to Linux architectures: + - restrict some build dependencies as linux-any: libqt5waylandclient5-dev, + libwayland-dev, plasma-wayland-protocols, qtwayland5-dev-tools, and + wayland-protocols + - add the dh-exec build dependency, needed for architecture-based filtering + in install files + - ship the Wayland plugins in libkf5idletime5 only in Linux architectures + * Enable the libxss-dev build dependency again on Hurd architectures, as it is + available now. + + -- Pino Toscano Sun, 26 Feb 2023 16:46:01 +0100 + +kidletime (5.103.0-1) unstable; urgency=medium + + [ Aurélien COUDERC ] + * New upstream release (5.103.0). + * Update build-deps and deps with the info from cmake. + + -- Aurélien COUDERC Sun, 12 Feb 2023 21:44:23 +0100 + +kidletime (5.102.0-1) unstable; urgency=medium + + [ Aurélien COUDERC ] + * New upstream release (5.102.0). + * Update build-deps and deps with the info from cmake. + * Bump Standards-Version to 4.6.2, no change required. + + -- Aurélien COUDERC Sun, 22 Jan 2023 21:35:01 +0100 + +kidletime (5.101.0-2) unstable; urgency=medium + + [ Aurélien COUDERC ] + * Add missing build dependencies for the Wayland plugin. + + -- Aurélien COUDERC Thu, 15 Dec 2022 23:02:11 +0100 + +kidletime (5.101.0-1) unstable; urgency=medium + + [ Aurélien COUDERC ] + * New upstream release (5.101.0). + * Update build-deps and deps with the info from cmake. + + -- Aurélien COUDERC Tue, 13 Dec 2022 07:40:22 +0100 + +kidletime (5.100.0-1) unstable; urgency=medium + + [ Aurélien COUDERC ] + * New upstream release (5.99.0). + * Update build-deps and deps with the info from cmake. + * New upstream release (5.100.0). + * Update build-deps and deps with the info from cmake. + + -- Aurélien COUDERC Sat, 19 Nov 2022 23:18:56 +0100 + +kidletime (5.98.0-1) unstable; urgency=medium + + [ Aurélien COUDERC ] + * New upstream release (5.98.0). + * Update build-deps and deps with the info from cmake. + + -- Aurélien COUDERC Sun, 18 Sep 2022 23:11:36 +0200 + +kidletime (5.97.0-1) unstable; urgency=medium + + [ Aurélien COUDERC ] + * New upstream release (5.97.0). + + -- Aurélien COUDERC Sun, 14 Aug 2022 18:55:28 +0200 + +kidletime (5.96.0-1) unstable; urgency=medium + + [ Aurélien COUDERC ] + * New upstream release (5.96.0). + * Bump Standards-Version to 4.6.1, no change required. + + -- Aurélien COUDERC Sun, 31 Jul 2022 13:32:57 +0200 + +kidletime (5.94.0-1) unstable; urgency=medium + + [ Aurélien COUDERC ] + * New upstream release (5.94.0). + + -- Aurélien COUDERC Thu, 19 May 2022 23:59:02 +0200 + +kidletime (5.93.0-1) unstable; urgency=medium + + [ Aurélien COUDERC ] + * New upstream release (5.92.0). + * Update the list of installed files. + * Update symbols from build for 5.92.0. + * New upstream release (5.93.0). - -- Debian Qt/KDE Maintainers Sun, 24 Apr 2022 17:20:54 +0800 + -- Aurélien COUDERC Wed, 11 May 2022 23:22:43 +0200 -kidletime (5.90.0-1) experimental; urgency=medium +kidletime (5.90.0-1) unstable; urgency=medium [ Norbert Preining ] * New upstream release (5.89.0). diff --git a/debian/control b/debian/control index 72a39db..907537d 100644 --- a/debian/control +++ b/debian/control @@ -3,24 +3,31 @@ Priority: optional Section: libs Maintainer: Debian Qt/KDE Maintainers Uploaders: Aurélien COUDERC , - Norbert Preining , Build-Depends: cmake (>= 3.16~), debhelper-compat (= 13), + dh-exec, + dh-sequence-kf5, + dh-sequence-pkgkde-symbolshelper, doxygen, - extra-cmake-modules (>= 5.90.0~), + extra-cmake-modules (>= 5.103.0~), libqt5sql5-sqlite, + libqt5waylandclient5-dev (>= 5.15.2~) [linux-any], libqt5x11extras5-dev (>= 5.15.2~), + libwayland-dev (>= 1.9~) [linux-any], libx11-dev, libx11-xcb-dev, libxcb-sync-dev, libxcb1-dev, - libxss-dev [!hurd-any], + libxss-dev, pkg-config, - pkg-kde-tools (>= 0.15.15ubuntu1~), + plasma-wayland-protocols (>= 1.6.0~) [linux-any], qtbase5-dev (>= 5.15.2~), + qtbase5-private-dev, qttools5-dev, qttools5-dev-tools (>= 5.4), -Standards-Version: 4.6.0 + qtwayland5-dev-tools [linux-any], + wayland-protocols (>= 1.27~) [linux-any], +Standards-Version: 4.6.2 Homepage: https://invent.kde.org/frameworks/kidletime Vcs-Browser: https://salsa.debian.org/qt-kde-team/kde/kidletime Vcs-Git: https://salsa.debian.org/qt-kde-team/kde/kidletime.git @@ -32,16 +39,16 @@ Architecture: any Depends: libkf5idletime5 (= ${binary:Version}), qtbase5-dev (>= 5.15.2~), ${misc:Depends}, -Recommends: libkf5idletime-doc (= ${source:Version}) +Recommends: libkf5idletime-doc (= ${source:Version}), Description: development headers for the kidletime library This package contains development files for building software that uses libraries from the kidletime KDE framework. -Breaks: libkf5kdelibs4support-dev (<< 5.54) +Breaks: libkf5kdelibs4support-dev (<< 5.54), Package: libkf5idletime-doc Architecture: all Multi-Arch: foreign -Depends: ${misc:Depends} +Depends: ${misc:Depends}, Description: library to provide information about idle time (documentation) This library contains a class that allows applications to watch for user activity or inactivity. It is useful not only for finding out about @@ -53,12 +60,12 @@ Section: doc Package: libkf5idletime5 Architecture: any -Depends: ${misc:Depends}, ${shlibs:Depends} +Depends: ${misc:Depends}, ${shlibs:Depends}, Multi-Arch: same -Recommends: kwayland-integration +Recommends: kwayland-integration, Description: library to provide information about idle time This library contains a class that allows applications to watch for user activity or inactivity. It is useful not only for finding out about the current idle time of the PC, but also for getting notified upon idle time events, such as custom timeouts, or user activity. -Breaks: baloo-kf5 (<< 5.54) +Breaks: baloo-kf5 (<< 5.54), diff --git a/debian/libkf5idletime-dev.install b/debian/libkf5idletime-dev.install index 39af516..984a76b 100644 --- a/debian/libkf5idletime-dev.install +++ b/debian/libkf5idletime-dev.install @@ -1,4 +1,3 @@ -/usr/include/KF5/kidletime_version.h usr/include/KF5/KIdleTime usr/lib/*/cmake/KF5IdleTime/ usr/lib/*/libKF5IdleTime.so diff --git a/debian/libkf5idletime5.install b/debian/libkf5idletime5.install old mode 100644 new mode 100755 index 7ef3751..f287f22 --- a/debian/libkf5idletime5.install +++ b/debian/libkf5idletime5.install @@ -1,5 +1,7 @@ +#!/usr/bin/dh-exec usr/lib/*/libKF5IdleTime.so.5 usr/lib/*/libKF5IdleTime.so.5.* usr/lib/*/qt5/plugins/kf5/org.kde.kidletime.platforms/KF5IdleTimeXcbPlugin*.so +[linux-any] usr/lib/*/qt5/plugins/kf5/org.kde.kidletime.platforms/KF5IdleTimeWaylandPlugin*.so usr/share/qlogging-categories5/kidletime.categories usr/share/qlogging-categories5/kidletime.renamecategories diff --git a/debian/libkf5idletime5.symbols b/debian/libkf5idletime5.symbols index ff43dca..c29fcf0 100644 --- a/debian/libkf5idletime5.symbols +++ b/debian/libkf5idletime5.symbols @@ -56,6 +56,7 @@ libKF5IdleTime.so.5 libkf5idletime5 #MINVER# _ZNK9KIdleTime10metaObjectEv@Base 4.96.0 _ZNK9KIdleTime12idleTimeoutsEv@Base 4.96.0 _ZNK9KIdleTime8idleTimeEv@Base 4.96.0 + _ZNSt6vectorIiSaIiEE17_M_realloc_insertIJRKiEEEvN9__gnu_cxx17__normal_iteratorIPiS1_EEDpOT_@Base 5.92.0 _ZTI17WidgetBasedPoller@Base 5.13.0 _ZTI20AbstractSystemPoller@Base 5.13.0 _ZTI9KIdleTime@Base 4.96.0 diff --git a/debian/meta/cmake-ignore b/debian/meta/cmake-ignore deleted file mode 100644 index be04c0e..0000000 --- a/debian/meta/cmake-ignore +++ /dev/null @@ -1,2 +0,0 @@ -- QCH , API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop): - series: xenial diff --git a/debian/rules b/debian/rules index c5cd7fb..b4bee98 100755 --- a/debian/rules +++ b/debian/rules @@ -3,7 +3,7 @@ export DEB_BUILD_MAINT_OPTIONS = hardening=+all %: - dh $@ --with kf5,pkgkde_symbolshelper --buildsystem kf5 --without build_stamp + dh $@ override_dh_auto_configure: dh_auto_configure -- -DBUILD_QCH=ON diff --git a/debian/salsa-ci.yml b/debian/salsa-ci.yml index c632fbb..ff55d43 100644 --- a/debian/salsa-ci.yml +++ b/debian/salsa-ci.yml @@ -2,7 +2,6 @@ include: - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/salsa-ci.yml - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/pipeline-jobs.yml variables: - SALSA_CI_DISABLE_BLHC: 'yes' SALSA_CI_DISABLE_MISSING_BREAKS: 'no' SALSA_CI_DISABLE_RC_BUGS: 'no' SALSA_CI_REPROTEST_ARGS: '--variations=-build-path' diff --git a/debian/tests/testsuite b/debian/tests/testsuite deleted file mode 100755 index dabe645..0000000 --- a/debian/tests/testsuite +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -dh_auto_test diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 12a9aca..bc0099c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -61,7 +61,7 @@ install( Devel ) -install(TARGETS KF5IdleTime EXPORT KF5IdleTimeTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) +install(TARGETS KF5IdleTime EXPORT KF5IdleTimeTargets ${KF_INSTALL_TARGETS_DEFAULT_ARGS}) ecm_qt_install_logging_categories( diff --git a/src/abstractsystempoller.h b/src/abstractsystempoller.h index e57407e..d2ddf2c 100644 --- a/src/abstractsystempoller.h +++ b/src/abstractsystempoller.h @@ -28,7 +28,10 @@ class KIDLETIME_EXPORT AbstractSystemPoller : public QObject public Q_SLOTS: virtual void addTimeout(int nextTimeout) = 0; virtual void removeTimeout(int nextTimeout) = 0; - virtual QList timeouts() const = 0; + + // TODO KF6: Make it a public method + virtual QList timeouts() const = 0; // clazy:exclude=const-signal-or-slot + virtual int forcePollRequest() = 0; virtual void catchIdleEvent() = 0; virtual void stopCatchingIdleEvents() = 0; diff --git a/src/kidletime.cpp b/src/kidletime.cpp index fa78aca..0929285 100644 --- a/src/kidletime.cpp +++ b/src/kidletime.cpp @@ -134,15 +134,20 @@ void KIdleTime::removeIdleTimeout(int identifier) { Q_D(KIdleTime); - if (!d->associations.contains(identifier) || !d->poller) { + const auto it = d->associations.constFind(identifier); + if (it == d->associations.cend() || !d->poller) { return; } - int msec = d->associations[identifier]; + const int msec = it.value(); - d->associations.remove(identifier); + d->associations.erase(it); - if (!d->associations.values().contains(msec)) { + const bool isFound = std::any_of(d->associations.cbegin(), d->associations.cend(), [msec](int i) { + return i == msec; + }); + + if (!isFound) { d->poller.data()->removeTimeout(msec); } } @@ -151,35 +156,43 @@ void KIdleTime::removeAllIdleTimeouts() { Q_D(KIdleTime); - QHash::iterator i = d->associations.begin(); - QSet removed; - removed.reserve(d->associations.size()); - - while (i != d->associations.end()) { - int msec = d->associations[i.key()]; + std::vector removed; - i = d->associations.erase(i); - - if (!removed.contains(msec) && d->poller) { + for (auto it = d->associations.cbegin(); it != d->associations.cend(); ++it) { + const int msec = it.value(); + const bool alreadyIns = std::find(removed.cbegin(), removed.cend(), msec) != removed.cend(); + if (!alreadyIns && d->poller) { + removed.push_back(msec); d->poller.data()->removeTimeout(msec); - removed.insert(msec); } } + + d->associations.clear(); } static QStringList pluginCandidates() { QStringList ret; + const QStringList libPath = QCoreApplication::libraryPaths(); for (const QString &path : libPath) { - const QDir pluginDir(path + QLatin1String("/kf5/org.kde.kidletime.platforms")); +#ifdef Q_OS_MACOS + const QDir pluginDir(path + QStringLiteral("/kf" QT_STRINGIFY(QT_VERSION_MAJOR) "/kidletime")); +#else + const QDir pluginDir(path + QStringLiteral("/kf" QT_STRINGIFY(QT_VERSION_MAJOR) "/org.kde.kidletime.platforms")); +#endif if (!pluginDir.exists()) { continue; } - for (const QString &entry : pluginDir.entryList(QDir::Files | QDir::NoDotAndDotDot)) { + + const auto entries = pluginDir.entryList(QDir::Files | QDir::NoDotAndDotDot); + + ret.reserve(ret.size() + entries.size()); + for (const QString &entry : entries) { ret << pluginDir.absoluteFilePath(entry); } } + return ret; } @@ -275,14 +288,13 @@ void KIdleTimePrivate::timeoutReached(int msec) { Q_Q(KIdleTime); - if (associations.values().contains(msec)) { - const auto listKeys = associations.keys(msec); - for (int key : listKeys) { + const auto listKeys = associations.keys(msec); + + for (const auto key : listKeys) { #if KIDLETIME_BUILD_DEPRECATED_SINCE(5, 76) - Q_EMIT q->timeoutReached(key); + Q_EMIT q->timeoutReached(key); #endif - Q_EMIT q->timeoutReached(key, msec); - } + Q_EMIT q->timeoutReached(key, msec); } } diff --git a/src/kidletime.h b/src/kidletime.h index 75888bd..a3b01d0 100644 --- a/src/kidletime.h +++ b/src/kidletime.h @@ -180,7 +180,7 @@ public Q_SLOTS: * @deprecated Since 5.76, use only timeoutReached(int identifier, int msec) */ KIDLETIME_DEPRECATED_VERSION(5, 76, "Use only timeoutReached(int identifier, int msec)") - void timeoutReached(int identifier); + void timeoutReached(int identifier); // clazy:exclude=overloaded-signal #endif /** @@ -196,7 +196,7 @@ public Q_SLOTS: * @see addIdleTimeout * @see removeIdleTimeout */ - void timeoutReached(int identifier, int msec); + void timeoutReached(int identifier, int msec); // clazy:exclude=overloaded-signal private: KIdleTime(); diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index cb5898d..5fa0ba0 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -14,3 +14,7 @@ if(X11_FOUND) add_subdirectory(xsync) endif() endif() + +if (Qt5WaylandClient_FOUND) + add_subdirectory(wayland) +endif() diff --git a/src/plugins/osx/CMakeLists.txt b/src/plugins/osx/CMakeLists.txt index e9b804e..e05dcc1 100644 --- a/src/plugins/osx/CMakeLists.txt +++ b/src/plugins/osx/CMakeLists.txt @@ -13,5 +13,5 @@ install( TARGETS KF5IdleTimeOsxPlugin DESTINATION - ${KDE_INSTALL_PLUGINDIR}/kf5/org.kde.kidletime.platforms/ + ${KDE_INSTALL_PLUGINDIR}/kf${QT_MAJOR_VERSION}/kidletime/ ) diff --git a/src/plugins/wayland/CMakeLists.txt b/src/plugins/wayland/CMakeLists.txt new file mode 100644 index 0000000..22c4512 --- /dev/null +++ b/src/plugins/wayland/CMakeLists.txt @@ -0,0 +1,30 @@ +add_library(KF5IdleTimeWaylandPlugin MODULE) +if (QT_MAJOR_VERSION EQUAL "5") + ecm_add_qtwayland_client_protocol(idletime_plugin_SRCS + PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/idle.xml + BASENAME idle + ) + ecm_add_qtwayland_client_protocol(idletime_plugin_SRCS + PROTOCOL ${WaylandProtocols_DATADIR}/staging/ext-idle-notify/ext-idle-notify-v1.xml + BASENAME ext-idle-notify-v1 + ) +else() + qt6_generate_wayland_protocol_client_sources(KF5IdleTimeWaylandPlugin FILES + ${PLASMA_WAYLAND_PROTOCOLS_DIR}/idle.xml + ${WAYLAND_PROTOCOLS_DIR}/ext-idle-notify-v1.xml) +endif() +target_sources(KF5IdleTimeWaylandPlugin PRIVATE poller.cpp ${idletime_plugin_SRCS}) + +target_link_libraries(KF5IdleTimeWaylandPlugin + KF5::IdleTime + Qt${QT_MAJOR_VERSION}::WaylandClient + Qt${QT_MAJOR_VERSION}::GuiPrivate + Wayland::Client +) + +install( + TARGETS + KF5IdleTimeWaylandPlugin + DESTINATION + ${KDE_INSTALL_PLUGINDIR}/kf5/org.kde.kidletime.platforms/ +) diff --git a/src/plugins/wayland/poller.cpp b/src/plugins/wayland/poller.cpp new file mode 100644 index 0000000..918766b --- /dev/null +++ b/src/plugins/wayland/poller.cpp @@ -0,0 +1,226 @@ +/* + SPDX-FileCopyrightText: 2021 David Edmundson + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ +#include "poller.h" + +#include +#include +#include +#include +#include + +#include + +#include "qwayland-ext-idle-notify-v1.h" +#include "qwayland-idle.h" + +Q_DECLARE_LOGGING_CATEGORY(POLLER) +Q_LOGGING_CATEGORY(POLLER, "kf5idletime_wayland") + +/* + * Porting notes: + * org_kde_kwin_idle refers to an early specific idle timeout protocol + * the version ext_idle refers to an upstream stable protocol + * + * Pragmattically they're both the same, but we have to have two implementations for a while + * + * When a suitable amount of time passes (Plasma 5.24 being EOL) drop IdleTimeoutKwin and drop IdleManagerKwin as well as merge the abstract IdleTimeout class into the real implementation + */ + +class IdleTimeout : public QObject +{ + Q_OBJECT +public: + IdleTimeout() = default; +Q_SIGNALS: + void idle(); + void resumeFromIdle(); +}; + +class IdleTimeoutKwin : public IdleTimeout, public QtWayland::org_kde_kwin_idle_timeout +{ + Q_OBJECT +public: + IdleTimeoutKwin(struct ::org_kde_kwin_idle_timeout *object) + : IdleTimeout() + , QtWayland::org_kde_kwin_idle_timeout(object) + {} + + ~IdleTimeoutKwin() + { + release(); + } + +protected: + void org_kde_kwin_idle_timeout_idle() override { + Q_EMIT idle(); + } + void org_kde_kwin_idle_timeout_resumed() override { + Q_EMIT resumeFromIdle(); + } +}; + +class IdleTimeoutExt : public IdleTimeout, public QtWayland::ext_idle_notification_v1 +{ + Q_OBJECT +public: + IdleTimeoutExt(struct ::ext_idle_notification_v1 *object) + : IdleTimeout() + , QtWayland::ext_idle_notification_v1(object) + { + } + + ~IdleTimeoutExt() + { + destroy(); + } + +protected: + void ext_idle_notification_v1_idled() override + { + Q_EMIT idle(); + } + void ext_idle_notification_v1_resumed() override + { + Q_EMIT resumeFromIdle(); + } +}; + +class IdleManagerKwin : public QWaylandClientExtensionTemplate, public QtWayland::org_kde_kwin_idle +{ +public: + IdleManagerKwin() + : QWaylandClientExtensionTemplate(1) + { +#if QTWAYLANDCLIENT_VERSION >= QT_VERSION_CHECK(6, 2, 0) + initialize(); +#else + // QWaylandClientExtensionTemplate invokes this with a QueuedConnection but we want shortcuts + // to be inhibited immediately. + QMetaObject::invokeMethod(this, "addRegistryListener"); +#endif + } +}; + +class IdleManagerExt : public QWaylandClientExtensionTemplate, public QtWayland::ext_idle_notifier_v1 +{ +public: + IdleManagerExt() + : QWaylandClientExtensionTemplate(1) + { +#if QTWAYLANDCLIENT_VERSION >= QT_VERSION_CHECK(6, 2, 0) + initialize(); +#else + // QWaylandClientExtensionTemplate invokes this with a QueuedConnection but we want shortcuts + // to be inhibited immediately. + QMetaObject::invokeMethod(this, "addRegistryListener"); +#endif + } + ~IdleManagerExt() + { + if (isActive()) { + destroy(); + } + } +}; + +Poller::Poller(QObject *parent) + : AbstractSystemPoller(parent) + , m_idleManagerKwin(new IdleManagerKwin) + , m_idleManagerExt(new IdleManagerExt) +{ +} + +Poller::~Poller() = default; + +bool Poller::isAvailable() +{ + return m_idleManagerKwin->isActive() || m_idleManagerExt->isActive(); +} + +void Poller::addTimeout(int nextTimeout) +{ + if (m_timeouts.contains(nextTimeout)) { + return; + } + + auto timeout = createTimeout(nextTimeout); + if (!timeout) { + return; + } + + connect(timeout, &IdleTimeout::idle, this, [this, nextTimeout] { + Q_EMIT timeoutReached(nextTimeout); + }); + connect(timeout, &IdleTimeout::resumeFromIdle, this, &Poller::resumingFromIdle); + m_timeouts.insert(nextTimeout, QSharedPointer(timeout)); +} + +void Poller::removeTimeout(int nextTimeout) +{ + m_timeouts.remove(nextTimeout); +} + +QList Poller::timeouts() const +{ + return QList(); +} + +void Poller::catchIdleEvent() +{ + if (m_catchResumeTimeout) { + // already setup + return; + } + if (!isAvailable()) { + return; + } + + m_catchResumeTimeout.reset(createTimeout(0)); + if (!m_catchResumeTimeout) { + return; + } + connect(m_catchResumeTimeout.get(), &IdleTimeout::resumeFromIdle, this, [this] { + stopCatchingIdleEvents(); + Q_EMIT resumingFromIdle(); + }); +} + +void Poller::stopCatchingIdleEvents() +{ + m_catchResumeTimeout.reset(); +} + +int Poller::forcePollRequest() +{ + qCWarning(POLLER) << "This plugin does not support polling idle time"; + return 0; +} + +void Poller::simulateUserActivity() +{ +} + +IdleTimeout* Poller::createTimeout(int timeout) +{ + QPlatformNativeInterface *nativeInterface = qGuiApp->platformNativeInterface(); + if (!nativeInterface) { + return nullptr; + } + auto seat = static_cast(nativeInterface->nativeResourceForIntegration("wl_seat")); + if (!seat) { + return nullptr; + } + + if (m_idleManagerExt->isActive()) { + return new IdleTimeoutExt(m_idleManagerExt->get_idle_notification(timeout, seat)); + } + if (m_idleManagerKwin->isActive()) { + return new IdleTimeoutKwin(m_idleManagerKwin->get_idle_timeout(seat, timeout)); + } + return nullptr; +} + +#include "poller.moc" diff --git a/src/plugins/wayland/poller.h b/src/plugins/wayland/poller.h new file mode 100644 index 0000000..1c93491 --- /dev/null +++ b/src/plugins/wayland/poller.h @@ -0,0 +1,52 @@ +/* + SPDX-FileCopyrightText: 2021 David Edmundson + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ +#pragma once + +#include "abstractsystempoller.h" + +#include +#include + +class IdleManagerKwin; +class IdleManagerExt; + +class IdleTimeout; + +class Poller : public AbstractSystemPoller +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.kde.kidletime.AbstractSystemPoller" FILE "wayland.json") + Q_INTERFACES(AbstractSystemPoller) + +public: + explicit Poller(QObject *parent = nullptr); + ~Poller() override; + + bool isAvailable() override; + bool setUpPoller() override { + return true; + } + void unloadPoller() override {} + +public Q_SLOTS: + void addTimeout(int nextTimeout) override; + void removeTimeout(int nextTimeout) override; + QList timeouts() const override; + int forcePollRequest() override; + void catchIdleEvent() override; + void stopCatchingIdleEvents() override; + void simulateUserActivity() override; + +private: + bool initWayland(); + IdleTimeout* createTimeout(int timeout); + + QScopedPointer m_idleManagerKwin; + QScopedPointer m_idleManagerExt; + QHash> m_timeouts; + QScopedPointer m_catchResumeTimeout; + +}; diff --git a/src/plugins/wayland/wayland.json b/src/plugins/wayland/wayland.json new file mode 100644 index 0000000..2565559 --- /dev/null +++ b/src/plugins/wayland/wayland.json @@ -0,0 +1,3 @@ +{ + "platforms": ["wayland", "wayland-egl"] +} diff --git a/src/plugins/windows/CMakeLists.txt b/src/plugins/windows/CMakeLists.txt index 01054d8..1b47f29 100644 --- a/src/plugins/windows/CMakeLists.txt +++ b/src/plugins/windows/CMakeLists.txt @@ -12,5 +12,5 @@ install( TARGETS KF5IdleTimeWindowsPlugin DESTINATION - ${KDE_INSTALL_PLUGINDIR}/kf5/org.kde.kidletime.platforms/ + ${KDE_INSTALL_PLUGINDIR}/kf${QT_MAJOR_VERSION}/org.kde.kidletime.platforms/ ) diff --git a/src/plugins/xscreensaver/CMakeLists.txt b/src/plugins/xscreensaver/CMakeLists.txt index da2c633..a97b4a1 100644 --- a/src/plugins/xscreensaver/CMakeLists.txt +++ b/src/plugins/xscreensaver/CMakeLists.txt @@ -18,7 +18,7 @@ target_link_libraries(KF5IdleTimeXcbPlugin1 if (TARGET Qt5::X11Extras) target_link_libraries(KF5IdleTimeXcbPlugin1 Qt5::X11Extras) elseif (TARGET Qt6::Gui) - target_link_libraries(KF5IdleTimeXcbPlugin1 Qt6::GuiPrivate) # qtx11extras_p.h + target_link_libraries(KF5IdleTimeXcbPlugin1 Qt6::Gui) endif() @@ -26,5 +26,5 @@ install( TARGETS KF5IdleTimeXcbPlugin1 DESTINATION - ${KDE_INSTALL_PLUGINDIR}/kf5/org.kde.kidletime.platforms/ + ${KDE_INSTALL_PLUGINDIR}/kf${QT_MAJOR_VERSION}/org.kde.kidletime.platforms/ ) diff --git a/src/plugins/xscreensaver/xscreensaverbasedpoller.cpp b/src/plugins/xscreensaver/xscreensaverbasedpoller.cpp index e34f0fb..617bfe0 100644 --- a/src/plugins/xscreensaver/xscreensaverbasedpoller.cpp +++ b/src/plugins/xscreensaver/xscreensaverbasedpoller.cpp @@ -9,7 +9,7 @@ #include #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) -#include +#include #else #include #endif @@ -17,6 +17,15 @@ #include #include +static Display *display() +{ +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + return QX11Info::display(); +#else + return qGuiApp->nativeInterface()->display(); +#endif +} + XScreensaverBasedPoller::XScreensaverBasedPoller(QObject *parent) : WidgetBasedPoller(parent) , m_screenSaverIface(nullptr) @@ -53,7 +62,7 @@ int XScreensaverBasedPoller::getIdleTime() { XScreenSaverInfo *mitInfo = nullptr; mitInfo = XScreenSaverAllocInfo(); - XScreenSaverQueryInfo(QX11Info::display(), DefaultRootWindow(QX11Info::display()), mitInfo); + XScreenSaverQueryInfo(display(), DefaultRootWindow(display()), mitInfo); int ret = mitInfo->idle; XFree(mitInfo); return ret; @@ -62,6 +71,6 @@ int XScreensaverBasedPoller::getIdleTime() void XScreensaverBasedPoller::simulateUserActivity() { stopCatchingIdleEvents(); - XResetScreenSaver(QX11Info::display()); - XFlush(QX11Info::display()); + XResetScreenSaver(display()); + XFlush(display()); } diff --git a/src/plugins/xsync/CMakeLists.txt b/src/plugins/xsync/CMakeLists.txt index 033c99c..5cd35d4 100644 --- a/src/plugins/xsync/CMakeLists.txt +++ b/src/plugins/xsync/CMakeLists.txt @@ -32,12 +32,12 @@ target_link_libraries(KF5IdleTimeXcbPlugin0 if (TARGET Qt5::X11Extras) target_link_libraries(KF5IdleTimeXcbPlugin0 Qt5::X11Extras) elseif (TARGET Qt6::Gui) - target_link_libraries(KF5IdleTimeXcbPlugin0 Qt6::GuiPrivate) # qtx11extras_p.h + target_link_libraries(KF5IdleTimeXcbPlugin0 Qt6::Gui) endif() install( TARGETS KF5IdleTimeXcbPlugin0 DESTINATION - ${KDE_INSTALL_PLUGINDIR}/kf5/org.kde.kidletime.platforms/ + ${KDE_INSTALL_PLUGINDIR}/kf${QT_MAJOR_VERSION}/org.kde.kidletime.platforms/ ) diff --git a/src/plugins/xsync/xsyncbasedpoller.cpp b/src/plugins/xsync/xsyncbasedpoller.cpp index 4b84d8e..fc374a8 100644 --- a/src/plugins/xsync/xsyncbasedpoller.cpp +++ b/src/plugins/xsync/xsyncbasedpoller.cpp @@ -13,7 +13,7 @@ #include #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) -#include +#include #else #include #endif @@ -62,8 +62,13 @@ XSyncBasedPoller *XSyncBasedPoller::instance() XSyncBasedPoller::XSyncBasedPoller(QObject *parent) : AbstractSystemPoller(parent) +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + , m_display(qGuiApp->nativeInterface()->display()) +#else , m_display(QX11Info::display()) +#endif , m_xcb_connection(nullptr) + , m_sync_event(0) , m_idleCounter(None) , m_resetAlarm(None) , m_available(true) diff --git a/src/plugins/xsync/xsyncbasedpoller.h b/src/plugins/xsync/xsyncbasedpoller.h index 4756d1f..369ef30 100644 --- a/src/plugins/xsync/xsyncbasedpoller.h +++ b/src/plugins/xsync/xsyncbasedpoller.h @@ -36,10 +36,12 @@ class XSyncBasedPoller : public AbstractSystemPoller bool xcbEvent(xcb_generic_event_t *event); + QList timeouts() const override; + public Q_SLOTS: void addTimeout(int nextTimeout) override; void removeTimeout(int nextTimeout) override; - QList timeouts() const override; + int forcePollRequest() override; void catchIdleEvent() override; void stopCatchingIdleEvents() override; diff --git a/src/widgetbasedpoller.h b/src/widgetbasedpoller.h index f1aaf70..719d3ad 100644 --- a/src/widgetbasedpoller.h +++ b/src/widgetbasedpoller.h @@ -27,13 +27,15 @@ class KIDLETIME_EXPORT WidgetBasedPoller : public AbstractSystemPoller bool setUpPoller() override; void unloadPoller() override; + QList timeouts() const override; + protected: bool eventFilter(QObject *object, QEvent *event) override; public Q_SLOTS: void addTimeout(int nextTimeout) override; void removeTimeout(int nextTimeout) override; - QList timeouts() const override; + int forcePollRequest() override; void catchIdleEvent() override; void stopCatchingIdleEvents() override;