diff options
author | Simon Ser <contact@emersion.fr> | 2022-10-04 09:46:47 +0200 |
---|---|---|
committer | Simon Zeni <simon@bl4ckb0ne.ca> | 2022-11-15 11:06:51 -0500 |
commit | 717e9ef581024d327fd6c21afce20ba216339b72 (patch) | |
tree | da3bd287dbdeca433120cfe802a34f5d9889fa36 /sway/ipc-json.c | |
parent | Listen to the output request_state event (diff) | |
download | sway-717e9ef581024d327fd6c21afce20ba216339b72.tar.gz sway-717e9ef581024d327fd6c21afce20ba216339b72.tar.zst sway-717e9ef581024d327fd6c21afce20ba216339b72.zip |
ipc: add view content type
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3599
Diffstat (limited to 'sway/ipc-json.c')
-rw-r--r-- | sway/ipc-json.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c index d757f21f..73a3d376 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c | |||
@@ -4,6 +4,7 @@ | |||
4 | #include <libevdev/libevdev.h> | 4 | #include <libevdev/libevdev.h> |
5 | #include <stdio.h> | 5 | #include <stdio.h> |
6 | #include <wlr/backend/libinput.h> | 6 | #include <wlr/backend/libinput.h> |
7 | #include <wlr/types/wlr_content_type_v1.h> | ||
7 | #include <wlr/types/wlr_output.h> | 8 | #include <wlr/types/wlr_output.h> |
8 | #include <xkbcommon/xkbcommon.h> | 9 | #include <xkbcommon/xkbcommon.h> |
9 | #include "config.h" | 10 | #include "config.h" |
@@ -201,6 +202,20 @@ static const char *ipc_json_user_idle_inhibitor_description(enum sway_idle_inhib | |||
201 | return NULL; | 202 | return NULL; |
202 | } | 203 | } |
203 | 204 | ||
205 | static const char *ipc_json_content_type_description(enum wp_content_type_v1_type type) { | ||
206 | switch (type) { | ||
207 | case WP_CONTENT_TYPE_V1_TYPE_NONE: | ||
208 | return "none"; | ||
209 | case WP_CONTENT_TYPE_V1_TYPE_PHOTO: | ||
210 | return "photo"; | ||
211 | case WP_CONTENT_TYPE_V1_TYPE_VIDEO: | ||
212 | return "video"; | ||
213 | case WP_CONTENT_TYPE_V1_TYPE_GAME: | ||
214 | return "game"; | ||
215 | } | ||
216 | return NULL; | ||
217 | } | ||
218 | |||
204 | json_object *ipc_json_get_version(void) { | 219 | json_object *ipc_json_get_version(void) { |
205 | int major = 0, minor = 0, patch = 0; | 220 | int major = 0, minor = 0, patch = 0; |
206 | json_object *version = json_object_new_object(); | 221 | json_object *version = json_object_new_object(); |
@@ -602,6 +617,16 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object | |||
602 | 617 | ||
603 | json_object_object_add(object, "idle_inhibitors", idle_inhibitors); | 618 | json_object_object_add(object, "idle_inhibitors", idle_inhibitors); |
604 | 619 | ||
620 | enum wp_content_type_v1_type content_type = WP_CONTENT_TYPE_V1_TYPE_NONE; | ||
621 | if (c->view->surface != NULL) { | ||
622 | content_type = wlr_surface_get_content_type_v1(server.content_type_manager_v1, | ||
623 | c->view->surface); | ||
624 | } | ||
625 | if (content_type != WP_CONTENT_TYPE_V1_TYPE_NONE) { | ||
626 | json_object_object_add(object, "content_type", | ||
627 | json_object_new_string(ipc_json_content_type_description(content_type))); | ||
628 | } | ||
629 | |||
605 | #if HAVE_XWAYLAND | 630 | #if HAVE_XWAYLAND |
606 | if (c->view->type == SWAY_VIEW_XWAYLAND) { | 631 | if (c->view->type == SWAY_VIEW_XWAYLAND) { |
607 | json_object_object_add(object, "window", | 632 | json_object_object_add(object, "window", |