Infobar: Add selbar; title of selected client in infobar (Feature #31 requested by markand), conf: [bar] selbar = true/false
This commit is contained in:
parent
fab6a9f584
commit
842bc7d3ce
@ -107,6 +107,9 @@ barwin_create(Window parent,
|
||||
void
|
||||
barwin_draw_text(BarWindow *bw, int x, int y, char *text)
|
||||
{
|
||||
if(!text)
|
||||
return;
|
||||
|
||||
/* Background color of the text if there is stipple */
|
||||
if(bw->stipple)
|
||||
draw_rectangle(bw->dr, x - 4, 0, textw(text) + 8, bw->geo.height, bw->bg);
|
||||
|
||||
11
src/client.c
11
src/client.c
@ -57,8 +57,8 @@ client_configure(Client *c)
|
||||
ev.type = ConfigureNotify;
|
||||
ev.event = c->win;
|
||||
ev.window = c->win;
|
||||
ev.x = c->geo.x;
|
||||
ev.y = c->geo.y;
|
||||
ev.x = spgeo[c->screen].x + c->geo.x;
|
||||
ev.y = spgeo[c->screen].y + c->geo.y;
|
||||
ev.width = c->geo.width;
|
||||
ev.height = c->geo.height;
|
||||
ev.above = None;
|
||||
@ -270,9 +270,16 @@ client_focus(Client *c)
|
||||
client_above(sel);
|
||||
|
||||
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
|
||||
|
||||
if(conf.bars.selbar)
|
||||
infobar_draw_selbar(sel->screen);
|
||||
}
|
||||
else
|
||||
{
|
||||
XSetInputFocus(dpy, ROOT, RevertToPointerRoot, CurrentTime);
|
||||
if(conf.bars.selbar)
|
||||
infobar_draw_selbar(selscreen);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -174,6 +174,7 @@ conf_bar_section(char *src)
|
||||
conf.bars.height = get_opt(src, "-1", "height").num;
|
||||
conf.colors.bar = getcolor(get_opt(src, "#000000", "bg").str);
|
||||
conf.colors.text = get_opt(src, "#ffffff", "fg").str;
|
||||
conf.bars.selbar = get_opt(src, "false", "selbar").bool;
|
||||
|
||||
if((conf.bars.nmouse = get_size_sec(src, "mouse")))
|
||||
{
|
||||
|
||||
@ -46,6 +46,9 @@ draw_text(Drawable d, int x, int y, char* fg, int pad, char *str)
|
||||
XftColor xftcolor;
|
||||
XftDraw *xftd;
|
||||
|
||||
if(!str)
|
||||
return;
|
||||
|
||||
/* Transform X Drawable -> Xft Drawable */
|
||||
xftd = XftDrawCreate(dpy, d, DefaultVisual(dpy, SCREEN), DefaultColormap(dpy, SCREEN));
|
||||
|
||||
|
||||
@ -100,6 +100,16 @@ infobar_init(void)
|
||||
conf.colors.layout_bg, conf.colors.layout_fg,
|
||||
False, False, conf.border.layout);
|
||||
|
||||
/* Selbar */
|
||||
if(conf.bars.selbar)
|
||||
infobar[sc].selbar = barwin_create(infobar[sc].bar->win,
|
||||
((conf.layout_placement)
|
||||
? (j + PAD / 2)
|
||||
: infobar[sc].layout_button->geo.x + infobar[sc].layout_button->geo.width + PAD / 2), 1,
|
||||
(sel) ? textw(sel->title) + PAD : 1,
|
||||
infobar[sc].geo.height - 2,
|
||||
conf.colors.bar, conf.colors.text, False, False, False);
|
||||
|
||||
/* Map/Refresh all */
|
||||
barwin_map(infobar[sc].bar);
|
||||
barwin_map_subwin(infobar[sc].bar);
|
||||
@ -110,12 +120,16 @@ infobar_init(void)
|
||||
if(conf.border.layout)
|
||||
barwin_map_subwin(infobar[sc].layout_button);
|
||||
|
||||
if(conf.bars.selbar)
|
||||
barwin_map(infobar[sc].selbar);
|
||||
|
||||
barwin_refresh_color(infobar[sc].bar);
|
||||
barwin_refresh(infobar[sc].bar);
|
||||
|
||||
/* Default statustext is set here */
|
||||
for(i = 0; i < s; ++i)
|
||||
infobar[i].statustext = _strdup(WMFS_VERSION);
|
||||
|
||||
infobar_draw(sc);
|
||||
}
|
||||
|
||||
@ -130,6 +144,7 @@ infobar_draw(int sc)
|
||||
{
|
||||
infobar_draw_taglist(sc);
|
||||
infobar_draw_layout(sc);
|
||||
infobar_draw_selbar(sc);
|
||||
barwin_refresh_color(infobar[sc].bar);
|
||||
statustext_handle(sc, infobar[sc].statustext);
|
||||
|
||||
@ -151,6 +166,29 @@ infobar_draw_layout(int sc)
|
||||
return;
|
||||
}
|
||||
|
||||
/** Draw Selbar (selected client title bar in infobar
|
||||
*\param sc Screen Number
|
||||
*/
|
||||
void
|
||||
infobar_draw_selbar(int sc)
|
||||
{
|
||||
if(!conf.bars.selbar)
|
||||
return;
|
||||
|
||||
barwin_move(infobar[sc].selbar,
|
||||
((conf.layout_placement)
|
||||
? (infobar[sc].tags_board->geo.x + infobar[sc].tags_board->geo.width + PAD / 2)
|
||||
: (infobar[sc].layout_button->geo.x + infobar[sc].layout_button->geo.width + PAD / 2)), 1);
|
||||
|
||||
barwin_resize(infobar[sc].selbar, textw(sel ? sel->title : NULL) + PAD, infobar[sc].geo.height - 2);
|
||||
barwin_refresh_color(infobar[sc].selbar);
|
||||
barwin_draw_text(infobar[sc].selbar, PAD / 2, FHINFOBAR - 1, (sel) ? sel->title : NULL);
|
||||
|
||||
barwin_refresh(infobar[sc].selbar);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Draw the taglist in the InfoBar
|
||||
*\param sc Screen number
|
||||
*/
|
||||
|
||||
@ -226,7 +226,7 @@ typedef struct
|
||||
/* InfoBar Struct */
|
||||
typedef struct
|
||||
{
|
||||
BarWindow *bar;
|
||||
BarWindow *bar, *selbar;
|
||||
BarWindow *layout_button;
|
||||
BarWindow *tags_board, *tags[MAXTAG];
|
||||
XRectangle geo;
|
||||
@ -345,6 +345,7 @@ typedef struct
|
||||
int height;
|
||||
MouseBinding *mouse;
|
||||
int nmouse;
|
||||
Bool selbar;
|
||||
} bars;
|
||||
struct
|
||||
{
|
||||
|
||||
@ -133,6 +133,7 @@ ushort textw(const char *text);
|
||||
void infobar_init(void);
|
||||
void infobar_draw(int sc);
|
||||
void infobar_draw_layout(int sc);
|
||||
void infobar_draw_selbar(int sc);
|
||||
void infobar_draw_taglist(int sc);
|
||||
void infobar_destroy(void);
|
||||
void infobar_set_position(int pos);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user