workspace->type = CT_WORKSPACE;
FREE(workspace->name);
workspace->name = sstrdup(num);
+ workspace->workspace_layout = config.default_layout;
/* We set ->num to the number if this workspace’s name begins with a
* positive number. Otherwise it’s a named ws and num will be -1. */
char *endptr = NULL;
ws->fullscreen_mode = CF_OUTPUT;
+ ws->workspace_layout = config.default_layout;
_workspace_apply_default_orientation(ws);
return ws;
/* Remember currently focused workspace for switching back to it later with
* the 'workspace back_and_forth' command.
* NOTE: We have to duplicate the name as the original will be freed when
- * the corresponding workspace is cleaned up. */
-
- FREE(previous_workspace_name);
- if (current)
- previous_workspace_name = sstrdup(current->name);
+ * the corresponding workspace is cleaned up.
+ * NOTE: Internal cons such as __i3_scratch (when a scratchpad window is
+ * focused) are skipped, see bug #868. */
+ if (current && !con_is_internal(current)) {
+ FREE(previous_workspace_name);
+ if (current) {
+ previous_workspace_name = sstrdup(current->name);
+ DLOG("Setting previous_workspace_name = %s\n", previous_workspace_name);
+ }
+ }
workspace_reassign_sticky(workspace);
/* 1: create a new split container */
Con *split = con_new(NULL, NULL);
split->parent = ws;
+ split->split = true;
/* 2: copy layout from workspace */
split->layout = ws->layout;
/* 4: switch workspace layout */
ws->layout = (orientation == HORIZ) ? L_SPLITH : L_SPLITV;
+ DLOG("split->layout = %d, ws->layout = %d\n", split->layout, ws->layout);
/* 5: attach the new split container to the workspace */
- DLOG("Attaching new split to ws\n");
+ DLOG("Attaching new split (%p) to ws (%p)\n", split, ws);
con_attach(split, ws, false);
/* 6: fix the percentages */
Con *workspace_attach_to(Con *ws) {
DLOG("Attaching a window to workspace %p / %s\n", ws, ws->name);
- if (config.default_layout == L_DEFAULT) {
+ if (ws->workspace_layout == L_DEFAULT) {
DLOG("Default layout, just attaching it to the workspace itself.\n");
return ws;
}
new->split = true;
/* 2: set the requested layout on the split con */
- new->layout = config.default_layout;
+ new->layout = ws->workspace_layout;
/* 4: attach the new split container to the workspace */
DLOG("Attaching new split %p to workspace %p\n", new, ws);