summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.arg.h2
-rw-r--r--config.default.h2
-rw-r--r--dwm.h9
-rw-r--r--event.c5
-rw-r--r--main.c2
-rw-r--r--view.c128
6 files changed, 112 insertions, 36 deletions
diff --git a/config.arg.h b/config.arg.h
index def5068..dfb9e1f 100644
--- a/config.arg.h
+++ b/config.arg.h
@@ -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 } }, \
diff --git a/config.default.h b/config.default.h
index 9fd8792..7fb22de 100644
--- a/config.default.h
+++ b/config.default.h
@@ -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 } }, \
diff --git a/dwm.h b/dwm.h
index ead92b3..4b85ea7 100644
--- a/dwm.h
+++ b/dwm.h
@@ -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 */
diff --git a/event.c b/event.c
index f4ac2d5..83e1b86 100644
--- a/event.c
+++ b/event.c
@@ -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);
diff --git a/main.c b/main.c
index a1fdde1..488ebc1 100644
--- a/main.c
+++ b/main.c
@@ -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;
diff --git a/view.c b/view.c
index b2ee32f..6697c90 100644
--- a/view.c
+++ b/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++;
@@ -319,6 +360,31 @@ toggleview(Arg *arg) {
}
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;