diff options
author | Alex Maese <memaese@hotmail.com> | 2022-06-09 18:51:15 -0500 |
---|---|---|
committer | Simon Zeni <simon@bl4ckb0ne.ca> | 2022-09-19 07:26:45 -0400 |
commit | 52f0e3a4d5bc5900df821b82a2c6941f57eaca25 (patch) | |
tree | 973d60e0f2d0d5ad7fe63aa1b38e549987c6d11a | |
parent | c015db4a9f115bfa10bd0b4c3fa05aca51b04c9b (diff) |
sway: add non-desktop outputs to json when running `swaymsg -t get_outputs`
-rw-r--r-- | include/sway/ipc-json.h | 2 | ||||
-rw-r--r-- | sway/ipc-json.c | 27 | ||||
-rw-r--r-- | sway/ipc-server.c | 6 |
3 files changed, 31 insertions, 4 deletions
diff --git a/include/sway/ipc-json.h b/include/sway/ipc-json.h index 6f4ade1a..bc9f4985 100644 --- a/include/sway/ipc-json.h +++ b/include/sway/ipc-json.h @@ -1,6 +1,7 @@ #ifndef _SWAY_IPC_JSON_H #define _SWAY_IPC_JSON_H #include <json.h> +#include "sway/output.h" #include "sway/tree/container.h" #include "sway/input/input-manager.h" @@ -9,6 +10,7 @@ json_object *ipc_json_get_version(void); json_object *ipc_json_get_binding_mode(void); json_object *ipc_json_describe_disabled_output(struct sway_output *o); +json_object *ipc_json_describe_non_desktop_output(struct sway_output_non_desktop *o); json_object *ipc_json_describe_node(struct sway_node *node); json_object *ipc_json_describe_node_recursive(struct sway_node *node); json_object *ipc_json_describe_input(struct sway_input_device *device); diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 63c182f2..763fb3fe 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c @@ -240,10 +240,7 @@ static json_object *ipc_json_create_node(int id, const char* type, char *name, return object; } -static void ipc_json_describe_output(struct sway_output *output, - json_object *object) { - struct wlr_output *wlr_output = output->wlr_output; - +static void ipc_json_describe_wlr_output(struct wlr_output *wlr_output, json_object *object) { json_object_object_add(object, "primary", json_object_new_boolean(false)); json_object_object_add(object, "make", json_object_new_string(wlr_output->make ? wlr_output->make : "Unknown")); @@ -267,11 +264,17 @@ static void ipc_json_describe_output(struct sway_output *output, json_object_object_add(object, "modes", modes_array); } +static void ipc_json_describe_output(struct sway_output *output, + json_object *object) { + ipc_json_describe_wlr_output(output->wlr_output, object); +} + static void ipc_json_describe_enabled_output(struct sway_output *output, json_object *object) { ipc_json_describe_output(output, object); struct wlr_output *wlr_output = output->wlr_output; + json_object_object_add(object, "non_desktop", json_object_new_boolean(false)); json_object_object_add(object, "active", json_object_new_boolean(true)); json_object_object_add(object, "dpms", json_object_new_boolean(wlr_output->enabled)); @@ -349,6 +352,7 @@ json_object *ipc_json_describe_disabled_output(struct sway_output *output) { ipc_json_describe_output(output, object); + json_object_object_add(object, "non_desktop", json_object_new_boolean(false)); json_object_object_add(object, "type", json_object_new_string("output")); json_object_object_add(object, "name", json_object_new_string(wlr_output->name)); @@ -370,6 +374,21 @@ json_object *ipc_json_describe_disabled_output(struct sway_output *output) { return object; } +json_object *ipc_json_describe_non_desktop_output(struct sway_output_non_desktop *output) { + struct wlr_output *wlr_output = output->wlr_output; + + json_object *object = json_object_new_object(); + + ipc_json_describe_wlr_output(wlr_output, object); + + json_object_object_add(object, "non_desktop", json_object_new_boolean(true)); + json_object_object_add(object, "type", json_object_new_string("output")); + json_object_object_add(object, "name", + json_object_new_string(wlr_output->name)); + + return object; +} + static json_object *ipc_json_describe_scratchpad_output(void) { struct wlr_box box; root_get_box(root, &box); diff --git a/sway/ipc-server.c b/sway/ipc-server.c index 3cbf7889..00b01d7d 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c @@ -685,6 +685,12 @@ void ipc_client_handle_command(struct ipc_client *client, uint32_t payload_lengt ipc_json_describe_disabled_output(output)); } } + + for (int i = 0; i < root->non_desktop_outputs->length; i++) { + struct sway_output_non_desktop *non_desktop_output = root->non_desktop_outputs->items[i]; + json_object_array_add(outputs, ipc_json_describe_non_desktop_output(non_desktop_output)); + } + const char *json_string = json_object_to_json_string(outputs); ipc_send_reply(client, payload_type, json_string, (uint32_t)strlen(json_string)); |