infobar: Add infobar.c and rename all infobar function
This commit is contained in:
parent
bc311b7ae6
commit
dece4e7c7c
@ -36,7 +36,8 @@ set(wmfs_src
|
|||||||
src/bar.c
|
src/bar.c
|
||||||
src/draw.c
|
src/draw.c
|
||||||
src/client.c
|
src/client.c
|
||||||
src/titlebar.c)
|
src/titlebar.c
|
||||||
|
src/infobar.c)
|
||||||
|
|
||||||
# Set the executable from the wmfs_src
|
# Set the executable from the wmfs_src
|
||||||
add_executable(wmfs ${wmfs_src})
|
add_executable(wmfs ${wmfs_src})
|
||||||
|
|||||||
57
src/bar.c
57
src/bar.c
@ -135,60 +135,3 @@ bar_refresh(BarWindow *bw)
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Top/Bottom Bar Manage Function */
|
|
||||||
void
|
|
||||||
updatebar(void)
|
|
||||||
{
|
|
||||||
char buf[256];
|
|
||||||
|
|
||||||
/* Refresh bar color */
|
|
||||||
bar_refresh_color(infobar.bar);
|
|
||||||
|
|
||||||
/* Draw taglist */
|
|
||||||
draw_taglist(infobar.bar->dr);
|
|
||||||
|
|
||||||
/* Draw layout symbol */
|
|
||||||
draw_layout();
|
|
||||||
|
|
||||||
/* Draw mwfact && nmaster info */
|
|
||||||
sprintf(buf, "mwfact: %.2f - nmaster: %d",
|
|
||||||
tags[seltag].mwfact,
|
|
||||||
tags[seltag].nmaster);
|
|
||||||
draw_text(infobar.bar->dr, infobar.lastsep + PAD/1.5, fonth, conf.colors.text, conf.colors.bar, 0, buf);
|
|
||||||
draw_rectangle(infobar.bar->dr, textw(buf) + infobar.lastsep + PAD,
|
|
||||||
0, conf.tagbordwidth, infobar.geo.height, conf.colors.tagbord);
|
|
||||||
|
|
||||||
/* Draw status text */
|
|
||||||
draw_text(infobar.bar->dr, mw - textw(infobar.statustext), fonth, conf.colors.text, conf.colors.bar, 0, infobar.statustext);
|
|
||||||
|
|
||||||
/* Bar border */
|
|
||||||
if(conf.tagbordwidth)
|
|
||||||
{
|
|
||||||
draw_rectangle(infobar.bar->dr, 0, ((conf.bartop) ? infobar.geo.height - 1: 0),
|
|
||||||
mw, 1, conf.colors.tagbord);
|
|
||||||
draw_rectangle(infobar.bar->dr, mw - textw(infobar.statustext) - 5,
|
|
||||||
0, conf.tagbordwidth, infobar.geo.height, conf.colors.tagbord);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Refresh the bar */
|
|
||||||
bar_refresh(infobar.bar);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
uicb_togglebarpos(uicb_t cmd)
|
|
||||||
{
|
|
||||||
conf.bartop = !conf.bartop;
|
|
||||||
if(conf.bartop)
|
|
||||||
sgeo.y = conf.titlebar.pos ? infobar.geo.height : infobar.geo.height + conf.titlebar.height;
|
|
||||||
else
|
|
||||||
sgeo.y = conf.titlebar.pos ? 0 : conf.titlebar.height;
|
|
||||||
infobar.geo.y = (conf.bartop) ? 0 : mh - infobar.geo.height;
|
|
||||||
bar_move(infobar.bar, 0, infobar.geo.y);
|
|
||||||
updatebar();
|
|
||||||
arrange();
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|||||||
38
src/config.c
38
src/config.c
@ -36,25 +36,25 @@
|
|||||||
|
|
||||||
func_name_list_t func_list[] =
|
func_name_list_t func_list[] =
|
||||||
{
|
{
|
||||||
{"spawn", uicb_spawn },
|
{"spawn", uicb_spawn },
|
||||||
{"client_kill", uicb_client_kill },
|
{"client_kill", uicb_client_kill },
|
||||||
{"client_prev", uicb_client_prev },
|
{"client_prev", uicb_client_prev },
|
||||||
{"client_next", uicb_client_next },
|
{"client_next", uicb_client_next },
|
||||||
{"togglemax", uicb_togglemax },
|
{"togglemax", uicb_togglemax },
|
||||||
{"layout_next", uicb_layout_next },
|
{"layout_next", uicb_layout_next },
|
||||||
{"layout_prev", uicb_layout_prev },
|
{"layout_prev", uicb_layout_prev },
|
||||||
{"tag", uicb_tag },
|
{"tag", uicb_tag },
|
||||||
{"tag_next", uicb_tag_next },
|
{"tag_next", uicb_tag_next },
|
||||||
{"tag_prev", uicb_tag_prev },
|
{"tag_prev", uicb_tag_prev },
|
||||||
{"tagtransfert", uicb_tagtransfert },
|
{"tagtransfert", uicb_tagtransfert },
|
||||||
{"set_mwfact", uicb_set_mwfact },
|
{"set_mwfact", uicb_set_mwfact },
|
||||||
{"set_nmaster", uicb_set_nmaster },
|
{"set_nmaster", uicb_set_nmaster },
|
||||||
{"quit", uicb_quit },
|
{"quit", uicb_quit },
|
||||||
{"togglebarpos", uicb_togglebarpos },
|
{"toggle_infobar_position", uicb_infobar_togglepos },
|
||||||
{"mouse_move", uicb_mousemove },
|
{"mouse_move", uicb_mousemove },
|
||||||
{"mouse_resize", uicb_resizemouse },
|
{"mouse_resize", uicb_resizemouse },
|
||||||
{"client_raise", uicb_client_raise },
|
{"client_raise", uicb_client_raise },
|
||||||
{"tile_switch", uicb_tile_switch }
|
{"tile_switch", uicb_tile_switch }
|
||||||
};
|
};
|
||||||
|
|
||||||
func_name_list_t layout_list[] =
|
func_name_list_t layout_list[] =
|
||||||
|
|||||||
85
src/draw.c
85
src/draw.c
@ -59,91 +59,6 @@ draw_text(Drawable d, int x, int y, char* fg, uint bg, int pad, char *str)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
draw_taglist(Drawable dr)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
char buf[conf.ntag][256];
|
|
||||||
char p[4];
|
|
||||||
taglen[0] = PAD/2;
|
|
||||||
|
|
||||||
for(i = 0; i < conf.ntag; ++i)
|
|
||||||
{
|
|
||||||
/* Make the tags string */
|
|
||||||
ITOA(p, client_pertag(i+1));
|
|
||||||
sprintf(buf[i], "%s<%s>", tags[i+1].name, (client_pertag(i+1)) ? p : "");
|
|
||||||
|
|
||||||
/* Draw the string */
|
|
||||||
draw_text(dr, taglen[i], fonth,
|
|
||||||
((i+1 == seltag) ? conf.colors.tagselfg : conf.colors.text),
|
|
||||||
((i+1 == seltag) ? conf.colors.tagselbg : conf.colors.bar), PAD, buf[i]);
|
|
||||||
|
|
||||||
/* Draw the tag separation */
|
|
||||||
draw_rectangle(dr, taglen[i] + textw(buf[i]) + PAD/2,
|
|
||||||
0, conf.tagbordwidth, infobar.geo.height, conf.colors.tagbord);
|
|
||||||
|
|
||||||
/* Edit taglen[i+1] for the next time */
|
|
||||||
taglen[i+1] = taglen[i] + textw(buf[i]) + PAD + conf.tagbordwidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
draw_layout(void)
|
|
||||||
{
|
|
||||||
int px, py, width;
|
|
||||||
char symbol[256];
|
|
||||||
|
|
||||||
/* Set symbol & position */
|
|
||||||
px = width = taglen[conf.ntag];
|
|
||||||
py = conf.bartop ? infobar.geo.y : infobar.geo.y + 1;
|
|
||||||
if(tags[seltag].layout.func == freelayout
|
|
||||||
|| tags[seltag].layout.func == maxlayout)
|
|
||||||
strcpy(symbol, tags[seltag].layout.symbol);
|
|
||||||
else
|
|
||||||
strcpy(symbol, conf.tile_symbol);
|
|
||||||
|
|
||||||
/* Draw layout name/symbol */
|
|
||||||
bar_refresh_color(infobar.layout_switch);
|
|
||||||
|
|
||||||
bar_move(infobar.layout_switch, px, py);
|
|
||||||
bar_resize(infobar.layout_switch, textw(symbol) + PAD, infobar.geo.height - 1);
|
|
||||||
draw_text(infobar.layout_switch->dr, PAD/2, fonth,
|
|
||||||
conf.colors.layout_fg,
|
|
||||||
conf.colors.layout_bg,
|
|
||||||
PAD, symbol);
|
|
||||||
width += textw(symbol) + PAD;
|
|
||||||
bar_refresh(infobar.layout_switch);
|
|
||||||
|
|
||||||
if(tags[seltag].layout.func == tile
|
|
||||||
|| tags[seltag].layout.func == tile_left
|
|
||||||
|| tags[seltag].layout.func == tile_top
|
|
||||||
|| tags[seltag].layout.func == tile_bottom
|
|
||||||
|| tags[seltag].layout.func == grid)
|
|
||||||
{
|
|
||||||
bar_map(infobar.layout_type_switch);
|
|
||||||
bar_refresh_color(infobar.layout_type_switch);
|
|
||||||
bar_move(infobar.layout_type_switch, px + infobar.layout_switch->geo.width + PAD/2, py);
|
|
||||||
bar_resize(infobar.layout_type_switch, textw(tags[seltag].layout.symbol) + PAD, infobar.geo.height - 1);
|
|
||||||
draw_text(infobar.layout_type_switch->dr, PAD/2, fonth,
|
|
||||||
conf.colors.layout_fg,
|
|
||||||
conf.colors.layout_bg,
|
|
||||||
PAD, tags[seltag].layout.symbol);
|
|
||||||
width += textw(tags[seltag].layout.symbol) + PAD * 1.5;
|
|
||||||
|
|
||||||
bar_refresh(infobar.layout_type_switch);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
bar_unmap(infobar.layout_type_switch);
|
|
||||||
|
|
||||||
/* Draw right separation */
|
|
||||||
infobar.lastsep = width + PAD / 2;
|
|
||||||
draw_rectangle(infobar.bar->dr, infobar.lastsep, 0, conf.tagbordwidth, infobar.geo.height, conf.colors.tagbord);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
draw_rectangle(Drawable dr, int x, int y, uint w, uint h, uint color)
|
draw_rectangle(Drawable dr, int x, int y, uint w, uint h, uint color)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -179,7 +179,7 @@ expose(XEvent ev)
|
|||||||
|
|
||||||
if(ev.xexpose.count == 0
|
if(ev.xexpose.count == 0
|
||||||
&& (ev.xexpose.window == infobar.bar->win))
|
&& (ev.xexpose.window == infobar.bar->win))
|
||||||
updatebar();
|
infobar_draw();
|
||||||
|
|
||||||
if(conf.titlebar.exist)
|
if(conf.titlebar.exist)
|
||||||
for(c = clients; c; c = c->next)
|
for(c = clients; c; c = c->next)
|
||||||
@ -345,7 +345,7 @@ mouseaction(Client *c, int x, int y, int type)
|
|||||||
if(type && !c->tile)
|
if(type && !c->tile)
|
||||||
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->geo.width, c->geo.height);
|
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->geo.width, c->geo.height);
|
||||||
XUngrabPointer(dpy, CurrentTime);
|
XUngrabPointer(dpy, CurrentTime);
|
||||||
updatebar();
|
infobar_draw();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(ev.type == MotionNotify)
|
else if(ev.type == MotionNotify)
|
||||||
|
|||||||
@ -50,7 +50,7 @@ arrange(void)
|
|||||||
else
|
else
|
||||||
client_focus(NULL);
|
client_focus(NULL);
|
||||||
|
|
||||||
updatebar();
|
infobar_draw();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -179,7 +179,7 @@ init(void)
|
|||||||
bar_map(infobar.bar);
|
bar_map(infobar.bar);
|
||||||
bar_map(infobar.layout_switch);
|
bar_map(infobar.layout_switch);
|
||||||
strcpy(infobar.statustext, "WMFS-" WMFS_VERSION);
|
strcpy(infobar.statustext, "WMFS-" WMFS_VERSION);
|
||||||
updatebar();
|
infobar_draw();
|
||||||
|
|
||||||
/* INIT WORKABLE SPACE GEOMETRY */
|
/* INIT WORKABLE SPACE GEOMETRY */
|
||||||
sgeo.x = 0;
|
sgeo.x = 0;
|
||||||
@ -243,7 +243,7 @@ mainloop(void)
|
|||||||
strncpy(infobar.statustext, sbuf, strlen(sbuf));
|
strncpy(infobar.statustext, sbuf, strlen(sbuf));
|
||||||
readstdin = False;
|
readstdin = False;
|
||||||
}
|
}
|
||||||
updatebar();
|
infobar_draw();
|
||||||
}
|
}
|
||||||
while(XPending(dpy))
|
while(XPending(dpy))
|
||||||
{
|
{
|
||||||
|
|||||||
10
src/wmfs.h
10
src/wmfs.h
@ -70,16 +70,18 @@ void bar_move(BarWindow *bw, int x, int y);
|
|||||||
void bar_resize(BarWindow *bw, uint w, uint h);
|
void bar_resize(BarWindow *bw, uint w, uint h);
|
||||||
void bar_refresh_color(BarWindow *bw);
|
void bar_refresh_color(BarWindow *bw);
|
||||||
void bar_refresh(BarWindow *bw);
|
void bar_refresh(BarWindow *bw);
|
||||||
void updatebar(void);
|
|
||||||
void uicb_togglebarpos(uicb_t);
|
|
||||||
|
|
||||||
/* draw.c */
|
/* draw.c */
|
||||||
void draw_text(Drawable d, int x, int y, char* fg, uint bg, int pad, char *str);
|
void draw_text(Drawable d, int x, int y, char* fg, uint bg, int pad, char *str);
|
||||||
void draw_taglist(Drawable dr);
|
|
||||||
void draw_layout(void);
|
|
||||||
void draw_rectangle(Drawable dr, int x, int y, uint w, uint h, uint color);
|
void draw_rectangle(Drawable dr, int x, int y, uint w, uint h, uint color);
|
||||||
ushort textw(const char *text);
|
ushort textw(const char *text);
|
||||||
|
|
||||||
|
/* infobar.c */
|
||||||
|
void infobar_draw(void);
|
||||||
|
void infobar_draw_layout(void);
|
||||||
|
void infobar_draw_taglist(Drawable dr);
|
||||||
|
void uicb_infobar_togglepos(uicb_t cmd);
|
||||||
|
|
||||||
/* client.c */
|
/* client.c */
|
||||||
int client_pertag(int tag);
|
int client_pertag(int tag);
|
||||||
void client_attach(Client *c);
|
void client_attach(Client *c);
|
||||||
|
|||||||
2
wmfsrc
2
wmfsrc
@ -102,7 +102,7 @@ keys
|
|||||||
key { mod = {"Alt"} key = "q" func = "client_kill" }
|
key { mod = {"Alt"} key = "q" func = "client_kill" }
|
||||||
key { mod = {"Control", "Alt", "Shift"} key = "q" func = "quit" }
|
key { mod = {"Control", "Alt", "Shift"} key = "q" func = "quit" }
|
||||||
key { mod = {"Control"} key = "m" func = "togglemax" }
|
key { mod = {"Control"} key = "m" func = "togglemax" }
|
||||||
key { mod = {"Control"} key = "b" func = "togglebarpos" }
|
key { mod = {"Control"} key = "b" func = "toggle_infobar_position" }
|
||||||
key { mod = {"Alt"} key = "Tab" func = "client_next" }
|
key { mod = {"Alt"} key = "Tab" func = "client_next" }
|
||||||
key { mod = {"Alt","Shift"} key = "Tab" func = "client_prev" }
|
key { mod = {"Alt","Shift"} key = "Tab" func = "client_prev" }
|
||||||
key { mod = {"Control"} key = "Right" func = "tag_next" }
|
key { mod = {"Control"} key = "Right" func = "tag_next" }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user