[x11window] Remove duplicate activities check

We check if activities are valid in Window::setActivities. We don't need
to do it when we read the X11 properties.
This commit is contained in:
David Edmundson 2022-09-28 15:00:49 +01:00 committed by Vlad Zahorodnii
parent ad95b495ac
commit 3649ec474b

View file

@ -2473,7 +2473,6 @@ Xcb::StringProperty X11Window::fetchActivities() const
void X11Window::readActivities(Xcb::StringProperty &property)
{
#if KWIN_BUILD_ACTIVITIES
QStringList newActivitiesList;
QString prop = QString::fromUtf8(property);
activitiesDefined = !prop.isEmpty();
@ -2494,31 +2493,12 @@ void X11Window::readActivities(Xcb::StringProperty &property)
return;
}
newActivitiesList = prop.split(u',');
const QStringList newActivitiesList = prop.split(u',');
if (newActivitiesList == m_activityList) {
return; // expected change, it's ok.
}
// otherwise, somebody else changed it. we need to validate before reacting.
// if the activities are not synced, and there are existing clients with
// activities specified, somebody has restarted kwin. we can not validate
// activities in this case. we need to trust the old values.
if (Workspace::self()->activities() && Workspace::self()->activities()->serviceStatus() != KActivities::Consumer::Unknown) {
QStringList allActivities = Workspace::self()->activities()->all();
if (allActivities.isEmpty()) {
qCDebug(KWIN_CORE) << "no activities!?!?";
// don't touch anything, there's probably something bad going on and we don't wanna make it worse
return;
}
for (int i = 0; i < newActivitiesList.size(); ++i) {
if (!allActivities.contains(newActivitiesList.at(i))) {
qCDebug(KWIN_CORE) << "invalid:" << newActivitiesList.at(i);
newActivitiesList.removeAt(i--);
}
}
}
setOnActivities(newActivitiesList);
#else
Q_UNUSED(property)