private bool Accepting_HandlePositionEvent (ref XEvent xevent)
{
pos_x = (int) xevent.ClientMessageEvent.ptr3 >> 16;
pos_y = (int) xevent.ClientMessageEvent.ptr3 & 0xFFFF;
// Copy is implicitly allowed
Control source_control = MwfWindow (source);
if (source_control == null)
allowed = EffectsFromX11Source (source, xevent.ClientMessageEvent.ptr5) | DragDropEffects.Copy;
else
allowed = drag_data.AllowedEffects;
IntPtr parent, child, new_child, last_drop_child;
parent = XplatUIX11.XRootWindow (display, 0);
child = toplevel;
last_drop_child = IntPtr.Zero;
while (true) {
int xd, yd;
new_child = IntPtr.Zero;
if (!XplatUIX11.XTranslateCoordinates (display,
parent, child, pos_x, pos_y,
out xd, out yd, out new_child))
break;
if (new_child == IntPtr.Zero)
break;
child = new_child;
Hwnd h = Hwnd.ObjectFromHandle (child);
if (h != null) {
Control d = Control.FromHandle (h.client_window);
if (d != null && d.allow_drop)
last_drop_child = child;
}
}
if (last_drop_child != IntPtr.Zero)
child = last_drop_child;
if (target != child) {
// We have moved into a new control
// or into a control for the first time
Finish ();
}
target = child;
Hwnd hwnd = Hwnd.ObjectFromHandle (target);
if (hwnd == null)
return true;
Control c = Control.FromHandle (hwnd.client_window);
if (c == null)
return true;
if (!c.allow_drop) {
SendStatus (source, DragDropEffects.None);
Finish ();
return true;
}
control = c;
position_recieved = true;
if (converts_pending > 0)
return true;
if (!status_sent) {
drag_event = new DragEventArgs (data, 0, pos_x, pos_y,
allowed, DragDropEffects.None);
control.DndEnter (drag_event);
SendStatus (source, drag_event.Effect);
status_sent = true;
} else {
drag_event.x = pos_x;
drag_event.y = pos_y;
control.DndOver (drag_event);
SendStatus (source, drag_event.Effect);
}
return true;
}