summaryrefslogtreecommitdiff
path: root/gtk/gtktextlayout.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2001-10-23 17:45:33 +0000
committerHavoc Pennington <hp@src.gnome.org>2001-10-23 17:45:33 +0000
commit9894b89bd97271e6f6c60214587ca45686ac5223 (patch)
treef00ee42d11b12f45361200d3b99f1aaee021a6a4 /gtk/gtktextlayout.c
parentbd3b53c4c7a32bf96b392db1f72ec227e371b64a (diff)
downloadgtk+-9894b89bd97271e6f6c60214587ca45686ac5223.tar.gz
Apply fix from Dov Grobgeld, #61858
2001-10-23 Havoc Pennington <hp@redhat.com> * gtk/gtktextlayout.c (gtk_text_layout_get_iter_at_pixel): Apply fix from Dov Grobgeld, #61858
Diffstat (limited to 'gtk/gtktextlayout.c')
-rw-r--r--gtk/gtktextlayout.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/gtk/gtktextlayout.c b/gtk/gtktextlayout.c
index 599c82f302..018a33aea8 100644
--- a/gtk/gtktextlayout.c
+++ b/gtk/gtktextlayout.c
@@ -2117,14 +2117,6 @@ gtk_text_layout_get_iter_at_pixel (GtkTextLayout *layout,
g_return_if_fail (GTK_IS_TEXT_LAYOUT (layout));
g_return_if_fail (target_iter != NULL);
- /* Adjust pixels to be on-screen. This gives nice
- behavior if the user is dragging with a pointer grab.
- */
- if (x < 0)
- x = 0;
- if (x > layout->width)
- x = layout->width;
-
get_line_at_y (layout, y, &line, &line_top);
display = gtk_text_layout_get_line_display (layout, line, FALSE);
@@ -2132,17 +2124,23 @@ gtk_text_layout_get_iter_at_pixel (GtkTextLayout *layout,
x -= display->x_offset;
y -= line_top + display->top_margin;
- /* We clamp y to the area of the actual layout so that the layouts
- * hit testing works OK on the space above and below the layout
+ /* If we are below the layout, position the cursor at the last character
+ * of the line.
*/
- y = CLAMP (y, 0, display->height - display->top_margin - display->bottom_margin - 1);
-
- if (!pango_layout_xy_to_index (display->layout, x * PANGO_SCALE, y * PANGO_SCALE,
- &byte_index, &trailing))
+ if (y > display->height - display->top_margin - display->bottom_margin)
{
byte_index = _gtk_text_line_byte_count (line);
trailing = 0;
}
+ else
+ {
+ /* Ignore the "outside" return value from pango. Pango is doing
+ * the right thing even if we are outside the layout in the
+ * x-direction.
+ */
+ pango_layout_xy_to_index (display->layout, x * PANGO_SCALE, y * PANGO_SCALE,
+ &byte_index, &trailing);
+ }
line_display_index_to_iter (layout, display, target_iter, byte_index, trailing);