ipc: add view content type

References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3599
This commit is contained in:
Simon Ser 2022-10-04 09:46:47 +02:00 committed by Simon Zeni
parent 907ca48a61
commit 717e9ef581
4 changed files with 30 additions and 0 deletions

View file

@ -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",

View file

@ -11,6 +11,7 @@
#include <wlr/config.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_content_type_v1.h>
#include <wlr/types/wlr_data_control_v1.h>
#include <wlr/types/wlr_drm_lease_v1.h>
#include <wlr/types/wlr_drm.h>
@ -205,6 +206,8 @@ bool server_init(struct sway_server *server) {
wlr_primary_selection_v1_device_manager_create(server->wl_display);
wlr_viewporter_create(server->wl_display);
wlr_single_pixel_buffer_manager_v1_create(server->wl_display);
server->content_type_manager_v1 =
wlr_content_type_manager_v1_create(server->wl_display, 1);
struct wlr_xdg_foreign_registry *foreign_registry =
wlr_xdg_foreign_registry_create(server->wl_display);