Add a DBus interface to the presentWindows effect
The same as for the highlightWindows effect. Toggling it through DBus is platform independent.
This commit is contained in:
parent
26bf4f51d0
commit
1419993b89
2 changed files with 25 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue