After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 316712 - gtkentry initial rendering bug w/ scroll_offset
gtkentry initial rendering bug w/ scroll_offset
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
2.8.x
Other All
: Normal trivial
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2005-09-19 15:50 UTC by Dan Winship
Modified: 2006-03-08 14:46 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Dan Winship 2005-09-19 15:50:23 UTC
When a GtkEntry is first created, it will have a scroll_offset of 3
(the initial dummy allocation.width minus 2 * INNER_BORDER, negated).
Under some circumstances (that I can't find a simple test case for), it will
actually render the text with this scroll_offset, and then re-render it
immediately afterward with a scroll_offset of 0 when the allocation is set to
its correct value, causing the text to jump 3 pixels.

This patch fixes the initial setting of scroll_offset.

Index: gtk/gtkentry.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkentry.c,v
retrieving revision 1.284.2.1
diff -u -r1.284.2.1 gtkentry.c
--- gtk/gtkentry.c      2 Sep 2005 19:51:06 -0000       1.284.2.1
+++ gtk/gtkentry.c      19 Sep 2005 15:42:16 -0000
@@ -3419,6 +3419,8 @@

   gdk_drawable_get_size (entry->text_area, &text_area_width, NULL);
   text_area_width -= 2 * INNER_BORDER;
+  if (text_area_width < 0)
+    text_area_width = 0;

   layout = gtk_entry_ensure_layout (entry, TRUE);
   line = pango_layout_get_lines (layout)->data;
Comment 1 Tim Janik 2006-03-08 13:54:49 UTC
i know i've seen this as well, in particular when entries were used for temporary editing context such as in a canvas. unfortunately i don't have a test case handy either.
the above patch still does make sense to me, the drawable width shouldn't ever be negative, and the width shrunken by INNER_BORDER still shouldn't be negative.
Comment 2 Michael Natterer 2006-03-08 14:05:19 UTC
Fixed in HEAD:

2006-03-08  Michael Natterer  <mitch@imendio.com>

	* gtk/gtkentry.c (gtk_entry_adjust_scroll): make sure that the
	text_area_width is always >= 0. Fixes bug #316712 (Dan Winship).
Comment 3 Tim Janik 2006-03-08 14:46:19 UTC
applied to gtk-2-8 as well.