author | Anselm R. Garbe <arg@suckless.org> |
Mon, 19 Feb 2007 10:51:11 +0100 | |
changeset 765 | e4e7c6dc0785 |
parent 763 | 718f8d6f6f56 |
child 769 | dc60583894e0 |
permissions | -rw-r--r-- |
644 | 1 |
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com> |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
2 |
* See LICENSE file for license details. |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
3 |
*/ |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
4 |
#include "dwm.h" |
674
5d79c351e30a
implemented nmaster appearance in mode label (using %u)
Anselm R. Garbe <arg@suckless.org>
parents:
662
diff
changeset
|
5 |
#include <stdio.h> |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
6 |
|
380
4bf79305d675
this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents:
378
diff
changeset
|
7 |
/* static */ |
4bf79305d675
this algorithm seems to keep order for any scenario
Anselm R. Garbe <arg@10kloc.org>
parents:
378
diff
changeset
|
8 |
|
382 | 9 |
static Client * |
480 | 10 |
nexttiled(Client *c) { |
761
4e835c2a7a12
removed getnext/getprev, redundant
Anselm R. Garbe <arg@suckless.org>
parents:
760
diff
changeset
|
11 |
for(; c && (c->isfloat || !isvisible(c)); c = c->next); |
480 | 12 |
return c; |
13 |
} |
|
14 |
||
442 | 15 |
static void |
532
651f2c868b31
code polishing, removed unnecessary newlines
Anselm R. Garbe <arg@10kloc.org>
parents:
531
diff
changeset
|
16 |
togglemax(Client *c) { |
481 | 17 |
XEvent ev; |
548 | 18 |
|
549 | 19 |
if(c->isfixed) |
548 | 20 |
return; |
532
651f2c868b31
code polishing, removed unnecessary newlines
Anselm R. Garbe <arg@10kloc.org>
parents:
531
diff
changeset
|
21 |
|
480 | 22 |
if((c->ismax = !c->ismax)) { |
762
140bcd4782d8
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents:
761
diff
changeset
|
23 |
c->rx = c->x; |
140bcd4782d8
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents:
761
diff
changeset
|
24 |
c->ry = c->y; |
140bcd4782d8
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents:
761
diff
changeset
|
25 |
c->rw = c->w; |
140bcd4782d8
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents:
761
diff
changeset
|
26 |
c->rh = c->h; |
140bcd4782d8
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents:
761
diff
changeset
|
27 |
resize(c, wax, way, waw - 2 * BORDERPX, wah - 2 * BORDERPX, True); |
480 | 28 |
} |
762
140bcd4782d8
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents:
761
diff
changeset
|
29 |
else |
140bcd4782d8
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents:
761
diff
changeset
|
30 |
resize(c, c->rx, c->ry, c->rw, c->rh, True); |
480 | 31 |
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); |
430
1e8aba00964e
no, reodering floating clients definately breaks the manage() policy which attaches all clients zoomed (otherwise higher-weight clients couldn't be attached zoomed, which sucks)
Anselm R. Garbe <arg@10kloc.org>
parents:
429
diff
changeset
|
32 |
} |
1e8aba00964e
no, reodering floating clients definately breaks the manage() policy which attaches all clients zoomed (otherwise higher-weight clients couldn't be attached zoomed, which sucks)
Anselm R. Garbe <arg@10kloc.org>
parents:
429
diff
changeset
|
33 |
|
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
34 |
/* extern */ |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
35 |
|
533
a5567a0d3011
do* has no Arg arument anymore (never called directly)
Anselm R. Garbe <arg@10kloc.org>
parents:
532
diff
changeset
|
36 |
void (*arrange)(void) = DEFMODE; |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
37 |
|
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
38 |
void |
461
9d23330a5268
removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents:
450
diff
changeset
|
39 |
detach(Client *c) { |
378
83576f5f0a90
added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents:
342
diff
changeset
|
40 |
if(c->prev) |
83576f5f0a90
added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents:
342
diff
changeset
|
41 |
c->prev->next = c->next; |
83576f5f0a90
added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents:
342
diff
changeset
|
42 |
if(c->next) |
83576f5f0a90
added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents:
342
diff
changeset
|
43 |
c->next->prev = c->prev; |
83576f5f0a90
added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents:
342
diff
changeset
|
44 |
if(c == clients) |
83576f5f0a90
added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents:
342
diff
changeset
|
45 |
clients = c->next; |
83576f5f0a90
added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents:
342
diff
changeset
|
46 |
c->next = c->prev = NULL; |
83576f5f0a90
added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents:
342
diff
changeset
|
47 |
} |
83576f5f0a90
added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents:
342
diff
changeset
|
48 |
|
83576f5f0a90
added attach/detach functions which don't attach at the begin of list, but at the slot of a first match of the tags of a client
Anselm R. Garbe <arg@10kloc.org>
parents:
342
diff
changeset
|
49 |
void |
533
a5567a0d3011
do* has no Arg arument anymore (never called directly)
Anselm R. Garbe <arg@10kloc.org>
parents:
532
diff
changeset
|
50 |
dofloat(void) { |
402 | 51 |
Client *c; |
400
052657ff2e7b
applied Sanders max_and_focus.patch
Anselm R. Garbe <arg@10kloc.org>
parents:
397
diff
changeset
|
52 |
|
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
53 |
for(c = clients; c; c = c->next) { |
760
8ed842c35e8d
added ban() which takes care than a banned window is not banned again... (this reduces the overall ConfigureNotify's to clients)
Anselm R. Garbe <arg@suckless.org>
parents:
757
diff
changeset
|
54 |
if(isvisible(c)) { |
762
140bcd4782d8
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents:
761
diff
changeset
|
55 |
if(c->isbanned) |
140bcd4782d8
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents:
761
diff
changeset
|
56 |
XMoveWindow(dpy, c->win, c->x, c->y); |
760
8ed842c35e8d
added ban() which takes care than a banned window is not banned again... (this reduces the overall ConfigureNotify's to clients)
Anselm R. Garbe <arg@suckless.org>
parents:
757
diff
changeset
|
57 |
c->isbanned = False; |
763
718f8d6f6f56
well, resize should be called in dofloat anyways ;)
Anselm R. Garbe <arg@suckless.org>
parents:
762
diff
changeset
|
58 |
resize(c, c->x, c->y, c->w, c->h, True); |
760
8ed842c35e8d
added ban() which takes care than a banned window is not banned again... (this reduces the overall ConfigureNotify's to clients)
Anselm R. Garbe <arg@suckless.org>
parents:
757
diff
changeset
|
59 |
} |
762
140bcd4782d8
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents:
761
diff
changeset
|
60 |
else { |
140bcd4782d8
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents:
761
diff
changeset
|
61 |
c->isbanned = True; |
140bcd4782d8
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents:
761
diff
changeset
|
62 |
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); |
140bcd4782d8
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents:
761
diff
changeset
|
63 |
} |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
64 |
} |
446
a2e587651c79
using a global stack for focus recovery on arrange() - seems to work great
Anselm R. Garbe <arg@10kloc.org>
parents:
443
diff
changeset
|
65 |
if(!sel || !isvisible(sel)) { |
450
728c9089b079
applied sanders patch of not manipulating sel
Anselm R. Garbe <arg@10kloc.org>
parents:
446
diff
changeset
|
66 |
for(c = stack; c && !isvisible(c); c = c->snext); |
728c9089b079
applied sanders patch of not manipulating sel
Anselm R. Garbe <arg@10kloc.org>
parents:
446
diff
changeset
|
67 |
focus(c); |
446
a2e587651c79
using a global stack for focus recovery on arrange() - seems to work great
Anselm R. Garbe <arg@10kloc.org>
parents:
443
diff
changeset
|
68 |
} |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
69 |
restack(); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
70 |
} |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
71 |
|
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
72 |
void |
533
a5567a0d3011
do* has no Arg arument anymore (never called directly)
Anselm R. Garbe <arg@10kloc.org>
parents:
532
diff
changeset
|
73 |
dotile(void) { |
762
140bcd4782d8
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents:
761
diff
changeset
|
74 |
unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th; |
402 | 75 |
Client *c; |
400
052657ff2e7b
applied Sanders max_and_focus.patch
Anselm R. Garbe <arg@10kloc.org>
parents:
397
diff
changeset
|
76 |
|
488 | 77 |
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) |
78 |
n++; |
|
650
f3b8c71a69d4
experimental version which allows master clients being increased/decreased
Anselm R. Garbe <arg@suckless.org>
parents:
644
diff
changeset
|
79 |
/* window geoms */ |
682
76b58d21ea98
removing to allow nmaster=0
Anselm R. Garbe <arg@suckless.org>
parents:
678
diff
changeset
|
80 |
mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1); |
76b58d21ea98
removing to allow nmaster=0
Anselm R. Garbe <arg@suckless.org>
parents:
678
diff
changeset
|
81 |
mw = (n > nmaster) ? (waw * master) / 1000 : waw; |
678
4dcbbfe9d137
allowing nmaster=0 (I think that's a straight idea)
Anselm R. Garbe <arg@suckless.org>
parents:
675
diff
changeset
|
82 |
th = (n > nmaster) ? wah / (n - nmaster) : 0; |
650
f3b8c71a69d4
experimental version which allows master clients being increased/decreased
Anselm R. Garbe <arg@suckless.org>
parents:
644
diff
changeset
|
83 |
tw = waw - mw; |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
84 |
|
535 | 85 |
for(i = 0, c = clients; c; c = c->next) |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
86 |
if(isvisible(c)) { |
762
140bcd4782d8
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents:
761
diff
changeset
|
87 |
if(c->isbanned) |
140bcd4782d8
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents:
761
diff
changeset
|
88 |
XMoveWindow(dpy, c->win, c->x, c->y); |
760
8ed842c35e8d
added ban() which takes care than a banned window is not banned again... (this reduces the overall ConfigureNotify's to clients)
Anselm R. Garbe <arg@suckless.org>
parents:
757
diff
changeset
|
89 |
c->isbanned = False; |
762
140bcd4782d8
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents:
761
diff
changeset
|
90 |
if(c->isfloat) |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
91 |
continue; |
488 | 92 |
c->ismax = False; |
762
140bcd4782d8
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents:
761
diff
changeset
|
93 |
nx = wax; |
140bcd4782d8
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents:
761
diff
changeset
|
94 |
ny = way; |
682
76b58d21ea98
removing to allow nmaster=0
Anselm R. Garbe <arg@suckless.org>
parents:
678
diff
changeset
|
95 |
if(i < nmaster) { |
762
140bcd4782d8
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents:
761
diff
changeset
|
96 |
ny += i * mh; |
140bcd4782d8
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents:
761
diff
changeset
|
97 |
nw = mw - 2 * BORDERPX; |
140bcd4782d8
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents:
761
diff
changeset
|
98 |
nh = mh - 2 * BORDERPX; |
507 | 99 |
} |
523
c1dd19da63ef
yet another simplification of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents:
522
diff
changeset
|
100 |
else { /* tile window */ |
762
140bcd4782d8
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents:
761
diff
changeset
|
101 |
nx += mw; |
140bcd4782d8
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents:
761
diff
changeset
|
102 |
nw = tw - 2 * BORDERPX; |
726
0f91934037b0
applied Sander's drop_bh patch
Anselm R. Garbe <arg@suckless.org>
parents:
721
diff
changeset
|
103 |
if(th > 2 * BORDERPX) { |
762
140bcd4782d8
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents:
761
diff
changeset
|
104 |
ny += (i - nmaster) * th; |
140bcd4782d8
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents:
761
diff
changeset
|
105 |
nh = th - 2 * BORDERPX; |
507 | 106 |
} |
726
0f91934037b0
applied Sander's drop_bh patch
Anselm R. Garbe <arg@suckless.org>
parents:
721
diff
changeset
|
107 |
else /* fallback if th <= 2 * BORDERPX */ |
762
140bcd4782d8
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents:
761
diff
changeset
|
108 |
nh = wah - 2 * BORDERPX; |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
109 |
} |
762
140bcd4782d8
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents:
761
diff
changeset
|
110 |
resize(c, nx, ny, nw, nh, False); |
535 | 111 |
i++; |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
112 |
} |
762
140bcd4782d8
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents:
761
diff
changeset
|
113 |
else { |
140bcd4782d8
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents:
761
diff
changeset
|
114 |
c->isbanned = True; |
140bcd4782d8
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents:
761
diff
changeset
|
115 |
XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); |
140bcd4782d8
removed ugly ban(), extended resize() that it only resets the size if necessary, added border_width commit to manage()
Anselm R. Garbe <arg@suckless.org>
parents:
761
diff
changeset
|
116 |
} |
446
a2e587651c79
using a global stack for focus recovery on arrange() - seems to work great
Anselm R. Garbe <arg@10kloc.org>
parents:
443
diff
changeset
|
117 |
if(!sel || !isvisible(sel)) { |
450
728c9089b079
applied sanders patch of not manipulating sel
Anselm R. Garbe <arg@10kloc.org>
parents:
446
diff
changeset
|
118 |
for(c = stack; c && !isvisible(c); c = c->snext); |
728c9089b079
applied sanders patch of not manipulating sel
Anselm R. Garbe <arg@10kloc.org>
parents:
446
diff
changeset
|
119 |
focus(c); |
446
a2e587651c79
using a global stack for focus recovery on arrange() - seems to work great
Anselm R. Garbe <arg@10kloc.org>
parents:
443
diff
changeset
|
120 |
} |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
121 |
restack(); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
122 |
} |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
123 |
|
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
124 |
void |
461
9d23330a5268
removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents:
450
diff
changeset
|
125 |
focusnext(Arg *arg) { |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
126 |
Client *c; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
127 |
|
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
128 |
if(!sel) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
129 |
return; |
761
4e835c2a7a12
removed getnext/getprev, redundant
Anselm R. Garbe <arg@suckless.org>
parents:
760
diff
changeset
|
130 |
for(c = sel->next; c && !isvisible(c); c = c->next); |
4e835c2a7a12
removed getnext/getprev, redundant
Anselm R. Garbe <arg@suckless.org>
parents:
760
diff
changeset
|
131 |
if(!c) |
4e835c2a7a12
removed getnext/getprev, redundant
Anselm R. Garbe <arg@suckless.org>
parents:
760
diff
changeset
|
132 |
for(c = clients; c && !isvisible(c); c = c->next); |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
133 |
if(c) { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
134 |
focus(c); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
135 |
restack(); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
136 |
} |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
137 |
} |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
138 |
|
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
139 |
void |
461
9d23330a5268
removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents:
450
diff
changeset
|
140 |
focusprev(Arg *arg) { |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
141 |
Client *c; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
142 |
|
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
143 |
if(!sel) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
144 |
return; |
761
4e835c2a7a12
removed getnext/getprev, redundant
Anselm R. Garbe <arg@suckless.org>
parents:
760
diff
changeset
|
145 |
for(c = sel->prev; c && !isvisible(c); c = c->prev); |
4e835c2a7a12
removed getnext/getprev, redundant
Anselm R. Garbe <arg@suckless.org>
parents:
760
diff
changeset
|
146 |
if(!c) { |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
147 |
for(c = clients; c && c->next; c = c->next); |
761
4e835c2a7a12
removed getnext/getprev, redundant
Anselm R. Garbe <arg@suckless.org>
parents:
760
diff
changeset
|
148 |
for(; c && !isvisible(c); c = c->prev); |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
149 |
} |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
150 |
if(c) { |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
151 |
focus(c); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
152 |
restack(); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
153 |
} |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
154 |
} |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
155 |
|
650
f3b8c71a69d4
experimental version which allows master clients being increased/decreased
Anselm R. Garbe <arg@suckless.org>
parents:
644
diff
changeset
|
156 |
void |
f3b8c71a69d4
experimental version which allows master clients being increased/decreased
Anselm R. Garbe <arg@suckless.org>
parents:
644
diff
changeset
|
157 |
incnmaster(Arg *arg) { |
721
d3876aa79292
prepared yet another hotfix release
Anselm R. Garbe <arg@suckless.org>
parents:
708
diff
changeset
|
158 |
if((arrange == dofloat) || (nmaster + arg->i < 1) |
757
22dfaeb82491
made for/if/else constructs more consistent, some code polishing
Anselm R. Garbe <arg@suckless.org>
parents:
751
diff
changeset
|
159 |
|| (wah / (nmaster + arg->i) <= 2 * BORDERPX)) |
650
f3b8c71a69d4
experimental version which allows master clients being increased/decreased
Anselm R. Garbe <arg@suckless.org>
parents:
644
diff
changeset
|
160 |
return; |
f3b8c71a69d4
experimental version which allows master clients being increased/decreased
Anselm R. Garbe <arg@suckless.org>
parents:
644
diff
changeset
|
161 |
nmaster += arg->i; |
674
5d79c351e30a
implemented nmaster appearance in mode label (using %u)
Anselm R. Garbe <arg@suckless.org>
parents:
662
diff
changeset
|
162 |
if(sel) |
5d79c351e30a
implemented nmaster appearance in mode label (using %u)
Anselm R. Garbe <arg@suckless.org>
parents:
662
diff
changeset
|
163 |
arrange(); |
5d79c351e30a
implemented nmaster appearance in mode label (using %u)
Anselm R. Garbe <arg@suckless.org>
parents:
662
diff
changeset
|
164 |
else |
5d79c351e30a
implemented nmaster appearance in mode label (using %u)
Anselm R. Garbe <arg@suckless.org>
parents:
662
diff
changeset
|
165 |
drawstatus(); |
650
f3b8c71a69d4
experimental version which allows master clients being increased/decreased
Anselm R. Garbe <arg@suckless.org>
parents:
644
diff
changeset
|
166 |
} |
f3b8c71a69d4
experimental version which allows master clients being increased/decreased
Anselm R. Garbe <arg@suckless.org>
parents:
644
diff
changeset
|
167 |
|
420 | 168 |
Bool |
461
9d23330a5268
removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents:
450
diff
changeset
|
169 |
isvisible(Client *c) { |
420 | 170 |
unsigned int i; |
171 |
||
172 |
for(i = 0; i < ntags; i++) |
|
173 |
if(c->tags[i] && seltag[i]) |
|
174 |
return True; |
|
175 |
return False; |
|
176 |
} |
|
177 |
||
415
ad2b6ce6e95b
I really need column growing, now pushing upstream
Anselm R. Garbe <arg@10kloc.org>
parents:
414
diff
changeset
|
178 |
void |
559 | 179 |
resizemaster(Arg *arg) { |
765
e4e7c6dc0785
don't resize master if not in tiled mode
Anselm R. Garbe <arg@suckless.org>
parents:
763
diff
changeset
|
180 |
if(arrange != dotile) |
e4e7c6dc0785
don't resize master if not in tiled mode
Anselm R. Garbe <arg@suckless.org>
parents:
763
diff
changeset
|
181 |
return; |
561 | 182 |
if(arg->i == 0) |
183 |
master = MASTER; |
|
184 |
else { |
|
726
0f91934037b0
applied Sander's drop_bh patch
Anselm R. Garbe <arg@suckless.org>
parents:
721
diff
changeset
|
185 |
if(waw * (master + arg->i) / 1000 >= waw - 2 * BORDERPX |
757
22dfaeb82491
made for/if/else constructs more consistent, some code polishing
Anselm R. Garbe <arg@suckless.org>
parents:
751
diff
changeset
|
186 |
|| waw * (master + arg->i) / 1000 <= 2 * BORDERPX) |
561 | 187 |
return; |
188 |
master += arg->i; |
|
189 |
} |
|
533
a5567a0d3011
do* has no Arg arument anymore (never called directly)
Anselm R. Garbe <arg@10kloc.org>
parents:
532
diff
changeset
|
190 |
arrange(); |
415
ad2b6ce6e95b
I really need column growing, now pushing upstream
Anselm R. Garbe <arg@10kloc.org>
parents:
414
diff
changeset
|
191 |
} |
ad2b6ce6e95b
I really need column growing, now pushing upstream
Anselm R. Garbe <arg@10kloc.org>
parents:
414
diff
changeset
|
192 |
|
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
193 |
void |
487 | 194 |
restack(void) { |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
195 |
Client *c; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
196 |
XEvent ev; |
481 | 197 |
|
691
5d7e363f889d
changed restack, to fix undrawed tag indicators
Anselm R. Garbe <arg@suckless.org>
parents:
690
diff
changeset
|
198 |
drawstatus(); |
5d7e363f889d
changed restack, to fix undrawed tag indicators
Anselm R. Garbe <arg@suckless.org>
parents:
690
diff
changeset
|
199 |
if(!sel) |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
200 |
return; |
687
a76799907854
removed client title bar
Anselm R. Garbe <arg@suckless.org>
parents:
682
diff
changeset
|
201 |
if(sel->isfloat || arrange == dofloat) |
436
b3659c3c5dab
sanders solution is convincing and elegant
Anselm R. Garbe <arg@10kloc.org>
parents:
433
diff
changeset
|
202 |
XRaiseWindow(dpy, sel->win); |
512
aca04c3022c1
fixed the z-layer issue described on mailinglist
Anselm R. Garbe <arg@10kloc.org>
parents:
511
diff
changeset
|
203 |
if(arrange != dofloat) { |
687
a76799907854
removed client title bar
Anselm R. Garbe <arg@suckless.org>
parents:
682
diff
changeset
|
204 |
if(!sel->isfloat) |
512
aca04c3022c1
fixed the z-layer issue described on mailinglist
Anselm R. Garbe <arg@10kloc.org>
parents:
511
diff
changeset
|
205 |
XLowerWindow(dpy, sel->win); |
436
b3659c3c5dab
sanders solution is convincing and elegant
Anselm R. Garbe <arg@10kloc.org>
parents:
433
diff
changeset
|
206 |
for(c = nexttiled(clients); c; c = nexttiled(c->next)) { |
512
aca04c3022c1
fixed the z-layer issue described on mailinglist
Anselm R. Garbe <arg@10kloc.org>
parents:
511
diff
changeset
|
207 |
if(c == sel) |
aca04c3022c1
fixed the z-layer issue described on mailinglist
Anselm R. Garbe <arg@10kloc.org>
parents:
511
diff
changeset
|
208 |
continue; |
436
b3659c3c5dab
sanders solution is convincing and elegant
Anselm R. Garbe <arg@10kloc.org>
parents:
433
diff
changeset
|
209 |
XLowerWindow(dpy, c->win); |
414
c6ffcc201229
don't access sel in restack without checking for NULL (multihead crashing bug)
Anselm R. Garbe <arg@10kloc.org>
parents:
402
diff
changeset
|
210 |
} |
512
aca04c3022c1
fixed the z-layer issue described on mailinglist
Anselm R. Garbe <arg@10kloc.org>
parents:
511
diff
changeset
|
211 |
} |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
212 |
XSync(dpy, False); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
213 |
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
214 |
} |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
215 |
|
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
216 |
void |
584
37281ebc1b5b
added togglefloat to hg tip (i consider this useful for some cases), using MODKEY-Shift-space as shortcut
arg@mig29
parents:
573
diff
changeset
|
217 |
togglefloat(Arg *arg) { |
751
c5f9c2d806e7
yet another consistency fix of dwm
Anselm R. Garbe <arg@suckless.org>
parents:
726
diff
changeset
|
218 |
if(!sel || arrange == dofloat) |
584
37281ebc1b5b
added togglefloat to hg tip (i consider this useful for some cases), using MODKEY-Shift-space as shortcut
arg@mig29
parents:
573
diff
changeset
|
219 |
return; |
37281ebc1b5b
added togglefloat to hg tip (i consider this useful for some cases), using MODKEY-Shift-space as shortcut
arg@mig29
parents:
573
diff
changeset
|
220 |
sel->isfloat = !sel->isfloat; |
37281ebc1b5b
added togglefloat to hg tip (i consider this useful for some cases), using MODKEY-Shift-space as shortcut
arg@mig29
parents:
573
diff
changeset
|
221 |
arrange(); |
37281ebc1b5b
added togglefloat to hg tip (i consider this useful for some cases), using MODKEY-Shift-space as shortcut
arg@mig29
parents:
573
diff
changeset
|
222 |
} |
37281ebc1b5b
added togglefloat to hg tip (i consider this useful for some cases), using MODKEY-Shift-space as shortcut
arg@mig29
parents:
573
diff
changeset
|
223 |
|
37281ebc1b5b
added togglefloat to hg tip (i consider this useful for some cases), using MODKEY-Shift-space as shortcut
arg@mig29
parents:
573
diff
changeset
|
224 |
void |
461
9d23330a5268
removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents:
450
diff
changeset
|
225 |
togglemode(Arg *arg) { |
333
827f8f6c9e97
separated setup stuff into main.c:setup() - this makes main() more readable
Anselm R. Garbe <arg@10kloc.org>
parents:
327
diff
changeset
|
226 |
arrange = (arrange == dofloat) ? dotile : dofloat; |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
227 |
if(sel) |
533
a5567a0d3011
do* has no Arg arument anymore (never called directly)
Anselm R. Garbe <arg@10kloc.org>
parents:
532
diff
changeset
|
228 |
arrange(); |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
229 |
else |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
230 |
drawstatus(); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
231 |
} |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
232 |
|
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
233 |
void |
461
9d23330a5268
removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents:
450
diff
changeset
|
234 |
toggleview(Arg *arg) { |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
235 |
unsigned int i; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
236 |
|
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
237 |
seltag[arg->i] = !seltag[arg->i]; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
238 |
for(i = 0; i < ntags && !seltag[i]; i++); |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
239 |
if(i == ntags) |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
240 |
seltag[arg->i] = True; /* cannot toggle last view */ |
533
a5567a0d3011
do* has no Arg arument anymore (never called directly)
Anselm R. Garbe <arg@10kloc.org>
parents:
532
diff
changeset
|
241 |
arrange(); |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
242 |
} |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
243 |
|
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
244 |
void |
461
9d23330a5268
removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents:
450
diff
changeset
|
245 |
view(Arg *arg) { |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
246 |
unsigned int i; |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
247 |
|
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
248 |
for(i = 0; i < ntags; i++) |
594
f7dcd3ac8d6f
removed viewall(), replaced with view(-1); added tag(-1) to tag a client with all tags (new key combo MODKEY-Shift-0)
arg@mig29
parents:
591
diff
changeset
|
249 |
seltag[i] = (arg->i == -1) ? True : False; |
611 | 250 |
if(arg->i >= 0 && arg->i < ntags) |
251 |
seltag[arg->i] = True; |
|
533
a5567a0d3011
do* has no Arg arument anymore (never called directly)
Anselm R. Garbe <arg@10kloc.org>
parents:
532
diff
changeset
|
252 |
arrange(); |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
253 |
} |
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
254 |
|
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
255 |
void |
461
9d23330a5268
removed a bunch of lines through making function signatures more consistent with my style ( { does not belong to a new line, if function args are single-lined)
Anselm R. Garbe <arg@10kloc.org>
parents:
450
diff
changeset
|
256 |
zoom(Arg *arg) { |
651
b9f4efd21473
added MODKEY-{plus,minus} shortcuts (increasing/decreasing master clients)
Anselm R. Garbe <arg@suckless.org>
parents:
650
diff
changeset
|
257 |
unsigned int n; |
423
6ba5dd429122
applied checking existance of >2 tiles patch (proposed by sander) to zoom and resizecol
Anselm R. Garbe <arg@10kloc.org>
parents:
422
diff
changeset
|
258 |
Client *c; |
473
2d8af0d7920d
implemented the maximization as I described on the mailinglist, this feels better to me.
arg@mmvi
parents:
463
diff
changeset
|
259 |
|
2d8af0d7920d
implemented the maximization as I described on the mailinglist, this feels better to me.
arg@mmvi
parents:
463
diff
changeset
|
260 |
if(!sel) |
2d8af0d7920d
implemented the maximization as I described on the mailinglist, this feels better to me.
arg@mmvi
parents:
463
diff
changeset
|
261 |
return; |
2d8af0d7920d
implemented the maximization as I described on the mailinglist, this feels better to me.
arg@mmvi
parents:
463
diff
changeset
|
262 |
if(sel->isfloat || (arrange == dofloat)) { |
480 | 263 |
togglemax(sel); |
473
2d8af0d7920d
implemented the maximization as I described on the mailinglist, this feels better to me.
arg@mmvi
parents:
463
diff
changeset
|
264 |
return; |
2d8af0d7920d
implemented the maximization as I described on the mailinglist, this feels better to me.
arg@mmvi
parents:
463
diff
changeset
|
265 |
} |
650
f3b8c71a69d4
experimental version which allows master clients being increased/decreased
Anselm R. Garbe <arg@suckless.org>
parents:
644
diff
changeset
|
266 |
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) |
f3b8c71a69d4
experimental version which allows master clients being increased/decreased
Anselm R. Garbe <arg@suckless.org>
parents:
644
diff
changeset
|
267 |
n++; |
654
04734db9a219
allowing zoom within master area as well
Anselm R. Garbe <arg@suckless.org>
parents:
651
diff
changeset
|
268 |
|
662
3e0f11a44293
allowing swap() for first master client
Anselm R. Garbe <arg@suckless.org>
parents:
661
diff
changeset
|
269 |
if((c = sel) == nexttiled(clients)) |
3e0f11a44293
allowing swap() for first master client
Anselm R. Garbe <arg@suckless.org>
parents:
661
diff
changeset
|
270 |
if(!(c = nexttiled(c->next))) |
3e0f11a44293
allowing swap() for first master client
Anselm R. Garbe <arg@suckless.org>
parents:
661
diff
changeset
|
271 |
return; |
3e0f11a44293
allowing swap() for first master client
Anselm R. Garbe <arg@suckless.org>
parents:
661
diff
changeset
|
272 |
detach(c); |
3e0f11a44293
allowing swap() for first master client
Anselm R. Garbe <arg@suckless.org>
parents:
661
diff
changeset
|
273 |
if(clients) |
3e0f11a44293
allowing swap() for first master client
Anselm R. Garbe <arg@suckless.org>
parents:
661
diff
changeset
|
274 |
clients->prev = c; |
3e0f11a44293
allowing swap() for first master client
Anselm R. Garbe <arg@suckless.org>
parents:
661
diff
changeset
|
275 |
c->next = clients; |
3e0f11a44293
allowing swap() for first master client
Anselm R. Garbe <arg@suckless.org>
parents:
661
diff
changeset
|
276 |
clients = c; |
3e0f11a44293
allowing swap() for first master client
Anselm R. Garbe <arg@suckless.org>
parents:
661
diff
changeset
|
277 |
focus(c); |
3e0f11a44293
allowing swap() for first master client
Anselm R. Garbe <arg@suckless.org>
parents:
661
diff
changeset
|
278 |
arrange(); |
327
96d09fd98e89
separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff
changeset
|
279 |
} |