diff options
author | Drew DeVault <sir@cmpwn.com> | 2015-11-27 10:20:16 -0700 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2015-11-27 10:20:16 -0700 |
commit | b7702eb34c9d5485145b0483891e710fae12e967 (patch) | |
tree | f87d318d7701b572932687a1f388af2ec6458b15 /sway/workspace.c | |
parent | cbd73487046820105a32c64ecf86554876f8f41b (diff) | |
parent | 2d0f78c0d6fb67b38c056856608708be610b7096 (diff) |
Merge pull request #266 from sce/sticky_floats_0
workspace: Learn sticky.
Diffstat (limited to 'sway/workspace.c')
-rw-r--r-- | sway/workspace.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/sway/workspace.c b/sway/workspace.c index f18a691f..6c9a39e0 100644 --- a/sway/workspace.c +++ b/sway/workspace.c @@ -221,11 +221,31 @@ bool workspace_switch(swayc_t *workspace) { strcpy(prev_workspace_name, active_ws->name); } + // move sticky containers + if (swayc_parent_by_type(active_ws, C_OUTPUT) == swayc_parent_by_type(workspace, C_OUTPUT)) { + // don't change list while traversing it, use intermediate list instead + list_t *stickies = create_list(); + for (int i = 0; i < active_ws->floating->length; i++) { + swayc_t *cont = active_ws->floating->items[i]; + if (cont->sticky) { + list_add(stickies, cont); + } + } + for (int i = 0; i < stickies->length; i++) { + swayc_t *cont = stickies->items[i]; + sway_log(L_DEBUG, "Moving sticky container %p to %p:%s", + cont, workspace, workspace->name); + swayc_t *parent = remove_child(cont); + add_floating(workspace, cont); + // Destroy old container if we need to + destroy_container(parent); + } + list_free(stickies); + } sway_log(L_DEBUG, "Switching to workspace %p:%s", workspace, workspace->name); if (!set_focused_container(get_focused_view(workspace))) { return false; } arrange_windows(workspace, -1, -1); - return true; } |