mirror of
https://github.com/swaywm/sway.git
synced 2024-11-25 17:31:28 +00:00
De-duplicate IPC output descriptions
This commit is contained in:
parent
42b61ab27a
commit
f0d57da315
|
@ -245,20 +245,42 @@ static json_object *ipc_json_create_node(int id, const char* type, char *name,
|
|||
static void ipc_json_describe_output(struct sway_output *output,
|
||||
json_object *object) {
|
||||
struct wlr_output *wlr_output = output->wlr_output;
|
||||
json_object_object_add(object, "active", json_object_new_boolean(true));
|
||||
json_object_object_add(object, "dpms",
|
||||
json_object_new_boolean(wlr_output->enabled));
|
||||
|
||||
json_object_object_add(object, "primary", json_object_new_boolean(false));
|
||||
json_object_object_add(object, "layout", json_object_new_string("output"));
|
||||
json_object_object_add(object, "orientation",
|
||||
json_object_new_string(
|
||||
ipc_json_orientation_description(L_NONE)));
|
||||
json_object_object_add(object, "make",
|
||||
json_object_new_string(wlr_output->make));
|
||||
json_object_object_add(object, "model",
|
||||
json_object_new_string(wlr_output->model));
|
||||
json_object_object_add(object, "serial",
|
||||
json_object_new_string(wlr_output->serial));
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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, "active", json_object_new_boolean(true));
|
||||
json_object_object_add(object, "dpms",
|
||||
json_object_new_boolean(wlr_output->enabled));
|
||||
json_object_object_add(object, "layout", json_object_new_string("output"));
|
||||
json_object_object_add(object, "orientation",
|
||||
json_object_new_string(
|
||||
ipc_json_orientation_description(L_NONE)));
|
||||
json_object_object_add(object, "scale",
|
||||
json_object_new_double(wlr_output->scale));
|
||||
json_object_object_add(object, "scale_filter",
|
||||
|
@ -325,33 +347,13 @@ json_object *ipc_json_describe_disabled_output(struct sway_output *output) {
|
|||
|
||||
json_object *object = json_object_new_object();
|
||||
|
||||
ipc_json_describe_output(output, object);
|
||||
|
||||
json_object_object_add(object, "type", json_object_new_string("output"));
|
||||
json_object_object_add(object, "name",
|
||||
json_object_new_string(wlr_output->name));
|
||||
json_object_object_add(object, "active", json_object_new_boolean(false));
|
||||
json_object_object_add(object, "dpms", json_object_new_boolean(false));
|
||||
json_object_object_add(object, "primary", json_object_new_boolean(false));
|
||||
json_object_object_add(object, "make",
|
||||
json_object_new_string(wlr_output->make));
|
||||
json_object_object_add(object, "model",
|
||||
json_object_new_string(wlr_output->model));
|
||||
json_object_object_add(object, "serial",
|
||||
json_object_new_string(wlr_output->serial));
|
||||
|
||||
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);
|
||||
|
||||
|
@ -706,7 +708,7 @@ json_object *ipc_json_describe_node(struct sway_node *node) {
|
|||
case N_ROOT:
|
||||
break;
|
||||
case N_OUTPUT:
|
||||
ipc_json_describe_output(node->sway_output, object);
|
||||
ipc_json_describe_enabled_output(node->sway_output, object);
|
||||
break;
|
||||
case N_CONTAINER:
|
||||
ipc_json_describe_container(node->sway_container, object);
|
||||
|
|
Loading…
Reference in a new issue