tasklist can now show focused only client
This commit is contained in:
parent
cdb85ad098
commit
528ff7316c
|
@ -203,8 +203,8 @@ This widget shows a list of running windows.
|
|||
Text alignement.
|
||||
*show_icons*::
|
||||
Show applications icons.
|
||||
*show_all*::
|
||||
Show all windows from all tags.
|
||||
*show*::
|
||||
Show all windows from all tags, tags clients only or focused client.
|
||||
*x*::
|
||||
Horizontal offset (auto-alignment if not set).
|
||||
*y*::
|
||||
|
@ -443,7 +443,7 @@ screen <integer> [MULTI]
|
|||
focus_bg = <color>
|
||||
font = <font>
|
||||
show_icons = <boolean>
|
||||
show_all = <boolean>
|
||||
show = <{all,tags,focus}>
|
||||
align = <{center,left,right}>
|
||||
x = <integer> y = <integer>
|
||||
mouse [MULTI]
|
||||
|
|
|
@ -125,8 +125,8 @@ cfg_opt_t widget_tasklist_opts[] =
|
|||
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_STR((char *) "show", (char *) "tags", CFGF_NONE),
|
||||
CFG_BOOL((char *) "show_icons", cfg_true, CFGF_NONE),
|
||||
CFG_BOOL((char *) "show_all", cfg_false, CFGF_NONE),
|
||||
CFG_END()
|
||||
};
|
||||
cfg_opt_t widget_graph_data_opts[] =
|
||||
|
|
|
@ -29,14 +29,18 @@
|
|||
#include "tag.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;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ShowFocus,
|
||||
ShowTags,
|
||||
ShowAll,
|
||||
} ShowClient;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Bool show_all;
|
||||
ShowClient show;
|
||||
Bool show_icons;
|
||||
Alignment align;
|
||||
XColor fg_sel;
|
||||
|
@ -45,6 +49,31 @@ typedef struct
|
|||
XColor bg;
|
||||
} 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
|
||||
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);
|
||||
|
||||
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++;
|
||||
|
||||
if(!n)
|
||||
|
@ -80,7 +109,7 @@ tasklist_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
|
|||
widget->area.y = widget->area.y = 0;
|
||||
|
||||
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;
|
||||
|
||||
|
@ -177,7 +206,7 @@ tasklist_button_press(Widget *widget, XButtonPressedEvent *ev)
|
|||
if(ev->button == Button1 && CLEANMASK(ev->state) == NoSymbol)
|
||||
{
|
||||
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++;
|
||||
|
||||
if(!n)
|
||||
|
@ -202,11 +231,11 @@ tasklist_button_press(Widget *widget, XButtonPressedEvent *ev)
|
|||
}
|
||||
/* found first visible client */
|
||||
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);
|
||||
/* found ci-th visible client */
|
||||
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)
|
||||
break;
|
||||
|
||||
|
@ -269,7 +298,14 @@ tasklist_new(Statusbar *statusbar, cfg_t *config)
|
|||
|
||||
d->align = draw_get_align(cfg_getstr(config, "align"));
|
||||
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")))
|
||||
w->font = XftFontOpenName(globalconf.display, get_phys_screen(statusbar->screen), buf);
|
||||
|
|
Loading…
Reference in New Issue