draw: remove phys_screen from font handling

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-11-04 17:50:10 +01:00
parent 622e2f2a84
commit 8e66a543bc
6 changed files with 16 additions and 20 deletions

View file

@ -453,7 +453,7 @@ main(int argc, char **argv)
colors_reqs[1] = xcolor_init_unchecked(&globalconf.colors.bg,
"white", sizeof("white") - 1);
globalconf.font = draw_font_new(globalconf.default_screen, "sans 8");
globalconf.font = draw_font_new("sans 8");
/* init cursors */
globalconf.cursor[CurNormal] = xutil_cursor_new(globalconf.connection, XUTIL_CURSOR_LEFT_PTR);

22
draw.c
View file

@ -100,16 +100,15 @@ draw_screen_default_visual(xcb_screen_t *s)
return NULL;
}
/** Create a new Pango font
* \param phys_screen The physical screen number.
* \param fontname Pango fontname (e.g. [FAMILY-LIST] [STYLE-OPTIONS] [SIZE])
* \return a new font
/** Create a new Pango font.
* \param fontname Pango fontname (e.g. [FAMILY-LIST] [STYLE-OPTIONS] [SIZE]).
* \return A new font.
*/
font_t *
draw_font_new(int phys_screen, const char *fontname)
draw_font_new(const char *fontname)
{
cairo_surface_t *surface;
xcb_screen_t *s = xutil_screen_get(globalconf.connection, phys_screen);
xcb_screen_t *s = xutil_screen_get(globalconf.connection, globalconf.default_screen);
cairo_t *cr;
PangoLayout *layout;
font_t *font = p_new(font_t, 1);
@ -117,7 +116,7 @@ draw_font_new(int phys_screen, const char *fontname)
/* Create a dummy cairo surface, cairo context and pango layout in
* order to get font informations */
surface = cairo_xcb_surface_create(globalconf.connection,
phys_screen,
globalconf.default_screen,
draw_screen_default_visual(s),
s->width_in_pixels,
s->height_in_pixels);
@ -817,7 +816,6 @@ draw_rotate(draw_context_t *ctx,
}
/** Return the width and height of a text in pixel.
* \param phys_screen Physical screen number.
* \param font Font to use.
* \param text The text.
* \param len The text length.
@ -825,14 +823,13 @@ draw_rotate(draw_context_t *ctx,
* \return Text height and width.
*/
area_t
draw_text_extents(int phys_screen, font_t *font,
const char *text, ssize_t len, draw_parser_data_t *parser_data)
draw_text_extents(font_t *font, const char *text, ssize_t len, draw_parser_data_t *parser_data)
{
cairo_surface_t *surface;
cairo_t *cr;
PangoLayout *layout;
PangoRectangle ext;
xcb_screen_t *s = xutil_screen_get(globalconf.connection, phys_screen);
xcb_screen_t *s = xutil_screen_get(globalconf.connection, globalconf.default_screen);
area_t geom = { 0, 0, 0, 0 };
if(!len)
@ -841,7 +838,8 @@ draw_text_extents(int phys_screen, font_t *font,
if(!draw_text_markup_expand(parser_data, text, len))
return geom;
surface = cairo_xcb_surface_create(globalconf.connection, phys_screen,
surface = cairo_xcb_surface_create(globalconf.connection,
globalconf.default_screen,
draw_screen_default_visual(s),
s->width_in_pixels,
s->height_in_pixels);

4
draw.h
View file

@ -128,7 +128,7 @@ draw_context_wipe(draw_context_t *ctx)
}
}
font_t *draw_font_new(int, const char *);
font_t *draw_font_new(const char *);
void draw_font_delete(font_t **);
char * draw_iso2utf8(const char *, size_t);
@ -191,7 +191,7 @@ void draw_graph_line(draw_context_t *, area_t, int *, int, position_t, vector_t,
const xcolor_t *, const xcolor_t *, const xcolor_t *);
void draw_image(draw_context_t *, int, int, int, image_t *);
void draw_rotate(draw_context_t *, xcb_drawable_t, xcb_drawable_t, int, int, int, int, double, int, int);
area_t draw_text_extents(int, font_t *, const char *, ssize_t, draw_parser_data_t *);
area_t draw_text_extents(font_t *, const char *, ssize_t, draw_parser_data_t *);
alignment_t draw_align_fromstr(const char *, ssize_t);
const char *draw_align_tostr(alignment_t);

2
luaa.c
View file

@ -156,7 +156,7 @@ luaA_font(lua_State *L)
{
const char *newfont = luaL_checkstring(L, 1);
draw_font_delete(&globalconf.font);
globalconf.font = draw_font_new(globalconf.default_screen, newfont);
globalconf.font = draw_font_new(newfont);
}
font = pango_font_description_to_string(globalconf.font->desc);

View file

@ -283,8 +283,7 @@ mouse_infobox_new(simple_window_t *sw, int phys_screen, int border, area_t geome
draw_parser_data_init(&pdata);
geom = draw_text_extents(globalconf.default_screen,
globalconf.font,
geom = draw_text_extents(globalconf.font,
MOUSE_INFOBOX_STRING_DEFAULT,
sizeof(MOUSE_INFOBOX_STRING_DEFAULT)-1,
&pdata);

View file

@ -146,8 +146,7 @@ luaA_textbox_newindex(lua_State *L, awesome_token_t token)
if(buf)
{
a_iso2utf8(&d->text, buf, len);
d->extents = draw_text_extents(globalconf.default_screen,
globalconf.font, d->text, d->len, &d->pdata).width;
d->extents = draw_text_extents(globalconf.font, d->text, d->len, &d->pdata).width;
}
else
d->extents = 0;