From da0ad4c39ed91c0d485b3d519ad1631ea6a46ba2 Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Fri, 20 Sep 2019 11:58:19 -0400 Subject: view: always populate pid If the view was mapped as fullscreen or the view was assigned either a workspace or output, the pid was not being populated since it was occurring as part of the pid mapping check in select_workspace. This extracts the pid population and makes it so it is always executed --- sway/tree/view.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/sway/tree/view.c b/sway/tree/view.c index 1d9cbec7..5041ee85 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -449,6 +449,25 @@ void view_execute_criteria(struct sway_view *view) { list_free(criterias); } +static void view_populate_pid(struct sway_view *view) { + pid_t pid; + switch (view->type) { +#if HAVE_XWAYLAND + case SWAY_VIEW_XWAYLAND:; + struct wlr_xwayland_surface *surf = + wlr_xwayland_surface_from_wlr_surface(view->surface); + pid = surf->pid; + break; +#endif + case SWAY_VIEW_XDG_SHELL:; + struct wl_client *client = + wl_resource_get_client(view->surface->resource); + wl_client_get_credentials(client, &pid, NULL, NULL); + break; + } + view->pid = pid; +} + static struct sway_workspace *select_workspace(struct sway_view *view) { struct sway_seat *seat = input_manager_current_seat(); @@ -488,24 +507,7 @@ static struct sway_workspace *select_workspace(struct sway_view *view) { } // Check if there's a PID mapping - pid_t pid; -#if HAVE_XWAYLAND - if (view->type == SWAY_VIEW_XWAYLAND) { - struct wlr_xwayland_surface *surf = - wlr_xwayland_surface_from_wlr_surface(view->surface); - pid = surf->pid; - } else { - struct wl_client *client = - wl_resource_get_client(view->surface->resource); - wl_client_get_credentials(client, &pid, NULL, NULL); - } -#else - struct wl_client *client = - wl_resource_get_client(view->surface->resource); - wl_client_get_credentials(client, &pid, NULL, NULL); -#endif - view->pid = pid; - ws = root_workspace_for_pid(pid); + ws = root_workspace_for_pid(view->pid); if (ws) { return ws; } @@ -563,6 +565,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface, return; } view->surface = wlr_surface; + view_populate_pid(view); // If there is a request to be opened fullscreen on a specific output, try // to honor that request. Otherwise, fallback to assigns, pid mappings, -- cgit v1.2.3