aboutsummaryrefslogtreecommitdiff
path: root/src/draw.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/draw.c')
-rw-r--r--src/draw.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/draw.c b/src/draw.c
index c6c18a2..f571671 100644
--- a/src/draw.c
+++ b/src/draw.c
@@ -195,7 +195,7 @@ static void layout_set_text(Layout *layout, PangoFontDescription *desc, int heig
layout->height = height;
}
-static GList *compute_group_layout(Drawer *draw, Window *win, GList *btns, int bx, bool root)
+static GList *compute_group_layout(Drawer *draw, GList *btns, int bx, bool root)
{
GList *layouts = NULL;
for (GList *it = btns; it; it = it->next) {
@@ -222,7 +222,7 @@ retry:
g_assert_true(btn->simple);
goto retry;
} else {
- layout->children = compute_group_layout(draw, win, group->children, bx, false);
+ layout->children = compute_group_layout(draw, group->children, bx, false);
g_assert_nonnull(layout->children);
Layout *last = g_list_last(layout->children)->data;
@@ -242,7 +242,7 @@ retry:
layout->width -= 1;
}
} else {
- layout->pl = pango_cairo_create_layout(window_get_context(win));
+ layout->pl = pango_layout_new(draw->ctx);
layout_set_text(layout, draw->desc, draw->height);
}
@@ -273,8 +273,11 @@ void draw_compute_layout(Drawer *draw, Window *win, GList *btns)
memset(draw->layout_end, 0, sizeof(draw->layout_end));
memset(draw->layout_bx, 0, sizeof(draw->layout_bx));
+ g_assert_null(draw->ctx);
+ draw->ctx = pango_cairo_create_context(window_get_context(win));
+
g_list_free_full(draw->layouts, (GDestroyNotify)layout_destroy);
- draw->layouts = compute_group_layout(draw, win, btns, 0, true);
+ draw->layouts = compute_group_layout(draw, btns, 0, true);
draw->layout_width[PANGO_ALIGN_LEFT] = draw->layout_bx[PANGO_ALIGN_LEFT];
draw->layout_width[PANGO_ALIGN_CENTER] = draw->layout_bx[PANGO_ALIGN_CENTER] - draw->layout_bx[PANGO_ALIGN_LEFT];
@@ -308,6 +311,7 @@ void draw_compute_layout(Drawer *draw, Window *win, GList *btns)
}
log_debug("Updated layouts");
+ g_clear_pointer(&draw->ctx, g_object_unref);
}
void draw_set_background(Drawer *draw, Color background)