Bug 437826

Summary: Moving a window to another activity via the task manager's context menu requires clicking activity twice
Product: [Plasma] plasmashell Reporter: bastimeyer123
Component: Task Manager and Icons-Only Task ManagerAssignee: Eike Hein <hein>
Status: RESOLVED DUPLICATE    
Severity: normal CC: g.guerin, nate, plasma-bugs
Priority: NOR Keywords: usability
Version: 5.21.5   
Target Milestone: 1.0   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description bastimeyer123 2021-05-29 12:33:16 UTC
SUMMARY
I have two desktop activities configured, a "default" one and a "work" one.

When trying to move a window between activities via the task manager's context menu, eg. while being on the "default" activity and clicking "Show in Activities" -> "work", I have to click the "work" activity twice in order for the window to be moved to the other activity.

After clicking the menu item of the other activity for the first time, it incorrectly selects "All Activities" for the application window, making it appear on all activities. When clicking on the other activity again, it correctly moves the window to the other activity.

This means that it's not possible to move a window from one activity to another without having it appear on all activities first and without clicking the other activity twice in the context menu.

STEPS TO REPRODUCE
1. Set up two activities, "one" and "two", and set the task manager to only show windows from the current activity
2. Open a window on activity "one"
3. Right-click the window's item in the task manager, click "Show in Activities" ("one" is selected) and click on "two"

OBSERVED RESULT
Window is now visible on both activities instead of just the activity "two". Also "All activities" is now selected in the context menu.

EXPECTED RESULT
Window should only be visible on activity "two" since I clicked on "two" and not on "All Activities"

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: Arch Linux
(available in About System)
KDE Plasma Version: 5.21.5
KDE Frameworks Version: 5.82.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
Comment 1 bastimeyer123 2021-05-29 14:32:45 UTC
After taking a look at the task manager's code, I just noticed that the activities list allows you to select multiple activities at once and when everything is selected, it shows "All Activities" being selected instead.
https://invent.kde.org/plasma/plasma-desktop/-/blob/7452d5c9bf6e1b39528284381f03df1605ab1151/applets/taskmanager/package/contents/ui/ContextMenu.qml#L446

This is very confusing if the user only has two activities set up and it makes the "All Activities" item redundant.

It would be much better if the activities list didn't allow for multiple selections when only two activities are set up, as you can see in my example above. With the current implementation, moving a window to a different activity requires two clicks whereas making it appear on all activities can already be accomplished by clicking the "All Activities" item/button.

I hope that makes sense.
Comment 2 Nate Graham 2021-06-08 20:52:42 UTC
Indeed, I agree.

Since yu're already digging in the code, would you like to submit a merge request to fix it? Probably not that hard.
Comment 3 bastimeyer123 2021-06-12 17:53:49 UTC
After upgrading to 5.22, the "All activities" button seems to be broken now, even though the taskmanager did not get changed according to the git history.

When I click on "All activities", the window doesn't appear on all activities and keeps being displayed only on the current one. The state of the button however changes correctly. Clicking the second activity (the "non-ideal" functionality) also works to make it appear on all activities.

The plasmoid is logging the following when clicking the "All activities" button which seems to be caused by passing `undefined` to `tasksModel.requestActivities` instead of an empty array:
> "Could not convert argument 1 at"
>          "@file:///usr/share/plasma/plasmoids/org.kde.plasma.taskmanager/contents/ui/ContextMenu.qml:425"
> "Passing incompatible arguments to C++ functions from JavaScript is dangerous and deprecated."
> "This will throw a JavaScript TypeError in future releases of Qt!"

According to `xprop`, the window's `_KDE_NET_WM_ACTIVITIES` property does have a value of "00000000-0000-0000-0000-000000000000", which should indicate that it should be displayed on all activities, but it's not.

----

> would you like to submit a merge request to fix it? Probably not that hard.

I'm not familiar with QML and Plasma internals, and apart from running `plasmawindowed /path/to/my/plasmoid-fork` and adding `console.log` statements, I don't know how to properly debug this, which is required for fixing what I have just described. I also can't find any automated tests, so I'm not sure if I'd break stuff with my changes before submitting a pull request.

This is the diff with my changes, but with the bug introduced in 5.22 it doesn't make sense for me to submit a pull request:
https://gist.githubusercontent.com/bastimeyer/8f9aef1aeb52e2ba8b785c11436b2c30/raw/ccfe9e0c1f8a4307b4ec4aa881e64089e0bbc0b2/changes.diff
Comment 4 Gauthier 2021-10-16 07:12:16 UTC
This is now solved with : https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/231

Scheduled for Plasma 5.24 (sad it got missed for 5.23).
Comment 5 Gauthier 2021-10-16 07:13:55 UTC

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