summaryrefslogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
authorAnselm R. Garbe <garbeam@gmail.com>2007-10-10 18:39:28 +0200
committerAnselm R. Garbe <garbeam@gmail.com>2007-10-10 18:39:28 +0200
commita73de0cff42588d3dc3b40e4e8b198c847208dca (patch)
tree75c52f9e0078aeea37206146f53da691701ff9fa /dwm.c
parentapplied Brandon MacDone's static initialization patch for seltags and Client-... (diff)
downloaddwm-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 '')
-rw-r--r--dwm.c54
1 files changed, 33 insertions, 21 deletions
diff --git a/dwm.c b/dwm.c
index 9e9e748..a4447f6 100644
--- a/dwm.c
+++ b/dwm.c
@@ -58,6 +58,22 @@ enum { WMProtocols, WMDelete, WMName, WMState, WMLast };/* default atoms */
58/* typedefs */ 58/* typedefs */
59typedef struct Client Client; 59typedef struct Client Client;
60 60
61struct 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
61typedef struct { 77typedef 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);
170void updatesizehints(Client *c); 186void updatesizehints(Client *c);
171void updatetitle(Client *c); 187void updatetitle(Client *c);
172void view(const char *arg); 188void view(const char *arg);
189void viewprevtag(const char *arg); /* views previous selected tags */
173int xerror(Display *dpy, XErrorEvent *ee); 190int xerror(Display *dpy, XErrorEvent *ee);
174int xerrordummy(Display *dsply, XErrorEvent *ee); 191int xerrordummy(Display *dsply, XErrorEvent *ee);
175int xerrorstart(Display *dsply, XErrorEvent *ee); 192int 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. */
220unsigned int ntags = sizeof tags / sizeof tags[0]; 237unsigned int ntags = sizeof tags / sizeof tags[0];
221Bool seltags[sizeof tags / sizeof tags[0]] = {[0] = True}; 238Bool seltags[sizeof tags / sizeof tags[0]] = {[0] = True};
222 239Bool prevtags[sizeof tags / sizeof tags[0]] = {[0] = True};
223struct 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*/
240void 242void
@@ -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
272void 273void
@@ -1002,13 +1003,13 @@ leavenotify(XEvent *e) {
1002 1003
1003void 1004void
1004manage(Window w, XWindowAttributes *wa) { 1005manage(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
1838view(const char *arg) { 1839view(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
1849void 1851void
1852viewprevtag(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
1861void
1850zoom(const char *arg) { 1862zoom(const char *arg) {
1851 Client *c; 1863 Client *c;
1852 1864