diff --git a/libtaskmanager/CMakeLists.txt b/libtaskmanager/CMakeLists.txt index 18b336c6e..cd01252cf 100644 --- a/libtaskmanager/CMakeLists.txt +++ b/libtaskmanager/CMakeLists.txt @@ -1,111 +1,112 @@ add_subdirectory(declarative) add_subdirectory(autotests) set(taskmanager_LIB_SRCS abstracttasksmodel.cpp abstracttasksproxymodeliface.cpp activityinfo.cpp concatenatetasksproxymodel.cpp flattentaskgroupsproxymodel.cpp launchertasksmodel.cpp startuptasksmodel.cpp taskfilterproxymodel.cpp taskgroupingproxymodel.cpp tasksmodel.cpp tasktools.cpp virtualdesktopinfo.cpp waylandtasksmodel.cpp windowtasksmodel.cpp ) if (X11_FOUND) set(taskmanager_LIB_SRCS ${taskmanager_LIB_SRCS} xwindowtasksmodel.cpp ) endif() add_library(taskmanager ${taskmanager_LIB_SRCS}) add_library(PW::LibTaskManager ALIAS taskmanager) generate_export_header(taskmanager) target_include_directories(taskmanager PUBLIC "$" "$") target_link_libraries(taskmanager PUBLIC Qt5::Core Qt5::Gui Qt5::Quick KF5::ItemModels PRIVATE + Qt5::DBus KF5::Activities KF5::ConfigCore KF5::KIOCore KF5::KIOWidgets KF5::ProcessCore KF5::WaylandClient KF5::WindowSystem ) if (X11_FOUND) target_link_libraries(taskmanager PRIVATE Qt5::X11Extras KF5::IconThemes) endif() set_target_properties(taskmanager PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION 6 EXPORT_NAME LibTaskManager) install(TARGETS taskmanager EXPORT libtaskmanagerLibraryTargets ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} ) install(FILES abstracttasksmodel.h abstracttasksmodeliface.h abstracttasksproxymodeliface.h activityinfo.h concatenatetasksproxymodel.h flattentaskgroupsproxymodel.h launchertasksmodel.h startuptasksmodel.h taskfilterproxymodel.h taskgroupingproxymodel.h tasksmodel.h tasktools.h virtualdesktopinfo.h waylandtasksmodel.h windowtasksmodel.h ${CMAKE_CURRENT_BINARY_DIR}/taskmanager_export.h DESTINATION ${KDE_INSTALL_INCLUDEDIR}/taskmanager COMPONENT Devel ) if (X11_FOUND) install(FILES xwindowtasksmodel.h ${CMAKE_CURRENT_BINARY_DIR}/taskmanager_export.h DESTINATION ${KDE_INSTALL_INCLUDEDIR}/taskmanager COMPONENT Devel ) endif() write_basic_config_version_file(${CMAKE_CURRENT_BINARY_DIR}/LibTaskManagerConfigVersion.cmake VERSION "${PROJECT_VERSION}" COMPATIBILITY AnyNewerVersion) set(CMAKECONFIG_INSTALL_DIR ${KDE_INSTALL_LIBDIR}/cmake/LibTaskManager) ecm_configure_package_config_file(LibTaskManagerConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/LibTaskManagerConfig.cmake" INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/LibTaskManagerConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/LibTaskManagerConfigVersion.cmake DESTINATION ${CMAKECONFIG_INSTALL_DIR}) install(EXPORT libtaskmanagerLibraryTargets NAMESPACE PW:: DESTINATION ${CMAKECONFIG_INSTALL_DIR} FILE LibTaskManagerLibraryTargets.cmake ) install(FILES taskmanagerrulesrc DESTINATION ${KDE_INSTALL_CONFDIR}) diff --git a/libtaskmanager/virtualdesktopinfo.cpp b/libtaskmanager/virtualdesktopinfo.cpp index f8b61955f..3087855e9 100644 --- a/libtaskmanager/virtualdesktopinfo.cpp +++ b/libtaskmanager/virtualdesktopinfo.cpp @@ -1,66 +1,95 @@ /******************************************************************** Copyright 2016 Eike Hein This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . *********************************************************************/ #include "virtualdesktopinfo.h" #include +#include + +#include + +#if HAVE_X11 +#include +#include +#endif + namespace TaskManager { VirtualDesktopInfo::VirtualDesktopInfo(QObject *parent) : QObject(parent) { connect(KWindowSystem::self(), &KWindowSystem::currentDesktopChanged, this, &VirtualDesktopInfo::currentDesktopChanged); connect(KWindowSystem::self(), &KWindowSystem::numberOfDesktopsChanged, this, &VirtualDesktopInfo::numberOfDesktopsChanged); connect(KWindowSystem::self(), &KWindowSystem::desktopNamesChanged, this, &VirtualDesktopInfo::desktopNamesChanged); + +#if HAVE_X11 + if (KWindowSystem::isPlatformX11()) { + QDBusConnection dbus = QDBusConnection::sessionBus(); + dbus.connect(QString(), QStringLiteral("/KWin"), QStringLiteral("org.kde.KWin"), QStringLiteral("reloadConfig"), + this, SIGNAL(desktopLayoutRowsChanged())); + } +#endif } VirtualDesktopInfo::~VirtualDesktopInfo() { } int VirtualDesktopInfo::currentDesktop() const { return KWindowSystem::currentDesktop(); } int VirtualDesktopInfo::numberOfDesktops() const { return KWindowSystem::numberOfDesktops(); } QStringList VirtualDesktopInfo::desktopNames() const { QStringList names; // Virtual desktop numbers start at 1. for (int i = 1; i <= KWindowSystem::numberOfDesktops(); ++i) { names << KWindowSystem::desktopName(i); } return names; } +int VirtualDesktopInfo::desktopLayoutRows() const +{ +#if HAVE_X11 + if (KWindowSystem::isPlatformX11()) { + const NETRootInfo info(QX11Info::connection(), NET::NumberOfDesktops | NET::DesktopNames, NET::WM2DesktopLayout); + return info.desktopLayoutColumnsRows().height(); + } +#endif + + return 0; +} + } diff --git a/libtaskmanager/virtualdesktopinfo.h b/libtaskmanager/virtualdesktopinfo.h index 088b5eb63..aca6e7684 100644 --- a/libtaskmanager/virtualdesktopinfo.h +++ b/libtaskmanager/virtualdesktopinfo.h @@ -1,90 +1,101 @@ /******************************************************************** Copyright 2016 Eike Hein This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . *********************************************************************/ #ifndef VIRTUALDESKTOPINFO_H #define VIRTUALDESKTOPINFO_H #include #include "taskmanager_export.h" +#include + namespace TaskManager { /** * @short Provides basic virtual desktop information. * * This class provides basic information about the virtual desktops present * in the session as a set of notifiable properties. * * @NOTE: This is a placeholder, to be moved into KWindowSystem (which it * wraps) or the Task Manager applet backend (which used to fill this role * in the past). * * @see KWindowSystem * * @author Eike Hein **/ class TASKMANAGER_EXPORT VirtualDesktopInfo : public QObject { Q_OBJECT Q_PROPERTY(int currentDesktop READ currentDesktop NOTIFY currentDesktopChanged) Q_PROPERTY(int numberOfDesktops READ numberOfDesktops NOTIFY numberOfDesktopsChanged) Q_PROPERTY(QStringList desktopNames READ desktopNames NOTIFY desktopNamesChanged) + Q_PROPERTY(int desktopLayoutRows READ desktopLayoutRows NOTIFY desktopLayoutRowsChanged) public: explicit VirtualDesktopInfo(QObject *parent = 0); virtual ~VirtualDesktopInfo(); /** * The currently active virtual desktop. * * @returns the number of the currently active virtual desktop. **/ int currentDesktop() const; /** * The number of virtual desktops present in the session. * * @returns the number of virtual desktops present in the session. **/ int numberOfDesktops() const; /** * The names of all virtual desktops present in the session. Note that * virtual desktops are indexed starting at 1, so the name for virtual * desktop 1 is at index 0 in this list. * * @returns a the list of names for the virtual desktops present in the * session. **/ QStringList desktopNames() const; + /** + * The number of rows in the virtual desktop layout. + * + * @returns the number of rows in the virtual desktop layout. + **/ + int desktopLayoutRows() const; + Q_SIGNALS: void currentDesktopChanged() const; void numberOfDesktopsChanged() const; void desktopNamesChanged() const; + void desktopLayoutRowsChanged() const; }; } #endif