From 2be259b24a5cd25efc8375207ac1a3bc1ceb9c62 Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Tue, 26 Aug 2003 00:06:18 +0000 Subject: [PATCH] Since we add one to the layout's reported width to account for the cursor, Mon Aug 25 19:55:55 2003 Owen Taylor * gtk/gtktextview.c (gtk_text_view_update_layout_width): Since we add one to the layout's reported width to account for the cursor, we need to subtract one when setting the wrap width for the layout. (Fixes infinite loop (#120325, Federico Crozat) * gtk/gtktextlayout.c (gtk_text_layout_get_line_display): Be a bit more careful about rounding when converting wrapped width from Pango units to pixels. --- ChangeLog | 12 ++++++++++++ ChangeLog.pre-2-10 | 12 ++++++++++++ ChangeLog.pre-2-4 | 12 ++++++++++++ ChangeLog.pre-2-6 | 12 ++++++++++++ ChangeLog.pre-2-8 | 12 ++++++++++++ gtk/gtktextlayout.c | 4 +++- gtk/gtktextview.c | 6 ++++-- 7 files changed, 67 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 78ea6e6746..6f25b59035 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Mon Aug 25 19:55:55 2003 Owen Taylor + + * gtk/gtktextview.c (gtk_text_view_update_layout_width): + Since we add one to the layout's reported width to + account for the cursor, we need to subtract one when + setting the wrap width for the layout. (Fixes infinite + loop (#120325, Federico Crozat) + + * gtk/gtktextlayout.c (gtk_text_layout_get_line_display): + Be a bit more careful about rounding when converting + wrapped width from Pango units to pixels. + 2003-08-26 Matthias Clasen Rename GtkMenuMerge to GtkUIManager. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 78ea6e6746..6f25b59035 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,15 @@ +Mon Aug 25 19:55:55 2003 Owen Taylor + + * gtk/gtktextview.c (gtk_text_view_update_layout_width): + Since we add one to the layout's reported width to + account for the cursor, we need to subtract one when + setting the wrap width for the layout. (Fixes infinite + loop (#120325, Federico Crozat) + + * gtk/gtktextlayout.c (gtk_text_layout_get_line_display): + Be a bit more careful about rounding when converting + wrapped width from Pango units to pixels. + 2003-08-26 Matthias Clasen Rename GtkMenuMerge to GtkUIManager. diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 78ea6e6746..6f25b59035 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,15 @@ +Mon Aug 25 19:55:55 2003 Owen Taylor + + * gtk/gtktextview.c (gtk_text_view_update_layout_width): + Since we add one to the layout's reported width to + account for the cursor, we need to subtract one when + setting the wrap width for the layout. (Fixes infinite + loop (#120325, Federico Crozat) + + * gtk/gtktextlayout.c (gtk_text_layout_get_line_display): + Be a bit more careful about rounding when converting + wrapped width from Pango units to pixels. + 2003-08-26 Matthias Clasen Rename GtkMenuMerge to GtkUIManager. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 78ea6e6746..6f25b59035 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,15 @@ +Mon Aug 25 19:55:55 2003 Owen Taylor + + * gtk/gtktextview.c (gtk_text_view_update_layout_width): + Since we add one to the layout's reported width to + account for the cursor, we need to subtract one when + setting the wrap width for the layout. (Fixes infinite + loop (#120325, Federico Crozat) + + * gtk/gtktextlayout.c (gtk_text_layout_get_line_display): + Be a bit more careful about rounding when converting + wrapped width from Pango units to pixels. + 2003-08-26 Matthias Clasen Rename GtkMenuMerge to GtkUIManager. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 78ea6e6746..6f25b59035 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,15 @@ +Mon Aug 25 19:55:55 2003 Owen Taylor + + * gtk/gtktextview.c (gtk_text_view_update_layout_width): + Since we add one to the layout's reported width to + account for the cursor, we need to subtract one when + setting the wrap width for the layout. (Fixes infinite + loop (#120325, Federico Crozat) + + * gtk/gtktextlayout.c (gtk_text_layout_get_line_display): + Be a bit more careful about rounding when converting + wrapped width from Pango units to pixels. + 2003-08-26 Matthias Clasen Rename GtkMenuMerge to GtkUIManager. diff --git a/gtk/gtktextlayout.c b/gtk/gtktextlayout.c index 52e7781371..3fed7624c4 100644 --- a/gtk/gtktextlayout.c +++ b/gtk/gtktextlayout.c @@ -122,6 +122,8 @@ enum { LAST_ARG }; +#define PIXEL_BOUND(d) (((d) + PANGO_SCALE - 1) / PANGO_SCALE) + static void gtk_text_layout_init (GtkTextLayout *text_layout); static void gtk_text_layout_class_init (GtkTextLayoutClass *klass); static void gtk_text_layout_finalize (GObject *object); @@ -1972,7 +1974,7 @@ gtk_text_layout_get_line_display (GtkTextLayout *layout, pango_layout_get_extents (display->layout, NULL, &extents); - display->width = PANGO_PIXELS (extents.width) + display->left_margin + display->right_margin; + display->width = PIXEL_BOUND (extents.width) + display->left_margin + display->right_margin; display->height += PANGO_PIXELS (extents.height); /* Free this if we aren't in a loop */ diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index 0b748f81f0..c79c136a65 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -94,6 +94,8 @@ #define SCREEN_WIDTH(widget) text_window_get_width (GTK_TEXT_VIEW (widget)->text_window) #define SCREEN_HEIGHT(widget) text_window_get_height (GTK_TEXT_VIEW (widget)->text_window) +#define SPACE_FOR_CURSOR 1 + struct _GtkTextPendingScroll { GtkTextMark *mark; @@ -1702,7 +1704,7 @@ gtk_text_view_update_adjustments (GtkTextView *text_view) gtk_text_layout_get_size (text_view->layout, &width, &height); /* Make room for the cursor after the last character in the widest line */ - width++; + width += SPACE_FOR_CURSOR; if (text_view->width != width || text_view->height != height) { @@ -1742,7 +1744,7 @@ gtk_text_view_update_layout_width (GtkTextView *text_view) gtk_text_view_ensure_layout (text_view); gtk_text_layout_set_screen_width (text_view->layout, - SCREEN_WIDTH (text_view)); + MAX (1, SCREEN_WIDTH (text_view) - SPACE_FOR_CURSOR)); } static void