dwm

Kris's build of dwm
git clone git clone https://git.krisyotam.com/krisyotam/dwm.git
Log | Files | Refs | README | LICENSE

scratchpad.c (1602B)


      1 void
      2 removescratch(const Arg *arg)
      3 {
      4 	Client *c = selmon->sel;
      5 	if (!c)
      6 		return;
      7 	unsigned int scratchtag = SPTAG(arg->ui);
      8 	c->tags = c->mon->tagset[c->mon->seltags] ^ scratchtag;
      9 	arrange(c->mon);
     10 }
     11 
     12 void
     13 setscratch(const Arg *arg)
     14 {
     15 	Client *c = selmon->sel;
     16 	if (!c)
     17 		return;
     18 	unsigned int scratchtag = SPTAG(arg->ui);
     19 	c->tags = scratchtag;
     20 	arrange(c->mon);
     21 }
     22 
     23 void
     24 togglescratch(const Arg *arg)
     25 {
     26 	Client *c = NULL, *next = NULL, *found = NULL;
     27 	Monitor *mon;
     28 	unsigned int scratchtag = SPTAG(arg->ui);
     29 	unsigned int newtagset = 0;
     30 	int nh = 0, nw = 0;
     31 	Arg sparg = {.v = scratchpads[arg->ui].cmd};
     32 
     33 	for (mon = mons; mon; mon = mon->next) {
     34 		for (c = mon->clients; c; c = next) {
     35 			next = c->next;
     36 			if (!(c->tags & scratchtag))
     37 				continue;
     38 
     39 			found = c;
     40 
     41 			if (HIDDEN(c)) {
     42 				XMapWindow(dpy, c->win);
     43 				setclientstate(c, NormalState);
     44 				newtagset = 0;
     45 			} else
     46 				newtagset = selmon->tagset[selmon->seltags] ^ scratchtag;
     47 
     48 			if (c->mon != selmon) {
     49 				if (c->mon->tagset[c->mon->seltags] & SPTAGMASK)
     50 					c->mon->tagset[c->mon->seltags] ^= scratchtag;
     51 				if (c->w > selmon->ww)
     52 					nw = selmon->ww - c->bw * 2;
     53 				if (c->h > selmon->wh)
     54 					nh = selmon->wh - c->bw * 2;
     55 				if (nw > 0 || nh > 0)
     56 					resizeclient(c, c->x, c->y, nw ? nw : c->w, nh ? nh : c->h);
     57 				sendmon(c, selmon);
     58 			}
     59 		}
     60 	}
     61 
     62 	if (found) {
     63 		if (newtagset) {
     64 			selmon->tagset[selmon->seltags] = newtagset;
     65 			arrange(selmon);
     66 			focus(NULL);
     67 		}
     68 		if (ISVISIBLE(found)) {
     69 			focus(found);
     70 			restack(selmon);
     71 		}
     72 	} else {
     73 		selmon->tagset[selmon->seltags] |= scratchtag;
     74 		spawn(&sparg);
     75 	}
     76 }
     77