diff --git a/awesome.c b/awesome.c index 2b9f2acd..3cd0c5e7 100644 --- a/awesome.c +++ b/awesome.c @@ -87,7 +87,7 @@ cleanup_screen(int screen) for(l = globalconf.screens[screen].layouts; l; l = ln) { ln = l->next; - p_delete(&l->symbol); + p_delete(&l->image); p_delete(&l); } } diff --git a/awesomerc b/awesomerc index 85e5c44b..b6cd2ba6 100644 --- a/awesomerc +++ b/awesomerc @@ -14,21 +14,22 @@ screen 0 } layouts { - layout tile { symbol = "[]=" } - layout tileleft { symbol = "=[]" } - layout max { symbol = "[ ]" } - layout spiral { symbol = "(@)" } - layout dwindle { symbol = "[\\]" } - layout floating { symbol = "><>" } + layout tile { image = "tile.png" } + layout tileleft { image = "tileleft.png" } + layout max { image = "max.png" } + layout spiral { image = "spiral.png" } + layout dwindle { image = "dwindle.png" } + layout floating { image = "floating.png" } } statusbar { position = "top" - taglist tl {} - layoutinfo li {} - netwmicon nwi {} - focustitle ft {} - textbox tb {} + + taglist mytaglist {} + layoutinfo mylayoutinfo {} + netwmicon mynetwmicon {} + focustitle myfocustitle {} + textbox mytextbox {} } } diff --git a/config.c b/config.c index 960cb3c1..f88889bf 100644 --- a/config.c +++ b/config.c @@ -382,7 +382,7 @@ config_parse(const char *confpatharg) }; static cfg_opt_t layout_opts[] = { - CFG_STR((char *) "symbol", (char *) "???", CFGF_NONE), + CFG_STR((char *) "image", NULL, CFGF_NONE), CFG_END() }; static cfg_opt_t layouts_opts[] = @@ -587,10 +587,10 @@ config_parse(const char *confpatharg) if(!layout->arrange) { warn("unknown layout %s in configuration file\n", cfg_title(cfgsectmp)); - layout->symbol = NULL; + layout->image = NULL; continue; } - layout->symbol = a_strdup(cfg_getstr(cfgsectmp, "symbol")); + layout->image = a_strdup(cfg_getstr(cfgsectmp, "image")); if(i < cfg_size(cfg_layouts, "layout") - 1) layout = layout->next = p_new(Layout, 1); diff --git a/config.h b/config.h index 2a996098..3433f2c9 100644 --- a/config.h +++ b/config.h @@ -55,7 +55,7 @@ typedef struct AwesomeConf AwesomeConf; typedef struct Layout Layout; struct Layout { - char *symbol; + char *image; void (*arrange) (int); Layout *next; }; diff --git a/draw.c b/draw.c index 7dbc10ba..ea15ea87 100644 --- a/draw.c +++ b/draw.c @@ -175,20 +175,31 @@ void draw_image_from_argb_data(DrawCtx *ctx, int x, int y, int w, int h, } void -draw_image(DrawCtx *ctx, int x, int y, const char *filename) +draw_image(DrawCtx *ctx, int x, int y, int wanted_h, const char *filename) { + double ratio; + int h; cairo_surface_t *surface, *source; cairo_t *cr; source = cairo_xlib_surface_create(ctx->display, ctx->drawable, ctx->visual, ctx->width, ctx->height); surface = cairo_image_surface_create_from_png(filename); cr = cairo_create (source); - cairo_set_source_surface(cr, surface, x, y); + if(wanted_h > 0 && (h = cairo_image_surface_get_height(surface)) > 0) + { + ratio = (double) wanted_h / (double) h; + cairo_scale(cr, ratio, ratio); + cairo_set_source_surface(cr, surface, x / ratio, y / ratio); + } + else + cairo_set_source_surface(cr, surface, x, y); cairo_paint(cr); cairo_destroy(cr); cairo_surface_destroy(source); cairo_surface_destroy(surface); + + } int @@ -205,7 +216,6 @@ draw_get_image_width(const char *filename) return width; } - Drawable draw_rotate(DrawCtx *ctx, int screen, double angle, int tx, int ty) { diff --git a/draw.h b/draw.h index ca27fe9c..dc78cae5 100644 --- a/draw.h +++ b/draw.h @@ -41,7 +41,7 @@ void draw_free_context(DrawCtx*); void draw_text(DrawCtx *, int, int, int, int, XftFont *, const char *, XColor fg, XColor bg); void draw_rectangle(DrawCtx *, int, int, int, int, Bool, XColor); void draw_circle(DrawCtx *, int, int, int, Bool, XColor); -void draw_image(DrawCtx *, int, int, const char *); +void draw_image(DrawCtx *, int, int, int, const char *); void draw_image_from_argb_data(DrawCtx *, int, int, int, int, int, unsigned char *); int draw_get_image_width(const char *filename); Drawable draw_rotate(DrawCtx *, int, double, int, int); diff --git a/icons/layouts/dwindle.png b/icons/layouts/dwindle.png new file mode 100644 index 00000000..064ef7d1 Binary files /dev/null and b/icons/layouts/dwindle.png differ diff --git a/icons/layouts/dwindlew.png b/icons/layouts/dwindlew.png new file mode 100644 index 00000000..0de87ea5 Binary files /dev/null and b/icons/layouts/dwindlew.png differ diff --git a/icons/layouts/floating.png b/icons/layouts/floating.png new file mode 100644 index 00000000..f5650042 Binary files /dev/null and b/icons/layouts/floating.png differ diff --git a/icons/layouts/floatingw.png b/icons/layouts/floatingw.png new file mode 100644 index 00000000..d045dddd Binary files /dev/null and b/icons/layouts/floatingw.png differ diff --git a/icons/layouts/max.png b/icons/layouts/max.png new file mode 100644 index 00000000..cbb467f4 Binary files /dev/null and b/icons/layouts/max.png differ diff --git a/icons/layouts/maxw.png b/icons/layouts/maxw.png new file mode 100644 index 00000000..426992ba Binary files /dev/null and b/icons/layouts/maxw.png differ diff --git a/icons/layouts/spiral.png b/icons/layouts/spiral.png new file mode 100644 index 00000000..b486fb5f Binary files /dev/null and b/icons/layouts/spiral.png differ diff --git a/icons/layouts/spiralw.png b/icons/layouts/spiralw.png new file mode 100644 index 00000000..d6564153 Binary files /dev/null and b/icons/layouts/spiralw.png differ diff --git a/icons/layouts/tile.png b/icons/layouts/tile.png new file mode 100644 index 00000000..51f3ed9a Binary files /dev/null and b/icons/layouts/tile.png differ diff --git a/icons/layouts/tileleft.png b/icons/layouts/tileleft.png new file mode 100644 index 00000000..b5c681fc Binary files /dev/null and b/icons/layouts/tileleft.png differ diff --git a/icons/layouts/tileleftw.png b/icons/layouts/tileleftw.png new file mode 100644 index 00000000..97132dbd Binary files /dev/null and b/icons/layouts/tileleftw.png differ diff --git a/icons/layouts/tilew.png b/icons/layouts/tilew.png new file mode 100644 index 00000000..87ac52c7 Binary files /dev/null and b/icons/layouts/tilew.png differ diff --git a/widgets/iconbox.c b/widgets/iconbox.c index 9c5df97b..90f36050 100644 --- a/widgets/iconbox.c +++ b/widgets/iconbox.c @@ -29,17 +29,16 @@ static int iconbox_draw(Widget *widget, DrawCtx *ctx, int offset, int used __attribute__ ((unused))) { - VirtScreen vscreen = globalconf.screens[widget->statusbar->screen]; int location, width; width = draw_get_image_width(widget->data); - location = widget_calculate_offset(vscreen.statusbar->width, + location = widget_calculate_offset(widget->statusbar->width, width, offset, widget->alignment); - draw_image(ctx, location, 0, widget->data); + draw_image(ctx, location, 0, 0, widget->data); return width; } diff --git a/widgets/layoutinfo.c b/widgets/layoutinfo.c index 8d672119..8b9e9c71 100644 --- a/widgets/layoutinfo.c +++ b/widgets/layoutinfo.c @@ -2,6 +2,8 @@ * layoutinfo.c - layout info widget * * Copyright © 2007 Aldo Cortesi + * Copyright © 2007 Julien Danjou + * Aldo Cortesi * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,23 +34,15 @@ layoutinfo_draw(Widget *widget, int offset, int used __attribute__ ((unused))) { - int width = 0, location; - VirtScreen vscreen = globalconf.screens[widget->statusbar->screen]; - Layout *l; - for(l = vscreen.layouts ; l; l = l->next) - width = MAX(width, (textwidth(ctx, vscreen.font, l->symbol))); - location = widget_calculate_offset(vscreen.statusbar->width, - width, - offset, - widget->alignment); - draw_text(ctx, location, 0, - width, - vscreen.statusbar->height, - vscreen.font, - get_current_layout(widget->statusbar->screen)->symbol, - vscreen.colors_normal[ColFG], - vscreen.colors_normal[ColBG]); - return width; + int location = widget_calculate_offset(widget->statusbar->width, + widget->statusbar->height, + offset, + widget->alignment); + + draw_image(ctx, location, 0, widget->statusbar->height, + get_current_layout(widget->statusbar->screen)->image); + + return widget->statusbar->height; } Widget *