Make drags from the Task Manager less prone to disaster
ClosedPublic

Authored by hein on Jun 1 2018, 8:59 PM.

Details

Summary

The Task Manager applet previously set a task's launcher URL as
generic URL MIME data of drags initiated from it. This made
everything that's willing to handle an URL drop a drop target
for drags from the Task Manager, which resulted e.g. in users
accidentally dropping .desktop files into chat apps that would
immediately send them as a message.

In truth, the utility of drags initiated from the Task Manager
is mostly confined to the shell: Adding apps to the desktop, to
the panel, to launcher menus (we don't have this currently but
should add it), and so on. It's therefore appropriate to use a
special internal MIME type for this payload instead of one as
generic as text/url. We already use special internal MIME types
to shuttle around window ids (for drops onto pagers, to assign
tasks to different virtual desktops or activities) and filter
out drops onto the Task Manager applet itself.

This patch makes the necessary changes in the Task Manager and
in the Folder View containment, which needs special care due to
its complex drop handling. A seperate patch will augment
ContainmentInterface::processMimeData to take care of the Desktop
and Panel containments (while compatible with the Folder View
change).

This is an implementation of an idea by David Edmundson posted
in D13162.

Diff Detail

Repository
R119 Plasma Desktop
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
hein created this revision.Jun 1 2018, 8:59 PM
Restricted Application added a project: Plasma. · View Herald TranscriptJun 1 2018, 8:59 PM
hein requested review of this revision.Jun 1 2018, 8:59 PM
zzag added a subscriber: zzag.Jun 1 2018, 10:50 PM
ngraham added a subscriber: ngraham.Jun 2 2018, 5:42 AM

The fact that TM entries are draggable outside their panel in the first place is a bit odd in many contexts because most of the time you're going to be looking at apps, not your desktop, and there's nothing you would actually want to or be able to drag them to. So when you accidentally initiate a drag, it will uselessly display the "nuh-uh, can't drag that here" icon most of the time. I kind of preferred one of the original patches from way back yonder that only made TM entries draggable outside their panel when widgets were unlocked (D8564: Disallow drop of task manager icons outside of plasmoid when widgets are locked).

But this implementation does fix the bug (speaking of which, let's add BUG: 390034), so +1 from me since it's an improvement over the current state of affairs and doesn't preclude alternative approaches in the future. Love the title too!

davidedmundson accepted this revision.Jun 2 2018, 4:51 PM

Title is a bit dramatic.

I would suggest master only given we need to ensure we we've updated everything

This revision is now accepted and ready to land.Jun 2 2018, 4:51 PM
hein added a comment.Jun 3 2018, 4:00 PM

Agreed on master-only.

The fact that TM entries are draggable outside their panel in the first place is a bit odd in many contexts because most of the time you're going to be looking at apps, not your desktop, and there's nothing you would actually want to or be able to drag them to.

I don't think this is odd at all. It's how desktop UIs work. I can also drag tabs from Firefox outside of Firefox, but I can't just drop them everywhere. Drags are globally modal in some sense, as are, say, context menus. There's no concept of "you can only drag within this area", generally, unless you go for cursor confinement, which has a host of other downsides.

It works the same in other desktop operating systems, e.g. in the Mac OS dock.

I kind of preferred one of the original patches from way back yonder that only made TM entries draggable outside their panel when widgets were unlocked (D8564: Disallow drop of task manager icons outside of plasmoid when widgets are locked).

This is not what the patch you like actually did. That patch disallowed dropping things outside the panel when it's locked, but it still, of course, allowed dragging them outside of the panel. It's basically the same as this, except that you need to unlock the panel to drop things on the desktop. I find that unnecessarily complicated and this works better.

This revision was automatically updated to reflect the committed changes.
In D13274#273076, @hein wrote:

This is not what the patch you like actually did. That patch disallowed dropping things outside the panel when it's locked, but it still, of course, allowed dragging them outside of the panel. It's basically the same as this, except that you need to unlock the panel to drop things on the desktop. I find that unnecessarily complicated and this works better.

Oops, my mistake. I guess that's what I wished it did! Either way, thanks for this. Should make folks happy.