[gtk+/touch-text-selection: 6/6] textview: limit GtkTextHandle behavior to touch devices
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/touch-text-selection: 6/6] textview: limit GtkTextHandle behavior to touch devices
- Date: Wed, 11 Jul 2012 15:40:54 +0000 (UTC)
commit a5184d2a70437e94409bbf7f66419232715461f0
Author: Carlos Garnacho <carlos lanedo com>
Date: Wed Jul 11 17:37:32 2012 +0200
textview: limit GtkTextHandle behavior to touch devices
Other devices won't cause the handles to appear, this commit
can be reverted to test handles behavior on non-touchscreens.
gtk/gtktextview.c | 23 ++++++++++++++++++-----
1 files changed, 18 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index acd0f7a..64d4c0b 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -4752,9 +4752,14 @@ gtk_text_view_button_press_event (GtkWidget *widget, GdkEventButton *event)
}
else
{
+ GdkDevice *device;
+
gtk_text_view_start_selection_drag (text_view, &iter, event);
- _gtk_text_view_update_handles (text_view,
- GTK_TEXT_HANDLE_MODE_CURSOR);
+ device = gdk_event_get_source_device ((GdkEvent *) event);
+
+ if (gdk_device_get_source (device) == GDK_SOURCE_TOUCHSCREEN)
+ _gtk_text_view_update_handles (text_view,
+ GTK_TEXT_HANDLE_MODE_CURSOR);
}
return TRUE;
@@ -4824,6 +4829,7 @@ gtk_text_view_button_release_event (GtkWidget *widget, GdkEventButton *event)
return TRUE;
else if (priv->pending_place_cursor_button == event->button)
{
+ GdkDevice *device;
GtkTextIter iter;
/* Unselect everything; we clicked inside selection, but
@@ -4838,8 +4844,11 @@ gtk_text_view_button_release_event (GtkWidget *widget, GdkEventButton *event)
gtk_text_buffer_place_cursor (get_buffer (text_view), &iter);
gtk_text_view_check_cursor_blink (text_view);
- _gtk_text_view_update_handles (text_view,
- GTK_TEXT_HANDLE_MODE_CURSOR);
+ device = gdk_event_get_source_device ((GdkEvent *) event);
+
+ if (gdk_device_get_source (device) == GDK_SOURCE_TOUCHSCREEN)
+ _gtk_text_view_update_handles (text_view,
+ GTK_TEXT_HANDLE_MODE_CURSOR);
priv->pending_place_cursor_button = 0;
@@ -6579,6 +6588,7 @@ selection_motion_event_handler (GtkTextView *text_view,
SelectionData *data)
{
GtkTextViewPrivate *priv;
+ GdkDevice *device;
priv = text_view->priv;
gdk_event_request_motions (event);
@@ -6627,7 +6637,10 @@ selection_motion_event_handler (GtkTextView *text_view,
text_view->priv->scroll_timeout =
gdk_threads_add_timeout (50, selection_scan_timeout, text_view);
- _gtk_text_view_update_handles (text_view, GTK_TEXT_HANDLE_MODE_SELECTION);
+ device = gdk_event_get_source_device ((GdkEvent *) event);
+
+ if (gdk_device_get_source (device) == GDK_SOURCE_TOUCHSCREEN)
+ _gtk_text_view_update_handles (text_view, GTK_TEXT_HANDLE_MODE_SELECTION);
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]