Commit 26bf4f51 authored by David Redondo's avatar David Redondo 🏎
Browse files

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.
parent ab58171e
......@@ -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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment