diff options
Diffstat (limited to 'sway/ipc-json.c')
-rw-r--r-- | sway/ipc-json.c | 216 |
1 files changed, 124 insertions, 92 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c index fceee84d..e422b24d 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c | |||
@@ -1,7 +1,11 @@ | |||
1 | #include <ctype.h> | ||
2 | #include <float.h> | ||
1 | #include <json.h> | 3 | #include <json.h> |
2 | #include <libevdev/libevdev.h> | 4 | #include <libevdev/libevdev.h> |
3 | #include <stdio.h> | 5 | #include <stdio.h> |
4 | #include <ctype.h> | 6 | #include <wlr/backend/libinput.h> |
7 | #include <wlr/types/wlr_output.h> | ||
8 | #include <xkbcommon/xkbcommon.h> | ||
5 | #include "config.h" | 9 | #include "config.h" |
6 | #include "log.h" | 10 | #include "log.h" |
7 | #include "sway/config.h" | 11 | #include "sway/config.h" |
@@ -13,16 +17,26 @@ | |||
13 | #include "sway/input/input-manager.h" | 17 | #include "sway/input/input-manager.h" |
14 | #include "sway/input/cursor.h" | 18 | #include "sway/input/cursor.h" |
15 | #include "sway/input/seat.h" | 19 | #include "sway/input/seat.h" |
16 | #include <wlr/backend/libinput.h> | ||
17 | #include <wlr/types/wlr_box.h> | ||
18 | #include <wlr/types/wlr_output.h> | ||
19 | #include <xkbcommon/xkbcommon.h> | ||
20 | #include "wlr-layer-shell-unstable-v1-protocol.h" | 20 | #include "wlr-layer-shell-unstable-v1-protocol.h" |
21 | #include "sway/desktop/idle_inhibit_v1.h" | 21 | #include "sway/desktop/idle_inhibit_v1.h" |
22 | 22 | ||
23 | static const int i3_output_id = INT32_MAX; | 23 | static const int i3_output_id = INT32_MAX; |
24 | static const int i3_scratch_id = INT32_MAX - 1; | 24 | static const int i3_scratch_id = INT32_MAX - 1; |
25 | 25 | ||
26 | static const char *ipc_json_node_type_description(enum sway_node_type node_type) { | ||
27 | switch (node_type) { | ||
28 | case N_ROOT: | ||
29 | return "root"; | ||
30 | case N_OUTPUT: | ||
31 | return "output"; | ||
32 | case N_WORKSPACE: | ||
33 | return "workspace"; | ||
34 | case N_CONTAINER: | ||
35 | return "con"; | ||
36 | } | ||
37 | return "none"; | ||
38 | } | ||
39 | |||
26 | static const char *ipc_json_layout_description(enum sway_container_layout l) { | 40 | static const char *ipc_json_layout_description(enum sway_container_layout l) { |
27 | switch (l) { | 41 | switch (l) { |
28 | case L_VERT: | 42 | case L_VERT: |
@@ -189,16 +203,22 @@ static json_object *ipc_json_create_empty_rect(void) { | |||
189 | return ipc_json_create_rect(&empty); | 203 | return ipc_json_create_rect(&empty); |
190 | } | 204 | } |
191 | 205 | ||
192 | static json_object *ipc_json_create_node(int id, char *name, | 206 | static json_object *ipc_json_create_node(int id, const char* type, char *name, |
193 | bool focused, json_object *focus, struct wlr_box *box) { | 207 | bool focused, json_object *focus, struct wlr_box *box) { |
194 | json_object *object = json_object_new_object(); | 208 | json_object *object = json_object_new_object(); |
195 | 209 | ||
196 | json_object_object_add(object, "id", json_object_new_int(id)); | 210 | json_object_object_add(object, "id", json_object_new_int(id)); |
197 | json_object_object_add(object, "name", | 211 | json_object_object_add(object, "type", json_object_new_string(type)); |
198 | name ? json_object_new_string(name) : NULL); | 212 | json_object_object_add(object, "orientation", |
199 | json_object_object_add(object, "rect", ipc_json_create_rect(box)); | 213 | json_object_new_string( |
214 | ipc_json_orientation_description(L_HORIZ))); | ||
215 | json_object_object_add(object, "percent", NULL); | ||
216 | json_object_object_add(object, "urgent", json_object_new_boolean(false)); | ||
217 | json_object_object_add(object, "marks", json_object_new_array()); | ||
200 | json_object_object_add(object, "focused", json_object_new_boolean(focused)); | 218 | json_object_object_add(object, "focused", json_object_new_boolean(focused)); |
201 | json_object_object_add(object, "focus", focus); | 219 | json_object_object_add(object, "layout", |
220 | json_object_new_string( | ||
221 | ipc_json_layout_description(L_HORIZ))); | ||
202 | 222 | ||
203 | // set default values to be compatible with i3 | 223 | // set default values to be compatible with i3 |
204 | json_object_object_add(object, "border", | 224 | json_object_object_add(object, "border", |
@@ -206,49 +226,63 @@ static json_object *ipc_json_create_node(int id, char *name, | |||
206 | ipc_json_border_description(B_NONE))); | 226 | ipc_json_border_description(B_NONE))); |
207 | json_object_object_add(object, "current_border_width", | 227 | json_object_object_add(object, "current_border_width", |
208 | json_object_new_int(0)); | 228 | json_object_new_int(0)); |
209 | json_object_object_add(object, "layout", | 229 | json_object_object_add(object, "rect", ipc_json_create_rect(box)); |
210 | json_object_new_string( | ||
211 | ipc_json_layout_description(L_HORIZ))); | ||
212 | json_object_object_add(object, "orientation", | ||
213 | json_object_new_string( | ||
214 | ipc_json_orientation_description(L_HORIZ))); | ||
215 | json_object_object_add(object, "percent", NULL); | ||
216 | json_object_object_add(object, "window_rect", ipc_json_create_empty_rect()); | ||
217 | json_object_object_add(object, "deco_rect", ipc_json_create_empty_rect()); | 230 | json_object_object_add(object, "deco_rect", ipc_json_create_empty_rect()); |
231 | json_object_object_add(object, "window_rect", ipc_json_create_empty_rect()); | ||
218 | json_object_object_add(object, "geometry", ipc_json_create_empty_rect()); | 232 | json_object_object_add(object, "geometry", ipc_json_create_empty_rect()); |
233 | json_object_object_add(object, "name", | ||
234 | name ? json_object_new_string(name) : NULL); | ||
219 | json_object_object_add(object, "window", NULL); | 235 | json_object_object_add(object, "window", NULL); |
220 | json_object_object_add(object, "urgent", json_object_new_boolean(false)); | ||
221 | json_object_object_add(object, "marks", json_object_new_array()); | ||
222 | json_object_object_add(object, "fullscreen_mode", json_object_new_int(0)); | ||
223 | json_object_object_add(object, "nodes", json_object_new_array()); | 236 | json_object_object_add(object, "nodes", json_object_new_array()); |
224 | json_object_object_add(object, "floating_nodes", json_object_new_array()); | 237 | json_object_object_add(object, "floating_nodes", json_object_new_array()); |
238 | json_object_object_add(object, "focus", focus); | ||
239 | json_object_object_add(object, "fullscreen_mode", json_object_new_int(0)); | ||
225 | json_object_object_add(object, "sticky", json_object_new_boolean(false)); | 240 | json_object_object_add(object, "sticky", json_object_new_boolean(false)); |
226 | 241 | ||
227 | return object; | 242 | return object; |
228 | } | 243 | } |
229 | 244 | ||
230 | static void ipc_json_describe_root(struct sway_root *root, json_object *object) { | 245 | static void ipc_json_describe_output(struct sway_output *output, |
231 | json_object_object_add(object, "type", json_object_new_string("root")); | 246 | json_object *object) { |
247 | struct wlr_output *wlr_output = output->wlr_output; | ||
248 | |||
249 | json_object_object_add(object, "primary", json_object_new_boolean(false)); | ||
250 | json_object_object_add(object, "make", | ||
251 | json_object_new_string(wlr_output->make ? wlr_output->make : "Unknown")); | ||
252 | json_object_object_add(object, "model", | ||
253 | json_object_new_string(wlr_output->model ? wlr_output->model : "Unknown")); | ||
254 | json_object_object_add(object, "serial", | ||
255 | json_object_new_string(wlr_output->serial ? wlr_output->serial : "Unknown")); | ||
256 | |||
257 | json_object *modes_array = json_object_new_array(); | ||
258 | struct wlr_output_mode *mode; | ||
259 | wl_list_for_each(mode, &wlr_output->modes, link) { | ||
260 | json_object *mode_object = json_object_new_object(); | ||
261 | json_object_object_add(mode_object, "width", | ||
262 | json_object_new_int(mode->width)); | ||
263 | json_object_object_add(mode_object, "height", | ||
264 | json_object_new_int(mode->height)); | ||
265 | json_object_object_add(mode_object, "refresh", | ||
266 | json_object_new_int(mode->refresh)); | ||
267 | json_object_array_add(modes_array, mode_object); | ||
268 | } | ||
269 | json_object_object_add(object, "modes", modes_array); | ||
232 | } | 270 | } |
233 | 271 | ||
234 | static void ipc_json_describe_output(struct sway_output *output, | 272 | static void ipc_json_describe_enabled_output(struct sway_output *output, |
235 | json_object *object) { | 273 | json_object *object) { |
274 | ipc_json_describe_output(output, object); | ||
275 | |||
236 | struct wlr_output *wlr_output = output->wlr_output; | 276 | struct wlr_output *wlr_output = output->wlr_output; |
237 | json_object_object_add(object, "type", json_object_new_string("output")); | ||
238 | json_object_object_add(object, "active", json_object_new_boolean(true)); | 277 | json_object_object_add(object, "active", json_object_new_boolean(true)); |
239 | json_object_object_add(object, "dpms", | 278 | json_object_object_add(object, "dpms", |
240 | json_object_new_boolean(wlr_output->enabled)); | 279 | json_object_new_boolean(wlr_output->enabled)); |
241 | json_object_object_add(object, "primary", json_object_new_boolean(false)); | 280 | json_object_object_add(object, "power", |
281 | json_object_new_boolean(wlr_output->enabled)); | ||
242 | json_object_object_add(object, "layout", json_object_new_string("output")); | 282 | json_object_object_add(object, "layout", json_object_new_string("output")); |
243 | json_object_object_add(object, "orientation", | 283 | json_object_object_add(object, "orientation", |
244 | json_object_new_string( | 284 | json_object_new_string( |
245 | ipc_json_orientation_description(L_NONE))); | 285 | ipc_json_orientation_description(L_NONE))); |
246 | json_object_object_add(object, "make", | ||
247 | json_object_new_string(wlr_output->make)); | ||
248 | json_object_object_add(object, "model", | ||
249 | json_object_new_string(wlr_output->model)); | ||
250 | json_object_object_add(object, "serial", | ||
251 | json_object_new_string(wlr_output->serial)); | ||
252 | json_object_object_add(object, "scale", | 286 | json_object_object_add(object, "scale", |
253 | json_object_new_double(wlr_output->scale)); | 287 | json_object_new_double(wlr_output->scale)); |
254 | json_object_object_add(object, "scale_filter", | 288 | json_object_object_add(object, "scale_filter", |
@@ -315,33 +349,14 @@ json_object *ipc_json_describe_disabled_output(struct sway_output *output) { | |||
315 | 349 | ||
316 | json_object *object = json_object_new_object(); | 350 | json_object *object = json_object_new_object(); |
317 | 351 | ||
352 | ipc_json_describe_output(output, object); | ||
353 | |||
318 | json_object_object_add(object, "type", json_object_new_string("output")); | 354 | json_object_object_add(object, "type", json_object_new_string("output")); |
319 | json_object_object_add(object, "name", | 355 | json_object_object_add(object, "name", |
320 | json_object_new_string(wlr_output->name)); | 356 | json_object_new_string(wlr_output->name)); |
321 | json_object_object_add(object, "active", json_object_new_boolean(false)); | 357 | json_object_object_add(object, "active", json_object_new_boolean(false)); |
322 | json_object_object_add(object, "dpms", json_object_new_boolean(false)); | 358 | json_object_object_add(object, "dpms", json_object_new_boolean(false)); |
323 | json_object_object_add(object, "primary", json_object_new_boolean(false)); | 359 | json_object_object_add(object, "power", json_object_new_boolean(false)); |
324 | json_object_object_add(object, "make", | ||
325 | json_object_new_string(wlr_output->make)); | ||
326 | json_object_object_add(object, "model", | ||
327 | json_object_new_string(wlr_output->model)); | ||
328 | json_object_object_add(object, "serial", | ||
329 | json_object_new_string(wlr_output->serial)); | ||
330 | |||
331 | json_object *modes_array = json_object_new_array(); | ||
332 | struct wlr_output_mode *mode; | ||
333 | wl_list_for_each(mode, &wlr_output->modes, link) { | ||
334 | json_object *mode_object = json_object_new_object(); | ||
335 | json_object_object_add(mode_object, "width", | ||
336 | json_object_new_int(mode->width)); | ||
337 | json_object_object_add(mode_object, "height", | ||
338 | json_object_new_int(mode->height)); | ||
339 | json_object_object_add(mode_object, "refresh", | ||
340 | json_object_new_int(mode->refresh)); | ||
341 | json_object_array_add(modes_array, mode_object); | ||
342 | } | ||
343 | |||
344 | json_object_object_add(object, "modes", modes_array); | ||
345 | 360 | ||
346 | json_object_object_add(object, "current_workspace", NULL); | 361 | json_object_object_add(object, "current_workspace", NULL); |
347 | 362 | ||
@@ -369,11 +384,9 @@ static json_object *ipc_json_describe_scratchpad_output(void) { | |||
369 | json_object_new_int(container->node.id)); | 384 | json_object_new_int(container->node.id)); |
370 | } | 385 | } |
371 | 386 | ||
372 | json_object *workspace = ipc_json_create_node(i3_scratch_id, | 387 | json_object *workspace = ipc_json_create_node(i3_scratch_id, "workspace", |
373 | "__i3_scratch", false, workspace_focus, &box); | 388 | "__i3_scratch", false, workspace_focus, &box); |
374 | json_object_object_add(workspace, "fullscreen_mode", json_object_new_int(1)); | 389 | json_object_object_add(workspace, "fullscreen_mode", json_object_new_int(1)); |
375 | json_object_object_add(workspace, "type", | ||
376 | json_object_new_string("workspace")); | ||
377 | 390 | ||
378 | // List all hidden scratchpad containers as floating nodes | 391 | // List all hidden scratchpad containers as floating nodes |
379 | json_object *floating_array = json_object_new_array(); | 392 | json_object *floating_array = json_object_new_array(); |
@@ -390,10 +403,8 @@ static json_object *ipc_json_describe_scratchpad_output(void) { | |||
390 | json_object *output_focus = json_object_new_array(); | 403 | json_object *output_focus = json_object_new_array(); |
391 | json_object_array_add(output_focus, json_object_new_int(i3_scratch_id)); | 404 | json_object_array_add(output_focus, json_object_new_int(i3_scratch_id)); |
392 | 405 | ||
393 | json_object *output = ipc_json_create_node(i3_output_id, | 406 | json_object *output = ipc_json_create_node(i3_output_id, "output", |
394 | "__i3", false, output_focus, &box); | 407 | "__i3", false, output_focus, &box); |
395 | json_object_object_add(output, "type", | ||
396 | json_object_new_string("output")); | ||
397 | json_object_object_add(output, "layout", | 408 | json_object_object_add(output, "layout", |
398 | json_object_new_string("output")); | 409 | json_object_new_string("output")); |
399 | 410 | ||
@@ -423,7 +434,6 @@ static void ipc_json_describe_workspace(struct sway_workspace *workspace, | |||
423 | json_object_object_add(object, "fullscreen_mode", json_object_new_int(1)); | 434 | json_object_object_add(object, "fullscreen_mode", json_object_new_int(1)); |
424 | json_object_object_add(object, "output", workspace->output ? | 435 | json_object_object_add(object, "output", workspace->output ? |
425 | json_object_new_string(workspace->output->wlr_output->name) : NULL); | 436 | json_object_new_string(workspace->output->wlr_output->name) : NULL); |
426 | json_object_object_add(object, "type", json_object_new_string("workspace")); | ||
427 | json_object_object_add(object, "urgent", | 437 | json_object_object_add(object, "urgent", |
428 | json_object_new_boolean(workspace->urgent)); | 438 | json_object_new_boolean(workspace->urgent)); |
429 | json_object_object_add(object, "representation", workspace->representation ? | 439 | json_object_object_add(object, "representation", workspace->representation ? |
@@ -448,30 +458,32 @@ static void ipc_json_describe_workspace(struct sway_workspace *workspace, | |||
448 | 458 | ||
449 | static void get_deco_rect(struct sway_container *c, struct wlr_box *deco_rect) { | 459 | static void get_deco_rect(struct sway_container *c, struct wlr_box *deco_rect) { |
450 | enum sway_container_layout parent_layout = container_parent_layout(c); | 460 | enum sway_container_layout parent_layout = container_parent_layout(c); |
451 | bool tab_or_stack = parent_layout == L_TABBED || parent_layout == L_STACKED; | 461 | list_t *siblings = container_get_siblings(c); |
462 | bool tab_or_stack = (parent_layout == L_TABBED || parent_layout == L_STACKED) | ||
463 | && ((siblings && siblings->length > 1) || !config->hide_lone_tab); | ||
452 | if (((!tab_or_stack || container_is_floating(c)) && | 464 | if (((!tab_or_stack || container_is_floating(c)) && |
453 | c->current.border != B_NORMAL) || | 465 | c->current.border != B_NORMAL) || |
454 | c->fullscreen_mode != FULLSCREEN_NONE || | 466 | c->pending.fullscreen_mode != FULLSCREEN_NONE || |
455 | c->workspace == NULL) { | 467 | c->pending.workspace == NULL) { |
456 | deco_rect->x = deco_rect->y = deco_rect->width = deco_rect->height = 0; | 468 | deco_rect->x = deco_rect->y = deco_rect->width = deco_rect->height = 0; |
457 | return; | 469 | return; |
458 | } | 470 | } |
459 | 471 | ||
460 | if (c->parent) { | 472 | if (c->pending.parent) { |
461 | deco_rect->x = c->x - c->parent->x; | 473 | deco_rect->x = c->pending.x - c->pending.parent->pending.x; |
462 | deco_rect->y = c->y - c->parent->y; | 474 | deco_rect->y = c->pending.y - c->pending.parent->pending.y; |
463 | } else { | 475 | } else { |
464 | deco_rect->x = c->x - c->workspace->x; | 476 | deco_rect->x = c->pending.x - c->pending.workspace->x; |
465 | deco_rect->y = c->y - c->workspace->y; | 477 | deco_rect->y = c->pending.y - c->pending.workspace->y; |
466 | } | 478 | } |
467 | deco_rect->width = c->width; | 479 | deco_rect->width = c->pending.width; |
468 | deco_rect->height = container_titlebar_height(); | 480 | deco_rect->height = container_titlebar_height(); |
469 | 481 | ||
470 | if (!container_is_floating(c)) { | 482 | if (!container_is_floating(c)) { |
471 | if (parent_layout == L_TABBED) { | 483 | if (parent_layout == L_TABBED) { |
472 | deco_rect->width = c->parent | 484 | deco_rect->width = c->pending.parent |
473 | ? c->parent->width / c->parent->children->length | 485 | ? c->pending.parent->pending.width / c->pending.parent->pending.children->length |
474 | : c->workspace->width / c->workspace->tiling->length; | 486 | : c->pending.workspace->width / c->pending.workspace->tiling->length; |
475 | deco_rect->x += deco_rect->width * container_sibling_index(c); | 487 | deco_rect->x += deco_rect->width * container_sibling_index(c); |
476 | } else if (parent_layout == L_STACKED) { | 488 | } else if (parent_layout == L_STACKED) { |
477 | if (!c->view) { | 489 | if (!c->view) { |
@@ -494,10 +506,10 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object | |||
494 | json_object_object_add(object, "visible", json_object_new_boolean(visible)); | 506 | json_object_object_add(object, "visible", json_object_new_boolean(visible)); |
495 | 507 | ||
496 | struct wlr_box window_box = { | 508 | struct wlr_box window_box = { |
497 | c->content_x - c->x, | 509 | c->pending.content_x - c->pending.x, |
498 | (c->current.border == B_PIXEL) ? c->current.border_thickness : 0, | 510 | (c->current.border == B_PIXEL) ? c->current.border_thickness : 0, |
499 | c->content_width, | 511 | c->pending.content_width, |
500 | c->content_height | 512 | c->pending.content_height |
501 | }; | 513 | }; |
502 | 514 | ||
503 | json_object_object_add(object, "window_rect", ipc_json_create_rect(&window_box)); | 515 | json_object_object_add(object, "window_rect", ipc_json_create_rect(&window_box)); |
@@ -583,16 +595,18 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object | |||
583 | static void ipc_json_describe_container(struct sway_container *c, json_object *object) { | 595 | static void ipc_json_describe_container(struct sway_container *c, json_object *object) { |
584 | json_object_object_add(object, "name", | 596 | json_object_object_add(object, "name", |
585 | c->title ? json_object_new_string(c->title) : NULL); | 597 | c->title ? json_object_new_string(c->title) : NULL); |
586 | json_object_object_add(object, "type", | 598 | if (container_is_floating(c)) { |
587 | json_object_new_string(container_is_floating(c) ? "floating_con" : "con")); | 599 | json_object_object_add(object, "type", |
600 | json_object_new_string("floating_con")); | ||
601 | } | ||
588 | 602 | ||
589 | json_object_object_add(object, "layout", | 603 | json_object_object_add(object, "layout", |
590 | json_object_new_string( | 604 | json_object_new_string( |
591 | ipc_json_layout_description(c->layout))); | 605 | ipc_json_layout_description(c->pending.layout))); |
592 | 606 | ||
593 | json_object_object_add(object, "orientation", | 607 | json_object_object_add(object, "orientation", |
594 | json_object_new_string( | 608 | json_object_new_string( |
595 | ipc_json_orientation_description(c->layout))); | 609 | ipc_json_orientation_description(c->pending.layout))); |
596 | 610 | ||
597 | bool urgent = c->view ? | 611 | bool urgent = c->view ? |
598 | view_is_urgent(c->view) : container_has_urgent_child(c); | 612 | view_is_urgent(c->view) : container_has_urgent_child(c); |
@@ -600,7 +614,7 @@ static void ipc_json_describe_container(struct sway_container *c, json_object *o | |||
600 | json_object_object_add(object, "sticky", json_object_new_boolean(c->is_sticky)); | 614 | json_object_object_add(object, "sticky", json_object_new_boolean(c->is_sticky)); |
601 | 615 | ||
602 | json_object_object_add(object, "fullscreen_mode", | 616 | json_object_object_add(object, "fullscreen_mode", |
603 | json_object_new_int(c->fullscreen_mode)); | 617 | json_object_new_int(c->pending.fullscreen_mode)); |
604 | 618 | ||
605 | struct sway_node *parent = node_get_parent(&c->node); | 619 | struct sway_node *parent = node_get_parent(&c->node); |
606 | struct wlr_box parent_box = {0, 0, 0, 0}; | 620 | struct wlr_box parent_box = {0, 0, 0, 0}; |
@@ -610,8 +624,8 @@ static void ipc_json_describe_container(struct sway_container *c, json_object *o | |||
610 | } | 624 | } |
611 | 625 | ||
612 | if (parent_box.width != 0 && parent_box.height != 0) { | 626 | if (parent_box.width != 0 && parent_box.height != 0) { |
613 | double percent = ((double)c->width / parent_box.width) | 627 | double percent = ((double)c->pending.width / parent_box.width) |
614 | * ((double)c->height / parent_box.height); | 628 | * ((double)c->pending.height / parent_box.height); |
615 | json_object_object_add(object, "percent", json_object_new_double(percent)); | 629 | json_object_object_add(object, "percent", json_object_new_double(percent)); |
616 | } | 630 | } |
617 | 631 | ||
@@ -692,15 +706,14 @@ json_object *ipc_json_describe_node(struct sway_node *node) { | |||
692 | }; | 706 | }; |
693 | seat_for_each_node(seat, focus_inactive_children_iterator, &data); | 707 | seat_for_each_node(seat, focus_inactive_children_iterator, &data); |
694 | 708 | ||
695 | json_object *object = ipc_json_create_node( | 709 | json_object *object = ipc_json_create_node((int)node->id, |
696 | (int)node->id, name, focused, focus, &box); | 710 | ipc_json_node_type_description(node->type), name, focused, focus, &box); |
697 | 711 | ||
698 | switch (node->type) { | 712 | switch (node->type) { |
699 | case N_ROOT: | 713 | case N_ROOT: |
700 | ipc_json_describe_root(root, object); | ||
701 | break; | 714 | break; |
702 | case N_OUTPUT: | 715 | case N_OUTPUT: |
703 | ipc_json_describe_output(node->sway_output, object); | 716 | ipc_json_describe_enabled_output(node->sway_output, object); |
704 | break; | 717 | break; |
705 | case N_CONTAINER: | 718 | case N_CONTAINER: |
706 | ipc_json_describe_container(node->sway_container, object); | 719 | ipc_json_describe_container(node->sway_container, object); |
@@ -743,10 +756,10 @@ json_object *ipc_json_describe_node_recursive(struct sway_node *node) { | |||
743 | } | 756 | } |
744 | break; | 757 | break; |
745 | case N_CONTAINER: | 758 | case N_CONTAINER: |
746 | if (node->sway_container->children) { | 759 | if (node->sway_container->pending.children) { |
747 | for (i = 0; i < node->sway_container->children->length; ++i) { | 760 | for (i = 0; i < node->sway_container->pending.children->length; ++i) { |
748 | struct sway_container *child = | 761 | struct sway_container *child = |
749 | node->sway_container->children->items[i]; | 762 | node->sway_container->pending.children->items[i]; |
750 | json_object_array_add(children, | 763 | json_object_array_add(children, |
751 | ipc_json_describe_node_recursive(&child->node)); | 764 | ipc_json_describe_node_recursive(&child->node)); |
752 | } | 765 | } |
@@ -971,10 +984,16 @@ json_object *ipc_json_describe_input(struct sway_input_device *device) { | |||
971 | input_device_get_type(device))); | 984 | input_device_get_type(device))); |
972 | 985 | ||
973 | if (device->wlr_device->type == WLR_INPUT_DEVICE_KEYBOARD) { | 986 | if (device->wlr_device->type == WLR_INPUT_DEVICE_KEYBOARD) { |
974 | struct wlr_keyboard *keyboard = device->wlr_device->keyboard; | 987 | struct wlr_keyboard *keyboard = |
988 | wlr_keyboard_from_input_device(device->wlr_device); | ||
975 | struct xkb_keymap *keymap = keyboard->keymap; | 989 | struct xkb_keymap *keymap = keyboard->keymap; |
976 | struct xkb_state *state = keyboard->xkb_state; | 990 | struct xkb_state *state = keyboard->xkb_state; |
977 | 991 | ||
992 | json_object_object_add(object, "repeat_delay", | ||
993 | json_object_new_int(keyboard->repeat_info.delay)); | ||
994 | json_object_object_add(object, "repeat_rate", | ||
995 | json_object_new_int(keyboard->repeat_info.rate)); | ||
996 | |||
978 | json_object *layouts_arr = json_object_new_array(); | 997 | json_object *layouts_arr = json_object_new_array(); |
979 | json_object_object_add(object, "xkb_layout_names", layouts_arr); | 998 | json_object_object_add(object, "xkb_layout_names", layouts_arr); |
980 | 999 | ||
@@ -996,6 +1015,17 @@ json_object *ipc_json_describe_input(struct sway_input_device *device) { | |||
996 | } | 1015 | } |
997 | } | 1016 | } |
998 | 1017 | ||
1018 | if (device->wlr_device->type == WLR_INPUT_DEVICE_POINTER) { | ||
1019 | struct input_config *ic = input_device_get_config(device); | ||
1020 | float scroll_factor = 1.0f; | ||
1021 | if (ic != NULL && !isnan(ic->scroll_factor) && | ||
1022 | ic->scroll_factor != FLT_MIN) { | ||
1023 | scroll_factor = ic->scroll_factor; | ||
1024 | } | ||
1025 | json_object_object_add(object, "scroll_factor", | ||
1026 | json_object_new_double(scroll_factor)); | ||
1027 | } | ||
1028 | |||
999 | if (wlr_input_device_is_libinput(device->wlr_device)) { | 1029 | if (wlr_input_device_is_libinput(device->wlr_device)) { |
1000 | struct libinput_device *libinput_dev; | 1030 | struct libinput_device *libinput_dev; |
1001 | libinput_dev = wlr_libinput_get_device_handle(device->wlr_device); | 1031 | libinput_dev = wlr_libinput_get_device_handle(device->wlr_device); |
@@ -1109,7 +1139,9 @@ json_object *ipc_json_describe_bar_config(struct bar_config *bar) { | |||
1109 | json_object_object_add(json, "verbose", | 1139 | json_object_object_add(json, "verbose", |
1110 | json_object_new_boolean(bar->verbose)); | 1140 | json_object_new_boolean(bar->verbose)); |
1111 | json_object_object_add(json, "pango_markup", | 1141 | json_object_object_add(json, "pango_markup", |
1112 | json_object_new_boolean(bar->pango_markup)); | 1142 | json_object_new_boolean(bar->pango_markup == PANGO_MARKUP_DEFAULT |
1143 | ? config->pango_markup | ||
1144 | : bar->pango_markup)); | ||
1113 | 1145 | ||
1114 | json_object *colors = json_object_new_object(); | 1146 | json_object *colors = json_object_new_object(); |
1115 | json_object_object_add(colors, "background", | 1147 | json_object_object_add(colors, "background", |