diff options
author | Brian Ashworth <bosrsf04@gmail.com> | 2019-09-20 11:58:19 -0400 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2019-09-20 20:47:59 +0300 |
commit | da0ad4c39ed91c0d485b3d519ad1631ea6a46ba2 (patch) | |
tree | 6a7c450992f7bac0db1de47f80f0073aaa15a240 | |
parent | 3a2e8608487161a45fab1a02401496a6eaa9618d (diff) |
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
-rw-r--r-- | sway/tree/view.c | 39 |
1 files 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, |