diff options
| author | Anselm R. Garbe <garbeam@gmail.com> | 2007-08-15 19:27:32 +0200 |
|---|---|---|
| committer | Anselm R. Garbe <garbeam@gmail.com> | 2007-08-15 19:27:32 +0200 |
| commit | 10d13f01ff764ba0e875adf5d2b83c49aa08d148 (patch) | |
| tree | cad3a1162879cdf53d3a6ac7f97a025d4a65ff40 | |
| parent | fix of resize (thanks Sander for the hint!) (diff) | |
| download | dwm-10d13f01ff764ba0e875adf5d2b83c49aa08d148.tar.gz dwm-10d13f01ff764ba0e875adf5d2b83c49aa08d148.zip | |
fififi
Diffstat (limited to '')
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | client.c | 14 | ||||
| -rw-r--r-- | dwm.h | 6 | ||||
| -rw-r--r-- | event.c | 5 | ||||
| -rw-r--r-- | main.c | 7 | ||||
| -rw-r--r-- | tag.c | 31 |
6 files changed, 35 insertions, 30 deletions
| @@ -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} |
| @@ -297,16 +297,6 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) { | |||
| 297 | } | 297 | } |
| 298 | 298 | ||
| 299 | void | 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 | unban(Client *c) { | 300 | unban(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 | ||
| 318 | void | 308 | void |
| 319 | unmanage(Client *c) { | 309 | unmanage(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); |
| @@ -81,7 +81,7 @@ extern int wax, way, wah, waw; /* windowarea geometry */ | |||
| 81 | extern unsigned int bh, blw, bpos; /* bar height, bar layout label width, bar position */ | 81 | extern unsigned int bh, blw, bpos; /* bar height, bar layout label width, bar position */ |
| 82 | extern unsigned int ntags, numlockmask; /* number of tags, numlock mask */ | 82 | extern unsigned int ntags, numlockmask; /* number of tags, numlock mask */ |
| 83 | extern void (*handler[LASTEvent])(XEvent *); /* event handler */ | 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 | extern Bool selscreen, *seltag; /* seltag is array of Bool */ | 85 | extern Bool selscreen, *seltag; /* seltag is array of Bool */ |
| 86 | extern Client *clients, *sel, *stack; /* global client list and stack */ | 86 | extern Client *clients, *sel, *stack; /* global client list and stack */ |
| 87 | extern Cursor cursor[CurLast]; | 87 | extern Cursor cursor[CurLast]; |
| @@ -99,9 +99,8 @@ void killclient(const char *arg); /* kill sel nicely */ | |||
| 99 | void manage(Window w, XWindowAttributes *wa); /* manage new client */ | 99 | void manage(Window w, XWindowAttributes *wa); /* manage new client */ |
| 100 | void resize(Client *c, int x, int y, | 100 | void 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*/ |
| 102 | void togglefloating(const char *arg); /* toggles sel between floating/tiled state */ | ||
| 103 | void unban(Client *c); /* unbans c */ | 102 | void unban(Client *c); /* unbans c */ |
| 104 | void unmanage(Client *c); /* destroy c */ | 103 | void unmanage(Client *c, long state); /* unmanage c */ |
| 105 | void updatesizehints(Client *c); /* update the size hint variables of c */ | 104 | void updatesizehints(Client *c); /* update the size hint variables of c */ |
| 106 | void updatetitle(Client *c); /* update the name of c */ | 105 | void 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 */ | |||
| 136 | Bool isvisible(Client *c); /* returns True if client is visible */ | 135 | Bool isvisible(Client *c); /* returns True if client is visible */ |
| 137 | void settags(Client *c, Client *trans); /* sets tags of c */ | 136 | void settags(Client *c, Client *trans); /* sets tags of c */ |
| 138 | void tag(const char *arg); /* tags sel with arg's index */ | 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 | void toggletag(const char *arg); /* toggles sel tags with arg's index */ | 139 | void toggletag(const char *arg); /* toggles sel tags with arg's index */ |
| 140 | void toggleview(const char *arg); /* toggles the tag with arg's index (in)visible */ | 140 | void toggleview(const char *arg); /* toggles the tag with arg's index (in)visible */ |
| 141 | void view(const char *arg); /* views the tag with arg's index */ | 141 | void view(const char *arg); /* views the tag with arg's index */ |
| @@ -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 | ||
| 232 | static void | 233 | static 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 | ||
| @@ -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; | |||
| 19 | unsigned int bh, ntags; | 20 | unsigned int bh, ntags; |
| 20 | unsigned int bpos = BARPOS; | 21 | unsigned int bpos = BARPOS; |
| 21 | unsigned int numlockmask = 0; | 22 | unsigned int numlockmask = 0; |
| 22 | Atom dwmtags, wmatom[WMLast], netatom[NetLast]; | 23 | Atom dwmconfig, wmatom[WMLast], netatom[NetLast]; |
| 23 | Bool *seltag; | 24 | Bool *seltag; |
| 24 | Bool selscreen = True; | 25 | Bool selscreen = True; |
| 25 | Client *clients = NULL; | 26 | Client *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); |
| @@ -28,14 +28,15 @@ static unsigned int nrules = 0; | |||
| 28 | static char prop[512]; | 28 | static char prop[512]; |
| 29 | 29 | ||
| 30 | static void | 30 | static void |
| 31 | persisttags(Client *c) | 31 | persistconfig(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 | ||
| 133 | void | 136 | void |
| @@ -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 | |||
| 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 | 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 | ||
