diff options
author | Erik Reider <[email protected]> | 2023-05-19 21:14:06 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2023-05-19 21:14:06 +0200 |
commit | 415e072a3af292937f0b4c41acadafaee6958437 (patch) | |
tree | 354de329d9cbf66054260d50aebefd86a26d5055 /sway/ipc-json.c | |
parent | 67078429428f0a97333c107da8a3ad8fb678a602 (diff) |
Add blur, shadow, and corner radius to layer-shell surfaces (#144)
Co-authored-by: Will McKinnon <[email protected]>
Diffstat (limited to 'sway/ipc-json.c')
-rw-r--r-- | sway/ipc-json.c | 69 |
1 files changed, 64 insertions, 5 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c index cd79e1c8..717ebf78 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c @@ -10,6 +10,7 @@ #include "log.h" #include "sway/config.h" #include "sway/ipc-json.h" +#include "sway/layers.h" #include "sway/tree/container.h" #include "sway/tree/view.h" #include "sway/tree/workspace.h" @@ -273,7 +274,8 @@ static json_object *ipc_json_create_node(int id, const char* type, char *name, return object; } -static void ipc_json_describe_wlr_output(struct wlr_output *wlr_output, json_object *object) { +static void ipc_json_describe_wlr_output(struct wlr_output *wlr_output, + struct sway_output *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")); @@ -299,7 +301,7 @@ static void ipc_json_describe_wlr_output(struct wlr_output *wlr_output, json_obj static void ipc_json_describe_output(struct sway_output *output, json_object *object) { - ipc_json_describe_wlr_output(output->wlr_output, object); + ipc_json_describe_wlr_output(output->wlr_output, output, object); } static void ipc_json_describe_enabled_output(struct sway_output *output, @@ -331,6 +333,63 @@ static void ipc_json_describe_enabled_output(struct sway_output *output, json_object_object_add(object, "adaptive_sync_status", json_object_new_string(adaptive_sync_status)); + struct json_object *layers = json_object_new_array(); + size_t len = sizeof(output->layers) / sizeof(output->layers[0]); + for (size_t i = 0; i < len; ++i) { + struct sway_layer_surface *lsurface; + wl_list_for_each(lsurface, &output->layers[i], link) { + json_object *layer = json_object_new_object(); + + json_object_object_add(layer, "namespace", + json_object_new_string(lsurface->layer_surface->namespace)); + + char *layer_name; + switch (lsurface->layer) { + case ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND: + layer_name = "background"; + break; + case ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM: + layer_name = "bottom"; + break; + case ZWLR_LAYER_SHELL_V1_LAYER_TOP: + layer_name = "top"; + break; + case ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY: + layer_name = "overlay"; + break; + } + + json_object_object_add(layer, "layer", + json_object_new_string(layer_name)); + + json_object *extent = json_object_new_object(); + json_object_object_add(extent, "width", + json_object_new_int(lsurface->extent.width)); + json_object_object_add(extent, "height", + json_object_new_int(lsurface->extent.height)); + json_object_object_add(extent, "x", + json_object_new_int(lsurface->extent.x)); + json_object_object_add(extent, "y", + json_object_new_int(lsurface->extent.y)); + json_object_object_add(layer, "extent", extent); + + json_object *effects = json_object_new_array(); + if (lsurface->has_blur) { + json_object_array_add(effects, json_object_new_string("blur")); + } + if (lsurface->has_shadow) { + json_object_array_add(effects, json_object_new_string("shadows")); + } + if (lsurface->corner_radius > 0) { + json_object_array_add(effects, json_object_new_string("corner_radius")); + } + json_object_object_add(layer, "effects", effects); + + json_object_array_add(layers, layer); + } + } + json_object_object_add(object, "layer_shell_surfaces", layers); + struct sway_workspace *ws = output_get_active_workspace(output); if (!sway_assert(ws, "Expected output to have a workspace")) { return; @@ -413,7 +472,7 @@ json_object *ipc_json_describe_non_desktop_output(struct sway_output_non_desktop json_object *object = json_object_new_object(); - ipc_json_describe_wlr_output(wlr_output, object); + ipc_json_describe_wlr_output(wlr_output, NULL, object); json_object_object_add(object, "non_desktop", json_object_new_boolean(true)); json_object_object_add(object, "type", json_object_new_string("output")); @@ -1053,9 +1112,9 @@ json_object *ipc_json_describe_input(struct sway_input_device *device) { struct xkb_keymap *keymap = keyboard->keymap; struct xkb_state *state = keyboard->xkb_state; - json_object_object_add(object, "repeat_delay", + json_object_object_add(object, "repeat_delay", json_object_new_int(keyboard->repeat_info.delay)); - json_object_object_add(object, "repeat_rate", + json_object_object_add(object, "repeat_rate", json_object_new_int(keyboard->repeat_info.rate)); json_object *layouts_arr = json_object_new_array(); |