[ALL] Add new tile with nmaster, buttons in the conf for it...
This commit is contained in:
parent
01fef420f9
commit
a0a75186e6
24
config.c
24
config.c
@ -20,7 +20,7 @@ func_name_list_t func_list[] = {
|
||||
{"tag", tag},
|
||||
{"tagtransfert", tagtransfert},
|
||||
{"set_mwfact", set_mwfact},
|
||||
{"tile_switch", tile_switch}
|
||||
{"set_nmaster", set_nmaster}
|
||||
};
|
||||
|
||||
key_name_list_t key_list[] = {
|
||||
@ -115,17 +115,18 @@ init_conf(void) {
|
||||
CFG_END()
|
||||
};
|
||||
|
||||
static cfg_opt_t layout_opts[] = {
|
||||
static cfg_opt_t layouts_opts[] = {
|
||||
|
||||
CFG_STR_LIST("free","[Free]", CFGF_NONE),
|
||||
CFG_STR_LIST("tile","[Tile]", CFGF_NONE),
|
||||
CFG_STR_LIST("max","[Max]", CFGF_NONE),
|
||||
CFG_STR_LIST("free", "[Free]", CFGF_NONE),
|
||||
CFG_STR_LIST("tile", "[Tile]", CFGF_NONE),
|
||||
CFG_STR_LIST("max", "[Max]", CFGF_NONE),
|
||||
CFG_END()
|
||||
};
|
||||
|
||||
static cfg_opt_t tag_opts[] = {
|
||||
CFG_STR("name", "", CFGF_NONE),
|
||||
CFG_FLOAT("mwfact", 0.65, CFGF_NONE),
|
||||
CFG_INT("nmaster", 1, CFGF_NONE),
|
||||
CFG_STR("layout", "tile", CFGF_NONE),
|
||||
CFG_END()
|
||||
};
|
||||
@ -180,7 +181,7 @@ init_conf(void) {
|
||||
|
||||
CFG_SEC("misc", misc_opts, CFGF_NONE),
|
||||
CFG_SEC("colors", colors_opts, CFGF_NONE),
|
||||
CFG_SEC("layout", layout_opts, CFGF_NONE),
|
||||
CFG_SEC("layouts", layouts_opts, CFGF_NONE),
|
||||
CFG_SEC("tags", tags_opts, CFGF_NONE),
|
||||
CFG_SEC("keys", keys_opts, CFGF_NONE),
|
||||
CFG_SEC("buttons", buttons_opts, CFGF_NONE),
|
||||
@ -190,7 +191,7 @@ init_conf(void) {
|
||||
cfg_t *cfg;
|
||||
cfg_t *cfg_misc;
|
||||
cfg_t *cfg_colors;
|
||||
cfg_t *cfg_layout;
|
||||
cfg_t *cfg_layouts;
|
||||
cfg_t *cfg_tags;
|
||||
cfg_t *cfg_keys;
|
||||
cfg_t *cfg_buttons;
|
||||
@ -215,7 +216,7 @@ init_conf(void) {
|
||||
|
||||
cfg_misc = cfg_getsec(cfg, "misc");
|
||||
cfg_colors = cfg_getsec(cfg, "colors");
|
||||
cfg_layout = cfg_getsec(cfg, "layout");
|
||||
cfg_layouts = cfg_getsec(cfg, "layouts");
|
||||
cfg_tags = cfg_getsec(cfg, "tags");
|
||||
cfg_keys = cfg_getsec(cfg, "keys");
|
||||
cfg_buttons = cfg_getsec(cfg, "buttons");
|
||||
@ -236,9 +237,9 @@ init_conf(void) {
|
||||
conf.colors.tagselbg = cfg_getint(cfg_colors, "tag_sel_bg");
|
||||
|
||||
/* layout */
|
||||
conf.layouts.free = strdup(cfg_getstr(cfg_layout, "free"));
|
||||
conf.layouts.tile = strdup(cfg_getstr(cfg_layout, "tile"));
|
||||
conf.layouts.max = strdup(cfg_getstr(cfg_layout, "max"));
|
||||
conf.layouts.free = strdup(cfg_getstr(cfg_layouts, "free"));
|
||||
conf.layouts.tile = strdup(cfg_getstr(cfg_layouts, "tile"));
|
||||
conf.layouts.max = strdup(cfg_getstr(cfg_layouts, "max"));
|
||||
|
||||
/* tag */
|
||||
conf.ntag = cfg_size(cfg_tags, "tag");
|
||||
@ -246,6 +247,7 @@ init_conf(void) {
|
||||
cfgtmp = cfg_getnsec(cfg_tags, "tag", i);
|
||||
conf.tag[i].name = strdup(cfg_getstr(cfgtmp, "name"));
|
||||
conf.tag[i].mwfact = cfg_getfloat(cfgtmp, "mwfact");
|
||||
conf.tag[i].nmaster = cfg_getint(cfgtmp, "nmaster");
|
||||
conf.tag[i].layout = layout_name_to_layout(cfg_getstr(cfgtmp, "layout"));
|
||||
}
|
||||
|
||||
|
||||
16
local.h
16
local.h
@ -77,11 +77,11 @@ typedef struct {
|
||||
typedef struct {
|
||||
char *name;
|
||||
float mwfact;
|
||||
int nmaster;
|
||||
int layout;
|
||||
} Tag;
|
||||
|
||||
typedef struct {
|
||||
/* bool and size */
|
||||
char *font;
|
||||
bool raisefocus;
|
||||
bool raiseswitch;
|
||||
@ -114,6 +114,7 @@ enum { NetSupported, NetWMName, NetLast };
|
||||
enum { Free=0, Tile, Max};
|
||||
|
||||
/* wmfs.c */
|
||||
void arrange(void);
|
||||
void attach(Client *c);
|
||||
void buttonpress(XEvent *event);
|
||||
int clienthintpertag(int tag);
|
||||
@ -137,27 +138,30 @@ void hide(Client *c);
|
||||
void init(void);
|
||||
Bool ishide(Client *c);
|
||||
void keymovex(char *cmd);
|
||||
|
||||
void keymovey(char *cmd);
|
||||
void keypress(XEvent *e);
|
||||
void keyresize(char *cmd);
|
||||
void killclient(char *cmd);
|
||||
void layoutswitch(char *cmd);
|
||||
void lowerclient(Client *c);
|
||||
void mapclient(Client *c);
|
||||
void manage(Window w, XWindowAttributes *wa);
|
||||
void maxlayout(void);
|
||||
void mouseaction(Client *c, int x, int y, int type);
|
||||
void moveresize(Client *c, int x, int y, int w, int h, bool r);
|
||||
Client *nexttiled(Client *c);
|
||||
void raiseclient(Client *c);
|
||||
void scan(void);
|
||||
void setborder(Window win, int color);
|
||||
void set_mwfact(char *cmd);
|
||||
void set_nmaster(char *cmd);
|
||||
void setsizehints(Client *c);
|
||||
void spawn(char *cmd);
|
||||
void tag(char *cmd);
|
||||
void tagswitch(char *cmd);
|
||||
void tagtransfert(char *cmd);
|
||||
void tile(void);
|
||||
void tile_switch(char *cmd);
|
||||
void togglemax(char *cmd);
|
||||
void unhide(Client *c);
|
||||
void unmanage(Client *c);
|
||||
@ -191,15 +195,17 @@ int mw, mh;
|
||||
int fonth;
|
||||
int fonty;
|
||||
int barheight;
|
||||
Client *master[MAXTAG]; /* Master client by tag */
|
||||
int seltag;
|
||||
Client *clients; /* First Client */
|
||||
Client *sel; /* selected client */
|
||||
int seltag; /* selected tag */
|
||||
|
||||
Client *selbytag[MAXTAG];
|
||||
char status[16];
|
||||
|
||||
/* layout */
|
||||
float mwfact[MAXTAG];
|
||||
int nmaster[MAXTAG];
|
||||
int layout[MAXTAG];
|
||||
/**/
|
||||
char bartext[256];
|
||||
char *ptrb, bufbt[sizeof bartext];
|
||||
int readp;
|
||||
|
||||
364
wmfs.c
364
wmfs.c
@ -29,6 +29,19 @@
|
||||
unsigned int numlockmask = 0;
|
||||
int taglen[MAXTAG] = {3};
|
||||
|
||||
void
|
||||
arrange(void) {
|
||||
Client *c;
|
||||
for(c = clients; c; c = c->next)
|
||||
if(!ishide(c))
|
||||
unhide(c);
|
||||
else
|
||||
hide(c);
|
||||
updatelayout();
|
||||
updateall();
|
||||
focus(NULL);
|
||||
}
|
||||
|
||||
void
|
||||
attach(Client *c) {
|
||||
if(clients)
|
||||
@ -48,10 +61,11 @@ buttonpress(XEvent *event) {
|
||||
/* Tbar'n'Button */
|
||||
if(conf.ttbarheight) {
|
||||
if((c = gettbar(ev->window))) {
|
||||
focus(c);
|
||||
if(ev->button == Button1)
|
||||
mouseaction(c, ev->x_root, ev->y_root, Move); /* type 0 for move */
|
||||
else if(ev->button == Button2)
|
||||
tile_switch(NULL);
|
||||
togglemax(NULL);
|
||||
else if(ev->button == Button3)
|
||||
mouseaction(c, ev->x_root, ev->y_root, Resize); /* type 1 for resize */
|
||||
} else if((c = getbutton(ev->window))) {
|
||||
@ -68,7 +82,7 @@ buttonpress(XEvent *event) {
|
||||
if(ev->button == Button1)
|
||||
mouseaction(c, ev->x_root, ev->y_root, Move); /* type 0 for move */
|
||||
else if(ev->button == Button2)
|
||||
tile_switch(NULL);
|
||||
togglemax(NULL);
|
||||
else if(ev->button == Button3)
|
||||
mouseaction(c, ev->x_root, ev->y_root, Resize); /* type 1 for resize */
|
||||
}
|
||||
@ -125,10 +139,9 @@ int
|
||||
clienthintpertag(int tag) {
|
||||
Client *c;
|
||||
int i = 0;
|
||||
for(c = clients; c; c = c->next) {
|
||||
for(c = clients; c; c = c->next)
|
||||
if(c->tag == tag && c->hint)
|
||||
++i;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
@ -136,10 +149,9 @@ int
|
||||
clientpertag(int tag) {
|
||||
Client *c;
|
||||
int i = 0;
|
||||
for(c = clients; c; c = c->next) {
|
||||
for(c = clients; c; c = c->next)
|
||||
if(c->tag == tag)
|
||||
++i;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
@ -169,6 +181,7 @@ configurerequest(XEvent event) {
|
||||
XResizeWindow(dpy, c->tbar, wc.width, conf.ttbarheight);
|
||||
XMoveWindow(dpy, c->button, wc.x + wc.width - 10, BUTY(wc.y));
|
||||
}
|
||||
|
||||
updatetitle(c);
|
||||
c->y = wc.y;
|
||||
c->x = wc.x;
|
||||
@ -251,8 +264,7 @@ freelayout(void) {
|
||||
Client*
|
||||
getbutton(Window w) {
|
||||
Client *c;
|
||||
if(conf.ttbarheight)
|
||||
for(c = clients; c && c->button != w; c = c->next);
|
||||
for(c = clients; c && c->button != w; c = c->next);
|
||||
return c;
|
||||
}
|
||||
|
||||
@ -283,8 +295,7 @@ getlayoutsym(int l) {
|
||||
Client*
|
||||
gettbar(Window w) {
|
||||
Client *c;
|
||||
if(conf.ttbarheight)
|
||||
for(c = clients; c && c->tbar != w; c = c->next);
|
||||
for(c = clients; c && c->tbar != w; c = c->next);
|
||||
return c;
|
||||
}
|
||||
|
||||
@ -310,7 +321,8 @@ getevent(void) {
|
||||
switch (event.type) {
|
||||
case EnterNotify:
|
||||
if(event.xcrossing.mode != NotifyNormal
|
||||
|| event.xcrossing.detail == NotifyInferior) return;
|
||||
|| event.xcrossing.detail == NotifyInferior)
|
||||
return;
|
||||
if((c = getclient(event.xcrossing.window))
|
||||
|| (c = gettbar(event.xcrossing.window)))
|
||||
if(c->win != bar)
|
||||
@ -444,19 +456,19 @@ hide(Client *c) {
|
||||
if(!c || c->hide) return;
|
||||
long data[] = { IconicState, None };
|
||||
|
||||
/* unmapclient(c); */
|
||||
/* Just hide for now... */
|
||||
XMoveWindow(dpy, c->win, c->x, c->y+mh*2);
|
||||
/* unmapclient(c); */
|
||||
/* Just hide for now... */
|
||||
|
||||
XMoveWindow(dpy, c->win, c->x, c->y+mh*2);
|
||||
if(conf.ttbarheight) {
|
||||
XMoveWindow(dpy, c->tbar, c->x, c->y+mh*2);
|
||||
XMoveWindow(dpy, c->button, c->x, c->y+mh*2);
|
||||
}
|
||||
|
||||
c->hide = True;
|
||||
XChangeProperty(dpy, c->win, XInternAtom(dpy, "WM_STATE", False),
|
||||
XInternAtom(dpy, "WM_STATE", False), 32,
|
||||
PropModeReplace, (unsigned char *) data, 2);
|
||||
c->hide = True;
|
||||
}
|
||||
|
||||
void
|
||||
@ -472,10 +484,10 @@ init(void) {
|
||||
mw = DisplayWidth (dpy, screen);
|
||||
mh = DisplayHeight (dpy, screen);
|
||||
seltag = 1;
|
||||
init_conf();
|
||||
for(i = 0; i< conf.ntag; ++i) {
|
||||
for(i = 0; i< conf.ntag+1; ++i) {
|
||||
mwfact[i] = conf.tag[i-1].mwfact;
|
||||
layout[i] = conf.tag[i-1].layout;
|
||||
nmaster[i] = conf.tag[i-1].nmaster;
|
||||
}
|
||||
|
||||
/* INIT FONT */
|
||||
@ -644,7 +656,7 @@ killclient(char *cmd) {
|
||||
ev.xclient.data.l[1] = CurrentTime;
|
||||
XSendEvent(dpy, sel->win, False, NoEventMask, &ev);
|
||||
}
|
||||
updatelayout();
|
||||
arrange();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -661,22 +673,34 @@ layoutswitch(char *cmd) {
|
||||
switch(layout[seltag]) {
|
||||
case Free: maxlayout(); break;
|
||||
case Tile: freelayout(); break;
|
||||
case Max: tile(); break;
|
||||
case Max: tile(); break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
lowerclient(Client *c) {
|
||||
if(!c)
|
||||
return;
|
||||
if(conf.ttbarheight) {
|
||||
XLowerWindow(dpy,c->button);
|
||||
XLowerWindow(dpy,c->tbar);
|
||||
}
|
||||
XLowerWindow(dpy,c->win);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
mapclient(Client *c) {
|
||||
if(!c)
|
||||
return;
|
||||
XMapWindow(dpy, c->win);
|
||||
XMapSubwindows(dpy, c->win);
|
||||
if(conf.ttbarheight) {
|
||||
XMapWindow(dpy, c->tbar);
|
||||
XMapWindow(dpy, c->button);
|
||||
}
|
||||
XMapSubwindows(dpy, c->win);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -695,47 +719,54 @@ manage(Window w, XWindowAttributes *wa) {
|
||||
c->h = wa->height;
|
||||
c->border = wa->border_width;
|
||||
c->tag = seltag;
|
||||
switch(layout[seltag]) {
|
||||
case Tile: c->tile = True; break;
|
||||
case Max: c->max = True; break;
|
||||
}
|
||||
|
||||
setborder(w, conf.colors.bordernormal);
|
||||
if(conf.ttbarheight) {
|
||||
c->tbar =
|
||||
XCreateSimpleWindow(dpy, root,
|
||||
c->x,
|
||||
c->y - conf.ttbarheight,
|
||||
c->w,
|
||||
conf.ttbarheight,
|
||||
conf.borderheight,
|
||||
conf.colors.bordernormal,
|
||||
conf.colors.bar);
|
||||
c->button =
|
||||
XCreateSimpleWindow(dpy, root,
|
||||
c->x + c->w - 10,
|
||||
BUTY(c->y),
|
||||
5,
|
||||
BUTH,
|
||||
1,
|
||||
conf.colors.bordernormal,
|
||||
conf.colors.borderfocus);
|
||||
}
|
||||
|
||||
XConfigureWindow(dpy, w, CWBorderWidth, &winc);
|
||||
|
||||
setborder(w, conf.colors.bordernormal);
|
||||
grabbuttons(c, False);
|
||||
XSelectInput(dpy, w, EnterWindowMask | FocusChangeMask |
|
||||
PropertyChangeMask | StructureNotifyMask);
|
||||
setsizehints(c);
|
||||
updatetitle(c);
|
||||
|
||||
if((rettrans = XGetTransientForHint(dpy, w, &trans) == Success))
|
||||
for(t = clients; t && t->win != trans; t = t->next);
|
||||
|
||||
if(conf.ttbarheight) {
|
||||
c->tbar = XCreateSimpleWindow(dpy, root,
|
||||
c->x,
|
||||
c->y - conf.ttbarheight,
|
||||
c->w,
|
||||
conf.ttbarheight,
|
||||
conf.borderheight,
|
||||
conf.colors.bordernormal,
|
||||
conf.colors.bar);
|
||||
XSelectInput(dpy, c->tbar, ExposureMask | EnterWindowMask);
|
||||
setborder(c->tbar, conf.colors.bordernormal);
|
||||
|
||||
c->button = XCreateSimpleWindow(dpy, root,
|
||||
c->x + c->w - 10,
|
||||
BUTY(c->y),
|
||||
5,
|
||||
BUTH,
|
||||
1,
|
||||
conf.colors.bordernormal,
|
||||
conf.colors.borderfocus);
|
||||
}
|
||||
|
||||
grabbuttons(c, False);
|
||||
setsizehints(c);
|
||||
if(t)
|
||||
c->tag = t->tag;
|
||||
attach(c);
|
||||
moveresize(c, c->x, c->y, c->w, c->h, 1);
|
||||
|
||||
/* for when there are a free client
|
||||
over the tiled client */
|
||||
//if(c->tile)
|
||||
// lowerclient(c);
|
||||
|
||||
XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
|
||||
mapclient(c);
|
||||
updatetitle(c);
|
||||
focus(c);
|
||||
updatelayout();
|
||||
return;
|
||||
}
|
||||
@ -773,7 +804,8 @@ mouseaction(Client *c, int x, int y, int type) {
|
||||
int ocx, ocy;
|
||||
XEvent ev;
|
||||
|
||||
if((c->max && !c->hint) || (layout[seltag] == Tile && !c->hint))
|
||||
if((c->max && !c->hint)
|
||||
|| (layout[seltag] == Tile && !c->hint))
|
||||
return;
|
||||
ocx = c->x;
|
||||
ocy = c->y;
|
||||
@ -821,21 +853,25 @@ moveresize(Client *c, int x, int y, int w, int h, bool r) {
|
||||
if(c->minw > 0 && w < c->minw) {
|
||||
w = c->minw;
|
||||
c->hint = c->free = True;
|
||||
c->tile = False;
|
||||
}
|
||||
|
||||
if(c->minh > 0 && h < c->minh) {
|
||||
h = c->minh;
|
||||
c->hint = c->free = True;
|
||||
c->tile = False;
|
||||
}
|
||||
|
||||
if(c->maxw > 0 && w > c->maxw) {
|
||||
w = c->maxw;
|
||||
c->hint = c->free = True;
|
||||
c->tile = False;
|
||||
}
|
||||
|
||||
if(c->maxh > 0 && h > c->maxh) {
|
||||
h = c->maxh;
|
||||
c->hint = c-> free = True;
|
||||
c->tile = False;
|
||||
}
|
||||
|
||||
if(w <= 0 || h <= 0)
|
||||
@ -854,6 +890,7 @@ moveresize(Client *c, int x, int y, int w, int h, bool r) {
|
||||
y = barheight+conf.ttbarheight;
|
||||
|
||||
XMoveResizeWindow(dpy, c->win, x, y, w ,h);
|
||||
|
||||
if(conf.ttbarheight) {
|
||||
XMoveResizeWindow(dpy, c->tbar, x, y - conf.ttbarheight, w, conf.ttbarheight);
|
||||
XMoveResizeWindow(dpy, c->button,
|
||||
@ -869,15 +906,21 @@ moveresize(Client *c, int x, int y, int w, int h, bool r) {
|
||||
return;
|
||||
}
|
||||
|
||||
Client *
|
||||
nexttiled(Client *c) {
|
||||
for(; c && (c->hint || ishide(c)); c = c->next);
|
||||
return c;
|
||||
}
|
||||
|
||||
void
|
||||
raiseclient(Client *c) {
|
||||
if(c) {
|
||||
XRaiseWindow(dpy,c->win);
|
||||
if(!c)
|
||||
return;
|
||||
XRaiseWindow(dpy,c->win);
|
||||
|
||||
if(conf.ttbarheight) {
|
||||
XRaiseWindow(dpy,c->tbar);
|
||||
XRaiseWindow(dpy,c->button);
|
||||
}
|
||||
if(conf.ttbarheight) {
|
||||
XRaiseWindow(dpy,c->tbar);
|
||||
XRaiseWindow(dpy,c->button);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -901,7 +944,7 @@ scan(void) {
|
||||
}
|
||||
if(wins)
|
||||
XFree(wins);
|
||||
updatelayout();
|
||||
arrange();
|
||||
|
||||
return;
|
||||
}
|
||||
@ -918,12 +961,23 @@ set_mwfact(char *cmd) {
|
||||
double c;
|
||||
if(!(sscanf(cmd, "%lf", &c)))
|
||||
return;
|
||||
if(mwfact[seltag] + c > 0.9
|
||||
|| mwfact[seltag] + c < 0.1
|
||||
if(mwfact[seltag] + c > 0.95
|
||||
|| mwfact[seltag] + c < 0.05
|
||||
|| layout[seltag] != Tile)
|
||||
return;
|
||||
mwfact[seltag] += c;
|
||||
tile();
|
||||
arrange();
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
set_nmaster(char *cmd) {
|
||||
int n = atoi(cmd);
|
||||
if(nmaster[seltag] + n == 0)
|
||||
return;
|
||||
nmaster[seltag] += n;
|
||||
arrange();
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
@ -959,60 +1013,49 @@ setsizehints(Client *c) {
|
||||
|
||||
void
|
||||
spawn(char *cmd) {
|
||||
if(strlen(cmd) > 0 && !fork()) {
|
||||
execl(getenv("SHELL"), "sh", "-c", cmd, NULL);
|
||||
exit(1);
|
||||
if(!strlen(cmd))
|
||||
return;
|
||||
if(fork() == 0) {
|
||||
if(fork() == 0) {
|
||||
if(dpy)
|
||||
close(ConnectionNumber(dpy));
|
||||
setsid();
|
||||
execl(getenv("SHELL"), getenv("SHELL"), "-c", cmd, (char*)NULL);
|
||||
exit(1);
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
tag(char *cmd) {
|
||||
Client *c;
|
||||
int tmp = atoi(cmd);
|
||||
|
||||
if(tmp > conf.ntag || tmp < 1 || tmp == seltag)
|
||||
return;
|
||||
|
||||
for(c = clients; c; c = c->next) {
|
||||
if(!ishide(c))
|
||||
hide(c);
|
||||
if(c->tag == tmp)
|
||||
unhide(c);
|
||||
}
|
||||
|
||||
seltag = tmp;
|
||||
|
||||
if(selbytag[seltag])
|
||||
focus(selbytag[seltag]);
|
||||
|
||||
updateall();
|
||||
arrange();
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
tagswitch(char *cmd) {
|
||||
Client *c;
|
||||
int tmp;
|
||||
|
||||
tmp = atoi(cmd);
|
||||
|
||||
if(seltag + tmp > conf.ntag || seltag + tmp < 1)
|
||||
return;
|
||||
|
||||
for(c = clients; c; c = c->next) {
|
||||
if(c->tag == seltag)
|
||||
hide(c);
|
||||
if(c && c->tag == seltag + tmp)
|
||||
unhide(c);
|
||||
}
|
||||
|
||||
seltag += tmp;
|
||||
|
||||
if(selbytag[seltag])
|
||||
focus(selbytag[seltag]);
|
||||
|
||||
updateall();
|
||||
arrange();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1023,93 +1066,68 @@ tagtransfert(char *cmd) {
|
||||
if(!sel)
|
||||
return;
|
||||
sel->tag = n;
|
||||
if(n != seltag)
|
||||
hide(sel);
|
||||
|
||||
if(n == seltag)
|
||||
unhide(sel);
|
||||
|
||||
updatelayout();
|
||||
updateall();
|
||||
arrange();
|
||||
}
|
||||
|
||||
/* Testing for now */
|
||||
void
|
||||
tile(void) {
|
||||
layout[seltag] = Tile;
|
||||
unsigned int i, n, x, y, w, h, ww, hh, th;
|
||||
unsigned int barto, bord, mwf, nm;
|
||||
Client *c;
|
||||
int i;
|
||||
unsigned int y, h, wm, n;
|
||||
unsigned int barto, mwf, bord;
|
||||
|
||||
barto = conf.ttbarheight + barheight;
|
||||
bord = conf.borderheight * 2;
|
||||
mwf = mw*mwfact[seltag];
|
||||
n = clientpertag(seltag) - clienthintpertag(seltag);
|
||||
y = barto;
|
||||
wm = (mh-bord) - conf.ttbarheight - barheight;
|
||||
n = clientpertag(seltag) - clienthintpertag(seltag);
|
||||
bord = conf.borderheight * 2;
|
||||
barto = conf.ttbarheight + barheight;
|
||||
mwf = mwfact[seltag] * mw;
|
||||
nm = nmaster[seltag];
|
||||
|
||||
if(n-1)
|
||||
h = (mh - barheight) / (n - 1) - (conf.ttbarheight + bord);
|
||||
layout[seltag] = Tile;
|
||||
|
||||
for(i = 0, c = clients; c; c = c->next, ++i) {
|
||||
if(!ishide(c)) {
|
||||
c->max = c->free = False;
|
||||
c->tile = True;
|
||||
c->ox = c->x; c->oy = c->y;
|
||||
c->ow = c->w; c->oh = c->h;
|
||||
/* window geoms */
|
||||
hh = ((n <= nm) ? mh / (n > 0 ? n : 1) : mh / nm) - bord*2;
|
||||
ww = (n <= nm) ? mw : mwf;
|
||||
th = (n > nm) ? mh / (n - nm) : 0;
|
||||
if(n > nm && th < barheight)
|
||||
th = mh;
|
||||
|
||||
/* 1 clients, maximize it */
|
||||
if(n == 1)
|
||||
moveresize(c, 0, barto, mw-bord, wm, 0);
|
||||
/* 2 and more... , master client */
|
||||
else if(i == 0) {
|
||||
moveresize(c, 0, barto, mwf-conf.borderheight, wm, 0);
|
||||
master[seltag] = c;
|
||||
}
|
||||
/* other clients */
|
||||
else {
|
||||
moveresize(c, (mwf+conf.borderheight), y, (mw-mwf-bord-conf.borderheight), h, 0);
|
||||
if(i < i + 1)
|
||||
y += h + bord + conf.ttbarheight;
|
||||
}
|
||||
/* when a client is out of screen */
|
||||
if(c->y > mh) {
|
||||
moveresize(c, 0, barto, mwf - conf.borderheight, wm, 0);
|
||||
master[seltag] = c;
|
||||
}
|
||||
x = 0;
|
||||
y = barto;
|
||||
|
||||
for(i = 0, c = nexttiled(clients); c; c = nexttiled(c->next), i++) {
|
||||
c->max = c->free = False;
|
||||
c->tile = True;
|
||||
c->ox = c->x; c->oy = c->y;
|
||||
c->ow = c->w; c->oh = c->h;
|
||||
/* MASTER CLIENT */
|
||||
if(i < nm) {
|
||||
y = barto + i * hh;
|
||||
w = ww - bord;
|
||||
h = hh;
|
||||
/* remainder */
|
||||
if(i + 1 == (n < nm ? n : nm))
|
||||
h = (mh - hh*i) - barheight ;
|
||||
h -= bord + conf.ttbarheight;
|
||||
}
|
||||
/* TILE CLIENT */
|
||||
else {
|
||||
if(i == nm) {
|
||||
y = barto;
|
||||
x += ww;
|
||||
}
|
||||
w = mw - ww - bord;
|
||||
/* remainder */
|
||||
if(i + 1 == n)
|
||||
h = (barto + mh) - y - (bord + barto);
|
||||
else
|
||||
h = th - (bord + conf.ttbarheight) - bord*2;
|
||||
}
|
||||
moveresize(c, x, y, w, h, 0);
|
||||
if(n > nm && th != mh)
|
||||
y = c->y + c->h + bord + conf.ttbarheight;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
tile_switch(char *cmd) {
|
||||
if(layout[seltag] != Tile)
|
||||
return;
|
||||
Client *tmp;
|
||||
int sx, sy, sw, sh;
|
||||
|
||||
if(sel == master[seltag]
|
||||
|| !master[seltag])
|
||||
return;
|
||||
|
||||
sx = sel->x;
|
||||
sy = sel->y;
|
||||
sw = sel->w;
|
||||
sh = sel->h;
|
||||
|
||||
moveresize(sel,
|
||||
master[seltag]->x,
|
||||
master[seltag]->y,
|
||||
master[seltag]->w,
|
||||
master[seltag]->h, 0);
|
||||
|
||||
moveresize(master[seltag], sx, sy, sw, sh, 0);
|
||||
tmp = master[seltag];
|
||||
master[seltag] = sel;
|
||||
focus(tmp);
|
||||
}
|
||||
|
||||
void
|
||||
togglemax(char *cmd) {
|
||||
@ -1144,22 +1162,23 @@ unhide(Client *c) {
|
||||
long data[] = { NormalState, None };
|
||||
|
||||
/* mapclient(c); */
|
||||
|
||||
XMoveWindow(dpy,c->win,c->x,c->y);
|
||||
if(conf.ttbarheight) {
|
||||
XMoveWindow(dpy,c->tbar,c->x, (c->y - conf.ttbarheight));
|
||||
XMoveWindow(dpy,c->button, (c->x + c->w -10), (c->y - 9));
|
||||
}
|
||||
|
||||
c->hide = False;
|
||||
XChangeProperty(dpy, c->win, XInternAtom(dpy, "WM_STATE", False),
|
||||
XInternAtom(dpy, "WM_STATE", False), 32,
|
||||
PropModeReplace, (unsigned char *) data, 2);
|
||||
c->hide = False;
|
||||
}
|
||||
|
||||
void
|
||||
unmanage(Client *c) {
|
||||
XSetErrorHandler(errorhandler);
|
||||
int i;
|
||||
c->hide = True;
|
||||
|
||||
sel = (sel == c) ? c->next : NULL;
|
||||
for(i = 0; i < conf.ntag; ++i)
|
||||
@ -1173,8 +1192,7 @@ unmanage(Client *c) {
|
||||
|
||||
detach(c);
|
||||
free(c);
|
||||
updatelayout();
|
||||
updateall();
|
||||
arrange();
|
||||
XSync(dpy, False);
|
||||
return;
|
||||
}
|
||||
@ -1193,6 +1211,7 @@ updatebar(void) {
|
||||
char buf[conf.ntag][100];
|
||||
char p[3];
|
||||
|
||||
|
||||
tm = localtime(<);
|
||||
lt = time(NULL);
|
||||
|
||||
@ -1222,13 +1241,20 @@ updatebar(void) {
|
||||
strlen(getlayoutsym(layout[seltag])));
|
||||
|
||||
/* Draw stdin */
|
||||
j = strlen(bartext);
|
||||
XSetForeground(dpy, gc, conf.colors.text);
|
||||
XDrawString(dpy, bar, gc, mw - j * fonty, fonth-1 , bartext ,j);
|
||||
XDrawLine(dpy, bar, gc, mw- j * fonty-5 , 0 , mw - j * fonty-5, barheight);
|
||||
|
||||
XSync(dpy, False);
|
||||
return;
|
||||
sprintf(bartext,"mwfact: %.2f nmaster: %i - %02i:%02i",
|
||||
mwfact[seltag],
|
||||
nmaster[seltag],
|
||||
tm->tm_hour,
|
||||
tm->tm_min);
|
||||
|
||||
j = strlen(bartext);
|
||||
XSetForeground(dpy, gc, conf.colors.text);
|
||||
XDrawString(dpy, bar, gc, mw - j * fonty, fonth-1 , bartext ,j);
|
||||
XDrawLine(dpy, bar, gc, mw- j * fonty-5 , 0 , mw - j * fonty-5, barheight);
|
||||
|
||||
XSync(dpy, False);
|
||||
return;
|
||||
}
|
||||
|
||||
/* if c is 0, you can execute this function for the first time
|
||||
@ -1390,6 +1416,7 @@ main(int argc,char **argv) {
|
||||
|
||||
if(!dpy) { printf("wmfs: cannot open X server\n"); exit(1); }
|
||||
|
||||
init_conf();
|
||||
init();
|
||||
scan();
|
||||
for(;;) {
|
||||
@ -1397,6 +1424,7 @@ main(int argc,char **argv) {
|
||||
/* getstdin(); */
|
||||
updatebar();
|
||||
getevent();
|
||||
updateall();
|
||||
}
|
||||
|
||||
XCloseDisplay(dpy);
|
||||
|
||||
46
wmfsrc
46
wmfsrc
@ -19,7 +19,7 @@ colors
|
||||
tag_sel_bg = 0x354B5C
|
||||
}
|
||||
|
||||
layout
|
||||
layouts
|
||||
{
|
||||
free = "[Free]"
|
||||
tile = "[Tile]"
|
||||
@ -28,7 +28,7 @@ layout
|
||||
|
||||
tags
|
||||
{
|
||||
tag { name = "one" mwfact = 0.65 layout = "tile"}
|
||||
tag { name = "one" mwfact = 0.65 nmaster = 2 layout = "tile"}
|
||||
tag { name = "two" }
|
||||
tag { name = "three" }
|
||||
tag { name = "four" }
|
||||
@ -43,6 +43,47 @@ buttons
|
||||
{
|
||||
buttons_font = "*-*-medium-*-10-*"
|
||||
|
||||
# MWFACT BUTTON {{{
|
||||
button
|
||||
{
|
||||
text = "[-]"
|
||||
mouse { button = "Button1" func = "set_mwfact" cmd = "-0.01"}
|
||||
fg_color = 0xFFFFFF
|
||||
bg_color = 0x090909
|
||||
}
|
||||
button
|
||||
{
|
||||
text = "Mwfact" fg_color = 0xFFFFFF bg_color = 0x3E3E3E
|
||||
mouse { button = "Button4" func = "set_mwfact" cmd = "+0.01"}
|
||||
mouse { button = "Button5" func = "set_mwfact" cmd = "-0.01"}
|
||||
}
|
||||
button
|
||||
{
|
||||
text = "[+] "
|
||||
mouse { button = "Button1" func = "set_mwfact" cmd = "+0.01"}
|
||||
fg_color = 0xFFFFFF
|
||||
bg_color = 0x090909
|
||||
}
|
||||
# }}}
|
||||
|
||||
# NMASTER BUTTON {{{
|
||||
button
|
||||
{
|
||||
text = "[-]"
|
||||
mouse { button = "Button1" func = "set_nmaster" cmd = "-1"}
|
||||
fg_color = 0xFFFFFF
|
||||
bg_color = 0x090909
|
||||
}
|
||||
button { text = "Nmaster" fg_color = 0xFFFFFF bg_color = 0x3E3E3E }
|
||||
button
|
||||
{
|
||||
text = "[+] "
|
||||
mouse { button = "Button1" func = "set_nmaster" cmd = "+1"}
|
||||
fg_color = 0xFFFFFF
|
||||
bg_color = 0x090909
|
||||
}
|
||||
# }}}
|
||||
|
||||
button
|
||||
{
|
||||
text = "Terminal"
|
||||
@ -67,7 +108,6 @@ keys
|
||||
key { mod = {"Control"} key = "Down" func = "layoutswitch" cmd = "-" }
|
||||
key { mod = {"Alt", "Shift"} key = "l" func = "set_mwfact" cmd = "+0.025" }
|
||||
key { mod = {"Alt", "Shift"} key = "h" func = "set_mwfact" cmd = "-0.025" }
|
||||
key { mod = {"Alt"} key = "d" func = "tile_switch" }
|
||||
|
||||
# moving client keybind
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user