layout: Add second layout button when the selected layout is a tiling layout and InfoBar struct
This commit is contained in:
parent
e3dcf8ddf9
commit
8f38ec390e
86
src/bar.c
86
src/bar.c
@ -52,8 +52,8 @@ bar_create(int x, int y, uint w, uint h, int bord, uint color, Bool entermask)
|
||||
CopyFromParent, DefaultVisual(dpy, screen),
|
||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &at);
|
||||
|
||||
bw->x = x; bw->y = y;
|
||||
bw->w = w; bw->h = h;
|
||||
bw->geo.x = x; bw->geo.y = y;
|
||||
bw->geo.width = w; bw->geo.height = h;
|
||||
bw->bord = bord;
|
||||
bw->color = color;
|
||||
|
||||
@ -71,22 +71,49 @@ bar_delete(BarWindow *bw)
|
||||
}
|
||||
|
||||
void
|
||||
bar_moveresize(BarWindow *bw, int x, int y, uint w, uint h)
|
||||
bar_map(BarWindow *bw)
|
||||
{
|
||||
if(w != bw->w || h != bw->h)
|
||||
if(!bw->mapped)
|
||||
{
|
||||
XFreePixmap(dpy, bw->dr);
|
||||
bw->dr = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, screen));
|
||||
bw->w = w; bw->h = h;
|
||||
XMapRaised(dpy, bw->win);
|
||||
bw->mapped = True;
|
||||
}
|
||||
|
||||
if(x != bw->x || y != bw->y)
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
bar_unmap(BarWindow *bw)
|
||||
{
|
||||
if(bw->mapped)
|
||||
{
|
||||
bw->x = x;
|
||||
bw->y = y;
|
||||
XUnmapWindow(dpy, bw->win);
|
||||
bw->mapped = False;
|
||||
}
|
||||
|
||||
XMoveResizeWindow(dpy, bw->win, bw->x, bw->y, bw->w, bw->h);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
bar_move(BarWindow *bw, int x, int y)
|
||||
{
|
||||
bw->geo.x = x;
|
||||
bw->geo.y = y;
|
||||
|
||||
XMoveWindow(dpy, bw->win, x, y);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
bar_resize(BarWindow *bw, uint w, uint h)
|
||||
{
|
||||
bw->geo.width = w;
|
||||
bw->geo.height = h;
|
||||
XFreePixmap(dpy, bw->dr);
|
||||
bw->dr = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, screen));
|
||||
|
||||
XResizeWindow(dpy, bw->win, w, h);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -94,7 +121,7 @@ bar_moveresize(BarWindow *bw, int x, int y, uint w, uint h)
|
||||
void
|
||||
bar_refresh_color(BarWindow *bw)
|
||||
{
|
||||
draw_rectangle(bw->dr, 0, 0, bw->w, bw->h, bw->color);
|
||||
draw_rectangle(bw->dr, 0, 0, bw->geo.width, bw->geo.height, bw->color);
|
||||
if(bw->bord)
|
||||
XSetWindowBorder(dpy, bw->win, bw->color);
|
||||
|
||||
@ -104,7 +131,7 @@ bar_refresh_color(BarWindow *bw)
|
||||
void
|
||||
bar_refresh(BarWindow *bw)
|
||||
{
|
||||
XCopyArea(dpy, bw->dr, bw->win, gc, 0, 0, bw->w, bw->h, 0, 0);
|
||||
XCopyArea(dpy, bw->dr, bw->win, gc, 0, 0, bw->geo.width, bw->geo.height, 0, 0);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -116,10 +143,10 @@ updatebar(void)
|
||||
char buf[256];
|
||||
|
||||
/* Refresh bar color */
|
||||
bar_refresh_color(bar);
|
||||
bar_refresh_color(infobar.bar);
|
||||
|
||||
/* Draw taglist */
|
||||
draw_taglist(bar->dr);
|
||||
draw_taglist(infobar.bar->dr);
|
||||
|
||||
/* Draw layout symbol */
|
||||
draw_layout();
|
||||
@ -128,27 +155,24 @@ updatebar(void)
|
||||
sprintf(buf, "mwfact: %.2f - nmaster: %d",
|
||||
tags[seltag].mwfact,
|
||||
tags[seltag].nmaster);
|
||||
draw_text(bar->dr,
|
||||
taglen[conf.ntag] + textw(tags[seltag].layout.symbol) + conf.tagbordwidth + PAD,
|
||||
fonth, conf.colors.text, conf.colors.bar, 0, buf);
|
||||
draw_rectangle(bar->dr,
|
||||
taglen[conf.ntag] + textw(tags[seltag].layout.symbol) + textw(buf) + PAD * 2,
|
||||
0, conf.tagbordwidth, barheight, conf.colors.tagbord);
|
||||
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(bar->dr, mw - textw(bartext), fonth, conf.colors.text, conf.colors.bar, 0, bartext);
|
||||
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(bar->dr, 0, ((conf.bartop) ? barheight-1: 0),
|
||||
draw_rectangle(infobar.bar->dr, 0, ((conf.bartop) ? infobar.geo.height - 1: 0),
|
||||
mw, 1, conf.colors.tagbord);
|
||||
draw_rectangle(bar->dr, mw - textw(bartext) - 5,
|
||||
0, conf.tagbordwidth, barheight, 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(bar);
|
||||
bar_refresh(infobar.bar);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -158,15 +182,11 @@ uicb_togglebarpos(uicb_t cmd)
|
||||
{
|
||||
conf.bartop = !conf.bartop;
|
||||
if(conf.bartop)
|
||||
sgeo.y = conf.titlebar.pos ? barheight : barheight + conf.titlebar.height;
|
||||
sgeo.y = conf.titlebar.pos ? infobar.geo.height : infobar.geo.height + conf.titlebar.height;
|
||||
else
|
||||
sgeo.y = conf.titlebar.pos ? 0 : conf.titlebar.height;
|
||||
|
||||
if(conf.bartop)
|
||||
bary = 0;
|
||||
else
|
||||
bary = mh - barheight;
|
||||
bar_moveresize(bar, 0, bary, mw, barheight);
|
||||
infobar.geo.y = (conf.bartop) ? 0 : mh - infobar.geo.height;
|
||||
bar_move(infobar.bar, 0, infobar.geo.y);
|
||||
updatebar();
|
||||
arrange();
|
||||
|
||||
|
||||
@ -161,9 +161,6 @@ client_get(Window w)
|
||||
void
|
||||
client_hide(Client *c)
|
||||
{
|
||||
//XMoveWindow(dpy, c->win, c->geo.x + mw * 2, c->geo.y);
|
||||
//if(conf.titlebar.exist)
|
||||
// XMoveWindow(dpy, c->tbar->win, c->geo.x + mw * 2, c->geo.y);
|
||||
client_unmap(c);
|
||||
setwinstate(c->win, IconicState);
|
||||
|
||||
@ -210,6 +207,7 @@ client_map(Client *c)
|
||||
bar_refresh(c->tbar);
|
||||
}
|
||||
XMapWindow(dpy, c->win);
|
||||
XMapSubwindows(dpy, c->win);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -433,9 +431,6 @@ uicb_client_raise(uicb_t cmd)
|
||||
void
|
||||
client_unhide(Client *c)
|
||||
{
|
||||
//XMoveWindow(dpy, c->win, c->geo.x, c->geo.y);
|
||||
//if(conf.titlebar.exist)
|
||||
// titlebar_update_position(c);
|
||||
client_map(c);
|
||||
setwinstate(c->win, NormalState);
|
||||
|
||||
@ -475,6 +470,7 @@ client_unmap(Client *c)
|
||||
return;
|
||||
|
||||
XUnmapWindow(dpy, c->win);
|
||||
XUnmapSubwindows(dpy, c->win);
|
||||
if(conf.titlebar.exist)
|
||||
XUnmapWindow(dpy, c->tbar->win);
|
||||
|
||||
|
||||
21
src/config.c
21
src/config.c
@ -59,11 +59,11 @@ func_name_list_t func_list[] =
|
||||
|
||||
func_name_list_t layout_list[] =
|
||||
{
|
||||
{"tile", tile },
|
||||
{"tile_right", tile },
|
||||
{"tile_left", tile_left },
|
||||
{"tile_top", tile_top },
|
||||
{"tile_bottom", tile_bottom },
|
||||
{"grid", grid},
|
||||
{"tile_grid", grid},
|
||||
{"max", maxlayout },
|
||||
{"free", freelayout }
|
||||
};
|
||||
@ -139,7 +139,7 @@ layout_name_to_struct(Layout lt[], char *name)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < MAXLAYOUT; ++i)
|
||||
for(i = 0; i < NUM_OF_LAYOUT; ++i)
|
||||
if(lt[i].func == name_to_func(name, layout_list))
|
||||
return lt[i];
|
||||
|
||||
@ -225,6 +225,7 @@ init_conf(void)
|
||||
CFG_END()
|
||||
};
|
||||
|
||||
|
||||
static cfg_opt_t layout_opts[] =
|
||||
{
|
||||
CFG_STR("type", "", CFGF_NONE),
|
||||
@ -234,9 +235,10 @@ init_conf(void)
|
||||
|
||||
static cfg_opt_t layouts_opts[] =
|
||||
{
|
||||
CFG_STR("fg", "#FFFFFF", CFGF_NONE),
|
||||
CFG_STR("bg", "#292929", CFGF_NONE),
|
||||
CFG_SEC("layout", layout_opts, CFGF_MULTI),
|
||||
CFG_STR("fg", "#FFFFFF", CFGF_NONE),
|
||||
CFG_STR("bg", "#292929", CFGF_NONE),
|
||||
CFG_STR("tile_symbol", "TILE", CFGF_NONE),
|
||||
CFG_SEC("layout", layout_opts, CFGF_MULTI),
|
||||
CFG_END()
|
||||
};
|
||||
|
||||
@ -433,8 +435,9 @@ init_conf(void)
|
||||
/* layout */
|
||||
conf.colors.layout_fg = strdup(var_to_str(cfg_getstr(cfg_layouts, "fg")));
|
||||
conf.colors.layout_bg = getcolor(var_to_str(cfg_getstr(cfg_layouts, "bg")));
|
||||
conf.tile_symbol = var_to_str(cfg_getstr(cfg_layouts, "tile_symbol"));
|
||||
|
||||
if((conf.nlayout = cfg_size(cfg_layouts, "layout")) > MAXLAYOUT
|
||||
if((conf.nlayout = cfg_size(cfg_layouts, "layout")) > NUM_OF_LAYOUT
|
||||
|| !(conf.nlayout = cfg_size(cfg_layouts, "layout")))
|
||||
{
|
||||
fprintf(stderr, "WMFS Configuration: Too many or no layouts\n");
|
||||
@ -460,10 +463,12 @@ init_conf(void)
|
||||
conf.layout[i].symbol = strdup(var_to_str(cfg_getstr(cfgtmp, "symbol")));
|
||||
conf.layout[i].func = name_to_func(strdup(cfg_getstr(cfgtmp, "type")), layout_list);
|
||||
}
|
||||
if(conf.layout[i].func != freelayout
|
||||
&& conf.layout[i].func != maxlayout)
|
||||
++conf.ntilelayout;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* tag */
|
||||
/* if there is no tag in the conf or more than
|
||||
* MAXTAG (32) print an error and create only one. */
|
||||
|
||||
54
src/draw.c
54
src/draw.c
@ -42,7 +42,7 @@ draw_text(Drawable d, int x, int y, char* fg, uint bg, int pad, char *str)
|
||||
xftd = XftDrawCreate(dpy, d, DefaultVisual(dpy, screen), DefaultColormap(dpy, screen));
|
||||
|
||||
/* Color the text font */
|
||||
draw_rectangle(d, x - pad/2, 0, textw(str) + pad, barheight, bg);
|
||||
draw_rectangle(d, x - pad/2, 0, textw(str) + pad, infobar.geo.height, bg);
|
||||
|
||||
/* Alloc text color */
|
||||
XftColorAllocName(dpy, DefaultVisual(dpy, screen),
|
||||
@ -80,7 +80,7 @@ draw_taglist(Drawable dr)
|
||||
|
||||
/* Draw the tag separation */
|
||||
draw_rectangle(dr, taglen[i] + textw(buf[i]) + PAD/2,
|
||||
0, conf.tagbordwidth, barheight, conf.colors.tagbord);
|
||||
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;
|
||||
@ -92,16 +92,54 @@ draw_taglist(Drawable dr)
|
||||
void
|
||||
draw_layout(void)
|
||||
{
|
||||
/* Draw layout name / symbol */
|
||||
draw_text(bar->dr, taglen[conf.ntag], fonth,
|
||||
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,
|
||||
2, tags[seltag].layout.symbol);
|
||||
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 */
|
||||
draw_rectangle(bar->dr,
|
||||
taglen[conf.ntag] + textw(tags[seltag].layout.symbol) + PAD/2,
|
||||
0, conf.tagbordwidth, barheight, conf.colors.tagbord);
|
||||
infobar.lastsep = width + PAD / 2;
|
||||
draw_rectangle(infobar.bar->dr, infobar.lastsep, 0, conf.tagbordwidth, infobar.geo.height, conf.colors.tagbord);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
39
src/event.c
39
src/event.c
@ -64,7 +64,7 @@ buttonpress(XEvent ev)
|
||||
|
||||
/* Bar */
|
||||
{
|
||||
if(ev.xbutton.window == bar->win)
|
||||
if(ev.xbutton.window == infobar.bar->win)
|
||||
{
|
||||
/* Tag*/
|
||||
for(i = 0; i < conf.ntag + 1; ++i)
|
||||
@ -86,20 +86,29 @@ buttonpress(XEvent ev)
|
||||
if (ev.xbutton.button == Button5)
|
||||
uicb_tag("-1");
|
||||
}
|
||||
|
||||
/* Layout */
|
||||
}
|
||||
/* Layout */
|
||||
{
|
||||
if(ev.xbutton.window == infobar.layout_switch->win)
|
||||
{
|
||||
if(ev.xbutton.x >= taglen[conf.ntag]
|
||||
&& ev.xbutton.x <= taglen[conf.ntag]
|
||||
+ textw(tags[seltag].layout.symbol) + PAD/2)
|
||||
{
|
||||
if(ev.xbutton.button == Button1
|
||||
|| ev.xbutton.button == Button4)
|
||||
layoutswitch(True);
|
||||
if(ev.xbutton.button == Button3
|
||||
|| ev.xbutton.button == Button5)
|
||||
layoutswitch(False);
|
||||
}
|
||||
if(ev.xbutton.button == Button1
|
||||
|| ev.xbutton.button == Button4)
|
||||
layoutswitch(True);
|
||||
|
||||
if(ev.xbutton.button == Button3
|
||||
|| ev.xbutton.button == Button5)
|
||||
layoutswitch(False);
|
||||
}
|
||||
|
||||
if(ev.xbutton.window == infobar.layout_type_switch->win)
|
||||
{
|
||||
if(ev.xbutton.button == Button1
|
||||
|| ev.xbutton.button == Button4)
|
||||
layout_tile_switch(True);
|
||||
|
||||
if(ev.xbutton.button == Button3
|
||||
|| ev.xbutton.button == Button5)
|
||||
layout_tile_switch(False);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -169,7 +178,7 @@ expose(XEvent ev)
|
||||
Client *c;
|
||||
|
||||
if(ev.xexpose.count == 0
|
||||
&& (ev.xexpose.window == bar->win))
|
||||
&& (ev.xexpose.window == infobar.bar->win))
|
||||
updatebar();
|
||||
|
||||
if(conf.titlebar.exist)
|
||||
|
||||
24
src/layout.c
24
src/layout.c
@ -102,6 +102,29 @@ layoutswitch(Bool b)
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
layout_tile_switch(Bool b)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < conf.ntilelayout; ++i)
|
||||
{
|
||||
if(tags[seltag].layout.func == conf.layout[i].func
|
||||
&& (conf.layout[i].func != freelayout
|
||||
&& conf.layout[i].func != maxlayout))
|
||||
{
|
||||
if(b)
|
||||
tags[seltag].layout = conf.layout[(i + 1) % conf.ntilelayout];
|
||||
else
|
||||
tags[seltag].layout = conf.layout[(i + conf.ntilelayout - 1) % conf.ntilelayout];
|
||||
break;
|
||||
}
|
||||
}
|
||||
arrange();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
uicb_layout_next(uicb_t cmd)
|
||||
{
|
||||
@ -117,6 +140,7 @@ uicb_layout_prev(uicb_t cmd)
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
maxlayout(void)
|
||||
{
|
||||
|
||||
@ -37,7 +37,9 @@
|
||||
|
||||
#define NBUTTON 8
|
||||
#define MAXTAG 36
|
||||
#define MAXLAYOUT 7
|
||||
|
||||
#define NUM_OF_LAYOUT 7
|
||||
#define NUM_OF_TILE 5
|
||||
|
||||
/* Typedef */
|
||||
typedef const char* uicb_t;
|
||||
@ -58,10 +60,10 @@ typedef struct
|
||||
{
|
||||
Window win;
|
||||
Drawable dr;
|
||||
int x, y;
|
||||
uint w ,h;
|
||||
XRectangle geo;
|
||||
uint color;
|
||||
int bord;
|
||||
Bool mapped;
|
||||
} BarWindow;
|
||||
|
||||
/* Client Structure. */
|
||||
@ -111,6 +113,17 @@ typedef struct
|
||||
uicb_t cmd;
|
||||
} MouseBinding;
|
||||
|
||||
/* InfoBar Struct */
|
||||
typedef struct
|
||||
{
|
||||
BarWindow *bar;
|
||||
BarWindow *layout_switch;
|
||||
BarWindow *layout_type_switch;
|
||||
XRectangle geo;
|
||||
int lastsep;
|
||||
char statustext[1024];
|
||||
} InfoBar;
|
||||
|
||||
/* Surface \o/ */
|
||||
typedef struct
|
||||
{
|
||||
@ -191,11 +204,13 @@ typedef struct
|
||||
int nmouse;
|
||||
} titlebar;
|
||||
Tag tag[MAXTAG];
|
||||
Layout layout[MAXLAYOUT];
|
||||
Layout layout[NUM_OF_LAYOUT];
|
||||
char *tile_symbol;
|
||||
int ntag;
|
||||
int nkeybind;
|
||||
int nbutton;
|
||||
int nlayout;
|
||||
int ntilelayout;
|
||||
} Conf;
|
||||
|
||||
/* Config.c struct */
|
||||
|
||||
@ -97,9 +97,8 @@ titlebar_update_position(Client *c)
|
||||
y = c->geo.y + c->geo.height + conf.client.borderheight;
|
||||
break;
|
||||
}
|
||||
|
||||
bar_moveresize(c->tbar, c->geo.x, y, c->geo.width,
|
||||
conf.titlebar.height - conf.client.borderheight);
|
||||
bar_move(c->tbar, c->geo.x, y);
|
||||
bar_resize(c->tbar, c->geo.width, conf.titlebar.height - conf.client.borderheight);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -149,12 +148,11 @@ titlebar_update(Client *c)
|
||||
}
|
||||
|
||||
/* Set y text position (always at the middle) and fg color */
|
||||
pos_y = (fonth - (xftfont->descent )) + ((conf.titlebar.height - fonth) / 2);
|
||||
pos_y = (fonth - (xftfont->descent ) - 1) + ((conf.titlebar.height - fonth) / 2);
|
||||
|
||||
/* Draw title */
|
||||
draw_text(c->tbar->dr, pos_x, pos_y, fg, bg, 0, c->title);
|
||||
}
|
||||
|
||||
bar_refresh(c->tbar);
|
||||
|
||||
return;
|
||||
|
||||
36
src/wmfs.c
36
src/wmfs.c
@ -92,7 +92,9 @@ quit(void)
|
||||
XFreeCursor(dpy, cursor[CurNormal]);
|
||||
XFreeCursor(dpy, cursor[CurMove]);
|
||||
XFreeCursor(dpy, cursor[CurResize]);
|
||||
bar_delete(bar);
|
||||
bar_delete(infobar.bar);
|
||||
bar_delete(infobar.layout_switch);
|
||||
bar_delete(infobar.layout_type_switch);
|
||||
efree(keys);
|
||||
efree(conf.titlebar.mouse);
|
||||
efree(conf.client.mouse);
|
||||
@ -130,7 +132,7 @@ init(void)
|
||||
xftfont = XftFontOpenName(dpy, screen, "sans-10");
|
||||
}
|
||||
fonth = (xftfont->ascent + xftfont->descent);
|
||||
barheight = fonth + (float)4.5;
|
||||
infobar.geo.height = fonth + (float)4.5;
|
||||
|
||||
/* INIT CURSOR */
|
||||
cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
|
||||
@ -165,20 +167,28 @@ init(void)
|
||||
uicb_spawn(conf.root.background_command);
|
||||
|
||||
/* INIT BAR / BUTTON */
|
||||
bary = (conf.bartop) ? 0 : mh - barheight;
|
||||
bar = bar_create(0, bary, mw, barheight, 0, conf.colors.bar, False);
|
||||
XMapRaised(dpy, bar->win);
|
||||
strcpy(bartext, "WMFS-" WMFS_VERSION);
|
||||
/* bar */
|
||||
infobar.geo.y = (conf.bartop) ? 0 : mh - infobar.geo.height;
|
||||
infobar.bar = bar_create(0, infobar.geo.y, mw, infobar.geo.height, 0, conf.colors.bar, False);
|
||||
|
||||
/* layout button */
|
||||
infobar.layout_switch = bar_create(0, (conf.bartop) ? infobar.geo.y : infobar.geo.y + 1,
|
||||
1, infobar.geo.height - 1, 0,
|
||||
conf.colors.layout_bg, False);
|
||||
infobar.layout_type_switch = bar_create(0, infobar.geo.y, 1, infobar.geo.height, 0, conf.colors.layout_bg, False);
|
||||
bar_map(infobar.bar);
|
||||
bar_map(infobar.layout_switch);
|
||||
strcpy(infobar.statustext, "WMFS-" WMFS_VERSION);
|
||||
updatebar();
|
||||
|
||||
/* INIT WORKABLE SPACE GEOMETRY */
|
||||
sgeo.x = 0;
|
||||
if(conf.bartop)
|
||||
sgeo.y = conf.titlebar.pos ? barheight : barheight + conf.titlebar.height;
|
||||
sgeo.y = conf.titlebar.pos ? infobar.geo.height : infobar.geo.height + conf.titlebar.height;
|
||||
else
|
||||
sgeo.y = conf.titlebar.pos ? 0 : conf.titlebar.height;
|
||||
sgeo.width = DisplayWidth(dpy, screen);
|
||||
sgeo.height = DisplayHeight(dpy, screen) - (barheight + conf.titlebar.height);
|
||||
sgeo.height = DisplayHeight(dpy, screen) - (infobar.geo.height + conf.titlebar.height);
|
||||
|
||||
/* INIT STUFF */
|
||||
grabkeys();
|
||||
@ -194,12 +204,12 @@ void
|
||||
mainloop(void)
|
||||
{
|
||||
fd_set fd;
|
||||
char sbuf[sizeof bartext], *p;
|
||||
char sbuf[sizeof infobar.statustext], *p;
|
||||
int len, r, offset = 0;
|
||||
Bool readstdin = True;
|
||||
|
||||
len = sizeof bartext - 1;
|
||||
sbuf[len] = bartext[len] = '\0';
|
||||
len = sizeof infobar.statustext - 1;
|
||||
sbuf[len] = infobar.statustext[len] = '\0';
|
||||
|
||||
while(!exiting)
|
||||
{
|
||||
@ -218,7 +228,7 @@ mainloop(void)
|
||||
if(*p == '\n')
|
||||
{
|
||||
*p = '\0';
|
||||
strncpy(bartext, sbuf, len);
|
||||
strncpy(infobar.statustext, sbuf, len);
|
||||
p += r - 1;
|
||||
for(r = 0; *(p - r) && *(p - r) != '\n'; ++r);
|
||||
offset = r;
|
||||
@ -230,7 +240,7 @@ mainloop(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy(bartext, sbuf, strlen(sbuf));
|
||||
strncpy(infobar.statustext, sbuf, strlen(sbuf));
|
||||
readstdin = False;
|
||||
}
|
||||
updatebar();
|
||||
|
||||
17
src/wmfs.h
17
src/wmfs.h
@ -58,13 +58,16 @@
|
||||
#define MouseMask (ButtonMask | PointerMotionMask)
|
||||
#define KeyMask (KeyPressMask | KeyReleaseMask)
|
||||
#define ITOA(p ,n) sprintf(p, "%d", n)
|
||||
#define debug(p) fprintf(stderr, "debug: %f\n", p)
|
||||
#define debug(p) fprintf(stderr, "debug: %d\n", p)
|
||||
#define PAD 8
|
||||
|
||||
/* bar.c */
|
||||
BarWindow *bar_create(int x, int y, uint w, uint h, int bord, uint color, Bool entermask);
|
||||
void bar_delete(BarWindow *bw);
|
||||
void bar_moveresize(BarWindow *bw, int x, int y, uint w, uint h);
|
||||
void bar_map(BarWindow *bw);
|
||||
void bar_unmap(BarWindow *bw);
|
||||
void bar_move(BarWindow *bw, int x, int y);
|
||||
void bar_resize(BarWindow *bw, uint w, uint h);
|
||||
void bar_refresh_color(BarWindow *bw);
|
||||
void bar_refresh(BarWindow *bw);
|
||||
void updatebar(void);
|
||||
@ -144,6 +147,7 @@ void titlebar_update(Client *c);
|
||||
void arrange(void);
|
||||
void freelayout(void);
|
||||
void layoutswitch(Bool b);
|
||||
void layout_tile_switch(Bool b);
|
||||
void maxlayout(void);
|
||||
Client *nexttiled(Client *c);
|
||||
|
||||
@ -196,14 +200,11 @@ Cursor cursor[CurLast];
|
||||
int fonth;
|
||||
XftFont *xftfont;
|
||||
|
||||
/* Bar / Tags */
|
||||
BarWindow *bar;
|
||||
/* InfoBar */
|
||||
InfoBar infobar;
|
||||
Tag tags[MAXTAG];
|
||||
int barheight;
|
||||
char bartext[1024];
|
||||
int seltag;
|
||||
int taglen[MAXTAG];
|
||||
int bary;
|
||||
int seltag;
|
||||
|
||||
/* Important Client */
|
||||
Client *clients;
|
||||
|
||||
28
wmfsrc
28
wmfsrc
@ -7,7 +7,7 @@ variables
|
||||
|
||||
misc
|
||||
{
|
||||
font = "sans-9"
|
||||
font = "dejavu-9"
|
||||
raisefocus = false
|
||||
raiseswitch = true
|
||||
}
|
||||
@ -24,11 +24,15 @@ layouts
|
||||
fg = "#191919"
|
||||
bg = "#7E89A2"
|
||||
|
||||
layout { type = "tile" symbol = "TILE >" }
|
||||
layout { type = "tile_left" symbol = "TILE <" }
|
||||
layout { type = "tile_top" symbol = "TILE ^" }
|
||||
layout { type = "tile_bottom" symbol = "TILE v" }
|
||||
layout { type = "grid" symbol = "GRID" }
|
||||
# Tiling layouts
|
||||
tile_symbol = "TILE"
|
||||
layout { type = "tile_right" symbol = "RIGHT" }
|
||||
layout { type = "tile_left" symbol = "LEFT" }
|
||||
layout { type = "tile_top" symbol = "TOP" }
|
||||
layout { type = "tile_bottom" symbol = "BOTTOM" }
|
||||
layout { type = "tile_grid" symbol = "GRID" }
|
||||
|
||||
# Other
|
||||
layout { type = "max" symbol = "MAX" }
|
||||
layout { type = "free" symbol = "FREE" }
|
||||
}
|
||||
@ -38,7 +42,7 @@ tags
|
||||
sel_fg = "#191919"
|
||||
sel_bg = "#7E89A2"
|
||||
border = "#3F485E"
|
||||
border_width = 1
|
||||
border_width = 2
|
||||
|
||||
tag { name = "one" mwfact = 0.65 nmaster = 1 layout = "tile" resizehint = false }
|
||||
tag { name = "two" }
|
||||
@ -62,9 +66,9 @@ root
|
||||
|
||||
client
|
||||
{
|
||||
border_height = 1
|
||||
border_normal = "#3F485E"
|
||||
border_focus = "#7E89A2"
|
||||
border_height = 2
|
||||
border_normal = "#191919"
|
||||
border_focus = "#003366"
|
||||
modifier = "Alt"
|
||||
|
||||
mouse { button = "1" func = "client_raise" }
|
||||
@ -79,9 +83,9 @@ titlebar
|
||||
position = "top"
|
||||
height = 12
|
||||
bg_normal = "#191919"
|
||||
bg_focus = "#191919"
|
||||
bg_focus = "#003366"
|
||||
fg_normal = "#D4D4D4"
|
||||
fg_focus = "#D4D4D4"
|
||||
fg_focus = "#B4B4B4"
|
||||
text_align = "center"
|
||||
|
||||
mouse { button = "1" func = "client_raise" }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user