comparison aewl.c @ 772:0c1e9952a278

naming change from dwm to aewl; cleanups
author meillo@marmaro.de
date Sat, 06 Dec 2008 11:15:51 +0100
parents 59a6f0ba5478
children d2e56ce18f5b
comparison
equal deleted inserted replaced
771:59a6f0ba5478 772:0c1e9952a278
130 unsigned int nmaster; /* number of master clients */ 130 unsigned int nmaster; /* number of master clients */
131 unsigned int numlockmask; /* dynamic lock mask */ 131 unsigned int numlockmask; /* dynamic lock mask */
132 void (*handler[LASTEvent])(XEvent *); /* event handler */ 132 void (*handler[LASTEvent])(XEvent *); /* event handler */
133 void (*arrange)(void); /* arrange function, indicates mode */ 133 void (*arrange)(void); /* arrange function, indicates mode */
134 Atom wmatom[WMLast], netatom[NetLast]; 134 Atom wmatom[WMLast], netatom[NetLast];
135 Bool running, selscreen, seltag; 135 Bool running = True;
136 Client *clients, *sel, *stack; /* global client list and stack */ 136 Bool selscreen = True;
137 Bool seltag;
138 Client* clients = NULL; /* global client list */
139 Client* stack = NULL; /* global client stack */
140 Client* sel = NULL; /* selected client */
137 Cursor cursor[CurLast]; 141 Cursor cursor[CurLast];
138 DC dc; /* global draw context */ 142 DC dc = {0}; /* global draw context */
139 Display *dpy; 143 Display *dpy;
140 Window root, barwin; 144 Window root, barwin;
141
142 Bool running = True;
143 Bool selscreen = True;
144 Client *clients = NULL;
145 Client *sel = NULL;
146 Client *stack = NULL;
147 DC dc = {0};
148 145
149 static int (*xerrorxlib)(Display *, XErrorEvent *); 146 static int (*xerrorxlib)(Display *, XErrorEvent *);
150 static Bool otherwm, readin; 147 static Bool otherwm, readin;
151 static unsigned int len = 0; 148 static unsigned int len = 0;
152 149
153 150
154 RULES 151 RULES
152 KEYS
153
155 154
156 155
157 /* client.c */ 156 /* client.c */
158 void configure(Client *c); /* send synthetic configure event */ 157 void configure(Client *c); /* send synthetic configure event */
159 void focus(Client *c); /* focus c, c may be NULL */ 158 void focus(Client *c); /* focus c, c may be NULL */
175 void grabkeys(void); /* grab all keys defined in config.h */ 174 void grabkeys(void); /* grab all keys defined in config.h */
176 void procevent(void); /* process pending X events */ 175 void procevent(void); /* process pending X events */
177 176
178 /* main.c */ 177 /* main.c */
179 void sendevent(Window w, Atom a, long value); /* send synthetic event to w */ 178 void sendevent(Window w, Atom a, long value); /* send synthetic event to w */
180 int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */ 179 int xerror(Display *dsply, XErrorEvent *ee); /* X error handler */
181 180
182 /* tag.c */ 181 /* tag.c */
183 Client *getnext(Client *c); /* returns next visible client */ 182 Client *getnext(Client *c); /* returns next visible client */
184 void settag(Client *c, Client *trans); /* sets tag of c */ 183 void settag(Client *c, Client *trans); /* sets tag of c */
185 184
197 196
198 void toggleview(void); /* toggle the view */ 197 void toggleview(void); /* toggle the view */
199 void focusnext(void); /* focuses next visible client */ 198 void focusnext(void); /* focuses next visible client */
200 void zoom(void); /* zooms the focused client to master area */ 199 void zoom(void); /* zooms the focused client to master area */
201 void killclient(void); /* kill c nicely */ 200 void killclient(void); /* kill c nicely */
202 void quit(void); /* quit dwm nicely */ 201 void quit(void); /* quit nicely */
203 void togglemode(void); /* toggles global arrange function (dotile/domax) */ 202 void togglemode(void); /* toggles global arrange function (dotile/domax) */
204 void togglefloat(void); /* toggles focusesd client between floating/non-floating state */ 203 void togglefloat(void); /* toggles focusesd client between floating/non-floating state */
205 void incnmaster(void); /* increments nmaster */ 204 void incnmaster(void); /* increments nmaster */
206 void decnmaster(void); /* decrements nmaster */ 205 void decnmaster(void); /* decrements nmaster */
207 void toggletag(void); /* toggles tag of c */ 206 void toggletag(void); /* toggles tag of c */
507 if(fork() == 0) { 506 if(fork() == 0) {
508 if(dpy) 507 if(dpy)
509 close(ConnectionNumber(dpy)); 508 close(ConnectionNumber(dpy));
510 setsid(); 509 setsid();
511 execl(shell, shell, "-c", cmd, (char *)NULL); 510 execl(shell, shell, "-c", cmd, (char *)NULL);
512 fprintf(stderr, "dwm: execl '%s -c %s'", shell, cmd); 511 fprintf(stderr, "aewl: execl '%s -c %s'", shell, cmd);
513 perror(" failed"); 512 perror(" failed");
514 } 513 }
515 exit(0); 514 exit(0);
516 } 515 }
517 wait(0); 516 wait(0);
590 589
591 590
592 591
593 592
594 593
595
596
597
598
599
600
601 /* from event.c */ 594 /* from event.c */
602 /* static */ 595 /* static */
603
604 KEYS
605 596
606 597
607 598
608 static void 599 static void
609 movemouse(Client *c) { 600 movemouse(Client *c) {
1582 barwin = XCreateWindow(dpy, root, sx, sy, sw, bh, 0, 1573 barwin = XCreateWindow(dpy, root, sx, sy, sw, bh, 0,
1583 DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen), 1574 DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen),
1584 CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); 1575 CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
1585 XDefineCursor(dpy, barwin, cursor[CurNormal]); 1576 XDefineCursor(dpy, barwin, cursor[CurNormal]);
1586 XMapRaised(dpy, barwin); 1577 XMapRaised(dpy, barwin);
1587 strcpy(stext, "dwm-"VERSION); 1578 strcpy(stext, "aewl-"VERSION);
1588 /* windowarea */ 1579 /* windowarea */
1589 wax = sx; 1580 wax = sx;
1590 way = sy + bh; 1581 way = sy + bh;
1591 wah = sh - bh; 1582 wah = sh - bh;
1592 waw = sw; 1583 waw = sw;
1642 || (ee->request_code == X_PolySegment && ee->error_code == BadDrawable) 1633 || (ee->request_code == X_PolySegment && ee->error_code == BadDrawable)
1643 || (ee->request_code == X_ConfigureWindow && ee->error_code == BadMatch) 1634 || (ee->request_code == X_ConfigureWindow && ee->error_code == BadMatch)
1644 || (ee->request_code == X_GrabKey && ee->error_code == BadAccess) 1635 || (ee->request_code == X_GrabKey && ee->error_code == BadAccess)
1645 || (ee->request_code == X_CopyArea && ee->error_code == BadDrawable)) 1636 || (ee->request_code == X_CopyArea && ee->error_code == BadDrawable))
1646 return 0; 1637 return 0;
1647 fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n", 1638 fprintf(stderr, "aewl: fatal error: request code=%d, error code=%d\n",
1648 ee->request_code, ee->error_code); 1639 ee->request_code, ee->error_code);
1649 return xerrorxlib(dpy, ee); /* may call exit */ 1640 return xerrorxlib(dpy, ee); /* may call exit */
1650 } 1641 }
1651 1642
1652 int 1643 int
1654 char *p; 1645 char *p;
1655 int r, xfd; 1646 int r, xfd;
1656 fd_set rd; 1647 fd_set rd;
1657 1648
1658 if(argc == 2 && !strncmp("-v", argv[1], 3)) { 1649 if(argc == 2 && !strncmp("-v", argv[1], 3)) {
1659 fputs("dwm-"VERSION", (C)opyright MMVI-MMVII Anselm R. Garbe\n", stdout); 1650 fputs("aewl-"VERSION", Copyright 2008 markus schnalke <meillo@marmaro.de>\n", stdout);
1651 fputs("forked off dwm-3.4, (C)opyright MMVI-MMVII Anselm R. Garbe\n", stdout);
1660 exit(EXIT_SUCCESS); 1652 exit(EXIT_SUCCESS);
1661 } else if(argc != 1) { 1653 } else if(argc != 1) {
1662 eprint("usage: dwm [-v]\n"); 1654 eprint("usage: aewl [-v]\n");
1663 } 1655 }
1664 setlocale(LC_CTYPE, ""); 1656 setlocale(LC_CTYPE, "");
1665 dpy = XOpenDisplay(0); 1657 dpy = XOpenDisplay(0);
1666 if(!dpy) { 1658 if(!dpy) {
1667 eprint("dwm: cannot open display\n"); 1659 eprint("aewl: cannot open display\n");
1668 } 1660 }
1669 xfd = ConnectionNumber(dpy); 1661 xfd = ConnectionNumber(dpy);
1670 screen = DefaultScreen(dpy); 1662 screen = DefaultScreen(dpy);
1671 root = RootWindow(dpy, screen); 1663 root = RootWindow(dpy, screen);
1672 otherwm = False; 1664 otherwm = False;
1673 XSetErrorHandler(xerrorstart); 1665 XSetErrorHandler(xerrorstart);
1674 /* this causes an error if some other window manager is running */ 1666 /* this causes an error if some other window manager is running */
1675 XSelectInput(dpy, root, SubstructureRedirectMask); 1667 XSelectInput(dpy, root, SubstructureRedirectMask);
1676 XSync(dpy, False); 1668 XSync(dpy, False);
1677 if(otherwm) { 1669 if(otherwm) {
1678 eprint("dwm: another window manager is already running\n"); 1670 eprint("aewl: another window manager is already running\n");
1679 } 1671 }
1680 1672
1681 XSync(dpy, False); 1673 XSync(dpy, False);
1682 XSetErrorHandler(NULL); 1674 XSetErrorHandler(NULL);
1683 xerrorxlib = XSetErrorHandler(xerror); 1675 xerrorxlib = XSetErrorHandler(xerror);