Sync activities after kwin restart

Activities are loaded async. During this time any fetch of activity
information is incorrect as we will treat any settings as invalid.

We need to ignore attempts to set activities during this time, but also
refresh Window's concept of activities once we are loaded.

BUG: 438312
This commit is contained in:
David Edmundson 2022-09-28 14:54:42 +01:00 committed by Vlad Zahorodnii
parent e60f26e0ab
commit ad95b495ac
5 changed files with 26 additions and 1 deletions

View file

@ -28,6 +28,7 @@ Activities::Activities()
connect(m_controller, &KActivities::Controller::activityRemoved, this, &Activities::removed);
connect(m_controller, &KActivities::Controller::activityAdded, this, &Activities::added);
connect(m_controller, &KActivities::Controller::currentActivityChanged, this, &Activities::slotCurrentChanged);
connect(m_controller, &KActivities::Controller::serviceStatusChanged, this, &Activities::slotServiceStatusChanged);
}
KActivities::Consumer::ServiceStatus Activities::serviceStatus() const
@ -35,6 +36,20 @@ KActivities::Consumer::ServiceStatus Activities::serviceStatus() const
return m_controller->serviceStatus();
}
void Activities::slotServiceStatusChanged()
{
if (m_controller->serviceStatus() != KActivities::Consumer::Running) {
return;
}
const auto windows = Workspace::self()->allClientList();
for (auto *const window : windows) {
if (window->isDesktop()) {
continue;
}
window->checkActivities();
}
}
void Activities::setCurrent(const QString &activity)
{
m_controller->setCurrentActivity(activity);

View file

@ -71,6 +71,7 @@ Q_SIGNALS:
void removed(const QString &id);
private Q_SLOTS:
void slotServiceStatusChanged();
void slotRemoved(const QString &activity);
void slotCurrentChanged(const QString &newActivity);
void reallyStop(const QString &id); // dbus deadlocks suck

View file

@ -3500,6 +3500,9 @@ void Window::setOnActivities(const QStringList &newActivitiesList)
if (!Workspace::self()->activities()) {
return;
}
if (Workspace::self()->activities()->serviceStatus() != KActivities::Consumer::Running) {
return;
}
const auto allActivities = Workspace::self()->activities()->all();
const auto activityList = [&] {
auto result = rules()->checkActivity(newActivitiesList);

View file

@ -1072,6 +1072,12 @@ public:
virtual bool userCanSetNoBorder() const;
virtual void checkNoBorder();
/**
* Refresh Window's cache of activites
* Called when activity daemon status changes
*/
virtual void checkActivities(){};
void setOnActivity(const QString &activity, bool enable);
void setOnActivities(const QStringList &newActivitiesList);
void setOnAllActivities(bool all);

View file

@ -176,6 +176,7 @@ public:
void setNoBorder(bool set) override;
bool userCanSetNoBorder() const override;
void checkNoBorder() override;
void checkActivities() override;
int sessionStackingOrder() const;
@ -520,7 +521,6 @@ private:
Xcb::StringProperty fetchActivities() const;
void readActivities(Xcb::StringProperty &property);
void checkActivities();
bool activitiesDefined; // whether the x property was actually set
bool sessionActivityOverride;