diff --git a/src/abstract_client.cpp b/src/abstract_client.cpp index 628c0315c0..8dae042ed8 100644 --- a/src/abstract_client.cpp +++ b/src/abstract_client.cpp @@ -9,6 +9,9 @@ */ #include "abstract_client.h" +#ifdef KWIN_BUILD_ACTIVITIES +#include "activities.h" +#endif #include "appmenu.h" #include "decorations/decoratedclient.h" #include "decorations/decorationpalette.h" @@ -2794,6 +2797,41 @@ void AbstractClient::setOnActivities(const QStringList &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() { setNoBorder(false); diff --git a/src/abstract_client.h b/src/abstract_client.h index f3dd378e49..8797f00eea 100644 --- a/src/abstract_client.h +++ b/src/abstract_client.h @@ -539,6 +539,7 @@ public: virtual void checkNoBorder(); virtual void setOnActivities(const QStringList &newActivitiesList); virtual void setOnAllActivities(bool set) = 0; + void setOnActivity(const QString &activity, bool enable); const WindowRules* rules() const { return &m_rules; } diff --git a/src/x11client.cpp b/src/x11client.cpp index 3a78d1ef1c..f714540d69 100644 --- a/src/x11client.cpp +++ b/src/x11client.cpp @@ -1878,36 +1878,6 @@ void X11Client::doSetDemandsAttention() 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 */ diff --git a/src/x11client.h b/src/x11client.h index dfca76d4a2..30631bf195 100644 --- a/src/x11client.h +++ b/src/x11client.h @@ -122,7 +122,6 @@ public: void destroyClient() override; QStringList activities() const override; - void setOnActivity(const QString &activity, bool enable); void setOnAllActivities(bool set) override; void setOnActivities(const QStringList &newActivitiesList) override; void updateActivities(bool includeTransients);