comparison aewl.c @ 773:d2e56ce18f5b

remove static since its only one source file now; removed empty lines
author meillo@marmaro.de
date Sat, 06 Dec 2008 11:28:48 +0100
parents 0c1e9952a278
children a3399a8964c7
comparison
equal deleted inserted replaced
772:0c1e9952a278 773:d2e56ce18f5b
146 static int (*xerrorxlib)(Display *, XErrorEvent *); 146 static int (*xerrorxlib)(Display *, XErrorEvent *);
147 static Bool otherwm, readin; 147 static Bool otherwm, readin;
148 static unsigned int len = 0; 148 static unsigned int len = 0;
149 149
150 150
151 RULES 151
152 KEYS
153
154
155
156 /* client.c */
157 void configure(Client *c); /* send synthetic configure event */ 152 void configure(Client *c); /* send synthetic configure event */
158 void focus(Client *c); /* focus c, c may be NULL */ 153 void focus(Client *c); /* focus c, c may be NULL */
159 Client *getclient(Window w); /* return client of w */ 154 Client *getclient(Window w); /* return client of w */
160 Bool isprotodel(Client *c); /* returns True if c->win supports wmatom[WMDelete] */ 155 Bool isprotodel(Client *c); /* returns True if c->win supports wmatom[WMDelete] */
161 void manage(Window w, XWindowAttributes *wa); /* manage new client */ 156 void manage(Window w, XWindowAttributes *wa); /* manage new client */
162 void resize(Client *c, Bool sizehints); /* resize c*/ 157 void resize(Client *c, Bool sizehints); /* resize c*/
163 void updatesizehints(Client *c); /* update the size hint variables of c */ 158 void updatesizehints(Client *c); /* update the size hint variables of c */
164 void updatetitle(Client *c); /* update the name of c */ 159 void updatetitle(Client *c); /* update the name of c */
165 void unmanage(Client *c); /* destroy c */ 160 void unmanage(Client *c); /* destroy c */
166 161
167 /* draw.c */
168 void drawstatus(void); /* draw the bar */ 162 void drawstatus(void); /* draw the bar */
169 unsigned long getcolor(const char *colstr); /* return color of colstr */ 163 unsigned long getcolor(const char *colstr); /* return color of colstr */
170 void setfont(const char *fontstr); /* set the font for DC */ 164 void setfont(const char *fontstr); /* set the font for DC */
171 unsigned int textw(const char *text); /* return the width of text in px*/ 165 unsigned int textw(const char *text); /* return the width of text in px*/
172 166
173 /* event.c */
174 void grabkeys(void); /* grab all keys defined in config.h */ 167 void grabkeys(void); /* grab all keys defined in config.h */
175 void procevent(void); /* process pending X events */ 168 void procevent(void); /* process pending X events */
176 169
177 /* main.c */
178 void sendevent(Window w, Atom a, long value); /* send synthetic event to w */ 170 void sendevent(Window w, Atom a, long value); /* send synthetic event to w */
179 int xerror(Display *dsply, XErrorEvent *ee); /* X error handler */ 171 int xerror(Display *dsply, XErrorEvent *ee); /* X error handler */
180 172
181 /* tag.c */
182 Client *getnext(Client *c); /* returns next visible client */ 173 Client *getnext(Client *c); /* returns next visible client */
183 void settag(Client *c, Client *trans); /* sets tag of c */ 174 void settag(Client *c, Client *trans); /* sets tag of c */
184 175
185 /* util.c */
186 void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */ 176 void *emallocz(unsigned int size); /* allocates zero-initialized memory, exits on error */
187 void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */ 177 void eprint(const char *errstr, ...); /* prints errstr and exits with 1 */
188 178
189 /* view.c */
190 void detach(Client *c); /* detaches c from global client list */ 179 void detach(Client *c); /* detaches c from global client list */
191 void dotile(void); /* arranges all windows tiled */ 180 void dotile(void); /* arranges all windows tiled */
192 void domax(void); /* arranges all windows fullscreen */ 181 void domax(void); /* arranges all windows fullscreen */
193 Bool isvisible(Client *c); /* returns True if client is visible */ 182 Bool isvisible(Client *c); /* returns True if client is visible */
194 void restack(void); /* restores z layers of all clients */ 183 void restack(void); /* restores z layers of all clients */
195
196 184
197 void toggleview(void); /* toggle the view */ 185 void toggleview(void); /* toggle the view */
198 void focusnext(void); /* focuses next visible client */ 186 void focusnext(void); /* focuses next visible client */
199 void zoom(void); /* zooms the focused client to master area */ 187 void zoom(void); /* zooms the focused client to master area */
200 void killclient(void); /* kill c nicely */ 188 void killclient(void); /* kill c nicely */
206 void toggletag(void); /* toggles tag of c */ 194 void toggletag(void); /* toggles tag of c */
207 void spawn(const char* cmd); /* forks a new subprocess with cmd */ 195 void spawn(const char* cmd); /* forks a new subprocess with cmd */
208 196
209 197
210 198
199 RULES
200 KEYS
201
202
211 203
212 204
213 205
214 206
215 207
216 208
217 209
218 /* from view.c */ 210 /* from view.c */
219 /* static */ 211
220 212 Client *
221 static Client *
222 nexttiled(Client *c) { 213 nexttiled(Client *c) {
223 for(c = getnext(c); c && c->isfloat; c = getnext(c->next)); 214 for(c = getnext(c); c && c->isfloat; c = getnext(c->next));
224 return c; 215 return c;
225 } 216 }
226 217
227 static void 218 void
228 togglemax(Client *c) { 219 togglemax(Client *c) {
229 XEvent ev; 220 XEvent ev;
230 221
231 if(c->isfixed) 222 if(c->isfixed)
232 return; 223 return;
250 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); 241 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
251 } 242 }
252 243
253 244
254 245
255 void (*arrange)(void) = DEFMODE;
256 246
257 void 247 void
258 detach(Client *c) { 248 detach(Client *c) {
259 if(c->prev) 249 if(c->prev)
260 c->prev->next = c->next; 250 c->prev->next = c->next;
453 clients = c; 443 clients = c;
454 focus(c); 444 focus(c);
455 arrange(); 445 arrange();
456 } 446 }
457 447
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473 /* from util.c */ 448 /* from util.c */
474
475 449
476 void * 450 void *
477 emallocz(unsigned int size) { 451 emallocz(unsigned int size) {
478 void *res = calloc(1, size); 452 void *res = calloc(1, size);
479 453
514 exit(0); 488 exit(0);
515 } 489 }
516 wait(0); 490 wait(0);
517 } 491 }
518 492
519
520
521
522
523
524
525
526
527
528
529
530
531 /* from tag.c */ 493 /* from tag.c */
532
533 /* static */
534 494
535 Client * 495 Client *
536 getnext(Client *c) { 496 getnext(Client *c) {
537 while(c && !isvisible(c)) { 497 while(c && !isvisible(c)) {
538 c = c->next; 498 c = c->next;
579 return; 539 return;
580 sel->tag = !sel->tag; 540 sel->tag = !sel->tag;
581 toggleview(); 541 toggleview();
582 } 542 }
583 543
584
585
586
587
588
589
590
591
592
593
594 /* from event.c */ 544 /* from event.c */
595 /* static */ 545
596 546 void
597
598
599 static void
600 movemouse(Client *c) { 547 movemouse(Client *c) {
601 int x1, y1, ocx, ocy, di; 548 int x1, y1, ocx, ocy, di;
602 unsigned int dui; 549 unsigned int dui;
603 Window dummy; 550 Window dummy;
604 XEvent ev; 551 XEvent ev;
638 break; 585 break;
639 } 586 }
640 } 587 }
641 } 588 }
642 589
643 static void 590 void
644 resizemouse(Client *c) { 591 resizemouse(Client *c) {
645 int ocx, ocy; 592 int ocx, ocy;
646 int nw, nh; 593 int nw, nh;
647 XEvent ev; 594 XEvent ev;
648 595
675 break; 622 break;
676 } 623 }
677 } 624 }
678 } 625 }
679 626
680 static void 627 void
681 buttonpress(XEvent *e) { 628 buttonpress(XEvent *e) {
682 Client *c; 629 Client *c;
683 XButtonPressedEvent *ev = &e->xbutton; 630 XButtonPressedEvent *ev = &e->xbutton;
684 631
685 if(barwin == ev->window) { 632 if(barwin == ev->window) {
697 resizemouse(c); 644 resizemouse(c);
698 } 645 }
699 } 646 }
700 } 647 }
701 648
702 static void 649 void
703 configurerequest(XEvent *e) { 650 configurerequest(XEvent *e) {
704 unsigned long newmask; 651 unsigned long newmask;
705 Client *c; 652 Client *c;
706 XConfigureRequestEvent *ev = &e->xconfigurerequest; 653 XConfigureRequestEvent *ev = &e->xconfigurerequest;
707 XWindowChanges wc; 654 XWindowChanges wc;
746 XConfigureWindow(dpy, ev->window, ev->value_mask, &wc); 693 XConfigureWindow(dpy, ev->window, ev->value_mask, &wc);
747 XSync(dpy, False); 694 XSync(dpy, False);
748 } 695 }
749 } 696 }
750 697
751 static void 698 void
752 destroynotify(XEvent *e) { 699 destroynotify(XEvent *e) {
753 Client *c; 700 Client *c;
754 XDestroyWindowEvent *ev = &e->xdestroywindow; 701 XDestroyWindowEvent *ev = &e->xdestroywindow;
755 702
756 if((c = getclient(ev->window))) 703 if((c = getclient(ev->window)))
757 unmanage(c); 704 unmanage(c);
758 } 705 }
759 706
760 static void 707 void
761 enternotify(XEvent *e) { 708 enternotify(XEvent *e) {
762 Client *c; 709 Client *c;
763 XCrossingEvent *ev = &e->xcrossing; 710 XCrossingEvent *ev = &e->xcrossing;
764 711
765 if(ev->mode != NotifyNormal || ev->detail == NotifyInferior) 712 if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
771 for(c = stack; c && !isvisible(c); c = c->snext); 718 for(c = stack; c && !isvisible(c); c = c->snext);
772 focus(c); 719 focus(c);
773 } 720 }
774 } 721 }
775 722
776 static void 723 void
777 expose(XEvent *e) { 724 expose(XEvent *e) {
778 XExposeEvent *ev = &e->xexpose; 725 XExposeEvent *ev = &e->xexpose;
779 726
780 if(ev->count == 0) { 727 if(ev->count == 0) {
781 if(barwin == ev->window) 728 if(barwin == ev->window)
782 drawstatus(); 729 drawstatus();
783 } 730 }
784 } 731 }
785 732
786 static void 733 void
787 keypress(XEvent *e) { 734 keypress(XEvent *e) {
788 static unsigned int len = sizeof key / sizeof key[0]; 735 static unsigned int len = sizeof key / sizeof key[0];
789 unsigned int i; 736 unsigned int i;
790 KeySym keysym; 737 KeySym keysym;
791 XKeyEvent *ev = &e->xkey; 738 XKeyEvent *ev = &e->xkey;
797 key[i].func(key[i].cmd); 744 key[i].func(key[i].cmd);
798 } 745 }
799 } 746 }
800 } 747 }
801 748
802 static void 749 void
803 leavenotify(XEvent *e) { 750 leavenotify(XEvent *e) {
804 XCrossingEvent *ev = &e->xcrossing; 751 XCrossingEvent *ev = &e->xcrossing;
805 752
806 if((ev->window == root) && !ev->same_screen) { 753 if((ev->window == root) && !ev->same_screen) {
807 selscreen = False; 754 selscreen = False;
808 focus(NULL); 755 focus(NULL);
809 } 756 }
810 } 757 }
811 758
812 static void 759 void
813 mappingnotify(XEvent *e) { 760 mappingnotify(XEvent *e) {
814 XMappingEvent *ev = &e->xmapping; 761 XMappingEvent *ev = &e->xmapping;
815 762
816 XRefreshKeyboardMapping(ev); 763 XRefreshKeyboardMapping(ev);
817 if(ev->request == MappingKeyboard) 764 if(ev->request == MappingKeyboard)
818 grabkeys(); 765 grabkeys();
819 } 766 }
820 767
821 static void 768 void
822 maprequest(XEvent *e) { 769 maprequest(XEvent *e) {
823 static XWindowAttributes wa; 770 static XWindowAttributes wa;
824 XMapRequestEvent *ev = &e->xmaprequest; 771 XMapRequestEvent *ev = &e->xmaprequest;
825 772
826 if(!XGetWindowAttributes(dpy, ev->window, &wa)) 773 if(!XGetWindowAttributes(dpy, ev->window, &wa))
832 } 779 }
833 if(!getclient(ev->window)) 780 if(!getclient(ev->window))
834 manage(ev->window, &wa); 781 manage(ev->window, &wa);
835 } 782 }
836 783
837 static void 784 void
838 propertynotify(XEvent *e) { 785 propertynotify(XEvent *e) {
839 Client *c; 786 Client *c;
840 Window trans; 787 Window trans;
841 XPropertyEvent *ev = &e->xproperty; 788 XPropertyEvent *ev = &e->xproperty;
842 789
860 drawstatus(); 807 drawstatus();
861 } 808 }
862 } 809 }
863 } 810 }
864 811
865 static void 812 void
866 unmapnotify(XEvent *e) { 813 unmapnotify(XEvent *e) {
867 Client *c; 814 Client *c;
868 XUnmapEvent *ev = &e->xunmap; 815 XUnmapEvent *ev = &e->xunmap;
869 816
870 if((c = getclient(ev->window))) 817 if((c = getclient(ev->window)))
916 if(handler[ev.type]) 863 if(handler[ev.type])
917 (handler[ev.type])(&ev); /* call handler */ 864 (handler[ev.type])(&ev); /* call handler */
918 } 865 }
919 } 866 }
920 867
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935 /* from draw.c */ 868 /* from draw.c */
936 /* static */ 869
937 870 unsigned int
938 static unsigned int
939 textnw(const char *text, unsigned int len) { 871 textnw(const char *text, unsigned int len) {
940 XRectangle r; 872 XRectangle r;
941 873
942 if(dc.font.set) { 874 if(dc.font.set) {
943 XmbTextExtents(dc.font.set, text, len, NULL, &r); 875 XmbTextExtents(dc.font.set, text, len, NULL, &r);
944 return r.width; 876 return r.width;
945 } 877 }
946 return XTextWidth(dc.font.xfont, text, len); 878 return XTextWidth(dc.font.xfont, text, len);
947 } 879 }
948 880
949 static void 881 void
950 drawtext(const char *text, unsigned long col[ColLast]) { 882 drawtext(const char *text, unsigned long col[ColLast]) {
951 int x, y, w, h; 883 int x, y, w, h;
952 static char buf[256]; 884 static char buf[256];
953 unsigned int len, olen; 885 unsigned int len, olen;
954 XGCValues gcv; 886 XGCValues gcv;
989 XChangeGC(dpy, dc.gc, GCForeground | GCFont, &gcv); 921 XChangeGC(dpy, dc.gc, GCForeground | GCFont, &gcv);
990 XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len); 922 XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
991 } 923 }
992 } 924 }
993 925
994
995
996 void 926 void
997 drawstatus(void) { 927 drawstatus(void) {
998 int x; 928 int x;
999 unsigned long black[ColLast]; 929 unsigned long black[ColLast];
1000 black[ColBG] = getcolor("#000000"); 930 black[ColBG] = getcolor("#000000");
1094 unsigned int 1024 unsigned int
1095 textw(const char *text) { 1025 textw(const char *text) {
1096 return textnw(text, strlen(text)) + dc.font.height; 1026 return textnw(text, strlen(text)) + dc.font.height;
1097 } 1027 }
1098 1028
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109 /* from client.c */ 1029 /* from client.c */
1110 /* static */ 1030
1111 1031 void
1112 static void
1113 detachstack(Client *c) { 1032 detachstack(Client *c) {
1114 Client **tc; 1033 Client **tc;
1115 for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext); 1034 for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext);
1116 *tc = c->snext; 1035 *tc = c->snext;
1117 } 1036 }
1118 1037
1119 static void 1038 void
1120 grabbuttons(Client *c, Bool focused) { 1039 grabbuttons(Client *c, Bool focused) {
1121 XUngrabButton(dpy, AnyButton, AnyModifier, c->win); 1040 XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
1122 1041
1123 if(focused) { 1042 if(focused) {
1124 XGrabButton(dpy, Button1, MODKEY, c->win, False, BUTTONMASK, 1043 XGrabButton(dpy, Button1, MODKEY, c->win, False, BUTTONMASK,
1151 XGrabButton(dpy, AnyButton, AnyModifier, c->win, False, BUTTONMASK, 1070 XGrabButton(dpy, AnyButton, AnyModifier, c->win, False, BUTTONMASK,
1152 GrabModeAsync, GrabModeSync, None, None); 1071 GrabModeAsync, GrabModeSync, None, None);
1153 } 1072 }
1154 } 1073 }
1155 1074
1156 static void 1075 void
1157 setclientstate(Client *c, long state) { 1076 setclientstate(Client *c, long state) {
1158 long data[] = {state, None}; 1077 long data[] = {state, None};
1159 XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32, 1078 XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32,
1160 PropModeReplace, (unsigned char *)data, 2); 1079 PropModeReplace, (unsigned char *)data, 2);
1161 } 1080 }
1162 1081
1163 static int 1082 int
1164 xerrordummy(Display *dsply, XErrorEvent *ee) { 1083 xerrordummy(Display *dsply, XErrorEvent *ee) {
1165 return 0; 1084 return 0;
1166 } 1085 }
1167
1168
1169 1086
1170 void 1087 void
1171 configure(Client *c) { 1088 configure(Client *c) {
1172 XEvent synev; 1089 XEvent synev;
1173 1090
1451 XSetErrorHandler(xerror); 1368 XSetErrorHandler(xerror);
1452 XUngrabServer(dpy); 1369 XUngrabServer(dpy);
1453 arrange(); 1370 arrange();
1454 } 1371 }
1455 1372
1456 1373 /* from main.c */
1457 1374
1458 1375 void
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474 /* static */
1475
1476
1477 static void
1478 cleanup(void) { 1376 cleanup(void) {
1479 close(STDIN_FILENO); 1377 close(STDIN_FILENO);
1480 while(stack) { 1378 while(stack) {
1481 resize(stack, True); 1379 resize(stack, True);
1482 unmanage(stack); 1380 unmanage(stack);
1494 XFreeCursor(dpy, cursor[CurMove]); 1392 XFreeCursor(dpy, cursor[CurMove]);
1495 XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); 1393 XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
1496 XSync(dpy, False); 1394 XSync(dpy, False);
1497 } 1395 }
1498 1396
1499 static void 1397 void
1500 scan(void) { 1398 scan(void) {
1501 unsigned int i, num; 1399 unsigned int i, num;
1502 Window *wins, d1, d2; 1400 Window *wins, d1, d2;
1503 XWindowAttributes wa; 1401 XWindowAttributes wa;
1504 1402
1515 } 1413 }
1516 if(wins) 1414 if(wins)
1517 XFree(wins); 1415 XFree(wins);
1518 } 1416 }
1519 1417
1520 static void 1418 void
1521 setup(void) { 1419 setup(void) {
1522 int i, j; 1420 int i, j;
1523 unsigned int mask; 1421 unsigned int mask;
1524 Window w; 1422 Window w;
1525 XModifierKeymap *modmap; 1423 XModifierKeymap *modmap;
1563 /* geometry */ 1461 /* geometry */
1564 sx = sy = 0; 1462 sx = sy = 0;
1565 sw = DisplayWidth(dpy, screen); 1463 sw = DisplayWidth(dpy, screen);
1566 sh = DisplayHeight(dpy, screen); 1464 sh = DisplayHeight(dpy, screen);
1567 nmaster = NMASTER; 1465 nmaster = NMASTER;
1466 arrange = DEFMODE;
1568 /* bar */ 1467 /* bar */
1569 dc.h = bh = dc.font.height + 2; 1468 dc.h = bh = dc.font.height + 2;
1570 wa.override_redirect = 1; 1469 wa.override_redirect = 1;
1571 wa.background_pixmap = ParentRelative; 1470 wa.background_pixmap = ParentRelative;
1572 wa.event_mask = ButtonPressMask | ExposureMask; 1471 wa.event_mask = ButtonPressMask | ExposureMask;
1591 1490
1592 /* 1491 /*
1593 * Startup Error handler to check if another window manager 1492 * Startup Error handler to check if another window manager
1594 * is already running. 1493 * is already running.
1595 */ 1494 */
1596 static int 1495 int
1597 xerrorstart(Display *dsply, XErrorEvent *ee) { 1496 xerrorstart(Display *dsply, XErrorEvent *ee) {
1598 otherwm = True; 1497 otherwm = True;
1599 return -1; 1498 return -1;
1600 } 1499 }
1601
1602
1603 1500
1604 void 1501 void
1605 sendevent(Window w, Atom a, long value) { 1502 sendevent(Window w, Atom a, long value) {
1606 XEvent e; 1503 XEvent e;
1607 1504