diff --git a/awesome-menu.c b/awesome-menu.c index 6be733604..c11091e3a 100644 --- a/awesome-menu.c +++ b/awesome-menu.c @@ -431,7 +431,7 @@ redraw(void) if(a_strlen(globalconf.prompt)) { - draw_text(globalconf.ctx, geometry, globalconf.prompt, globalconf.styles.focus); + draw_text(globalconf.ctx, geometry, globalconf.prompt, &globalconf.styles.focus); len = MARGIN * 2 + draw_text_extents(globalconf.connection, globalconf.default_screen, globalconf.styles.focus.font, globalconf.prompt).width; @@ -439,7 +439,7 @@ redraw(void) geometry.width -= len; } - draw_text(globalconf.ctx, geometry, globalconf.text, globalconf.styles.normal); + draw_text(globalconf.ctx, geometry, globalconf.text, &globalconf.styles.normal); len = MARGIN * 2 + MAX(draw_text_extents(globalconf.connection, globalconf.default_screen, globalconf.styles.normal.font, globalconf.text).width, @@ -461,7 +461,7 @@ redraw(void) else selected_item_is_drawn = true; } - draw_text(globalconf.ctx, geometry, item->data, style); + draw_text(globalconf.ctx, geometry, item->data, &style); geometry.x += len; geometry.width -= len; } @@ -483,7 +483,7 @@ redraw(void) if(geometry.x < prompt_len) break; - draw_text(globalconf.ctx, geometry, item->data, style); + draw_text(globalconf.ctx, geometry, item->data, &style); } if(item) diff --git a/awesome-message.c b/awesome-message.c index 5283581be..16b0ba587 100644 --- a/awesome-message.c +++ b/awesome-message.c @@ -211,7 +211,7 @@ main(int argc, char **argv) geometry.width, geometry.height, sw->drawable); geometry.x = geometry.y = 0; - draw_text(ctx, geometry, argv[optind], globalconf.style); + draw_text(ctx, geometry, argv[optind], &globalconf.style); if(icon_geometry.width > 0 && icon_geometry.height > 0) draw_image(ctx, 0, (geometry.height / 2) - (globalconf.style.font->height / 2), diff --git a/common/draw.c b/common/draw.c index 4e12f079c..28561159d 100644 --- a/common/draw.c +++ b/common/draw.c @@ -285,14 +285,14 @@ draw_text_markup_expand(draw_parser_data_t *data, return true; } -/** Draw text into a draw context - * \param ctx draw_context_t to draw to - * \param area area to draw to - * \param text text to draw - * \return area_t with width and height are set to what used +/** Draw text into a draw context. + * \param ctx Draw context to draw to. + * \param area Area to draw to. + * \param text Text to draw. + * \param style A pointer to the style to use. */ void -draw_text(draw_context_t *ctx, area_t area, const char *text, style_t style) +draw_text(draw_context_t *ctx, area_t area, const char *text, const style_t *style) { int x, y; ssize_t len, olen; @@ -326,7 +326,7 @@ draw_text(draw_context_t *ctx, area_t area, const char *text, style_t style) if(parser_data.has_bg_color) draw_rectangle(ctx, area, 1.0, true, parser_data.bg_color); else - draw_rectangle(ctx, area, 1.0, true, style.bg); + draw_rectangle(ctx, area, 1.0, true, style->bg); pango_layout_set_width(ctx->layout, pango_units_from_double(area.width @@ -334,14 +334,14 @@ draw_text(draw_context_t *ctx, area_t area, const char *text, style_t style) + parser_data.margin.right))); pango_layout_set_ellipsize(ctx->layout, PANGO_ELLIPSIZE_END); pango_layout_set_markup(ctx->layout, buf, len); - pango_layout_set_font_description(ctx->layout, style.font->desc); + pango_layout_set_font_description(ctx->layout, style->font->desc); pango_layout_get_pixel_extents(ctx->layout, NULL, &ext); x = area.x + parser_data.margin.left; /* + 1 is added for rounding, so that in any case of doubt we rather draw * the text 1px lower than too high which usually results in a better type * face */ - y = area.y + (ctx->height - style.font->height + 1) / 2; + y = area.y + (ctx->height - style->font->height + 1) / 2; switch(parser_data.align) { @@ -359,8 +359,8 @@ draw_text(draw_context_t *ctx, area_t area, const char *text, style_t style) p_clear(&shadow, 1); if(parser_data.shadow.offset) shadow = parser_data.shadow; - else if(style.shadow.offset) - shadow = style.shadow; + else if(style->shadow.offset) + shadow = style->shadow; if(shadow.offset) { @@ -376,9 +376,9 @@ draw_text(draw_context_t *ctx, area_t area, const char *text, style_t style) cairo_move_to(ctx->cr, x, y); cairo_set_source_rgb(ctx->cr, - style.fg.red / 65535.0, - style.fg.green / 65535.0, - style.fg.blue / 65535.0); + style->fg.red / 65535.0, + style->fg.green / 65535.0, + style->fg.blue / 65535.0); pango_cairo_update_layout(ctx->cr, ctx->layout); pango_cairo_show_layout(ctx->cr, ctx->layout); diff --git a/common/draw.h b/common/draw.h index e907ae861..f4feba761 100644 --- a/common/draw.h +++ b/common/draw.h @@ -130,7 +130,7 @@ void draw_context_delete(draw_context_t **); font_t *draw_font_new(xcb_connection_t *, int, char *); void draw_font_delete(font_t **); -void draw_text(draw_context_t *, area_t, const char *, style_t); +void draw_text(draw_context_t *, area_t, const char *, const style_t *); void draw_rectangle(draw_context_t *, area_t, float, bool, xcolor_t); void draw_rectangle_gradient(draw_context_t *, area_t, float, bool, area_t, xcolor_t *, xcolor_t *, xcolor_t *); diff --git a/mouse.c b/mouse.c index ac3301b07..2bbb8919d 100644 --- a/mouse.c +++ b/mouse.c @@ -131,14 +131,15 @@ mouse_snapclient(client_t *c, area_t geometry) return titlebar_geometry_remove(&c->titlebar, geometry); } -/** Redraw the resizebar - * \param ctx draw context - * \param style the style to use for drawing - * \param geometry the geometry to use for the box - * \param border the client border size +/** Redraw the resizebar. + * \param ctx Draw context. + * \param style The style pointer to use for drawing. + * \param geometry The geometry to use for the box. + * \param border The client border size. */ static void -mouse_resizebar_draw(draw_context_t *ctx, style_t style, simple_window_t *sw, area_t geometry, int border) +mouse_resizebar_draw(draw_context_t *ctx, style_t *style, + simple_window_t *sw, area_t geometry, int border) { area_t draw_geometry = { 0, 0, ctx->width, ctx->height, NULL, NULL }; char size[64]; @@ -153,21 +154,23 @@ mouse_resizebar_draw(draw_context_t *ctx, style_t style, simple_window_t *sw, ar } /** Initialize the resizebar window. - * \param phys_screen physical screen id - * \param border border size of the client - * \param geometry client geometry - * \param style style used to draw - * \param ctx drawctx to create + * \param phys_screen Physical screen number. + * \param border Border size of the client. + * \param geometry Client geometry. + * \param style Style used to draw. + * \param ctx Draw context to create. + * \return The simple window. */ static simple_window_t * -mouse_resizebar_new(int phys_screen, int border, area_t geometry, style_t style, draw_context_t **ctx) +mouse_resizebar_new(int phys_screen, int border, area_t geometry, + style_t *style, draw_context_t **ctx) { simple_window_t *sw; area_t geom; geom = draw_text_extents(globalconf.connection, globalconf.default_screen, - style.font, + style->font, "0000x0000+0000+0000"); geom.x = geometry.x + ((2 * border + geometry.width) - geom.width) / 2; geom.y = geometry.y + ((2 * border + geometry.height) - geom.height) / 2; @@ -200,7 +203,7 @@ uicb_client_movemouse(int screen, char *arg __attribute__ ((unused))) Layout *layout = layout_get_current(screen); simple_window_t *sw = NULL; draw_context_t *ctx; - style_t style; + style_t *style; xcb_generic_event_t *ev = NULL; xcb_motion_notify_event_t *ev_motion = NULL; xcb_grab_pointer_reply_t *grab_pointer_r = NULL; @@ -222,7 +225,7 @@ uicb_client_movemouse(int screen, char *arg __attribute__ ((unused))) geometry = c->geometry; ocx = geometry.x; ocy = geometry.y; - style = globalconf.screens[c->screen].styles.focus; + style = &globalconf.screens[c->screen].styles.focus; /* Get responses */ if(!(grab_pointer_r = xcb_grab_pointer_reply(globalconf.connection, grab_pointer_c, NULL))) @@ -330,7 +333,7 @@ uicb_client_resizemouse(int screen, char *arg __attribute__ ((unused))) double mwfact; simple_window_t *sw = NULL; draw_context_t *ctx = NULL; - style_t style; + style_t *style; xcb_grab_pointer_cookie_t grab_pointer_c; xcb_grab_pointer_reply_t *grab_pointer_r = NULL; xcb_screen_t *s = xcb_aux_get_screen(globalconf.connection, c->phys_screen); @@ -339,7 +342,7 @@ uicb_client_resizemouse(int screen, char *arg __attribute__ ((unused))) if(!c || c->isfixed) return; - style = globalconf.screens[c->screen].styles.focus; + style = &globalconf.screens[c->screen].styles.focus; if(layout->arrange == layout_floating || c->isfloating) { diff --git a/titlebar.c b/titlebar.c index a0d4e80c3..d2f8508da 100644 --- a/titlebar.c +++ b/titlebar.c @@ -221,7 +221,7 @@ titlebar_draw(client_t *c) text = titlebar_text(c); geometry.x = geometry.y = 0; style = client_style_get(c); - draw_text(ctx, geometry, text, *style); + draw_text(ctx, geometry, text, style); p_delete(&text); switch(c->titlebar.position) diff --git a/widgets/taglist.c b/widgets/taglist.c index 8ab13defd..39fae7ba3 100644 --- a/widgets/taglist.c +++ b/widgets/taglist.c @@ -163,7 +163,7 @@ taglist_draw(widget_t *widget, tag && area; tag = tag->next, area = area->next, i++) { - draw_text(ctx, *area, text[i], *styles[i]); + draw_text(ctx, *area, text[i], styles[i]); p_delete(&text[i]); if(tag_isoccupied(tag)) diff --git a/widgets/tasklist.c b/widgets/tasklist.c index 502bc3c91..f45f54029 100644 --- a/widgets/tasklist.c +++ b/widgets/tasklist.c @@ -162,7 +162,7 @@ tasklist_draw(widget_t *widget, draw_context_t *ctx, int offset, int used) if(i == n - 1) area.width += box_width_rest; - draw_text(ctx, area, text, *style); + draw_text(ctx, area, text, style); p_delete(&text); diff --git a/widgets/textbox.c b/widgets/textbox.c index c216e2894..c32ff63ac 100644 --- a/widgets/textbox.c +++ b/widgets/textbox.c @@ -56,7 +56,8 @@ textbox_draw(widget_t *widget, draw_context_t *ctx, int offset, int used) if(!widget->user_supplied_y) widget->area.y = 0; - draw_text(ctx, widget->area, d->text, globalconf.screens[widget->statusbar->screen].styles.normal); + draw_text(ctx, widget->area, d->text, + &globalconf.screens[widget->statusbar->screen].styles.normal); return widget->area.width; }