comparison aewl.c @ 778:7ea91d4d0882

rename eprint() -> die()
author meillo@marmaro.de
date Mon, 16 Feb 2009 16:18:25 +0100
parents 3835ddb75a55
children f1e806b34697
comparison
equal deleted inserted replaced
777:3835ddb75a55 778:7ea91d4d0882
168 168
169 Client *getnext(Client *c); /* returns next visible client */ 169 Client *getnext(Client *c); /* returns next visible client */
170 void settag(Client *c, Client *trans); /* sets tag of c */ 170 void settag(Client *c, Client *trans); /* sets tag of c */
171 171
172 void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */ 172 void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */
173 void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */ 173 void die(const char *errstr, ...); /* prints errstr and exits with 1 */
174 174
175 void detach(Client *c); /* detaches c from global client list */ 175 void detach(Client *c); /* detaches c from global client list */
176 void dotile(void); /* arranges all windows tiled */ 176 void dotile(void); /* arranges all windows tiled */
177 void domax(void); /* arranges all windows fullscreen */ 177 void domax(void); /* arranges all windows fullscreen */
178 Bool isvisible(Client *c); /* returns True if client is visible */ 178 Bool isvisible(Client *c); /* returns True if client is visible */
442 void * 442 void *
443 emallocz(unsigned int size) { 443 emallocz(unsigned int size) {
444 void *res = calloc(1, size); 444 void *res = calloc(1, size);
445 445
446 if(!res) 446 if(!res)
447 eprint("fatal: could not malloc() %u bytes\n", size); 447 die("fatal: could not malloc() %u bytes\n", size);
448 return res; 448 return res;
449 } 449 }
450 450
451 void 451 void
452 eprint(const char *errstr, ...) { 452 die(const char *errstr, ...) {
453 va_list ap; 453 va_list ap;
454 454
455 va_start(ap, errstr); 455 va_start(ap, errstr);
456 vfprintf(stderr, errstr, ap); 456 vfprintf(stderr, errstr, ap);
457 va_end(ap); 457 va_end(ap);
958 getcolor(const char *colstr) { 958 getcolor(const char *colstr) {
959 Colormap cmap = DefaultColormap(dpy, screen); 959 Colormap cmap = DefaultColormap(dpy, screen);
960 XColor color; 960 XColor color;
961 961
962 if(!XAllocNamedColor(dpy, cmap, colstr, &color, &color)) 962 if(!XAllocNamedColor(dpy, cmap, colstr, &color, &color))
963 eprint("error, cannot allocate color '%s'\n", colstr); 963 die("error, cannot allocate color '%s'\n", colstr);
964 return color.pixel; 964 return color.pixel;
965 } 965 }
966 966
967 void 967 void
968 setfont(const char *fontstr) { 968 setfont(const char *fontstr) {
995 } else { 995 } else {
996 if(dc.font.xfont) 996 if(dc.font.xfont)
997 XFreeFont(dpy, dc.font.xfont); 997 XFreeFont(dpy, dc.font.xfont);
998 dc.font.xfont = NULL; 998 dc.font.xfont = NULL;
999 if(!(dc.font.xfont = XLoadQueryFont(dpy, fontstr))) 999 if(!(dc.font.xfont = XLoadQueryFont(dpy, fontstr)))
1000 eprint("error, cannot load font: '%s'\n", fontstr); 1000 die("error, cannot load font: '%s'\n", fontstr);
1001 dc.font.ascent = dc.font.xfont->ascent; 1001 dc.font.ascent = dc.font.xfont->ascent;
1002 dc.font.descent = dc.font.xfont->descent; 1002 dc.font.descent = dc.font.xfont->descent;
1003 } 1003 }
1004 dc.font.height = dc.font.ascent + dc.font.descent; 1004 dc.font.height = dc.font.ascent + dc.font.descent;
1005 } 1005 }
1467 barwin = XCreateWindow(dpy, root, sx, sy, sw, bh, 0, 1467 barwin = XCreateWindow(dpy, root, sx, sy, sw, bh, 0,
1468 DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen), 1468 DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen),
1469 CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); 1469 CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
1470 XDefineCursor(dpy, barwin, cursor[CurNormal]); 1470 XDefineCursor(dpy, barwin, cursor[CurNormal]);
1471 XMapRaised(dpy, barwin); 1471 XMapRaised(dpy, barwin);
1472 strcpy(stext, "aewl-"VERSION);
1473 /* windowarea */ 1472 /* windowarea */
1474 wax = sx; 1473 wax = sx;
1475 way = sy + bh; 1474 way = sy + bh;
1476 wah = sh - bh; 1475 wah = sh - bh;
1477 waw = sw; 1476 waw = sw;
1540 xerrorxlib = XSetErrorHandler(xerrorstart); 1539 xerrorxlib = XSetErrorHandler(xerrorstart);
1541 /* this causes an error if some other window manager is running */ 1540 /* this causes an error if some other window manager is running */
1542 XSelectInput(dpy, DefaultRootWindow(dpy), SubstructureRedirectMask); 1541 XSelectInput(dpy, DefaultRootWindow(dpy), SubstructureRedirectMask);
1543 XSync(dpy, False); 1542 XSync(dpy, False);
1544 if(otherwm) { 1543 if(otherwm) {
1545 eprint("aewl: another window manager is already running\n"); 1544 die("aewl: another window manager is already running\n");
1546 } 1545 }
1547 1546
1548 XSetErrorHandler(xerror); 1547 XSetErrorHandler(xerror);
1549 XSync(dpy, False); 1548 XSync(dpy, False);
1550 } 1549 }
1576 if(argc == 2 && !strncmp("-v", argv[1], 3)) { 1575 if(argc == 2 && !strncmp("-v", argv[1], 3)) {
1577 fputs("aewl-"VERSION", Copyright 2008 markus schnalke <meillo@marmaro.de>\n", stdout); 1576 fputs("aewl-"VERSION", Copyright 2008 markus schnalke <meillo@marmaro.de>\n", stdout);
1578 fputs("forked off dwm-3.4, (C)opyright MMVI-MMVII Anselm R. Garbe\n", stdout); 1577 fputs("forked off dwm-3.4, (C)opyright MMVI-MMVII Anselm R. Garbe\n", stdout);
1579 exit(EXIT_SUCCESS); 1578 exit(EXIT_SUCCESS);
1580 } else if(argc != 1) { 1579 } else if(argc != 1) {
1581 eprint("usage: aewl [-v]\n"); 1580 die("usage: aewl [-v]\n");
1582 } 1581 }
1583 setlocale(LC_CTYPE, ""); 1582 setlocale(LC_CTYPE, "");
1584 dpy = XOpenDisplay(0); 1583 dpy = XOpenDisplay(0);
1585 if(!dpy) { 1584 if(!dpy) {
1586 eprint("aewl: cannot open display\n"); 1585 die("aewl: cannot open display\n");
1587 } 1586 }
1588 1587
1589 checkotherwm(); 1588 checkotherwm();
1590 setup(); 1589 setup();
1591 scan(); 1590 scan();