gaps.c (2257B)
1 /* Settings */ 2 static int enablegaps = 1; 3 4 static void 5 setgaps(int oh, int ov, int ih, int iv) 6 { 7 if (oh < 0) oh = 0; 8 if (ov < 0) ov = 0; 9 if (ih < 0) ih = 0; 10 if (iv < 0) iv = 0; 11 12 selmon->gappoh = oh; 13 selmon->gappov = ov; 14 selmon->gappih = ih; 15 selmon->gappiv = iv; 16 arrange(selmon); 17 } 18 19 static void 20 togglegaps(const Arg *arg) 21 { 22 enablegaps = !enablegaps; 23 arrange(NULL); 24 } 25 26 static void 27 defaultgaps(const Arg *arg) 28 { 29 setgaps(gappoh, gappov, gappih, gappiv); 30 } 31 32 static void 33 incrgaps(const Arg *arg) 34 { 35 setgaps(selmon->gappoh + arg->i, 36 selmon->gappov + arg->i, 37 selmon->gappih + arg->i, 38 selmon->gappiv + arg->i); 39 } 40 41 static void 42 incrigaps(const Arg *arg) 43 { 44 setgaps(selmon->gappoh, 45 selmon->gappov, 46 selmon->gappih + arg->i, 47 selmon->gappiv + arg->i); 48 } 49 50 static void 51 incrogaps(const Arg *arg) 52 { 53 setgaps(selmon->gappoh + arg->i, 54 selmon->gappov + arg->i, 55 selmon->gappih, 56 selmon->gappiv); 57 } 58 59 static void 60 getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc) 61 { 62 unsigned int n, oe, ie; 63 oe = ie = enablegaps; 64 Client *c; 65 66 for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); 67 68 if (smartgaps && n == 1) { 69 oe = 0; /* outer gaps disabled when only one client */ 70 } 71 72 *oh = m->gappoh*oe; /* outer horizontal gap */ 73 *ov = m->gappov*oe; /* outer vertical gap */ 74 *ih = m->gappih*ie; /* inner horizontal gap */ 75 *iv = m->gappiv*ie; /* inner vertical gap */ 76 *nc = n; /* number of clients */ 77 } 78 79 static void 80 getfacts(Monitor *m, int msize, int ssize, float *mf, float *sf, int *mr, int *sr) 81 { 82 unsigned int n; 83 float mfacts, sfacts; 84 int mtotal = 0, stotal = 0; 85 Client *c; 86 87 for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); 88 mfacts = MIN(n, m->nmaster); 89 sfacts = n - m->nmaster; 90 91 for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) 92 if (n < m->nmaster) 93 mtotal += msize / mfacts; 94 else 95 stotal += ssize / sfacts; 96 97 *mf = mfacts; /* total factor of master area */ 98 *sf = sfacts; /* total factor of stack area */ 99 *mr = msize - mtotal; /* the remainder (rest) of pixels after an even master split */ 100 *sr = ssize - stotal; /* the remainder (rest) of pixels after an even stack split */ 101 }