Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose sandbox properties via IPC JSON, criteria, title format #8521

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

jacobmcnamee
Copy link

Rebase and update of #7187.

Add sandbox properties to IPC JSON, criteria, and title format:

  • sandbox_engine
  • sandbox_app_id
  • sandbox_instance_id

These properties may be set by sandbox engines (e.g. flatpak) via the security context protocol: https://wayland.app/protocols/security-context-v1.

Example Usage

Prepend sandbox properties to window title when sandbox engine is set:

for_window [sandbox_engine="."] title_format "[%sandbox_engine/%sandbox_app_id/%sandbox_instance_id] %title"

Testing

Launch an app via flatpak:

flatpak run org.gnome.clocks

Observe JSON layout tree via swaymsg -r -t get_tree:

"name": "Clocks",
"pid": 14309,
"app_id": "org.gnome.clocks",
...
"sandbox_engine": "org.flatpak",
"sandbox_app_id": "org.gnome.clocks",
"sandbox_instance_id": "2307446143",

Observe pretty layout tree via swaymsg -p -t get_tree:

#1: root "root"
  #2147483647: output "__i3"
    #2147483646: workspace "__i3_scratch"
  #3: output "WL-1"
    #4: workspace "1"
      #5: con "Clocks" (xdg_shell, pid: 14309, app_id: "org.gnome.clocks", sandbox_engine: "org.flatpak", sandbox_app_id: "org.gnome.clocks", sandbox_instance_id: "2307446143")

Observe window title when configured as shown above:

[org.flatpak/org.gnome.clocks/2307446143] Clocks

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this has nothing xdg-shell specific - do we really need to get through the view->impl abstraction, or can we just put this logic in generic view code?

@@ -602,6 +602,18 @@ static void ipc_json_describe_view(struct sway_container *c, json_object *object
json_object_object_add(object, "inhibit_idle",
json_object_new_boolean(view_inhibit_idle(c->view)));

const char *sandbox_engine = view_get_sandbox_engine(c->view);
json_object_object_add(object, "sandbox_engine",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we should be adding these new props to the IPC man page as well.

If the value is \_\_focused\_\_, then the sandbox engine must be the same as
that of the currently focused window.

*sandbox_app_id*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm kind of wondering whether we should expose this, or whether we should always prefer the sandbox-provided app ID over the one provided by the sandboxed client.

(IIRC GNOME allows org.libreoffice.Writer if the sandbox app ID is org.libreoffice.)

Copy link
Member

@emersion emersion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the whole this looks good to me, added a few comments!

(Thanks for rebasing on top of my criteria changes!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants