use image instead of symbols for layouts
|
@ -87,7 +87,7 @@ cleanup_screen(int screen)
|
||||||
for(l = globalconf.screens[screen].layouts; l; l = ln)
|
for(l = globalconf.screens[screen].layouts; l; l = ln)
|
||||||
{
|
{
|
||||||
ln = l->next;
|
ln = l->next;
|
||||||
p_delete(&l->symbol);
|
p_delete(&l->image);
|
||||||
p_delete(&l);
|
p_delete(&l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
23
awesomerc
|
@ -14,21 +14,22 @@ screen 0
|
||||||
}
|
}
|
||||||
layouts
|
layouts
|
||||||
{
|
{
|
||||||
layout tile { symbol = "[]=" }
|
layout tile { image = "tile.png" }
|
||||||
layout tileleft { symbol = "=[]" }
|
layout tileleft { image = "tileleft.png" }
|
||||||
layout max { symbol = "[ ]" }
|
layout max { image = "max.png" }
|
||||||
layout spiral { symbol = "(@)" }
|
layout spiral { image = "spiral.png" }
|
||||||
layout dwindle { symbol = "[\\]" }
|
layout dwindle { image = "dwindle.png" }
|
||||||
layout floating { symbol = "><>" }
|
layout floating { image = "floating.png" }
|
||||||
}
|
}
|
||||||
statusbar
|
statusbar
|
||||||
{
|
{
|
||||||
position = "top"
|
position = "top"
|
||||||
taglist tl {}
|
|
||||||
layoutinfo li {}
|
taglist mytaglist {}
|
||||||
netwmicon nwi {}
|
layoutinfo mylayoutinfo {}
|
||||||
focustitle ft {}
|
netwmicon mynetwmicon {}
|
||||||
textbox tb {}
|
focustitle myfocustitle {}
|
||||||
|
textbox mytextbox {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
6
config.c
|
@ -382,7 +382,7 @@ config_parse(const char *confpatharg)
|
||||||
};
|
};
|
||||||
static cfg_opt_t layout_opts[] =
|
static cfg_opt_t layout_opts[] =
|
||||||
{
|
{
|
||||||
CFG_STR((char *) "symbol", (char *) "???", CFGF_NONE),
|
CFG_STR((char *) "image", NULL, CFGF_NONE),
|
||||||
CFG_END()
|
CFG_END()
|
||||||
};
|
};
|
||||||
static cfg_opt_t layouts_opts[] =
|
static cfg_opt_t layouts_opts[] =
|
||||||
|
@ -587,10 +587,10 @@ config_parse(const char *confpatharg)
|
||||||
if(!layout->arrange)
|
if(!layout->arrange)
|
||||||
{
|
{
|
||||||
warn("unknown layout %s in configuration file\n", cfg_title(cfgsectmp));
|
warn("unknown layout %s in configuration file\n", cfg_title(cfgsectmp));
|
||||||
layout->symbol = NULL;
|
layout->image = NULL;
|
||||||
continue;
|
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)
|
if(i < cfg_size(cfg_layouts, "layout") - 1)
|
||||||
layout = layout->next = p_new(Layout, 1);
|
layout = layout->next = p_new(Layout, 1);
|
||||||
|
|
2
config.h
|
@ -55,7 +55,7 @@ typedef struct AwesomeConf AwesomeConf;
|
||||||
typedef struct Layout Layout;
|
typedef struct Layout Layout;
|
||||||
struct Layout
|
struct Layout
|
||||||
{
|
{
|
||||||
char *symbol;
|
char *image;
|
||||||
void (*arrange) (int);
|
void (*arrange) (int);
|
||||||
Layout *next;
|
Layout *next;
|
||||||
};
|
};
|
||||||
|
|
14
draw.c
|
@ -175,20 +175,31 @@ void draw_image_from_argb_data(DrawCtx *ctx, int x, int y, int w, int h,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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_surface_t *surface, *source;
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
|
|
||||||
source = cairo_xlib_surface_create(ctx->display, ctx->drawable, ctx->visual, ctx->width, ctx->height);
|
source = cairo_xlib_surface_create(ctx->display, ctx->drawable, ctx->visual, ctx->width, ctx->height);
|
||||||
surface = cairo_image_surface_create_from_png(filename);
|
surface = cairo_image_surface_create_from_png(filename);
|
||||||
cr = cairo_create (source);
|
cr = cairo_create (source);
|
||||||
|
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_set_source_surface(cr, surface, x, y);
|
||||||
cairo_paint(cr);
|
cairo_paint(cr);
|
||||||
|
|
||||||
cairo_destroy(cr);
|
cairo_destroy(cr);
|
||||||
cairo_surface_destroy(source);
|
cairo_surface_destroy(source);
|
||||||
cairo_surface_destroy(surface);
|
cairo_surface_destroy(surface);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -205,7 +216,6 @@ draw_get_image_width(const char *filename)
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Drawable
|
Drawable
|
||||||
draw_rotate(DrawCtx *ctx, int screen, double angle, int tx, int ty)
|
draw_rotate(DrawCtx *ctx, int screen, double angle, int tx, int ty)
|
||||||
{
|
{
|
||||||
|
|
2
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_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_rectangle(DrawCtx *, int, int, int, int, Bool, XColor);
|
||||||
void draw_circle(DrawCtx *, 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 *);
|
void draw_image_from_argb_data(DrawCtx *, int, int, int, int, int, unsigned char *);
|
||||||
int draw_get_image_width(const char *filename);
|
int draw_get_image_width(const char *filename);
|
||||||
Drawable draw_rotate(DrawCtx *, int, double, int, int);
|
Drawable draw_rotate(DrawCtx *, int, double, int, int);
|
||||||
|
|
After Width: | Height: | Size: 3.9 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 497 B |
After Width: | Height: | Size: 497 B |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 2.9 KiB |
|
@ -29,17 +29,16 @@ static int
|
||||||
iconbox_draw(Widget *widget, DrawCtx *ctx, int offset,
|
iconbox_draw(Widget *widget, DrawCtx *ctx, int offset,
|
||||||
int used __attribute__ ((unused)))
|
int used __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
VirtScreen vscreen = globalconf.screens[widget->statusbar->screen];
|
|
||||||
int location, width;
|
int location, width;
|
||||||
|
|
||||||
width = draw_get_image_width(widget->data);
|
width = draw_get_image_width(widget->data);
|
||||||
|
|
||||||
location = widget_calculate_offset(vscreen.statusbar->width,
|
location = widget_calculate_offset(widget->statusbar->width,
|
||||||
width,
|
width,
|
||||||
offset,
|
offset,
|
||||||
widget->alignment);
|
widget->alignment);
|
||||||
|
|
||||||
draw_image(ctx, location, 0, widget->data);
|
draw_image(ctx, location, 0, 0, widget->data);
|
||||||
|
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
* layoutinfo.c - layout info widget
|
* layoutinfo.c - layout info widget
|
||||||
*
|
*
|
||||||
* Copyright © 2007 Aldo Cortesi <aldo@nullcube.com>
|
* Copyright © 2007 Aldo Cortesi <aldo@nullcube.com>
|
||||||
|
* Copyright © 2007 Julien Danjou <julien@danjou.info>
|
||||||
|
* Aldo Cortesi <aldo@nullcube.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -32,23 +34,15 @@ layoutinfo_draw(Widget *widget,
|
||||||
int offset,
|
int offset,
|
||||||
int used __attribute__ ((unused)))
|
int used __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
int width = 0, location;
|
int location = widget_calculate_offset(widget->statusbar->width,
|
||||||
VirtScreen vscreen = globalconf.screens[widget->statusbar->screen];
|
widget->statusbar->height,
|
||||||
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,
|
offset,
|
||||||
widget->alignment);
|
widget->alignment);
|
||||||
draw_text(ctx, location, 0,
|
|
||||||
width,
|
draw_image(ctx, location, 0, widget->statusbar->height,
|
||||||
vscreen.statusbar->height,
|
get_current_layout(widget->statusbar->screen)->image);
|
||||||
vscreen.font,
|
|
||||||
get_current_layout(widget->statusbar->screen)->symbol,
|
return widget->statusbar->height;
|
||||||
vscreen.colors_normal[ColFG],
|
|
||||||
vscreen.colors_normal[ColBG]);
|
|
||||||
return width;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget *
|
Widget *
|
||||||
|
|