diff options
| author | Jacob McNamee <jacob@jacobmcnamee.com> | 2024-12-26 21:38:05 -0800 |
|---|---|---|
| committer | Simon Ser <contact@emersion.fr> | 2025-01-13 08:54:23 +0100 |
| commit | cff16d32f9435592d0fe1f5794213e50341d9bed (patch) | |
| tree | 45bda2b815593f6aea48a25291dde21a9705cb63 | |
| parent | e3f0ba4cd9ca709cac115ade54958885614d889c (diff) | |
tree/view: add getters for sandbox properties
| -rw-r--r-- | include/sway/tree/view.h | 6 | ||||
| -rw-r--r-- | sway/tree/view.c | 29 |
2 files changed, 35 insertions, 0 deletions
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index f6032221..9f084eeb 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 492095b9..33161cc5 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -8,6 +8,7 @@ #include <wlr/types/wlr_foreign_toplevel_management_v1.h> #include <wlr/types/wlr_fractional_scale_v1.h> #include <wlr/types/wlr_output_layout.h> +#include <wlr/types/wlr_security_context_v1.h> #include <wlr/types/wlr_server_decoration.h> #include <wlr/types/wlr_subcompositor.h> #include <wlr/types/wlr_xdg_decoration_v1.h> @@ -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: |
