From 5137409a90489e025372aadae92334d8f6267a6f Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Thu, 30 Aug 2001 19:09:09 +0000 Subject: [PATCH] handle NULL shaped object from the empty-child-anchor case by drawing a 2001-08-30 Havoc Pennington * gtk/gtktextdisplay.c (render_layout_line): handle NULL shaped object from the empty-child-anchor case by drawing a little box. * gtk/gtktextlayout.c (add_child_attrs): Still set shape attribute if the child anchor has no anchored widgets - fixes #59328. Also, remove bizarre deletion of preedit string that seems to have gotten in here somehow. --- ChangeLog | 11 +++++++++++ ChangeLog.pre-2-0 | 11 +++++++++++ ChangeLog.pre-2-10 | 11 +++++++++++ ChangeLog.pre-2-2 | 11 +++++++++++ ChangeLog.pre-2-4 | 11 +++++++++++ ChangeLog.pre-2-6 | 11 +++++++++++ ChangeLog.pre-2-8 | 11 +++++++++++ gtk/gtktextdisplay.c | 34 ++++++++++++++++++++++++++++++++-- gtk/gtktextlayout.c | 29 ++++++++++++++--------------- 9 files changed, 123 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index e163aab2e..21e375642 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2001-08-30 Havoc Pennington + + * gtk/gtktextdisplay.c (render_layout_line): handle NULL shaped + object from the empty-child-anchor case by drawing a little box. + + * gtk/gtktextlayout.c (add_child_attrs): Still set shape attribute + if the child anchor has no anchored widgets - fixes #59328. + + Also, remove bizarre deletion of preedit string that seems to have + gotten in here somehow. + 2001-08-30 Havoc Pennington * gtk/gtktextview.c (gtk_text_view_check_cursor_blink): apply fix diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index e163aab2e..21e375642 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,14 @@ +2001-08-30 Havoc Pennington + + * gtk/gtktextdisplay.c (render_layout_line): handle NULL shaped + object from the empty-child-anchor case by drawing a little box. + + * gtk/gtktextlayout.c (add_child_attrs): Still set shape attribute + if the child anchor has no anchored widgets - fixes #59328. + + Also, remove bizarre deletion of preedit string that seems to have + gotten in here somehow. + 2001-08-30 Havoc Pennington * gtk/gtktextview.c (gtk_text_view_check_cursor_blink): apply fix diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index e163aab2e..21e375642 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,14 @@ +2001-08-30 Havoc Pennington + + * gtk/gtktextdisplay.c (render_layout_line): handle NULL shaped + object from the empty-child-anchor case by drawing a little box. + + * gtk/gtktextlayout.c (add_child_attrs): Still set shape attribute + if the child anchor has no anchored widgets - fixes #59328. + + Also, remove bizarre deletion of preedit string that seems to have + gotten in here somehow. + 2001-08-30 Havoc Pennington * gtk/gtktextview.c (gtk_text_view_check_cursor_blink): apply fix diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index e163aab2e..21e375642 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,14 @@ +2001-08-30 Havoc Pennington + + * gtk/gtktextdisplay.c (render_layout_line): handle NULL shaped + object from the empty-child-anchor case by drawing a little box. + + * gtk/gtktextlayout.c (add_child_attrs): Still set shape attribute + if the child anchor has no anchored widgets - fixes #59328. + + Also, remove bizarre deletion of preedit string that seems to have + gotten in here somehow. + 2001-08-30 Havoc Pennington * gtk/gtktextview.c (gtk_text_view_check_cursor_blink): apply fix diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index e163aab2e..21e375642 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,14 @@ +2001-08-30 Havoc Pennington + + * gtk/gtktextdisplay.c (render_layout_line): handle NULL shaped + object from the empty-child-anchor case by drawing a little box. + + * gtk/gtktextlayout.c (add_child_attrs): Still set shape attribute + if the child anchor has no anchored widgets - fixes #59328. + + Also, remove bizarre deletion of preedit string that seems to have + gotten in here somehow. + 2001-08-30 Havoc Pennington * gtk/gtktextview.c (gtk_text_view_check_cursor_blink): apply fix diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index e163aab2e..21e375642 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,14 @@ +2001-08-30 Havoc Pennington + + * gtk/gtktextdisplay.c (render_layout_line): handle NULL shaped + object from the empty-child-anchor case by drawing a little box. + + * gtk/gtktextlayout.c (add_child_attrs): Still set shape attribute + if the child anchor has no anchored widgets - fixes #59328. + + Also, remove bizarre deletion of preedit string that seems to have + gotten in here somehow. + 2001-08-30 Havoc Pennington * gtk/gtktextview.c (gtk_text_view_check_cursor_blink): apply fix diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index e163aab2e..21e375642 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,14 @@ +2001-08-30 Havoc Pennington + + * gtk/gtktextdisplay.c (render_layout_line): handle NULL shaped + object from the empty-child-anchor case by drawing a little box. + + * gtk/gtktextlayout.c (add_child_attrs): Still set shape attribute + if the child anchor has no anchored widgets - fixes #59328. + + Also, remove bizarre deletion of preedit string that seems to have + gotten in here somehow. + 2001-08-30 Havoc Pennington * gtk/gtktextview.c (gtk_text_view_check_cursor_blink): apply fix diff --git a/gtk/gtktextdisplay.c b/gtk/gtktextdisplay.c index 9149886c4..d5b5f5018 100644 --- a/gtk/gtktextdisplay.c +++ b/gtk/gtktextdisplay.c @@ -297,8 +297,38 @@ render_layout_line (GdkDrawable *drawable, GObject *shaped = (*shaped_pointer)->data; *shaped_pointer = (*shaped_pointer)->next; - - if (GDK_IS_PIXBUF (shaped)) + + if (shaped == NULL) + { + /* This happens if we have an empty widget anchor. Draw + * something empty-looking. + */ + GdkRectangle shape_rect, draw_rect; + + shape_rect.x = x + x_off / PANGO_SCALE; + shape_rect.y = risen_y - PANGO_PIXELS (logical_rect.height); + shape_rect.width = PANGO_PIXELS (logical_rect.width); + shape_rect.height = PANGO_PIXELS (logical_rect.height); + + if (gdk_rectangle_intersect (&shape_rect, &render_state->clip_rect, + &draw_rect)) + { + gdk_draw_rectangle (drawable, render_state->fg_gc, + FALSE, shape_rect.x, shape_rect.y, + shape_rect.width, shape_rect.height); + + gdk_draw_line (drawable, render_state->fg_gc, + shape_rect.x, shape_rect.y, + shape_rect.x + shape_rect.width, + shape_rect.y + shape_rect.height); + + gdk_draw_line (drawable, render_state->fg_gc, + shape_rect.x + shape_rect.width, shape_rect.y, + shape_rect.x, + shape_rect.y + shape_rect.height); + } + } + else if (GDK_IS_PIXBUF (shaped)) { gint width, height; GdkRectangle pixbuf_rect, draw_rect; diff --git a/gtk/gtktextlayout.c b/gtk/gtktextlayout.c index 26bd73e25..c1aba56b1 100644 --- a/gtk/gtktextlayout.c +++ b/gtk/gtktextlayout.c @@ -1411,23 +1411,19 @@ add_child_attrs (GtkTextLayout *layout, if (tmp_list == NULL) { - /* No widget at this anchor in this display; - * not an error. + /* If tmp_list == NULL then there is no widget at this anchor in + * this display; not an error. We make up an arbitrary size + * to use, just so the programmer can see the blank spot. + * We also put a NULL in the shaped objects list, to keep + * the correspondence between the list and the shaped chars in + * the layout. A bad hack, yes. */ - return; - } - - if (layout->preedit_string) - { - g_free (layout->preedit_string); - layout->preedit_string = NULL; - } + width = 30; + height = 20; - if (layout->preedit_attrs) - { - pango_attr_list_unref (layout->preedit_attrs); - layout->preedit_attrs = NULL; + display->shaped_objects = + g_slist_append (display->shaped_objects, NULL); } logical_rect.x = 0; @@ -1540,7 +1536,10 @@ allocate_child_widgets (GtkTextLayout *text_layout, GObject *shaped_object = shaped->data; shaped = shaped->next; - if (GTK_IS_WIDGET (shaped_object)) + /* shaped_object is NULL for child anchors with no + * widgets stored at them + */ + if (shaped_object && GTK_IS_WIDGET (shaped_object)) { PangoRectangle extents; -- 2.43.2