diff options
author | Benjamin Otte <otte@redhat.com> | 2011-10-28 10:23:05 -0700 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2011-11-02 02:32:54 +0100 |
commit | 54d6ef115b364edfebaaa67cc584006adaf499dc (patch) | |
tree | df95e4a3005b5c7447ebc2171866e671e4da781f /gtk/gtkiconview.c | |
parent | e739757babb025e1840f263fdc6d63d73f917beb (diff) | |
download | gtk+-54d6ef115b364edfebaaa67cc584006adaf499dc.tar.gz |
iconview: Keep the device for dnd autoscroll
This is necessary to query the device's coordinates when doing the
scrolling.
Diffstat (limited to 'gtk/gtkiconview.c')
-rw-r--r-- | gtk/gtkiconview.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c index 66072cad82..e527dde40d 100644 --- a/gtk/gtkiconview.c +++ b/gtk/gtkiconview.c @@ -6074,7 +6074,8 @@ remove_scroll_timeout (GtkIconView *icon_view) } static void -gtk_icon_view_autoscroll (GtkIconView *icon_view) +gtk_icon_view_autoscroll (GtkIconView *icon_view, + GdkDevice *device) { GdkWindow *window; gint px, py, x, y, width, height; @@ -6082,7 +6083,7 @@ gtk_icon_view_autoscroll (GtkIconView *icon_view) window = gtk_widget_get_window (GTK_WIDGET (icon_view)); - gdk_window_get_pointer (window, &px, &py, NULL); + gdk_window_get_device_position (window, device, &px, &py, NULL); gdk_window_get_geometry (window, &x, &y, &width, &height); /* see if we are near the edge. */ @@ -6103,13 +6104,17 @@ gtk_icon_view_autoscroll (GtkIconView *icon_view) gtk_adjustment_get_value (icon_view->priv->hadjustment) + hoffset); } +typedef struct { + GtkIconView *icon_view; + GdkDevice *device; +} DragScrollData; static gboolean -drag_scroll_timeout (gpointer data) +drag_scroll_timeout (gpointer datap) { - GtkIconView *icon_view = GTK_ICON_VIEW (data); + DragScrollData *data = datap; - gtk_icon_view_autoscroll (icon_view); + gtk_icon_view_autoscroll (data->icon_view, data->device); return TRUE; } @@ -6506,8 +6511,12 @@ gtk_icon_view_drag_motion (GtkWidget *widget, { if (icon_view->priv->scroll_timeout_id == 0) { + DragScrollData *data = g_slice_new (DragScrollData); + data->icon_view = icon_view; + data->device = gdk_drag_context_get_device (context); + icon_view->priv->scroll_timeout_id = - gdk_threads_add_timeout (50, drag_scroll_timeout, icon_view); + gdk_threads_add_timeout_full (G_PRIORITY_DEFAULT, 50, drag_scroll_timeout, data, g_free); } if (target == gdk_atom_intern_static_string ("GTK_TREE_MODEL_ROW")) |