[gtk+/touch-text-selection: 5/6] entry: limit GtkTextHandle behavior to touch devices
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/touch-text-selection: 5/6] entry: limit GtkTextHandle behavior to touch devices
- Date: Wed, 11 Jul 2012 15:40:49 +0000 (UTC)
commit f47dbc49bdb5c6668e895f2d38ae22ec02e7f31b
Author: Carlos Garnacho <carlos lanedo com>
Date: Wed Jul 11 17:35:29 2012 +0200
entry: 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/gtkentry.c | 26 ++++++++++++++++++++++----
1 files changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index d7b2df1..b9c214f 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -4039,9 +4039,16 @@ gtk_entry_button_press (GtkWidget *widget,
}
else
{
+ GdkDevice *source;
+
gtk_editable_set_position (editable, tmp_pos);
- priv->dragged_handle_pos = GTK_TEXT_HANDLE_POSITION_CURSOR;
- _gtk_entry_update_handles (entry, GTK_TEXT_HANDLE_MODE_CURSOR);
+ source = gdk_event_get_source_device ((GdkEvent *) event);
+
+ if (gdk_device_get_source (source) == GDK_SOURCE_TOUCHSCREEN)
+ {
+ priv->dragged_handle_pos = GTK_TEXT_HANDLE_POSITION_CURSOR;
+ _gtk_entry_update_handles (entry, GTK_TEXT_HANDLE_MODE_CURSOR);
+ }
}
break;
@@ -4132,9 +4139,15 @@ gtk_entry_button_release (GtkWidget *widget,
if (priv->in_drag)
{
gint tmp_pos = gtk_entry_find_position (entry, priv->drag_start_x);
+ GdkDevice *source;
gtk_editable_set_position (GTK_EDITABLE (entry), tmp_pos);
- _gtk_entry_update_handles (entry, GTK_TEXT_HANDLE_MODE_CURSOR);
+
+ source = gdk_event_get_source_device ((GdkEvent *) event);
+
+ if (gdk_device_get_source (source) == GDK_SOURCE_TOUCHSCREEN)
+ _gtk_entry_update_handles (entry, GTK_TEXT_HANDLE_MODE_CURSOR);
+
priv->in_drag = 0;
}
@@ -4259,6 +4272,8 @@ gtk_entry_motion_notify (GtkWidget *widget,
}
else
{
+ GdkDevice *source;
+
if (event->y < 0)
tmp_pos = 0;
else if (event->y >= gdk_window_get_height (priv->text_area))
@@ -4307,7 +4322,10 @@ gtk_entry_motion_notify (GtkWidget *widget,
else
gtk_entry_set_positions (entry, tmp_pos, -1);
- _gtk_entry_update_handles (entry, GTK_TEXT_HANDLE_MODE_SELECTION);
+ source = gdk_event_get_source_device ((GdkEvent *) event);
+
+ if (gdk_device_get_source (source) == GDK_SOURCE_TOUCHSCREEN)
+ _gtk_entry_update_handles (entry, GTK_TEXT_HANDLE_MODE_SELECTION);
}
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]