mirror of
https://github.com/NickHu/sway
synced 2024-12-25 21:58:16 +01:00
sway: add non-desktop outputs to json when running swaymsg -t get_outputs
This commit is contained in:
parent
c015db4a9f
commit
52f0e3a4d5
3 changed files with 31 additions and 4 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in a new issue