Add tags_occupied color in theme and tags_*_statusline to draw status sequences in tags button in according to tag state (normal/selected/occupied)
This commit is contained in:
parent
feaa413951
commit
38f3e3b6b0
16
src/config.c
16
src/config.c
@ -10,6 +10,7 @@
|
||||
#include "screen.h"
|
||||
#include "infobar.h"
|
||||
#include "util.h"
|
||||
#include "status.h"
|
||||
|
||||
static void
|
||||
config_mouse_section(struct mbhead *mousebinds, struct conf_sec **sec)
|
||||
@ -75,9 +76,24 @@ config_theme(void)
|
||||
t->tags_n.bg = color_atoh(fetch_opt_first(ks[i], "#222222", "tags_normal_bg").str);
|
||||
t->tags_s.fg = color_atoh(fetch_opt_first(ks[i], "#222222", "tags_sel_fg").str);
|
||||
t->tags_s.bg = color_atoh(fetch_opt_first(ks[i], "#CCCCCC", "tags_sel_bg").str);
|
||||
t->tags_o.fg = color_atoh(fetch_opt_first(ks[i], "#CCCCCC", "tags_occupied_fg").str);
|
||||
t->tags_o.bg = color_atoh(fetch_opt_first(ks[i], "#444444", "tags_occupied_bg").str);
|
||||
t->tags_border_col = color_atoh(fetch_opt_first(ks[i], "#888888", "tags_border_color").str);
|
||||
t->tags_border_width = fetch_opt_first(ks[i], "0", "tags_border_width").num;
|
||||
|
||||
|
||||
/* status line */
|
||||
t->tags_n_sl = status_new_ctx(NULL, t);
|
||||
t->tags_s_sl = status_new_ctx(NULL, t);
|
||||
t->tags_o_sl = status_new_ctx(NULL, t);
|
||||
|
||||
if((t->tags_n_sl.status = xstrdup(fetch_opt_first(ks[i], "", "tags_normal_statusline").str)))
|
||||
status_parse(&t->tags_n_sl);
|
||||
if((t->tags_s_sl.status = xstrdup(fetch_opt_first(ks[i], "", "tags_sel_statusline").str)))
|
||||
status_parse(&t->tags_s_sl);
|
||||
if((t->tags_o_sl.status = xstrdup(fetch_opt_first(ks[i], "", "tags_occupied_statusline").str)))
|
||||
status_parse(&t->tags_o_sl);
|
||||
|
||||
/* Client / frame */
|
||||
t->client_n.fg = color_atoh(fetch_opt_first(ks[i], "#CCCCCC", "client_normal_fg").str);
|
||||
t->client_n.bg = color_atoh(fetch_opt_first(ks[i], "#222222", "client_normal_bg").str);
|
||||
|
||||
@ -49,6 +49,8 @@ infobar_elem_tag_init(struct element *e)
|
||||
j = e->geo.x;
|
||||
e->geo.h -= (e->infobar->theme->tags_border_width << 1);
|
||||
|
||||
e->statusctx = &e->infobar->theme->tags_n_sl;
|
||||
|
||||
TAILQ_FOREACH(t, &e->infobar->screen->tags, next)
|
||||
{
|
||||
s = draw_textw(e->infobar->theme, t->name) + PAD;
|
||||
@ -92,15 +94,33 @@ infobar_elem_tag_update(struct element *e)
|
||||
{
|
||||
b->fg = e->infobar->theme->tags_s.fg;
|
||||
b->bg = e->infobar->theme->tags_s.bg;
|
||||
e->statusctx = &e->infobar->theme->tags_s_sl;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(SLIST_EMPTY(&t->clients))
|
||||
{
|
||||
b->fg = e->infobar->theme->tags_n.fg;
|
||||
b->bg = e->infobar->theme->tags_n.bg;
|
||||
e->statusctx = &e->infobar->theme->tags_n_sl;
|
||||
}
|
||||
/* Occupied tag */
|
||||
else
|
||||
{
|
||||
b->fg = e->infobar->theme->tags_o.fg;
|
||||
b->bg = e->infobar->theme->tags_o.bg;
|
||||
e->statusctx = &e->infobar->theme->tags_o_sl;
|
||||
}
|
||||
}
|
||||
|
||||
barwin_refresh_color(b);
|
||||
|
||||
/* Manage status line */
|
||||
e->statusctx->barwin = b;
|
||||
status_flush_mousebind(e->statusctx);
|
||||
status_copy_mousebind(e->statusctx);
|
||||
status_render(e->statusctx);
|
||||
|
||||
draw_text(b->dr, e->infobar->theme, (PAD >> 1),
|
||||
TEXTY(e->infobar->theme, e->geo.h), b->fg, t->name);
|
||||
|
||||
|
||||
67
src/status.c
67
src/status.c
@ -44,6 +44,17 @@ status_new_ctx(struct barwin *b, struct theme *t)
|
||||
return ctx;
|
||||
}
|
||||
|
||||
void
|
||||
status_free_ctx(struct status_ctx *ctx)
|
||||
{
|
||||
free(ctx->status);
|
||||
|
||||
if(ctx->barwin)
|
||||
status_flush_mousebind(ctx);
|
||||
|
||||
status_flush_list(ctx);
|
||||
}
|
||||
|
||||
/* Parse mousebind sequence next normal sequence: \<seq>[](button;func;cmd) */
|
||||
static char*
|
||||
status_parse_mouse(struct status_seq *sq, struct status_ctx *ctx, char *str)
|
||||
@ -63,8 +74,11 @@ status_parse_mouse(struct status_seq *sq, struct status_ctx *ctx, char *str)
|
||||
m->button = ATOI(arg[0]);
|
||||
m->func = uicb_name_func(arg[1]);
|
||||
m->cmd = (i > 1 ? xstrdup(arg[2]) : NULL);
|
||||
m->flags |= MOUSEBIND_STATUS;
|
||||
|
||||
if(ctx->barwin)
|
||||
SLIST_INSERT_HEAD(&ctx->barwin->mousebinds, m, next);
|
||||
|
||||
SLIST_INSERT_HEAD(&sq->mousebinds, m, snext);
|
||||
|
||||
return end + 1;
|
||||
@ -76,7 +90,7 @@ status_parse_mouse(struct status_seq *sq, struct status_ctx *ctx, char *str)
|
||||
str = end + 2; \
|
||||
continue; \
|
||||
}
|
||||
static void
|
||||
void
|
||||
status_parse(struct status_ctx *ctx)
|
||||
{
|
||||
struct status_seq *sq, *prev = NULL;
|
||||
@ -265,17 +279,12 @@ status_render(struct status_ctx *ctx)
|
||||
barwin_refresh(ctx->barwin);
|
||||
}
|
||||
|
||||
/* Parse and render statustext */
|
||||
void
|
||||
status_manage(struct status_ctx *ctx)
|
||||
status_flush_list(struct status_ctx *ctx)
|
||||
{
|
||||
struct status_seq *sq;
|
||||
struct mousebind *m;
|
||||
|
||||
/*
|
||||
* Flush previous linked list of status sequences
|
||||
* and mousebind of status barwin
|
||||
*/
|
||||
/* Flush previous linked list of status sequences */
|
||||
while(!SLIST_EMPTY(&ctx->statushead))
|
||||
{
|
||||
sq = SLIST_FIRST(&ctx->statushead);
|
||||
@ -283,13 +292,43 @@ status_manage(struct status_ctx *ctx)
|
||||
free(sq->str);
|
||||
free(sq);
|
||||
}
|
||||
while(!SLIST_EMPTY(&ctx->barwin->mousebinds))
|
||||
{
|
||||
m = SLIST_FIRST(&ctx->barwin->mousebinds);
|
||||
SLIST_REMOVE_HEAD(&ctx->barwin->mousebinds, next);
|
||||
free((void*)m->cmd);
|
||||
free(m);
|
||||
}
|
||||
|
||||
void
|
||||
status_flush_mousebind(struct status_ctx *ctx)
|
||||
{
|
||||
struct mousebind *m;
|
||||
|
||||
SLIST_FOREACH(m, &ctx->barwin->mousebinds, next)
|
||||
if(m->flags & MOUSEBIND_STATUS)
|
||||
SLIST_REMOVE(&ctx->barwin->mousebinds, m, mousebind, next);
|
||||
}
|
||||
|
||||
void
|
||||
status_copy_mousebind(struct status_ctx *ctx)
|
||||
{
|
||||
struct mousebind *m;
|
||||
struct status_seq *sq;
|
||||
|
||||
if(!ctx->barwin)
|
||||
return;
|
||||
|
||||
SLIST_FOREACH(sq, &ctx->statushead, next)
|
||||
{
|
||||
SLIST_FOREACH(m, &sq->mousebinds, snext)
|
||||
SLIST_INSERT_HEAD(&ctx->barwin->mousebinds, m, next);
|
||||
}
|
||||
}
|
||||
|
||||
/* Parse and render statustext */
|
||||
void
|
||||
status_manage(struct status_ctx *ctx)
|
||||
{
|
||||
if(!ctx->status)
|
||||
return;
|
||||
|
||||
status_flush_list(ctx);
|
||||
status_flush_mousebind(ctx);
|
||||
status_parse(ctx);
|
||||
status_render(ctx);
|
||||
}
|
||||
|
||||
@ -9,6 +9,11 @@
|
||||
#include "wmfs.h"
|
||||
|
||||
struct status_ctx status_new_ctx(struct barwin *b, struct theme *t);
|
||||
void status_free_ctx(struct status_ctx *ctx);
|
||||
void status_flush_list(struct status_ctx *ctx);
|
||||
void status_flush_mousebind(struct status_ctx *ctx);
|
||||
void status_copy_mousebind(struct status_ctx *ctx);
|
||||
void status_parse(struct status_ctx *ctx);
|
||||
void status_render(struct status_ctx *ctx);
|
||||
void status_manage(struct status_ctx *ctx);
|
||||
void uicb_status(Uicb cmd);
|
||||
|
||||
@ -439,6 +439,9 @@ wmfs_quit(void)
|
||||
{
|
||||
r = SLIST_FIRST(&W->h.rule);
|
||||
SLIST_REMOVE_HEAD(&W->h.rule, next);
|
||||
status_free_ctx(&t->tags_n_sl);
|
||||
status_free_ctx(&t->tags_s_sl);
|
||||
status_free_ctx(&t->tags_o_sl);
|
||||
free(r->class);
|
||||
free(r->instance);
|
||||
free(r->role);
|
||||
|
||||
@ -119,6 +119,7 @@ struct element
|
||||
{
|
||||
struct geo geo;
|
||||
struct infobar *infobar;
|
||||
struct status_ctx *statusctx;
|
||||
int type;
|
||||
enum position align;
|
||||
void (*func_init)(struct element *e);
|
||||
@ -218,6 +219,8 @@ struct keybind
|
||||
struct mousebind
|
||||
{
|
||||
struct geo area;
|
||||
#define MOUSEBIND_STATUS 0x01
|
||||
Flags flags;
|
||||
unsigned int button;
|
||||
bool use_area;
|
||||
void (*func)(Uicb);
|
||||
@ -243,7 +246,8 @@ struct theme
|
||||
int bars_width;
|
||||
|
||||
/* struct elements */
|
||||
struct colpair tags_n, tags_s; /* normal / selected */
|
||||
struct colpair tags_n, tags_s, tags_o; /* normal / selected / occupied */
|
||||
struct status_ctx tags_n_sl, tags_s_sl, tags_o_sl; /* status line */
|
||||
int tags_border_width;
|
||||
Color tags_border_col;
|
||||
|
||||
|
||||
8
wmfsrc
8
wmfsrc
@ -22,8 +22,16 @@
|
||||
# Element tags
|
||||
tags_normal_fg = "#AABBAA"
|
||||
tags_normal_bg = "#223322"
|
||||
# tags_normal_statusline = ""
|
||||
|
||||
tags_sel_fg = "#223322"
|
||||
tags_sel_bg = "#AABBAA"
|
||||
# tags_sel_statusline = ""
|
||||
|
||||
tags_occupied_fg = "#AABBAA"
|
||||
tags_occupied_bg = "#445544"
|
||||
tags_occupied_statusline = "\R[0;0;3;3;#AABBAA]"
|
||||
|
||||
tags_border_color = "#112211"
|
||||
tags_border_width = 1
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user