added the new dotile as described on ml

new_dwm
Anselm R. Garbe 19 years ago
parent 8fa47ac679
commit fee8df6ccf

@ -36,6 +36,8 @@ static Key key[] = { \
{ MODKEY, XK_j, focusnext, { 0 } }, \
{ MODKEY, XK_k, focusprev, { 0 } }, \
{ MODKEY, XK_Return, zoom, { 0 } }, \
{ MODKEY, XK_b, togglestackpos, { 0 } }, \
{ MODKEY, XK_d, togglestackdir, { 0 } }, \
{ MODKEY, XK_g, resizecol, { .i = 20 } }, \
{ MODKEY, XK_s, resizecol, { .i = -20 } }, \
{ MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \

@ -30,6 +30,8 @@ static Key key[] = { \
{ MODKEY, XK_Tab, focusnext, { 0 } }, \
{ MODKEY|ShiftMask, XK_Tab, focusprev, { 0 } }, \
{ MODKEY, XK_Return, zoom, { 0 } }, \
{ MODKEY, XK_b, togglestackpos, { 0 } }, \
{ MODKEY, XK_d, togglestackdir, { 0 } }, \
{ MODKEY, XK_g, resizecol, { .i = 20 } }, \
{ MODKEY, XK_s, resizecol, { .i = -20 } }, \
{ MODKEY|ShiftMask, XK_1, tag, { .i = 0 } }, \

@ -102,7 +102,7 @@ struct Client {
extern const char *tags[]; /* all tags */
extern char stext[1024]; /* status text */
extern int bx, by, bw, bh, bmw; /* bar geometry, bar mode label width */
extern int master, screen, sx, sy, sw, sh; /* screen geometry, master width */
extern int master, screen, sx, sy, sw, sh; /* screen geometry, master dimension*/
extern unsigned int ntags, numlockmask; /* number of tags, dynamic lock mask */
extern void (*handler[LASTEvent])(XEvent *); /* event handler */
extern void (*arrange)(Arg *); /* arrange function, indicates mode */
@ -170,10 +170,13 @@ extern void dotile(Arg *arg); /* arranges all windows, arg is ignored */
extern void focusnext(Arg *arg); /* focuses next visible client, arg is ignored */
extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ignored */
extern Bool isvisible(Client *c); /* returns True if client is visible */
extern void resizecol(Arg *arg); /* resizes the master width with arg's index value */
extern void resizecol(Arg *arg); /* resizes the master dimension with arg's index value */
extern void restack(void); /* restores z layers of all clients */
extern void togglestackdir(Arg *arg); /* toggles stack direction */
extern void togglestackpos(Arg *arg); /* toggles stack position */
extern void togglemode(Arg *arg); /* toggles global arrange function (dotile/dofloat) */
extern void toggleview(Arg *arg); /* toggles the tag with arg's index (in)visible */
extern void updatemaster(void); /* updates master dimension */
extern void view(Arg *arg); /* views the tag with arg's index */
extern void viewall(Arg *arg); /* views all tags, arg is ignored */
extern void zoom(Arg *arg); /* zooms the focused client to master column, arg is ignored */
extern void zoom(Arg *arg); /* zooms the focused client to master area, arg is ignored */

@ -177,8 +177,9 @@ configurerequest(XEvent *e) {
configure(c);
XSync(dpy, False);
if(c->isfloat) {
if(isvisible(c))
resize(c, False, TopLeft);
resize(c, False, TopLeft);
if(!isvisible(c))
ban(c);
}
else
arrange(NULL);

@ -133,7 +133,7 @@ setup(void) {
sx = sy = 0;
sw = DisplayWidth(dpy, screen);
sh = DisplayHeight(dpy, screen);
master = ((stackpos == StackBottom ? sh - bh : sw) * MASTER) / 100;
updatemaster();
bx = by = 0;
bw = sw;

128
view.c

@ -148,52 +148,93 @@ dotile(Arg *arg) {
c->h = sh - 2 * BORDERPX - bh;
}
else if(i == 0) { /* master window */
c->x = sx;
if(stackpos == StackLeft)
c->x += master;
c->y = sy + bh;
if(isvertical) {
switch(stackpos) {
case StackLeft:
c->x = sx + stackw;
c->y = sy + bh;
c->w = master - 2 * BORDERPX;
c->h = sh - 2 * BORDERPX - bh;
}
else {
c->w = sw;
c->h = sh - bh - 2 * BORDERPX;
break;
case StackBottom:
c->x = sx;
c->y = sy + bh;
c->w = sw - 2 * BORDERPX;
c->h = master - 2 * BORDERPX;
break;
case StackRight:
c->x = sx;
c->y = sy + bh;
c->w = master - 2 * BORDERPX;
c->h = sh - bh - 2 * BORDERPX;
break;
}
}
else if((isvertical && th > bh) || (!isvertical && tw > MINW)) {
/* tile window */
c->x = sx;
if(isvertical)
c->y = sy + (i - 1) * th + bh;
else
c->y = sy + bh;
if(stackpos == StackRight)
c->x += master;
else if(stackpos == StackBottom)
c->y += master;
c->w = tw - 2 * BORDERPX;
c->h = th - 2 * BORDERPX;
if(i + 1 == n) { /* fixes for last tile to take up rest space */
if(isvertical)
c->h = sh - c->y - 2 * BORDERPX;
switch(stackpos) {
case StackLeft:
if(isvertical) {
c->x = sx;
c->y = sy + (i - 1) * th + bh;
if(i + 1 == n)
c->h = sh - c->y - 2 * BORDERPX;
}
else {
if(stackpos == StackLeft)
c->w = master - c->x - 2 * BORDERPX;
else
c->x = sx + (i - 1) * tw;
c->y = sy + bh;
if(i + 1 == n)
c->w = sx + stackw - c->x - 2 * BORDERPX;
}
break;
case StackBottom:
if(isvertical) {
c->x = sx;
c->y = sy + master + (i - 1) * th + bh;
if(i + 1 == n)
c->h = sh - c->y - 2 * BORDERPX;
}
else {
c->x = sx + (i - 1) * tw;
c->y = sy + bh + master;
if(i + 1 == n)
c->w = sw - c->x - 2 * BORDERPX;
}
break;
case StackRight:
if(isvertical) {
c->x = sx + master;
c->y = sy + (i - 1) * th + bh;
if(i + 1 == n)
c->h = sh - c->y - 2 * BORDERPX;
}
else {
c->x = sx + master + (i - 1) * tw;
c->y = sy + bh;
if(i + 1 == n)
c->w = sx + stackw - c->x - 2 * BORDERPX;
}
break;
}
}
else { /* fallback if th < bh resp. tw < MINW */
c->x = sx;
c->y = sy + bh;
if(stackpos == StackRight)
c->x += master;
else if(stackpos == StackBottom)
c->y += master;
c->w = stackw - 2 * BORDERPX;
c->h = stackh - 2 * BORDERPX;
switch(stackpos) {
case StackLeft:
c->x = sx;
c->y = sy + bh;
break;
case StackBottom:
c->x = sx;
c->y = sy + master;
break;
case StackRight:
c->x = sx + master;
c->y = sy + bh;
break;
}
}
resize(c, False, TopLeft);
i++;
@ -318,6 +359,31 @@ toggleview(Arg *arg) {
arrange(NULL);
}
void
togglestackdir(Arg *arg) {
if(arrange == dofloat)
return;
isvertical = !isvertical;
arrange(NULL);
}
void
togglestackpos(Arg *arg) {
if(arrange == dofloat)
return;
if(stackpos == StackBottom)
stackpos = STACKPOS;
else
stackpos = StackBottom;
updatemaster();
arrange(NULL);
}
void
updatemaster(void) {
master = ((stackpos == StackBottom ? sh - bh : sw) * MASTER) / 100;
}
void
view(Arg *arg) {
unsigned int i;
@ -339,6 +405,8 @@ viewall(Arg *arg) {
arrange(NULL);
}
void
zoom(Arg *arg) {
unsigned int n;

Loading…
Cancel
Save