-
Notifications
You must be signed in to change notification settings - Fork 0
/
yajl_dumps.c
351 lines (309 loc) · 8.2 KB
/
yajl_dumps.c
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
#include "yajl_dumps.h"
#include <stdint.h>
int
dump_tag(yajl_gen gen, const char *name, const int tag_mask)
{
// clang-format off
YMAP(
YSTR("bit_mask"); YINT(tag_mask);
YSTR("name"); YSTR(name);
)
// clang-format on
return 0;
}
int
dump_tags(yajl_gen gen, const char *tags[], int tags_len)
{
// clang-format off
YARR(
for (int i = 0; i < tags_len; i++)
dump_tag(gen, tags[i], 1 << i);
)
// clang-format on
return 0;
}
int
dump_client(yajl_gen gen, Client *c)
{
// clang-format off
YMAP(
YSTR("name"); YSTR(c->name);
YSTR("tags"); YINT(c->tags);
YSTR("window_id"); YINT(c->win);
YSTR("monitor_number"); YINT(c->mon->num);
YSTR("geometry"); YMAP(
YSTR("current"); YMAP (
YSTR("x"); YINT(c->x);
YSTR("y"); YINT(c->y);
YSTR("width"); YINT(c->w);
YSTR("height"); YINT(c->h);
)
YSTR("old"); YMAP(
YSTR("x"); YINT(c->oldx);
YSTR("y"); YINT(c->oldy);
YSTR("width"); YINT(c->oldw);
YSTR("height"); YINT(c->oldh);
)
)
YSTR("size_hints"); YMAP(
YSTR("base"); YMAP(
YSTR("width"); YINT(c->basew);
YSTR("height"); YINT(c->baseh);
)
YSTR("step"); YMAP(
YSTR("width"); YINT(c->incw);
YSTR("height"); YINT(c->inch);
)
YSTR("max"); YMAP(
YSTR("width"); YINT(c->maxw);
YSTR("height"); YINT(c->maxh);
)
YSTR("min"); YMAP(
YSTR("width"); YINT(c->minw);
YSTR("height"); YINT(c->minh);
)
YSTR("aspect_ratio"); YMAP(
YSTR("min"); YDOUBLE(c->mina);
YSTR("max"); YDOUBLE(c->maxa);
)
)
YSTR("border_width"); YMAP(
YSTR("current"); YINT(c->bw);
YSTR("old"); YINT(c->oldbw);
)
YSTR("states"); YMAP(
YSTR("is_fixed"); YBOOL(c->isfixed);
YSTR("is_floating"); YBOOL(c->isfloating);
YSTR("is_urgent"); YBOOL(c->isurgent);
YSTR("never_focus"); YBOOL(c->neverfocus);
YSTR("old_state"); YBOOL(c->oldstate);
YSTR("is_fullscreen"); YBOOL(c->isfullscreen);
)
)
// clang-format on
return 0;
}
int
dump_monitor(yajl_gen gen, Monitor *mon, int is_selected)
{
// clang-format off
YMAP(
YSTR("master_factor"); YDOUBLE(mon->mfact);
YSTR("num_master"); YINT(mon->nmaster);
YSTR("num"); YINT(mon->num);
YSTR("is_selected"); YBOOL(is_selected);
YSTR("monitor_geometry"); YMAP(
YSTR("x"); YINT(mon->mx);
YSTR("y"); YINT(mon->my);
YSTR("width"); YINT(mon->mw);
YSTR("height"); YINT(mon->mh);
)
YSTR("window_geometry"); YMAP(
YSTR("x"); YINT(mon->wx);
YSTR("y"); YINT(mon->wy);
YSTR("width"); YINT(mon->ww);
YSTR("height"); YINT(mon->wh);
)
YSTR("tagset"); YMAP(
YSTR("current"); YINT(mon->tagset[mon->seltags]);
YSTR("old"); YINT(mon->tagset[mon->seltags ^ 1]);
)
YSTR("tag_state"); dump_tag_state(gen, mon->tagstate);
YSTR("clients"); YMAP(
YSTR("selected"); YINT(mon->sel ? mon->sel->win : 0);
YSTR("stack"); YARR(
for (Client* c = mon->stack; c; c = c->snext)
YINT(c->win);
)
YSTR("all"); YARR(
for (Client* c = mon->clients; c; c = c->next)
YINT(c->win);
)
)
YSTR("layout"); YMAP(
YSTR("symbol"); YMAP(
YSTR("current"); YSTR(mon->ltsymbol);
YSTR("old"); YSTR(mon->lastltsymbol);
)
YSTR("address"); YMAP(
YSTR("current"); YINT((uintptr_t)mon->lt[mon->sellt]);
YSTR("old"); YINT((uintptr_t)mon->lt[mon->sellt ^ 1]);
)
)
YSTR("bar"); YMAP(
YSTR("y"); YINT(mon->by);
YSTR("is_shown"); YBOOL(mon->showbar);
YSTR("is_top"); YBOOL(mon->topbar);
YSTR("window_id"); YINT(mon->barwin);
)
)
// clang-format on
return 0;
}
int
dump_monitors(yajl_gen gen, Monitor *mons, Monitor *selmon)
{
// clang-format off
YARR(
for (Monitor *mon = mons; mon; mon = mon->next) {
if (mon == selmon)
dump_monitor(gen, mon, 1);
else
dump_monitor(gen, mon, 0);
}
)
// clang-format on
return 0;
}
int
dump_layouts(yajl_gen gen, const Layout layouts[], const int layouts_len)
{
// clang-format off
YARR(
for (int i = 0; i < layouts_len; i++) {
YMAP(
// Check for a NULL pointer. The cycle layouts patch adds an entry at
// the end of the layouts array with a NULL pointer for the symbol
YSTR("symbol"); YSTR((layouts[i].symbol ? layouts[i].symbol : ""));
YSTR("address"); YINT((uintptr_t)(layouts + i));
)
}
)
// clang-format on
return 0;
}
int
dump_tag_state(yajl_gen gen, TagState state)
{
// clang-format off
YMAP(
YSTR("selected"); YINT(state.selected);
YSTR("occupied"); YINT(state.occupied);
YSTR("urgent"); YINT(state.urgent);
)
// clang-format on
return 0;
}
int
dump_tag_event(yajl_gen gen, int mon_num, TagState old_state,
TagState new_state)
{
// clang-format off
YMAP(
YSTR("tag_change_event"); YMAP(
YSTR("monitor_number"); YINT(mon_num);
YSTR("old_state"); dump_tag_state(gen, old_state);
YSTR("new_state"); dump_tag_state(gen, new_state);
)
)
// clang-format on
return 0;
}
int
dump_client_focus_change_event(yajl_gen gen, Client *old_client,
Client *new_client, int mon_num)
{
// clang-format off
YMAP(
YSTR("client_focus_change_event"); YMAP(
YSTR("monitor_number"); YINT(mon_num);
YSTR("old_win_id"); old_client == NULL ? YNULL() : YINT(old_client->win);
YSTR("new_win_id"); new_client == NULL ? YNULL() : YINT(new_client->win);
)
)
// clang-format on
return 0;
}
int
dump_layout_change_event(yajl_gen gen, const int mon_num,
const char *old_symbol, const Layout *old_layout,
const char *new_symbol, const Layout *new_layout)
{
// clang-format off
YMAP(
YSTR("layout_change_event"); YMAP(
YSTR("monitor_number"); YINT(mon_num);
YSTR("old_symbol"); YSTR(old_symbol);
YSTR("old_address"); YINT((uintptr_t)old_layout);
YSTR("new_symbol"); YSTR(new_symbol);
YSTR("new_address"); YINT((uintptr_t)new_layout);
)
)
// clang-format on
return 0;
}
int
dump_monitor_focus_change_event(yajl_gen gen, const int last_mon_num,
const int new_mon_num)
{
// clang-format off
YMAP(
YSTR("monitor_focus_change_event"); YMAP(
YSTR("old_monitor_number"); YINT(last_mon_num);
YSTR("new_monitor_number"); YINT(new_mon_num);
)
)
// clang-format on
return 0;
}
int
dump_focused_title_change_event(yajl_gen gen, const int mon_num,
const Window client_id, const char *old_name,
const char *new_name)
{
// clang-format off
YMAP(
YSTR("focused_title_change_event"); YMAP(
YSTR("monitor_number"); YINT(mon_num);
YSTR("client_window_id"); YINT(client_id);
YSTR("old_name"); YSTR(old_name);
YSTR("new_name"); YSTR(new_name);
)
)
// clang-format on
return 0;
}
int
dump_client_state(yajl_gen gen, const ClientState *state)
{
// clang-format off
YMAP(
YSTR("old_state"); YBOOL(state->oldstate);
YSTR("is_fixed"); YBOOL(state->isfixed);
YSTR("is_floating"); YBOOL(state->isfloating);
YSTR("is_fullscreen"); YBOOL(state->isfullscreen);
YSTR("is_urgent"); YBOOL(state->isurgent);
YSTR("never_focus"); YBOOL(state->neverfocus);
)
// clang-format on
return 0;
}
int
dump_focused_state_change_event(yajl_gen gen, const int mon_num,
const Window client_id,
const ClientState *old_state,
const ClientState *new_state)
{
// clang-format off
YMAP(
YSTR("focused_state_change_event"); YMAP(
YSTR("monitor_number"); YINT(mon_num);
YSTR("client_window_id"); YINT(client_id);
YSTR("old_state"); dump_client_state(gen, old_state);
YSTR("new_state"); dump_client_state(gen, new_state);
)
)
// clang-format on
return 0;
}
int
dump_error_message(yajl_gen gen, const char *reason)
{
// clang-format off
YMAP(
YSTR("result"); YSTR("error");
YSTR("reason"); YSTR(reason);
)
// clang-format on
return 0;
}