Browse Source

added the new dotile as described on ml

master
Anselm R. Garbe 18 years ago
parent
commit
fee8df6ccf
6 changed files with 112 additions and 36 deletions
  1. +2
    -0
      config.arg.h
  2. +2
    -0
      config.default.h
  3. +6
    -3
      dwm.h
  4. +3
    -2
      event.c
  5. +1
    -1
      main.c
  6. +98
    -30
      view.c

+ 2
- 0
config.arg.h View File

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


+ 2
- 0
config.default.h View File

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


+ 6
- 3
dwm.h View File

@ -102,7 +102,7 @@ struct Client {
extern const char *tags[]; /* all tags */ extern const char *tags[]; /* all tags */
extern char stext[1024]; /* status text */ extern char stext[1024]; /* status text */
extern int bx, by, bw, bh, bmw; /* bar geometry, bar mode label width */ 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 unsigned int ntags, numlockmask; /* number of tags, dynamic lock mask */
extern void (*handler[LASTEvent])(XEvent *); /* event handler */ extern void (*handler[LASTEvent])(XEvent *); /* event handler */
extern void (*arrange)(Arg *); /* arrange function, indicates mode */ 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 focusnext(Arg *arg); /* focuses next visible client, arg is ignored */
extern void focusprev(Arg *arg); /* focuses previous 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 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 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 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 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 view(Arg *arg); /* views the tag with arg's index */
extern void viewall(Arg *arg); /* views all tags, arg is ignored */ 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 */

+ 3
- 2
event.c View File

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


+ 1
- 1
main.c View File

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


+ 98
- 30
view.c View File

@ -148,52 +148,93 @@ dotile(Arg *arg) {
c->h = sh - 2 * BORDERPX - bh; c->h = sh - 2 * BORDERPX - bh;
} }
else if(i == 0) { /* master window */ 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->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; 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)) { else if((isvertical && th > bh) || (!isvertical && tw > MINW)) {
/* tile window */ /* 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->w = tw - 2 * BORDERPX;
c->h = th - 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 { 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; 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 */ 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->w = stackw - 2 * BORDERPX;
c->h = stackh - 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); resize(c, False, TopLeft);
i++; i++;
@ -318,6 +359,31 @@ toggleview(Arg *arg) {
arrange(NULL); 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 void
view(Arg *arg) { view(Arg *arg) {
unsigned int i; unsigned int i;
@ -339,6 +405,8 @@ viewall(Arg *arg) {
arrange(NULL); arrange(NULL);
} }
void void
zoom(Arg *arg) { zoom(Arg *arg) {
unsigned int n; unsigned int n;


Loading…
Cancel
Save