Update for plasma 6.6
This commit is contained in:
1 parent
449c6f2df1
commit
bd0095d920
11 files changed
+25
-96
No files matched your search
+3
-5
@@ -1,6 +1,6 @@
|
||||
project(applet_window_appmenu)
|
||||
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
|
||||
|
||||
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
|
||||
project(applet_window_appmenu)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(VERSION 0.8.0)
|
||||
@@ -18,11 +18,9 @@ set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
|
||||
find_package(Qt6 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Quick Widgets DBus)
|
||||
|
||||
find_package(KF6 ${KF6_MIN_VERSION} REQUIRED COMPONENTS WindowSystem ConfigWidgets)
|
||||
find_package(KWayland REQUIRED)
|
||||
|
||||
find_package(Plasma "6.0" REQUIRED)
|
||||
|
||||
find_package(KDecoration2 REQUIRED)
|
||||
find_package(KDecoration3 REQUIRED)
|
||||
find_package(LibTaskManager)
|
||||
|
||||
include(ECMQtDeclareLoggingCategory)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Window AppMenu Applet
|
||||
This is port [psifidotos](https://github.com/psifidotos/applet-window-appmenu/) and [proatgram](https://github.com/proatgram/applet-window-appmenu6/) .
|
||||
|
||||
This is a Plasma 6 applet that shows the current window appmenu in your panels. This plasmoid was coming from [Latte land](https://phabricator.kde.org/source/latte-dock/repository/master/) but now support only Plasma panels.
|
||||
This is a Plasma 6.6 applet that shows the current window appmenu in your panels. This plasmoid was coming from [Latte land](https://phabricator.kde.org/source/latte-dock/repository/master/) but now support only Plasma panels.
|
||||
|
||||
<p align="center">
|
||||
<img src="https://i.imgur.com/T0sLWav.gif" width="580"><br/>
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
if ! [ -a build ] ; then
|
||||
if [ ! -d build ] ; then
|
||||
mkdir build
|
||||
fi
|
||||
cd build
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ target_link_libraries(org.kde.windowappmenu
|
||||
KF6::ConfigWidgets
|
||||
Plasma::Plasma
|
||||
KF6::WindowSystem
|
||||
KDecoration2::KDecoration
|
||||
KDecoration2::KDecoration2Private)
|
||||
KDecoration3::KDecoration
|
||||
KDecoration3::KDecoration3Private)
|
||||
|
||||
install(TARGETS org.kde.windowappmenu DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/applets)
|
||||
@@ -62,10 +62,10 @@ bool DecorationPalette::isValid() const
|
||||
return m_activeTitleBarColor.isValid();
|
||||
}
|
||||
|
||||
QColor DecorationPalette::color(KDecoration2::ColorGroup group, KDecoration2::ColorRole role) const
|
||||
QColor DecorationPalette::color(KDecoration3::ColorGroup group, KDecoration3::ColorRole role) const
|
||||
{
|
||||
using KDecoration2::ColorRole;
|
||||
using KDecoration2::ColorGroup;
|
||||
using KDecoration3::ColorRole;
|
||||
using KDecoration3::ColorGroup;
|
||||
|
||||
switch (role) {
|
||||
case ColorRole::Frame:
|
||||
|
||||
@@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#ifndef KWIN_DECORATION_PALETTE_H
|
||||
#define KWIN_DECORATION_PALETTE_H
|
||||
|
||||
#include <KDecoration2/DecorationSettings>
|
||||
#include <KDecoration3/DecorationSettings>
|
||||
#include <QFileSystemWatcher>
|
||||
#include <QPalette>
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
QColor color(KDecoration2::ColorGroup group, KDecoration2::ColorRole role) const;
|
||||
QColor color(KDecoration3::ColorGroup group, KDecoration3::ColorRole role) const;
|
||||
QPalette palette() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"Icon": "show-menu",
|
||||
"Id": "org.kde.windowappmenu",
|
||||
"License": "GPL-2.0+",
|
||||
"Name": "Window AppMenu6",
|
||||
"Name": "Window AppMenu",
|
||||
"ServiceTypes": [
|
||||
"Plasma/Applet"
|
||||
],
|
||||
|
||||
@@ -21,7 +21,6 @@ target_link_libraries(appmenuplugin
|
||||
Qt6::Widgets
|
||||
Qt6::Quick
|
||||
Plasma::Plasma
|
||||
Plasma::KWaylandClient
|
||||
KF6::WindowSystem
|
||||
PW::LibTaskManager
|
||||
dbusmenuqt)
|
||||
|
||||
@@ -62,13 +62,6 @@ AppMenuModel::AppMenuModel(QObject *parent)
|
||||
: QAbstractListModel(parent),
|
||||
m_serviceWatcher(new QDBusServiceWatcher(this))
|
||||
{
|
||||
#if LibTaskManager_CURRENTMINOR_VERSION < 19
|
||||
// Disable for Plasma Desktop < 5.19
|
||||
if (KWindowSystem::isPlatformWayland()) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
initWM();
|
||||
|
||||
connect(this, &AppMenuModel::modelNeedsUpdate, this, [this] {
|
||||
|
||||
@@ -18,15 +18,12 @@
|
||||
*/
|
||||
|
||||
#include "waylandwindowmanager.h"
|
||||
#include <config-appmenu.h>
|
||||
|
||||
//Qt
|
||||
#include <QDebug>
|
||||
#include <QModelIndex>
|
||||
|
||||
// KDE
|
||||
#include <KWayland/Client/connection_thread.h>
|
||||
#include <KWayland/Client/registry.h>
|
||||
#include <KWindowSystem>
|
||||
|
||||
// Plasma
|
||||
@@ -39,17 +36,12 @@ namespace WM {
|
||||
WaylandWindowManager::WaylandWindowManager(QObject *parent)
|
||||
: AbstractWindowManager(parent)
|
||||
{
|
||||
#if KF5_CURRENTMINOR_VERSION < 69
|
||||
// Disable for KF5::Wayland < 5.69
|
||||
if (KWindowSystem::isPlatformWayland()) {
|
||||
if (!KWindowSystem::isPlatformWayland()) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
m_tasksModel = new TaskManager::TasksModel(this);
|
||||
|
||||
setupWaylandIntegration();
|
||||
|
||||
m_delayedApplicationMenuTimer.setSingleShot(true);
|
||||
m_delayedApplicationMenuTimer.setInterval(DELAYEDMENUTIMER);
|
||||
connect(&m_delayedApplicationMenuTimer, &QTimer::timeout, this, &WaylandWindowManager::onDelayedTimerTriggered);
|
||||
@@ -71,80 +63,38 @@ WaylandWindowManager::~WaylandWindowManager()
|
||||
{
|
||||
}
|
||||
|
||||
void WaylandWindowManager::setupWaylandIntegration()
|
||||
{
|
||||
if (!KWindowSystem::isPlatformWayland()) {
|
||||
return;
|
||||
}
|
||||
|
||||
using namespace KWayland::Client;
|
||||
auto connection = ConnectionThread::fromApplication(this);
|
||||
|
||||
if (!connection) {
|
||||
return;
|
||||
}
|
||||
|
||||
Registry *registry{new Registry(this)};
|
||||
registry->create(connection);
|
||||
|
||||
connect(registry, &Registry::plasmaShellAnnounced, this
|
||||
, [this, registry](quint32 name, quint32 version) {
|
||||
m_waylandShell = registry->createPlasmaShell(name, version, this);
|
||||
});
|
||||
|
||||
QObject::connect(registry, &KWayland::Client::Registry::plasmaWindowManagementAnnounced,
|
||||
[this, registry](quint32 name, quint32 version) {
|
||||
m_windowManagement = registry->createPlasmaWindowManagement(name, version, this);
|
||||
});
|
||||
|
||||
registry->setup();
|
||||
connection->roundtrip();
|
||||
}
|
||||
|
||||
KWayland::Client::PlasmaWindow *WaylandWindowManager::windowFor(QVariant wid)
|
||||
{
|
||||
auto it = std::find_if(m_windowManagement->windows().constBegin(), m_windowManagement->windows().constEnd(), [&wid](KWayland::Client::PlasmaWindow * w) noexcept {
|
||||
return w->isValid() && w->uuid().toUInt() == wid.toUInt();
|
||||
});
|
||||
|
||||
if (it == m_windowManagement->windows().constEnd()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return *it;
|
||||
}
|
||||
|
||||
void WaylandWindowManager::onActiveWindowChanged()
|
||||
{
|
||||
if (hasUserWindowId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if LibTaskManager_CURRENTMINOR_VERSION >= 19
|
||||
const QModelIndex activeTaskIndex = m_tasksModel->activeTask();
|
||||
const QString objectPath = m_tasksModel->data(activeTaskIndex, TaskManager::AbstractTasksModel::ApplicationMenuObjectPath).toString();
|
||||
const QString serviceName = m_tasksModel->data(activeTaskIndex, TaskManager::AbstractTasksModel::ApplicationMenuServiceName).toString();
|
||||
|
||||
validateApplicationMenu(objectPath, serviceName);
|
||||
#endif
|
||||
}
|
||||
|
||||
void WaylandWindowManager::onWinIdChanged()
|
||||
{
|
||||
if (!m_windowManagement || !hasUserWindowId()) {
|
||||
if (!hasUserWindowId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if KF5_CURRENTMINOR_VERSION >= 69
|
||||
auto window = windowFor(m_userWindowId);
|
||||
// Search the tasks model for the window matching m_userWindowId
|
||||
for (int i = 0; i < m_tasksModel->rowCount(); ++i) {
|
||||
const QModelIndex idx = m_tasksModel->index(i, 0);
|
||||
const QVariant wid = m_tasksModel->data(idx, TaskManager::AbstractTasksModel::WinIdList);
|
||||
|
||||
if (window) {
|
||||
const QString objectPath = window->applicationMenuObjectPath();
|
||||
const QString serviceName = window->applicationMenuServiceName();
|
||||
if (wid.toList().contains(m_userWindowId) || wid == m_userWindowId) {
|
||||
const QString objectPath = m_tasksModel->data(idx, TaskManager::AbstractTasksModel::ApplicationMenuObjectPath).toString();
|
||||
const QString serviceName = m_tasksModel->data(idx, TaskManager::AbstractTasksModel::ApplicationMenuServiceName).toString();
|
||||
|
||||
validateApplicationMenu(objectPath, serviceName);
|
||||
validateApplicationMenu(objectPath, serviceName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void WaylandWindowManager::validateApplicationMenu(const QString &objectPath, const QString &serviceName)
|
||||
|
||||
@@ -28,10 +28,6 @@
|
||||
#include <QPointer>
|
||||
#include <QTimer>
|
||||
|
||||
// KDE
|
||||
#include <KWayland/Client/plasmashell.h>
|
||||
#include <KWayland/Client/plasmawindowmanagement.h>
|
||||
|
||||
// Plasma TaskManager
|
||||
#include <taskmanager/tasksmodel.h>
|
||||
|
||||
@@ -51,20 +47,13 @@ private slots:
|
||||
void onWinIdChanged();
|
||||
|
||||
private:
|
||||
void setupWaylandIntegration();
|
||||
void validateApplicationMenu(const QString &objectPath, const QString &serviceName);
|
||||
|
||||
|
||||
KWayland::Client::PlasmaWindow *windowFor(QVariant wid);
|
||||
|
||||
private:
|
||||
//! window that its menu initialization may be delayed
|
||||
QVariant m_delayedMenuWindowId{-1};
|
||||
QTimer m_delayedApplicationMenuTimer;
|
||||
|
||||
KWayland::Client::PlasmaShell *m_waylandShell{nullptr};
|
||||
QPointer<KWayland::Client::PlasmaWindowManagement> m_windowManagement;
|
||||
|
||||
TaskManager::TasksModel* m_tasksModel;
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user