From cff16d32f9435592d0fe1f5794213e50341d9bed Mon Sep 17 00:00:00 2001 From: Jacob McNamee Date: Thu, 26 Dec 2024 21:38:05 -0800 Subject: [PATCH] tree/view: add getters for sandbox properties --- include/sway/tree/view.h | 6 ++++++ sway/tree/view.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index f60322212..9f084eeb4 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -221,6 +221,12 @@ const char *view_get_window_role(struct sway_view *view); uint32_t view_get_window_type(struct sway_view *view); +const char *view_get_sandbox_engine(struct sway_view *view); + +const char *view_get_sandbox_app_id(struct sway_view *view); + +const char *view_get_sandbox_instance_id(struct sway_view *view); + const char *view_get_shell(struct sway_view *view); void view_get_constraints(struct sway_view *view, double *min_width, diff --git a/sway/tree/view.c b/sway/tree/view.c index 492095b93..33161cc53 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -154,6 +155,34 @@ uint32_t view_get_window_type(struct sway_view *view) { return 0; } +static const struct wlr_security_context_v1_state *security_context_from_view( + struct sway_view *view) { + const struct wl_client *client = + wl_resource_get_client(view->surface->resource); + const struct wlr_security_context_v1_state *security_context = + wlr_security_context_manager_v1_lookup_client( + server.security_context_manager_v1, client); + return security_context; +} + +const char *view_get_sandbox_engine(struct sway_view *view) { + const struct wlr_security_context_v1_state *security_context = + security_context_from_view(view); + return security_context ? security_context->sandbox_engine : NULL; +} + +const char *view_get_sandbox_app_id(struct sway_view *view) { + const struct wlr_security_context_v1_state *security_context = + security_context_from_view(view); + return security_context ? security_context->app_id : NULL; +} + +const char *view_get_sandbox_instance_id(struct sway_view *view) { + const struct wlr_security_context_v1_state *security_context = + security_context_from_view(view); + return security_context ? security_context->instance_id : NULL; +} + const char *view_get_shell(struct sway_view *view) { switch(view->type) { case SWAY_VIEW_XDG_SHELL: