comparison client.c @ 532:651f2c868b31

code polishing, removed unnecessary newlines
author Anselm R. Garbe <arg@10kloc.org>
date Fri, 06 Oct 2006 11:50:15 +0200
parents 2b4bd49fc155
children a5567a0d3011
comparison
equal deleted inserted replaced
531:96563762b4ad 532:651f2c868b31
1 /* 1 /* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details. 2 * See LICENSE file for license details.
4 */ 3 */
5 #include "dwm.h" 4 #include "dwm.h"
6 #include <stdlib.h> 5 #include <stdlib.h>
7 #include <string.h> 6 #include <string.h>
154 case SouthGravity: 153 case SouthGravity:
155 case SouthWestGravity: 154 case SouthWestGravity:
156 dy = -(c->h); 155 dy = -(c->h);
157 break; 156 break;
158 } 157 }
159
160 switch (c->grav) { 158 switch (c->grav) {
161 default: 159 default:
162 break; 160 break;
163 case StaticGravity: 161 case StaticGravity:
164 case NorthWestGravity: 162 case NorthWestGravity:
175 case EastGravity: 173 case EastGravity:
176 case SouthEastGravity: 174 case SouthEastGravity:
177 dx = -(c->w + c->border); 175 dx = -(c->w + c->border);
178 break; 176 break;
179 } 177 }
180
181 if(invert) { 178 if(invert) {
182 dx = -dx; 179 dx = -dx;
183 dy = -dy; 180 dy = -dy;
184 } 181 }
185 c->x += dx; 182 c->x += dx;
208 c->x = c->tx = wa->x; 205 c->x = c->tx = wa->x;
209 c->y = c->ty = wa->y; 206 c->y = c->ty = wa->y;
210 c->w = c->tw = wa->width; 207 c->w = c->tw = wa->width;
211 c->h = wa->height; 208 c->h = wa->height;
212 c->th = bh; 209 c->th = bh;
213
214 c->border = 0; 210 c->border = 0;
215 updatesize(c); 211 updatesize(c);
216
217 if(c->x + c->w + 2 * BORDERPX > sw) 212 if(c->x + c->w + 2 * BORDERPX > sw)
218 c->x = sw - c->w - 2 * BORDERPX; 213 c->x = sw - c->w - 2 * BORDERPX;
219 if(c->x < sx) 214 if(c->x < sx)
220 c->x = sx; 215 c->x = sx;
221 if(c->y + c->h + 2 * BORDERPX > sh) 216 if(c->y + c->h + 2 * BORDERPX > sh)
222 c->y = sh - c->h - 2 * BORDERPX; 217 c->y = sh - c->h - 2 * BORDERPX;
223 if(c->h != sh && c->y < bh) 218 if(c->h != sh && c->y < bh)
224 c->y = bh; 219 c->y = bh;
225
226 c->proto = getproto(c->win); 220 c->proto = getproto(c->win);
227 XSelectInput(dpy, c->win, 221 XSelectInput(dpy, c->win,
228 StructureNotifyMask | PropertyChangeMask | EnterWindowMask); 222 StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
229 XGetTransientForHint(dpy, c->win, &trans); 223 XGetTransientForHint(dpy, c->win, &trans);
230 twa.override_redirect = 1; 224 twa.override_redirect = 1;
231 twa.background_pixmap = ParentRelative; 225 twa.background_pixmap = ParentRelative;
232 twa.event_mask = ExposureMask | EnterWindowMask; 226 twa.event_mask = ExposureMask | EnterWindowMask;
233
234 c->twin = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th, 227 c->twin = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th,
235 0, DefaultDepth(dpy, screen), CopyFromParent, 228 0, DefaultDepth(dpy, screen), CopyFromParent,
236 DefaultVisual(dpy, screen), 229 DefaultVisual(dpy, screen),
237 CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa); 230 CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
238
239 grabbuttons(c, False); 231 grabbuttons(c, False);
240 updatetitle(c); 232 updatetitle(c);
241 settags(c, getclient(trans)); 233 settags(c, getclient(trans));
242 if(!c->isfloat) 234 if(!c->isfloat)
243 c->isfloat = trans 235 c->isfloat = trans
244 || (c->maxw && c->minw && 236 || (c->maxw && c->minw &&
245 c->maxw == c->minw && c->maxh == c->minh); 237 c->maxw == c->minw && c->maxh == c->minh);
246 resizetitle(c); 238 resizetitle(c);
247
248 if(clients) 239 if(clients)
249 clients->prev = c; 240 clients->prev = c;
250 c->next = clients; 241 c->next = clients;
251 c->snext = stack; 242 c->snext = stack;
252 stack = clients = c; 243 stack = clients = c;
253
254 ban(c); 244 ban(c);
255 XMapWindow(dpy, c->win); 245 XMapWindow(dpy, c->win);
256 XMapWindow(dpy, c->twin); 246 XMapWindow(dpy, c->twin);
257 if(isvisible(c)) 247 if(isvisible(c))
258 focus(c); 248 focus(c);
281 } 271 }
282 if(sticky == TopRight || sticky == BotRight) 272 if(sticky == TopRight || sticky == BotRight)
283 c->x = right - c->w; 273 c->x = right - c->w;
284 if(sticky == BotLeft || sticky == BotRight) 274 if(sticky == BotLeft || sticky == BotRight)
285 c->y = bottom - c->h; 275 c->y = bottom - c->h;
286
287 /* offscreen appearance fixes */ 276 /* offscreen appearance fixes */
288 if(c->x + c->w < sx) 277 if(c->x + c->w < sx)
289 c->x = sx; 278 c->x = sx;
290 if(c->y + c->h < bh) 279 if(c->y + c->h < bh)
291 c->y = bh; 280 c->y = bh;
292 if(c->x > sw) 281 if(c->x > sw)
293 c->x = sw - c->w; 282 c->x = sw - c->w;
294 if(c->y > sh) 283 if(c->y > sh)
295 c->y = sh - c->h; 284 c->y = sh - c->h;
296
297 resizetitle(c); 285 resizetitle(c);
298 wc.x = c->x; 286 wc.x = c->x;
299 wc.y = c->y; 287 wc.y = c->y;
300 wc.width = c->w; 288 wc.width = c->w;
301 wc.height = c->h; 289 wc.height = c->h;
390 Client *nc; 378 Client *nc;
391 379
392 /* The server grab construct avoids race conditions. */ 380 /* The server grab construct avoids race conditions. */
393 XGrabServer(dpy); 381 XGrabServer(dpy);
394 XSetErrorHandler(xerrordummy); 382 XSetErrorHandler(xerrordummy);
395
396 detach(c); 383 detach(c);
397 detachstack(c); 384 detachstack(c);
398 if(sel == c) { 385 if(sel == c) {
399 for(nc = stack; nc && !isvisible(nc); nc = nc->snext); 386 for(nc = stack; nc && !isvisible(nc); nc = nc->snext);
400 focus(nc); 387 focus(nc);
401 } 388 }
402
403 XUngrabButton(dpy, AnyButton, AnyModifier, c->win); 389 XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
404 XDestroyWindow(dpy, c->twin); 390 XDestroyWindow(dpy, c->twin);
405
406 free(c->tags); 391 free(c->tags);
407 free(c); 392 free(c);
408
409 XSync(dpy, False); 393 XSync(dpy, False);
410 XSetErrorHandler(xerror); 394 XSetErrorHandler(xerror);
411 XUngrabServer(dpy); 395 XUngrabServer(dpy);
412 arrange(NULL); 396 arrange(NULL);
413 } 397 }