Commit 218efa62 authored by Benjamin Otte's avatar Benjamin Otte

dnd: Pass dx/dy instead of x_root/y_root

This way, we don't need root coordinates when computing the dnd start
position.
parent a7c3c794
......@@ -87,8 +87,8 @@ GdkDragContext *
_gdk_broadway_window_drag_begin (GdkWindow *window,
GdkDevice *device,
GdkContentFormats *formats,
gint x_root,
gint y_root)
gint dx,
gint dy)
{
GdkDragContext *new_context;
......
......@@ -137,8 +137,8 @@ GDK_AVAILABLE_IN_ALL
GdkDragContext * gdk_drag_begin (GdkWindow *window,
GdkDevice *device,
GdkContentFormats *formats,
gint x_root,
gint y_root);
gint dx,
gint dy);
GDK_AVAILABLE_IN_ALL
gboolean gdk_drag_drop_succeeded (GdkDragContext *context);
......
......@@ -6928,8 +6928,8 @@ gdk_window_register_dnd (GdkWindow *window)
* @window: the source window for this drag
* @device: the device that controls this drag
* @formats: (transfer none): the offered formats
* @x_root: the x coordinate where the drag nominally started
* @y_root: the y coordinate where the drag nominally started
* @dx: the x offset to @device's position where the drag nominally started
* @dy: the y offset to @device's position where the drag nominally started
*
* Starts a drag and creates a new drag context for it.
*
......
......@@ -36,8 +36,8 @@ GdkDragContext *
_gdk_quartz_window_drag_begin (GdkWindow *window,
GdkDevice *device,
GList *targets,
gint x_root,
gint y_root)
gint dx,
gint dy)
{
g_assert (_gdk_quartz_drag_source_context == NULL);
......
......@@ -586,8 +586,8 @@ GdkDragContext *
_gdk_wayland_window_drag_begin (GdkWindow *window,
GdkDevice *device,
GdkContentFormats *formats,
gint x_root,
gint y_root)
gint dx,
gint dy)
{
GdkWaylandDragContext *context_wayland;
GdkDragContext *context;
......
......@@ -2011,13 +2011,14 @@ GdkDragContext *
_gdk_win32_window_drag_begin (GdkWindow *window,
GdkDevice *device,
GdkContentFormats *formats,
gint x_root,
gint y_root)
gint dx,
gint dy)
{
GdkDragContext *new_context;
GdkWin32DragContext *context_win32;
BYTE kbd_state[256];
GdkWin32Selection *sel_win32 = _gdk_win32_selection_get ();
int x_root, y_root;
if (!use_ole2_dnd)
{
......@@ -2050,6 +2051,10 @@ _gdk_win32_window_drag_begin (GdkWindow *window,
context_win32 = GDK_WIN32_DRAG_CONTEXT (new_context);
}
gdk_device_get_position (device, &x_root, &y_root);
x_root += dx;
y_root += dy;
context_win32->start_x = x_root;
context_win32->start_y = y_root;
context_win32->last_x = context_win32->start_x;
......
......@@ -2101,10 +2101,11 @@ GdkDragContext *
_gdk_x11_window_drag_begin (GdkWindow *window,
GdkDevice *device,
GdkContentFormats *formats,
gint x_root,
gint y_root)
gint dx,
gint dy)
{
GdkDragContext *context;
int x_root, y_root;
context = (GdkDragContext *) g_object_new (GDK_TYPE_X11_DRAG_CONTEXT,
"display", gdk_window_get_display (window),
......@@ -2120,6 +2121,9 @@ _gdk_x11_window_drag_begin (GdkWindow *window,
context->actions = 0;
gdk_drag_context_set_device (context, device);
gdk_device_get_position (device, &x_root, &y_root);
x_root += dx;
y_root += dy;
GDK_X11_DRAG_CONTEXT (context)->start_x = x_root;
GDK_X11_DRAG_CONTEXT (context)->start_y = y_root;
......
......@@ -1060,7 +1060,7 @@ gtk_drag_begin_internal (GtkWidget *widget,
GtkWidget *ipc_widget;
GdkDevice *pointer, *keyboard;
GdkWindow *ipc_window;
int start_x, start_y;
int dx, dy;
GdkAtom selection;
pointer = keyboard = NULL;
......@@ -1106,21 +1106,37 @@ gtk_drag_begin_internal (GtkWidget *widget,
GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
gtk_widget_translate_coordinates (widget, toplevel,
x, y, &x, &y);
gdk_window_get_root_coords (gtk_widget_get_window (toplevel),
x, y, &start_x, &start_y);
gdk_window_get_device_position (gtk_widget_get_window (toplevel),
pointer,
&dx, &dy,
NULL);
dx -= x;
dy -= y;
}
else if (event && gdk_event_get_event_type (event) == GDK_MOTION_NOTIFY)
{
double x, y;
double ex, ey;
GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
gdk_event_get_root_coords (event, &x, &y);
start_x = (int)x;
start_y = (int)y;
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
gdk_device_get_position (pointer, &start_x, &start_y);
{
dx = 0;
dy = 0;
}
context = gdk_drag_begin (ipc_window, pointer, target_list, start_x, start_y);
context = gdk_drag_begin (ipc_window, pointer, target_list, dx, dy);
if (!gdk_drag_context_manage_dnd (context, ipc_window, actions))
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment