aboutsummaryrefslogtreecommitdiff
path: root/sway/ipc-json.c
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2022-10-04 09:46:47 +0200
committerSimon Zeni <simon@bl4ckb0ne.ca>2022-11-15 11:06:51 -0500
commit717e9ef581024d327fd6c21afce20ba216339b72 (patch)
treeda3bd287dbdeca433120cfe802a34f5d9889fa36 /sway/ipc-json.c
parent907ca48a612971fd6ab43afb47554c77551fbddf (diff)
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.c25
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 @@
#include <libevdev/libevdev.h>
#include <stdio.h>
#include <wlr/backend/libinput.h>
+#include <wlr/types/wlr_content_type_v1.h>
#include <wlr/types/wlr_output.h>
#include <xkbcommon/xkbcommon.h>
#include "config.h"
@@ -201,6 +202,20 @@ static const char *ipc_json_user_idle_inhibitor_description(enum sway_idle_inhib
return NULL;
}
+static const char *ipc_json_content_type_description(enum wp_content_type_v1_type type) {
+ switch (type) {
+ case WP_CONTENT_TYPE_V1_TYPE_NONE:
+ return "none";
+ case WP_CONTENT_TYPE_V1_TYPE_PHOTO:
+ return "photo";
+ case WP_CONTENT_TYPE_V1_TYPE_VIDEO:
+ return "video";
+ case WP_CONTENT_TYPE_V1_TYPE_GAME:
+ return "game";
+ }
+ return NULL;
+}
+
json_object *ipc_json_get_version(void) {
int major = 0, minor = 0, patch = 0;
json_object *version = json_object_new_object();
@@ -602,6 +617,16 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object
json_object_object_add(object, "idle_inhibitors", idle_inhibitors);
+ enum wp_content_type_v1_type content_type = WP_CONTENT_TYPE_V1_TYPE_NONE;
+ if (c->view->surface != NULL) {
+ content_type = wlr_surface_get_content_type_v1(server.content_type_manager_v1,
+ c->view->surface);
+ }
+ if (content_type != WP_CONTENT_TYPE_V1_TYPE_NONE) {
+ json_object_object_add(object, "content_type",
+ json_object_new_string(ipc_json_content_type_description(content_type)));
+ }
+
#if HAVE_XWAYLAND
if (c->view->type == SWAY_VIEW_XWAYLAND) {
json_object_object_add(object, "window",