font: Get rid of temporary cairo surface

i3 actually manages to have two different cairo surfaces referring to
the same drawable. One comes from the code in draw_util. The second is
temporarily created while rendering text via draw_text(). No idea how
well cairo handles this case.

This commit instead changes the code to pass the already existing cairo
surface from the caller through.

This might or might not fix https://github.com/i3/i3/pull/4357. My
thinking here is that cairo now knows the actual size of the drawable
and thus does not clip the drawing to a smaller size.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter
2021-03-05 11:37:03 +01:00
parent 8d645d0de6
commit b23c8875f7
3 changed files with 8 additions and 12 deletions

View File

@ -445,11 +445,13 @@ bool font_is_pango(void);
* specified coordinates (from the top left corner of the leftmost, uppermost
* glyph) and using the provided gc.
*
* The given cairo surface must refer to the specified X drawable.
*
* Text must be specified as an i3String.
*
*/
void draw_text(i3String *text, xcb_drawable_t drawable, xcb_gcontext_t gc,
xcb_visualtype_t *visual, int x, int y, int max_width);
cairo_surface_t *surface, int x, int y, int max_width);
/**
* Predict the text width in pixels for the given text. Text must be