Commit 1419993b authored by David Redondo's avatar David Redondo 🏎
Browse files

Add a DBus interface to the presentWindows effect

The same as for the highlightWindows effect. Toggling it through
DBus is platform independent.
parent 26bf4f51
......@@ -21,6 +21,7 @@
#include <netwm_def.h>
#include <QApplication>
#include <QDBusConnection>
#include <QQmlContext>
#include <QQmlEngine>
#include <QQuickItem>
......@@ -55,6 +56,7 @@ PresentWindowsEffect::PresentWindowsEffect()
{
initConfig<PresentWindowsConfig>();
// TODO KF6 remove atom support
auto announceSupportProperties = [this] {
m_atomDesktop = effects->announceSupportProperty("_KDE_PRESENT_WINDOWS_DESKTOP", this);
m_atomWindows = effects->announceSupportProperty("_KDE_PRESENT_WINDOWS_GROUP", this);
......@@ -106,10 +108,17 @@ PresentWindowsEffect::PresentWindowsEffect()
connect(effects, &EffectsHandler::screenAboutToLock, this, [this]() {
setActive(false);
});
QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/kde/KWin/PresentWindows"),
QStringLiteral("org.kde.KWin.PresentWindows"),
this,
QDBusConnection::ExportScriptableSlots);
QDBusConnection::sessionBus().registerService(QStringLiteral("org.kde.KWin.PresentWindows"));
}
PresentWindowsEffect::~PresentWindowsEffect()
{
QDBusConnection::sessionBus().unregisterService(QStringLiteral("org.kde.KWin.PresentWindows"));
delete m_filterFrame;
delete m_closeView;
}
......@@ -925,6 +934,21 @@ void PresentWindowsEffect::slotPropertyNotify(EffectWindow* w, long a)
}
}
void PresentWindowsEffect::presentWindows(const QStringList &windows)
{
m_selectedWindows.clear();
for (const auto &window : windows) {
if (auto effectWindow = effects->findWindow(QUuid(window)); effectWindow) {
m_selectedWindows.append(effectWindow);
} else if (auto effectWindow = effects->findWindow(window.toLong()); effectWindow) {
m_selectedWindows.append(effectWindow);
}
}
m_mode = ModeWindowGroup;
setActive(true);
}
//-----------------------------------------------------------------------------
// Window rearranging
......
......@@ -184,6 +184,7 @@ public:
return m_rightButtonDesktop;
}
public Q_SLOTS:
Q_SCRIPTABLE void presentWindows(const QStringList &windows);
void setActive(bool active);
void toggleActive() {
m_mode = ModeCurrentDesktop;
......
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