Add a DBus interface to the highlightWindows effect
The Taskmanager can now activate it this way, instead of using X atoms. This means it will also work on Wayland.
This commit is contained in:
parent
ab58171ed8
commit
26bf4f51d0
2 changed files with 31 additions and 0 deletions
|
@ -3,12 +3,15 @@
|
|||
This file is part of the KDE project.
|
||||
|
||||
SPDX-FileCopyrightText: 2009 Lucas Murray <lmurray@undefinedfire.com>
|
||||
SPDX-FileCopyrightText: 2021 David Redondo <kde@david-redondo.de>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "highlightwindow.h"
|
||||
|
||||
#include <QDBusConnection>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
|
@ -17,6 +20,7 @@ HighlightWindowEffect::HighlightWindowEffect()
|
|||
, m_fadeDuration(animationTime(150))
|
||||
, m_monitorWindow(nullptr)
|
||||
{
|
||||
// TODO KF6 remove atom support
|
||||
m_atom = effects->announceSupportProperty("_KDE_WINDOW_HIGHLIGHT", this);
|
||||
connect(effects, &EffectsHandler::windowAdded, this, &HighlightWindowEffect::slotWindowAdded);
|
||||
connect(effects, &EffectsHandler::windowClosed, this, &HighlightWindowEffect::slotWindowClosed);
|
||||
|
@ -31,6 +35,17 @@ HighlightWindowEffect::HighlightWindowEffect()
|
|||
m_atom = effects->announceSupportProperty("_KDE_WINDOW_HIGHLIGHT", this);
|
||||
}
|
||||
);
|
||||
|
||||
QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/kde/KWin/HighlightWindow"),
|
||||
QStringLiteral("org.kde.KWin.HighlightWindow"),
|
||||
this,
|
||||
QDBusConnection::ExportScriptableContents);
|
||||
QDBusConnection::sessionBus().registerService(QStringLiteral("org.kde.KWin.HighlightWindow"));
|
||||
}
|
||||
|
||||
HighlightWindowEffect::~HighlightWindowEffect()
|
||||
{
|
||||
QDBusConnection::sessionBus().unregisterService(QStringLiteral("org.kde.KWin.HighlightWindow"));
|
||||
}
|
||||
|
||||
static bool isInitiallyHidden(EffectWindow* w)
|
||||
|
@ -44,6 +59,20 @@ static bool isHighlightWindow(EffectWindow *window)
|
|||
return window->isNormalWindow() || window->isDialog();
|
||||
}
|
||||
|
||||
void HighlightWindowEffect::highlightWindows(const QStringList &windows)
|
||||
{
|
||||
QVector<EffectWindow*> effectWindows;
|
||||
effectWindows.reserve(windows.count());
|
||||
for (const auto &window : windows) {
|
||||
if (auto effectWindow = effects->findWindow(QUuid(window)); effectWindow) {
|
||||
effectWindows.append(effectWindow);
|
||||
} else if (auto effectWindow = effects->findWindow(window.toLong()); effectWindow) {
|
||||
effectWindows.append(effectWindow);
|
||||
}
|
||||
}
|
||||
highlightWindows(effectWindows);
|
||||
}
|
||||
|
||||
void HighlightWindowEffect::slotWindowAdded(EffectWindow* w)
|
||||
{
|
||||
if (!m_highlightedWindows.isEmpty()) {
|
||||
|
|
|
@ -21,6 +21,7 @@ class HighlightWindowEffect : public AnimationEffect
|
|||
|
||||
public:
|
||||
HighlightWindowEffect();
|
||||
~HighlightWindowEffect() override;
|
||||
|
||||
int requestedEffectChainPosition() const override {
|
||||
return 70;
|
||||
|
@ -28,6 +29,7 @@ public:
|
|||
|
||||
bool provides(Feature feature) override;
|
||||
bool perform(Feature feature, const QVariantList &arguments) override;
|
||||
Q_SCRIPTABLE void highlightWindows(const QStringList &windows);
|
||||
|
||||
public Q_SLOTS:
|
||||
void slotWindowAdded(KWin::EffectWindow* w);
|
||||
|
|
Loading…
Reference in a new issue