Infobar: Complete requested feature #8 (By Cheaterman) infobar_position = "<pos>" by tag
This commit is contained in:
parent
0b3a2d1b8f
commit
74fd1d7c92
27
src/config.c
27
src/config.c
@ -138,16 +138,6 @@ conf_bar_section(cfg_t *cfg_b)
|
||||
conf.colors.bar = getcolor(alias_to_str(cfg_getstr(cfg_b, "bg")));
|
||||
conf.colors.text = _strdup(alias_to_str(cfg_getstr(cfg_b, "fg")));
|
||||
|
||||
if(!strcmp(_strdup(cfg_getstr(cfg_b, "position")),"none")
|
||||
|| !strcmp(_strdup(cfg_getstr(cfg_b, "position")), "hide")
|
||||
|| !strcmp(_strdup(cfg_getstr(cfg_b, "position")), "hidden"))
|
||||
conf.barpos = 0;
|
||||
else if(!strcmp(_strdup(cfg_getstr(cfg_b, "position")), "bottom")
|
||||
|| !strcmp(_strdup(cfg_getstr(cfg_b, "position")), "down"))
|
||||
conf.barpos = 1;
|
||||
else
|
||||
conf.barpos = 2;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -264,12 +254,13 @@ void
|
||||
conf_tag_section(cfg_t *cfg_t)
|
||||
{
|
||||
int i, j, k, l = 0;
|
||||
char *tmp;
|
||||
|
||||
/* If there is no tag in the conf or more than
|
||||
* MAXTAG (32) print an error and create only one.
|
||||
*/
|
||||
Tag default_tag = { "WMFS",
|
||||
0.50, 1, False,
|
||||
0.50, 1, False, IB_Top,
|
||||
layout_name_to_struct(conf.layout, "tile_right", conf.nlayout, layout_list) };
|
||||
|
||||
conf.tag_round = cfg_getbool(cfg_t, "tag_round");
|
||||
@ -301,6 +292,19 @@ conf_tag_section(cfg_t *cfg_t)
|
||||
tags[k][conf.ntag[k]].mwfact = cfg_getfloat(cfgtmp, "mwfact");
|
||||
tags[k][conf.ntag[k]].nmaster = cfg_getint(cfgtmp, "nmaster");
|
||||
tags[k][conf.ntag[k]].resizehint = cfg_getbool(cfgtmp, "resizehint");
|
||||
|
||||
tmp = _strdup(cfg_getstr(cfgtmp, "infobar_position"));
|
||||
|
||||
if(!strcmp(tmp ,"none")
|
||||
|| !strcmp(tmp, "hide")
|
||||
|| !strcmp(tmp, "hidden"))
|
||||
tags[k][conf.ntag[k]].barpos = IB_Hide;
|
||||
else if(!strcmp(tmp, "bottom")
|
||||
|| !strcmp(tmp, "down"))
|
||||
tags[k][conf.ntag[k]].barpos = IB_Bottom;
|
||||
else
|
||||
tags[k][conf.ntag[k]].barpos = IB_Top;
|
||||
|
||||
tags[k][conf.ntag[k]].layout = layout_name_to_struct(conf.layout, cfg_getstr(cfgtmp, "layout"),
|
||||
conf.nlayout, layout_list);
|
||||
}
|
||||
@ -318,6 +322,7 @@ conf_tag_section(cfg_t *cfg_t)
|
||||
}
|
||||
|
||||
seltag = emalloc(screen_count(), sizeof(int));
|
||||
|
||||
for(j = 0; j < screen_count(); ++j)
|
||||
seltag[j] = 1;
|
||||
|
||||
|
||||
@ -49,7 +49,6 @@ cfg_opt_t bar_opts[] =
|
||||
{
|
||||
CFG_STR("bg", "#090909", CFGF_NONE),
|
||||
CFG_STR("fg", "#6289A1", CFGF_NONE),
|
||||
CFG_STR("position", "top", CFGF_NONE),
|
||||
CFG_BOOL("border", cfg_false, CFGF_NONE),
|
||||
CFG_END()
|
||||
};
|
||||
@ -120,12 +119,13 @@ cfg_opt_t layouts_opts[] =
|
||||
|
||||
cfg_opt_t tag_opts[] =
|
||||
{
|
||||
CFG_INT("screen", -1, CFGF_NONE),
|
||||
CFG_STR("name", "", CFGF_NONE),
|
||||
CFG_FLOAT("mwfact", 0.65, CFGF_NONE),
|
||||
CFG_INT("nmaster", 1, CFGF_NONE),
|
||||
CFG_STR("layout", "tile_right", CFGF_NONE),
|
||||
CFG_BOOL("resizehint", cfg_false, CFGF_NONE),
|
||||
CFG_INT("screen", -1, CFGF_NONE),
|
||||
CFG_STR("name", "", CFGF_NONE),
|
||||
CFG_FLOAT("mwfact", 0.65, CFGF_NONE),
|
||||
CFG_INT("nmaster", 1, CFGF_NONE),
|
||||
CFG_STR("layout", "tile_right", CFGF_NONE),
|
||||
CFG_STR("infobar_position", "top", CFGF_NONE),
|
||||
CFG_BOOL("resizehint", cfg_false, CFGF_NONE),
|
||||
CFG_END()
|
||||
};
|
||||
|
||||
|
||||
100
src/infobar.c
100
src/infobar.c
@ -47,21 +47,22 @@ infobar_init(void)
|
||||
j = 0;
|
||||
infobar[sc].geo.height = INFOBARH;
|
||||
|
||||
if(!conf.barpos)
|
||||
switch(tags[sc][seltag[sc]].barpos)
|
||||
{
|
||||
case IB_Hide:
|
||||
sgeo[sc].y = TBARH;
|
||||
sgeo[selscreen].height += INFOBARH;
|
||||
infobar[selscreen].geo.y = -(infobar[selscreen].geo.height) * 2;
|
||||
}
|
||||
else if(conf.barpos == 1)
|
||||
{
|
||||
break;
|
||||
case IB_Bottom:
|
||||
sgeo[selscreen].y = TBARH;
|
||||
infobar[selscreen].geo.y = sgeo[selscreen].height + TBARH;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
default:
|
||||
case IB_Top:
|
||||
sgeo[sc].y = INFOBARH + TBARH;
|
||||
infobar[selscreen].geo.y = sgeo[selscreen].y - (INFOBARH + TBARH);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Create infobar barwindow */
|
||||
@ -94,6 +95,7 @@ infobar_init(void)
|
||||
barwin_refresh_color(infobar[sc].bar);
|
||||
barwin_refresh(infobar[sc].bar);
|
||||
|
||||
/* Default statustext is set here */
|
||||
strcpy(statustext, "WMFS-" WMFS_VERSION);
|
||||
infobar_draw(sc);
|
||||
}
|
||||
@ -183,6 +185,56 @@ infobar_destroy(void)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Set the infobar position
|
||||
* \param pos Position of the bar
|
||||
*/
|
||||
void
|
||||
infobar_set_position(int pos)
|
||||
{
|
||||
int th;
|
||||
|
||||
screen_get_sel();
|
||||
|
||||
if(XineramaIsActive(dpy))
|
||||
{
|
||||
int n = 0;
|
||||
XineramaScreenInfo *xsi = XineramaQueryScreens(dpy, &n);
|
||||
|
||||
th = xsi[selscreen].height;
|
||||
XFree(xsi);
|
||||
}
|
||||
else
|
||||
th = MAXH;
|
||||
|
||||
switch(pos)
|
||||
{
|
||||
case IB_Hide:
|
||||
sgeo[selscreen].y = TBARH;
|
||||
sgeo[selscreen].height = th - TBARH;
|
||||
infobar[selscreen].geo.y = -(infobar[selscreen].geo.height) * 2;
|
||||
break;
|
||||
case IB_Bottom:
|
||||
sgeo[selscreen].y = TBARH;
|
||||
sgeo[selscreen].height = th - INFOBARH - TBARH;
|
||||
infobar[selscreen].geo.y = sgeo[selscreen].height + TBARH;
|
||||
break;
|
||||
default:
|
||||
case IB_Top:
|
||||
sgeo[selscreen].y = INFOBARH + TBARH;
|
||||
sgeo[selscreen].height = th - INFOBARH - TBARH;
|
||||
infobar[selscreen].geo.y = sgeo[selscreen].y - (INFOBARH + TBARH);
|
||||
break;
|
||||
}
|
||||
|
||||
tags[selscreen][seltag[selscreen]].barpos = pos;
|
||||
|
||||
barwin_move(infobar[selscreen].bar, sgeo[selscreen].x - BORDH, infobar[selscreen].geo.y);
|
||||
infobar_draw(selscreen);
|
||||
ewmh_set_workarea();
|
||||
arrange(selscreen);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Toggle the infobar position
|
||||
* \param cmd uicb_t type unused
|
||||
@ -190,36 +242,10 @@ infobar_destroy(void)
|
||||
void
|
||||
uicb_infobar_togglepos(uicb_t cmd)
|
||||
{
|
||||
screen_get_sel();
|
||||
|
||||
conf.barpos = (conf.barpos < 2) ? conf.barpos + 1 : 0;
|
||||
|
||||
/* Hidden position */
|
||||
if(!conf.barpos)
|
||||
{
|
||||
sgeo[selscreen].y = TBARH;
|
||||
sgeo[selscreen].height += INFOBARH;
|
||||
infobar[selscreen].geo.y = -(infobar[selscreen].geo.height) * 2;
|
||||
}
|
||||
/* Bottom position */
|
||||
else if(conf.barpos == 1)
|
||||
{
|
||||
sgeo[selscreen].y = TBARH;
|
||||
sgeo[selscreen].height -= INFOBARH;
|
||||
infobar[selscreen].geo.y = sgeo[selscreen].height + TBARH;
|
||||
}
|
||||
/* Top position */
|
||||
else
|
||||
{
|
||||
sgeo[selscreen].y = INFOBARH + TBARH;
|
||||
infobar[selscreen].geo.y = sgeo[selscreen].y - (INFOBARH + TBARH);
|
||||
}
|
||||
|
||||
barwin_move(infobar[selscreen].bar, sgeo[selscreen].x - BORDH, infobar[selscreen].geo.y);
|
||||
infobar_draw(selscreen);
|
||||
ewmh_set_workarea();
|
||||
|
||||
arrange(selscreen);
|
||||
infobar_set_position((tags[selscreen][seltag[selscreen]].barpos
|
||||
= (tags[selscreen][seltag[selscreen]].barpos < 2)
|
||||
? tags[selscreen][seltag[selscreen]].barpos + 1
|
||||
: 0));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -50,6 +50,7 @@ arrange(int screen)
|
||||
|
||||
tags[screen][seltag[screen]].layout.func(screen);
|
||||
infobar_draw(screen);
|
||||
// infobar_set_position(tags[screen][seltag[screen]].barpos);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -39,7 +39,6 @@ void
|
||||
mouse_move(Client *c)
|
||||
{
|
||||
int ocx, ocy, mx, my;
|
||||
int oscreen = c->screen;
|
||||
int dint;
|
||||
uint duint;
|
||||
Window dw, sw;
|
||||
|
||||
11
src/screen.c
11
src/screen.c
@ -61,15 +61,17 @@ XRectangle
|
||||
screen_get_geo(int s)
|
||||
{
|
||||
int n = 0;
|
||||
int barpos = tags[selscreen][seltag[selscreen]].barpos;
|
||||
XRectangle geo;
|
||||
|
||||
|
||||
if(XineramaIsActive(dpy))
|
||||
{
|
||||
XineramaScreenInfo *xsi;
|
||||
|
||||
xsi = XineramaQueryScreens(dpy, &n);
|
||||
geo.x = xsi[s].x_org + BORDH;
|
||||
if(!conf.barpos || conf.barpos == 1)
|
||||
if(barpos == IB_Hide || barpos == IB_Bottom)
|
||||
geo.y = TBARH;
|
||||
else
|
||||
geo.y = xsi[s].y_org + INFOBARH + TBARH;
|
||||
@ -81,7 +83,7 @@ screen_get_geo(int s)
|
||||
else
|
||||
{
|
||||
geo.x = BORDH;
|
||||
if(!conf.barpos || conf.barpos == 1)
|
||||
if(barpos == IB_Hide || barpos == IB_Bottom)
|
||||
geo.y = TBARH;
|
||||
else
|
||||
geo.y = INFOBARH + TBARH;
|
||||
@ -101,14 +103,15 @@ int
|
||||
screen_get_with_geo(int x, int y)
|
||||
{
|
||||
int i, r = 0;
|
||||
int barpos = tags[selscreen][seltag[selscreen]].barpos;
|
||||
int yh;
|
||||
|
||||
if(!conf.barpos || conf.barpos == 1)
|
||||
if(barpos == IB_Hide || barpos == IB_Bottom)
|
||||
yh = (sgeo[i].y - TBARH);
|
||||
|
||||
for(i = 0; i < screen_count(); ++i)
|
||||
{
|
||||
if(!conf.barpos || conf.barpos == 1)
|
||||
if(barpos == IB_Hide || barpos == IB_Bottom)
|
||||
yh = (sgeo[i].y - TBARH);
|
||||
else
|
||||
yh = (sgeo[i].y - INFOBARH - TBARH);
|
||||
|
||||
@ -48,8 +48,11 @@ typedef unsigned char uchar;
|
||||
|
||||
/* Enum */
|
||||
enum { CurNormal, CurResize, CurMove, CurLast };
|
||||
/* Infobar position */
|
||||
enum { IB_Hide = 0, IB_Bottom = 1, IB_Top = 2 };
|
||||
typedef enum { Top, Bottom, Right, Left, Center, PositionLast } Position;
|
||||
|
||||
|
||||
/* Ewmh hints list */
|
||||
enum
|
||||
{
|
||||
@ -181,6 +184,7 @@ typedef struct
|
||||
BarWindow *layout_button;
|
||||
BarWindow *tags[MAXTAG];
|
||||
XRectangle geo;
|
||||
int position;
|
||||
char statustext[1024];
|
||||
} InfoBar;
|
||||
|
||||
@ -198,6 +202,7 @@ typedef struct
|
||||
float mwfact;
|
||||
int nmaster;
|
||||
Bool resizehint;
|
||||
int barpos;
|
||||
Layout layout;
|
||||
} Tag;
|
||||
|
||||
@ -254,7 +259,6 @@ typedef struct
|
||||
char *font;
|
||||
Bool raisefocus;
|
||||
Bool raiseswitch;
|
||||
int barpos;
|
||||
struct
|
||||
{
|
||||
/*
|
||||
|
||||
@ -61,6 +61,7 @@ tag_set(int tag)
|
||||
seltag[selscreen] = tag;
|
||||
}
|
||||
ewmh_get_current_desktop();
|
||||
infobar_set_position(tags[selscreen][seltag[selscreen]].barpos);
|
||||
arrange(selscreen);
|
||||
client_focus(NULL);
|
||||
|
||||
|
||||
@ -118,6 +118,7 @@ void infobar_draw(int sc);
|
||||
void infobar_draw_layout(int sc);
|
||||
void infobar_draw_taglist(int sc);
|
||||
void infobar_destroy(void);
|
||||
void infobar_set_position(int pos);
|
||||
void uicb_infobar_togglepos(uicb_t);
|
||||
|
||||
/* client.c */
|
||||
|
||||
5
wmfsrc
5
wmfsrc
@ -17,9 +17,6 @@ bar
|
||||
bg = "#191919"
|
||||
fg = "#D4D4D4"
|
||||
border = true
|
||||
|
||||
# Infobar position : top, bottom or hide.
|
||||
position = "top"
|
||||
}
|
||||
|
||||
layouts
|
||||
@ -55,7 +52,7 @@ tags
|
||||
# Border around the tag buttons
|
||||
border = true
|
||||
|
||||
tag { screen = 1 name = "one" mwfact = 0.65 nmaster = 1 layout = "tile_right" resizehint = false }
|
||||
tag { screen = 1 name = "one" mwfact = 0.65 nmaster = 1 layout = "tile_right" resizehint = false infobar_position = "top" }
|
||||
tag { name = "two" }
|
||||
tag { name = "three" }
|
||||
tag { name = "four" }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user