summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnselm R. Garbe <garbeam@gmail.com>2007-08-15 19:27:32 +0200
committerAnselm R. Garbe <garbeam@gmail.com>2007-08-15 19:27:32 +0200
commit10d13f01ff764ba0e875adf5d2b83c49aa08d148 (patch)
treecad3a1162879cdf53d3a6ac7f97a025d4a65ff40
parentfix of resize (thanks Sander for the hint!) (diff)
downloaddwm-10d13f01ff764ba0e875adf5d2b83c49aa08d148.tar.gz
dwm-10d13f01ff764ba0e875adf5d2b83c49aa08d148.zip
fififi
Diffstat (limited to '')
-rw-r--r--Makefile2
-rw-r--r--client.c14
-rw-r--r--dwm.h6
-rw-r--r--event.c5
-rw-r--r--main.c7
-rw-r--r--tag.c31
6 files changed, 35 insertions, 30 deletions
diff --git a/Makefile b/Makefile
index 24947f1..b1378b8 100644
--- a/Makefile
+++ b/Makefile
@@ -36,7 +36,7 @@ dist: clean
36 @echo creating dist tarball 36 @echo creating dist tarball
37 @mkdir -p dwm-${VERSION} 37 @mkdir -p dwm-${VERSION}
38 @cp -R LICENSE Makefile README config.*.h config.mk \ 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 @tar -cf dwm-${VERSION}.tar dwm-${VERSION} 40 @tar -cf dwm-${VERSION}.tar dwm-${VERSION}
41 @gzip dwm-${VERSION}.tar 41 @gzip dwm-${VERSION}.tar
42 @rm -rf dwm-${VERSION} 42 @rm -rf dwm-${VERSION}
diff --git a/client.c b/client.c
index ed19d9c..22408f2 100644
--- a/client.c
+++ b/client.c
@@ -297,16 +297,6 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
297} 297}
298 298
299void 299void
300togglefloating(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
309void
310unban(Client *c) { 300unban(Client *c) {
311 if(!c->isbanned) 301 if(!c->isbanned)
312 return; 302 return;
@@ -316,7 +306,7 @@ unban(Client *c) {
316} 306}
317 307
318void 308void
319unmanage(Client *c) { 309unmanage(Client *c, long state) {
320 XWindowChanges wc; 310 XWindowChanges wc;
321 311
322 wc.border_width = c->oldborder; 312 wc.border_width = c->oldborder;
@@ -329,7 +319,7 @@ unmanage(Client *c) {
329 if(sel == c) 319 if(sel == c)
330 focus(NULL); 320 focus(NULL);
331 XUngrabButton(dpy, AnyButton, AnyModifier, c->win); 321 XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
332 setclientstate(c, WithdrawnState); 322 setclientstate(c, state);
333 free(c->tags); 323 free(c->tags);
334 free(c); 324 free(c);
335 XSync(dpy, False); 325 XSync(dpy, False);
diff --git a/dwm.h b/dwm.h
index 236c780..509b845 100644
--- a/dwm.h
+++ b/dwm.h
@@ -81,7 +81,7 @@ extern int wax, way, wah, waw; /* windowarea geometry */
81extern unsigned int bh, blw, bpos; /* bar height, bar layout label width, bar position */ 81extern unsigned int bh, blw, bpos; /* bar height, bar layout label width, bar position */
82extern unsigned int ntags, numlockmask; /* number of tags, numlock mask */ 82extern unsigned int ntags, numlockmask; /* number of tags, numlock mask */
83extern void (*handler[LASTEvent])(XEvent *); /* event handler */ 83extern void (*handler[LASTEvent])(XEvent *); /* event handler */
84extern Atom dwmtags, wmatom[WMLast], netatom[NetLast]; 84extern Atom dwmconfig, wmatom[WMLast], netatom[NetLast];
85extern Bool selscreen, *seltag; /* seltag is array of Bool */ 85extern Bool selscreen, *seltag; /* seltag is array of Bool */
86extern Client *clients, *sel, *stack; /* global client list and stack */ 86extern Client *clients, *sel, *stack; /* global client list and stack */
87extern Cursor cursor[CurLast]; 87extern Cursor cursor[CurLast];
@@ -99,9 +99,8 @@ void killclient(const char *arg); /* kill sel nicely */
99void manage(Window w, XWindowAttributes *wa); /* manage new client */ 99void manage(Window w, XWindowAttributes *wa); /* manage new client */
100void resize(Client *c, int x, int y, 100void resize(Client *c, int x, int y,
101 int w, int h, Bool sizehints); /* resize with given coordinates c*/ 101 int w, int h, Bool sizehints); /* resize with given coordinates c*/
102void togglefloating(const char *arg); /* toggles sel between floating/tiled state */
103void unban(Client *c); /* unbans c */ 102void unban(Client *c); /* unbans c */
104void unmanage(Client *c); /* destroy c */ 103void unmanage(Client *c, long state); /* unmanage c */
105void updatesizehints(Client *c); /* update the size hint variables of c */ 104void updatesizehints(Client *c); /* update the size hint variables of c */
106void updatetitle(Client *c); /* update the name of c */ 105void updatetitle(Client *c); /* update the name of c */
107 106
@@ -136,6 +135,7 @@ void compileregs(void); /* initialize regexps of rules defined in config.h */
136Bool isvisible(Client *c); /* returns True if client is visible */ 135Bool isvisible(Client *c); /* returns True if client is visible */
137void settags(Client *c, Client *trans); /* sets tags of c */ 136void settags(Client *c, Client *trans); /* sets tags of c */
138void tag(const char *arg); /* tags sel with arg's index */ 137void tag(const char *arg); /* tags sel with arg's index */
138void togglefloating(const char *arg); /* toggles sel between floating/tiled state */
139void toggletag(const char *arg); /* toggles sel tags with arg's index */ 139void toggletag(const char *arg); /* toggles sel tags with arg's index */
140void toggleview(const char *arg); /* toggles the tag with arg's index (in)visible */ 140void toggleview(const char *arg); /* toggles the tag with arg's index (in)visible */
141void view(const char *arg); /* views the tag with arg's index */ 141void view(const char *arg); /* views the tag with arg's index */
diff --git a/event.c b/event.c
index 4bedf18..b8a16a7 100644
--- a/event.c
+++ b/event.c
@@ -4,6 +4,7 @@
4#include <stdlib.h> 4#include <stdlib.h>
5#include <X11/keysym.h> 5#include <X11/keysym.h>
6#include <X11/Xatom.h> 6#include <X11/Xatom.h>
7#include <X11/Xutil.h>
7 8
8/* static */ 9/* static */
9 10
@@ -226,7 +227,7 @@ destroynotify(XEvent *e) {
226 XDestroyWindowEvent *ev = &e->xdestroywindow; 227 XDestroyWindowEvent *ev = &e->xdestroywindow;
227 228
228 if((c = getclient(ev->window))) 229 if((c = getclient(ev->window)))
229 unmanage(c); 230 unmanage(c, WithdrawnState);
230} 231}
231 232
232static void 233static void
@@ -338,7 +339,7 @@ unmapnotify(XEvent *e) {
338 339
339 if((c = getclient(ev->window)) && (ev->event == root)) { 340 if((c = getclient(ev->window)) && (ev->event == root)) {
340 if(ev->send_event || c->unmapped-- == 0) 341 if(ev->send_event || c->unmapped-- == 0)
341 unmanage(c); 342 unmanage(c, WithdrawnState);
342 } 343 }
343} 344}
344 345
diff --git a/main.c b/main.c
index 2140d89..6d84a77 100644
--- a/main.c
+++ b/main.c
@@ -11,6 +11,7 @@
11#include <X11/keysym.h> 11#include <X11/keysym.h>
12#include <X11/Xatom.h> 12#include <X11/Xatom.h>
13#include <X11/Xproto.h> 13#include <X11/Xproto.h>
14#include <X11/Xutil.h>
14 15
15/* extern */ 16/* extern */
16 17
@@ -19,7 +20,7 @@ int screen, sx, sy, sw, sh, wax, way, waw, wah;
19unsigned int bh, ntags; 20unsigned int bh, ntags;
20unsigned int bpos = BARPOS; 21unsigned int bpos = BARPOS;
21unsigned int numlockmask = 0; 22unsigned int numlockmask = 0;
22Atom dwmtags, wmatom[WMLast], netatom[NetLast]; 23Atom dwmconfig, wmatom[WMLast], netatom[NetLast];
23Bool *seltag; 24Bool *seltag;
24Bool selscreen = True; 25Bool selscreen = True;
25Client *clients = NULL; 26Client *clients = NULL;
@@ -41,7 +42,7 @@ cleanup(void) {
41 close(STDIN_FILENO); 42 close(STDIN_FILENO);
42 while(stack) { 43 while(stack) {
43 unban(stack); 44 unban(stack);
44 unmanage(stack); 45 unmanage(stack, NormalState);
45 } 46 }
46 if(dc.font.set) 47 if(dc.font.set)
47 XFreeFontSet(dpy, dc.font.set); 48 XFreeFontSet(dpy, dc.font.set);
@@ -139,7 +140,7 @@ setup(void) {
139 XSetWindowAttributes wa; 140 XSetWindowAttributes wa;
140 141
141 /* init atoms */ 142 /* init atoms */
142 dwmtags = XInternAtom(dpy, "__DWM_TAGS", False); 143 dwmconfig = XInternAtom(dpy, "_DWM_CONFIG", False);
143 wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); 144 wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
144 wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False); 145 wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
145 wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False); 146 wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False);
diff --git a/tag.c b/tag.c
index a532761..cb1a2c4 100644
--- a/tag.c
+++ b/tag.c
@@ -28,14 +28,15 @@ static unsigned int nrules = 0;
28static char prop[512]; 28static char prop[512];
29 29
30static void 30static void
31persisttags(Client *c) 31persistconfig(Client *c) {
32{
33 unsigned int i; 32 unsigned int i;
34 33
35 for(i = 0; i < ntags && i < sizeof prop - 1; i++) 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 prop[i] = '\0'; 38 prop[i] = '\0';
38 XChangeProperty(dpy, c->win, dwmtags, XA_STRING, 8, 39 XChangeProperty(dpy, c->win, dwmconfig, XA_STRING, 8,
39 PropModeReplace, (unsigned char *)prop, i); 40 PropModeReplace, (unsigned char *)prop, i);
40} 41}
41 42
@@ -93,14 +94,16 @@ settags(Client *c, Client *trans) {
93 else { 94 else {
94 /* check if window has set a property */ 95 /* check if window has set a property */
95 name.nitems = 0; 96 name.nitems = 0;
96 XGetTextProperty(dpy, c->win, &name, dwmtags); 97 XGetTextProperty(dpy, c->win, &name, dwmconfig);
97 if(name.nitems && name.encoding == XA_STRING) { 98 if(name.nitems && name.encoding == XA_STRING) {
98 strncpy(prop, (char *)name.value, sizeof prop - 1); 99 strncpy(prop, (char *)name.value, sizeof prop - 1);
99 prop[sizeof prop - 1] = '\0'; 100 prop[sizeof prop - 1] = '\0';
100 XFree(name.value); 101 XFree(name.value);
101 for(i = 0; i < ntags && i < sizeof prop - 1 && prop[i] != '\0'; i++) 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 matched = True; 104 matched = True;
105 if(i < sizeof prop - 1 && prop[i] != '\0')
106 c->isfloating = prop[i] == '1';
104 } 107 }
105 } 108 }
106 if(!matched) { 109 if(!matched) {
@@ -127,7 +130,7 @@ settags(Client *c, Client *trans) {
127 if(!matched) 130 if(!matched)
128 for(i = 0; i < ntags; i++) 131 for(i = 0; i < ntags; i++)
129 c->tags[i] = seltag[i]; 132 c->tags[i] = seltag[i];
130 persisttags(c); 133 persistconfig(c);
131} 134}
132 135
133void 136void
@@ -142,7 +145,17 @@ tag(const char *arg) {
142 if(i >= 0 && i < ntags) 145 if(i >= 0 && i < ntags)
143 sel->tags[i] = True; 146 sel->tags[i] = True;
144 if(sel) 147 if(sel)
145 persisttags(sel); 148 persistconfig(sel);
149 arrange();
150}
151
152void
153togglefloating(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 arrange(); 159 arrange();
147} 160}
148 161
@@ -158,7 +171,7 @@ toggletag(const char *arg) {
158 if(j == ntags) 171 if(j == ntags)
159 sel->tags[i] = True; 172 sel->tags[i] = True;
160 if(sel) 173 if(sel)
161 persisttags(sel); 174 persistconfig(sel);
162 arrange(); 175 arrange();
163} 176}
164 177