Bug 435743

Summary: Wayland: Switching activities does not remember current virtual desktop
Product: [Plasma] kwin Reporter: Oded Arbel <oded>
Component: activitiesAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED DUPLICATE    
Severity: normal CC: daniel.pflager, nate
Priority: NOR    
Version: git master   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Oded Arbel 2021-04-14 23:00:47 UTC
SUMMARY
With KWin Wayland, when changing desktops, the desktop is changed in all activities, while in KWin X11 each activity maintains its own "current desktop".

STEPS TO REPRODUCE
1. Set up two or more activities with 2 or more desktops/workspaces.
2. Switch to desktop 2 in the first activity.
3. Switch to the second activity.
4. Switch to desktop 1.
5. Switch back to the first activity.

OBSERVED RESULT
Back in the first activity, the current desktop is desktop 1.

EXPECTED RESULT
In the first activity the current desktop should remain desktop 2, as it is under X11.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
KDE Plasma Version: 5.21.80
KDE Frameworks Version: 5.82.0
Qt Version: 5.15.2
Comment 1 Oded Arbel 2021-09-23 13:27:57 UTC
This issue had apparently been ported back to X11 - where kwin_x11 used to remember a different current virtual desktop for each activity, it is now also affected.

This could be a recent change in kwin_x11 - I'm running on neon unstable, currently with kwin-x11 4:5.22.5+p20.04+tunstable+git20210923.0148-0 , or it could be an old behavior that was triggered by the fact that yesterday I removed all of my activities and recreated them.
Comment 2 Daniel P Pflager 2021-09-25 18:05:41 UTC
I have observed a similar behavior with Plasma on X11.

I have a dozen activities at least.  Each one has a different custom folder.

When I change activity, the desktop becomes empty.

If I `touch` something in the directory associated with that activity, the desktop will appear.

It's as if there is a "refresh desktop" function not being called when the activity changes.

Plasma on X11 OR Wayland
Operating System: openSUSE Leap 15.2
KDE Plasma Version: 5.18.6
KDE Frameworks Version: 5.71.0
Qt Version: 5.12.7
Kernel Version: 5.3.18-lp152.87-preempt
OS Type: 64-bit
Processors: 8 × Intel® Core™ i7-7820HQ CPU @ 2.90GHz
Memory: 62.4 GiB of RAM
Comment 3 Daniel P Pflager 2021-09-25 18:13:51 UTC
In the Configure Desktop dialog (right-click on the empty Desktop, then select Configure Desktop), the (Custom location) radio button shows as being still selected and the Custom location textbox is set to the correct filesystem location. 

If I now change the radio button selection to Desktop folder or to Places panel item, the icons for that selection do appear on the desktop.

Having switched to one of the radio buttons above, if I then re-select the (Custom location) radio button, I will see the desktop icons for the Custom location again.

Thereafter, during the same session, they seem to "stick".
Comment 4 Oded Arbel 2021-09-26 11:17:22 UTC
(In reply to Daniel P Pflager from comment #2)
> I have observed a similar behavior with Plasma on X11.
> 
> I have a dozen activities at least.  Each one has a different custom folder.

I think the issue you are discussing here is not the issue I reported - I was worried about the virtual desktop selected (i.e. you switch to desktop 1, change activity, switch to desktop 4, change back, you'd expect to be at desktop 1 and not 4).

You seem to be talking about what the folder containment on activity desktop is set for - it seems to be a serious issue that should be reported, so I recommend you open a new ticket for that. Up until now I only use folder containment on one of my activities, so I didn't encounter it - but I will check.
Comment 5 Oded Arbel 2021-09-26 20:14:35 UTC
I forgot to mention that as part of the reproduction, you have to open System Settings, go to Workspace Behavior -> Activities -> Switching and check "Current Desktop: remember for each activity". Apparently this is not the default.

I re-checked that on Plasma 5.18 in Kubuntu 20.04, and Plasma 5.21 in Kubuntu 21.04, "remember for each activity" works for X11 and doesn't work for Wayland.
Comment 6 Oded Arbel 2021-09-26 21:17:25 UTC
Apparently the problem on X11 is that the Activity Manager service plugin "org.kde.ActivityManager.VirtualDesktopSwitch" wasn't loaded for some reason and executing `qdbus org.kde.ActivityManager /MainApplication org.kde.ActivityManager.Application.loadPlugin org.kde.ActivityManager.VirtualDesktopSwitch` solved the problem.

I'm not sure why it was not loaded, but I can see the following lines in the logs:

----8<----
Sep 26 21:08:31 vesho kactivitymanagerd[4524]: kf.coreaddons: Checking for plugins in ("/usr/lib/x86_64-linux-gnu/qt5/plugins/kactivitymanagerd/1", "/usr/lib/x86_64-linux-gnu/libexec/kactivitymanagerd/1")
Sep 26 21:08:31 vesho kactivitymanagerd[4524]: org.kde.kactivities.application: Plugin Name is  "org.kde.ActivityManager.ActivityRunner" "/usr/lib/x86_64-linux-gnu/qt5/plugins/kactivitymanagerd/1/kactivitymanagerd_plugin_activityrunner.so"
Sep 26 21:08:31 vesho kactivitymanagerd[4524]: org.kde.kactivities.application: Plugin Name is  "org.kde.ActivityManager.ActivityTemplates" "/usr/lib/x86_64-linux-gnu/qt5/plugins/kactivitymanagerd/1/kactivitymanagerd_plugin_activitytemplates.so"
Sep 26 21:08:31 vesho kactivitymanagerd[4524]: org.kde.kactivities.application: Plugin Name is  "org.kde.ActivityManager.EventSpy" "/usr/lib/x86_64-linux-gnu/qt5/plugins/kactivitymanagerd/1/kactivitymanagerd_plugin_eventspy.so"
Sep 26 21:08:31 vesho kactivitymanagerd[4524]: org.kde.kactivities.application: Plugin Name is  "org.kde.ActivityManager.GlobalShortcuts" "/usr/lib/x86_64-linux-gnu/qt5/plugins/kactivitymanagerd/1/kactivitymanagerd_plugin_globalshortcuts.so"
Sep 26 21:08:31 vesho kactivitymanagerd[4524]: org.kde.kactivities.application: Plugin Name is  "org.kde.ActivityManager.GtkEventSpy" "/usr/lib/x86_64-linux-gnu/qt5/plugins/kactivitymanagerd/1/kactivitymanagerd_plugin_gtk_eventspy.so"
Sep 26 21:08:31 vesho kactivitymanagerd[4524]: org.kde.kactivities.application: Plugin Name is  "org.kde.ActivityManager.RunApplication" "/usr/lib/x86_64-linux-gnu/qt5/plugins/kactivitymanagerd/1/kactivitymanagerd_plugin_runapplication.so"
Sep 26 21:08:31 vesho kactivitymanagerd[4524]: org.kde.kactivities.application: Plugin Name is  "org.kde.ActivityManager.SLC" "/usr/lib/x86_64-linux-gnu/qt5/plugins/kactivitymanagerd/1/kactivitymanagerd_plugin_slc.so"
Sep 26 21:08:31 vesho kactivitymanagerd[4524]: org.kde.kactivities.application: Plugin Name is  "org.kde.ActivityManager.ResourceScoring" "/usr/lib/x86_64-linux-gnu/qt5/plugins/kactivitymanagerd/1/kactivitymanagerd_plugin_sqlite.so"
Sep 26 21:08:31 vesho kactivitymanagerd[4524]: org.kde.kactivities.application: Plugin Name is  "org.kde.ActivityManager.VirtualDesktopSwitch" "/usr/lib/x86_64-linux-gnu/qt5/plugins/kactivitymanagerd/1/kactivitymanagerd_plugin_virtualdesktopswitch.so"
Sep 26 21:08:31 vesho kactivitymanagerd[4524]: org.kde.kactivities.application: Found 8 enabled plugins:
Sep 26 21:08:31 vesho kactivitymanagerd[4524]: org.kde.kactivities.application: Setting the name of  0x558b20255aa0  to  "org.kde.ActivityManager.ActivityRunner"
Sep 26 21:08:31 vesho kactivitymanagerd[4524]: org.kde.kactivities.application: [   OK   ] loaded:   "org.kde.ActivityManager.ActivityRunner"
Sep 26 21:08:31 vesho kactivitymanagerd[4524]: org.kde.kactivities.application: Setting the name of  0x558b2022bed0  to  "org.kde.ActivityManager.ActivityTemplates"
Sep 26 21:08:31 vesho kactivitymanagerd[4524]: org.kde.kactivities.application: [   OK   ] loaded:   "org.kde.ActivityManager.ActivityTemplates"
Sep 26 21:08:31 vesho kactivitymanagerd[4524]: org.kde.kactivities.application: [   OK   ] loaded:   "org.kde.ActivityManager.EventSpy"
Sep 26 21:08:31 vesho kactivitymanagerd[4524]: org.kde.kactivities.application: [   OK   ] loaded:   "org.kde.ActivityManager.GlobalShortcuts"
Sep 26 21:08:31 vesho kactivitymanagerd[4524]: org.kde.kactivities.application: [   OK   ] loaded:   "org.kde.ActivityManager.GtkEventSpy"
Sep 26 21:08:31 vesho kactivitymanagerd[4524]: org.kde.kactivities.application: Setting the name of  0x558b2029a190  to  "org.kde.ActivityManager.RunApplication"
Sep 26 21:08:31 vesho kactivitymanagerd[4524]: org.kde.kactivities.application: [   OK   ] loaded:   "org.kde.ActivityManager.RunApplication"
Sep 26 21:08:31 vesho kactivitymanagerd[4524]: org.kde.kactivities.application: [   OK   ] loaded:   "org.kde.ActivityManager.SLC"
Sep 26 21:08:31 vesho kactivitymanagerd[4524]: org.kde.kactivities.application: Setting the name of  0x558b20257a80  to  "org.kde.ActivityManager.Resources.Scoring"
Sep 26 21:08:31 vesho kactivitymanagerd[4524]: org.kde.kactivities.resources: Marking the test backup as working...
Sep 26 21:08:31 vesho kactivitymanagerd[4524]: org.kde.kactivities.resources: Creating the backup of the current database...
Sep 26 21:08:32 vesho kactivitymanagerd[4524]: org.kde.kactivities.resources: KActivities: Database connection:  "kactivities_db_resources_140641042691200_readwrite" 
                                                   query_only:          QVariant(qlonglong, 0) 
                                                   journal_mode:        QVariant(QString, "wal") 
                                                   wal_autocheckpoint:  QVariant(qlonglong, 100) 
                                                   synchronous:         QVariant(qlonglong, 1)
Sep 26 21:08:32 vesho kactivitymanagerd[4524]: org.kde.kactivities.resources: Database opened successfully
Sep 26 21:08:32 vesho kactivitymanagerd[4524]: org.kde.kactivities.application: [   OK   ] loaded:   "org.kde.ActivityManager.ResourceScoring"
----8<----

So 9 plugins where detected but only 8 were enabled. The setting System Settings -> Workspace Behavior -> Activities -> Switching -> "Remember for each activity" was checked, and `~/.config/kactivitymanagerdrc` had `org.kde.ActivityManager.VirtualDesktopSwitchEnabled=true`, so I'm unsure as to why it failed.

After logging in and out, the plugin appears to stick - it gets loaded and virtual desktop switching works again.
Comment 7 Oded Arbel 2021-09-26 21:25:16 UTC
With all the plugins loaded, the Wayland work in https://invent.kde.org/plasma/kactivitymanagerd/-/merge_requests/16 - for Plasma 5.23 - also appears to be working well, so the "remember for each activity" setting does now work for Wayland.

That MR was merged at the beginning of the month, so it stands to reason it didn't work when this ticket was first opened - thank you David Redondo and David Edmundson!

*** This bug has been marked as a duplicate of bug 439183 ***