sites

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

dwm-5.8.2-pertag_without_bar.diff (4342B)


      1 diff --git a/dwm.c b/dwm.c
      2 --- a/dwm.c
      3 +++ b/dwm.c
      4 @@ -122,26 +122,6 @@ typedef struct {
      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 @@ -278,6 +258,30 @@ static Window root;
     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 +};
     58 +
     59  /* compile-time check if all tags fit into an unsigned int bit array. */
     60  struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
     61  
     62 @@ -609,6 +613,7 @@ configurerequest(XEvent *e) {
     63  Monitor *
     64  createmon(void) {
     65  	Monitor *m;
     66 +	unsigned int i;
     67  
     68  	if(!(m = (Monitor *)calloc(1, sizeof(Monitor))))
     69  		die("fatal: could not malloc() %u bytes\n", sizeof(Monitor));
     70 @@ -619,6 +624,14 @@ createmon(void) {
     71  	m->lt[0] = &layouts[0];
     72  	m->lt[1] = &layouts[1 % LENGTH(layouts)];
     73  	strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
     74 +
     75 +	/* pertag init */
     76 +	m->curtag = m->prevtag = 1;
     77 +	for(i=0; i < LENGTH(tags) + 1 ; i++) {
     78 +		m->mfacts[i] = mfact;
     79 +		m->lts[i] = &layouts[0];
     80 +	}
     81 +
     82  	return m;
     83  }
     84  
     85 @@ -1486,7 +1499,7 @@ setlayout(const Arg *arg) {
     86  	if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
     87  		selmon->sellt ^= 1;
     88  	if(arg && arg->v)
     89 -		selmon->lt[selmon->sellt] = (Layout *)arg->v;
     90 +		selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag] = (Layout *)arg->v;
     91  	strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
     92  	if(selmon->sel)
     93  		arrange(selmon);
     94 @@ -1504,7 +1517,7 @@ setmfact(const Arg *arg) {
     95  	f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0;
     96  	if(f < 0.1 || f > 0.9)
     97  		return;
     98 -	selmon->mfact = f;
     99 +	selmon->mfact = selmon->mfacts[selmon->curtag] = f;
    100  	arrange(selmon);
    101  }
    102  
    103 @@ -1547,7 +1560,6 @@ setup(void) {
    104  	XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
    105  	if(!dc.font.set)
    106  		XSetFont(dpy, dc.gc, dc.font.xfont->fid);
    107 -	/* init bars */
    108  	updatebars();
    109  	updatestatus();
    110  	/* EWMH support per view */
    111 @@ -1678,12 +1690,25 @@ togglefloating(const Arg *arg) {
    112  void
    113  toggletag(const Arg *arg) {
    114  	unsigned int newtags;
    115 +	unsigned int i;
    116  
    117  	if(!selmon->sel)
    118  		return;
    119  	newtags = selmon->sel->tags ^ (arg->ui & TAGMASK);
    120  	if(newtags) {
    121  		selmon->sel->tags = newtags;
    122 +		if(newtags == ~0) {
    123 +			selmon->prevtag = selmon->curtag;
    124 +			selmon->curtag = 0;
    125 +		}
    126 +		if(!(newtags & 1 << (selmon->curtag - 1))) {
    127 +			selmon->prevtag = selmon->curtag;
    128 +			for (i=0; !(newtags & 1 << i); i++);
    129 +			selmon->curtag = i + 1;
    130 +		}
    131 +		selmon->sel->tags = newtags;
    132 +		selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag];
    133 +		selmon->mfact = selmon->mfacts[selmon->curtag];
    134  		arrange(selmon);
    135  	}
    136  }
    137 @@ -1950,11 +1975,27 @@ updatewmhints(Client *c) {
    138  
    139  void
    140  view(const Arg *arg) {
    141 +	unsigned int i;
    142 +
    143  	if((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
    144  		return;
    145  	selmon->seltags ^= 1; /* toggle sel tagset */
    146 -	if(arg->ui & TAGMASK)
    147 +	if(arg->ui & TAGMASK) {
    148  		selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
    149 +		selmon->prevtag = selmon->curtag;
    150 +		if(arg->ui == ~0)
    151 +			selmon->curtag = 0;
    152 +		else {
    153 +			for (i=0; !(arg->ui & 1 << i); i++);
    154 +			selmon->curtag = i + 1;
    155 +		}
    156 +	} else {
    157 +		selmon->prevtag= selmon->curtag ^ selmon->prevtag;
    158 +		selmon->curtag^= selmon->prevtag;
    159 +		selmon->prevtag= selmon->curtag ^ selmon->prevtag;
    160 +	}
    161 +	selmon->lt[selmon->sellt]= selmon->lts[selmon->curtag];
    162 +	selmon->mfact = selmon->mfacts[selmon->curtag];
    163  	arrange(selmon);
    164  }
    165