Move setOnActivity to AbstractClient
Since we want to support activities for wayland clients too this needs to move up in the hierarchy.
This commit is contained in:
parent
391b7e023e
commit
c795e8a3d8
4 changed files with 39 additions and 31 deletions
|
@ -9,6 +9,9 @@
|
||||||
*/
|
*/
|
||||||
#include "abstract_client.h"
|
#include "abstract_client.h"
|
||||||
|
|
||||||
|
#ifdef KWIN_BUILD_ACTIVITIES
|
||||||
|
#include "activities.h"
|
||||||
|
#endif
|
||||||
#include "appmenu.h"
|
#include "appmenu.h"
|
||||||
#include "decorations/decoratedclient.h"
|
#include "decorations/decoratedclient.h"
|
||||||
#include "decorations/decorationpalette.h"
|
#include "decorations/decorationpalette.h"
|
||||||
|
@ -2794,6 +2797,41 @@ void AbstractClient::setOnActivities(const QStringList &newActivitiesList)
|
||||||
Q_UNUSED(newActivitiesList)
|
Q_UNUSED(newActivitiesList)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether the client is on @p activity.
|
||||||
|
* If you remove it from its last activity, then it's on all activities.
|
||||||
|
*
|
||||||
|
* Note: If it was on all activities and you try to remove it from one, nothing will happen;
|
||||||
|
* I don't think that's an important enough use case to handle here.
|
||||||
|
*/
|
||||||
|
void AbstractClient::setOnActivity(const QString &activity, bool enable)
|
||||||
|
{
|
||||||
|
#ifdef KWIN_BUILD_ACTIVITIES
|
||||||
|
if (!Activities::self()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QStringList newActivitiesList = activities();
|
||||||
|
if (newActivitiesList.contains(activity) == enable) {
|
||||||
|
//nothing to do
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (enable) {
|
||||||
|
QStringList allActivities = Activities::self()->all();
|
||||||
|
if (!allActivities.contains(activity)) {
|
||||||
|
//bogus ID
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
newActivitiesList.append(activity);
|
||||||
|
} else {
|
||||||
|
newActivitiesList.removeOne(activity);
|
||||||
|
}
|
||||||
|
setOnActivities(newActivitiesList);
|
||||||
|
#else
|
||||||
|
Q_UNUSED(activity)
|
||||||
|
Q_UNUSED(enable)
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void AbstractClient::checkNoBorder()
|
void AbstractClient::checkNoBorder()
|
||||||
{
|
{
|
||||||
setNoBorder(false);
|
setNoBorder(false);
|
||||||
|
|
|
@ -539,6 +539,7 @@ public:
|
||||||
virtual void checkNoBorder();
|
virtual void checkNoBorder();
|
||||||
virtual void setOnActivities(const QStringList &newActivitiesList);
|
virtual void setOnActivities(const QStringList &newActivitiesList);
|
||||||
virtual void setOnAllActivities(bool set) = 0;
|
virtual void setOnAllActivities(bool set) = 0;
|
||||||
|
void setOnActivity(const QString &activity, bool enable);
|
||||||
const WindowRules* rules() const {
|
const WindowRules* rules() const {
|
||||||
return &m_rules;
|
return &m_rules;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1878,36 +1878,6 @@ void X11Client::doSetDemandsAttention()
|
||||||
info->setState(isDemandingAttention() ? NET::DemandsAttention : NET::States(), NET::DemandsAttention);
|
info->setState(isDemandingAttention() ? NET::DemandsAttention : NET::States(), NET::DemandsAttention);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets whether the client is on @p activity.
|
|
||||||
* If you remove it from its last activity, then it's on all activities.
|
|
||||||
*
|
|
||||||
* Note: If it was on all activities and you try to remove it from one, nothing will happen;
|
|
||||||
* I don't think that's an important enough use case to handle here.
|
|
||||||
*/
|
|
||||||
void X11Client::setOnActivity(const QString &activity, bool enable)
|
|
||||||
{
|
|
||||||
#ifdef KWIN_BUILD_ACTIVITIES
|
|
||||||
if (! Activities::self()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
QStringList newActivitiesList = activities();
|
|
||||||
if (newActivitiesList.contains(activity) == enable) //nothing to do
|
|
||||||
return;
|
|
||||||
if (enable) {
|
|
||||||
QStringList allActivities = Activities::self()->all();
|
|
||||||
if (!allActivities.contains(activity)) //bogus ID
|
|
||||||
return;
|
|
||||||
newActivitiesList.append(activity);
|
|
||||||
} else
|
|
||||||
newActivitiesList.removeOne(activity);
|
|
||||||
setOnActivities(newActivitiesList);
|
|
||||||
#else
|
|
||||||
Q_UNUSED(activity)
|
|
||||||
Q_UNUSED(enable)
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set exactly which activities this client is on
|
* set exactly which activities this client is on
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -122,7 +122,6 @@ public:
|
||||||
void destroyClient() override;
|
void destroyClient() override;
|
||||||
|
|
||||||
QStringList activities() const override;
|
QStringList activities() const override;
|
||||||
void setOnActivity(const QString &activity, bool enable);
|
|
||||||
void setOnAllActivities(bool set) override;
|
void setOnAllActivities(bool set) override;
|
||||||
void setOnActivities(const QStringList &newActivitiesList) override;
|
void setOnActivities(const QStringList &newActivitiesList) override;
|
||||||
void updateActivities(bool includeTransients);
|
void updateActivities(bool includeTransients);
|
||||||
|
|
Loading…
Reference in a new issue