add option to show appicons in tasklist
This commit is contained in:
parent
33cd7c261f
commit
a69b5dfc40
|
@ -87,7 +87,6 @@ screen 0
|
||||||
arg = "-1"
|
arg = "-1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
netwmicon mynetwmicon {}
|
|
||||||
tasklist mytasklist
|
tasklist mytasklist
|
||||||
{
|
{
|
||||||
mouse
|
mouse
|
||||||
|
|
|
@ -158,6 +158,8 @@ This widget shows a list of running windows.
|
||||||
Foreground color for focused window.
|
Foreground color for focused window.
|
||||||
*align*::
|
*align*::
|
||||||
Text alignement.
|
Text alignement.
|
||||||
|
*show_icons*::
|
||||||
|
Show applications icons.
|
||||||
|
|
||||||
textbox
|
textbox
|
||||||
~~~~~~~
|
~~~~~~~
|
||||||
|
@ -291,6 +293,7 @@ screen <integer> [MULTI]
|
||||||
}
|
}
|
||||||
tasklist <identifier>
|
tasklist <identifier>
|
||||||
{
|
{
|
||||||
|
show_icons=<{true,false}>
|
||||||
focus_fg=<color>
|
focus_fg=<color>
|
||||||
focus_bg=<color>
|
focus_bg=<color>
|
||||||
fg=<color>
|
fg=<color>
|
||||||
|
|
1
config.c
1
config.c
|
@ -554,6 +554,7 @@ config_parse(const char *confpatharg)
|
||||||
CFG_STR((char *) "focus_bg", (char *) NULL, CFGF_NONE),
|
CFG_STR((char *) "focus_bg", (char *) NULL, CFGF_NONE),
|
||||||
CFG_STR((char *) "font", (char *) NULL, CFGF_NONE),
|
CFG_STR((char *) "font", (char *) NULL, CFGF_NONE),
|
||||||
CFG_STR((char *) "align", (char *) "left", CFGF_NONE),
|
CFG_STR((char *) "align", (char *) "left", CFGF_NONE),
|
||||||
|
CFG_BOOL((char *) "show_icons", cfg_true, CFGF_NONE),
|
||||||
CFG_END()
|
CFG_END()
|
||||||
};
|
};
|
||||||
static cfg_opt_t widget_progressbar_bar_opts[] =
|
static cfg_opt_t widget_progressbar_bar_opts[] =
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
#include "xutil.h"
|
#include "xutil.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
|
#include "ewmh.h"
|
||||||
|
#include "rules.h"
|
||||||
|
|
||||||
#define ISVISIBLE_ON_TB(c, screen) (client_isvisible(c, screen) && !c->skiptb)
|
#define ISVISIBLE_ON_TB(c, screen) (client_isvisible(c, screen) && !c->skiptb)
|
||||||
|
|
||||||
|
@ -34,6 +36,7 @@ extern AwesomeConf globalconf;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
Bool show_icons;
|
||||||
int align;
|
int align;
|
||||||
XColor fg_sel;
|
XColor fg_sel;
|
||||||
XColor bg_sel;
|
XColor bg_sel;
|
||||||
|
@ -47,7 +50,10 @@ tasklist_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
|
||||||
Client *c;
|
Client *c;
|
||||||
Data *d = widget->data;
|
Data *d = widget->data;
|
||||||
Client *sel = focus_get_current_client(widget->statusbar->screen);
|
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)
|
for(c = globalconf.clients; c; c = c->next)
|
||||||
if(ISVISIBLE_ON_TB(c, widget->statusbar->screen))
|
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)
|
for(c = globalconf.clients; c; c = c->next)
|
||||||
if(ISVISIBLE_ON_TB(c, widget->statusbar->screen))
|
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)
|
if(sel == c)
|
||||||
{
|
{
|
||||||
draw_text(ctx, widget->location + box_width * i, 0,
|
draw_text(ctx, widget->location + icon_width + box_width * i, 0,
|
||||||
box_width,
|
box_width - icon_width,
|
||||||
widget->statusbar->height,
|
widget->statusbar->height,
|
||||||
d->align,
|
d->align,
|
||||||
widget->font->height / 2, widget->font, c->name,
|
widget->font->height / 2, widget->font, c->name,
|
||||||
d->fg_sel, d->bg_sel);
|
d->fg_sel, d->bg_sel);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
draw_text(ctx, widget->location + box_width * i, 0,
|
draw_text(ctx, widget->location + icon_width + box_width * i, 0,
|
||||||
box_width,
|
box_width - icon_width,
|
||||||
widget->statusbar->height,
|
widget->statusbar->height,
|
||||||
d->align,
|
d->align,
|
||||||
widget->font->height / 2, widget->font, c->name,
|
widget->font->height / 2, widget->font, c->name,
|
||||||
d->fg, d->bg);
|
d->fg, d->bg);
|
||||||
if(sel->isfloating)
|
if(c->isfloating)
|
||||||
draw_circle(ctx, widget->location + box_width * i, 0,
|
draw_circle(ctx, widget->location + icon_width + box_width * i, 0,
|
||||||
(widget->font->height + 2) / 4,
|
(widget->font->height + 2) / 4,
|
||||||
sel->ismax, d->fg);
|
c->ismax, d->fg);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,6 +212,7 @@ tasklist_new(Statusbar *statusbar, cfg_t *config)
|
||||||
d->fg_sel = globalconf.screens[statusbar->screen].colors_selected[ColFG];
|
d->fg_sel = globalconf.screens[statusbar->screen].colors_selected[ColFG];
|
||||||
|
|
||||||
d->align = draw_get_align(cfg_getstr(config, "align"));
|
d->align = draw_get_align(cfg_getstr(config, "align"));
|
||||||
|
d->show_icons = cfg_getbool(config, "show_icons");
|
||||||
|
|
||||||
if((buf = cfg_getstr(config, "font")))
|
if((buf = cfg_getstr(config, "font")))
|
||||||
w->font = XftFontOpenName(globalconf.display, get_phys_screen(statusbar->screen), buf);
|
w->font = XftFontOpenName(globalconf.display, get_phys_screen(statusbar->screen), buf);
|
||||||
|
|
Loading…
Reference in New Issue