TAILQ_INIT(&(new->focus_head));
TAILQ_INIT(&(new->swallow_head));
- if (parent != NULL)
- con_attach(new, parent, false);
+ if (parent != NULL) {
+ /* Set layout of ws if this is the first child of the ws and the user
+ * wanted something different than the default layout. */
+ if (parent->type == CT_WORKSPACE &&
+ con_is_leaf(parent) &&
+ config.default_layout != L_DEFAULT) {
+ con_set_layout(new, config.default_layout);
+ con_attach(new, parent, false);
+ con_set_layout(parent, config.default_layout);
+ } else {
+ con_attach(new, parent, false);
+ }
+ }
return new;
}
unsigned int num = 0;
if (con->fullscreen_mode != CF_NONE)
- values[num++] = atoms[_NET_WM_STATE_FULLSCREEN];
+ values[num++] = A__NET_WM_STATE_FULLSCREEN;
xcb_change_property(conn, XCB_PROP_MODE_REPLACE, con->window->id,
- atoms[_NET_WM_STATE], ATOM, 32, num, values);
+ A__NET_WM_STATE, A_ATOM, 32, num, values);
}
/*
con = con->parent;
}
+ Con *source_output = con_get_output(con),
+ *dest_output = con_get_output(workspace);
+
/* 1: save the container which is going to be focused after the current
* container is moved away */
Con *focus_next = con_next_focused(con);
Con *next = con_descend_focused(workspace);
/* 3: we go up one level, but only when next is a normal container */
- if (next->type != CT_WORKSPACE)
+ if (next->type != CT_WORKSPACE) {
+ DLOG("next originally = %p / %s / type %d\n", next, next->name, next->type);
next = next->parent;
+ }
/* 4: if the target container is floating, we get the workspace instead.
* Only tiling windows need to get inserted next to the current container.
next = floatingcon->parent;
}
+ if (con->type == CT_FLOATING_CON) {
+ Con *ws = con_get_workspace(next);
+ DLOG("This is a floating window, using workspace %p / %s\n", ws, ws->name);
+ next = ws;
+ }
+
DLOG("Re-attaching container to %p / %s\n", next, next->name);
/* 5: re-attach the con to the parent of this focused container */
Con *parent = con->parent;
* calling tree_render(), so for the "real" focus this is a no-op) */
con_focus(con);
- /* 8: keep focus on the current workspace */
- con_focus(focus_next);
+ /* 8: when moving to a visible workspace on a different output, we keep the
+ * con focused. Otherwise, we leave the focus on the current workspace as we
+ * don’t want to focus invisible workspaces */
+ if (source_output != dest_output &&
+ workspace_is_visible(workspace)) {
+ DLOG("Moved to a different output, focusing target\n");
+ } else {
+ con_focus(focus_next);
+ }
CALL(parent, on_remove_child);
}
DLOG("Focus list empty, returning ws\n");
next = ws;
}
+ } else {
+ /* Instead of returning the next CT_FLOATING_CON, we descend it to
+ * get an actual window to focus. */
+ next = con_descend_focused(next);
}
return next;
}
return next;
}
+/*
+ * Returns the focused con inside this client, descending the tree as far as
+ * possible. This comes in handy when attaching a con to a workspace at the
+ * currently focused position, for example.
+ *
+ * Works like con_descend_focused but considers only tiling cons.
+ *
+ */
+Con *con_descend_tiling_focused(Con *con) {
+ Con *next = con;
+ Con *before;
+ Con *child;
+ do {
+ before = next;
+ TAILQ_FOREACH(child, &(next->focus_head), focused) {
+ if (child->type == CT_FLOATING_CON)
+ continue;
+
+ next = child;
+ break;
+ }
+ } while (before != next);
+ return next;
+}
+
+
/*
* Returns a "relative" Rect which contains the amount of pixels that need to
* be added to the original Rect to get the final position (obviously the
/* 3: While the layout is irrelevant in stacked/tabbed mode, it needs
* to be set. Otherwise, this con will not be interpreted as a split
* container. */
- new->orientation = HORIZ;
+ if (config.default_orientation == NO_ORIENTATION) {
+ new->orientation = (con->rect.height > con->rect.width) ? VERT : HORIZ;
+ } else {
+ new->orientation = config.default_orientation;
+ }
Con *old_focused = TAILQ_FIRST(&(con->focus_head));
if (old_focused == TAILQ_END(&(con->focus_head)))
int children = con_num_children(con);
if (children == 0) {
DLOG("Container empty, closing\n");
- tree_close(con, false, false);
+ tree_close(con, DONT_KILL_WINDOW, false);
return;
}
}