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