]> Pileus Git - ~andy/gtk/commitdiff
clamp cursor coordinates to window bounds (fix from Maemo Gtk).
authorTim Janik <timj@imendio.com>
Fri, 26 Jan 2007 12:26:01 +0000 (12:26 +0000)
committerTim Janik <timj@src.gnome.org>
Fri, 26 Jan 2007 12:26:01 +0000 (12:26 +0000)
Fri Jan 26 13:07:07 2007  Tim Janik  <timj@imendio.com>

        * gtk/gtkstyle.c (draw_insertion_cursor): clamp cursor coordinates to
        window bounds (fix from Maemo Gtk).

svn path=/trunk/; revision=17217

ChangeLog
gtk/gtkstyle.c

index eb27a334835f0431f8348ec6d61ea5870a054781..d4ee62567c948380fda746c50cbff5e48f3d1df7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Jan 26 13:07:07 2007  Tim Janik  <timj@imendio.com>
+
+       * gtk/gtkstyle.c (draw_insertion_cursor): clamp cursor coordinates to
+       window bounds (fix from Maemo Gtk).
+
 2007-01-26  Michael Natterer  <mitch@imendio.com>
 
        * gtk/gtkentrycompletion.c (gtk_entry_completion_insert_prefix):
index 44b7d6eff7661cd67af39718c48120129b5a38e1..a673e4fcfd6f3aefef41aca391ce25732c7f6c23 100644 (file)
@@ -6677,6 +6677,7 @@ draw_insertion_cursor (GtkWidget        *widget,
   gint i;
   gfloat cursor_aspect_ratio;
   gint offset;
+  gint window_width;
   
   /* When changing the shape or size of the cursor here,
    * propagate the changes to gtktextview.c:text_window_invalidate_cursors().
@@ -6693,6 +6694,13 @@ draw_insertion_cursor (GtkWidget        *widget,
   else
     offset = stem_width - stem_width / 2;
   
+  gdk_drawable_get_size (widget->window, &window_width, NULL);
+
+  if (location->x - offset < 0 && direction == GTK_TEXT_DIR_LTR)
+    location->x += ABS (location->x - offset);
+  else if (location->x + offset > window_width && direction == GTK_TEXT_DIR_RTL)
+    location->x -= location->x + offset - window_width;
+
   for (i = 0; i < stem_width; i++)
     gdk_draw_line (drawable, gc,
                   location->x + i - offset, location->y,