[gtk+] iconview: Keep the device for dnd autoscroll
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] iconview: Keep the device for dnd autoscroll
- Date: Wed, 2 Nov 2011 01:37:59 +0000 (UTC)
commit 54d6ef115b364edfebaaa67cc584006adaf499dc
Author: Benjamin Otte <otte redhat com>
Date: Fri Oct 28 10:23:05 2011 -0700
iconview: Keep the device for dnd autoscroll
This is necessary to query the device's coordinates when doing the
scrolling.
gtk/gtkiconview.c | 21 +++++++++++++++------
1 files changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c
index 66072ca..e527dde 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"))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]