aboutsummaryrefslogtreecommitdiff
path: root/sway/tree
diff options
context:
space:
mode:
authorRonan Pigott <ronan@rjp.ie>2022-11-16 15:50:34 -0700
committerSimon Ser <contact@emersion.fr>2022-11-26 09:48:58 +0100
commit864b3a9a18f236f92f1898bb44ab977ceaebfd68 (patch)
treebab0ea888c50af46725c94fe5c0c024bdf432a69 /sway/tree
parentd75c9f9722389d441fd24bd490c5cf12c4bef39a (diff)
view: associate launch contexts with views
Views now maintain a reference to a launch context which, as a last resort, is populated at map time with a context associated with its pid. This opens the possibility of populating it before map via another source, e.g. xdga-tokens or configuration.
Diffstat (limited to 'sway/tree')
-rw-r--r--sway/tree/view.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 7482e7a4..31387aaa 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -64,6 +64,8 @@ void view_destroy(struct sway_view *view) {
}
list_free(view->executed_criteria);
+ view_assign_ctx(view, NULL);
+
free(view->title_format);
if (view->impl->destroy) {
@@ -534,6 +536,20 @@ static void view_populate_pid(struct sway_view *view) {
view->pid = pid;
}
+void view_assign_ctx(struct sway_view *view, struct launcher_ctx *ctx) {
+ if (view->ctx) {
+ // This ctx has been replaced
+ launcher_ctx_destroy(view->ctx);
+ view->ctx = NULL;
+ }
+ if (ctx == NULL) {
+ return;
+ }
+ launcher_ctx_consume(ctx);
+
+ view->ctx = ctx;
+}
+
static struct sway_workspace *select_workspace(struct sway_view *view) {
struct sway_seat *seat = input_manager_current_seat();
@@ -569,13 +585,14 @@ static struct sway_workspace *select_workspace(struct sway_view *view) {
}
list_free(criterias);
if (ws) {
- remove_workspace_pid(view->pid);
+ view_assign_ctx(view, NULL);
return ws;
}
// Check if there's a PID mapping
- ws = workspace_for_pid(view->pid);
+ ws = view->ctx ? launcher_ctx_get_workspace(view->ctx) : NULL;
if (ws) {
+ view_assign_ctx(view, NULL);
return ws;
}
@@ -718,6 +735,13 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
view_populate_pid(view);
view->container = container_create(view);
+ if (view->ctx == NULL) {
+ struct launcher_ctx *ctx = launcher_ctx_find_pid(view->pid);
+ if (ctx != NULL) {
+ view_assign_ctx(view, ctx);
+ }
+ }
+
// If there is a request to be opened fullscreen on a specific output, try
// to honor that request. Otherwise, fallback to assigns, pid mappings,
// focused workspace, etc