Index: gtk/gtktextview.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktextview.c,v
retrieving revision 1.264
diff -u -p -r1.264 gtktextview.c
--- gtk/gtktextview.c	28 Nov 2004 06:06:57 -0000	1.264
+++ gtk/gtktextview.c	4 Dec 2004 07:46:12 -0000
@@ -1297,9 +1297,38 @@ gtk_text_view_get_iter_at_location (GtkT
   gtk_text_view_ensure_layout (text_view);
   
   gtk_text_layout_get_iter_at_pixel (text_view->layout,
-                                     iter,
-                                     x,
-                                     y);
+                                     iter, x, y);
+}
+
+/**
+ * gtk_text_view_get_iter_at_position:
+ * @text_view: a #GtkTextView
+ * @iter: a #GtkTextIter
+ * @trailing: 
+ * @x: x position, in buffer coordinates
+ * @y: y position, in buffer coordinates
+ *
+ * Retrieves the iterator at buffer coordinates @x and @y. Buffer
+ * coordinates are coordinates for the entire buffer, not just the
+ * currently-displayed portion.  If you have coordinates from an
+ * event, you have to convert those to buffer coordinates with
+ * gtk_text_view_window_to_buffer_coords().
+ *
+ **/
+void
+gtk_text_view_get_iter_at_position (GtkTextView *text_view,
+				    GtkTextIter *iter,
+				    gint        *trailing,
+				    gint         x,
+				    gint         y)
+{
+  g_return_if_fail (GTK_IS_TEXT_VIEW (text_view));
+  g_return_if_fail (iter != NULL);
+
+  gtk_text_view_ensure_layout (text_view);
+  
+  gtk_text_layout_get_iter_at_position (text_view->layout,
+					iter, trailing, x, y);
 }
 
 /**
Index: gtk/gtktextview.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktextview.h,v
retrieving revision 1.45
diff -u -p -r1.45 gtktextview.h
--- gtk/gtktextview.h	2 Aug 2004 05:34:08 -0000	1.45
+++ gtk/gtktextview.h	4 Dec 2004 07:46:12 -0000
@@ -250,6 +250,11 @@ void           gtk_text_view_get_iter_at
                                                     GtkTextIter   *iter,
                                                     gint           x,
                                                     gint           y);
+void           gtk_text_view_get_iter_at_position  (GtkTextView   *text_view,
+                                                    GtkTextIter   *iter,
+						    gint          *trailing,
+                                                    gint           x,
+                                                    gint           y);
 void           gtk_text_view_get_line_yrange       (GtkTextView       *text_view,
                                                     const GtkTextIter *iter,
                                                     gint              *y,
Index: gtk/gtktextlayout.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktextlayout.c,v
retrieving revision 1.103
diff -u -p -r1.103 gtktextlayout.c
--- gtk/gtktextlayout.c	28 Nov 2004 06:06:57 -0000	1.103
+++ gtk/gtktextlayout.c	4 Dec 2004 07:46:12 -0000
@@ -2277,11 +2277,25 @@ gtk_text_layout_get_line_at_y (GtkTextLa
 
 void
 gtk_text_layout_get_iter_at_pixel (GtkTextLayout *layout,
-                                   GtkTextIter *target_iter,
-                                   gint x, gint y)
+                                   GtkTextIter   *target_iter,
+                                   gint           x, 
+				   gint           y)
+{
+  gint trailing;
+
+  gtk_text_layout_get_iter_at_position (layout, target_iter, &trailing, x, y);
+
+  gtk_text_iter_forward_chars (target_iter, trailing);  
+}
+
+void gtk_text_layout_get_iter_at_position (GtkTextLayout     *layout,
+					   GtkTextIter       *target_iter,
+					   gint              *trailing,
+					   gint               x,
+					   gint               y)
 {
   GtkTextLine *line;
-  gint byte_index, trailing;
+  gint byte_index;
   gint line_top;
   GtkTextLineDisplay *display;
 
@@ -2301,7 +2315,7 @@ gtk_text_layout_get_iter_at_pixel (GtkTe
   if (y > display->height - display->top_margin - display->bottom_margin)
     {
       byte_index = _gtk_text_line_byte_count (line);
-      trailing = 0;
+      *trailing = 0;
     }
   else
     {
@@ -2310,13 +2324,14 @@ gtk_text_layout_get_iter_at_pixel (GtkTe
         * x-direction.
         */
       pango_layout_xy_to_index (display->layout, x * PANGO_SCALE, y * PANGO_SCALE,
-                                &byte_index, &trailing);
+                                &byte_index, trailing);
     }
 
-  line_display_index_to_iter (layout, display, target_iter, byte_index, trailing);
+  line_display_index_to_iter (layout, display, target_iter, byte_index, 0);
 
   gtk_text_layout_free_line_display (layout, display);
 }
+
 
 /**
  * gtk_text_layout_get_cursor_locations:
Index: gtk/gtktextlayout.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktextlayout.h,v
retrieving revision 1.32
diff -u -p -r1.32 gtktextlayout.h
--- gtk/gtktextlayout.h	21 Nov 2004 16:24:00 -0000	1.32
+++ gtk/gtktextlayout.h	4 Dec 2004 07:46:13 -0000
@@ -319,6 +319,11 @@ void gtk_text_layout_get_iter_at_pixel (
                                         GtkTextIter       *iter,
                                         gint               x,
                                         gint               y);
+void gtk_text_layout_get_iter_at_position (GtkTextLayout     *layout,
+					   GtkTextIter       *iter,
+					   gint              *trailing,
+					   gint               x,
+					   gint               y);
 void gtk_text_layout_invalidate        (GtkTextLayout     *layout,
                                         const GtkTextIter *start,
                                         const GtkTextIter *end);
