about summary refs log tree commit diff stats
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c112
1 files changed, 56 insertions, 56 deletions
diff --git a/main.c b/main.c
index a1cf245..39172ee 100644
--- a/main.c
+++ b/main.c
@@ -43,16 +43,16 @@ DC dc = {0};
 Client *clients = NULL;
 Client *sel = NULL;
 
-static Bool other_wm_running;
+static Bool otherwm;
 static const char version[] =
 	"dwm-" VERSION ", (C)opyright MMVI Anselm R. Garbe\n";
-static int (*x_xerror) (Display *, XErrorEvent *);
+static int (*xerrorxlib)(Display *, XErrorEvent *);
 
 static void
-usage() {	error("usage: dwm [-v]\n"); }
+usage() {	eprint("usage: dwm [-v]\n"); }
 
 static void
-scan_wins()
+scan()
 {
 	unsigned int i, num;
 	Window *wins;
@@ -73,6 +73,22 @@ scan_wins()
 		XFree(wins);
 }
 
+static void
+cleanup()
+{
+	while(sel) {
+		resize(sel, True);
+		unmanage(sel);
+	}
+	XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
+}
+
+void
+quit(Arg *arg)
+{
+	running = False;
+}
+
 static int
 win_property(Window w, Atom a, Atom t, long l, unsigned char **prop)
 {
@@ -94,7 +110,7 @@ win_property(Window w, Atom a, Atom t, long l, unsigned char **prop)
 }
 
 int
-proto(Window w)
+getproto(Window w)
 {
 	unsigned char *protocols;
 	long res;
@@ -129,58 +145,42 @@ sendevent(Window w, Atom a, long value)
 }
 
 /*
- * There's no way to check accesses to destroyed windows, thus
- * those cases are ignored (especially on UnmapNotify's).
- * Other types of errors call Xlib's default error handler, which
- * calls exit().
- */
-int
-xerror(Display *dpy, XErrorEvent *error)
-{
-	if(error->error_code == BadWindow
-			|| (error->request_code == X_SetInputFocus
-				&& error->error_code == BadMatch)
-			|| (error->request_code == X_PolyText8
-				&& error->error_code == BadDrawable)
-			|| (error->request_code == X_PolyFillRectangle
-				&& error->error_code == BadDrawable)
-			|| (error->request_code == X_PolySegment
-				&& error->error_code == BadDrawable)
-			|| (error->request_code == X_ConfigureWindow
-				&& error->error_code == BadMatch)
-			|| (error->request_code == X_GrabKey
-				&& error->error_code == BadAccess))
-		return 0;
-	fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n",
-			error->request_code, error->error_code);
-	return x_xerror(dpy, error); /* may call exit() */
-}
-
-/*
  * Startup Error handler to check if another window manager
  * is already running.
  */
 static int
-startup_xerror(Display *dpy, XErrorEvent *error)
+xerrorstart(Display *dsply, XErrorEvent *ee)
 {
-	other_wm_running = True;
+	otherwm = True;
 	return -1;
 }
 
-static void
-cleanup()
-{
-	while(sel) {
-		resize(sel, True);
-		unmanage(sel);
-	}
-	XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
-}
-
-void
-quit(Arg *arg)
+/*
+ * There's no way to check accesses to destroyed windows, thus
+ * those cases are ignored (especially on UnmapNotify's).
+ * Other types of errors call Xlib's default error handler, which
+ * calls exit().
+ */
+int
+xerror(Display *dpy, XErrorEvent *ee)
 {
-	running = False;
+	if(ee->error_code == BadWindow
+			|| (ee->request_code == X_SetInputFocus
+				&& ee->error_code == BadMatch)
+			|| (ee->request_code == X_PolyText8
+				&& ee->error_code == BadDrawable)
+			|| (ee->request_code == X_PolyFillRectangle
+				&& ee->error_code == BadDrawable)
+			|| (ee->request_code == X_PolySegment
+				&& ee->error_code == BadDrawable)
+			|| (ee->request_code == X_ConfigureWindow
+				&& ee->error_code == BadMatch)
+			|| (ee->request_code == X_GrabKey
+				&& ee->error_code == BadAccess))
+		return 0;
+	fprintf(stderr, "dwm: fatal error: request code=%d, error code=%d\n",
+			ee->request_code, ee->error_code);
+	return xerrorxlib(dpy, ee); /* may call exit() */
 }
 
 int
@@ -208,23 +208,23 @@ main(int argc, char *argv[])
 
 	dpy = XOpenDisplay(0);
 	if(!dpy)
-		error("dwm: cannot connect X server\n");
+		eprint("dwm: cannot connect X server\n");
 
 	screen = DefaultScreen(dpy);
 	root = RootWindow(dpy, screen);
 
 	/* check if another WM is already running */
-	other_wm_running = False;
-	XSetErrorHandler(startup_xerror);
+	otherwm = False;
+	XSetErrorHandler(xerrorstart);
 	/* this causes an error if some other WM is running */
 	XSelectInput(dpy, root, SubstructureRedirectMask);
 	XFlush(dpy);
 
-	if(other_wm_running)
-		error("dwm: another window manager is already running\n");
+	if(otherwm)
+		eprint("dwm: another window manager is already running\n");
 
 	XSetErrorHandler(0);
-	x_xerror = XSetErrorHandler(xerror);
+	xerrorxlib = XSetErrorHandler(xerror);
 
 	/* init atoms */
 	wm_atom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
@@ -278,7 +278,7 @@ main(int argc, char *argv[])
 	XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
 
 	strcpy(stext, "dwm-"VERSION);
-	scan_wins();
+	scan();
 
 	/* main event loop, reads status text from stdin as well */
 Mainloop:
@@ -292,7 +292,7 @@ Mainloop:
 		if(i == -1 && errno == EINTR)
 			continue;
 		if(i < 0)
-			error("select failed\n");
+			eprint("select failed\n");
 		else if(i > 0) {
 			if(FD_ISSET(ConnectionNumber(dpy), &rd)) {
 				while(XPending(dpy)) {
a384c26e2217ef5908b'>7a583220 ^
33352536 ^

ee9a9237 ^
33352536 ^




6030d7e2 ^





33352536 ^
9d27e966 ^
33352536 ^

6030d7e2 ^

33352536 ^



6030d7e2 ^
33352536 ^
261b1b80 ^
33352536 ^

261b1b80 ^
33352536 ^




6030d7e2 ^
33352536 ^
cf02c20b ^
ee9a9237 ^
33352536 ^

7a583220 ^
33352536 ^

6030d7e2 ^
f3612481 ^
71eb22a5 ^
7a583220 ^
33352536 ^

80f53f4a ^


1639687b ^
33352536 ^
80f53f4a ^
261b1b80 ^
6030d7e2 ^
33352536 ^


1639687b ^
33352536 ^
80f53f4a ^








6030d7e2 ^
f3612481 ^

7a583220 ^
33352536 ^
6030d7e2 ^
33352536 ^
6030d7e2 ^
33352536 ^


6030d7e2 ^


71eb22a5 ^
64e8faba ^

33352536 ^
6030d7e2 ^

ee9a9237 ^
6030d7e2 ^
33352536 ^
ee9a9237 ^
6030d7e2 ^
ee9a9237 ^
33352536 ^
9d27e966 ^
ee9a9237 ^
33352536 ^
ee9a9237 ^
6030d7e2 ^
33352536 ^
93be389b ^
33352536 ^
6030d7e2 ^
328a8e11 ^
ee9a9237 ^
6030d7e2 ^

9d27e966 ^
33352536 ^
ee9a9237 ^
6030d7e2 ^
ee9a9237 ^
33352536 ^
7a583220 ^
33352536 ^


6030d7e2 ^
f3612481 ^
71eb22a5 ^
7a583220 ^
33352536 ^

6030d7e2 ^
ee9a9237 ^
33352536 ^
ee9a9237 ^
6030d7e2 ^
9d27e966 ^
cf02c20b ^
ee9a9237 ^
33352536 ^
6030d7e2 ^
ee9a9237 ^
6030d7e2 ^


ee9a9237 ^
6030d7e2 ^
ee9a9237 ^
33352536 ^
7a583220 ^
33352536 ^

6030d7e2 ^
f3612481 ^
71eb22a5 ^
7a583220 ^
33352536 ^

9d27e966 ^
ee9a9237 ^
6030d7e2 ^
33352536 ^
ee9a9237 ^
6030d7e2 ^
9d27e966 ^
cf02c20b ^
7a583220 ^
33352536 ^

6030d7e2 ^
6ee77ba7 ^
ee9a9237 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214