GtkTextView: Scroll on the pointer doing DnD.
This commit is contained in:
@ -110,6 +110,7 @@ struct _GtkTextViewPrivate
|
|||||||
guint im_spot_idle;
|
guint im_spot_idle;
|
||||||
gchar *im_module;
|
gchar *im_module;
|
||||||
GdkDevice *grab_device;
|
GdkDevice *grab_device;
|
||||||
|
GdkDevice *dnd_device;
|
||||||
guint scroll_after_paste : 1;
|
guint scroll_after_paste : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -6078,15 +6079,15 @@ static gint
|
|||||||
drag_scan_timeout (gpointer data)
|
drag_scan_timeout (gpointer data)
|
||||||
{
|
{
|
||||||
GtkTextView *text_view;
|
GtkTextView *text_view;
|
||||||
|
GtkTextViewPrivate *priv;
|
||||||
GtkTextIter newplace;
|
GtkTextIter newplace;
|
||||||
gint x, y, width, height;
|
gint x, y, width, height;
|
||||||
gdouble pointer_xoffset, pointer_yoffset;
|
gdouble pointer_xoffset, pointer_yoffset;
|
||||||
GdkDevice *device;
|
|
||||||
|
|
||||||
text_view = GTK_TEXT_VIEW (data);
|
text_view = GTK_TEXT_VIEW (data);
|
||||||
device = gdk_display_get_core_pointer (gtk_widget_get_display (GTK_WIDGET (data)));
|
priv = GTK_TEXT_VIEW_GET_PRIVATE (text_view);
|
||||||
|
|
||||||
get_iter_at_pointer (text_view, device, &newplace, &x, &y);
|
get_iter_at_pointer (text_view, priv->dnd_device, &newplace, &x, &y);
|
||||||
gdk_drawable_get_size (text_view->text_window->bin_window, &width, &height);
|
gdk_drawable_get_size (text_view->text_window->bin_window, &width, &height);
|
||||||
|
|
||||||
gtk_text_buffer_move_mark (get_buffer (text_view),
|
gtk_text_buffer_move_mark (get_buffer (text_view),
|
||||||
@ -6814,11 +6815,16 @@ gtk_text_view_drag_leave (GtkWidget *widget,
|
|||||||
guint time)
|
guint time)
|
||||||
{
|
{
|
||||||
GtkTextView *text_view;
|
GtkTextView *text_view;
|
||||||
|
GtkTextViewPrivate *priv;
|
||||||
|
|
||||||
text_view = GTK_TEXT_VIEW (widget);
|
text_view = GTK_TEXT_VIEW (widget);
|
||||||
|
priv = GTK_TEXT_VIEW_GET_PRIVATE (text_view);
|
||||||
|
|
||||||
gtk_text_mark_set_visible (text_view->dnd_mark, FALSE);
|
gtk_text_mark_set_visible (text_view->dnd_mark, FALSE);
|
||||||
|
|
||||||
|
if (priv->dnd_device)
|
||||||
|
priv->dnd_device = NULL;
|
||||||
|
|
||||||
if (text_view->scroll_timeout != 0)
|
if (text_view->scroll_timeout != 0)
|
||||||
g_source_remove (text_view->scroll_timeout);
|
g_source_remove (text_view->scroll_timeout);
|
||||||
|
|
||||||
@ -6834,6 +6840,7 @@ gtk_text_view_drag_motion (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
GtkTextIter newplace;
|
GtkTextIter newplace;
|
||||||
GtkTextView *text_view;
|
GtkTextView *text_view;
|
||||||
|
GtkTextViewPrivate *priv;
|
||||||
GtkTextIter start;
|
GtkTextIter start;
|
||||||
GtkTextIter end;
|
GtkTextIter end;
|
||||||
GdkRectangle target_rect;
|
GdkRectangle target_rect;
|
||||||
@ -6842,6 +6849,7 @@ gtk_text_view_drag_motion (GtkWidget *widget,
|
|||||||
GdkDragAction suggested_action = 0;
|
GdkDragAction suggested_action = 0;
|
||||||
|
|
||||||
text_view = GTK_TEXT_VIEW (widget);
|
text_view = GTK_TEXT_VIEW (widget);
|
||||||
|
priv = GTK_TEXT_VIEW_GET_PRIVATE (text_view);
|
||||||
|
|
||||||
target_rect = text_view->text_window->allocation;
|
target_rect = text_view->text_window->allocation;
|
||||||
|
|
||||||
@ -6912,6 +6920,8 @@ gtk_text_view_drag_motion (GtkWidget *widget,
|
|||||||
gtk_text_mark_set_visible (text_view->dnd_mark, FALSE);
|
gtk_text_mark_set_visible (text_view->dnd_mark, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
priv->dnd_device = gdk_drag_context_get_device (context);
|
||||||
|
|
||||||
if (!text_view->scroll_timeout)
|
if (!text_view->scroll_timeout)
|
||||||
text_view->scroll_timeout =
|
text_view->scroll_timeout =
|
||||||
gdk_threads_add_timeout (100, drag_scan_timeout, text_view);
|
gdk_threads_add_timeout (100, drag_scan_timeout, text_view);
|
||||||
|
|||||||
Reference in New Issue
Block a user