[Task Manager] When closing apps, resize only when mouse is out.
ClosedPublic

Authored by thsurrel on Jan 21 2019, 9:17 PM.

Details

Summary

When closing several apps from the task manager with the mouse
middle button, it is convenient that the remaining tasks are not
resized so that you don't need to move your mouse to target the
next app you intend to close. The tasks will be resized when the
mouse is moved out of the task manager.
This mimics the behavior of tabs in Firefox or Chrome.

Test Plan

With the task manager configured without grouping, open several
applications so that the tasks displayed in the task manager get
smaller to fit in the available space. Now close the last three
for example: you should be able to do so without having to move
your mouse.

Diff Detail

Repository
R119 Plasma Desktop
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
thsurrel created this revision.Jan 21 2019, 9:17 PM
Restricted Application added a project: Plasma. · View Herald TranscriptJan 21 2019, 9:17 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
thsurrel requested review of this revision.Jan 21 2019, 9:17 PM
thsurrel edited the summary of this revision. (Show Details)Jan 21 2019, 9:28 PM
hein accepted this revision.Jan 24 2019, 1:10 PM
hein added a subscriber: hein.

I like the idea. The Firefox implementation is smart enough not to do it when a tab is closed by means other than direct user mouse interaction though.

This revision is now accepted and ready to land.Jan 24 2019, 1:10 PM
thsurrel updated this revision to Diff 50196.Jan 24 2019, 3:51 PM

Let's be as smart as Firefox!
Thanks for the review

hein added a comment.Jan 25 2019, 10:23 AM

I think it needs to be made a bit more robust still. For one it's not called requestClose() without reason: Not all windows are closable / will be closed upon this request. It might also race with a different window closing going on in parallel. taskClosedWithMouseMiddleButton needs to be invalidated on exit, and the middle-click close and onItemRemoved probably need to compare persistent model indexes or window ids (easier) to check it's the same.

thsurrel updated this revision to Diff 50291.EditedJan 25 2019, 9:05 PM

Improvements as per @hein comments
Keep resizing if the task being closed with the middle button is
the last one in the task manager. That matches Firefox behavior.

Thanks again for the fast reviews.

hein added inline comments.Jan 26 2019, 7:37 AM
applets/taskmanager/package/contents/ui/Task.qml
156

Getting close, but pid is not reliable. It's not available for all tasks (e.g. remote X11 clients). You need to use the window id role instead.

thsurrel added inline comments.Feb 1 2019, 8:17 PM
applets/taskmanager/package/contents/ui/Task.qml
156

I do not find a window id role, maybe I am not looking in the right place. Could you please provide so more guidance ?
And sorry for the late reply.

Hi @hein, could you help me finish this patch ? Can you have a look at my previous question ? Many thanks in advance.

hein added a comment.Mar 4 2019, 10:54 AM

Sorry for the late reply, too.

The role is WinIdList.

hein requested changes to this revision.Mar 4 2019, 10:58 AM
This revision now requires changes to proceed.Mar 4 2019, 10:58 AM
thsurrel updated this revision to Diff 53240.Mar 5 2019, 9:00 PM

Use the WinIdList role

hein requested changes to this revision.Mar 7 2019, 6:10 PM

Almost! This is not going to work reliably for groups, because the order in which their children are deleted is up to the client processes. That means once a group goes from two to one and morphs into a regular task item, the window id it has might not match the winIdList[0] you previously recorded. Instead, you should store the entire winIdList, and when an item is removed check whether it's winIdList[0] is in the list you saved away. You also need to do a bounds check before you access [0] though because not every task has a window id (e.g. launchers and startup notifications), so you're causing errors ATM.

This revision now requires changes to proceed.Mar 7 2019, 6:10 PM
thsurrel updated this revision to Diff 53394.Mar 7 2019, 8:41 PM

Fix code for groups and WinId-less tasks.

Thank you so much for your patient reviews!

As a side note, I noticed something a bit odd while testing: if the task manager is configured with grouping, and you open a bunch of Kate instances and close them all at once by middle-clicking on the "grouped task", then it takes more and more time for each instance of Kate to close. Closing 9 instances of Kate, the last one is closing about 7 seconds after the 8th... Can you reproduce that ? I don't think it is a task manager issue, though, as I cannot reproduce that with other applications.

Ping
Does this seem better now, @hein ?

hein accepted this revision.Mar 17 2019, 4:29 PM

Looks good now!

Do you need help landing this or do you have a dev account?

This revision is now accepted and ready to land.Mar 17 2019, 4:29 PM

I can land this myself.
Thank you again for all your help.

This revision was automatically updated to reflect the committed changes.