From fd6903673b084ef16f18e228405cb50adf28550d Mon Sep 17 00:00:00 2001 From: Ranieri Althoff Date: Mon, 15 Apr 2019 21:46:50 -0300 Subject: [PATCH] Send disabled output available modes on IPC get_outputs - Also fix missing trailing newline on pretty print Signed-off-by: Ranieri Althoff <1993083+ranisalt@users.noreply.github.com> --- sway/ipc-json.c | 16 +++++++++++++++- swaymsg/main.c | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 4ccf6dfd3..4af8d34bc 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c @@ -240,7 +240,21 @@ json_object *ipc_json_describe_disabled_output(struct sway_output *output) { json_object_new_string(wlr_output->model)); json_object_object_add(object, "serial", json_object_new_string(wlr_output->serial)); - json_object_object_add(object, "modes", json_object_new_array()); + + json_object *modes_array = json_object_new_array(); + struct wlr_output_mode *mode; + wl_list_for_each(mode, &wlr_output->modes, link) { + json_object *mode_object = json_object_new_object(); + json_object_object_add(mode_object, "width", + json_object_new_int(mode->width)); + json_object_object_add(mode_object, "height", + json_object_new_int(mode->height)); + json_object_object_add(mode_object, "refresh", + json_object_new_int(mode->refresh)); + json_object_array_add(modes_array, mode_object); + } + + json_object_object_add(object, "modes", modes_array); json_object_object_add(object, "current_workspace", NULL); diff --git a/swaymsg/main.c b/swaymsg/main.c index e2c43445c..ccc847f5c 100644 --- a/swaymsg/main.c +++ b/swaymsg/main.c @@ -230,7 +230,7 @@ static void pretty_print_output(json_object *o) { ); } else { printf( - "Output %s '%s %s %s' (inactive)", + "Output %s '%s %s %s' (inactive)\n", json_object_get_string(name), json_object_get_string(make), json_object_get_string(model),