Abort drag-and-drop from a busy program

7

1

When the following happens:

  1. I start a drag-and-drop operation, starting from application ABC.
  2. Application ABC locks up (temporarily)
  3. I release the mouse button

then, until application ABC finishes processing, I have the following problems:

  • Other programs cannot "grab" the mouse pointer
  • The drag-and-drop cursor remains active
  • I cannot click anything
  • I cannot open the gnome-panel or GNOME menu
  • I cannot press certain keys (including space, enter, arrow keys)

Obviously, I then cannot do other work while waiting for the application to finish.

A situation when this occurs is when I have ~500 firefox tabs open, when dragging tabs it sometimes freezes for half an hour or so.

A workaround is to use a terminal by pressing Ctrl-Alt-F1, log in, run killall ABC to kill the offending application, and press Ctrl-Alt-F7 to get back to the graphical environment. But I would rather not have to kill ABC, instead letting it finish processing, while getting my mouse back.

So, is it possible to forcibly abort a drag-and-drop / un-grab the mouse pointer from a busy program, without killing the process?

Mechanical snail

Posted 2011-08-22T00:04:04.967

Reputation: 6 625

1My bet is that doing this as you're asking would require some programming alterations to gnome. But indeed, I'd like to know myself. I too am a connoisseur of Firefox abuse. (+1) – James T Snell – 2011-08-29T16:40:44.220

@Doc: I installed an extension to count them. Currently I have 1295 tabs open. (Of course the issue isn't specific to Firefox.) – Mechanical snail – 2011-08-29T23:36:15.063

1+1 this doesn't only happen with firefox, I experienced this with totem quite a few times. – Jens Mühlenhoff – 2012-02-26T10:47:29.183

3Can't you just abort the drag-and-drop by pressing ESC before releasing the mouse button? – mins – 2012-01-11T22:37:36.830

In my case this doesn't help. – Jens Mühlenhoff – 2012-02-26T10:48:22.023

Answers

6

In fact, it is possible to do this (at least with recent versions of X).

You can do this by pressing the XF86Ungrab key, introduced in this commit.

By default, this keysym is not bound to any physical key or key combination (it was disabled in 2012 after it was reported as a security hole, since it allows anyone to bypass lock screens by breaking their grabs). On some other setups it is bound to a shortcut that uses the number pad. Obviously, that won't work on laptops that lack a keypad.

But you can still activate the keysym using xdotool:

setxkbmap -option grab:break_actions
xdotool key XF86Ungrab

This works with X.org version 2:1.11.4-0ubuntu10.8 on Ubuntu Precise.

Mechanical snail

Posted 2011-08-22T00:04:04.967

Reputation: 6 625

1

In most operating systems or window systems you can abort a mouse drag handler by pressing the Escape button. And sometimes you can cancel the even by finding or using a "drag cancel" target like Mac os's top menu. For example in most Windows you will notice cursor changes to circle with line through it, like a classic No Smoking sign or No Diving type of sign in the real world ;)

In the case of OP, they are using GNOME / Firefox:

In Gnome, in most cases hitting escape key before letting go of mouse button will (should) cancel the drag/drop event. It is even part of their dev guidelines:

http://developer.gnome.org/hig-book/3.2/input-mouse.html.en#drag-drop-override

Allow all mouse operations to be cancelled before their completion. Pressing the Esc key should cancel any mouse operation in progress, such as dragging and dropping a file in a file manager, or drawing a shape in a drawing application.

and..

Allow the user to cancel a drag and drop operation by all of these methods:

  • pressing Esc before releasing the mouse button dropping the object
  • back on its original location performing a query drag and selecting
  • Cancel on the pop-up menu (see Section 10.1.3.1.2 ― Query Drag)
  • dropping the object on an invalid drop target.

I am sure it is the same in KDE from doing a few searches

On Mozilla dev's Drop Event

drop The drop event is fired on the element where the drop was occured at the end of the drag operation. A listener would be responsible for retrieving the data being dragged and inserting it at the drop location. This event will only fire if a drop is desired. It will not fire if the user cancelled the drag operation, for example by pressing the Escape key, or if the mouse button was released while the mouse was not over a valid drop target. For information about this, see Performing a Drop.

I never said this would work all the time in EVERY setup, for example I don't think this works on Ubuntu which is kind of lame. I remember the drag event abort working with the Escape key since in wondows since version 3.1.

In all MS Windows operating systems in almost all (properly coded) applications: - hitting the escape key before releasing the mouse button during a drag/drop mouse event will cancel/abort the handler function.

For example in Google Chrome on Windows7: - drag a tab off the toolbar as if you are going to detach it and before letting go, hit your keyboard Escape key. It should abort the drag and return your tab.

Anthony Hatzopoulos

Posted 2011-08-22T00:04:04.967

Reputation: 244

Really? I've never seen this, what are these operating systems? – terdon – 2012-08-26T18:30:24.507

What OSes/Window systems do you use? Have you tried it. Let me update my answer for you. – Anthony Hatzopoulos – 2012-08-27T01:56:39.257

Thanks for the detailed info @AnthonyHatzopoulos. I thought you meant that Esc could abort a drag and drop operation after the mouse has been released and the operation has begun. That is what the OP is asking for. Still, +1 for effort :) – terdon – 2012-08-27T10:40:54.093