add option to show appicons in tasklist

This commit is contained in:
Julien Danjou 2008-01-03 19:21:36 +01:00
parent 33cd7c261f
commit a69b5dfc40
4 changed files with 46 additions and 9 deletions

View File

@ -87,7 +87,6 @@ screen 0
arg = "-1"
}
}
netwmicon mynetwmicon {}
tasklist mytasklist
{
mouse

View File

@ -158,6 +158,8 @@ This widget shows a list of running windows.
Foreground color for focused window.
*align*::
Text alignement.
*show_icons*::
Show applications icons.
textbox
~~~~~~~
@ -291,6 +293,7 @@ screen <integer> [MULTI]
}
tasklist <identifier>
{
show_icons=<{true,false}>
focus_fg=<color>
focus_bg=<color>
fg=<color>

View File

@ -554,6 +554,7 @@ config_parse(const char *confpatharg)
CFG_STR((char *) "focus_bg", (char *) NULL, CFGF_NONE),
CFG_STR((char *) "font", (char *) NULL, CFGF_NONE),
CFG_STR((char *) "align", (char *) "left", CFGF_NONE),
CFG_BOOL((char *) "show_icons", cfg_true, CFGF_NONE),
CFG_END()
};
static cfg_opt_t widget_progressbar_bar_opts[] =

View File

@ -27,6 +27,8 @@
#include "xutil.h"
#include "screen.h"
#include "event.h"
#include "ewmh.h"
#include "rules.h"
#define ISVISIBLE_ON_TB(c, screen) (client_isvisible(c, screen) && !c->skiptb)
@ -34,6 +36,7 @@ extern AwesomeConf globalconf;
typedef struct
{
Bool show_icons;
int align;
XColor fg_sel;
XColor bg_sel;
@ -47,7 +50,10 @@ tasklist_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
Client *c;
Data *d = widget->data;
Client *sel = focus_get_current_client(widget->statusbar->screen);
int n = 0, i = 0, box_width = 0;
Rule *r;
Area area;
int n = 0, i = 0, box_width = 0, icon_width = 0;
NetWMIcon *icon;
for(c = globalconf.clients; c; c = c->next)
if(ISVISIBLE_ON_TB(c, widget->statusbar->screen))
@ -69,26 +75,53 @@ tasklist_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
for(c = globalconf.clients; c; c = c->next)
if(ISVISIBLE_ON_TB(c, widget->statusbar->screen))
{
icon_width = 0;
if(d->show_icons)
{
for(r = globalconf.rules; r; r = r->next)
if(r->icon && client_match_rule(c, r))
{
area = draw_get_image_size(r->icon);
icon_width = ((double) widget->statusbar->height / (double) area.height) * area.width;
draw_image(ctx,
widget->location + box_width * i,
0, widget->statusbar->height,
r->icon);
}
if(!icon_width && (icon = ewmh_get_window_icon(c->win)))
{
icon_width = ((double) widget->statusbar->height / (double) icon->height)
* icon->width;
draw_image_from_argb_data(ctx,
widget->location + box_width * i, 0,
icon->width, icon->height,
widget->statusbar->height, icon->image);
p_delete(&icon);
}
}
if(sel == c)
{
draw_text(ctx, widget->location + box_width * i, 0,
box_width,
draw_text(ctx, widget->location + icon_width + box_width * i, 0,
box_width - icon_width,
widget->statusbar->height,
d->align,
widget->font->height / 2, widget->font, c->name,
d->fg_sel, d->bg_sel);
}
else
draw_text(ctx, widget->location + box_width * i, 0,
box_width,
draw_text(ctx, widget->location + icon_width + box_width * i, 0,
box_width - icon_width,
widget->statusbar->height,
d->align,
widget->font->height / 2, widget->font, c->name,
d->fg, d->bg);
if(sel->isfloating)
draw_circle(ctx, widget->location + box_width * i, 0,
if(c->isfloating)
draw_circle(ctx, widget->location + icon_width + box_width * i, 0,
(widget->font->height + 2) / 4,
sel->ismax, d->fg);
c->ismax, d->fg);
i++;
}
@ -179,6 +212,7 @@ tasklist_new(Statusbar *statusbar, cfg_t *config)
d->fg_sel = globalconf.screens[statusbar->screen].colors_selected[ColFG];
d->align = draw_get_align(cfg_getstr(config, "align"));
d->show_icons = cfg_getbool(config, "show_icons");
if((buf = cfg_getstr(config, "font")))
w->font = XftFontOpenName(globalconf.display, get_phys_screen(statusbar->screen), buf);