tasklist can now show focused only client

This commit is contained in:
Julien Danjou 2008-02-06 20:03:18 +01:00
parent cdb85ad098
commit 528ff7316c
3 changed files with 50 additions and 14 deletions

View File

@ -203,8 +203,8 @@ This widget shows a list of running windows.
Text alignement. Text alignement.
*show_icons*:: *show_icons*::
Show applications icons. Show applications icons.
*show_all*:: *show*::
Show all windows from all tags. Show all windows from all tags, tags clients only or focused client.
*x*:: *x*::
Horizontal offset (auto-alignment if not set). Horizontal offset (auto-alignment if not set).
*y*:: *y*::
@ -443,7 +443,7 @@ screen <integer> [MULTI]
focus_bg = <color> focus_bg = <color>
font = <font> font = <font>
show_icons = <boolean> show_icons = <boolean>
show_all = <boolean> show = <{all,tags,focus}>
align = <{center,left,right}> align = <{center,left,right}>
x = <integer> y = <integer> x = <integer> y = <integer>
mouse [MULTI] mouse [MULTI]

View File

@ -125,8 +125,8 @@ cfg_opt_t widget_tasklist_opts[] =
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_STR((char *) "show", (char *) "tags", CFGF_NONE),
CFG_BOOL((char *) "show_icons", cfg_true, CFGF_NONE), CFG_BOOL((char *) "show_icons", cfg_true, CFGF_NONE),
CFG_BOOL((char *) "show_all", cfg_false, CFGF_NONE),
CFG_END() CFG_END()
}; };
cfg_opt_t widget_graph_data_opts[] = cfg_opt_t widget_graph_data_opts[] =

View File

@ -29,14 +29,18 @@
#include "tag.h" #include "tag.h"
#include "common/util.h" #include "common/util.h"
#define ISVISIBLE_ON_TB(c, nscreen, show_all) ((!show_all && client_isvisible(c, nscreen) && !c->skiptb) \
|| (show_all && c->screen == nscreen && !c->skiptb))
extern AwesomeConf globalconf; extern AwesomeConf globalconf;
typedef enum
{
ShowFocus,
ShowTags,
ShowAll,
} ShowClient;
typedef struct typedef struct
{ {
Bool show_all; ShowClient show;
Bool show_icons; Bool show_icons;
Alignment align; Alignment align;
XColor fg_sel; XColor fg_sel;
@ -45,6 +49,31 @@ typedef struct
XColor bg; XColor bg;
} Data; } Data;
static inline Bool
tasklist_isvisible(Client *c, int screen, ShowClient show)
{
if(c->skiptb)
return False;
switch(show)
{
case ShowAll:
if(c->screen == screen)
return True;
break;
case ShowTags:
if(client_isvisible(c, screen))
return True;
break;
case ShowFocus:
if(c == globalconf.focus->client)
return True;
break;
}
return False;
}
static int static int
tasklist_draw(Widget *widget, DrawCtx *ctx, int offset, int used) tasklist_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
{ {
@ -60,7 +89,7 @@ tasklist_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
return (widget->area.width = 0); return (widget->area.width = 0);
for(c = globalconf.clients; c; c = c->next) for(c = globalconf.clients; c; c = c->next)
if(ISVISIBLE_ON_TB(c, widget->statusbar->screen, d->show_all)) if(tasklist_isvisible(c, widget->statusbar->screen, d->show))
n++; n++;
if(!n) if(!n)
@ -80,7 +109,7 @@ tasklist_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
widget->area.y = widget->area.y = 0; widget->area.y = widget->area.y = 0;
for(c = globalconf.clients; c; c = c->next) for(c = globalconf.clients; c; c = c->next)
if(ISVISIBLE_ON_TB(c, widget->statusbar->screen, d->show_all)) if(tasklist_isvisible(c, widget->statusbar->screen, d->show))
{ {
icon_width = 0; icon_width = 0;
@ -177,7 +206,7 @@ tasklist_button_press(Widget *widget, XButtonPressedEvent *ev)
if(ev->button == Button1 && CLEANMASK(ev->state) == NoSymbol) if(ev->button == Button1 && CLEANMASK(ev->state) == NoSymbol)
{ {
for(c = globalconf.clients; c; c = c->next) for(c = globalconf.clients; c; c = c->next)
if(ISVISIBLE_ON_TB(c, widget->statusbar->screen, d->show_all)) if(tasklist_isvisible(c, widget->statusbar->screen, d->show))
n++; n++;
if(!n) if(!n)
@ -202,11 +231,11 @@ tasklist_button_press(Widget *widget, XButtonPressedEvent *ev)
} }
/* found first visible client */ /* found first visible client */
for(c = globalconf.clients; for(c = globalconf.clients;
c && !ISVISIBLE_ON_TB(c, widget->statusbar->screen, d->show_all); c && !tasklist_isvisible(c, widget->statusbar->screen, d->show);
c = c->next); c = c->next);
/* found ci-th visible client */ /* found ci-th visible client */
for(i = 0; c ; c = c->next) for(i = 0; c ; c = c->next)
if(ISVISIBLE_ON_TB(c, widget->statusbar->screen, d->show_all)) if(tasklist_isvisible(c, widget->statusbar->screen, d->show))
if(i++ >= ci) if(i++ >= ci)
break; break;
@ -269,7 +298,14 @@ tasklist_new(Statusbar *statusbar, cfg_t *config)
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"); d->show_icons = cfg_getbool(config, "show_icons");
d->show_all = cfg_getbool(config, "show_all");
buf = cfg_getstr(config, "show");
if(!a_strcmp(buf, "all"))
d->show = ShowAll;
else if(!a_strcmp(buf, "tags"))
d->show = ShowTags;
else
d->show = ShowFocus;
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);