https://bugs.kde.org/show_bug.cgi?id=438312

--- Comment #10 from Aaron Rainbolt <arraybo...@gmail.com> ---
OK, I've read through the code and I think I see why this bug is occurring. My
understanding of C++ is not all that great since I don't actually know the
language, so this could be partially wrong. It appears that KWin tells
ksmserver to restore the previous session when the user logs back in,
relaunching programs that were open when the user logged out. However, when
"kwin_x11 --replace" is used, the applications are already launched, so the
session restoration code isn't run and the apps end up visible on all
activities.

In kwin/src/activities.cpp, bool Activities::start(const QString &id), lines
117-123:

>     QDBusInterface ksmserver("org.kde.ksmserver", "/KSMServer", 
> "org.kde.KSMServerInterface");
>     if (ksmserver.isValid()) {
>         ksmserver.asyncCall("restoreSubSession", id);
>     } else {
>         qCDebug(KWIN_CORE) << "couldn't get ksmserver interface";
>         return false;
>     }

ksmserver's "restoreSubSession" member function is called.

In
https://invent.kde.org/plasma/plasma-workspace/-/blob/master/ksmserver/server.cpp,
the member function void KSMServer::restoreSubSession(const QString &name)
calls void KSMServer::tryRestoreNext(), which appears to go through a list of
apps that need relaunched, determine whether they are already launched or not,
relaunches them if they are not launched, and skips over them when they are
already launched. Particularly, lines 986-994 of the above mentioned file:

> bool alreadyStarted = false;
>         foreach (KSMClient *c, clients) {
>             if (QString::fromLocal8Bit(c->clientId()) == clientId) {
>                 alreadyStarted = true;
>                 break;
>             }
>         }
>         if (alreadyStarted)
>             continue;

I believe this is where the bug is. The "if (alreadyStarted)" block needs to
determine which activity the window(s) of the already launched app are supposed
to be on, and specifically set the window(s) of that app to that activity.
Otherwise, when "kwin_x11 --replace" is called, none of the session restoration
really works, and thus you end up with a big lump of windows on all your
activities. I'd guess the reason that the activities still seem to be set
correctly for each app (as described in my previous comment) would be because
the windows themselves still retain memory of what activity they're supposed to
be on, but the restarted kwin process isn't taking that into account.

This might not be the best place for the fix to go, and it's possible I've
misunderstood the code, but this is what I have so far. I'm not quite sure how
to implement the proposed fix, I'm still working on that part. But here's the
progress I've made, hopefully this will be helpful.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to