comparison wm.c @ 26:e8f627998d6f

simplified several portions of code through replacing rect structs with x,y,h,w counterparts (much more readable)
author Anselm R. Garbe <garbeam@wmii.de>
date Wed, 12 Jul 2006 15:17:22 +0200
parents 3ef108a5ca0a
children f96fb3fd8203
comparison
equal deleted inserted replaced
25:e238dc4844d7 26:e8f627998d6f
21 /* X structs */ 21 /* X structs */
22 Display *dpy; 22 Display *dpy;
23 Window root, barwin; 23 Window root, barwin;
24 Atom wm_atom[WMLast], net_atom[NetLast]; 24 Atom wm_atom[WMLast], net_atom[NetLast];
25 Cursor cursor[CurLast]; 25 Cursor cursor[CurLast];
26 XRectangle rect, barrect;
27 Bool running = True; 26 Bool running = True;
28 Bool sel_screen; 27 Bool sel_screen;
29 28
30 char statustext[1024], tag[256]; 29 char statustext[1024], tag[256];
31 int screen; 30 int screen, sx, sy, sw, sh, bx, by, bw, bh;
32 31
33 Brush brush = {0}; 32 Brush brush = {0};
34 Client *clients = NULL; 33 Client *clients = NULL;
35 Client *stack = NULL; 34 Client *stack = NULL;
36 35
37 static Bool other_wm_running; 36 static Bool other_wm_running;
38 static const char version[] = "gridwm - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n"; 37 static const char version[] = "gridwm - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n";
39 static int (*x_error_handler) (Display *, XErrorEvent *); 38 static int (*x_error_handler) (Display *, XErrorEvent *);
40 39
41 static const char *status[] = { 40 static const char *status[] = {
42 "sh", "-c", "echo -n `date '+%Y/%m/%d %H:%M'`" 41 "sh", "-c", "echo -n `date '+%Y-%m-%d %H:%M'`"
43 " `uptime | sed 's/.*://; s/,//g'`" 42 " `uptime | sed 's/.*://; s/,//g'`"
44 " `acpi | awk '{print $4}' | sed 's/,//'`", 0 43 " `acpi | awk '{print $4}' | sed 's/,//'`", 0
45 }; 44 };
46 45
47 static void 46 static void
218 XFlush(dpy); 217 XFlush(dpy);
219 218
220 if(other_wm_running) 219 if(other_wm_running)
221 error("gridwm: another window manager is already running\n"); 220 error("gridwm: another window manager is already running\n");
222 221
223 rect.x = rect.y = 0; 222 sx = sy = 0;
224 rect.width = DisplayWidth(dpy, screen); 223 sw = DisplayWidth(dpy, screen);
225 rect.height = DisplayHeight(dpy, screen); 224 sh = DisplayHeight(dpy, screen);
226 sel_screen = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask); 225 sel_screen = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
227 226
228 XSetErrorHandler(0); 227 XSetErrorHandler(0);
229 x_error_handler = XSetErrorHandler(error_handler); 228 x_error_handler = XSetErrorHandler(error_handler);
230 229
251 250
252 wa.override_redirect = 1; 251 wa.override_redirect = 1;
253 wa.background_pixmap = ParentRelative; 252 wa.background_pixmap = ParentRelative;
254 wa.event_mask = ExposureMask; 253 wa.event_mask = ExposureMask;
255 254
256 barrect = rect; 255 bx = by = 0;
257 barrect.height = labelheight(&brush.font); 256 bw = sw;
258 barrect.y = rect.height - barrect.height; 257 bh = texth(&brush.font);
259 barwin = XCreateWindow(dpy, root, barrect.x, barrect.y, 258 barwin = XCreateWindow(dpy, root, bx, by, bw, bh, 0, DefaultDepth(dpy, screen),
260 barrect.width, barrect.height, 0, DefaultDepth(dpy, screen),
261 CopyFromParent, DefaultVisual(dpy, screen), 259 CopyFromParent, DefaultVisual(dpy, screen),
262 CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); 260 CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
263 XDefineCursor(dpy, barwin, cursor[CurNormal]); 261 XDefineCursor(dpy, barwin, cursor[CurNormal]);
264 XMapRaised(dpy, barwin); 262 XMapRaised(dpy, barwin);
265 263
266 brush.drawable = XCreatePixmap(dpy, root, rect.width, barrect.height, 264 brush.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
267 DefaultDepth(dpy, screen));
268 brush.gc = XCreateGC(dpy, root, 0, 0); 265 brush.gc = XCreateGC(dpy, root, 0, 0);
269 266
270 pipe_spawn(statustext, sizeof(statustext), dpy, (char **)status); 267 pipe_spawn(statustext, sizeof(statustext), dpy, (char **)status);
271 draw_bar(); 268 draw_bar();
272 269