internal bool DoDragMotion(Gdk.DragContext context, int x, int y, uint time) { DragDropInfo.LastDragPosition = new Point(x, y); DragDropAction ac; if ((enabledEvents & WidgetEvent.DragOverCheck) == 0) { if ((enabledEvents & WidgetEvent.DragOver) != 0) { ac = DragDropAction.Default; } else { ac = ConvertDragAction(DragDropInfo.DestDragAction); } } else { // This is a workaround to what seems to be a mac gtk bug. // Suggested action is set to all when no control key is pressed var cact = ConvertDragAction(context.Actions); if (cact == DragDropAction.All) { cact = DragDropAction.Move; } var target = Gtk.Drag.DestFindTarget(EventsRootWidget, context, null); var targetTypes = Util.GetDragTypes(new Gdk.Atom[] { target }); DragOverCheckEventArgs da = new DragOverCheckEventArgs(new Point(x, y), targetTypes, cact); ApplicationContext.InvokeUserCode(delegate { EventSink.OnDragOverCheck(da); }); ac = da.AllowedAction; if ((enabledEvents & WidgetEvent.DragOver) == 0 && ac == DragDropAction.Default) { ac = DragDropAction.None; } } if (ac == DragDropAction.None) { OnSetDragStatus(context, x, y, time, (Gdk.DragAction) 0); return(true); } else if (ac == DragDropAction.Default) { // Undefined, we need more data QueryDragData(context, time, true); return(true); } else { // Gtk.Drag.Highlight (Widget); OnSetDragStatus(context, x, y, time, ConvertDragAction(ac)); return(true); } }
internal bool DoDragDrop(Gdk.DragContext context, int x, int y, uint time) { DragDropInfo.LastDragPosition = new Point(x, y); var cda = ConvertDragAction(context.Action); DragDropResult res; if ((enabledEvents & WidgetEvent.DragDropCheck) == 0) { if ((enabledEvents & WidgetEvent.DragDrop) != 0) { res = DragDropResult.None; } else { res = DragDropResult.Canceled; } } else { DragCheckEventArgs da = new DragCheckEventArgs(new Point(x, y), Util.GetDragTypes(context.Targets), cda); ApplicationContext.InvokeUserCode(delegate { EventSink.OnDragDropCheck(da); }); res = da.Result; if ((enabledEvents & WidgetEvent.DragDrop) == 0 && res == DragDropResult.None) { res = DragDropResult.Canceled; } } if (res == DragDropResult.Canceled) { Gtk.Drag.Finish(context, false, false, time); return(true); } else if (res == DragDropResult.Success) { Gtk.Drag.Finish(context, true, cda == DragDropAction.Move, time); return(true); } else { // Undefined, we need more data QueryDragData(context, time, false); return(true); } }
void HandleWidgetDragDrop(object o, Gtk.DragDropArgs args) { lastDragPosition = new Point(args.X, args.Y); var cda = ConvertDragAction(args.Context.Action); DragDropResult res; if (!dropCheckEventEnabled) { if (dropEventEnabled) { res = DragDropResult.None; } else { res = DragDropResult.Canceled; } } else { DragCheckEventArgs da = new DragCheckEventArgs(new Point(args.X, args.Y), Util.GetDragTypes(args.Context.Targets), cda); EventSink.OnDragDropCheck(da); res = da.Result; if (!dropEventEnabled && res == DragDropResult.None) { res = DragDropResult.Canceled; } } if (res == DragDropResult.Canceled) { args.RetVal = true; Gtk.Drag.Finish(args.Context, false, false, args.Time); } else if (res == DragDropResult.Success) { args.RetVal = true; Gtk.Drag.Finish(args.Context, true, cda == DragDropAction.Move, args.Time); } else { // Undefined, we need more data args.RetVal = true; QueryDragData(args.Context, args.Time, false); } }
void HandleWidgetDragMotion(object o, Gtk.DragMotionArgs args) { lastDragPosition = new Point(args.X, args.Y); DragDropAction ac; if (!dragMotionCheckEventEnabled) { if (dragMotionEventEnabled) { ac = DragDropAction.Default; } else { ac = ConvertDragAction(destDragAction); } } else { DragOverCheckEventArgs da = new DragOverCheckEventArgs(new Point(args.X, args.Y), Util.GetDragTypes(args.Context.Targets), ConvertDragAction(args.Context.Actions)); EventSink.OnDragOverCheck(da); ac = da.AllowedAction; if (!dragMotionEventEnabled && ac == DragDropAction.Default) { ac = DragDropAction.None; } } if (ac == DragDropAction.None) { args.RetVal = false; } else if (ac == DragDropAction.Default) { // Undefined, we need more data args.RetVal = true; QueryDragData(args.Context, args.Time, true); } else { // Gtk.Drag.Highlight (Widget); args.RetVal = true; Gdk.Drag.Status(args.Context, ConvertDragAction(ac), args.Time); } }