Commit 04ac4c66 authored by Benjamin Otte's avatar Benjamin Otte

dnd: Pass device, not event

You don't start a dnd operation with a device, you start it with an
event.
parent 23c798b4
......@@ -2665,8 +2665,6 @@ gtk_calendar_drag_update (GtkGestureDrag *gesture,
gdouble start_x, start_y;
GdkDragContext *context;
GdkContentFormats *targets;
GdkEventSequence *sequence;
GdkEvent *last_event;
if (!priv->in_drag)
return;
......@@ -2676,20 +2674,17 @@ gtk_calendar_drag_update (GtkGestureDrag *gesture,
gtk_gesture_drag_get_start_point (gesture, &start_x, &start_y);
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
last_event = gdk_event_copy (gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence));
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (gesture));
targets = gdk_content_formats_new (NULL, 0);
targets = gtk_content_formats_add_text_targets (targets);
context = gtk_drag_begin_with_coordinates (widget, targets, GDK_ACTION_COPY,
last_event,
context = gtk_drag_begin_with_coordinates (widget,
gtk_gesture_get_device (GTK_GESTURE (gesture)),
targets, GDK_ACTION_COPY,
start_x, start_y);
priv->in_drag = 0;
gdk_content_formats_unref (targets);
gdk_event_free (last_event);
gtk_drag_set_icon_default (context);
}
......
......@@ -965,46 +965,27 @@ gtk_drag_dest_drop (GtkWidget *widget,
*/
GdkDragContext *
gtk_drag_begin_internal (GtkWidget *widget,
GdkDevice *device,
GtkImageDefinition *icon,
GdkContentFormats *target_list,
GdkDragAction actions,
const GdkEvent *event,
int x,
int y)
{
GtkDragSourceInfo *info;
GtkWidget *toplevel;
guint32 time = GDK_CURRENT_TIME;
GdkDragContext *context;
GtkWidget *ipc_widget;
GdkDevice *pointer;
GdkWindow *ipc_window;
int dx, dy;
GdkAtom selection;
guint32 time;
ipc_widget = gtk_drag_get_ipc_widget (widget);
time = gtk_get_current_event_time ();
if (event)
{
time = gdk_event_get_time (event);
if (time == GDK_CURRENT_TIME)
time = gtk_get_current_event_time ();
pointer = gdk_event_get_device (event);
if (gdk_device_get_source (pointer) == GDK_SOURCE_KEYBOARD)
pointer = gdk_device_get_associated_device (pointer);
}
else
{
GdkSeat *seat;
seat = gdk_display_get_default_seat (gtk_widget_get_display (widget));
pointer = gdk_seat_get_pointer (seat);
}
if (!pointer)
return NULL;
if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
device = gdk_device_get_associated_device (device);
ipc_window = gtk_widget_get_window (ipc_widget);
......@@ -1014,13 +995,13 @@ gtk_drag_begin_internal (GtkWidget *widget,
gtk_widget_translate_coordinates (widget, toplevel,
x, y, &x, &y);
gdk_window_get_device_position (gtk_widget_get_window (toplevel),
pointer,
device,
&dx, &dy,
NULL);
dx -= x;
dy -= y;
context = gdk_drag_begin (ipc_window, pointer, target_list, actions, dx, dy);
context = gdk_drag_begin (ipc_window, device, target_list, actions, dx, dy);
if (context == NULL)
{
gtk_drag_release_ipc_widget (ipc_widget);
......@@ -1096,11 +1077,11 @@ gtk_drag_begin_internal (GtkWidget *widget,
/**
* gtk_drag_begin_with_coordinates: (method)
* @widget: the source widget
* @device: (nullable): the device that starts the drag or %NULL to use the default
* pointer.
* @targets: The targets (data formats) in which the
* source can provide the data
* @actions: A bitmask of the allowed drag actions for this drag
* @event: (nullable): The event that triggered the start of the drag,
* or %NULL if none can be obtained.
* @x: The initial x coordinate to start dragging from, in the coordinate space
* of @widget.
* @y: The initial y coordinate to start dragging from, in the coordinate space
......@@ -1138,18 +1119,31 @@ gtk_drag_begin_internal (GtkWidget *widget,
*/
GdkDragContext *
gtk_drag_begin_with_coordinates (GtkWidget *widget,
GdkDevice *device,
GdkContentFormats *targets,
GdkDragAction actions,
GdkEvent *event,
gint x,
gint y)
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
g_return_val_if_fail (device == NULL || GDK_IS_DEVICE (device), NULL);
g_return_val_if_fail (gtk_widget_get_realized (widget), NULL);
g_return_val_if_fail (targets != NULL, NULL);
return gtk_drag_begin_internal (widget, NULL, targets,
actions, event, x, y);
if (device == NULL)
{
GdkSeat *seat;
seat = gdk_display_get_default_seat (gtk_widget_get_display (widget));
device = gdk_seat_get_pointer (seat);
}
return gtk_drag_begin_internal (widget,
device,
NULL,
targets,
actions,
x, y);
}
static void
......
......@@ -61,9 +61,9 @@ void gtk_drag_unhighlight (GtkWidget *widget);
GDK_AVAILABLE_IN_3_10
GdkDragContext *gtk_drag_begin_with_coordinates (GtkWidget *widget,
GdkDevice *device,
GdkContentFormats *targets,
GdkDragAction actions,
GdkEvent *event,
gint x,
gint y);
......
......@@ -41,10 +41,10 @@ struct _GtkDragDestSite
G_BEGIN_DECLS
GdkDragContext * gtk_drag_begin_internal (GtkWidget *widget,
GdkDevice *device,
GtkImageDefinition *icon,
GdkContentFormats *target_list,
GdkDragAction actions,
const GdkEvent *event,
int x,
int y);
void gtk_drag_set_icon_definition (GdkDragContext *context,
......
......@@ -85,20 +85,14 @@ gtk_drag_source_event_cb (GtkWidget *widget,
if (gtk_drag_check_threshold (widget, start_x, start_y,
start_x + offset_x, start_y + offset_y))
{
GdkEventSequence *sequence;
GdkEvent *last_event;
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (site->drag_gesture));
last_event = gdk_event_copy (gtk_gesture_get_last_event (site->drag_gesture, sequence));
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (site->drag_gesture));
gtk_drag_begin_internal (widget, site->image_def, site->target_list,
site->actions, last_event,
gtk_drag_begin_internal (widget,
gtk_gesture_get_device (site->drag_gesture),
site->image_def, site->target_list,
site->actions,
start_x, start_y);
gdk_event_free (last_event);
return TRUE;
}
}
......
......@@ -3677,9 +3677,9 @@ gtk_entry_event (GtkWidget *widget,
{
icon_info->in_drag = TRUE;
gtk_drag_begin_with_coordinates (widget,
device,
icon_info->target_list,
icon_info->actions,
event,
priv->start_x,
priv->start_y);
}
......@@ -4002,8 +4002,9 @@ gtk_entry_drag_gesture_update (GtkGestureDrag *gesture,
gtk_entry_get_pixel_ranges (entry, &ranges, &n_ranges);
gtk_drag_begin_with_coordinates (widget, target_list, actions,
(GdkEvent*) event,
gtk_drag_begin_with_coordinates (widget,
gdk_event_get_device ((GdkEvent*) event),
target_list, actions,
priv->drag_start_x + ranges[0],
priv->drag_start_y);
g_free (ranges);
......
......@@ -6191,9 +6191,9 @@ gtk_icon_view_maybe_begin_drag (GtkIconView *icon_view,
retval = TRUE;
context = gtk_drag_begin_with_coordinates (widget,
gdk_event_get_device ((GdkEvent*) event),
gtk_drag_source_get_target_list (widget),
icon_view->priv->source_actions,
(GdkEvent*)event,
icon_view->priv->press_start_x,
icon_view->priv->press_start_y);
......
......@@ -4769,16 +4769,15 @@ gtk_label_drag_gesture_update (GtkGestureDrag *gesture,
x, y))
{
GdkContentFormats *target_list = gdk_content_formats_new (NULL, 0);
const GdkEvent *event;
event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
target_list = gtk_content_formats_add_text_targets (target_list);
g_signal_connect (widget, "drag-begin",
G_CALLBACK (drag_begin_cb), NULL);
gtk_drag_begin_with_coordinates (widget, target_list,
gtk_drag_begin_with_coordinates (widget,
gtk_gesture_get_device (GTK_GESTURE (gesture)),
target_list,
GDK_ACTION_COPY,
(GdkEvent*) event,
info->drag_start_x,
info->drag_start_y);
......
......@@ -2712,8 +2712,9 @@ gtk_notebook_motion_notify (GtkWidget *widget,
{
priv->detached_tab = priv->cur_page;
gtk_drag_begin_with_coordinates (widget, priv->source_targets, GDK_ACTION_MOVE,
(GdkEvent*) event,
gtk_drag_begin_with_coordinates (widget,
gdk_event_get_device ((GdkEvent*) event),
priv->source_targets, GDK_ACTION_MOVE,
priv->drag_begin_x, priv->drag_begin_y);
return TRUE;
}
......
......@@ -1725,8 +1725,9 @@ on_motion_notify_event (GtkWidget *widget,
{
sidebar->dragging_over = TRUE;
gtk_drag_begin_with_coordinates (widget, sidebar->source_targets, GDK_ACTION_MOVE,
(GdkEvent*)event,
gtk_drag_begin_with_coordinates (widget,
gdk_event_get_device ((GdkEvent*) event),
sidebar->source_targets, GDK_ACTION_MOVE,
-1, -1);
}
......
......@@ -7819,9 +7819,11 @@ gtk_text_view_start_selection_dnd (GtkTextView *text_view,
g_signal_connect (text_view, "drag-begin",
G_CALLBACK (drag_begin_cb), NULL);
gtk_drag_begin_with_coordinates (GTK_WIDGET (text_view), formats,
gtk_drag_begin_with_coordinates (GTK_WIDGET (text_view),
gdk_event_get_device (event),
formats,
GDK_ACTION_COPY | GDK_ACTION_MOVE,
(GdkEvent*) event, x, y);
x, y);
}
static void
......
......@@ -7421,8 +7421,6 @@ gtk_tree_view_maybe_begin_dragging_row (GtkTreeView *tree_view)
{
GtkWidget *widget = GTK_WIDGET (tree_view);
gdouble start_x, start_y, offset_x, offset_y;
GdkEventSequence *sequence;
const GdkEvent *event;
GdkDragContext *context;
TreeViewDragInfo *di;
GtkTreePath *path = NULL;
......@@ -7479,13 +7477,11 @@ gtk_tree_view_maybe_begin_dragging_row (GtkTreeView *tree_view)
/* Now we can begin the drag */
gtk_gesture_set_state (GTK_GESTURE (tree_view->priv->drag_gesture),
GTK_EVENT_SEQUENCE_CLAIMED);
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (tree_view->priv->drag_gesture));
event = gtk_gesture_get_last_event (GTK_GESTURE (tree_view->priv->drag_gesture), sequence);
context = gtk_drag_begin_with_coordinates (widget,
gtk_gesture_get_device (GTK_GESTURE (tree_view->priv->drag_gesture)),
gtk_drag_source_get_target_list (widget),
di->source_actions,
(GdkEvent*)event,
start_x, start_y);
set_source_row (context, model, path);
......
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