Add a connection label for wayland clients lauched by sway

This adds a few arguments to exec that cause sway to create a wayland socket
file descriptor and point the WAYLAND_SOCKET environment variable at the
socket.  This in turn allows sway to track all windows created by this client
(in a more robust manner than the existing pid-based tracking).

Note that this only works if the exec ends up launching a single wayland client
(a script that launches multiple commands will not work correctly; a process
that uses libwayland-client itself and runs other processes is fine).

"exec --use-wayland-socket command" only sets WAYLAND_SOCKET and does nothing else.

"exec --label <label> <program>" will associate the specified label with the
wl_client and all windows it creates.
This commit is contained in:
Daniel De Graaf 2020-12-06 13:57:45 -05:00
parent f614f35e73
commit 05a418c9fe
5 changed files with 132 additions and 5 deletions

View file

@ -0,0 +1,4 @@
#include <wayland-server-core.h>
char* wl_client_label_get(struct wl_client *client);
void wl_client_label_set(struct wl_client *client, char* label);

View file

@ -231,6 +231,8 @@ const char *view_get_class(struct sway_view *view);
const char *view_get_instance(struct sway_view *view);
const char *view_get_conn_label(struct sway_view *view);
uint32_t view_get_x11_window_id(struct sway_view *view);
uint32_t view_get_x11_parent_id(struct sway_view *view);