Commit df37446f authored by Benjamin Otte's avatar Benjamin Otte

textview: Remove extra magic for drawing children

Instead, just draw the children. The cairo code will keep track of
things, so there's no need to track things.
Also, the old code was doing it wrong.

https://bugzilla.gnome.org/show_bug.cgi?id=672544
parent 7a7e2ed9
...@@ -108,7 +108,6 @@ struct _GtkTextRenderer ...@@ -108,7 +108,6 @@ struct _GtkTextRenderer
cairo_t *cr; cairo_t *cr;
GdkRGBA *error_color; /* Error underline color for this widget */ GdkRGBA *error_color; /* Error underline color for this widget */
GList *widgets; /* widgets encountered when drawing */
GdkRGBA rgba[4]; GdkRGBA rgba[4];
guint8 rgba_set[4]; guint8 rgba_set[4];
...@@ -423,12 +422,7 @@ gtk_text_renderer_draw_shape (PangoRenderer *renderer, ...@@ -423,12 +422,7 @@ gtk_text_renderer_draw_shape (PangoRenderer *renderer,
} }
else if (GTK_IS_WIDGET (attr->data)) else if (GTK_IS_WIDGET (attr->data))
{ {
GtkWidget *widget; /* nothing to do */
widget = GTK_WIDGET (attr->data);
text_renderer->widgets = g_list_prepend (text_renderer->widgets,
g_object_ref (widget));
} }
else else
g_assert_not_reached (); /* not a pixbuf or widget */ g_assert_not_reached (); /* not a pixbuf or widget */
...@@ -497,11 +491,10 @@ text_renderer_begin (GtkTextRenderer *text_renderer, ...@@ -497,11 +491,10 @@ text_renderer_begin (GtkTextRenderer *text_renderer,
/* Returns a GSList of (referenced) widgets encountered while drawing. /* Returns a GSList of (referenced) widgets encountered while drawing.
*/ */
static GList * static void
text_renderer_end (GtkTextRenderer *text_renderer) text_renderer_end (GtkTextRenderer *text_renderer)
{ {
GtkStyleContext *context; GtkStyleContext *context;
GList *widgets = text_renderer->widgets;
cairo_restore (text_renderer->cr); cairo_restore (text_renderer->cr);
...@@ -512,15 +505,11 @@ text_renderer_end (GtkTextRenderer *text_renderer) ...@@ -512,15 +505,11 @@ text_renderer_end (GtkTextRenderer *text_renderer)
text_renderer->widget = NULL; text_renderer->widget = NULL;
text_renderer->cr = NULL; text_renderer->cr = NULL;
text_renderer->widgets = NULL;
if (text_renderer->error_color) if (text_renderer->error_color)
{ {
gdk_rgba_free (text_renderer->error_color); gdk_rgba_free (text_renderer->error_color);
text_renderer->error_color = NULL; text_renderer->error_color = NULL;
} }
return widgets;
} }
static cairo_region_t * static cairo_region_t *
...@@ -816,8 +805,7 @@ get_text_renderer (void) ...@@ -816,8 +805,7 @@ get_text_renderer (void)
void void
gtk_text_layout_draw (GtkTextLayout *layout, gtk_text_layout_draw (GtkTextLayout *layout,
GtkWidget *widget, GtkWidget *widget,
cairo_t *cr, cairo_t *cr)
GList **widgets)
{ {
GtkStyleContext *context; GtkStyleContext *context;
gint offset_y; gint offset_y;
...@@ -826,7 +814,6 @@ gtk_text_layout_draw (GtkTextLayout *layout, ...@@ -826,7 +814,6 @@ gtk_text_layout_draw (GtkTextLayout *layout,
gboolean have_selection; gboolean have_selection;
GSList *line_list; GSList *line_list;
GSList *tmp_list; GSList *tmp_list;
GList *tmp_widgets;
GdkRectangle clip; GdkRectangle clip;
g_return_if_fail (GTK_IS_TEXT_LAYOUT (layout)); g_return_if_fail (GTK_IS_TEXT_LAYOUT (layout));
...@@ -931,11 +918,7 @@ gtk_text_layout_draw (GtkTextLayout *layout, ...@@ -931,11 +918,7 @@ gtk_text_layout_draw (GtkTextLayout *layout,
gtk_text_layout_wrap_loop_end (layout); gtk_text_layout_wrap_loop_end (layout);
tmp_widgets = text_renderer_end (text_renderer); text_renderer_end (text_renderer);
if (widgets)
*widgets = tmp_widgets;
else
g_list_free_full (tmp_widgets, g_object_unref);
g_slist_free (line_list); g_slist_free (line_list);
} }
...@@ -92,8 +92,7 @@ G_BEGIN_DECLS ...@@ -92,8 +92,7 @@ G_BEGIN_DECLS
*/ */
void gtk_text_layout_draw (GtkTextLayout *layout, void gtk_text_layout_draw (GtkTextLayout *layout,
GtkWidget *widget, GtkWidget *widget,
cairo_t *cr, cairo_t *cr);
GList **widgets);
G_END_DECLS G_END_DECLS
......
...@@ -398,7 +398,7 @@ _gtk_text_util_create_rich_drag_icon (GtkWidget *widget, ...@@ -398,7 +398,7 @@ _gtk_text_util_create_rich_drag_icon (GtkWidget *widget,
cairo_save (cr); cairo_save (cr);
cairo_translate (cr, 1 + DRAG_ICON_LAYOUT_BORDER, 1 + DRAG_ICON_LAYOUT_BORDER); cairo_translate (cr, 1 + DRAG_ICON_LAYOUT_BORDER, 1 + DRAG_ICON_LAYOUT_BORDER);
gtk_text_layout_draw (layout, widget, cr, NULL); gtk_text_layout_draw (layout, widget, cr);
cairo_restore (cr); cairo_restore (cr);
......
...@@ -4804,8 +4804,6 @@ gtk_text_view_paint (GtkWidget *widget, ...@@ -4804,8 +4804,6 @@ gtk_text_view_paint (GtkWidget *widget,
{ {
GtkTextView *text_view; GtkTextView *text_view;
GtkTextViewPrivate *priv; GtkTextViewPrivate *priv;
GList *child_exposes;
GList *tmp_list;
text_view = GTK_TEXT_VIEW (widget); text_view = GTK_TEXT_VIEW (widget);
priv = text_view->priv; priv = text_view->priv;
...@@ -4833,33 +4831,14 @@ gtk_text_view_paint (GtkWidget *widget, ...@@ -4833,33 +4831,14 @@ gtk_text_view_paint (GtkWidget *widget,
area->width, area->height); area->width, area->height);
#endif #endif
child_exposes = NULL;
cairo_save (cr); cairo_save (cr);
cairo_translate (cr, -priv->xoffset, -priv->yoffset); cairo_translate (cr, -priv->xoffset, -priv->yoffset);
gtk_text_layout_draw (priv->layout, gtk_text_layout_draw (priv->layout,
widget, widget,
cr, cr);
&child_exposes);
cairo_restore (cr); cairo_restore (cr);
tmp_list = child_exposes;
while (tmp_list != NULL)
{
GtkWidget *child = tmp_list->data;
gtk_container_propagate_draw (GTK_CONTAINER (text_view),
child,
cr);
g_object_unref (child);
tmp_list = tmp_list->next;
}
g_list_free (child_exposes);
} }
static gboolean static gboolean
...@@ -4894,10 +4873,9 @@ gtk_text_view_draw (GtkWidget *widget, ...@@ -4894,10 +4873,9 @@ gtk_text_view_draw (GtkWidget *widget,
/* propagate_draw checks that event->window matches /* propagate_draw checks that event->window matches
* child->window * child->window
*/ */
if (!vc->anchor) gtk_container_propagate_draw (GTK_CONTAINER (widget),
gtk_container_propagate_draw (GTK_CONTAINER (widget), vc->widget,
vc->widget, cr);
cr);
tmp_list = tmp_list->next; tmp_list = tmp_list->next;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment