After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 135056 - Alt-Tab doesn't work during drag-and-drop (nor does workspace switch, etc.)
Alt-Tab doesn't work during drag-and-drop (nor does workspace switch, etc.)
Status: RESOLVED FIXED
Product: metacity
Classification: Other
Component: general
2.4.x
Other Linux
: High normal
: ---
Assigned To: Metacity maintainers list
Metacity maintainers list
: 145329 325943 340792 343422 373077 380783 476956 525556 (view as bug list)
Depends on:
Blocks: 96743 155451 344059 659609
 
 
Reported: 2004-02-21 18:01 UTC by Steve McKay
Modified: 2014-06-04 06:54 UTC
See Also:
GNOME target: ---
GNOME version: 2.23/2.24


Attachments
(trivial) patch for bug #135056 (408 bytes, patch)
2008-04-25 02:31 UTC, Santanu Chatterjee
reviewed Details | Review
allow keyboard ops to work without a pointer grab (488 bytes, patch)
2009-06-08 02:13 UTC, Matthias Clasen
committed Details | Review
Allow keyboard ops to work without a pointer grab (895 bytes, patch)
2011-10-01 07:01 UTC, drago01
none Details | Review

Description Steve McKay 2004-02-21 18:01:08 UTC
Alt-Tab functionality is not available while dragging a file from a
nautilus window. My expectation is that I would be able to start a drag
operation, bring the drop target window to the front using alt-tab, then
drop the file into the target window. What actually happens is that during
a drag operation metacity's window switcher dialog does not appear when
alt-tab is pressed.
Comment 1 Ben FrantzDale 2004-02-23 05:38:36 UTC
Similarly, you can't use a key combo to switch desktops.
Comment 2 Rob Adams 2004-02-28 16:30:46 UTC
I don't think that it's possible to fix this without some sort of
really complicated window manager protocol, since in dnd the window
has a grab.
Comment 3 James Ascroft-Leigh 2004-04-26 18:42:18 UTC
I find myself dreading the use of drag and drop between windows because of these
two issues.  Personally I do not have a "Window List" utility on my only panel.
 Instead I prefer to use many workspaces to avoid minimising things, Alt+Tab to
switch windows if they get covered and a nice small "Window Selector" utility
for the rare minimised windows.

Thus if I need to drag and drop between windows I think I need to first make
sure that the windows are both on the same workspace and the target area needs
to be visible even when the source window is on top.  This normally means
unmaximising and shuffling windows to prepare for a drag and drop operation.

Alt-Tab would be useful as would handling drag and drop with the "Window
Selector" in the same way as with the "Window List".  I don't have enough hands
to use Ctrl+Alt+{Up,Down,Left,Right} to switch workspaces while dragging but
dragging onto the "Workspace Switcher" utility to cause a workspace switch would
be great.
Comment 4 Rob Adams 2004-07-02 21:54:50 UTC
*** Bug 145329 has been marked as a duplicate of this bug. ***
Comment 5 Elijah Newren 2006-01-06 05:45:43 UTC
*** Bug 325943 has been marked as a duplicate of this bug. ***
Comment 6 Sergej Kotliar 2006-05-06 08:57:20 UTC
*** Bug 340792 has been marked as a duplicate of this bug. ***
Comment 7 Cos Costa 2006-05-15 21:44:43 UTC
Looking for that Alt+Tab switch while dragndrop in gnome @ least since 2.10. It's keeping me kind of unsatisfied with gnome while the other desktops (kde, osx, xp) support that semi-standard functionality. 
Ppl I showed linux with gnome as desktop (yes I do linux-promotion in my neighbourhood) are pretty quickly coming back to the point of asking why that function is not available. So as I know about the drag over windows list till window pops up, I tell them this as a workaround. But its not really the same handy and quick as a real Alt+Tab Window switch to bring the desired app to the foreground.

Just wanted to point out that pretty old bug/missing feature, telling that there is quite some ppl looking out for it, on that great desktop.
Comment 8 Elijah Newren 2006-05-30 18:32:12 UTC
*** Bug 343422 has been marked as a duplicate of this bug. ***
Comment 9 Vitaliy Ischenko 2006-11-09 19:17:11 UTC
It Is wery usefull thing
Is there any chance, that we will see this feature in nearest future?
Comment 10 Elijah Newren 2006-11-10 01:23:57 UTC
*** Bug 373077 has been marked as a duplicate of this bug. ***
Comment 11 Fabio Bonelli 2006-11-30 19:44:39 UTC
*** Bug 380783 has been marked as a duplicate of this bug. ***
Comment 12 Yevgen Muntyan 2007-01-04 03:34:26 UTC
See http://bugzilla.gnome.org/show_bug.cgi?id=390312 for gtk side of this problem. GTK grabs keyboard at the moment but that can be fixed. QT applications do not grab keyboard on DND right now if you need to test it without newest patched GTK.
Comment 13 Yevgen Muntyan 2007-04-12 23:26:20 UTC
I'd think gtk bug blocks fixing this one, not vice versa. Gtk could be fixed right now, without waiting for metacity.
Comment 14 Elijah Newren 2007-04-12 23:32:25 UTC
I marked this as blocking another metacity bug, not the gtk bug.  ;-)
Comment 15 Yevgen Muntyan 2007-04-12 23:52:38 UTC
Sorry, paranoia. For some reason I decided the email from bugzilla was about gtk bug.
Comment 16 Vincent Untz 2007-09-14 16:15:00 UTC
*** Bug 476956 has been marked as a duplicate of this bug. ***
Comment 17 Valent Turkovic 2008-01-27 17:38:38 UTC
Is it possible to fix this now? Sorry for a lame question :)
I'm just a gnome user.
Comment 18 Thomas Thurman 2008-04-01 14:46:53 UTC
*** Bug 525556 has been marked as a duplicate of this bug. ***
Comment 19 André Klapper 2008-04-03 12:58:07 UTC
@thomas: i don't consider this as a 2.24 blocker, we have all survived this bug for the last years... feel free to set a target milestone instead.
Comment 20 Santanu Chatterjee 2008-04-09 14:11:47 UTC
I am quite fed up with this problem, and I doubt whether anybody is
willing to fix this... dunno why... this does seem like a pretty big
usability problem to me. 

I want to fix this. But the problem is I have no experience at all
in any kind of open source project, let alone GNOME. But I know C,
and some Python. No GUI programming experience.

If you think that it is possible for me to fix this and if anyone 
is willing to volunteer to do some initial handholding, I can
try to fix this thing. I can devote around 3-4 hours every Saturday
for this purpose. If any of you is willing to help me, please
let me know.

This bug is bugging me for quite sometime now...
Comment 21 Thomas Thurman 2008-04-09 14:23:26 UTC
Santanu:

It is actually on my priority list, but there's a lot of other things on the list above it.  (There's basically just me and Elijah actively fixing Metacity at present, and Elijah's very busy on other projects too.)

I would be delighted if you could do some work on this bug!  I will try to put together a list of likely places that need investigating and append it here; most Saturdays I could spare the 3-4 hours to talk it over in real time, but we have house guests this weekend.  What time zone are you in?

In the meantime, take a look at the code overview and the other files in the "doc" directory, and get a feel for how the code is laid out.  Some of those files may be a bit out of date, but they give the right sort of idea.

Thanks again.
Comment 22 Santanu Chatterjee 2008-04-10 15:46:01 UTC
Thomas:

Thanks for offering to help me with this.
I would really like to help in any way possible to fix this bug.

I am in India, so time zone is IST (+5:30hrs). I can start from 
next Saturday (19th April). For this purpose I have to come to
the university on Saturday (since I have no net connectivity
where I stay). I can be present for discussing with you anytime 
from 11:00am to 8:00pm IST. Please let me know if you can be online
during any portion of this time. I don't know whether IRC chat
would be possible (since we are behind proxy that blocks
everything except http and https)... maybe gmail!

Anyways, in the meantime, I will download the Metacity code and
go through the relevant portions you mentioned.

Comment 23 Thomas Thurman 2008-04-10 16:13:39 UTC
That's wonderful (but don't come on this Saturday, the twelfth, if you want to talk to me, because we have house guests and I'll be busy all day).  I am in Philadelphia at the moment, which is -5:00hrs.

I am on gmail, yes: I'm marnanel @ gmail.

I wish universities wouldn't block things like IRC :( I learned more from IRC when I was a student than from many of my classes.
Comment 24 Santanu Chatterjee 2008-04-25 02:31:41 UTC
Created attachment 109876 [details] [review]
(trivial) patch for bug #135056

I am attaching my (trivial) patch for this bug.

After applying this patch:

1. One can open two nautilus windows (probably in
   such a way that they completely cover each other),
   and then click on a selection in one of the windows
   and (without releasing the mouse button, and without
   starting a drag operation), use Alt+Tab to switch to
   the other nautilus window (or any other relevant 
   window which can accept the selection) and then drag
   and drop it there.

2. If one is using any non gtk application, then one can
   start a drag operation in one window, use Alt+Tab to
   switch to a different window and drop it there.
   I have only tried it on two dolphin (the KDE file manager)
   windows on my system.

   (Using keyboard shortcuts to switch to a different workspace
   while dragging a selection on one window and then dropping
   the selection to another window on the other workspace has 
   always been possible if the window concerned are not gtk
   based.)
Comment 25 Thomas Thurman 2008-04-28 00:16:59 UTC
Hm, I think it's an improvement, certainly.  But what's stopping us grabbing during drag-and-drop operations with GTK apps that *isn't* with non-GTK apps?
Comment 26 Santanu Chatterjee 2008-04-28 02:38:27 UTC
Thurman:

I believe this is somewhow related to the gtk 
bug #390312 (comment #12). I think that metacity is
not getting any information about the keyboard events
occuring within the frame where DND has been started.
Anyway, I should not say much without proof. 

I will try to find that out using meta_warning in
a few days and post here.
Comment 27 Santanu Chatterjee 2008-05-03 06:17:42 UTC
I did some work regarding the above (comment #26 ), but the
details are a bit long. So, I posted them at 
http://paste.ubuntu.com/9691/

Do let me know if my method seems wrong.
Also let me know if I should be posting such comments here
in the future.


Comment 28 Valent Turkovic 2008-06-04 07:20:04 UTC
Can this be fixed in Gnome 2.22.x update or are we waiting for some new gnome release?
Comment 29 Thomas Thurman 2008-07-20 22:04:46 UTC
Santanu: I think it would have been quite appropriate to post that as a comment here.  I'll save you posting it again:

---------------

Since this post is going to be a bit long, I don't know
whether I should be posting this as a bugzilla comment. So, I am pasting
here. If you think I should be posting this as a comment
at bugzilla, do let me know. Anyways, here goes...

While trying to find out why during drag operations on GTK based apps
all keyboard operations fail, I decided to follow two approaches, both
using my patched
(http://bugzilla.gnome.org/attachment.cgi?id=109876&action=view)
version of metacity.

Approach#1:
===========

I modified the display.c file to put the following lines at the start
of the event_callback function:

---------------------
if (grab_op_is_keyboard(display->grab_op))
   {
     meta_warning("SANTANU: KEYBOARD OPERATION RECEIVED\n");
   }
---------------------

Then I compiled and started this version of metacity.  After that I
started a nautilus window (a GTK based app), and a dolphin window
(representing a non-GTK app).

Then after starting a drag operation on a selection inside the
nautilus window, I pressed Alt+Tab. No output from the meta_warning
line. From this I conclude (correctly?) that metacity is not getting
that event information.

Next I did the same thing inside the dolphin window, and once I
pressed Alt+Tab while dragging, I got a number of meta_warning
messages from my introduced line.

My conclusion: In case of GTK apps, metacity is not getting any
keyboard events while dragging inside a GTK app.

Approach#2:
===========

I started a nautilus window, collected its window id using xwininfo,
and started xev to monitor this window. I noticed that As soon as I
start a drag operation on a selection, I get a FocusOut event, and no
event information (even if I drag the selection to a different window,
I don't get a LeaveNotify event) via any keyboard combinations like
Alt+Tab until I end the drag operation, when I get a FocusIn event
information (probably bacause I ended the operation in the same
window where I started it).

When I do the same in a dolphin window, while starting a drag
operation, I do not get any FocusOut event. And while the drag
operation is in progress, if I press any key (not even a combination
such as ALt+Tab), I get this type of information from xev:

--------------------
PropertyNotify event, serial 16, synthetic NO, window 0xa00007,
   atom 0xfb (_NET_WM_USER_TIME), time 2553106035, state PropertyNewValue
--------------------

I get the FocusOut event only when I use something like Alt+Tab that
causes the focus to shift to a different entity on the display.

My Conclusion: Same as above (in Approach#1). Something is probably
wrong in GTK's implementation of DND for which metacity, compiz, xfwm,
etc. are having this unexpected DND/Alt+Tab behavior.

But this is just my inexperienced conclusion. Please let me know if
there is something wrong with my approach. I am not not even sure at
this moment what exactly is meant by things like PropertyNotify event,
but I can somewhat guess what FocusOut event means.
Comment 30 Santanu Chatterjee 2008-07-30 13:53:44 UTC
Thomas: Thanks.
Comment 31 Havoc Pennington 2008-07-31 00:31:53 UTC
The patch here doesn't look OK to me; if you pop up alt+tab without a grab, there's no guarantee afaik you'll ever get any of the events that pop it down again. So the alt+tab mode can get "stuck"

There's a reason for the grabbing, it isn't just there for no reason ;-)
Comment 32 Matthias Clasen 2009-06-08 02:13:45 UTC
Created attachment 136114 [details] [review]
allow keyboard ops to work without a pointer grab
Comment 33 Matthias Clasen 2009-06-08 02:15:34 UTC
Here is a minimally-invasive patch that makes dnd and workspace-switching / focus-cycling work together. It still tries to get a pointer grab, but allows keyboard ops to proceed without one. This has been tested to work with a corresponding change to make GTK+ use passive key grabs for its keynav needs during dnd.
Comment 34 Thomas Thurman 2009-07-09 16:35:46 UTC
Matthias: I'm trying to test this patch.  Is it supposed to make alt-tab work during drag-and-drop?  It doesn't seem to.
Comment 35 Matthias Clasen 2009-07-09 17:11:09 UTC
Yes, it works here.

Start a drag, press alt-tab to bring the window up front that you want to drop in, then drop.

You need GTK+ 2.17.2 at least, I guess.
Comment 36 Christian Neumair 2009-08-07 11:16:20 UTC
Ping. If this patch works and has been reviewed, couldn't it be merged to master and stable?
Comment 37 Matthias Clasen 2009-08-07 12:50:26 UTC
We are shipping it in Fedora and it works fine as far as I can tell.
Comment 38 Sense Hofstede 2009-12-17 12:38:39 UTC
This has also been reported on Launchpad in Ubuntu at <https://launchpad.net/bugs/488139>.
What are the thoughts of the maintainers on the patch that Fedora is shipping?
Comment 39 Martin Mai 2010-04-23 14:55:34 UTC
I can confirm that this patch works great. The only small thing that might me considered is that the drag'n'drop process will think that you are holding down [ALT] if you don't move the pointer after you have switched windows with [ALT] + [TAB] (Yes, I released both keys).
Comment 40 drago01 2011-10-01 07:01:29 UTC
Created attachment 197940 [details] [review]
Allow keyboard ops to work without a pointer grab
Comment 41 drago01 2011-10-01 07:03:20 UTC
Comment on attachment 197940 [details] [review]
Allow keyboard ops to work without a pointer grab

Wrong bug.
Comment 42 Dominique Leuenberger 2012-08-06 18:55:25 UTC
So, we're talking about a 8 year old bug here...

In plus, the bug has a patch attached (for more than 3 years)

The patch is shipped by major distros:
- Fedora
- openSUSE
- Ubuntu

Wouldn't it be time to just merge the patch then, and allow downstreams to drop it in their packages?
Comment 43 Nelson Benitez 2013-07-24 11:43:12 UTC
This patch is included[1] in mutter (the successor of metacity), I tried it on fedora 19 and it's working fine (I dragged text from gedit to nautilus via ALT+TAB). 

So it would be cool if someone could commit it to metacity as well to close this bug.

[1] https://git.gnome.org/browse/mutter/tree/src/core/display.c#n4138
Comment 44 Alberts Muktupāvels 2014-06-04 06:54:13 UTC
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.