comparison client.c @ 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)
author Anselm R. Garbe <arg@10kloc.org>
date Tue, 12 Sep 2006 10:57:28 +0200
parents ffb462fb7903
children bd32d89ed9d5
comparison
equal deleted inserted replaced
460:ab4b08d49d24 461:9d23330a5268
9 #include <X11/Xutil.h> 9 #include <X11/Xutil.h>
10 10
11 /* static functions */ 11 /* static functions */
12 12
13 static void 13 static void
14 detachstack(Client *c) 14 detachstack(Client *c) {
15 {
16 Client **tc; 15 Client **tc;
17 for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext); 16 for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext);
18 *tc = c->snext; 17 *tc = c->snext;
19 } 18 }
20 19
21 static void 20 static void
22 grabbuttons(Client *c, Bool focused) 21 grabbuttons(Client *c, Bool focused) {
23 {
24 XUngrabButton(dpy, AnyButton, AnyModifier, c->win); 22 XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
25 23
26 if(focused) { 24 if(focused) {
27 XGrabButton(dpy, Button1, MODKEY, c->win, False, BUTTONMASK, 25 XGrabButton(dpy, Button1, MODKEY, c->win, False, BUTTONMASK,
28 GrabModeAsync, GrabModeSync, None, None); 26 GrabModeAsync, GrabModeSync, None, None);
52 GrabModeAsync, GrabModeSync, None, None); 50 GrabModeAsync, GrabModeSync, None, None);
53 } 51 }
54 else 52 else
55 XGrabButton(dpy, AnyButton, AnyModifier, c->win, False, BUTTONMASK, 53 XGrabButton(dpy, AnyButton, AnyModifier, c->win, False, BUTTONMASK,
56 GrabModeAsync, GrabModeSync, None, None); 54 GrabModeAsync, GrabModeSync, None, None);
57
58 } 55 }
59 56
60 static void 57 static void
61 resizetitle(Client *c) 58 resizetitle(Client *c) {
62 {
63 c->tw = textw(c->name); 59 c->tw = textw(c->name);
64 if(c->tw > c->w) 60 if(c->tw > c->w)
65 c->tw = c->w + 2; 61 c->tw = c->w + 2;
66 c->tx = c->x + c->w - c->tw + 2; 62 c->tx = c->x + c->w - c->tw + 2;
67 c->ty = c->y; 63 c->ty = c->y;
68 if(isvisible(c)) 64 if(isvisible(c))
69 XMoveResizeWindow(dpy, c->twin, c->tx, c->ty, c->tw, c->th); 65 XMoveResizeWindow(dpy, c->twin, c->tx, c->ty, c->tw, c->th);
70 else 66 else
71 XMoveResizeWindow(dpy, c->twin, c->tx + 2 * sw, c->ty, c->tw, c->th); 67 XMoveResizeWindow(dpy, c->twin, c->tx + 2 * sw, c->ty, c->tw, c->th);
72
73 } 68 }
74 69
75 static int 70 static int
76 xerrordummy(Display *dsply, XErrorEvent *ee) 71 xerrordummy(Display *dsply, XErrorEvent *ee) {
77 {
78 return 0; 72 return 0;
79 } 73 }
80 74
81 /* extern functions */ 75 /* extern functions */
82 76
83 void 77 void
84 ban(Client *c) 78 ban(Client *c) {
85 {
86 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); 79 XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
87 XMoveWindow(dpy, c->twin, c->tx + 2 * sw, c->ty); 80 XMoveWindow(dpy, c->twin, c->tx + 2 * sw, c->ty);
88 } 81 }
89 82
90 void 83 void
91 focus(Client *c) 84 focus(Client *c) {
92 {
93 Client *old; 85 Client *old;
94 86
95 if(!issel) 87 if(!issel)
96 return; 88 return;
97 if(!sel) 89 if(!sel)
117 else 109 else
118 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); 110 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
119 } 111 }
120 112
121 Client * 113 Client *
122 getclient(Window w) 114 getclient(Window w) {
123 {
124 Client *c; 115 Client *c;
125 116
126 for(c = clients; c; c = c->next) 117 for(c = clients; c; c = c->next)
127 if(c->win == w) 118 if(c->win == w)
128 return c; 119 return c;
129 return NULL; 120 return NULL;
130 } 121 }
131 122
132 Client * 123 Client *
133 getctitle(Window w) 124 getctitle(Window w) {
134 {
135 Client *c; 125 Client *c;
136 126
137 for(c = clients; c; c = c->next) 127 for(c = clients; c; c = c->next)
138 if(c->twin == w) 128 if(c->twin == w)
139 return c; 129 return c;
140 return NULL; 130 return NULL;
141 } 131 }
142 132
143 void 133 void
144 gravitate(Client *c, Bool invert) 134 gravitate(Client *c, Bool invert) {
145 {
146 int dx = 0, dy = 0; 135 int dx = 0, dy = 0;
147 136
148 switch(c->grav) { 137 switch(c->grav) {
149 default: 138 default:
150 break; 139 break;
194 c->x += dx; 183 c->x += dx;
195 c->y += dy; 184 c->y += dy;
196 } 185 }
197 186
198 void 187 void
199 killclient(Arg *arg) 188 killclient(Arg *arg) {
200 {
201 if(!sel) 189 if(!sel)
202 return; 190 return;
203 if(sel->proto & PROTODELWIN) 191 if(sel->proto & PROTODELWIN)
204 sendevent(sel->win, wmatom[WMProtocols], wmatom[WMDelete]); 192 sendevent(sel->win, wmatom[WMProtocols], wmatom[WMDelete]);
205 else 193 else
206 XKillClient(dpy, sel->win); 194 XKillClient(dpy, sel->win);
207 } 195 }
208 196
209 void 197 void
210 manage(Window w, XWindowAttributes *wa) 198 manage(Window w, XWindowAttributes *wa) {
211 {
212 Client *c; 199 Client *c;
213 Window trans; 200 Window trans;
214 XSetWindowAttributes twa; 201 XSetWindowAttributes twa;
215 202
216 c = emallocz(sizeof(Client)); 203 c = emallocz(sizeof(Client));
268 focus(c); 255 focus(c);
269 arrange(NULL); 256 arrange(NULL);
270 } 257 }
271 258
272 void 259 void
273 resize(Client *c, Bool sizehints, Corner sticky) 260 resize(Client *c, Bool sizehints, Corner sticky) {
274 {
275 int bottom = c->y + c->h; 261 int bottom = c->y + c->h;
276 int right = c->x + c->w; 262 int right = c->x + c->w;
277 XWindowChanges wc; 263 XWindowChanges wc;
278 264
279 if(sizehints) { 265 if(sizehints) {
307 XConfigureWindow(dpy, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc); 293 XConfigureWindow(dpy, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc);
308 XSync(dpy, False); 294 XSync(dpy, False);
309 } 295 }
310 296
311 void 297 void
312 updatesize(Client *c) 298 updatesize(Client *c) {
313 {
314 long msize; 299 long msize;
315 XSizeHints size; 300 XSizeHints size;
316 301
317 if(!XGetWMNormalHints(dpy, c->win, &size, &msize) || !size.flags) 302 if(!XGetWMNormalHints(dpy, c->win, &size, &msize) || !size.flags)
318 size.flags = PSize; 303 size.flags = PSize;
346 else 331 else
347 c->grav = NorthWestGravity; 332 c->grav = NorthWestGravity;
348 } 333 }
349 334
350 void 335 void
351 updatetitle(Client *c) 336 updatetitle(Client *c) {
352 {
353 char **list = NULL; 337 char **list = NULL;
354 int n; 338 int n;
355 XTextProperty name; 339 XTextProperty name;
356 340
357 name.nitems = 0; 341 name.nitems = 0;
374 XFree(name.value); 358 XFree(name.value);
375 resizetitle(c); 359 resizetitle(c);
376 } 360 }
377 361
378 void 362 void
379 togglemax(Arg *arg) 363 togglemax(Arg *arg) {
380 {
381 int ox, oy, ow, oh; 364 int ox, oy, ow, oh;
382 Client *c; 365 Client *c;
383 XEvent ev; 366 XEvent ev;
384 367
385 if(!sel) 368 if(!sel)
410 arrange(NULL); 393 arrange(NULL);
411 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); 394 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
412 } 395 }
413 396
414 void 397 void
415 unmanage(Client *c) 398 unmanage(Client *c) {
416 {
417 Client *nc; 399 Client *nc;
418 400
419 XGrabServer(dpy); 401 XGrabServer(dpy);
420 XSetErrorHandler(xerrordummy); 402 XSetErrorHandler(xerrordummy);
421 403