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 81543 - metacity crash when drag a String from qt apps.
metacity crash when drag a String from qt apps.
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: X11
unspecified
Other other
: Normal normal
: ---
Assigned To: gtk-bugs
Havoc Pennington
Depends on:
Blocks:
 
 
Reported: 2002-05-12 13:15 UTC by Young-Ho Cha
Modified: 2011-02-04 16:09 UTC
See Also:
GNOME target: ---
GNOME version: 2.0



Description Young-Ho Cha 2002-05-12 13:15:49 UTC
metacity crash when drag a String from qt apps to out of window. (I was
tested with kwrite(kde3), and aviplay(qt2))

dragging other object (directory, file) are fine.
Comment 1 Havoc Pennington 2002-05-12 14:49:17 UTC
The problem here is that in xdnd_enter_filter(), event->any.window 
is used; event->any.window is filled in by gdk_event_translate().
However, it can be filled in as NULL. In this
case, it's NULL because the window being entered is the client window 
that's the drag destination, which is not known to Metacity's instance 
of GDK so gdk_window_lookup() returns NULL.

A simple test case is to open kwrite, open gtk-demo, type 
some stuff in kwrite, select it, dnd selection to the gtk-demo, as
soon as you get an enter event on gtk-demo metacity will crash. Xnest
recommended. ;-)
Comment 2 Anders Carlsson 2002-05-12 17:41:45 UTC
Is changing the code to

GdkDisplay *display = gdk_x11_lookup_xdisplay (xevent->xany.display);
GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);

instead of having

GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (GDK_DRAWABLE_DISPLAY
(event->any.window));

an OK fix?
Comment 3 Havoc Pennington 2002-05-12 17:51:16 UTC
I'm testing with the regular branch, not the multihead branch. Both
probably need fixing in different ways.
Comment 4 Anders Carlsson 2002-05-12 17:56:01 UTC
I also had to add a NULL check in a call to gdk_window_ref. I can't
drag from a qt app to a gtk app and have it copy the text though
Comment 5 Owen Taylor 2002-05-12 18:49:05 UTC
Ugh, Qt must be calling XSendEvent() with a non-zero mask,
and then Metacity must be listening to whatever that mask
is on the toplevel window. (I 

The GDK code just needs to return if event->any.window is NULL
or it's a foreign window.

Clearly, metacity has no business interpreting DND events
destined for GTK+.

(I can't find any mention of the expected event_mask in the Xdnd 
spec, so can't prove that the Qt behavior is a bug in Qt, though
I'd consider it so.)
Comment 6 Matthias Clasen 2002-05-13 09:21:40 UTC
Looks like Xdnd must be amended to specify that client messages
must be send with an 
empty event mask in order to keep them from
propagating up to unsuspecting 
embedders like the wm.

Looking into this, I 
found:

/*************************************************************
 
* xdnd_send_xevent:
 *     Like gdk_send_event, but if the target is the root
 *     
window, sets an event mask of ButtonPressMask, otherwise
 *     an event mask of 0.
 *   
arguments:
 *     
 *   results:
 
*************************************************************/

Is this 
a leftover form pre-Xdnd-V4 days ? With XdndProxy, it should never be necessary to send 
client messages to the root window, should it ? I wonder who receives events sent to the 
root window with an empty event mask, though.  
Comment 7 Owen Taylor 2002-05-13 15:30:35 UTC
Yes, I believe this is a leftover from earlier versions of
the spec, or possibly a kfm compatibility hack. (Don't really
remember at this point.)

Nobody receives events sent to the root window with an
event_mask of 0.
Comment 8 Matthias Clasen 2002-05-14 09:59:41 UTC
Will you contact John Lindal about the event mask clarification in 
Xdnd ?
Comment 9 Owen Taylor 2002-06-13 19:43:13 UTC
Fixed:

Thu Jun 13 15:02:49 2002  Owen Taylor  <otaylor@redhat.com>

	* gdk/x11/gdkdnd-x11.c: Ignore all client events that
	were sent to a window that we don't know about or
	to a foreign window. (#81543, Young-Ho, Cha)

Sent a quick mail to John Lindal.