diff options
| author | Anselm R. Garbe <garbeam@gmail.com> | 2007-10-10 18:39:28 +0200 |
|---|---|---|
| committer | Anselm R. Garbe <garbeam@gmail.com> | 2007-10-10 18:39:28 +0200 |
| commit | a73de0cff42588d3dc3b40e4e8b198c847208dca (patch) | |
| tree | 75c52f9e0078aeea37206146f53da691701ff9fa /dwm.c | |
| parent | applied Brandon MacDone's static initialization patch for seltags and Client-... (diff) | |
| download | dwm-a73de0cff42588d3dc3b40e4e8b198c847208dca.tar.gz dwm-a73de0cff42588d3dc3b40e4e8b198c847208dca.zip | |
added antoszka's viewprev patch with some minor modifications, restored Client->tags as Bool *, however kept the static initialization of ntags and seltags (prevtags) - this seems to be the best compromise
Diffstat (limited to 'dwm.c')
| -rw-r--r-- | dwm.c | 54 |
1 files changed, 33 insertions, 21 deletions
| @@ -58,6 +58,22 @@ enum { WMProtocols, WMDelete, WMName, WMState, WMLast };/* default atoms */ | |||
| 58 | /* typedefs */ | 58 | /* typedefs */ |
| 59 | typedef struct Client Client; | 59 | typedef struct Client Client; |
| 60 | 60 | ||
| 61 | struct Client { | ||
| 62 | char name[256]; | ||
| 63 | int x, y, w, h; | ||
| 64 | int rx, ry, rw, rh; /* revert geometry */ | ||
| 65 | int basew, baseh, incw, inch, maxw, maxh, minw, minh; | ||
| 66 | int minax, maxax, minay, maxay; | ||
| 67 | long flags; | ||
| 68 | unsigned int border, oldborder; | ||
| 69 | Bool isbanned, isfixed, ismax, isfloating, wasfloating; | ||
| 70 | Bool *tags; | ||
| 71 | Client *next; | ||
| 72 | Client *prev; | ||
| 73 | Client *snext; | ||
| 74 | Window win; | ||
| 75 | }; | ||
| 76 | |||
| 61 | typedef struct { | 77 | typedef struct { |
| 62 | int x, y, w, h; | 78 | int x, y, w, h; |
| 63 | unsigned long norm[ColLast]; | 79 | unsigned long norm[ColLast]; |
| @@ -170,6 +186,7 @@ void updatebarpos(void); | |||
| 170 | void updatesizehints(Client *c); | 186 | void updatesizehints(Client *c); |
| 171 | void updatetitle(Client *c); | 187 | void updatetitle(Client *c); |
| 172 | void view(const char *arg); | 188 | void view(const char *arg); |
| 189 | void viewprevtag(const char *arg); /* views previous selected tags */ | ||
| 173 | int xerror(Display *dpy, XErrorEvent *ee); | 190 | int xerror(Display *dpy, XErrorEvent *ee); |
| 174 | int xerrordummy(Display *dsply, XErrorEvent *ee); | 191 | int xerrordummy(Display *dsply, XErrorEvent *ee); |
| 175 | int xerrorstart(Display *dsply, XErrorEvent *ee); | 192 | int xerrorstart(Display *dsply, XErrorEvent *ee); |
| @@ -219,22 +236,7 @@ Regs *regs = NULL; | |||
| 219 | /* Statically define the number of tags. */ | 236 | /* Statically define the number of tags. */ |
| 220 | unsigned int ntags = sizeof tags / sizeof tags[0]; | 237 | unsigned int ntags = sizeof tags / sizeof tags[0]; |
| 221 | Bool seltags[sizeof tags / sizeof tags[0]] = {[0] = True}; | 238 | Bool seltags[sizeof tags / sizeof tags[0]] = {[0] = True}; |
| 222 | 239 | Bool prevtags[sizeof tags / sizeof tags[0]] = {[0] = True}; | |
| 223 | struct Client { | ||
| 224 | char name[256]; | ||
| 225 | int x, y, w, h; | ||
| 226 | int rx, ry, rw, rh; /* revert geometry */ | ||
| 227 | int basew, baseh, incw, inch, maxw, maxh, minw, minh; | ||
| 228 | int minax, maxax, minay, maxay; | ||
| 229 | long flags; | ||
| 230 | unsigned int border, oldborder; | ||
| 231 | Bool isbanned, isfixed, ismax, isfloating, wasfloating; | ||
| 232 | Bool tags[sizeof tags / sizeof tags[0]]; | ||
| 233 | Client *next; | ||
| 234 | Client *prev; | ||
| 235 | Client *snext; | ||
| 236 | Window win; | ||
| 237 | }; | ||
| 238 | 240 | ||
| 239 | /* functions*/ | 241 | /* functions*/ |
| 240 | void | 242 | void |
| @@ -265,8 +267,7 @@ applyrules(Client *c) { | |||
| 265 | if(ch.res_name) | 267 | if(ch.res_name) |
| 266 | XFree(ch.res_name); | 268 | XFree(ch.res_name); |
| 267 | if(!matched) | 269 | if(!matched) |
| 268 | for(i = 0; i < ntags; i++) | 270 | memcpy(c->tags, seltags, sizeof seltags); |
| 269 | c->tags[i] = seltags[i]; | ||
| 270 | } | 271 | } |
| 271 | 272 | ||
| 272 | void | 273 | void |
| @@ -1002,13 +1003,13 @@ leavenotify(XEvent *e) { | |||
| 1002 | 1003 | ||
| 1003 | void | 1004 | void |
| 1004 | manage(Window w, XWindowAttributes *wa) { | 1005 | manage(Window w, XWindowAttributes *wa) { |
| 1005 | unsigned int i; | ||
| 1006 | Client *c, *t = NULL; | 1006 | Client *c, *t = NULL; |
| 1007 | Window trans; | 1007 | Window trans; |
| 1008 | Status rettrans; | 1008 | Status rettrans; |
| 1009 | XWindowChanges wc; | 1009 | XWindowChanges wc; |
| 1010 | 1010 | ||
| 1011 | c = emallocz(sizeof(Client)); | 1011 | c = emallocz(sizeof(Client)); |
| 1012 | c->tags = emallocz(sizeof seltags); | ||
| 1012 | c->win = w; | 1013 | c->win = w; |
| 1013 | c->x = wa->x; | 1014 | c->x = wa->x; |
| 1014 | c->y = wa->y; | 1015 | c->y = wa->y; |
| @@ -1043,8 +1044,7 @@ manage(Window w, XWindowAttributes *wa) { | |||
| 1043 | if((rettrans = XGetTransientForHint(dpy, w, &trans) == Success)) | 1044 | if((rettrans = XGetTransientForHint(dpy, w, &trans) == Success)) |
| 1044 | for(t = clients; t && t->win != trans; t = t->next); | 1045 | for(t = clients; t && t->win != trans; t = t->next); |
| 1045 | if(t) | 1046 | if(t) |
| 1046 | for(i = 0; i < ntags; i++) | 1047 | memcpy(c->tags, t->tags, sizeof seltags); |
| 1047 | c->tags[i] = t->tags[i]; | ||
| 1048 | applyrules(c); | 1048 | applyrules(c); |
| 1049 | if(!c->isfloating) | 1049 | if(!c->isfloating) |
| 1050 | c->isfloating = (rettrans == Success) || c->isfixed; | 1050 | c->isfloating = (rettrans == Success) || c->isfixed; |
| @@ -1702,6 +1702,7 @@ unmanage(Client *c) { | |||
| 1702 | focus(NULL); | 1702 | focus(NULL); |
| 1703 | XUngrabButton(dpy, AnyButton, AnyModifier, c->win); | 1703 | XUngrabButton(dpy, AnyButton, AnyModifier, c->win); |
| 1704 | setclientstate(c, WithdrawnState); | 1704 | setclientstate(c, WithdrawnState); |
| 1705 | free(c->tags); | ||
| 1705 | free(c); | 1706 | free(c); |
| 1706 | XSync(dpy, False); | 1707 | XSync(dpy, False); |
| 1707 | XSetErrorHandler(xerror); | 1708 | XSetErrorHandler(xerror); |
| @@ -1838,6 +1839,7 @@ void | |||
| 1838 | view(const char *arg) { | 1839 | view(const char *arg) { |
| 1839 | unsigned int i; | 1840 | unsigned int i; |
| 1840 | 1841 | ||
| 1842 | memcpy(prevtags, seltags, sizeof seltags); | ||
| 1841 | for(i = 0; i < ntags; i++) | 1843 | for(i = 0; i < ntags; i++) |
| 1842 | seltags[i] = arg == NULL; | 1844 | seltags[i] = arg == NULL; |
| 1843 | i = idxoftag(arg); | 1845 | i = idxoftag(arg); |
| @@ -1847,6 +1849,16 @@ view(const char *arg) { | |||
| 1847 | } | 1849 | } |
| 1848 | 1850 | ||
| 1849 | void | 1851 | void |
| 1852 | viewprevtag(const char *arg) { | ||
| 1853 | static Bool tmptags[sizeof tags / sizeof tags[0]]; | ||
| 1854 | |||
| 1855 | memcpy(tmptags, seltags, sizeof seltags); | ||
| 1856 | memcpy(seltags, prevtags, sizeof seltags); | ||
| 1857 | memcpy(prevtags, tmptags, sizeof seltags); | ||
| 1858 | arrange(); | ||
| 1859 | } | ||
| 1860 | |||
| 1861 | void | ||
| 1850 | zoom(const char *arg) { | 1862 | zoom(const char *arg) { |
| 1851 | Client *c; | 1863 | Client *c; |
| 1852 | 1864 | ||
