My build of dwm
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 

149 lignes
4.8 KiB

  1. diff --git a/config.def.h b/config.def.h
  2. index 1c0b587..b172f63 100644
  3. --- a/config.def.h
  4. +++ b/config.def.h
  5. @@ -2,6 +2,7 @@
  6. /* appearance */
  7. static const unsigned int borderpx = 1; /* border pixel of windows */
  8. +static const Gap default_gap = {.isgap = 1, .realgap = 10, .gappx = 10};
  9. static const unsigned int snap = 32; /* snap pixel */
  10. static const int showbar = 1; /* 0 means no bar */
  11. static const int topbar = 1; /* 0 means bottom bar */
  12. @@ -84,6 +85,10 @@ static Key keys[] = {
  13. { MODKEY, XK_period, focusmon, {.i = +1 } },
  14. { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
  15. { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
  16. + { MODKEY, XK_minus, setgaps, {.i = -5 } },
  17. + { MODKEY, XK_equal, setgaps, {.i = +5 } },
  18. + { MODKEY|ShiftMask, XK_minus, setgaps, {.i = GAP_RESET } },
  19. + { MODKEY|ShiftMask, XK_equal, setgaps, {.i = GAP_TOGGLE} },
  20. TAGKEYS( XK_1, 0)
  21. TAGKEYS( XK_2, 1)
  22. TAGKEYS( XK_3, 2)
  23. diff --git a/dwm.c b/dwm.c
  24. index 664c527..25bc9b7 100644
  25. --- a/dwm.c
  26. +++ b/dwm.c
  27. @@ -57,6 +57,9 @@
  28. #define TAGMASK ((1 << LENGTH(tags)) - 1)
  29. #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
  30. +#define GAP_TOGGLE 100
  31. +#define GAP_RESET 0
  32. +
  33. /* enums */
  34. enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
  35. enum { SchemeNorm, SchemeSel }; /* color schemes */
  36. @@ -111,6 +114,12 @@ typedef struct {
  37. void (*arrange)(Monitor *);
  38. } Layout;
  39. +typedef struct {
  40. + int isgap;
  41. + int realgap;
  42. + int gappx;
  43. +} Gap;
  44. +
  45. struct Monitor {
  46. char ltsymbol[16];
  47. float mfact;
  48. @@ -119,6 +128,7 @@ struct Monitor {
  49. int by; /* bar geometry */
  50. int mx, my, mw, mh; /* screen size */
  51. int wx, wy, ww, wh; /* window area */
  52. + Gap *gap;
  53. unsigned int seltags;
  54. unsigned int sellt;
  55. unsigned int tagset[2];
  56. @@ -169,6 +179,7 @@ static void focus(Client *c);
  57. static void focusin(XEvent *e);
  58. static void focusmon(const Arg *arg);
  59. static void focusstack(const Arg *arg);
  60. +static void gap_copy(Gap *to, const Gap *from);
  61. static Atom getatomprop(Client *c, Atom prop);
  62. static int getrootptr(int *x, int *y);
  63. static long getstate(Window w);
  64. @@ -200,6 +211,7 @@ static void sendmon(Client *c, Monitor *m);
  65. static void setclientstate(Client *c, long state);
  66. static void setfocus(Client *c);
  67. static void setfullscreen(Client *c, int fullscreen);
  68. +static void setgaps(const Arg *arg);
  69. static void setlayout(const Arg *arg);
  70. static void setmfact(const Arg *arg);
  71. static void setup(void);
  72. @@ -639,6 +651,8 @@ createmon(void)
  73. m->nmaster = nmaster;
  74. m->showbar = showbar;
  75. m->topbar = topbar;
  76. + m->gap = malloc(sizeof(Gap));
  77. + gap_copy(m->gap, &default_gap);
  78. m->lt[0] = &layouts[0];
  79. m->lt[1] = &layouts[1 % LENGTH(layouts)];
  80. strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
  81. @@ -1498,6 +1512,35 @@ setfullscreen(Client *c, int fullscreen)
  82. }
  83. }
  84. +void
  85. +gap_copy(Gap *to, const Gap *from)
  86. +{
  87. + to->isgap = from->isgap;
  88. + to->realgap = from->realgap;
  89. + to->gappx = from->gappx;
  90. +}
  91. +
  92. +void
  93. +setgaps(const Arg *arg)
  94. +{
  95. + Gap *p = selmon->gap;
  96. + switch(arg->i)
  97. + {
  98. + case GAP_TOGGLE:
  99. + p->isgap = 1 - p->isgap;
  100. + break;
  101. + case GAP_RESET:
  102. + gap_copy(p, &default_gap);
  103. + break;
  104. + default:
  105. + p->realgap += arg->i;
  106. + p->isgap = 1;
  107. + }
  108. + p->realgap = MAX(p->realgap, 0);
  109. + p->gappx = p->realgap * p->isgap;
  110. + arrange(selmon);
  111. +}
  112. +
  113. void
  114. setlayout(const Arg *arg)
  115. {
  116. @@ -1684,18 +1727,18 @@ tile(Monitor *m)
  117. if (n > m->nmaster)
  118. mw = m->nmaster ? m->ww * m->mfact : 0;
  119. else
  120. - mw = m->ww;
  121. - for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
  122. + mw = m->ww - m->gap->gappx;
  123. + for (i = 0, my = ty = m->gap->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
  124. if (i < m->nmaster) {
  125. - h = (m->wh - my) / (MIN(n, m->nmaster) - i);
  126. - resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
  127. - if (my + HEIGHT(c) < m->wh)
  128. - my += HEIGHT(c);
  129. + h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gap->gappx;
  130. + resize(c, m->wx + m->gap->gappx, m->wy + my, mw - (2*c->bw) - m->gap->gappx, h - (2*c->bw), 0);
  131. + if (my + HEIGHT(c) + m->gap->gappx < m->wh)
  132. + my += HEIGHT(c) + m->gap->gappx;
  133. } else {
  134. - h = (m->wh - ty) / (n - i);
  135. - resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
  136. - if (ty + HEIGHT(c) < m->wh)
  137. - ty += HEIGHT(c);
  138. + h = (m->wh - ty) / (n - i) - m->gap->gappx;
  139. + resize(c, m->wx + mw + m->gap->gappx, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gap->gappx, h - (2*c->bw), 0);
  140. + if (ty + HEIGHT(c) + m->gap->gappx < m->wh)
  141. + ty += HEIGHT(c) + m->gap->gappx;
  142. }
  143. }