diff options
-rw-r--r-- | include/sway/config.h | 2 | ||||
-rw-r--r-- | include/sway/ipc-json.h | 1 | ||||
-rw-r--r-- | sway/commands/output.c | 4 | ||||
-rw-r--r-- | sway/config/output.c | 2 | ||||
-rw-r--r-- | sway/ipc-json.c | 38 | ||||
-rw-r--r-- | sway/ipc-server.c | 16 |
6 files changed, 57 insertions, 6 deletions
diff --git a/include/sway/config.h b/include/sway/config.h index fdfbbedb..83ded720 100644 --- a/include/sway/config.h +++ b/include/sway/config.h | |||
@@ -105,7 +105,7 @@ struct output_config { | |||
105 | int width, height; | 105 | int width, height; |
106 | float refresh_rate; | 106 | float refresh_rate; |
107 | int x, y; | 107 | int x, y; |
108 | int scale; | 108 | float scale; |
109 | int32_t transform; | 109 | int32_t transform; |
110 | 110 | ||
111 | char *background; | 111 | char *background; |
diff --git a/include/sway/ipc-json.h b/include/sway/ipc-json.h index 9986c399..9435b664 100644 --- a/include/sway/ipc-json.h +++ b/include/sway/ipc-json.h | |||
@@ -5,6 +5,7 @@ | |||
5 | 5 | ||
6 | json_object *ipc_json_get_version(); | 6 | json_object *ipc_json_get_version(); |
7 | 7 | ||
8 | json_object *ipc_json_describe_container(swayc_t *c); | ||
8 | json_object *ipc_json_describe_container_recursive(swayc_t *c); | 9 | json_object *ipc_json_describe_container_recursive(swayc_t *c); |
9 | 10 | ||
10 | #endif | 11 | #endif |
diff --git a/sway/commands/output.c b/sway/commands/output.c index d71e4d8d..7988e3e4 100644 --- a/sway/commands/output.c +++ b/sway/commands/output.c | |||
@@ -144,7 +144,7 @@ struct cmd_results *cmd_output(int argc, char **argv) { | |||
144 | goto fail; | 144 | goto fail; |
145 | } | 145 | } |
146 | char *end; | 146 | char *end; |
147 | output->scale = strtol(argv[i], &end, 10); | 147 | output->scale = strtof(argv[i], &end); |
148 | if (*end) { | 148 | if (*end) { |
149 | error = cmd_results_new(CMD_INVALID, "output", | 149 | error = cmd_results_new(CMD_INVALID, "output", |
150 | "Invalid scale."); | 150 | "Invalid scale."); |
@@ -278,7 +278,7 @@ struct cmd_results *cmd_output(int argc, char **argv) { | |||
278 | } | 278 | } |
279 | 279 | ||
280 | sway_log(L_DEBUG, "Config stored for output %s (enabled: %d) (%dx%d@%fHz " | 280 | sway_log(L_DEBUG, "Config stored for output %s (enabled: %d) (%dx%d@%fHz " |
281 | "position %d,%d scale %d transform %d) (bg %s %s)", | 281 | "position %d,%d scale %f transform %d) (bg %s %s)", |
282 | output->name, output->enabled, output->width, output->height, | 282 | output->name, output->enabled, output->width, output->height, |
283 | output->refresh_rate, output->x, output->y, output->scale, | 283 | output->refresh_rate, output->x, output->y, output->scale, |
284 | output->transform, output->background, output->background_option); | 284 | output->transform, output->background, output->background_option); |
diff --git a/sway/config/output.c b/sway/config/output.c index dc9ee37c..ff3f73a3 100644 --- a/sway/config/output.c +++ b/sway/config/output.c | |||
@@ -111,7 +111,7 @@ void apply_output_config(struct output_config *oc, swayc_t *output) { | |||
111 | set_mode(wlr_output, oc->width, oc->height, oc->refresh_rate); | 111 | set_mode(wlr_output, oc->width, oc->height, oc->refresh_rate); |
112 | } | 112 | } |
113 | if (oc && oc->scale > 0) { | 113 | if (oc && oc->scale > 0) { |
114 | sway_log(L_DEBUG, "Set %s scale to %d", oc->name, oc->scale); | 114 | sway_log(L_DEBUG, "Set %s scale to %f", oc->name, oc->scale); |
115 | wlr_output_set_scale(wlr_output, oc->scale); | 115 | wlr_output_set_scale(wlr_output, oc->scale); |
116 | } | 116 | } |
117 | if (oc && oc->transform >= 0) { | 117 | if (oc && oc->transform >= 0) { |
diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 2e774a96..09a32c1b 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c | |||
@@ -4,6 +4,7 @@ | |||
4 | #include "log.h" | 4 | #include "log.h" |
5 | #include "sway/ipc-json.h" | 5 | #include "sway/ipc-json.h" |
6 | #include "sway/container.h" | 6 | #include "sway/container.h" |
7 | #include "sway/output.h" | ||
7 | #include <wlr/types/wlr_box.h> | 8 | #include <wlr/types/wlr_box.h> |
8 | #include <wlr/types/wlr_output.h> | 9 | #include <wlr/types/wlr_output.h> |
9 | 10 | ||
@@ -38,10 +39,43 @@ static void ipc_json_describe_root(swayc_t *root, json_object *object) { | |||
38 | json_object_object_add(object, "layout", json_object_new_string("splith")); | 39 | json_object_object_add(object, "layout", json_object_new_string("splith")); |
39 | } | 40 | } |
40 | 41 | ||
41 | static void ipc_json_describe_output(swayc_t *output, json_object *object) { | 42 | static const char *ipc_json_get_output_transform(enum wl_output_transform transform) { |
43 | switch (transform) { | ||
44 | case WL_OUTPUT_TRANSFORM_NORMAL: | ||
45 | return "normal"; | ||
46 | case WL_OUTPUT_TRANSFORM_90: | ||
47 | return "90"; | ||
48 | case WL_OUTPUT_TRANSFORM_180: | ||
49 | return "180"; | ||
50 | case WL_OUTPUT_TRANSFORM_270: | ||
51 | return "270"; | ||
52 | case WL_OUTPUT_TRANSFORM_FLIPPED: | ||
53 | return "flipped"; | ||
54 | case WL_OUTPUT_TRANSFORM_FLIPPED_90: | ||
55 | return "flipped-90"; | ||
56 | case WL_OUTPUT_TRANSFORM_FLIPPED_180: | ||
57 | return "flipped-180"; | ||
58 | case WL_OUTPUT_TRANSFORM_FLIPPED_270: | ||
59 | return "flipped-270"; | ||
60 | } | ||
61 | return NULL; | ||
62 | } | ||
63 | |||
64 | static void ipc_json_describe_output(swayc_t *container, json_object *object) { | ||
65 | struct wlr_output *wlr_output = container->sway_output->wlr_output; | ||
42 | json_object_object_add(object, "type", json_object_new_string("output")); | 66 | json_object_object_add(object, "type", json_object_new_string("output")); |
67 | json_object_object_add(object, "active", json_object_new_boolean(true)); | ||
68 | json_object_object_add(object, "primary", json_object_new_boolean(false)); | ||
69 | json_object_object_add(object, "layout", json_object_new_string("output")); | ||
70 | json_object_object_add(object, "make", json_object_new_string(wlr_output->make)); | ||
71 | json_object_object_add(object, "model", json_object_new_string(wlr_output->model)); | ||
72 | json_object_object_add(object, "serial", json_object_new_string(wlr_output->serial)); | ||
73 | json_object_object_add(object, "scale", json_object_new_double(wlr_output->scale)); | ||
74 | json_object_object_add(object, "refresh", json_object_new_int(wlr_output->refresh)); | ||
75 | json_object_object_add(object, "transform", | ||
76 | json_object_new_string(ipc_json_get_output_transform(wlr_output->transform))); | ||
43 | json_object_object_add(object, "current_workspace", | 77 | json_object_object_add(object, "current_workspace", |
44 | (output->focused) ? json_object_new_string(output->focused->name) : NULL); | 78 | (container->focused) ? json_object_new_string(container->focused->name) : NULL); |
45 | } | 79 | } |
46 | 80 | ||
47 | static void ipc_json_describe_workspace(swayc_t *workspace, json_object *object) { | 81 | static void ipc_json_describe_workspace(swayc_t *workspace, json_object *object) { |
diff --git a/sway/ipc-server.c b/sway/ipc-server.c index 71f8dddd..b7cd2d76 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c | |||
@@ -343,6 +343,22 @@ void ipc_client_handle_command(struct ipc_client *client) { | |||
343 | goto exit_cleanup; | 343 | goto exit_cleanup; |
344 | } | 344 | } |
345 | 345 | ||
346 | case IPC_GET_OUTPUTS: | ||
347 | { | ||
348 | json_object *outputs = json_object_new_array(); | ||
349 | for (int i = 0; i < root_container.children->length; ++i) { | ||
350 | swayc_t *container = root_container.children->items[i]; | ||
351 | if (container->type == C_OUTPUT) { | ||
352 | json_object_array_add(outputs, | ||
353 | ipc_json_describe_container(container)); | ||
354 | } | ||
355 | } | ||
356 | const char *json_string = json_object_to_json_string(outputs); | ||
357 | ipc_send_reply(client, json_string, (uint32_t) strlen(json_string)); | ||
358 | json_object_put(outputs); // free | ||
359 | goto exit_cleanup; | ||
360 | } | ||
361 | |||
346 | case IPC_GET_TREE: | 362 | case IPC_GET_TREE: |
347 | { | 363 | { |
348 | json_object *tree = | 364 | json_object *tree = |