author | Anselm R. Garbe <garbeam@gmail.com> |
Sun, 26 Aug 2007 12:53:40 +0200 | |
changeset 976 | 7c117df5d202 |
parent 962 | 8d1df2c37229 |
child 979 | 1f295ac327ef |
permissions | -rw-r--r-- |
941
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
1 |
/* See LICENSE file for copyright and license details. */ |
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
2 |
#include "dwm.h" |
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
3 |
#include <stdio.h> |
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
4 |
|
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
5 |
/* static */ |
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
6 |
|
943
d0b93818f723
renamed MASTER into MWFACT, master into mwfact, and incmaster into addtomwfact
Anselm R. Garbe <garbeam@gmail.com>
parents:
941
diff
changeset
|
7 |
static double mwfact = MWFACT; |
941
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
8 |
|
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
9 |
/* extern */ |
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
10 |
|
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
11 |
void |
959
0aeefb841608
applied Jukka Salmi's setmwfact patch
Anselm R. Garbe <garbeam@gmail.com>
parents:
955
diff
changeset
|
12 |
setmwfact(const char *arg) { |
962
8d1df2c37229
applied Gottox mwfact patch
Anselm R. Garbe <garbeam@gmail.com>
parents:
959
diff
changeset
|
13 |
double delta; |
941
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
14 |
|
948 | 15 |
if(!isarrange(tile)) |
941
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
16 |
return; |
943
d0b93818f723
renamed MASTER into MWFACT, master into mwfact, and incmaster into addtomwfact
Anselm R. Garbe <garbeam@gmail.com>
parents:
941
diff
changeset
|
17 |
/* arg handling, manipulate mwfact */ |
955 | 18 |
if(arg == NULL) |
19 |
mwfact = MWFACT; |
|
20 |
else if(1 == sscanf(arg, "%lf", &delta)) { |
|
959
0aeefb841608
applied Jukka Salmi's setmwfact patch
Anselm R. Garbe <garbeam@gmail.com>
parents:
955
diff
changeset
|
21 |
if(arg[0] != '+' && arg[0] != '-') |
962
8d1df2c37229
applied Gottox mwfact patch
Anselm R. Garbe <garbeam@gmail.com>
parents:
959
diff
changeset
|
22 |
mwfact = delta; |
959
0aeefb841608
applied Jukka Salmi's setmwfact patch
Anselm R. Garbe <garbeam@gmail.com>
parents:
955
diff
changeset
|
23 |
else |
962
8d1df2c37229
applied Gottox mwfact patch
Anselm R. Garbe <garbeam@gmail.com>
parents:
959
diff
changeset
|
24 |
mwfact += delta; |
8d1df2c37229
applied Gottox mwfact patch
Anselm R. Garbe <garbeam@gmail.com>
parents:
959
diff
changeset
|
25 |
if(mwfact < 0.1) |
8d1df2c37229
applied Gottox mwfact patch
Anselm R. Garbe <garbeam@gmail.com>
parents:
959
diff
changeset
|
26 |
mwfact = 0.1; |
8d1df2c37229
applied Gottox mwfact patch
Anselm R. Garbe <garbeam@gmail.com>
parents:
959
diff
changeset
|
27 |
else if(mwfact > 0.9) |
8d1df2c37229
applied Gottox mwfact patch
Anselm R. Garbe <garbeam@gmail.com>
parents:
959
diff
changeset
|
28 |
mwfact = 0.9; |
941
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
29 |
} |
946
b938876de936
made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents:
943
diff
changeset
|
30 |
arrange(); |
941
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
31 |
} |
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
32 |
|
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
33 |
void |
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
34 |
tile(void) { |
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
35 |
unsigned int i, n, nx, ny, nw, nh, mw, th; |
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
36 |
Client *c; |
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
37 |
|
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
38 |
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) |
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
39 |
n++; |
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
40 |
|
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
41 |
/* window geoms */ |
943
d0b93818f723
renamed MASTER into MWFACT, master into mwfact, and incmaster into addtomwfact
Anselm R. Garbe <garbeam@gmail.com>
parents:
941
diff
changeset
|
42 |
mw = (n == 1) ? waw : mwfact * waw; |
941
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
43 |
th = (n > 1) ? wah / (n - 1) : 0; |
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
44 |
if(n > 1 && th < bh) |
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
45 |
th = wah; |
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
46 |
|
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
47 |
nx = wax; |
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
48 |
ny = way; |
976
7c117df5d202
prepared 4.4.1 bugfix and minor feature enhancement release
Anselm R. Garbe <garbeam@gmail.com>
parents:
962
diff
changeset
|
49 |
for(i = 0, c = nexttiled(clients); c; c = nexttiled(c->next), i++) { |
947 | 50 |
c->ismax = False; |
51 |
if(i == 0) { /* master */ |
|
52 |
nw = mw - 2 * c->border; |
|
53 |
nh = wah - 2 * c->border; |
|
54 |
} |
|
55 |
else { /* tile window */ |
|
56 |
if(i == 1) { |
|
57 |
ny = way; |
|
58 |
nx += mw; |
|
941
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
59 |
} |
947 | 60 |
nw = waw - mw - 2 * c->border; |
61 |
if(i + 1 == n) /* remainder */ |
|
62 |
nh = (way + wah) - ny - 2 * c->border; |
|
63 |
else |
|
64 |
nh = th - 2 * c->border; |
|
941
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
65 |
} |
947 | 66 |
resize(c, nx, ny, nw, nh, False); |
67 |
if(n > 1 && th != wah) |
|
68 |
ny += nh + 2 * c->border; |
|
69 |
} |
|
941
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
70 |
} |
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
71 |
|
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
72 |
void |
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
73 |
zoom(const char *arg) { |
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
74 |
Client *c; |
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
75 |
|
946
b938876de936
made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents:
943
diff
changeset
|
76 |
if(!sel || !isarrange(tile) || sel->isfloating) |
941
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
77 |
return; |
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
78 |
if((c = sel) == nexttiled(clients)) |
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
79 |
if(!(c = nexttiled(c->next))) |
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
80 |
return; |
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
81 |
detach(c); |
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
82 |
attach(c); |
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
83 |
focus(c); |
946
b938876de936
made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents:
943
diff
changeset
|
84 |
arrange(); |
941
8c93b982f22e
separated layout-specific stuff into separate .h and .c files which are included in config.h resp. config.mk - this allows writing layouts for dwm without any need to patch existing code
Anselm R. Garbe <garbeam@gmail.com>
parents:
diff
changeset
|
85 |
} |