commit cff16d32f9435592d0fe1f5794213e50341d9bed
parent e3f0ba4cd9ca709cac115ade54958885614d889c
Author: Jacob McNamee <jacob@jacobmcnamee.com>
Date: Thu, 26 Dec 2024 21:38:05 -0800
tree/view: add getters for sandbox properties
Diffstat:
2 files changed, 35 insertions(+), 0 deletions(-)
diff --git 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
@@ -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: