fififi 10d13f01
Anselm R. Garbe · 2007-08-15 19:27 6 file(s) · +35 −30
Makefile +1 −1
36 36
	@echo creating dist tarball
37 37
	@mkdir -p dwm-${VERSION}
38 38
	@cp -R LICENSE Makefile README config.*.h config.mk \
39 -
		dwm.1 dwm.h ${SRC} dwm-${VERSION}
39 +
		dwm.1 dwm.h tile.h ${SRC} dwm-${VERSION}
40 40
	@tar -cf dwm-${VERSION}.tar dwm-${VERSION}
41 41
	@gzip dwm-${VERSION}.tar
42 42
	@rm -rf dwm-${VERSION}
client.c +2 −12
297 297
}
298 298
299 299
void
300 -
togglefloating(const char *arg) {
301 -
	if(!sel || isfloating())
302 -
		return;
303 -
	sel->isfloating = !sel->isfloating;
304 -
	if(sel->isfloating)
305 -
		resize(sel, sel->x, sel->y, sel->w, sel->h, True);
306 -
	arrange();
307 -
}
308 -
309 -
void
310 300
unban(Client *c) {
311 301
	if(!c->isbanned)
312 302
		return;
316 306
}
317 307
318 308
void
319 -
unmanage(Client *c) {
309 +
unmanage(Client *c, long state) {
320 310
	XWindowChanges wc;
321 311
322 312
	wc.border_width = c->oldborder;
329 319
	if(sel == c)
330 320
		focus(NULL);
331 321
	XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
332 -
	setclientstate(c, WithdrawnState);
322 +
	setclientstate(c, state);
333 323
	free(c->tags);
334 324
	free(c);
335 325
	XSync(dpy, False);
dwm.h +3 −3
81 81
extern unsigned int bh, blw, bpos;		/* bar height, bar layout label width, bar position */
82 82
extern unsigned int ntags, numlockmask;		/* number of tags, numlock mask */
83 83
extern void (*handler[LASTEvent])(XEvent *);	/* event handler */
84 -
extern Atom dwmtags, wmatom[WMLast], netatom[NetLast];
84 +
extern Atom dwmconfig, wmatom[WMLast], netatom[NetLast];
85 85
extern Bool selscreen, *seltag;			/* seltag is array of Bool */
86 86
extern Client *clients, *sel, *stack;		/* global client list and stack */
87 87
extern Cursor cursor[CurLast];
99 99
void manage(Window w, XWindowAttributes *wa);	/* manage new client */
100 100
void resize(Client *c, int x, int y,
101 101
		int w, int h, Bool sizehints);	/* resize with given coordinates c*/
102 -
void togglefloating(const char *arg);	/* toggles sel between floating/tiled state */
103 102
void unban(Client *c);			/* unbans c */
104 -
void unmanage(Client *c);		/* destroy c */
103 +
void unmanage(Client *c, long state);	/* unmanage c */
105 104
void updatesizehints(Client *c);	/* update the size hint variables of c */
106 105
void updatetitle(Client *c);		/* update the name of c */
107 106
136 135
Bool isvisible(Client *c);		/* returns True if client is visible */
137 136
void settags(Client *c, Client *trans);	/* sets tags of c */
138 137
void tag(const char *arg);		/* tags sel with arg's index */
138 +
void togglefloating(const char *arg);	/* toggles sel between floating/tiled state */
139 139
void toggletag(const char *arg);	/* toggles sel tags with arg's index */
140 140
void toggleview(const char *arg);	/* toggles the tag with arg's index (in)visible */
141 141
void view(const char *arg);		/* views the tag with arg's index */
event.c +3 −2
4 4
#include <stdlib.h>
5 5
#include <X11/keysym.h>
6 6
#include <X11/Xatom.h>
7 +
#include <X11/Xutil.h>
7 8
8 9
/* static */
9 10
226 227
	XDestroyWindowEvent *ev = &e->xdestroywindow;
227 228
228 229
	if((c = getclient(ev->window)))
229 -
		unmanage(c);
230 +
		unmanage(c, WithdrawnState);
230 231
}
231 232
232 233
static void
338 339
339 340
	if((c = getclient(ev->window)) && (ev->event == root)) {
340 341
		if(ev->send_event || c->unmapped-- == 0)
341 -
			unmanage(c);
342 +
			unmanage(c, WithdrawnState);
342 343
	}
343 344
}
344 345
main.c +4 −3
11 11
#include <X11/keysym.h>
12 12
#include <X11/Xatom.h>
13 13
#include <X11/Xproto.h>
14 +
#include <X11/Xutil.h>
14 15
15 16
/* extern */
16 17
19 20
unsigned int bh, ntags;
20 21
unsigned int bpos = BARPOS;
21 22
unsigned int numlockmask = 0;
22 -
Atom dwmtags, wmatom[WMLast], netatom[NetLast];
23 +
Atom dwmconfig, wmatom[WMLast], netatom[NetLast];
23 24
Bool *seltag;
24 25
Bool selscreen = True;
25 26
Client *clients = NULL;
41 42
	close(STDIN_FILENO);
42 43
	while(stack) {
43 44
		unban(stack);
44 -
		unmanage(stack);
45 +
		unmanage(stack, NormalState);
45 46
	}
46 47
	if(dc.font.set)
47 48
		XFreeFontSet(dpy, dc.font.set);
139 140
	XSetWindowAttributes wa;
140 141
141 142
	/* init atoms */
142 -
	dwmtags = XInternAtom(dpy, "__DWM_TAGS", False);
143 +
	dwmconfig = XInternAtom(dpy, "_DWM_CONFIG", False);
143 144
	wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
144 145
	wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
145 146
	wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False);
tag.c +22 −9
28 28
static char prop[512];
29 29
30 30
static void
31 -
persisttags(Client *c)
32 -
{
31 +
persistconfig(Client *c) {
33 32
	unsigned int i;
34 33
35 34
	for(i = 0; i < ntags && i < sizeof prop - 1; i++)
36 -
		prop[i] = c->tags[i] ? '+' : '-';
35 +
		prop[i] = c->tags[i] ? '1' : '0';
36 +
	if(i < sizeof prop - 1)
37 +
		prop[i++] = c->isfloating ? '1' : '0';
37 38
	prop[i] = '\0';
38 -
	XChangeProperty(dpy, c->win, dwmtags, XA_STRING, 8,
39 +
	XChangeProperty(dpy, c->win, dwmconfig, XA_STRING, 8,
39 40
			PropModeReplace, (unsigned char *)prop, i);
40 41
}
41 42
93 94
	else {
94 95
		/* check if window has set a property */
95 96
		name.nitems = 0;
96 -
		XGetTextProperty(dpy, c->win, &name, dwmtags);
97 +
		XGetTextProperty(dpy, c->win, &name, dwmconfig);
97 98
		if(name.nitems && name.encoding == XA_STRING) {
98 99
			strncpy(prop, (char *)name.value, sizeof prop - 1);
99 100
			prop[sizeof prop - 1] = '\0';
100 101
			XFree(name.value);
101 102
			for(i = 0; i < ntags && i < sizeof prop - 1 && prop[i] != '\0'; i++)
102 -
				if((c->tags[i] = prop[i] == '+'))
103 +
				if((c->tags[i] = prop[i] == '1'))
103 104
					matched = True;
105 +
			if(i < sizeof prop - 1 && prop[i] != '\0')
106 +
				c->isfloating = prop[i] == '1';
104 107
		}
105 108
	}
106 109
	if(!matched) {
127 130
	if(!matched)
128 131
		for(i = 0; i < ntags; i++)
129 132
			c->tags[i] = seltag[i];
130 -
	persisttags(c);
133 +
	persistconfig(c);
131 134
}
132 135
133 136
void
142 145
	if(i >= 0 && i < ntags)
143 146
		sel->tags[i] = True;
144 147
	if(sel)
145 -
		persisttags(sel);
148 +
		persistconfig(sel);
149 +
	arrange();
150 +
}
151 +
152 +
void
153 +
togglefloating(const char *arg) {
154 +
	if(!sel || isfloating())
155 +
		return;
156 +
	sel->isfloating = !sel->isfloating;
157 +
	if(sel->isfloating)
158 +
		resize(sel, sel->x, sel->y, sel->w, sel->h, True);
146 159
	arrange();
147 160
}
148 161
158 171
	if(j == ntags)
159 172
		sel->tags[i] = True;
160 173
	if(sel)
161 -
		persisttags(sel);
174 +
		persistconfig(sel);
162 175
	arrange();
163 176
}
164 177