[Barbutton/conf] Add XPM support (#3)
This commit is contained in:
parent
71f9e05187
commit
839418b524
60
bar.c
60
bar.c
@ -147,9 +147,10 @@ updatebar(void)
|
|||||||
void
|
void
|
||||||
updatebutton(Bool c)
|
updatebutton(Bool c)
|
||||||
{
|
{
|
||||||
int i, j, x, pm = 0;
|
int i, j, x, pm = 0, buttonw = 0;
|
||||||
int y = 0, hi = 0;
|
int y = 0, hi = 0;
|
||||||
|
|
||||||
|
/* Calcul the position of the first button with the layout image size */
|
||||||
j = taglen[conf.ntag] + get_image_attribute(tags[seltag].layout.image)->width + PAD / 2;
|
j = taglen[conf.ntag] + get_image_attribute(tags[seltag].layout.image)->width + PAD / 2;
|
||||||
|
|
||||||
if(!conf.bartop)
|
if(!conf.bartop)
|
||||||
@ -160,29 +161,54 @@ updatebutton(Bool c)
|
|||||||
|
|
||||||
for(i = 0; i < conf.nbutton; ++i)
|
for(i = 0; i < conf.nbutton; ++i)
|
||||||
{
|
{
|
||||||
if(!(x = conf.barbutton[i].x))
|
|
||||||
|
/* CALCUL POSITION */
|
||||||
{
|
{
|
||||||
if(i)
|
if(!(x = conf.barbutton[i].x))
|
||||||
pm += textw(conf.barbutton[i-1].text) + BPAD;
|
{
|
||||||
x = (!i) ? j : j + pm;
|
if(i)
|
||||||
|
pm += (conf.barbutton[i-1].type) ?
|
||||||
|
get_image_attribute(conf.barbutton[i-1].content)->width :
|
||||||
|
textw(conf.barbutton[i-1].content) + BPAD;
|
||||||
|
|
||||||
|
x = (!i) ? j : j + pm;
|
||||||
|
}
|
||||||
|
|
||||||
|
buttonw = (conf.barbutton[i].type) ?
|
||||||
|
get_image_attribute(conf.barbutton[i].content)->width :
|
||||||
|
textw(conf.barbutton[i].content) + BPAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!c)
|
|
||||||
|
/* FIRST TIME */
|
||||||
{
|
{
|
||||||
conf.barbutton[i].bw = bar_create(x, y, textw(conf.barbutton[i].text) + BPAD,
|
if(!c)
|
||||||
barheight + hi, 0,
|
{
|
||||||
conf.barbutton[i].bg_color, False);
|
conf.barbutton[i].bw = bar_create(x, y, buttonw, barheight + hi, 0,
|
||||||
XMapRaised(dpy, conf.barbutton[i].bw->win);
|
conf.barbutton[i].bg_color, False);
|
||||||
|
XMapRaised(dpy, conf.barbutton[i].bw->win);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!conf.barbutton[i].bw)
|
/* REFRESH/DRAW TEXT/IMAGE */
|
||||||
return;
|
{
|
||||||
|
if(!conf.barbutton[i].bw)
|
||||||
|
return;
|
||||||
|
if(!conf.barbutton[i].type)
|
||||||
|
bar_refresh_color(conf.barbutton[i].bw);
|
||||||
|
bar_moveresize(conf.barbutton[i].bw, x, y, buttonw, barheight + hi);
|
||||||
|
|
||||||
bar_refresh_color(conf.barbutton[i].bw);
|
/* Check the button type (image/text) */
|
||||||
bar_moveresize(conf.barbutton[i].bw, x, y, textw(conf.barbutton[i].text) + BPAD, barheight + hi);
|
if(conf.barbutton[i].type)
|
||||||
draw_text(conf.barbutton[i].bw->dr, BPAD/2, fonth, conf.barbutton[i].fg_color,
|
draw_image(conf.barbutton[i].bw->dr, 0, 0,
|
||||||
conf.barbutton[i].bg_color, BPAD, conf.barbutton[i].text);
|
conf.barbutton[i].content);
|
||||||
bar_refresh(conf.barbutton[i].bw);
|
else
|
||||||
|
draw_text(conf.barbutton[i].bw->dr, BPAD/2, fonth, conf.barbutton[i].fg_color,
|
||||||
|
conf.barbutton[i].bg_color, BPAD, conf.barbutton[i].content);
|
||||||
|
|
||||||
|
/* Refresh button */
|
||||||
|
bar_refresh(conf.barbutton[i].bw);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
|
|
||||||
|
|||||||
16
config.c
16
config.c
@ -243,7 +243,8 @@ init_conf(void)
|
|||||||
|
|
||||||
static cfg_opt_t button_opts[] =
|
static cfg_opt_t button_opts[] =
|
||||||
{
|
{
|
||||||
CFG_STR("text", "", CFGF_NONE),
|
CFG_STR("type", "text", CFGF_NONE),
|
||||||
|
CFG_STR("content", "", CFGF_NONE),
|
||||||
CFG_SEC("mouse", mouse_button_opts, CFGF_MULTI),
|
CFG_SEC("mouse", mouse_button_opts, CFGF_MULTI),
|
||||||
CFG_STR("fg_color", "#000000", CFGF_NONE),
|
CFG_STR("fg_color", "#000000", CFGF_NONE),
|
||||||
CFG_STR("bg_color", "#FFFFFF", CFGF_NONE),
|
CFG_STR("bg_color", "#FFFFFF", CFGF_NONE),
|
||||||
@ -464,9 +465,16 @@ init_conf(void)
|
|||||||
conf.barbutton[i].mouse[j] = char_to_button(cfg_getstr(cfgtmp3, "button"));
|
conf.barbutton[i].mouse[j] = char_to_button(cfg_getstr(cfgtmp3, "button"));
|
||||||
}
|
}
|
||||||
conf.barbutton[i].nmousesec = cfg_size(cfgtmp2, "mouse");
|
conf.barbutton[i].nmousesec = cfg_size(cfgtmp2, "mouse");
|
||||||
conf.barbutton[i].text = strdup(var_to_str(cfg_getstr(cfgtmp2, "text")));
|
if(strcmp("image", strdup(cfg_getstr(cfgtmp2, "type"))) == 0)
|
||||||
conf.barbutton[i].fg_color = strdup(var_to_str(cfg_getstr(cfgtmp2, "fg_color")));
|
conf.barbutton[i].type = True;
|
||||||
conf.barbutton[i].bg_color = getcolor(strdup(var_to_str(cfg_getstr(cfgtmp2, "bg_color"))));
|
else
|
||||||
|
conf.barbutton[i].type = False;
|
||||||
|
conf.barbutton[i].content = strdup(var_to_str(cfg_getstr(cfgtmp2, "content")));
|
||||||
|
if(!conf.barbutton[i].type)
|
||||||
|
{
|
||||||
|
conf.barbutton[i].fg_color = strdup(var_to_str(cfg_getstr(cfgtmp2, "fg_color")));
|
||||||
|
conf.barbutton[i].bg_color = getcolor(strdup(var_to_str(cfg_getstr(cfgtmp2, "bg_color"))));
|
||||||
|
}
|
||||||
conf.barbutton[i].x = cfg_getint(cfgtmp2, "x");
|
conf.barbutton[i].x = cfg_getint(cfgtmp2, "x");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
draw.c
2
draw.c
@ -120,7 +120,7 @@ draw_layout(int x, int y)
|
|||||||
bar_moveresize(layoutsym, x, y, get_image_attribute(tags[seltag].layout.image)->width, barheight-1);
|
bar_moveresize(layoutsym, x, y, get_image_attribute(tags[seltag].layout.image)->width, barheight-1);
|
||||||
|
|
||||||
draw_image(layoutsym->dr, 0,
|
draw_image(layoutsym->dr, 0,
|
||||||
(barheight)/2 - get_image_attribute(tags[seltag].layout.image)->height/2,
|
(barheight/2 - get_image_attribute(tags[seltag].layout.image)->height/2),
|
||||||
tags[seltag].layout.image);
|
tags[seltag].layout.image);
|
||||||
|
|
||||||
bar_refresh(layoutsym);
|
bar_refresh(layoutsym);
|
||||||
|
|||||||
3
wmfs.h
3
wmfs.h
@ -119,7 +119,8 @@ typedef struct
|
|||||||
/* Bar Button */
|
/* Bar Button */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
char *text;
|
Bool type; /* False -> text, True -> image. */
|
||||||
|
char *content;
|
||||||
BarWindow *bw;
|
BarWindow *bw;
|
||||||
char *fg_color;
|
char *fg_color;
|
||||||
int bg_color;
|
int bg_color;
|
||||||
|
|||||||
36
wmfsrc
36
wmfsrc
@ -46,9 +46,9 @@ colors
|
|||||||
|
|
||||||
layouts
|
layouts
|
||||||
{
|
{
|
||||||
layout { type = "tile" image = "/" }
|
layout { type = "tile" image = "icons/tile.xpm" }
|
||||||
layout { type = "max" image = "/" }
|
layout { type = "max" image = "icons/max.xpm" }
|
||||||
layout { type = "free" image = "/" }
|
layout { type = "free" image = "icons/free.xpm" }
|
||||||
}
|
}
|
||||||
|
|
||||||
tags
|
tags
|
||||||
@ -69,41 +69,41 @@ buttons
|
|||||||
# MWFACT BUTTON {{{
|
# MWFACT BUTTON {{{
|
||||||
button
|
button
|
||||||
{
|
{
|
||||||
text = "[-]"
|
content = "[-]"
|
||||||
mouse { button = "Button1" func = "set_mwfact" cmd = "-0.01" }
|
mouse { button = "Button1" func = "set_mwfact" cmd = "-0.01" }
|
||||||
fg_color = "#FFFFFF"
|
fg_color = "#FFFFFF"
|
||||||
bg_color = "#191919"
|
bg_color = "#191919"
|
||||||
}
|
}
|
||||||
button
|
button
|
||||||
{
|
{
|
||||||
text = "Mwfact" fg_color = "#FFFFFF" bg_color = "#3E3E3E"
|
content = "Mwfact" fg_color = "#FFFFFF" bg_color = "#3E3E3E"
|
||||||
mouse { button = "Button4" func = "set_mwfact" cmd = "+0.01" }
|
mouse { button = "Button4" func = "set_mwfact" cmd = "+0.01" }
|
||||||
mouse { button = "Button5" func = "set_mwfact" cmd = "-0.01" }
|
mouse { button = "Button5" func = "set_mwfact" cmd = "-0.01" }
|
||||||
}
|
}
|
||||||
button
|
button
|
||||||
{
|
{
|
||||||
text = "[+] "
|
content = "[+] "
|
||||||
mouse { button = "Button1" func = "set_mwfact" cmd = "+0.01" }
|
mouse { button = "Button1" func = "set_mwfact" cmd = "+0.01" }
|
||||||
fg_color = "#FFFFFF"
|
fg_color = "#FFFFFF"
|
||||||
bg_color = "#191919"
|
bg_color = "#191919"
|
||||||
}
|
}
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# NMASTER BUTTON {{{
|
# NMASTER BUTTON {{{
|
||||||
button
|
button
|
||||||
{
|
{
|
||||||
text = "[-]"
|
content = "[-]"
|
||||||
mouse { button = "Button1" func = "set_nmaster" cmd = "-1" }
|
mouse { button = "Button1" func = "set_nmaster" cmd = "-1" }
|
||||||
fg_color = "#FFFFFF"
|
fg_color = "#FFFFFF"
|
||||||
bg_color = "#191919"
|
bg_color = "#191919"
|
||||||
}
|
}
|
||||||
button { text = "Nmaster" fg_color = "#FFFFFF" bg_color = "#3E3E3E" }
|
button { content = "Nmaster" fg_color = "#FFFFFF" bg_color = "#3E3E3E" }
|
||||||
button
|
button
|
||||||
{
|
{
|
||||||
text = "[+] "
|
content = "[+] "
|
||||||
mouse { button = "Button1" func = "set_nmaster" cmd = "+1" }
|
mouse { button = "Button1" func = "set_nmaster" cmd = "+1" }
|
||||||
fg_color = "#FFFFFF"
|
fg_color = "#FFFFFF"
|
||||||
bg_color = "#191919"
|
bg_color = "#191919"
|
||||||
}
|
}
|
||||||
# }}}
|
# }}}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user