plasma: handle tasks moving in tasks applet

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-09-29 05:11:47 +03:00
parent 1aca9ade6a
commit f52f6e7de3
2 changed files with 18 additions and 9 deletions

View file

@ -17,7 +17,6 @@
*/
#include "tasks.h"
#include "kworkspace/ktaskmanager.h"
#include <QGraphicsSceneContextMenuEvent>
#include <Plasma/Svg>
@ -225,6 +224,10 @@ void TasksApplet::init()
KTaskManager::self(), SIGNAL(taskAdded(KTaskManager::Task)),
this, SLOT(slotUpdateLayout())
);
connect(
KTaskManager::self(), SIGNAL(taskChanged(KTaskManager::Task)),
this, SLOT(slotTaskChanged(KTaskManager::Task))
);
connect(
KTaskManager::self(), SIGNAL(taskRemoved(KTaskManager::Task)),
this, SLOT(slotUpdateLayout())
@ -252,15 +255,19 @@ void TasksApplet::constraintsEvent(Plasma::Constraints constraints)
break;
}
}
updateOrientation();
QMutexLocker locker(&m_mutex);
foreach (TasksSvg* taskssvg, m_taskssvgs) {
taskssvg->setOrientation(m_layout->orientation());
}
}
}
void TasksApplet::updateOrientation()
void TasksApplet::slotTaskChanged(const KTaskManager::Task &task)
{
QMutexLocker locker(&m_mutex);
foreach (TasksSvg* taskssvg, m_taskssvgs) {
taskssvg->setOrientation(m_layout->orientation());
// special case for tasks moved from one virtual desktop to another
const KWindowInfo kwindowinfo = KWindowSystem::windowInfo(task.window, NET::WMDesktop);
if (!kwindowinfo.isOnDesktop(KWindowSystem::currentDesktop())) {
slotUpdateLayout();
}
}
@ -278,7 +285,8 @@ void TasksApplet::slotUpdateLayout()
}
adjustSize();
foreach (const KTaskManager::Task &task, KTaskManager::self()->tasks()) {
if (task.desktop != KWindowSystem::currentDesktop()) {
const KWindowInfo kwindowinfo = KWindowSystem::windowInfo(task.window, NET::WMDesktop);
if (!kwindowinfo.isOnDesktop(KWindowSystem::currentDesktop())) {
continue;
}
TasksSvg* taskssvg = new TasksSvg(task, this);

View file

@ -19,6 +19,8 @@
#ifndef TASKS_H
#define TASKS_H
#include "kworkspace/ktaskmanager.h"
#include <QMutex>
#include <QGraphicsLinearLayout>
#include <Plasma/Applet>
@ -35,6 +37,7 @@ public:
void init() final;
private Q_SLOTS:
void slotTaskChanged(const KTaskManager::Task &task);
void slotUpdateLayout();
protected:
@ -42,8 +45,6 @@ protected:
void constraintsEvent(Plasma::Constraints constraints) final;
private:
void updateOrientation();
QMutex m_mutex;
QGraphicsLinearLayout* m_layout;
QGraphicsWidget* m_spacer;