sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

dwm-pertag-5.7.2.diff (4762B)


      1 diff -r 2bcd25cce4ab dwm.c
      2 --- a/dwm.c	Sun Sep 27 20:20:14 2009 +0100
      3 +++ b/dwm.c	Tue Oct 20 18:27:52 2009 -0300
      4 @@ -120,26 +120,6 @@
      5  	void (*arrange)(Monitor *);
      6  } Layout;
      7  
      8 -struct Monitor {
      9 -	char ltsymbol[16];
     10 -	float mfact;
     11 -	int num;
     12 -	int by;               /* bar geometry */
     13 -	int mx, my, mw, mh;   /* screen size */
     14 -	int wx, wy, ww, wh;   /* window area  */
     15 -	unsigned int seltags;
     16 -	unsigned int sellt;
     17 -	unsigned int tagset[2];
     18 -	Bool showbar;
     19 -	Bool topbar;
     20 -	Client *clients;
     21 -	Client *sel;
     22 -	Client *stack;
     23 -	Monitor *next;
     24 -	Window barwin;
     25 -	const Layout *lt[2];
     26 -};
     27 -
     28  typedef struct {
     29  	const char *class;
     30  	const char *instance;
     31 @@ -273,6 +253,31 @@
     32  /* configuration, allows nested code to access above variables */
     33  #include "config.h"
     34  
     35 +struct Monitor {
     36 +	char ltsymbol[16];
     37 +	float mfact;
     38 +	int num;
     39 +	int by;               /* bar geometry */
     40 +	int mx, my, mw, mh;   /* screen size */
     41 +	int wx, wy, ww, wh;   /* window area  */
     42 +	unsigned int seltags;
     43 +	unsigned int sellt;
     44 +	unsigned int tagset[2];
     45 +	Bool showbar;
     46 +	Bool topbar;
     47 +	Client *clients;
     48 +	Client *sel;
     49 +	Client *stack;
     50 +	Monitor *next;
     51 +	Window barwin;
     52 +	const Layout *lt[2];
     53 +	int curtag;
     54 +	int prevtag;
     55 +	const Layout *lts[LENGTH(tags) + 1];
     56 +	double mfacts[LENGTH(tags) + 1];
     57 +	Bool showbars[LENGTH(tags) + 1];
     58 +};
     59 +
     60  /* compile-time check if all tags fit into an unsigned int bit array. */
     61  struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
     62  
     63 @@ -1450,7 +1455,7 @@
     64  	if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
     65  		selmon->sellt ^= 1;
     66  	if(arg && arg->v)
     67 -		selmon->lt[selmon->sellt] = (Layout *)arg->v;
     68 +		selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag] = (Layout *)arg->v;
     69  	strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
     70  	if(selmon->sel)
     71  		arrange(selmon);
     72 @@ -1468,13 +1473,15 @@
     73  	f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
     74  	if(f < 0.1 || f > 0.9)
     75  		return;
     76 -	selmon->mfact = f;
     77 +	selmon->mfact = selmon->mfacts[selmon->curtag] = f;
     78  	arrange(selmon);
     79  }
     80  
     81  void
     82  setup(void) {
     83  	XSetWindowAttributes wa;
     84 +	Monitor *m;
     85 +	unsigned int i;
     86  
     87  	/* clean up any zombies immediately */
     88  	sigchld(0);
     89 @@ -1509,7 +1516,27 @@
     90  	XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
     91  	if(!dc.font.set)
     92  		XSetFont(dpy, dc.gc, dc.font.xfont->fid);
     93 +	/* init tags */
     94 +	for(m = mons; m; m = m->next)
     95 +		m->curtag = m->prevtag = 1;
     96 +	/* init mfacts */
     97 +	for(m = mons; m; m = m->next) {
     98 +		for(i=0; i < LENGTH(tags) + 1 ; i++) {
     99 +			m->mfacts[i] = m->mfact;
    100 +		}
    101 +	}
    102 +	/* init layouts */
    103 +	for(m = mons; m; m = m->next) {
    104 +		for(i=0; i < LENGTH(tags) + 1; i++) {
    105 +			m->lts[i] = &layouts[0];
    106 +		}
    107 +	}
    108  	/* init bars */
    109 +	for(m = mons; m; m = m->next) {
    110 +		for(i=0; i < LENGTH(tags) + 1; i++) {
    111 +			m->showbars[i] = m->showbar;
    112 +		}
    113 +	}
    114  	updatebars();
    115  	updatestatus();
    116  	/* EWMH support per view */
    117 @@ -1620,7 +1647,7 @@
    118  
    119  void
    120  togglebar(const Arg *arg) {
    121 -	selmon->showbar = !selmon->showbar;
    122 +	selmon->showbar = selmon->showbars[selmon->curtag] = !selmon->showbar;
    123  	updatebarpos(selmon);
    124  	XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
    125  	arrange(selmon);
    126 @@ -1640,12 +1667,27 @@
    127  void
    128  toggletag(const Arg *arg) {
    129  	unsigned int newtags;
    130 +	unsigned int i;
    131  
    132  	if(!selmon->sel)
    133  		return;
    134  	newtags = selmon->sel->tags ^ (arg->ui & TAGMASK);
    135  	if(newtags) {
    136  		selmon->sel->tags = newtags;
    137 +		if(newtags == ~0) {
    138 +			selmon->prevtag = selmon->curtag;
    139 +			selmon->curtag = 0;
    140 +		}
    141 +		if(!(newtags & 1 << (selmon->curtag - 1))) {
    142 +			selmon->prevtag = selmon->curtag;
    143 +			for (i=0; !(newtags & 1 << i); i++);
    144 +			selmon->curtag = i + 1;
    145 +		}
    146 +		selmon->sel->tags = newtags;
    147 +		selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag];
    148 +		selmon->mfact = selmon->mfacts[selmon->curtag];
    149 +		if (selmon->showbar != selmon->showbars[selmon->curtag])
    150 +			togglebar(NULL);
    151  		arrange(selmon);
    152  	}
    153  }
    154 @@ -1912,11 +1954,29 @@
    155  
    156  void
    157  view(const Arg *arg) {
    158 +	unsigned int i;
    159 +
    160  	if((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
    161  		return;
    162  	selmon->seltags ^= 1; /* toggle sel tagset */
    163 -	if(arg->ui & TAGMASK)
    164 +	if(arg->ui & TAGMASK) {
    165  		selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
    166 +		selmon->prevtag = selmon->curtag;
    167 +		if(arg->ui == ~0)
    168 +			selmon->curtag = 0;
    169 +		else {
    170 +			for (i=0; !(arg->ui & 1 << i); i++);
    171 +			selmon->curtag = i + 1;
    172 +		}
    173 +	} else {
    174 +		selmon->prevtag= selmon->curtag ^ selmon->prevtag;
    175 +		selmon->curtag^= selmon->prevtag;
    176 +		selmon->prevtag= selmon->curtag ^ selmon->prevtag;
    177 +	}
    178 +	selmon->lt[selmon->sellt]= selmon->lts[selmon->curtag];
    179 +	selmon->mfact = selmon->mfacts[selmon->curtag];
    180 +	if(selmon->showbar != selmon->showbars[selmon->curtag])
    181 +		togglebar(NULL);
    182  	arrange(selmon);
    183  }
    184