annotate view.c @ 681:335c93c666c7

this looks better now ;)
author Anselm R. Garbe <arg@suckless.org>
date Thu, 11 Jan 2007 16:38:45 +0100
parents 4dcbbfe9d137
children 76b58d21ea98
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
644
1ed8c40dde36 corrections
arg@mig29
parents: 643
diff changeset
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
76b62c0c8c11 improved selection policy
Anselm R. Garbe <arg@10kloc.org>
parents: 381
diff changeset
9 static Client *
480
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
10 nexttiled(Client *c) {
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
11 for(c = getnext(c); c && c->isfloat; c = getnext(c->next));
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
12 return c;
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
13 }
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
14
442
056a5072c70a no this is better
Anselm R. Garbe <arg@10kloc.org>
parents: 437
diff changeset
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
arg@mmvi
parents: 480
diff changeset
17 XEvent ev;
548
3d23384eb5ab applied sanders max size fix
arg@mig29
parents: 535
diff changeset
18
549
fd1061442711 applied sanders try2 patch
arg@mig29
parents: 548
diff changeset
19 if(c->isfixed)
548
3d23384eb5ab applied sanders max size fix
arg@mig29
parents: 535
diff changeset
20 return;
532
651f2c868b31 code polishing, removed unnecessary newlines
Anselm R. Garbe <arg@10kloc.org>
parents: 531
diff changeset
21
480
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
22 if((c->ismax = !c->ismax)) {
565
fe766305eed1 applied Gottox' windowarea patch
arg@mig29
parents: 561
diff changeset
23 c->rx = c->x; c->x = wax;
fe766305eed1 applied Gottox' windowarea patch
arg@mig29
parents: 561
diff changeset
24 c->ry = c->y; c->y = way;
fe766305eed1 applied Gottox' windowarea patch
arg@mig29
parents: 561
diff changeset
25 c->rw = c->w; c->w = waw - 2 * BORDERPX;
fe766305eed1 applied Gottox' windowarea patch
arg@mig29
parents: 561
diff changeset
26 c->rh = c->h; c->h = wah - 2 * BORDERPX;
480
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
27 }
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
28 else {
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
29 c->x = c->rx;
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
30 c->y = c->ry;
481
arg@mmvi
parents: 480
diff changeset
31 c->w = c->rw;
arg@mmvi
parents: 480
diff changeset
32 c->h = c->rh;
480
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
33 }
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
34 resize(c, True, TopLeft);
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
35 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
36 }
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
37
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
38 /* extern */
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
39
533
a5567a0d3011 do* has no Arg arument anymore (never called directly)
Anselm R. Garbe <arg@10kloc.org>
parents: 532
diff changeset
40 void (*arrange)(void) = DEFMODE;
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
41
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
42 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
43 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
44 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
45 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
46 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
47 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
48 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
49 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
50 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
51 }
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
52
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
53 void
533
a5567a0d3011 do* has no Arg arument anymore (never called directly)
Anselm R. Garbe <arg@10kloc.org>
parents: 532
diff changeset
54 dofloat(void) {
402
c7d5ff57998d removed unused vars
Anselm R. Garbe <arg@10kloc.org>
parents: 401
diff changeset
55 Client *c;
400
052657ff2e7b applied Sanders max_and_focus.patch
Anselm R. Garbe <arg@10kloc.org>
parents: 397
diff changeset
56
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
57 for(c = clients; c; c = c->next) {
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
58 if(isvisible(c)) {
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
59 resize(c, True, TopLeft);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
60 }
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
61 else
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
62 ban(c);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
63 }
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
64 if(!sel || !isvisible(sel)) {
450
728c9089b079 applied sanders patch of not manipulating sel
Anselm R. Garbe <arg@10kloc.org>
parents: 446
diff changeset
65 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
66 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
67 }
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
68 restack();
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
69 }
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 void
533
a5567a0d3011 do* has no Arg arument anymore (never called directly)
Anselm R. Garbe <arg@10kloc.org>
parents: 532
diff changeset
72 dotile(void) {
650
f3b8c71a69d4 experimental version which allows master clients being increased/decreased
Anselm R. Garbe <arg@suckless.org>
parents: 644
diff changeset
73 unsigned int i, n, mw, mh, tw, th;
402
c7d5ff57998d removed unused vars
Anselm R. Garbe <arg@10kloc.org>
parents: 401
diff changeset
74 Client *c;
400
052657ff2e7b applied Sanders max_and_focus.patch
Anselm R. Garbe <arg@10kloc.org>
parents: 397
diff changeset
75
488
0d2559f46b9e applied sanders jukka patch
arg@mmvi
parents: 487
diff changeset
76 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
0d2559f46b9e applied sanders jukka patch
arg@mmvi
parents: 487
diff changeset
77 n++;
678
4dcbbfe9d137 allowing nmaster=0 (I think that's a straight idea)
Anselm R. Garbe <arg@suckless.org>
parents: 675
diff changeset
78
650
f3b8c71a69d4 experimental version which allows master clients being increased/decreased
Anselm R. Garbe <arg@suckless.org>
parents: 644
diff changeset
79 /* window geoms */
678
4dcbbfe9d137 allowing nmaster=0 (I think that's a straight idea)
Anselm R. Garbe <arg@suckless.org>
parents: 675
diff changeset
80 if(nmaster > 0) {
4dcbbfe9d137 allowing nmaster=0 (I think that's a straight idea)
Anselm R. Garbe <arg@suckless.org>
parents: 675
diff changeset
81 mh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1);
4dcbbfe9d137 allowing nmaster=0 (I think that's a straight idea)
Anselm R. Garbe <arg@suckless.org>
parents: 675
diff changeset
82 mw = (n > nmaster) ? (waw * master) / 1000 : waw;
4dcbbfe9d137 allowing nmaster=0 (I think that's a straight idea)
Anselm R. Garbe <arg@suckless.org>
parents: 675
diff changeset
83 }
4dcbbfe9d137 allowing nmaster=0 (I think that's a straight idea)
Anselm R. Garbe <arg@suckless.org>
parents: 675
diff changeset
84 else
4dcbbfe9d137 allowing nmaster=0 (I think that's a straight idea)
Anselm R. Garbe <arg@suckless.org>
parents: 675
diff changeset
85 mh = mw = 0;
4dcbbfe9d137 allowing nmaster=0 (I think that's a straight idea)
Anselm R. Garbe <arg@suckless.org>
parents: 675
diff changeset
86 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
87 tw = waw - mw;
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
88
535
Anselm R. Garbe <arg@10kloc.org>
parents: 533
diff changeset
89 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
90 if(isvisible(c)) {
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
91 if(c->isfloat) {
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
92 resize(c, True, TopLeft);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
93 continue;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
94 }
488
0d2559f46b9e applied sanders jukka patch
arg@mmvi
parents: 487
diff changeset
95 c->ismax = False;
565
fe766305eed1 applied Gottox' windowarea patch
arg@mig29
parents: 561
diff changeset
96 c->x = wax;
fe766305eed1 applied Gottox' windowarea patch
arg@mig29
parents: 561
diff changeset
97 c->y = way;
678
4dcbbfe9d137 allowing nmaster=0 (I think that's a straight idea)
Anselm R. Garbe <arg@suckless.org>
parents: 675
diff changeset
98 if((nmaster > 0) && (i < nmaster)) {
650
f3b8c71a69d4 experimental version which allows master clients being increased/decreased
Anselm R. Garbe <arg@suckless.org>
parents: 644
diff changeset
99 c->y += i * mh;
f3b8c71a69d4 experimental version which allows master clients being increased/decreased
Anselm R. Garbe <arg@suckless.org>
parents: 644
diff changeset
100 c->w = mw - 2 * BORDERPX;
f3b8c71a69d4 experimental version which allows master clients being increased/decreased
Anselm R. Garbe <arg@suckless.org>
parents: 644
diff changeset
101 c->h = mh - 2 * BORDERPX;
507
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
102 }
523
c1dd19da63ef yet another simplification of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 522
diff changeset
103 else { /* tile window */
650
f3b8c71a69d4 experimental version which allows master clients being increased/decreased
Anselm R. Garbe <arg@suckless.org>
parents: 644
diff changeset
104 c->x += mw;
f3b8c71a69d4 experimental version which allows master clients being increased/decreased
Anselm R. Garbe <arg@suckless.org>
parents: 644
diff changeset
105 c->w = tw - 2 * BORDERPX;
523
c1dd19da63ef yet another simplification of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 522
diff changeset
106 if(th > bh) {
650
f3b8c71a69d4 experimental version which allows master clients being increased/decreased
Anselm R. Garbe <arg@suckless.org>
parents: 644
diff changeset
107 c->y += (i - nmaster) * th;
565
fe766305eed1 applied Gottox' windowarea patch
arg@mig29
parents: 561
diff changeset
108 c->h = th - 2 * BORDERPX;
507
2824b5d0f0f0 prelim of dotile()
Anselm R. Garbe <arg@10kloc.org>
parents: 505
diff changeset
109 }
531
96563762b4ad yet another small fix and simplification of dotile
Anselm R. Garbe <arg@10kloc.org>
parents: 530
diff changeset
110 else /* fallback if th < bh */
565
fe766305eed1 applied Gottox' windowarea patch
arg@mig29
parents: 561
diff changeset
111 c->h = wah - 2 * BORDERPX;
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
112 }
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
113 resize(c, False, TopLeft);
535
Anselm R. Garbe <arg@10kloc.org>
parents: 533
diff changeset
114 i++;
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
115 }
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
116 else
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
117 ban(c);
532
651f2c868b31 code polishing, removed unnecessary newlines
Anselm R. Garbe <arg@10kloc.org>
parents: 531
diff changeset
118
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
119 if(!sel || !isvisible(sel)) {
450
728c9089b079 applied sanders patch of not manipulating sel
Anselm R. Garbe <arg@10kloc.org>
parents: 446
diff changeset
120 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
121 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
122 }
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
123 restack();
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
124 }
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
125
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
126 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
127 focusnext(Arg *arg) {
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
128 Client *c;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
129
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
130 if(!sel)
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
131 return;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
132 if(!(c = getnext(sel->next)))
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
133 c = getnext(clients);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
134 if(c) {
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
135 focus(c);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
136 restack();
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
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
140 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
141 focusprev(Arg *arg) {
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
142 Client *c;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
143
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
144 if(!sel)
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
145 return;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
146 if(!(c = getprev(sel->prev))) {
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);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
148 c = getprev(c);
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) {
678
4dcbbfe9d137 allowing nmaster=0 (I think that's a straight idea)
Anselm R. Garbe <arg@suckless.org>
parents: 675
diff changeset
158 if((arrange == dofloat)
4dcbbfe9d137 allowing nmaster=0 (I think that's a straight idea)
Anselm R. Garbe <arg@suckless.org>
parents: 675
diff changeset
159 || ((int)nmaster + arg->i < 0)
4dcbbfe9d137 allowing nmaster=0 (I think that's a straight idea)
Anselm R. Garbe <arg@suckless.org>
parents: 675
diff changeset
160 || (((int)nmaster + arg->i > 0) && (wah / (nmaster + arg->i) < bh)))
650
f3b8c71a69d4 experimental version which allows master clients being increased/decreased
Anselm R. Garbe <arg@suckless.org>
parents: 644
diff changeset
161 return;
f3b8c71a69d4 experimental version which allows master clients being increased/decreased
Anselm R. Garbe <arg@suckless.org>
parents: 644
diff changeset
162 nmaster += arg->i;
675
1438e35b622e reorganized
Anselm R. Garbe <arg@suckless.org>
parents: 674
diff changeset
163 updatemodetext();
674
5d79c351e30a implemented nmaster appearance in mode label (using %u)
Anselm R. Garbe <arg@suckless.org>
parents: 662
diff changeset
164 if(sel)
5d79c351e30a implemented nmaster appearance in mode label (using %u)
Anselm R. Garbe <arg@suckless.org>
parents: 662
diff changeset
165 arrange();
5d79c351e30a implemented nmaster appearance in mode label (using %u)
Anselm R. Garbe <arg@suckless.org>
parents: 662
diff changeset
166 else
5d79c351e30a implemented nmaster appearance in mode label (using %u)
Anselm R. Garbe <arg@suckless.org>
parents: 662
diff changeset
167 drawstatus();
650
f3b8c71a69d4 experimental version which allows master clients being increased/decreased
Anselm R. Garbe <arg@suckless.org>
parents: 644
diff changeset
168 }
f3b8c71a69d4 experimental version which allows master clients being increased/decreased
Anselm R. Garbe <arg@suckless.org>
parents: 644
diff changeset
169
420
c033e1ade281 s/growcol/resizetile/g
Anselm R. Garbe <arg@10kloc.org>
parents: 419
diff changeset
170 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
171 isvisible(Client *c) {
420
c033e1ade281 s/growcol/resizetile/g
Anselm R. Garbe <arg@10kloc.org>
parents: 419
diff changeset
172 unsigned int i;
c033e1ade281 s/growcol/resizetile/g
Anselm R. Garbe <arg@10kloc.org>
parents: 419
diff changeset
173
c033e1ade281 s/growcol/resizetile/g
Anselm R. Garbe <arg@10kloc.org>
parents: 419
diff changeset
174 for(i = 0; i < ntags; i++)
c033e1ade281 s/growcol/resizetile/g
Anselm R. Garbe <arg@10kloc.org>
parents: 419
diff changeset
175 if(c->tags[i] && seltag[i])
c033e1ade281 s/growcol/resizetile/g
Anselm R. Garbe <arg@10kloc.org>
parents: 419
diff changeset
176 return True;
c033e1ade281 s/growcol/resizetile/g
Anselm R. Garbe <arg@10kloc.org>
parents: 419
diff changeset
177 return False;
c033e1ade281 s/growcol/resizetile/g
Anselm R. Garbe <arg@10kloc.org>
parents: 419
diff changeset
178 }
c033e1ade281 s/growcol/resizetile/g
Anselm R. Garbe <arg@10kloc.org>
parents: 419
diff changeset
179
415
ad2b6ce6e95b I really need column growing, now pushing upstream
Anselm R. Garbe <arg@10kloc.org>
parents: 414
diff changeset
180 void
559
a2c465098a3b renamed resizecol into resizemaster
arg@mig29
parents: 558
diff changeset
181 resizemaster(Arg *arg) {
561
b5435d3fb7b0 applied Jukkas patch
arg@mig29
parents: 559
diff changeset
182 if(arg->i == 0)
b5435d3fb7b0 applied Jukkas patch
arg@mig29
parents: 559
diff changeset
183 master = MASTER;
b5435d3fb7b0 applied Jukkas patch
arg@mig29
parents: 559
diff changeset
184 else {
b5435d3fb7b0 applied Jukkas patch
arg@mig29
parents: 559
diff changeset
185 if(master + arg->i > 950 || master + arg->i < 50)
b5435d3fb7b0 applied Jukkas patch
arg@mig29
parents: 559
diff changeset
186 return;
b5435d3fb7b0 applied Jukkas patch
arg@mig29
parents: 559
diff changeset
187 master += arg->i;
b5435d3fb7b0 applied Jukkas patch
arg@mig29
parents: 559
diff changeset
188 }
533
a5567a0d3011 do* has no Arg arument anymore (never called directly)
Anselm R. Garbe <arg@10kloc.org>
parents: 532
diff changeset
189 arrange();
415
ad2b6ce6e95b I really need column growing, now pushing upstream
Anselm R. Garbe <arg@10kloc.org>
parents: 414
diff changeset
190 }
ad2b6ce6e95b I really need column growing, now pushing upstream
Anselm R. Garbe <arg@10kloc.org>
parents: 414
diff changeset
191
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
192 void
487
be4f90c03582 applied Jukkas patch
arg@mmvi
parents: 486
diff changeset
193 restack(void) {
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
194 Client *c;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
195 XEvent ev;
481
arg@mmvi
parents: 480
diff changeset
196
437
433a5c662f73 drawstatus even if no client exists
Anselm R. Garbe <arg@10kloc.org>
parents: 436
diff changeset
197 if(!sel) {
433a5c662f73 drawstatus even if no client exists
Anselm R. Garbe <arg@10kloc.org>
parents: 436
diff changeset
198 drawstatus();
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
199 return;
437
433a5c662f73 drawstatus even if no client exists
Anselm R. Garbe <arg@10kloc.org>
parents: 436
diff changeset
200 }
436
b3659c3c5dab sanders solution is convincing and elegant
Anselm R. Garbe <arg@10kloc.org>
parents: 433
diff changeset
201 if(sel->isfloat || arrange == dofloat) {
b3659c3c5dab sanders solution is convincing and elegant
Anselm R. Garbe <arg@10kloc.org>
parents: 433
diff changeset
202 XRaiseWindow(dpy, sel->win);
b3659c3c5dab sanders solution is convincing and elegant
Anselm R. Garbe <arg@10kloc.org>
parents: 433
diff changeset
203 XRaiseWindow(dpy, sel->twin);
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
204 }
512
aca04c3022c1 fixed the z-layer issue described on mailinglist
Anselm R. Garbe <arg@10kloc.org>
parents: 511
diff changeset
205 if(arrange != dofloat) {
aca04c3022c1 fixed the z-layer issue described on mailinglist
Anselm R. Garbe <arg@10kloc.org>
parents: 511
diff changeset
206 if(!sel->isfloat) {
aca04c3022c1 fixed the z-layer issue described on mailinglist
Anselm R. Garbe <arg@10kloc.org>
parents: 511
diff changeset
207 XLowerWindow(dpy, sel->twin);
aca04c3022c1 fixed the z-layer issue described on mailinglist
Anselm R. Garbe <arg@10kloc.org>
parents: 511
diff changeset
208 XLowerWindow(dpy, sel->win);
aca04c3022c1 fixed the z-layer issue described on mailinglist
Anselm R. Garbe <arg@10kloc.org>
parents: 511
diff changeset
209 }
436
b3659c3c5dab sanders solution is convincing and elegant
Anselm R. Garbe <arg@10kloc.org>
parents: 433
diff changeset
210 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
211 if(c == sel)
aca04c3022c1 fixed the z-layer issue described on mailinglist
Anselm R. Garbe <arg@10kloc.org>
parents: 511
diff changeset
212 continue;
436
b3659c3c5dab sanders solution is convincing and elegant
Anselm R. Garbe <arg@10kloc.org>
parents: 433
diff changeset
213 XLowerWindow(dpy, c->twin);
b3659c3c5dab sanders solution is convincing and elegant
Anselm R. Garbe <arg@10kloc.org>
parents: 433
diff changeset
214 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
215 }
512
aca04c3022c1 fixed the z-layer issue described on mailinglist
Anselm R. Garbe <arg@10kloc.org>
parents: 511
diff changeset
216 }
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
217 drawall();
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
218 XSync(dpy, False);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
219 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
220 }
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
221
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
222 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
223 togglefloat(Arg *arg) {
591
d9e9df9fdce6 togglefloat should only work in dotile mode (thanks to Sander for this hint)
arg@mig29
parents: 588
diff changeset
224 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
225 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
226 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
227 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
228 }
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
229
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
230 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
231 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
232 arrange = (arrange == dofloat) ? dotile : dofloat;
675
1438e35b622e reorganized
Anselm R. Garbe <arg@suckless.org>
parents: 674
diff changeset
233 updatemodetext();
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
234 if(sel)
533
a5567a0d3011 do* has no Arg arument anymore (never called directly)
Anselm R. Garbe <arg@10kloc.org>
parents: 532
diff changeset
235 arrange();
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
236 else
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
237 drawstatus();
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
238 }
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
239
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
240 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
241 toggleview(Arg *arg) {
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
242 unsigned int i;
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 seltag[arg->i] = !seltag[arg->i];
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
245 for(i = 0; i < ntags && !seltag[i]; i++);
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
246 if(i == ntags)
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
247 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
248 arrange();
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
249 }
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
250
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
251 void
675
1438e35b622e reorganized
Anselm R. Garbe <arg@suckless.org>
parents: 674
diff changeset
252 updatemodetext() {
1438e35b622e reorganized
Anselm R. Garbe <arg@suckless.org>
parents: 674
diff changeset
253 snprintf(mtext, sizeof mtext, arrange == dofloat ? FLOATSYMBOL : TILESYMBOL, nmaster);
1438e35b622e reorganized
Anselm R. Garbe <arg@suckless.org>
parents: 674
diff changeset
254 bmw = textw(mtext);
1438e35b622e reorganized
Anselm R. Garbe <arg@suckless.org>
parents: 674
diff changeset
255 }
1438e35b622e reorganized
Anselm R. Garbe <arg@suckless.org>
parents: 674
diff changeset
256
1438e35b622e reorganized
Anselm R. Garbe <arg@suckless.org>
parents: 674
diff changeset
257 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
258 view(Arg *arg) {
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
259 unsigned int i;
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
260
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
261 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
262 seltag[i] = (arg->i == -1) ? True : False;
611
c7f84f23ec5a hotfix of a serious crashing bug
arg@mig29
parents: 594
diff changeset
263 if(arg->i >= 0 && arg->i < ntags)
c7f84f23ec5a hotfix of a serious crashing bug
arg@mig29
parents: 594
diff changeset
264 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
265 arrange();
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
266 }
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
267
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
268 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
269 zoom(Arg *arg) {
651
b9f4efd21473 added MODKEY-{plus,minus} shortcuts (increasing/decreasing master clients)
Anselm R. Garbe <arg@suckless.org>
parents: 650
diff changeset
270 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
271 Client *c;
473
2d8af0d7920d implemented the maximization as I described on the mailinglist, this feels better to me.
arg@mmvi
parents: 463
diff changeset
272
2d8af0d7920d implemented the maximization as I described on the mailinglist, this feels better to me.
arg@mmvi
parents: 463
diff changeset
273 if(!sel)
2d8af0d7920d implemented the maximization as I described on the mailinglist, this feels better to me.
arg@mmvi
parents: 463
diff changeset
274 return;
2d8af0d7920d implemented the maximization as I described on the mailinglist, this feels better to me.
arg@mmvi
parents: 463
diff changeset
275 if(sel->isfloat || (arrange == dofloat)) {
480
680aca428830 small change to achieve Jukka's last proposal
arg@mmvi
parents: 479
diff changeset
276 togglemax(sel);
473
2d8af0d7920d implemented the maximization as I described on the mailinglist, this feels better to me.
arg@mmvi
parents: 463
diff changeset
277 return;
2d8af0d7920d implemented the maximization as I described on the mailinglist, this feels better to me.
arg@mmvi
parents: 463
diff changeset
278 }
650
f3b8c71a69d4 experimental version which allows master clients being increased/decreased
Anselm R. Garbe <arg@suckless.org>
parents: 644
diff changeset
279 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
280 n++;
654
04734db9a219 allowing zoom within master area as well
Anselm R. Garbe <arg@suckless.org>
parents: 651
diff changeset
281
662
3e0f11a44293 allowing swap() for first master client
Anselm R. Garbe <arg@suckless.org>
parents: 661
diff changeset
282 if((c = sel) == nexttiled(clients))
3e0f11a44293 allowing swap() for first master client
Anselm R. Garbe <arg@suckless.org>
parents: 661
diff changeset
283 if(!(c = nexttiled(c->next)))
3e0f11a44293 allowing swap() for first master client
Anselm R. Garbe <arg@suckless.org>
parents: 661
diff changeset
284 return;
3e0f11a44293 allowing swap() for first master client
Anselm R. Garbe <arg@suckless.org>
parents: 661
diff changeset
285 detach(c);
3e0f11a44293 allowing swap() for first master client
Anselm R. Garbe <arg@suckless.org>
parents: 661
diff changeset
286 if(clients)
3e0f11a44293 allowing swap() for first master client
Anselm R. Garbe <arg@suckless.org>
parents: 661
diff changeset
287 clients->prev = c;
3e0f11a44293 allowing swap() for first master client
Anselm R. Garbe <arg@suckless.org>
parents: 661
diff changeset
288 c->next = clients;
3e0f11a44293 allowing swap() for first master client
Anselm R. Garbe <arg@suckless.org>
parents: 661
diff changeset
289 clients = c;
3e0f11a44293 allowing swap() for first master client
Anselm R. Garbe <arg@suckless.org>
parents: 661
diff changeset
290 focus(c);
3e0f11a44293 allowing swap() for first master client
Anselm R. Garbe <arg@suckless.org>
parents: 661
diff changeset
291 arrange();
327
96d09fd98e89 separated several functions into view.c
Anselm R. Garbe <arg@10kloc.org>
parents:
diff changeset
292 }