diff options
author | S. Christoffer Eliesen <christoffer@eliesen.no> | 2015-11-26 23:53:20 +0100 |
---|---|---|
committer | S. Christoffer Eliesen <christoffer@eliesen.no> | 2015-11-27 17:58:10 +0100 |
commit | 2d0f78c0d6fb67b38c056856608708be610b7096 (patch) | |
tree | f87d318d7701b572932687a1f388af2ec6458b15 /sway/workspace.c | |
parent | commands: code formatting: Sort list of commands by alphabet. (diff) | |
download | sway-2d0f78c0d6fb67b38c056856608708be610b7096.tar.gz sway-2d0f78c0d6fb67b38c056856608708be610b7096.tar.zst sway-2d0f78c0d6fb67b38c056856608708be610b7096.zip |
workspace: Learn sticky.
A floating window that's sticky will move to the new active workspace
whenever the workspace on the same output changes.
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) { | |||
221 | strcpy(prev_workspace_name, active_ws->name); | 221 | strcpy(prev_workspace_name, active_ws->name); |
222 | } | 222 | } |
223 | 223 | ||
224 | // move sticky containers | ||
225 | if (swayc_parent_by_type(active_ws, C_OUTPUT) == swayc_parent_by_type(workspace, C_OUTPUT)) { | ||
226 | // don't change list while traversing it, use intermediate list instead | ||
227 | list_t *stickies = create_list(); | ||
228 | for (int i = 0; i < active_ws->floating->length; i++) { | ||
229 | swayc_t *cont = active_ws->floating->items[i]; | ||
230 | if (cont->sticky) { | ||
231 | list_add(stickies, cont); | ||
232 | } | ||
233 | } | ||
234 | for (int i = 0; i < stickies->length; i++) { | ||
235 | swayc_t *cont = stickies->items[i]; | ||
236 | sway_log(L_DEBUG, "Moving sticky container %p to %p:%s", | ||
237 | cont, workspace, workspace->name); | ||
238 | swayc_t *parent = remove_child(cont); | ||
239 | add_floating(workspace, cont); | ||
240 | // Destroy old container if we need to | ||
241 | destroy_container(parent); | ||
242 | } | ||
243 | list_free(stickies); | ||
244 | } | ||
224 | sway_log(L_DEBUG, "Switching to workspace %p:%s", workspace, workspace->name); | 245 | sway_log(L_DEBUG, "Switching to workspace %p:%s", workspace, workspace->name); |
225 | if (!set_focused_container(get_focused_view(workspace))) { | 246 | if (!set_focused_container(get_focused_view(workspace))) { |
226 | return false; | 247 | return false; |
227 | } | 248 | } |
228 | arrange_windows(workspace, -1, -1); | 249 | arrange_windows(workspace, -1, -1); |
229 | |||
230 | return true; | 250 | return true; |
231 | } | 251 | } |