aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFurkan Sahin <furkan-dev@proton.me>2024-12-26 21:38:05 -0800
committerFurkan Sahin <furkan-dev@proton.me>2024-12-26 21:38:05 -0800
commitd789e3a3737a368b69e4109ddc6da5b59d7810ad (patch)
tree45bda2b815593f6aea48a25291dde21a9705cb63
parent114c47a62436d53ae24ea3f56d45be6b886dc39a (diff)
tree/view: add getters for sandbox properties
-rw-r--r--include/sway/tree/view.h6
-rw-r--r--sway/tree/view.c29
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: