aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/view.c
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-09-20 11:58:19 -0400
committerLibravatar Simon Ser <contact@emersion.fr>2019-09-20 20:47:59 +0300
commitda0ad4c39ed91c0d485b3d519ad1631ea6a46ba2 (patch)
tree6a7c450992f7bac0db1de47f80f0073aaa15a240 /sway/tree/view.c
parentswaybar: make status block text render in the same way as others (diff)
downloadsway-da0ad4c39ed91c0d485b3d519ad1631ea6a46ba2.tar.gz
sway-da0ad4c39ed91c0d485b3d519ad1631ea6a46ba2.tar.zst
sway-da0ad4c39ed91c0d485b3d519ad1631ea6a46ba2.zip
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
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r--sway/tree/view.c39
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) {
449 list_free(criterias); 449 list_free(criterias);
450} 450}
451 451
452static void view_populate_pid(struct sway_view *view) {
453 pid_t pid;
454 switch (view->type) {
455#if HAVE_XWAYLAND
456 case SWAY_VIEW_XWAYLAND:;
457 struct wlr_xwayland_surface *surf =
458 wlr_xwayland_surface_from_wlr_surface(view->surface);
459 pid = surf->pid;
460 break;
461#endif
462 case SWAY_VIEW_XDG_SHELL:;
463 struct wl_client *client =
464 wl_resource_get_client(view->surface->resource);
465 wl_client_get_credentials(client, &pid, NULL, NULL);
466 break;
467 }
468 view->pid = pid;
469}
470
452static struct sway_workspace *select_workspace(struct sway_view *view) { 471static struct sway_workspace *select_workspace(struct sway_view *view) {
453 struct sway_seat *seat = input_manager_current_seat(); 472 struct sway_seat *seat = input_manager_current_seat();
454 473
@@ -488,24 +507,7 @@ static struct sway_workspace *select_workspace(struct sway_view *view) {
488 } 507 }
489 508
490 // Check if there's a PID mapping 509 // Check if there's a PID mapping
491 pid_t pid; 510 ws = root_workspace_for_pid(view->pid);
492#if HAVE_XWAYLAND
493 if (view->type == SWAY_VIEW_XWAYLAND) {
494 struct wlr_xwayland_surface *surf =
495 wlr_xwayland_surface_from_wlr_surface(view->surface);
496 pid = surf->pid;
497 } else {
498 struct wl_client *client =
499 wl_resource_get_client(view->surface->resource);
500 wl_client_get_credentials(client, &pid, NULL, NULL);
501 }
502#else
503 struct wl_client *client =
504 wl_resource_get_client(view->surface->resource);
505 wl_client_get_credentials(client, &pid, NULL, NULL);
506#endif
507 view->pid = pid;
508 ws = root_workspace_for_pid(pid);
509 if (ws) { 511 if (ws) {
510 return ws; 512 return ws;
511 } 513 }
@@ -563,6 +565,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
563 return; 565 return;
564 } 566 }
565 view->surface = wlr_surface; 567 view->surface = wlr_surface;
568 view_populate_pid(view);
566 569
567 // If there is a request to be opened fullscreen on a specific output, try 570 // If there is a request to be opened fullscreen on a specific output, try
568 // to honor that request. Otherwise, fallback to assigns, pid mappings, 571 // to honor that request. Otherwise, fallback to assigns, pid mappings,