scripting: add isEffectActive to query effect active state
This commit is contained in:
parent
c974bf0b04
commit
5fc009d64a
4 changed files with 29 additions and 0 deletions
|
@ -1421,6 +1421,17 @@ QStringList EffectsHandlerImpl::activeEffects() const
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool EffectsHandlerImpl::isEffectActive(const QString &pluginId) const
|
||||
{
|
||||
auto it = std::find_if(loaded_effects.cbegin(), loaded_effects.cend(), [&pluginId](const EffectPair &p) {
|
||||
return p.first == pluginId;
|
||||
});
|
||||
if (it == loaded_effects.cend()) {
|
||||
return false;
|
||||
}
|
||||
return it->second->isActive();
|
||||
}
|
||||
|
||||
bool EffectsHandlerImpl::blocksDirectScanout() const
|
||||
{
|
||||
return std::any_of(m_activeEffects.constBegin(), m_activeEffects.constEnd(), [](const Effect *effect) {
|
||||
|
|
|
@ -177,6 +177,7 @@ public:
|
|||
QStringList listOfEffects() const;
|
||||
void unloadAllEffects();
|
||||
QStringList activeEffects() const;
|
||||
bool isEffectActive(const QString &pluginId) const;
|
||||
|
||||
/**
|
||||
* @returns whether or not any effect is currently active where KWin should not use direct scanout
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "core/output.h"
|
||||
#include "core/outputbackend.h"
|
||||
#include "cursor.h"
|
||||
#include "effects.h"
|
||||
#include "outline.h"
|
||||
#include "tiles/tilemanager.h"
|
||||
#include "virtualdesktops.h"
|
||||
|
@ -327,6 +328,14 @@ QList<KWin::Window *> WorkspaceWrapper::windowAt(const QPointF &pos, int count)
|
|||
return result;
|
||||
}
|
||||
|
||||
bool WorkspaceWrapper::isEffectActive(const QString &pluginId) const
|
||||
{
|
||||
if (!effects) {
|
||||
return false;
|
||||
}
|
||||
return static_cast<EffectsHandlerImpl *>(effects)->isEffectActive(pluginId);
|
||||
}
|
||||
|
||||
QSize WorkspaceWrapper::desktopGridSize() const
|
||||
{
|
||||
return VirtualDesktopManager::self()->grid().size();
|
||||
|
|
|
@ -256,6 +256,14 @@ public:
|
|||
*/
|
||||
Q_INVOKABLE QList<KWin::Window *> windowAt(const QPointF &pos, int count = 1) const;
|
||||
|
||||
/**
|
||||
* Checks if a specific effect is currently active.
|
||||
* @param pluginId The plugin Id of the effect to check.
|
||||
* @return @c true if the effect is loaded and currently active, @c false otherwise.
|
||||
* @since 6.0
|
||||
*/
|
||||
Q_INVOKABLE bool isEffectActive(const QString &pluginId) const;
|
||||
|
||||
public Q_SLOTS:
|
||||
// all the available key bindings
|
||||
void slotSwitchDesktopNext();
|
||||
|
|
Loading…
Reference in a new issue