Xinqi Bao's Git
projects
/
dwm.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
adding some prevention that master clients get smaller than bh
[dwm.git]
/
view.c
diff --git
a/view.c
b/view.c
index
14cfc1d
..
793151d
100644
(file)
--- a/
view.c
+++ b/
view.c
@@
-1,4
+1,4
@@
-/* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
+/* (C)opyright MMVI
-MMVII
Anselm R. Garbe <garbeam at gmail dot com>
* See LICENSE file for license details.
*/
#include "dwm.h"
* See LICENSE file for license details.
*/
#include "dwm.h"
@@
-11,6
+11,40
@@
nexttiled(Client *c) {
return c;
}
return c;
}
+static Bool
+ismaster(Client *c) {
+ Client *cl;
+ unsigned int i;
+
+ for(cl = nexttiled(clients), i = 0; cl && cl != c; cl = nexttiled(cl->next), i++);
+ return i < nmaster;
+}
+
+static void
+pop(Client *c) {
+ detach(c);
+ if(clients)
+ clients->prev = c;
+ c->next = clients;
+ clients = c;
+}
+
+static void
+swap(Client *c1, Client *c2) {
+ Client tmp = *c1;
+ Client *cp = c1->prev;
+ Client *cn = c1->next;
+
+ *c1 = *c2;
+ c1->prev = cp;
+ c1->next = cn;
+ cp = c2->prev;
+ cn = c2->next;
+ *c2 = tmp;
+ c2->prev = cp;
+ c2->next = cn;
+}
+
static void
togglemax(Client *c) {
XEvent ev;
static void
togglemax(Client *c) {
XEvent ev;
@@
-34,6
+68,15
@@
togglemax(Client *c) {
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
}
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
}
+static Client *
+topofstack() {
+ Client *c;
+ unsigned int i;
+
+ for(c = nexttiled(clients), i = 0; c && i < nmaster; c = nexttiled(c->next), i++);
+ return (i < nmaster) ? NULL : c;
+}
+
/* extern */
void (*arrange)(void) = DEFMODE;
/* extern */
void (*arrange)(void) = DEFMODE;
@@
-69,13
+112,16
@@
dofloat(void) {
void
dotile(void) {
void
dotile(void) {
- unsigned int i, n, m
px, stack
w, th;
+ unsigned int i, n, m
w, mh, t
w, th;
Client *c;
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
n++;
Client *c;
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
n++;
- mpx = (waw * master) / 1000;
- stackw = waw - mpx;
+ /* window geoms */
+ mw = (n > nmaster) ? (waw * master) / 1000 : waw;
+ mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1);
+ tw = waw - mw;
+ th = (n > nmaster) ? wah / (n - nmaster) : 0;
for(i = 0, c = clients; c; c = c->next)
if(isvisible(c)) {
for(i = 0, c = clients; c; c = c->next)
if(isvisible(c)) {
@@
-86,20
+132,16
@@
dotile(void) {
c->ismax = False;
c->x = wax;
c->y = way;
c->ismax = False;
c->x = wax;
c->y = way;
- if(n == 1) { /* only 1 window */
- c->w = waw - 2 * BORDERPX;
- c->h = wah - 2 * BORDERPX;
- }
- else if(i == 0) { /* master window */
- c->w = mpx - 2 * BORDERPX;
- c->h = wah - 2 * BORDERPX;
- th = wah / (n - 1);
+ if(i < nmaster) {
+ c->y += i * mh;
+ c->w = mw - 2 * BORDERPX;
+ c->h = mh - 2 * BORDERPX;
}
else { /* tile window */
}
else { /* tile window */
- c->x += m
px
;
- c->w =
stack
w - 2 * BORDERPX;
+ c->x += m
w
;
+ c->w =
t
w - 2 * BORDERPX;
if(th > bh) {
if(th > bh) {
- c->y += (i -
1
) * th;
+ c->y += (i -
nmaster
) * th;
c->h = th - 2 * BORDERPX;
}
else /* fallback if th < bh */
c->h = th - 2 * BORDERPX;
}
else /* fallback if th < bh */
@@
-148,6
+190,15
@@
focusprev(Arg *arg) {
}
}
}
}
+void
+incnmaster(Arg *arg) {
+ if(nmaster + arg->i < 1 || (wah / (nmaster + arg->i) < bh))
+ return;
+ nmaster += arg->i;
+
+ arrange();
+}
+
Bool
isvisible(Client *c) {
unsigned int i;
Bool
isvisible(Client *c) {
unsigned int i;
@@
-234,7
+285,8
@@
view(Arg *arg) {
for(i = 0; i < ntags; i++)
seltag[i] = (arg->i == -1) ? True : False;
for(i = 0; i < ntags; i++)
seltag[i] = (arg->i == -1) ? True : False;
- seltag[arg->i] = True;
+ if(arg->i >= 0 && arg->i < ntags)
+ seltag[arg->i] = True;
arrange();
}
arrange();
}
@@
-249,19
+301,21
@@
zoom(Arg *arg) {
togglemax(sel);
return;
}
togglemax(sel);
return;
}
- for(n = 0, c = clients; c; c = c->next)
- if(isvisible(c) && !c->isfloat)
- n++;
- if(n < 2 || (arrange == dofloat))
- return;
- if((c = sel) == nexttiled(clients))
- if(!(c = nexttiled(c->next)))
+ for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
+ n++;
+
+ c = sel;
+ if(n <= nmaster || (arrange == dofloat))
+ pop(c);
+ else if(ismaster(sel)) {
+ if(!(c = topofstack()))
return;
return;
- detach(c);
- if(clients)
- clients->prev = c;
- c->next = clients;
- clients = c;
+ swap(c, sel);
+ c = sel;
+ }
+ else
+ pop(c);
+
focus(c);
arrange();
}
focus(c);
arrange();
}