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) ca65478c
Anselm R. Garbe · 2006-09-12 10:57 7 file(s) · +83 −158
client.c +16 −34
11 11
/* static functions */
12 12
13 13
static void
14 -
detachstack(Client *c)
15 -
{
14 +
detachstack(Client *c) {
16 15
	Client **tc;
17 16
	for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext);
18 17
	*tc = c->snext;
19 18
}
20 19
21 20
static void
22 -
grabbuttons(Client *c, Bool focused)
23 -
{
21 +
grabbuttons(Client *c, Bool focused) {
24 22
	XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
25 23
26 24
	if(focused) {
54 52
	else
55 53
		XGrabButton(dpy, AnyButton, AnyModifier, c->win, False, BUTTONMASK,
56 54
				GrabModeAsync, GrabModeSync, None, None);
57 -
58 55
}
59 56
60 57
static void
61 -
resizetitle(Client *c)
62 -
{
58 +
resizetitle(Client *c) {
63 59
	c->tw = textw(c->name);
64 60
	if(c->tw > c->w)
65 61
		c->tw = c->w + 2;
69 65
		XMoveResizeWindow(dpy, c->twin, c->tx, c->ty, c->tw, c->th);
70 66
	else
71 67
		XMoveResizeWindow(dpy, c->twin, c->tx + 2 * sw, c->ty, c->tw, c->th);
72 -
73 68
}
74 69
75 70
static int
76 -
xerrordummy(Display *dsply, XErrorEvent *ee)
77 -
{
71 +
xerrordummy(Display *dsply, XErrorEvent *ee) {
78 72
	return 0;
79 73
}
80 74
81 75
/* extern functions */
82 76
83 77
void
84 -
ban(Client *c)
85 -
{
78 +
ban(Client *c) {
86 79
	XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
87 80
	XMoveWindow(dpy, c->twin, c->tx + 2 * sw, c->ty);
88 81
}
89 82
90 83
void
91 -
focus(Client *c)
92 -
{
84 +
focus(Client *c) {
93 85
	Client *old;
94 86
95 87
	if(!issel)
119 111
}
120 112
121 113
Client *
122 -
getclient(Window w)
123 -
{
114 +
getclient(Window w) {
124 115
	Client *c;
125 116
126 117
	for(c = clients; c; c = c->next)
130 121
}
131 122
132 123
Client *
133 -
getctitle(Window w)
134 -
{
124 +
getctitle(Window w) {
135 125
	Client *c;
136 126
137 127
	for(c = clients; c; c = c->next)
141 131
}
142 132
143 133
void
144 -
gravitate(Client *c, Bool invert)
145 -
{
134 +
gravitate(Client *c, Bool invert) {
146 135
	int dx = 0, dy = 0;
147 136
148 137
	switch(c->grav) {
196 185
}
197 186
198 187
void
199 -
killclient(Arg *arg)
200 -
{
188 +
killclient(Arg *arg) {
201 189
	if(!sel)
202 190
		return;
203 191
	if(sel->proto & PROTODELWIN)
207 195
}
208 196
209 197
void
210 -
manage(Window w, XWindowAttributes *wa)
211 -
{
198 +
manage(Window w, XWindowAttributes *wa) {
212 199
	Client *c;
213 200
	Window trans;
214 201
	XSetWindowAttributes twa;
270 257
}
271 258
272 259
void
273 -
resize(Client *c, Bool sizehints, Corner sticky)
274 -
{
260 +
resize(Client *c, Bool sizehints, Corner sticky) {
275 261
	int bottom = c->y + c->h;
276 262
	int right = c->x + c->w;
277 263
	XWindowChanges wc;
309 295
}
310 296
311 297
void
312 -
updatesize(Client *c)
313 -
{
298 +
updatesize(Client *c) {
314 299
	long msize;
315 300
	XSizeHints size;
316 301
348 333
}
349 334
350 335
void
351 -
updatetitle(Client *c)
352 -
{
336 +
updatetitle(Client *c) {
353 337
	char **list = NULL;
354 338
	int n;
355 339
	XTextProperty name;
376 360
}
377 361
378 362
void
379 -
togglemax(Arg *arg)
380 -
{
363 +
togglemax(Arg *arg) {
381 364
	int ox, oy, ow, oh;
382 365
	Client *c;
383 366
	XEvent ev;
412 395
}
413 396
414 397
void
415 -
unmanage(Client *c)
416 -
{
398 +
unmanage(Client *c) {
417 399
	Client *nc;
418 400
419 401
	XGrabServer(dpy);
draw.c +8 −16
10 10
/* static */
11 11
12 12
static unsigned int
13 -
textnw(const char *text, unsigned int len)
14 -
{
13 +
textnw(const char *text, unsigned int len) {
15 14
	XRectangle r;
16 15
17 16
	if(dc.font.set) {
22 21
}
23 22
24 23
static void
25 -
drawtext(const char *text, unsigned long col[ColLast], Bool highlight)
26 -
{
24 +
drawtext(const char *text, unsigned long col[ColLast], Bool highlight) {
27 25
	int x, y, w, h;
28 26
	static char buf[256];
29 27
	unsigned int len, olen;
82 80
/* extern */
83 81
84 82
void
85 -
drawall()
86 -
{
83 +
drawall() {
87 84
	Client *c;
88 85
89 86
	for(c = clients; c; c = getnext(c->next))
92 89
}
93 90
94 91
void
95 -
drawstatus()
96 -
{
92 +
drawstatus() {
97 93
	int i, x;
98 94
99 95
	dc.x = dc.y = 0;
131 127
}
132 128
133 129
void
134 -
drawtitle(Client *c)
135 -
{
130 +
drawtitle(Client *c) {
136 131
	if(c == sel && issel) {
137 132
		drawstatus();
138 133
		XUnmapWindow(dpy, c->twin);
150 145
}
151 146
152 147
unsigned long
153 -
getcolor(const char *colstr)
154 -
{
148 +
getcolor(const char *colstr) {
155 149
	Colormap cmap = DefaultColormap(dpy, screen);
156 150
	XColor color;
157 151
160 154
}
161 155
162 156
void
163 -
setfont(const char *fontstr)
164 -
{
157 +
setfont(const char *fontstr) {
165 158
	char **missing, *def;
166 159
	int i, n;
167 160
211 204
}
212 205
213 206
unsigned int
214 -
textw(const char *text)
215 -
{
207 +
textw(const char *text) {
216 208
	return textnw(text, strlen(text)) + dc.font.height;
217 209
}
event.c +22 −37
21 21
#define CLEANMASK(mask) (mask & ~(numlockmask | LockMask))
22 22
23 23
static void
24 -
movemouse(Client *c)
25 -
{
24 +
movemouse(Client *c) {
26 25
	int x1, y1, ocx, ocy, di;
27 26
	unsigned int dui;
28 27
	Window dummy;
37 36
	for(;;) {
38 37
		XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev);
39 38
		switch (ev.type) {
40 -
		default: break;
39 +
		default:
40 +
			break;
41 41
		case Expose:
42 42
			handler[Expose](&ev);
43 43
			break;
55 55
}
56 56
57 57
static void
58 -
resizemouse(Client *c)
59 -
{
58 +
resizemouse(Client *c) {
60 59
	int ocx, ocy;
61 60
	int nw, nh;
62 61
	Corner sticky;
71 70
	for(;;) {
72 71
		XMaskEvent(dpy, MOUSEMASK | ExposureMask, &ev);
73 72
		switch(ev.type) {
74 -
		default: break;
73 +
		default:
74 +
			break;
75 75
		case Expose:
76 76
			handler[Expose](&ev);
77 77
			break;
97 97
}
98 98
99 99
static void
100 -
buttonpress(XEvent *e)
101 -
{
100 +
buttonpress(XEvent *e) {
102 101
	int x;
103 102
	Arg a;
104 103
	Client *c;
147 146
}
148 147
149 148
static void
150 -
synconfig(Client *c, int x, int y, int w, int h, unsigned int border)
151 -
{
149 +
synconfig(Client *c, int x, int y, int w, int h, unsigned int border) {
152 150
	XEvent synev;
153 151
154 152
	synev.type = ConfigureNotify;
165 163
}
166 164
167 165
static void
168 -
configurerequest(XEvent *e)
169 -
{
166 +
configurerequest(XEvent *e) {
170 167
	unsigned long newmask;
171 168
	Client *c;
172 169
	XConfigureRequestEvent *ev = &e->xconfigurerequest;
219 216
}
220 217
221 218
static void
222 -
destroynotify(XEvent *e)
223 -
{
219 +
destroynotify(XEvent *e) {
224 220
	Client *c;
225 221
	XDestroyWindowEvent *ev = &e->xdestroywindow;
226 222
229 225
}
230 226
231 227
static void
232 -
enternotify(XEvent *e)
233 -
{
228 +
enternotify(XEvent *e) {
234 229
	Client *c;
235 230
	XCrossingEvent *ev = &e->xcrossing;
236 231
247 242
}
248 243
249 244
static void
250 -
expose(XEvent *e)
251 -
{
245 +
expose(XEvent *e) {
252 246
	Client *c;
253 247
	XExposeEvent *ev = &e->xexpose;
254 248
261 255
}
262 256
263 257
static void
264 -
keypress(XEvent *e)
265 -
{
258 +
keypress(XEvent *e) {
266 259
	static unsigned int len = sizeof(key) / sizeof(key[0]);
267 260
	unsigned int i;
268 261
	KeySym keysym;
270 263
271 264
	keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
272 265
	for(i = 0; i < len; i++) {
273 -
		if(keysym == key[i].keysym &&
274 -
				CLEANMASK(key[i].mod) == CLEANMASK(ev->state))
266 +
		if(keysym == key[i].keysym
267 +
			&& CLEANMASK(key[i].mod) == CLEANMASK(ev->state))
275 268
		{
276 269
			if(key[i].func)
277 270
				key[i].func(&key[i].arg);
281 274
}
282 275
283 276
static void
284 -
leavenotify(XEvent *e)
285 -
{
277 +
leavenotify(XEvent *e) {
286 278
	XCrossingEvent *ev = &e->xcrossing;
287 279
288 280
	if((ev->window == root) && !ev->same_screen) {
292 284
}
293 285
294 286
static void
295 -
mappingnotify(XEvent *e)
296 -
{
287 +
mappingnotify(XEvent *e) {
297 288
	XMappingEvent *ev = &e->xmapping;
298 289
299 290
	XRefreshKeyboardMapping(ev);
302 293
}
303 294
304 295
static void
305 -
maprequest(XEvent *e)
306 -
{
296 +
maprequest(XEvent *e) {
307 297
	static XWindowAttributes wa;
308 298
	XMapRequestEvent *ev = &e->xmaprequest;
309 299
321 311
}
322 312
323 313
static void
324 -
propertynotify(XEvent *e)
325 -
{
314 +
propertynotify(XEvent *e) {
326 315
	Client *c;
327 316
	Window trans;
328 317
	XPropertyEvent *ev = &e->xproperty;
354 343
}
355 344
356 345
static void
357 -
unmapnotify(XEvent *e)
358 -
{
346 +
unmapnotify(XEvent *e) {
359 347
	Client *c;
360 348
	XUnmapEvent *ev = &e->xunmap;
361 349
380 368
};
381 369
382 370
void
383 -
grabkeys()
384 -
{
371 +
grabkeys() {
385 372
	static unsigned int len = sizeof(key) / sizeof(key[0]);
386 373
	unsigned int i;
387 374
	KeyCode code;
401 388
}
402 389
403 390
void
404 -
procevent()
405 -
{
391 +
procevent() {
406 392
	XEvent ev;
407 393
408 394
	while(XPending(dpy)) {
411 397
			(handler[ev.type])(&ev); /* call handler */
412 398
	}
413 399
}
414 -
main.c +11 −19
39 39
static Bool otherwm, readin;
40 40
41 41
static void
42 -
cleanup()
43 -
{
42 +
cleanup() {
44 43
	close(STDIN_FILENO);
45 44
	while(sel) {
46 45
		resize(sel, True, TopLeft);
60 59
}
61 60
62 61
static void
63 -
scan()
64 -
{
62 +
scan() {
65 63
	unsigned int i, num;
66 64
	Window *wins, d1, d2;
67 65
	XWindowAttributes wa;
82 80
}
83 81
84 82
static void
85 -
setup()
86 -
{
83 +
setup() {
87 84
	int i, j;
88 85
	unsigned int mask;
89 86
	Window w;
112 109
	}
113 110
	XFree(modmap);
114 111
115 -
	wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask | EnterWindowMask | LeaveWindowMask;
112 +
	wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
113 +
		| EnterWindowMask | LeaveWindowMask;
116 114
	wa.cursor = cursor[CurNormal];
117 115
	XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
118 116
163 161
 * is already running.
164 162
 */
165 163
static int
166 -
xerrorstart(Display *dsply, XErrorEvent *ee)
167 -
{
164 +
xerrorstart(Display *dsply, XErrorEvent *ee) {
168 165
	otherwm = True;
169 166
	return -1;
170 167
}
172 169
/* extern */
173 170
174 171
int
175 -
getproto(Window w)
176 -
{
172 +
getproto(Window w) {
177 173
	int i, format, protos, status;
178 174
	unsigned long extra, res;
179 175
	Atom *protocols, real;
191 187
}
192 188
193 189
void
194 -
sendevent(Window w, Atom a, long value)
195 -
{
190 +
sendevent(Window w, Atom a, long value) {
196 191
	XEvent e;
197 192
198 193
	e.type = ClientMessage;
206 201
}
207 202
208 203
void
209 -
quit(Arg *arg)
210 -
{
204 +
quit(Arg *arg) {
211 205
	readin = running = False;
212 206
}
213 207
217 211
 * default error handler, which may call exit.
218 212
 */
219 213
int
220 -
xerror(Display *dpy, XErrorEvent *ee)
221 -
{
214 +
xerror(Display *dpy, XErrorEvent *ee) {
222 215
	if(ee->error_code == BadWindow
223 216
	|| (ee->request_code == X_SetInputFocus && ee->error_code == BadMatch)
224 217
	|| (ee->request_code == X_PolyText8 && ee->error_code == BadDrawable)
234 227
}
235 228
236 229
int
237 -
main(int argc, char *argv[])
238 -
{
230 +
main(int argc, char *argv[]) {
239 231
	int r, xfd;
240 232
	fd_set rd;
241 233
tag.c +6 −12
33 33
/* extern */
34 34
35 35
Client *
36 -
getnext(Client *c)
37 -
{
36 +
getnext(Client *c) {
38 37
	for(; c && !isvisible(c); c = c->next);
39 38
	return c;
40 39
}
41 40
42 41
Client *
43 -
getprev(Client *c)
44 -
{
42 +
getprev(Client *c) {
45 43
	for(; c && !isvisible(c); c = c->prev);
46 44
	return c;
47 45
}
48 46
49 47
void
50 -
initrregs()
51 -
{
48 +
initrregs() {
52 49
	unsigned int i;
53 50
	regex_t *reg;
54 51
76 73
}
77 74
78 75
void
79 -
settags(Client *c, Client *trans)
80 -
{
76 +
settags(Client *c, Client *trans) {
81 77
	char prop[512];
82 78
	unsigned int i, j;
83 79
	regmatch_t tmp;
114 110
}
115 111
116 112
void
117 -
tag(Arg *arg)
118 -
{
113 +
tag(Arg *arg) {
119 114
	unsigned int i;
120 115
121 116
	if(!sel)
129 124
}
130 125
131 126
void
132 -
toggletag(Arg *arg)
133 -
{
127 +
toggletag(Arg *arg) {
134 128
	unsigned int i;
135 129
136 130
	if(!sel)
util.c +4 −8
12 12
/* extern */
13 13
14 14
void *
15 -
emallocz(unsigned int size)
16 -
{
15 +
emallocz(unsigned int size) {
17 16
	void *res = calloc(1, size);
18 17
19 18
	if(!res)
22 21
}
23 22
24 23
void
25 -
eprint(const char *errstr, ...)
26 -
{
24 +
eprint(const char *errstr, ...) {
27 25
	va_list ap;
28 26
29 27
	va_start(ap, errstr);
33 31
}
34 32
35 33
void *
36 -
erealloc(void *ptr, unsigned int size)
37 -
{
34 +
erealloc(void *ptr, unsigned int size) {
38 35
	void *res = realloc(ptr, size);
39 36
	if(!res)
40 37
		eprint("fatal: could not malloc() %u bytes\n", size);
42 39
}
43 40
44 41
void
45 -
spawn(Arg *arg)
46 -
{
42 +
spawn(Arg *arg) {
47 43
	static char *shell = NULL;
48 44
49 45
	if(!shell && !(shell = getenv("SHELL")))
view.c +16 −32
8 8
/* static */
9 9
10 10
static Client *
11 -
minclient()
12 -
{
11 +
minclient() {
13 12
	Client *c, *min;
14 13
15 14
	if((clients && clients->isfloat) || arrange == dofloat)
21 20
}
22 21
23 22
static void
24 -
reorder()
25 -
{
23 +
reorder() {
26 24
	Client *c, *newclients, *tail;
27 25
28 26
	newclients = tail = NULL;
40 38
}
41 39
42 40
static Client *
43 -
nexttiled(Client *c)
44 -
{
41 +
nexttiled(Client *c) {
45 42
	for(c = getnext(c); c && c->isfloat; c = getnext(c->next));
46 43
	return c;
47 44
}
51 48
void (*arrange)(Arg *) = DEFMODE;
52 49
53 50
void
54 -
detach(Client *c)
55 -
{
51 +
detach(Client *c) {
56 52
	if(c->prev)
57 53
		c->prev->next = c->next;
58 54
	if(c->next)
63 59
}
64 60
65 61
void
66 -
dofloat(Arg *arg)
67 -
{
62 +
dofloat(Arg *arg) {
68 63
	Client *c;
69 64
70 65
	maximized = False;
84 79
}
85 80
86 81
void
87 -
dotile(Arg *arg)
88 -
{
82 +
dotile(Arg *arg) {
89 83
	int h, i, n, w;
90 84
	Client *c;
91 85
148 142
}
149 143
150 144
void
151 -
focusnext(Arg *arg)
152 -
{
145 +
focusnext(Arg *arg) {
153 146
	Client *c;
154 147
   
155 148
	if(!sel)
164 157
}
165 158
166 159
void
167 -
focusprev(Arg *arg)
168 -
{
160 +
focusprev(Arg *arg) {
169 161
	Client *c;
170 162
171 163
	if(!sel)
182 174
}
183 175
184 176
Bool
185 -
isvisible(Client *c)
186 -
{
177 +
isvisible(Client *c) {
187 178
	unsigned int i;
188 179
189 180
	for(i = 0; i < ntags; i++)
193 184
}
194 185
195 186
void
196 -
resizecol(Arg *arg)
197 -
{
187 +
resizecol(Arg *arg) {
198 188
	unsigned int n;
199 189
	Client *c;
200 190
218 208
}
219 209
220 210
void
221 -
restack()
222 -
{
211 +
restack() {
223 212
	Client *c;
224 213
	XEvent ev;
225 214
	
242 231
}
243 232
244 233
void
245 -
togglemode(Arg *arg)
246 -
{
234 +
togglemode(Arg *arg) {
247 235
	arrange = (arrange == dofloat) ? dotile : dofloat;
248 236
	if(sel)
249 237
		arrange(NULL);
252 240
}
253 241
254 242
void
255 -
toggleview(Arg *arg)
256 -
{
243 +
toggleview(Arg *arg) {
257 244
	unsigned int i;
258 245
259 246
	seltag[arg->i] = !seltag[arg->i];
265 252
}
266 253
267 254
void
268 -
view(Arg *arg)
269 -
{
255 +
view(Arg *arg) {
270 256
	unsigned int i;
271 257
272 258
	for(i = 0; i < ntags; i++)
277 263
}
278 264
279 265
void
280 -
viewall(Arg *arg)
281 -
{
266 +
viewall(Arg *arg) {
282 267
	unsigned int i;
283 268
284 269
	for(i = 0; i < ntags; i++)
288 273
}
289 274
290 275
void
291 -
zoom(Arg *arg)
292 -
{
276 +
zoom(Arg *arg) {
293 277
	unsigned int n;
294 278
	Client *c;
295 279