about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--client.c4
-rw-r--r--draw.c104
-rw-r--r--dwm.h4
-rw-r--r--event.c141
-rw-r--r--main.c25
5 files changed, 136 insertions, 142 deletions
diff --git a/client.c b/client.c
index 1e3216e..92b26a2 100644
--- a/client.c
+++ b/client.c
@@ -178,7 +178,7 @@ killclient(Arg *arg)
 	if(!sel)
 		return;
 	if(sel->proto & WM_PROTOCOL_DELWIN)
-		sendevent(sel->win, wm_atom[WMProtocols], wm_atom[WMDelete]);
+		sendevent(sel->win, wmatom[WMProtocols], wmatom[WMDelete]);
 	else
 		XKillClient(dpy, sel->win);
 }
@@ -353,7 +353,7 @@ settitle(Client *c)
 
 	name.nitems = 0;
 	c->name[0] = 0;
-	XGetTextProperty(dpy, c->win, &name, net_atom[NetWMName]);
+	XGetTextProperty(dpy, c->win, &name, netatom[NetWMName]);
 	if(!name.nitems)
 		XGetWMName(dpy, c->win, &name);
 	if(!name.nitems)
diff --git a/draw.c b/draw.c
index 9743ec1..1c6613f 100644
--- a/draw.c
+++ b/draw.c
@@ -29,51 +29,18 @@ drawborder(void)
 	XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious);
 }
 
-/* extern functions */
-
-void
-drawall()
-{
-	Client *c;
-
-	for(c = clients; c; c = getnext(c->next))
-		drawtitle(c);
-	drawstatus();
-}
-
-void
-drawstatus()
+static unsigned int
+textnw(char *text, unsigned int len)
 {
-	int i;
-	Bool istile = arrange == dotile;
-
-	dc.x = dc.y = 0;
-	dc.w = bw;
-	drawtext(NULL, !istile, False);
-
-	dc.w = 0;
-	for(i = 0; i < TLast; i++) {
-		dc.x += dc.w;
-		dc.w = textw(tags[i]);
-		if(istile)
-			drawtext(tags[i], (i == tsel), True);
-		else
-			drawtext(tags[i], (i != tsel), True);
-	}
-	if(sel) {
-		dc.x += dc.w;
-		dc.w = textw(sel->name);
-		drawtext(sel->name, istile, True);
+	XRectangle r;
+	if(dc.font.set) {
+		XmbTextExtents(dc.font.set, text, len, NULL, &r);
+		return r.width;
 	}
-	dc.w = textw(stext);
-	dc.x = bx + bw - dc.w;
-	drawtext(stext, !istile, False);
-
-	XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
-	XFlush(dpy);
+	return XTextWidth(dc.font.xfont, text, len);
 }
 
-void
+static void
 drawtext(const char *text, Bool invert, Bool border)
 {
 	int x, y, w, h;
@@ -123,6 +90,50 @@ drawtext(const char *text, Bool invert, Bool border)
 	}
 }
 
+/* extern functions */
+
+void
+drawall()
+{
+	Client *c;
+
+	for(c = clients; c; c = getnext(c->next))
+		drawtitle(c);
+	drawstatus();
+}
+
+void
+drawstatus()
+{
+	int i;
+	Bool istile = arrange == dotile;
+
+	dc.x = dc.y = 0;
+	dc.w = bw;
+	drawtext(NULL, !istile, False);
+
+	dc.w = 0;
+	for(i = 0; i < TLast; i++) {
+		dc.x += dc.w;
+		dc.w = textw(tags[i]);
+		if(istile)
+			drawtext(tags[i], (i == tsel), True);
+		else
+			drawtext(tags[i], (i != tsel), True);
+	}
+	if(sel) {
+		dc.x += dc.w;
+		dc.w = textw(sel->name);
+		drawtext(sel->name, istile, True);
+	}
+	dc.w = textw(stext);
+	dc.x = bx + bw - dc.w;
+	drawtext(stext, !istile, False);
+
+	XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
+	XFlush(dpy);
+}
+
 void
 drawtitle(Client *c)
 {
@@ -219,17 +230,6 @@ setfont(const char *fontstr)
 }
 
 unsigned int
-textnw(char *text, unsigned int len)
-{
-	XRectangle r;
-	if(dc.font.set) {
-		XmbTextExtents(dc.font.set, text, len, NULL, &r);
-		return r.width;
-	}
-	return XTextWidth(dc.font.xfont, text, len);
-}
-
-unsigned int
 textw(char *text)
 {
 	return textnw(text, strlen(text)) + dc.font.height;
diff --git a/dwm.h b/dwm.h
index e95633b..e7ddaa7 100644
--- a/dwm.h
+++ b/dwm.h
@@ -89,7 +89,7 @@ struct Key {
 
 extern Display *dpy;
 extern Window root, barwin;
-extern Atom wm_atom[WMLast], net_atom[NetLast];
+extern Atom wmatom[WMLast], netatom[NetLast];
 extern Cursor cursor[CurLast];
 extern Bool running, issel;
 extern void (*handler[LASTEvent])(XEvent *);
@@ -124,11 +124,9 @@ extern void zoom(Arg *arg);
 /* draw.c */
 extern void drawall();
 extern void drawstatus();
-extern void drawtext(const char *text, Bool invert, Bool border);
 extern void drawtitle(Client *c);
 extern unsigned long getcolor(const char *colstr);
 extern void setfont(const char *fontstr);
-extern unsigned int textnw(char *text, unsigned int len);
 extern unsigned int textw(char *text);
 
 /* event.c */
diff --git a/event.c b/event.c
index 2d8a728..798cb3c 100644
--- a/event.c
+++ b/event.c
@@ -51,8 +51,73 @@ Key key[] = {
 
 /* static functions */
 
-static void movemouse(Client *c);
-static void resizemouse(Client *c);
+static void
+movemouse(Client *c)
+{
+	XEvent ev;
+	int x1, y1, ocx, ocy, di;
+	unsigned int dui;
+	Window dummy;
+
+	ocx = c->x;
+	ocy = c->y;
+	if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
+				None, cursor[CurMove], CurrentTime) != GrabSuccess)
+		return;
+	XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
+	for(;;) {
+		XMaskEvent(dpy, MouseMask | ExposureMask, &ev);
+		switch (ev.type) {
+		default: break;
+		case Expose:
+			handler[Expose](&ev);
+			break;
+		case MotionNotify:
+			XFlush(dpy);
+			c->x = ocx + (ev.xmotion.x - x1);
+			c->y = ocy + (ev.xmotion.y - y1);
+			resize(c, False);
+			break;
+		case ButtonRelease:
+			XUngrabPointer(dpy, CurrentTime);
+			return;
+		}
+	}
+}
+
+static void
+resizemouse(Client *c)
+{
+	XEvent ev;
+	int ocx, ocy;
+
+	ocx = c->x;
+	ocy = c->y;
+	if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
+				None, cursor[CurResize], CurrentTime) != GrabSuccess)
+		return;
+	XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
+	for(;;) {
+		XMaskEvent(dpy, MouseMask | ExposureMask, &ev);
+		switch(ev.type) {
+		default: break;
+		case Expose:
+			handler[Expose](&ev);
+			break;
+		case MotionNotify:
+			XFlush(dpy);
+			c->w = abs(ocx - ev.xmotion.x);
+			c->h = abs(ocy - ev.xmotion.y);
+			c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w;
+			c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h;
+			resize(c, True);
+			break;
+		case ButtonRelease:
+			XUngrabPointer(dpy, CurrentTime);
+			return;
+		}
+	}
+}
 
 static void
 buttonpress(XEvent *e)
@@ -214,40 +279,6 @@ maprequest(XEvent *e)
 }
 
 static void
-movemouse(Client *c)
-{
-	XEvent ev;
-	int x1, y1, ocx, ocy, di;
-	unsigned int dui;
-	Window dummy;
-
-	ocx = c->x;
-	ocy = c->y;
-	if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
-				None, cursor[CurMove], CurrentTime) != GrabSuccess)
-		return;
-	XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
-	for(;;) {
-		XMaskEvent(dpy, MouseMask | ExposureMask, &ev);
-		switch (ev.type) {
-		default: break;
-		case Expose:
-			handler[Expose](&ev);
-			break;
-		case MotionNotify:
-			XFlush(dpy);
-			c->x = ocx + (ev.xmotion.x - x1);
-			c->y = ocy + (ev.xmotion.y - y1);
-			resize(c, False);
-			break;
-		case ButtonRelease:
-			XUngrabPointer(dpy, CurrentTime);
-			return;
-		}
-	}
-}
-
-static void
 propertynotify(XEvent *e)
 {
 	XPropertyEvent *ev = &e->xproperty;
@@ -258,7 +289,7 @@ propertynotify(XEvent *e)
 		return; /* ignore */
 
 	if((c = getclient(ev->window))) {
-		if(ev->atom == wm_atom[WMProtocols]) {
+		if(ev->atom == wmatom[WMProtocols]) {
 			c->proto = getproto(c->win);
 			return;
 		}
@@ -273,7 +304,7 @@ propertynotify(XEvent *e)
 				setsize(c);
 				break;
 		}
-		if(ev->atom == XA_WM_NAME || ev->atom == net_atom[NetWMName]) {
+		if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
 			settitle(c);
 			drawtitle(c);
 		}
@@ -281,40 +312,6 @@ propertynotify(XEvent *e)
 }
 
 static void
-resizemouse(Client *c)
-{
-	XEvent ev;
-	int ocx, ocy;
-
-	ocx = c->x;
-	ocy = c->y;
-	if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
-				None, cursor[CurResize], CurrentTime) != GrabSuccess)
-		return;
-	XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
-	for(;;) {
-		XMaskEvent(dpy, MouseMask | ExposureMask, &ev);
-		switch(ev.type) {
-		default: break;
-		case Expose:
-			handler[Expose](&ev);
-			break;
-		case MotionNotify:
-			XFlush(dpy);
-			c->w = abs(ocx - ev.xmotion.x);
-			c->h = abs(ocy - ev.xmotion.y);
-			c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w;
-			c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h;
-			resize(c, True);
-			break;
-		case ButtonRelease:
-			XUngrabPointer(dpy, CurrentTime);
-			return;
-		}
-	}
-}
-
-static void
 unmapnotify(XEvent *e)
 {
 	Client *c;
diff --git a/main.c b/main.c
index b96157c..935d860 100644
--- a/main.c
+++ b/main.c
@@ -16,10 +16,10 @@
 
 Display *dpy;
 Window root, barwin;
-Atom wm_atom[WMLast], net_atom[NetLast];
+Atom wmatom[WMLast], netatom[NetLast];
 Cursor cursor[CurLast];
 Bool running = True;
-Bool issel;
+Bool issel = True;
 
 int tsel = Tdev; /* default tag */
 int screen, sx, sy, sw, sh, bx, by, bw, bh, mw;
@@ -30,8 +30,6 @@ Client *clients = NULL;
 Client *sel = NULL;
 
 static Bool otherwm;
-static const char version[] =
-	"dwm-" VERSION ", (C)opyright MMVI Anselm R. Garbe\n";
 static int (*xerrorxlib)(Display *, XErrorEvent *);
 
 /* static functions */
@@ -109,12 +107,12 @@ getproto(Window w)
 	int protos = 0;
 	int i;
 
-	res = win_property(w, wm_atom[WMProtocols], XA_ATOM, 20L, &protocols);
+	res = win_property(w, wmatom[WMProtocols], XA_ATOM, 20L, &protocols);
 	if(res <= 0) {
 		return protos;
 	}
 	for(i = 0; i < res; i++) {
-		if(protocols[i] == wm_atom[WMDelete])
+		if(protocols[i] == wmatom[WMDelete])
 			protos |= WM_PROTOCOL_DELWIN;
 	}
 	free((char *) protocols);
@@ -184,7 +182,8 @@ main(int argc, char *argv[])
 	for(i = 1; (i < argc) && (argv[i][0] == '-'); i++) {
 		switch (argv[i][1]) {
 		case 'v':
-			fprintf(stdout, "%s", version);
+			fprintf(stdout, "%s",
+					"dwm-"VERSION", (C)opyright MMVI Anselm R. Garbe\n");
 			exit(0);
 			break;
 		default:
@@ -214,12 +213,12 @@ main(int argc, char *argv[])
 	xerrorxlib = XSetErrorHandler(xerror);
 
 	/* init atoms */
-	wm_atom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
-	wm_atom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
-	net_atom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
-	net_atom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
-	XChangeProperty(dpy, root, net_atom[NetSupported], XA_ATOM, 32,
-			PropModeReplace, (unsigned char *) net_atom, NetLast);
+	wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
+	wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
+	netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
+	netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
+	XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
+			PropModeReplace, (unsigned char *) netatom, NetLast);
 
 	/* init cursors */
 	cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
pre>
3369875c ^
fc52705f ^

7fb3fccb ^

08cf048f ^
7fb3fccb ^








fc52705f ^
1d0a623a ^
1b76245c ^
fc52705f ^
66b97b4d ^
5e21a9f6 ^
1f59be84 ^
555d95c1 ^
2589de99 ^
1f59be84 ^
9c30b383 ^


343bc535 ^
1f59be84 ^

7a9b05fa ^
7bba6e7b ^

ea542d0a ^
9f95c745 ^
78c50205 ^
9f95c745 ^
7cc045d9 ^

78c50205 ^
65c905fe ^
48e40252 ^

7cc045d9 ^



acc4792d ^
7cc045d9 ^








a796831f ^



3369875c ^





















88be3dbc ^
1ead3562 ^
e3fa6cc7 ^
3d6c13dc ^
acc4792d ^
c51043ab ^
23fd54f1 ^
1ead3562 ^
23fd54f1 ^

acc4792d ^
23fd54f1 ^
3369875c ^
1ead3562 ^
fc52705f ^
3369875c ^
fc52705f ^
acc4792d ^
fc52705f ^
c51043ab ^
1ead3562 ^
c51043ab ^

4f10b93a ^
35457609 ^
5683823a ^
acc4792d ^

2f677225 ^

1ead3562 ^
2f677225 ^


acc4792d ^
7fb3fccb ^

1ead3562 ^
7fb3fccb ^




acc4792d ^
7fb3fccb ^

1ead3562 ^
7fb3fccb ^

acc4792d ^
2589de99 ^


d63cddea ^

2589de99 ^
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
215
216
217
218
219
220
221
222
223
224
225