about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--README1
-rw-r--r--client.c12
-rw-r--r--config.h4
-rw-r--r--event.c87
-rw-r--r--font.c4
-rw-r--r--key.c17
-rw-r--r--menu.c2
-rw-r--r--util.c13
-rw-r--r--wm.c50
-rw-r--r--wm.h10
10 files changed, 59 insertions, 141 deletions
diff --git a/README b/README
index c766f1b..814549e 100644
--- a/README
+++ b/README
@@ -2,6 +2,7 @@ gridwm
 ------
 
 gridwm is an automatic X11 window manager which arranges all windows in a grid.
+One goal is not to exceed 3kSLOC.
 
 
 Requirements
diff --git a/client.c b/client.c
index 1e693f7..62f4d98 100644
--- a/client.c
+++ b/client.c
@@ -51,7 +51,6 @@ create_client(Window w, XWindowAttributes *wa)
 	c->r[RFloat].height = wa->height;
 	c->border = wa->border_width;
 	XSetWindowBorderWidth(dpy, c->win, 0);
-	c->proto = win_proto(c->win);
 	XGetTransientForHint(dpy, c->win, &c->trans);
 	if(!XGetWMNormalHints(dpy, c->win, &c->size, &msize) || !c->size.flags)
 		c->size.flags = PSize;
@@ -59,7 +58,6 @@ create_client(Window w, XWindowAttributes *wa)
 		(c->size.flags & PMinSize && c->size.flags & PMaxSize
 		 && c->size.min_width == c->size.max_width
 		 && c->size.min_height == c->size.max_height);
-	XAddToSaveSet(dpy, c->win);
 	update_client_name(c);
 	twa.override_redirect = 1;
 	twa.background_pixmap = ParentRelative;
@@ -87,3 +85,13 @@ manage(Client *c)
 	XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
 	XFlush(dpy);
 }
+
+Client *
+getclient(Window w)
+{
+	Client *c;
+	for(c = clients; c; c = c->next)
+		if(c->win == w)
+			return c;
+	return NULL;
+}
diff --git a/config.h b/config.h
index d37034d..2f73716 100644
--- a/config.h
+++ b/config.h
@@ -10,4 +10,6 @@
 #define STATUSCMD	"echo -n `date` `uptime | sed 's/.*://; s/,//g'`" \
 					" `acpi | awk '{print $4}' | sed 's/,//'`"
 #define KEYS		\
-	{ Mod1Mask, XK_Return, run, "xterm -u8 -bg black -fg white -fn -*-terminus-medium-*-*-*-14-*-*-*-*-*-iso10646-*" },
+	{ Mod1Mask, XK_Return, run, "xterm -u8 -bg black -fg white -fn '-*-terminus-medium-*-*-*-14-*-*-*-*-*-iso10646-*'" }, \
+	{ Mod1Mask | ShiftMask, XK_q, quit, NULL},
+
diff --git a/event.c b/event.c
index b31c94f..909012d 100644
--- a/event.c
+++ b/event.c
@@ -16,7 +16,6 @@ static void destroynotify(XEvent *e);
 static void enternotify(XEvent *e);
 static void leavenotify(XEvent *e);
 static void expose(XEvent *e);
-static void keypress(XEvent *e);
 static void keymapnotify(XEvent *e);
 static void maprequest(XEvent *e);
 static void propertynotify(XEvent *e);
@@ -47,80 +46,36 @@ flush_masked_events(long even_mask)
 static void
 configurerequest(XEvent *e)
 {
-#if 0
 	XConfigureRequestEvent *ev = &e->xconfigurerequest;
 	XWindowChanges wc;
-	XRectangle *frect;
 	Client *c;
 
-	c = client_of_win(ev->window);
+	c = getclient(ev->window);
 	ev->value_mask &= ~CWSibling;
 	if(c) {
-		gravitate_client(c, True);
-
 		if(ev->value_mask & CWX)
-			c->rect.x = ev->x;
+			c->r[RFloat].x = ev->x;
 		if(ev->value_mask & CWY)
-			c->rect.y = ev->y;
+			c->r[RFloat].y = ev->y;
 		if(ev->value_mask & CWWidth)
-			c->rect.width = ev->width;
+			c->r[RFloat].width = ev->width;
 		if(ev->value_mask & CWHeight)
-			c->rect.height = ev->height;
+			c->r[RFloat].height = ev->height;
 		if(ev->value_mask & CWBorderWidth)
 			c->border = ev->border_width;
-
-		gravitate_client(c, False);
-
-		if(c->frame) {
-			if(c->sel->area->floating)
-				frect=&c->sel->rect;
-			else
-				frect=&c->sel->revert;
-
-			if(c->rect.width >= screen->rect.width && c->rect.height >= screen->rect.height) {
-				frect->y = wc.y = -height_of_bar();
-				frect->x = wc.x = -def.border;
-			}
-			else {
-				frect->y = wc.y = c->rect.y - height_of_bar();
-				frect->x = wc.x = c->rect.x - def.border;
-			}
-			frect->width = wc.width = c->rect.width + 2 * def.border;
-			frect->height = wc.height = c->rect.height + def.border
-				+ height_of_bar();
-			wc.border_width = 1;
-			wc.sibling = None;
-			wc.stack_mode = ev->detail;
-			if(c->sel->area->view != screen->sel)
-				wc.x += 2 * screen->rect.width;
-			if(c->sel->area->floating) {
-				XConfigureWindow(dpy, c->framewin, ev->value_mask, &wc);
-				configure_client(c);
-			}
-		}
 	}
 
 	wc.x = ev->x;
 	wc.y = ev->y;
 	wc.width = ev->width;
 	wc.height = ev->height;
-
-	if(c && c->frame) {
-		wc.x = def.border;
-		wc.y = height_of_bar();
-		wc.width = c->sel->rect.width - 2 * def.border;
-		wc.height = c->sel->rect.height - def.border - height_of_bar();
-	}
-
 	wc.border_width = 0;
 	wc.sibling = None;
 	wc.stack_mode = Above;
 	ev->value_mask &= ~CWStackMode;
 	ev->value_mask |= CWBorderWidth;
 	XConfigureWindow(dpy, ev->window, ev->value_mask, &wc);
-
 	XFlush(dpy);
-#endif
 }
 
 static void
@@ -182,32 +137,6 @@ expose(XEvent *e)
 }
 
 static void
-keypress(XEvent *e)
-{
-#if 0
-	XKeyEvent *ev = &e->xkey;
-	KeySym k = 0;
-	char buf[32];
-	int n;
-	static Frame *f;
-
-
-	ev->state &= valid_mask;
-	if((f = frame_of_win(ev->window))) {
-		buf[0] = 0;
-		n = XLookupString(ev, buf, sizeof(buf), &k, 0);
-		if(IsFunctionKey(k) || IsKeypadKey(k) || IsMiscFunctionKey(k)
-				|| IsPFKey(k) || IsPrivateKeypadKey(k))
-			return;
-		buf[n] = 0;
-		blitz_kpress_input(&f->tagbar, ev->state, k, buf);
-	}
-	else
-		key(root, ev->state, (KeyCode) ev->keycode);
-#endif
-}
-
-static void
 keymapnotify(XEvent *e)
 {
 #if 0
@@ -231,7 +160,11 @@ maprequest(XEvent *e)
 	}
 
 	/*if(!client_of_win(ev->window))*/
-		manage(create_client(ev->window, &wa));
+		/*manage(create_client(ev->window, &wa));*/
+	XMapRaised(dpy, ev->window);
+	XMoveResizeWindow(dpy, ev->window, rect.x, rect.y, rect.width, rect.height - barrect.height);
+	XSetInputFocus(dpy, ev->window, RevertToPointerRoot, CurrentTime);
+	XFlush(dpy);
 }
 
 static void
diff --git a/font.c b/font.c
index 99301b5..a6b8225 100644
--- a/font.c
+++ b/font.c
@@ -38,7 +38,7 @@ loadfont(Blitz *blitz, BlitzFont *font)
 	font->set = XCreateFontSet(blitz->dpy, fontname, &missing, &n, &def);
 	if(missing) {
 		while(n--)
-			fprintf(stderr, "liblitz: missing fontset: %s\n", missing[n]);
+			fprintf(stderr, "missing fontset: %s\n", missing[n]);
 		XFreeStringList(missing);
 		if(font->set) {
 			XFreeFontSet(blitz->dpy, font->set);
@@ -72,7 +72,7 @@ loadfont(Blitz *blitz, BlitzFont *font)
 			font->xfont = XLoadQueryFont(blitz->dpy, fontname);
 		}
 		if (!font->xfont) {
-			fprintf(stderr, "%s", "liblitz: error, cannot load 'fixed' font\n");
+			fprintf(stderr, "%s", "error, cannot load 'fixed' font\n");
 			exit(1);
 		}
 		font->ascent = font->xfont->ascent;
diff --git a/key.c b/key.c
index a8742da..b5d46c6 100644
--- a/key.c
+++ b/key.c
@@ -24,3 +24,20 @@ update_keys()
 		XGrabKey(dpy, code, key[i].mod, root, True, GrabModeAsync, GrabModeAsync);
 	}
 }
+
+void
+keypress(XEvent *e)
+{
+	XKeyEvent *ev = &e->xkey;
+	unsigned int i, len;
+	KeySym keysym;
+
+	keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
+	len = sizeof(key) / sizeof(key[0]);
+	for(i = 0; i < len; i++)
+		if((keysym == key[i].keysym) && (key[i].mod == ev->state)) {
+			if(key[i].func)
+				key[i].func(key[i].arg);
+			return;
+		}
+}
diff --git a/menu.c b/menu.c
index 6d8843e..ff0ffc1 100644
--- a/menu.c
+++ b/menu.c
@@ -358,8 +358,6 @@ main(int argc, char *argv[])
 
 	char buf[256];
 
-	fputs(STATUSCMD, stdout);
-	fputs("\n", stdout);
 	pipe_spawn(buf, sizeof(buf), NULL, STATUSCMD);
 	fputs(buf, stderr);
 
diff --git a/util.c b/util.c
index de4df98..c0f2489 100644
--- a/util.c
+++ b/util.c
@@ -93,11 +93,12 @@ spawn(Display *dpy, const char *cmd)
 		return;
 	if(fork() == 0) {
 		if(fork() == 0) {
-			setsid();
 			if(dpy)
 				close(ConnectionNumber(dpy));
-			execlp(shell, "shell", "-c", cmd, NULL);
-			fprintf(stderr, "gridwm: execvp %s", cmd);
+			setsid();
+			fprintf(stderr, "gridwm: execlp %s %s -c %s", shell, shell, cmd);
+			execlp(shell, shell, "-c", cmd, NULL);
+			fprintf(stderr, "gridwm: execlp %s", cmd);
 			perror(" failed");
 		}
 		exit (0);
@@ -123,14 +124,14 @@ pipe_spawn(char *buf, unsigned int len, Display *dpy, const char *cmd)
 	}
 
 	if(fork() == 0) {
-		setsid();
 		if(dpy)
 			close(ConnectionNumber(dpy));
+		setsid();
 		dup2(pfd[1], STDOUT_FILENO);
 		close(pfd[0]);
 		close(pfd[1]);
-		execlp(shell, "shell", "-c", cmd, NULL);
-		fprintf(stderr, "gridwm: execvp %s", cmd);
+		execlp(shell, shell, "-c", cmd, NULL);
+		fprintf(stderr, "gridwm: execlp %s", cmd);
 		perror(" failed");
 	}
 	else {
diff --git a/wm.c b/wm.c
index 038e6b9..8c5814f 100644
--- a/wm.c
+++ b/wm.c
@@ -16,11 +16,11 @@
 /* X structs */
 Display *dpy;
 Window root, barwin;
-Atom wm_atom[WMLast], net_atom[NetLast];
+Atom net_atom[NetLast];
 Cursor cursor[CurLast];
 XRectangle rect, barrect;
 Bool running = True;
-Client *client = NULL;
+Client *clients = NULL;
 
 char *bartext, tag[256];
 int screen, sel_screen;
@@ -63,46 +63,6 @@ scan_wins()
 		XFree(wins);
 }
 
-static int
-win_property(Window w, Atom a, Atom t, long l, unsigned char **prop)
-{
-	Atom real;
-	int format;
-	unsigned long res, extra;
-	int status;
-
-	status = XGetWindowProperty(dpy, w, a, 0L, l, False, t, &real, &format,
-			&res, &extra, prop);
-
-	if(status != Success || *prop == NULL) {
-		return 0;
-	}
-	if(res == 0)
-		free((void *) *prop);
-	return res;
-}
-
-int
-win_proto(Window w)
-{
-	Atom *protocols;
-	long res;
-	int protos = 0;
-	int i;
-
-	res = win_property(w, wm_atom[WMProtocols], XA_ATOM, 20L,
-			((unsigned char **) &protocols));
-	if(res <= 0) {
-		return protos;
-	}
-	for(i = 0; i < res; i++) {
-		if(protocols[i] == wm_atom[WMDelete])
-			protos |= WM_PROTOCOL_DELWIN;
-	}
-	free((char *) protocols);
-	return protos;
-}
-
 /*
  * There's no way to check accesses to destroyed windows, thus
  * those cases are ignored (especially on UnmapNotify's).
@@ -201,9 +161,6 @@ main(int argc, char *argv[])
 	x_error_handler = XSetErrorHandler(error_handler);
 
 	/* init atoms */
-	wm_atom[WMState] = XInternAtom(dpy, "WM_STATE", False);
-	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);
 
@@ -242,7 +199,8 @@ main(int argc, char *argv[])
 	XMapRaised(dpy, barwin);
 	draw_bar();
 
-	wa.event_mask = SubstructureRedirectMask | EnterWindowMask | LeaveWindowMask;
+	wa.event_mask = SubstructureRedirectMask | EnterWindowMask \
+					| LeaveWindowMask;
 	wa.cursor = cursor[CurNormal];
 	XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
 
diff --git a/wm.h b/wm.h
index 454f7bf..9ea74fe 100644
--- a/wm.h
+++ b/wm.h
@@ -10,7 +10,6 @@
 #include <X11/Xutil.h>
 
 /* atoms */
-enum { WMState, WMProtocols, WMDelete, WMLast };
 enum { NetSupported, NetWMName, NetLast };
 
 /* cursor */
@@ -25,7 +24,6 @@ typedef struct Key Key;
 struct Client {
 	char name[256];
 	char tag[256];
-	int proto;
 	unsigned int border;
 	Bool fixedsize;
 	Window win;
@@ -46,7 +44,7 @@ struct Key {
 
 extern Display *dpy;
 extern Window root, barwin;
-extern Atom wm_atom[WMLast], net_atom[NetLast];
+extern Atom net_atom[NetLast];
 extern Cursor cursor[CurLast];
 extern XRectangle rect, barrect;
 extern Bool running;
@@ -57,20 +55,22 @@ extern int screen, sel_screen;
 extern char *bartext, tag[256];
 
 extern Brush brush;
-extern Client *client;
+extern Client *clients;
 
 /* bar.c */
 extern void draw_bar();
 
 /* cmd.c */
 extern void run(char *arg);
+extern void quit(char *arg);
 
 /* client.c */
 extern Client *create_client(Window w, XWindowAttributes *wa);
 extern void manage(Client *c);
+extern Client * getclient(Window w);
 
 /* key.c */
 extern void update_keys();
+extern void keypress(XEvent *e);
 
 /* wm.c */
-extern int win_proto(Window w);
tter Ben Morrison <ben@gbmor.dev> 2020-03-16 02:42:35 -0400 removed experimental host matching and tls support' href='/gbmor/getwtxt/commit/README.md?id=31c992e6eaa8f4afe90ec95c5c778412fb887146'>31c992e ^
86b7c42 ^
1b2d93c ^



86b7c42 ^
1b2d93c ^


86b7c42 ^

31c992e ^
4658fe8 ^
1b2d93c ^











1b2d93c ^
4658fe8 ^
1b2d93c ^











c66ed36 ^
1b2d93c ^
c66ed36 ^

ef0ee91 ^
1b2d93c ^
4b056d5 ^


1b2d93c ^
ef0ee91 ^
1b2d93c ^
e3a24e2 ^
1b2d93c ^
58fb387 ^


ef0ee91 ^
c66ed36 ^
2d9f29e ^
2d9f29e ^
1b2d93c ^

6dd01e1 ^
1b2d93c ^
cc01a95 ^
ef0ee91 ^
1b2d93c ^


2d9f29e ^
6dd01e1 ^
1b2d93c ^


cc01a95 ^
1b2d93c ^

1b2d93c ^

2d9f29e ^
6dd01e1 ^
2d9f29e ^






561a63a ^
1b2d93c ^

























2d9f29e ^

6dd01e1 ^
1b2d93c ^
2d9f29e ^







6dd01e1 ^
2d9f29e ^






6dd01e1 ^
2d9f29e ^

1b2d93c ^
2d9f29e ^

1b2d93c ^


2d9f29e ^
6dd01e1 ^
1b2d93c ^
2d9f29e ^
561a63a ^
2d9f29e ^
1b2d93c ^









3089283 ^
1b2d93c ^



3089283 ^

1b2d93c ^


86b7c42 ^
1b2d93c ^

2d9f29e ^


c66ed36 ^
2d9f29e ^







c66ed36 ^
4b056d5 ^






2d9f29e ^
1b2d93c ^
e86aefb ^
1b2d93c ^
e8b0b0c ^
d002048 ^
e86aefb ^
8916d1e ^
e86aefb ^


42ede0e ^


6dd01e1 ^
42ede0e ^
081febb ^
6dd01e1 ^


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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329