dnd: No longer allow passing -1

Nobody ever does that and special cases are evil.
This commit is contained in:
Benjamin Otte 2017-12-11 22:34:13 +01:00
parent 756b276070
commit 23c798b41d

View File

@ -973,6 +973,7 @@ gtk_drag_begin_internal (GtkWidget *widget,
int y) int y)
{ {
GtkDragSourceInfo *info; GtkDragSourceInfo *info;
GtkWidget *toplevel;
guint32 time = GDK_CURRENT_TIME; guint32 time = GDK_CURRENT_TIME;
GdkDragContext *context; GdkDragContext *context;
GtkWidget *ipc_widget; GtkWidget *ipc_widget;
@ -1009,40 +1010,15 @@ gtk_drag_begin_internal (GtkWidget *widget,
source_widgets = g_slist_prepend (source_widgets, ipc_widget); source_widgets = g_slist_prepend (source_widgets, ipc_widget);
if (x != -1 && y != -1) toplevel = gtk_widget_get_toplevel (widget);
{ gtk_widget_translate_coordinates (widget, toplevel,
GtkWidget *toplevel = gtk_widget_get_toplevel (widget); x, y, &x, &y);
gtk_widget_translate_coordinates (widget, toplevel, gdk_window_get_device_position (gtk_widget_get_window (toplevel),
x, y, &x, &y); pointer,
gdk_window_get_device_position (gtk_widget_get_window (toplevel), &dx, &dy,
pointer, NULL);
&dx, &dy, dx -= x;
NULL); dy -= y;
dx -= x;
dy -= y;
}
else if (event && gdk_event_get_event_type (event) == GDK_MOTION_NOTIFY)
{
double ex, ey;
GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
gdk_event_get_coords (event, &ex, &ey);
x = ex;
y = ey;
gtk_widget_translate_coordinates (widget, toplevel,
x, y, &x, &y);
gdk_window_get_device_position (gtk_widget_get_window (toplevel),
pointer,
&dx, &dy,
NULL);
dx -= x;
dy -= y;
}
else
{
dx = 0;
dy = 0;
}
context = gdk_drag_begin (ipc_window, pointer, target_list, actions, dx, dy); context = gdk_drag_begin (ipc_window, pointer, target_list, actions, dx, dy);
if (context == NULL) if (context == NULL)
@ -1126,11 +1102,9 @@ gtk_drag_begin_internal (GtkWidget *widget,
* @event: (nullable): The event that triggered the start of the drag, * @event: (nullable): The event that triggered the start of the drag,
* or %NULL if none can be obtained. * or %NULL if none can be obtained.
* @x: The initial x coordinate to start dragging from, in the coordinate space * @x: The initial x coordinate to start dragging from, in the coordinate space
* of @widget. If -1 is passed, the coordinates are retrieved from @event or * of @widget.
* the current pointer position
* @y: The initial y coordinate to start dragging from, in the coordinate space * @y: The initial y coordinate to start dragging from, in the coordinate space
* of @widget. If -1 is passed, the coordinates are retrieved from @event or * of @widget.
* the current pointer position
* *
* Initiates a drag on the source side. The function only needs to be used * Initiates a drag on the source side. The function only needs to be used
* when the application is starting drags itself, and is not needed when * when the application is starting drags itself, and is not needed when