Xinqi Bao's Git
projects
/
dwm.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
my new 1920x1200 Z61p arrived, now I can use terminus in a sane way...
[dwm.git]
/
view.c
diff --git
a/view.c
b/view.c
index
93a8c66
..
daf0711
100644
(file)
--- a/
view.c
+++ b/
view.c
@@
-1,11
+1,8
@@
-/*
- * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
+/* (C)opyright MMVI 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"
-#define MINDIM 100
-
/* static */
static Client *
/* static */
static Client *
@@
-45,9
+42,9
@@
reorder(void) {
}
static void
}
static void
-togglemax(Client *c)
-{
+togglemax(Client *c) {
XEvent ev;
XEvent ev;
+
if((c->ismax = !c->ismax)) {
c->rx = c->x; c->x = sx;
c->ry = c->y; c->y = bh;
if((c->ismax = !c->ismax)) {
c->rx = c->x; c->x = sx;
c->ry = c->y; c->y = bh;
@@
-66,8
+63,7
@@
togglemax(Client *c)
/* extern */
/* extern */
-void (*arrange)(Arg *) = DEFMODE;
-StackPos stackpos = STACKPOS;
+void (*arrange)(void) = DEFMODE;
void
detach(Client *c) {
void
detach(Client *c) {
@@
-81,7
+77,7
@@
detach(Client *c) {
}
void
}
void
-dofloat(
Arg *arg
) {
+dofloat(
void
) {
Client *c;
for(c = clients; c; c = c->next) {
Client *c;
for(c = clients; c; c = c->next) {
@@
-98,100
+94,56
@@
dofloat(Arg *arg) {
restack();
}
restack();
}
-/* This algorithm is based on a (M)aster area and a (S)tacking area.
- * It supports following arrangements:
- * SSMMM MMMMM MMMSS
- * SSMMM SSSSS MMMSS
- */
void
void
-dotile(
Arg *arg
) {
-
int i, n, stackw, stackh, tw
, th;
+dotile(
void
) {
+
unsigned int i, n, mpx, stackw, stackh
, 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++;
-
- if(stackpos == StackBottom) {
- stackw = sw;
- stackh = sh - bh - master;
- }
- else {
- stackw = sw - master;
- stackh = sh - bh;
- }
-
- tw = stackw;
+ mpx = (sw * master) / 1000;
+ stackw = sw - mpx;
+ stackh = sh - bh;
+ th = stackh;
if(n > 1)
if(n > 1)
- th = stackh / (n - 1);
- else
- th = stackh;
+ th /= (n - 1);
- for(i = 0, c = clients; c; c = c->next)
{
+ for(i = 0, c = clients; c; c = c->next)
if(isvisible(c)) {
if(c->isfloat) {
resize(c, True, TopLeft);
continue;
}
c->ismax = False;
if(isvisible(c)) {
if(c->isfloat) {
resize(c, True, TopLeft);
continue;
}
c->ismax = False;
+ c->x = sx;
+ c->y = sy + bh;
if(n == 1) { /* only 1 window */
if(n == 1) { /* only 1 window */
- c->x = sx;
- c->y = sy + bh;
c->w = sw - 2 * BORDERPX;
c->h = sh - 2 * BORDERPX - bh;
}
else if(i == 0) { /* master window */
c->w = sw - 2 * BORDERPX;
c->h = sh - 2 * BORDERPX - bh;
}
else if(i == 0) { /* master window */
- c->x = sx;
- if(stackpos == StackLeft)
- c->x += stackw;
- c->y = sy + bh;
- switch(stackpos) {
- case StackLeft:
- case StackRight:
- c->w = master - 2 * BORDERPX;
- c->h = sh - bh - 2 * BORDERPX;
- break;
- case StackBottom:
- c->w = sw - 2 * BORDERPX;
- c->h = master - 2 * BORDERPX;
- break;
- }
+ c->w = mpx - 2 * BORDERPX;
+ c->h = sh - bh - 2 * BORDERPX;
}
}
- else if(th > bh) { /* tile window */
- c->x = sx;
- if(stackpos == StackRight)
- c->x += master;
- c->w = tw - 2 * BORDERPX;
- c->h = th - 2 * BORDERPX;
- switch(stackpos) {
- case StackLeft:
- case StackRight:
+ else { /* tile window */
+ c->x += mpx;
+ c->w = stackw - 2 * BORDERPX;
+ if(th > bh) {
c->y = sy + (i - 1) * th + bh;
if(i + 1 == n)
c->h = sh - c->y - 2 * BORDERPX;
c->y = sy + (i - 1) * th + bh;
if(i + 1 == n)
c->h = sh - c->y - 2 * BORDERPX;
- break;
- case StackBottom:
- c->y = sy + master + (i - 1) * th + bh;
- if(i + 1 == n)
- c->h = sh - c->y - 2 * BORDERPX;
- break;
+ else
+ c->h = th - 2 * BORDERPX;
}
}
- }
- else { /* fallback if th < bh */
- c->x = sx;
- if(stackpos == StackRight)
- c->x += master;
- c->y = sy + bh;
- if(stackpos == StackBottom)
- c->y += master;
- c->w = stackw - 2 * BORDERPX;
- c->h = stackh - 2 * BORDERPX;
+ else /* fallback if th < bh */
+ c->h = stackh - 2 * BORDERPX;
}
resize(c, False, TopLeft);
i++;
}
else
ban(c);
}
resize(c, False, TopLeft);
i++;
}
else
ban(c);
- }
+
if(!sel || !isvisible(sel)) {
for(c = stack; c && !isvisible(c); c = c->snext);
focus(c);
if(!sel || !isvisible(sel)) {
for(c = stack; c && !isvisible(c); c = c->snext);
focus(c);
@@
-205,7
+157,6
@@
focusnext(Arg *arg) {
if(!sel)
return;
if(!sel)
return;
-
if(!(c = getnext(sel->next)))
c = getnext(clients);
if(c) {
if(!(c = getnext(sel->next)))
c = getnext(clients);
if(c) {
@@
-220,7
+171,6
@@
focusprev(Arg *arg) {
if(!sel)
return;
if(!sel)
return;
-
if(!(c = getprev(sel->prev))) {
for(c = clients; c && c->next; c = c->next);
c = getprev(c);
if(!(c = getprev(sel->prev))) {
for(c = clients; c && c->next; c = c->next);
c = getprev(c);
@@
-243,7
+193,6
@@
isvisible(Client *c) {
void
resizecol(Arg *arg) {
void
resizecol(Arg *arg) {
- int s;
unsigned int n;
Client *c;
unsigned int n;
Client *c;
@@
-252,19
+201,17
@@
resizecol(Arg *arg) {
n++;
if(!sel || sel->isfloat || n < 2 || (arrange == dofloat))
return;
n++;
if(!sel || sel->isfloat || n < 2 || (arrange == dofloat))
return;
-
- s = stackpos == StackBottom ? sh - bh : sw;
if(sel == getnext(clients)) {
if(sel == getnext(clients)) {
- if(master + arg->i >
s - MINDIM || master + arg->i < MINDIM
)
+ if(master + arg->i >
950 || master + arg->i < 50
)
return;
master += arg->i;
}
else {
return;
master += arg->i;
}
else {
- if(master - arg->i >
s - MINDIM || master - arg->i < MINDIM
)
+ if(master - arg->i >
950 || master - arg->i < 50
)
return;
master -= arg->i;
}
return;
master -= arg->i;
}
- arrange(
NULL
);
+ arrange();
}
void
}
void
@@
-301,7
+248,7
@@
void
togglemode(Arg *arg) {
arrange = (arrange == dofloat) ? dotile : dofloat;
if(sel)
togglemode(Arg *arg) {
arrange = (arrange == dofloat) ? dotile : dofloat;
if(sel)
- arrange(
NULL
);
+ arrange();
else
drawstatus();
}
else
drawstatus();
}
@@
-315,19
+262,7
@@
toggleview(Arg *arg) {
if(i == ntags)
seltag[arg->i] = True; /* cannot toggle last view */
reorder();
if(i == ntags)
seltag[arg->i] = True; /* cannot toggle last view */
reorder();
- arrange(NULL);
-}
-
-void
-togglestackpos(Arg *arg) {
- if(arrange == dofloat)
- return;
- if(stackpos == StackBottom)
- stackpos = STACKPOS;
- else
- stackpos = StackBottom;
- master = ((stackpos == StackBottom ? sh - bh : sw) * MASTER) / 100;
- arrange(NULL);
+ arrange();
}
void
}
void
@@
-338,7
+273,7
@@
view(Arg *arg) {
seltag[i] = False;
seltag[arg->i] = True;
reorder();
seltag[i] = False;
seltag[arg->i] = True;
reorder();
- arrange(
NULL
);
+ arrange();
}
void
}
void
@@
-348,11
+283,9
@@
viewall(Arg *arg) {
for(i = 0; i < ntags; i++)
seltag[i] = True;
reorder();
for(i = 0; i < ntags; i++)
seltag[i] = True;
reorder();
- arrange(
NULL
);
+ arrange();
}
}
-
-
void
zoom(Arg *arg) {
unsigned int n;
void
zoom(Arg *arg) {
unsigned int n;
@@
-360,18
+293,15
@@
zoom(Arg *arg) {
if(!sel)
return;
if(!sel)
return;
-
if(sel->isfloat || (arrange == dofloat)) {
togglemax(sel);
return;
}
if(sel->isfloat || (arrange == dofloat)) {
togglemax(sel);
return;
}
-
for(n = 0, c = clients; c; c = c->next)
if(isvisible(c) && !c->isfloat)
n++;
if(n < 2 || (arrange == dofloat))
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)))
return;
if((c = sel) == nexttiled(clients))
if(!(c = nexttiled(c->next)))
return;
@@
-381,5
+311,5
@@
zoom(Arg *arg) {
c->next = clients;
clients = c;
focus(c);
c->next = clients;
clients = c;
focus(c);
- arrange(
NULL
);
+ arrange();
}
}