[gtk+/xi2] GtkTextView: Make text selection follow only the device that started it.
- From: Carlos Garnacho <carlosg src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtk+/xi2] GtkTextView: Make text selection follow only the device that started it.
- Date: Wed, 30 Dec 2009 21:18:12 +0000 (UTC)
commit be1650e5e80dd75155800e22ef27b75707667411
Author: Carlos Garnacho <carlos gnome org>
Date: Thu Dec 24 14:19:11 2009 +0100
GtkTextView: Make text selection follow only the device that started it.
Other devices' motion events are ignored during text selection, device-aware
API is now used to request the pointer position.
gtk/gtktextview.c | 26 +++++++++++++++++---------
1 files changed, 17 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 0c41e24..f05188b 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -5914,6 +5914,7 @@ gtk_text_view_unselect (GtkTextView *text_view)
static void
get_iter_at_pointer (GtkTextView *text_view,
+ GdkDevice *device,
GtkTextIter *iter,
gint *x,
gint *y)
@@ -5921,9 +5922,9 @@ get_iter_at_pointer (GtkTextView *text_view,
gint xcoord, ycoord;
GdkModifierType state;
- gdk_window_get_pointer (text_view->text_window->bin_window,
- &xcoord, &ycoord, &state);
-
+ gdk_window_get_device_position (text_view->text_window->bin_window,
+ device, &xcoord, &ycoord, &state);
+
gtk_text_layout_get_iter_at_pixel (text_view->layout,
iter,
xcoord + text_view->xoffset,
@@ -5937,12 +5938,13 @@ get_iter_at_pointer (GtkTextView *text_view,
static void
move_mark_to_pointer_and_scroll (GtkTextView *text_view,
- const gchar *mark_name)
+ const gchar *mark_name,
+ GdkDevice *device)
{
GtkTextIter newplace;
GtkTextMark *mark;
- get_iter_at_pointer (text_view, &newplace, NULL, NULL);
+ get_iter_at_pointer (text_view, device, &newplace, NULL, NULL);
mark = gtk_text_buffer_get_mark (get_buffer (text_view), mark_name);
@@ -5967,7 +5969,6 @@ selection_scan_timeout (gpointer data)
text_view = GTK_TEXT_VIEW (data);
- DV(g_print (G_STRLOC": calling move_mark_to_pointer_and_scroll\n"));
gtk_text_view_scroll_mark_onscreen (text_view,
gtk_text_buffer_get_insert (get_buffer (text_view)));
@@ -5996,10 +5997,12 @@ drag_scan_timeout (gpointer data)
GtkTextIter newplace;
gint x, y, width, height;
gdouble pointer_xoffset, pointer_yoffset;
+ GdkDevice *device;
text_view = GTK_TEXT_VIEW (data);
+ device = gdk_display_get_core_pointer (gtk_widget_get_display (GTK_WIDGET (data)));
- get_iter_at_pointer (text_view, &newplace, &x, &y);
+ get_iter_at_pointer (text_view, device, &newplace, &x, &y);
gdk_drawable_get_size (text_view->text_window->bin_window, &width, &height);
gtk_text_buffer_move_mark (get_buffer (text_view),
@@ -6117,6 +6120,7 @@ typedef struct
SelectionGranularity granularity;
GtkTextMark *orig_start;
GtkTextMark *orig_end;
+ GdkDevice *device;
} SelectionData;
static void
@@ -6138,9 +6142,12 @@ selection_motion_event_handler (GtkTextView *text_view,
{
gdk_event_request_motions (event);
+ if (data->device != event->device)
+ return FALSE;
+
if (data->granularity == SELECT_CHARACTERS)
{
- move_mark_to_pointer_and_scroll (text_view, "insert");
+ move_mark_to_pointer_and_scroll (text_view, "insert", event->device);
}
else
{
@@ -6153,7 +6160,7 @@ selection_motion_event_handler (GtkTextView *text_view,
gtk_text_buffer_get_iter_at_mark (buffer, &orig_start, data->orig_start);
gtk_text_buffer_get_iter_at_mark (buffer, &orig_end, data->orig_end);
- get_iter_at_pointer (text_view, &cursor, NULL, NULL);
+ get_iter_at_pointer (text_view, event->device, &cursor, NULL, NULL);
start = cursor;
extend_selection (text_view, data->granularity, &start, &end);
@@ -6254,6 +6261,7 @@ gtk_text_view_start_selection_drag (GtkTextView *text_view,
&orig_start, TRUE);
data->orig_end = gtk_text_buffer_create_mark (buffer, NULL,
&orig_end, TRUE);
+ data->device = button->device;
gtk_text_view_check_cursor_blink (text_view);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]