Xinqi Bao's Git
projects
/
dwm.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
using MASTERWIDTH=640 and 32px steps by default (incmasterw())
[dwm.git]
/
layout.c
diff --git
a/layout.c
b/layout.c
index
6a65599
..
8756e00
100644
(file)
--- a/
layout.c
+++ b/
layout.c
@@
-2,6
+2,7
@@
* See LICENSE file for license details.
*/
#include "dwm.h"
* See LICENSE file for license details.
*/
#include "dwm.h"
+#include <stdlib.h>
unsigned int blw = 0;
Layout *lt = NULL;
unsigned int blw = 0;
Layout *lt = NULL;
@@
-30,7
+31,7
@@
tile(void) {
if(c->isbanned)
XMoveWindow(dpy, c->win, c->x, c->y);
c->isbanned = False;
if(c->isbanned)
XMoveWindow(dpy, c->win, c->x, c->y);
c->isbanned = False;
- if(c->is
versatile
)
+ if(c->is
untiled
)
continue;
c->ismax = False;
nx = wax;
continue;
c->ismax = False;
nx = wax;
@@
-69,30
+70,22
@@
LAYOUTS
/* extern */
void
/* extern */
void
-focus
next(Arg
arg) {
+focus
client(const char *
arg) {
Client *c;
Client *c;
- if(!sel)
+ if(!sel
|| !arg
)
return;
return;
- for(c = sel->next; c && !isvisible(c); c = c->next);
- if(!c)
- for(c = clients; c && !isvisible(c); c = c->next);
- if(c) {
-
focus(c
);
- restack();
+ if(atoi(arg) < 0) {
+ for(c = sel->prev; c && !isvisible(c); c = c->prev);
+ if(!c) {
+ for(c = clients; c && c->next; c = c->next);
+
for(; c && !isvisible(c); c = c->prev
);
+ }
}
}
-}
-
-void
-focusprev(Arg arg) {
- Client *c;
-
- if(!sel)
- return;
- for(c = sel->prev; c && !isvisible(c); c = c->prev);
- if(!c) {
- for(c = clients; c && c->next; c = c->next);
- for(; c && !isvisible(c); c = c->prev);
+ else {
+ for(c = sel->next; c && !isvisible(c); c = c->next);
+ if(!c)
+ for(c = clients; c && !isvisible(c); c = c->next);
}
if(c) {
focus(c);
}
if(c) {
focus(c);
@@
-101,26
+94,35
@@
focusprev(Arg arg) {
}
void
}
void
-incmasterw(Arg arg) {
+incmasterw(const char *arg) {
+ int i;
if(lt->arrange != tile)
return;
if(lt->arrange != tile)
return;
- if(
arg.i == 0
)
+ if(
!arg
)
masterw = MASTERWIDTH;
else {
masterw = MASTERWIDTH;
else {
- if(waw * (masterw + arg.i) / 1000 >= waw - 2 * BORDERPX
- || waw * (masterw + arg.i) / 1000 <= 2 * BORDERPX)
+ i = atoi(arg);
+ if(waw * (masterw + i) / 1000 >= waw - 2 * BORDERPX
+ || waw * (masterw + i) / 1000 <= 2 * BORDERPX)
return;
return;
- masterw +=
arg.
i;
+ masterw += i;
}
lt->arrange();
}
void
}
lt->arrange();
}
void
-incnmaster(Arg arg) {
- if((lt->arrange != tile) || (nmaster + arg.i < 1)
- || (wah / (nmaster + arg.i) <= 2 * BORDERPX))
- return;
- nmaster += arg.i;
+incnmaster(const char *arg) {
+ int i;
+
+ if(!arg)
+ nmaster = NMASTER;
+ else {
+ i = atoi(arg);
+ if((lt->arrange != tile) || (nmaster + i < 1)
+ || (wah / (nmaster + i) <= 2 * BORDERPX))
+ return;
+ nmaster += i;
+ }
if(sel)
lt->arrange();
else
if(sel)
lt->arrange();
else
@@
-142,7
+144,7
@@
initlayouts(void) {
Client *
nexttiled(Client *c) {
Client *
nexttiled(Client *c) {
- for(; c && (c->is
versatile
|| !isvisible(c)); c = c->next);
+ for(; c && (c->is
untiled
|| !isvisible(c)); c = c->next);
return c;
}
return c;
}
@@
-154,10
+156,10
@@
restack(void) {
drawstatus();
if(!sel)
return;
drawstatus();
if(!sel)
return;
- if(sel->is
versatile || lt->arrange == versa
tile)
+ if(sel->is
untiled || lt->arrange == un
tile)
XRaiseWindow(dpy, sel->win);
XRaiseWindow(dpy, sel->win);
- if(lt->arrange !=
versa
tile) {
- if(!sel->is
versatile
)
+ if(lt->arrange !=
un
tile) {
+ if(!sel->is
untiled
)
XLowerWindow(dpy, sel->win);
for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
if(c == sel)
XLowerWindow(dpy, sel->win);
for(c = nexttiled(clients); c; c = nexttiled(c->next)) {
if(c == sel)
@@
-170,10
+172,10
@@
restack(void) {
}
void
}
void
-setlayout(
Arg
arg) {
-
unsigned
int i;
+setlayout(
const char *
arg) {
+ int i;
- if(
arg.i == -1
) {
+ if(
!arg
) {
for(i = 0; i < nlayouts && lt != &layout[i]; i++);
if(i == nlayouts - 1)
lt = &layout[0];
for(i = 0; i < nlayouts && lt != &layout[i]; i++);
if(i == nlayouts - 1)
lt = &layout[0];
@@
-181,9
+183,10
@@
setlayout(Arg arg) {
lt = &layout[++i];
}
else {
lt = &layout[++i];
}
else {
- if(arg.i < 0 || arg.i >= nlayouts)
+ i = atoi(arg);
+ if(i < 0 || i >= nlayouts)
return;
return;
- lt = &layout[
arg.
i];
+ lt = &layout[i];
}
if(sel)
lt->arrange();
}
if(sel)
lt->arrange();
@@
-192,10
+195,10
@@
setlayout(Arg arg) {
}
void
}
void
-togglemax(
Arg
arg) {
+togglemax(
const char *
arg) {
XEvent ev;
XEvent ev;
- if(!sel ||
!sel->isversatile || sel->isfixed || lt->arrange != versatile
)
+ if(!sel ||
(lt->arrange != untile && !sel->isuntiled) || sel->isfixed
)
return;
if((sel->ismax = !sel->ismax)) {
sel->rx = sel->x;
return;
if((sel->ismax = !sel->ismax)) {
sel->rx = sel->x;
@@
-206,11
+209,12
@@
togglemax(Arg arg) {
}
else
resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True);
}
else
resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True);
+ drawstatus();
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
}
void
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
}
void
-
versa
tile(void) {
+
un
tile(void) {
Client *c;
for(c = clients; c; c = c->next) {
Client *c;
for(c = clients; c; c = c->next) {
@@
-233,11
+237,11
@@
versatile(void) {
}
void
}
void
-zoom(
Arg
arg) {
+zoom(
const char *
arg) {
unsigned int n;
Client *c;
unsigned int n;
Client *c;
- if(!sel || lt->arrange != tile || sel->is
versatile
)
+ if(!sel || lt->arrange != tile || sel->is
untiled
)
return;
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
n++;
return;
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
n++;