[gtk+/touch-text-selection: 7/8] entry: Fix warnings on backwards touch selection from the last position
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/touch-text-selection: 7/8] entry: Fix warnings on backwards touch selection from the last position
- Date: Fri, 24 Aug 2012 15:06:49 +0000 (UTC)
commit da8de209284f9bac86c2e4eb80ac921663751d30
Author: Carlos Garnacho <carlos lanedo com>
Date: Fri Aug 24 14:49:58 2012 +0200
entry: Fix warnings on backwards touch selection from the last position
It shouldn't allow backwards selection, but still shouldn't go off bounds
trying to keep a minimum selection.
gtk/gtkentry.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 7116ac8..cb6e92c 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -4338,11 +4338,14 @@ gtk_entry_motion_notify (GtkWidget *widget,
{
GdkInputSource input_source;
GdkDevice *source;
+ guint length;
+
+ length = gtk_entry_buffer_get_length (get_buffer (entry));
if (event->y < 0)
tmp_pos = 0;
else if (event->y >= gdk_window_get_height (priv->text_area))
- tmp_pos = gtk_entry_buffer_get_length (get_buffer (entry));
+ tmp_pos = length;
else
tmp_pos = gtk_entry_find_position (entry, event->x + priv->scroll_offset);
@@ -4389,7 +4392,7 @@ gtk_entry_motion_notify (GtkWidget *widget,
* so handles don't get inverted.
*/
if (input_source == GDK_SOURCE_TOUCHSCREEN)
- pos = MAX (gtk_entry_move_backward_word (entry, bound, TRUE), pos);
+ pos = MIN (MAX (pos, gtk_entry_move_backward_word (entry, bound, TRUE)), length);
gtk_entry_set_positions (entry, pos, bound);
}
@@ -4399,7 +4402,7 @@ gtk_entry_motion_notify (GtkWidget *widget,
* so handles don't get inverted.
*/
if (input_source == GDK_SOURCE_TOUCHSCREEN)
- tmp_pos = MAX (priv->selection_bound + 1, tmp_pos);
+ tmp_pos = MIN (MAX (tmp_pos, priv->selection_bound + 1), length);
gtk_entry_set_positions (entry, tmp_pos, -1);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]