comparison main.c @ 76:4bd49f404f10

proceeded with cleaning up, sorting functions, etc
author Anselm R. Garbe <garbeam@wmii.de>
date Sat, 15 Jul 2006 17:00:56 +0200
parents f08271b7cb20
children 38c8f7f7d401
comparison
equal deleted inserted replaced
75:f08271b7cb20 76:4bd49f404f10
1 /* 1 /*
2 * (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. 3 * See LICENSE file for license details.
4 */ 4 */
5 5
6 #include "dwm.h"
7
6 #include <errno.h> 8 #include <errno.h>
7 #include <stdarg.h>
8 #include <stdio.h> 9 #include <stdio.h>
9 #include <stdlib.h> 10 #include <stdlib.h>
10 #include <string.h> 11 #include <string.h>
11 #include <unistd.h> 12 #include <unistd.h>
12
13 #include <X11/cursorfont.h> 13 #include <X11/cursorfont.h>
14 #include <X11/Xatom.h> 14 #include <X11/Xatom.h>
15 #include <X11/Xproto.h> 15 #include <X11/Xproto.h>
16 16
17 #include "dwm.h"
18
19 /********** CUSTOMIZE **********/
20
21 char *tags[TLast] = {
22 [Tscratch] = "scratch",
23 [Tdev] = "dev",
24 [Twww] = "www",
25 [Twork] = "work",
26 };
27
28 /********** CUSTOMIZE **********/
29
30 /* X structs */
31 Display *dpy; 17 Display *dpy;
32 Window root, barwin; 18 Window root, barwin;
33 Atom wm_atom[WMLast], net_atom[NetLast]; 19 Atom wm_atom[WMLast], net_atom[NetLast];
34 Cursor cursor[CurLast]; 20 Cursor cursor[CurLast];
35 Bool running = True; 21 Bool running = True;
46 static Bool otherwm; 32 static Bool otherwm;
47 static const char version[] = 33 static const char version[] =
48 "dwm-" VERSION ", (C)opyright MMVI Anselm R. Garbe\n"; 34 "dwm-" VERSION ", (C)opyright MMVI Anselm R. Garbe\n";
49 static int (*xerrorxlib)(Display *, XErrorEvent *); 35 static int (*xerrorxlib)(Display *, XErrorEvent *);
50 36
37 /* static functions */
38
51 static void 39 static void
52 usage() { eprint("usage: dwm [-v]\n"); } 40 cleanup()
41 {
42 while(sel) {
43 resize(sel, True);
44 unmanage(sel);
45 }
46 XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
47 }
53 48
54 static void 49 static void
55 scan() 50 scan()
56 { 51 {
57 unsigned int i, num; 52 unsigned int i, num;
71 } 66 }
72 if(wins) 67 if(wins)
73 XFree(wins); 68 XFree(wins);
74 } 69 }
75 70
76 static void
77 cleanup()
78 {
79 while(sel) {
80 resize(sel, True);
81 unmanage(sel);
82 }
83 XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
84 }
85
86 void
87 quit(Arg *arg)
88 {
89 running = False;
90 }
91
92 static int 71 static int
93 win_property(Window w, Atom a, Atom t, long l, unsigned char **prop) 72 win_property(Window w, Atom a, Atom t, long l, unsigned char **prop)
94 { 73 {
95 Atom real; 74 Atom real;
96 int format; 75 int format;
106 if(res == 0) { 85 if(res == 0) {
107 free((void *) *prop); 86 free((void *) *prop);
108 } 87 }
109 return res; 88 return res;
110 } 89 }
90
91 /*
92 * Startup Error handler to check if another window manager
93 * is already running.
94 */
95 static int
96 xerrorstart(Display *dsply, XErrorEvent *ee)
97 {
98 otherwm = True;
99 return -1;
100 }
101
102 /* extern functions */
111 103
112 int 104 int
113 getproto(Window w) 105 getproto(Window w)
114 { 106 {
115 unsigned char *protocols; 107 unsigned char *protocols;
142 e.xclient.data.l[1] = CurrentTime; 134 e.xclient.data.l[1] = CurrentTime;
143 XSendEvent(dpy, w, False, NoEventMask, &e); 135 XSendEvent(dpy, w, False, NoEventMask, &e);
144 XFlush(dpy); 136 XFlush(dpy);
145 } 137 }
146 138
147 /* 139 void
148 * Startup Error handler to check if another window manager 140 quit(Arg *arg)
149 * is already running. 141 {
150 */ 142 running = False;
151 static int
152 xerrorstart(Display *dsply, XErrorEvent *ee)
153 {
154 otherwm = True;
155 return -1;
156 } 143 }
157 144
158 /* 145 /*
159 * There's no way to check accesses to destroyed windows, thus 146 * There's no way to check accesses to destroyed windows, thus
160 * those cases are ignored (especially on UnmapNotify's). 147 * those cases are ignored (especially on UnmapNotify's).
199 case 'v': 186 case 'v':
200 fprintf(stdout, "%s", version); 187 fprintf(stdout, "%s", version);
201 exit(0); 188 exit(0);
202 break; 189 break;
203 default: 190 default:
204 usage(); 191 eprint("usage: dwm [-v]\n");
205 break; 192 break;
206 } 193 }
207 } 194 }
208 195
209 dpy = XOpenDisplay(0); 196 dpy = XOpenDisplay(0);