Another copy of my dotfiles. Because I don't completely trust GitHub.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

192 lines
4.0 KiB

  1. /* Settings */
  2. #if !PERTAG_PATCH
  3. static int enablegaps = 1;
  4. #endif // PERTAG_PATCH
  5. static void
  6. setgaps(int oh, int ov, int ih, int iv)
  7. {
  8. if (oh < 0) oh = 0;
  9. if (ov < 0) ov = 0;
  10. if (ih < 0) ih = 0;
  11. if (iv < 0) iv = 0;
  12. selmon->gappoh = oh;
  13. selmon->gappov = ov;
  14. selmon->gappih = ih;
  15. selmon->gappiv = iv;
  16. arrange(selmon);
  17. }
  18. #if IPC_PATCH || DWMC_PATCH
  19. /* External function that takes one integer and splits it
  20. * into four gap values:
  21. * - outer horizontal (oh)
  22. * - outer vertical (ov)
  23. * - inner horizontal (ih)
  24. * - inner vertical (iv)
  25. *
  26. * Each value is represented as one byte with the uppermost
  27. * bit of each byte indicating whether or not to keep the
  28. * current value.
  29. *
  30. * Example:
  31. *
  32. * 10000000 10000000 00001111 00001111
  33. * | | | |
  34. * + keep oh + keep ov + ih 15px + iv 15px
  35. *
  36. * This gives an int of:
  37. * 10000000100000000000111100001111 = 2155876111
  38. *
  39. * Thus this command should set inner gaps to 15:
  40. * xsetroot -name "fsignal:setgaps i 2155876111"
  41. */
  42. static void
  43. setgapsex(const Arg *arg)
  44. {
  45. int oh = selmon->gappoh;
  46. int ov = selmon->gappov;
  47. int ih = selmon->gappih;
  48. int iv = selmon->gappiv;
  49. if (!(arg->i & (1 << 31)))
  50. oh = (arg->i & 0x7f000000) >> 24;
  51. if (!(arg->i & (1 << 23)))
  52. ov = (arg->i & 0x7f0000) >> 16;
  53. if (!(arg->i & (1 << 15)))
  54. ih = (arg->i & 0x7f00) >> 8;
  55. if (!(arg->i & (1 << 7)))
  56. iv = (arg->i & 0x7f);
  57. /* Auto enable gaps if disabled */
  58. #if PERTAG_PATCH
  59. if (!selmon->pertag->enablegaps[selmon->pertag->curtag])
  60. selmon->pertag->enablegaps[selmon->pertag->curtag] = 1;
  61. #else
  62. if (!enablegaps)
  63. enablegaps = 1;
  64. #endif // PERTAG_PATCH
  65. setgaps(oh, ov, ih, iv);
  66. }
  67. #endif // IPC_PATCH | DWMC_PATCH
  68. static void
  69. togglegaps(const Arg *arg)
  70. {
  71. #if PERTAG_PATCH
  72. selmon->pertag->enablegaps[selmon->pertag->curtag] = !selmon->pertag->enablegaps[selmon->pertag->curtag];
  73. #else
  74. enablegaps = !enablegaps;
  75. #endif // PERTAG_PATCH
  76. arrange(NULL);
  77. }
  78. static void
  79. defaultgaps(const Arg *arg)
  80. {
  81. setgaps(gappoh, gappov, gappih, gappiv);
  82. }
  83. static void
  84. incrgaps(const Arg *arg)
  85. {
  86. setgaps(
  87. selmon->gappoh + arg->i,
  88. selmon->gappov + arg->i,
  89. selmon->gappih + arg->i,
  90. selmon->gappiv + arg->i
  91. );
  92. }
  93. static void
  94. incrigaps(const Arg *arg)
  95. {
  96. setgaps(
  97. selmon->gappoh,
  98. selmon->gappov,
  99. selmon->gappih + arg->i,
  100. selmon->gappiv + arg->i
  101. );
  102. }
  103. static void
  104. incrogaps(const Arg *arg)
  105. {
  106. setgaps(
  107. selmon->gappoh + arg->i,
  108. selmon->gappov + arg->i,
  109. selmon->gappih,
  110. selmon->gappiv
  111. );
  112. }
  113. static void
  114. incrohgaps(const Arg *arg)
  115. {
  116. setgaps(
  117. selmon->gappoh + arg->i,
  118. selmon->gappov,
  119. selmon->gappih,
  120. selmon->gappiv
  121. );
  122. }
  123. static void
  124. incrovgaps(const Arg *arg)
  125. {
  126. setgaps(
  127. selmon->gappoh,
  128. selmon->gappov + arg->i,
  129. selmon->gappih,
  130. selmon->gappiv
  131. );
  132. }
  133. static void
  134. incrihgaps(const Arg *arg)
  135. {
  136. setgaps(
  137. selmon->gappoh,
  138. selmon->gappov,
  139. selmon->gappih + arg->i,
  140. selmon->gappiv
  141. );
  142. }
  143. static void
  144. incrivgaps(const Arg *arg)
  145. {
  146. setgaps(
  147. selmon->gappoh,
  148. selmon->gappov,
  149. selmon->gappih,
  150. selmon->gappiv + arg->i
  151. );
  152. }
  153. #if DRAGMFACT_PATCH || CENTEREDMASTER_LAYOUT || CENTEREDFLOATINGMASTER_LAYOUT || COLUMNS_LAYOUT || DECK_LAYOUT || FIBONACCI_DWINDLE_LAYOUT || FIBONACCI_SPIRAL_LAYOUT || GAPPLESSGRID_LAYOUT || NROWGRID_LAYOUT || HORIZGRID_LAYOUT || BSTACK_LAYOUT || BSTACKHORIZ_LAYOUT || GRIDMODE_LAYOUT || FLEXTILE_DELUXE_LAYOUT || TILE_LAYOUT || (VANITYGAPS_MONOCLE_PATCH && MONOCLE_LAYOUT)
  154. static void
  155. getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc)
  156. {
  157. unsigned int n, oe, ie;
  158. #if PERTAG_PATCH
  159. oe = ie = selmon->pertag->enablegaps[selmon->pertag->curtag];
  160. #else
  161. oe = ie = enablegaps;
  162. #endif // PERTAG_PATCH
  163. Client *c;
  164. for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
  165. if (smartgaps && n == 1) {
  166. oe = 0; // outer gaps disabled when only one client
  167. }
  168. *oh = m->gappoh*oe; // outer horizontal gap
  169. *ov = m->gappov*oe; // outer vertical gap
  170. *ih = m->gappih*ie; // inner horizontal gap
  171. *iv = m->gappiv*ie; // inner vertical gap
  172. *nc = n; // number of clients
  173. }
  174. #endif