26 __i3->
type = CT_OUTPUT;
29 x_set_name(__i3,
"[i3 con] pseudo-output __i3");
37 DLOG(
"adding main content container\n");
39 content->
type = CT_CON;
48 ws->
type = CT_WORKSPACE;
52 x_set_name(ws,
"[i3 con] workspace __i3_scratch");
62 bool tree_restore(
const char *path, xcb_get_geometry_reply_t *geometry) {
66 LOG(
"%s does not exist, not restoring tree\n", globbed);
83 printf(
"appended tree, using new root\n");
85 printf(
"new root = %p\n", croot);
87 printf(
"out = %p\n", out);
89 printf(
"ws = %p\n", ws);
93 if (strcmp(out->
name,
"__i3") != 0) {
94 DLOG(
"Adding pseudo-output __i3 during inplace restart\n");
113 croot->
name =
"root";
114 croot->
type = CT_ROOT;
142 if (con->
type == CT_FLOATING_CON) {
144 if (con->
type != CT_WORKSPACE)
147 DLOG(
"con = %p\n", con);
185 bool was_mapped = con->
mapped;
197 DLOG(
"next = %p, focused = %p\n", next, focused);
199 DLOG(
"closing %p, kill_window = %d\n", con, kill_window);
200 Con *child, *nextchild;
201 bool abort_kill =
false;
204 for (child =
TAILQ_FIRST(&(con->nodes_head)); child; ) {
206 DLOG(
"killing child=%p\n", child);
207 if (!
tree_close(child, kill_window,
true,
false))
213 DLOG(
"One of the children could not be killed immediately (WM_DELETE sent), aborting.\n");
217 if (con->
window != NULL) {
222 xcb_void_cookie_t cookie;
233 cookie = xcb_change_property(
conn, XCB_PROP_MODE_REPLACE,
234 con->
window->
id, A_WM_STATE, A_WM_STATE, 32, 2, data);
251 if (con->
type != CT_FLOATING_CON) {
259 DLOG(
"Container was floating, killing floating container\n");
261 DLOG(
"parent container killed\n");
262 if (con == focused) {
263 DLOG(
"This is the focused container, i need to find another one to focus. I start looking at ws = %p\n", ws);
267 dont_kill_parent =
true;
268 DLOG(
"Alright, focusing %p\n", next);
282 DLOG(
"No next container, i will just exit now\n");
286 if (was_mapped || con == focused) {
287 if ((kill_window !=
DONT_KILL_WINDOW) || !dont_kill_parent || con == focused) {
288 DLOG(
"focusing %p / %s\n", next, next->
name);
289 if (next->
type == CT_DOCKAREA) {
293 if (!force_set_focus && con != focused)
294 DLOG(
"not changing focus, the container was not focused before\n");
299 DLOG(
"not focusing because we're not killing anybody");
302 DLOG(
"not focusing, was not mapped\n");
306 if (!dont_kill_parent)
307 CALL(parent, on_remove_child);
317 assert(focused != NULL);
318 if (focused->
type == CT_WORKSPACE) {
319 LOG(
"Cannot close workspace\n");
324 assert(focused->
type != CT_OUTPUT);
325 assert(focused->
type != CT_ROOT);
328 tree_close(focused, kill_window,
false,
false);
338 if (con->
type == CT_WORKSPACE) {
339 DLOG(
"Workspace, simply changing orientation to %d\n", orientation);
354 parent->
layout == L_DEFAULT) {
356 DLOG(
"Just changing orientation of existing container\n");
360 DLOG(
"Splitting in orientation %d\n", orientation);
366 new->parent = parent;
385 LOG(
"Currently in fullscreen, not going up\n");
391 focused->
type == CT_WORKSPACE) {
392 LOG(
"Cannot go up any further\n");
405 if (next ==
TAILQ_END(&(focused->focus_head))) {
406 printf(
"cannot go down\n");
418 if (con->
type == CT_WORKSPACE) {
421 TAILQ_FOREACH(current, &(con->floating_head), floating_windows)
435 DLOG(
"-- BEGIN RENDERING --\n");
444 DLOG(
"-- END RENDERING --\n");
454 if (con->
type == CT_WORKSPACE) {
460 DLOG(
"Current output is %s\n", current_output->
name);
464 if (way ==
'n' && orientation ==
HORIZ)
466 else if (way ==
'p' && orientation ==
HORIZ)
468 else if (way ==
'n' && orientation ==
VERT)
470 else if (way ==
'p' && orientation ==
VERT)
478 DLOG(
"Next output is %s\n", next_output->
name);
481 Con *workspace = NULL;
499 if (con->
type == CT_FLOATING_CON) {
501 if (orientation ==
HORIZ) {
505 else next =
TAILQ_PREV(con, floating_head, floating_windows);
511 else next =
TAILQ_LAST(&(parent->floating_head), floating_head);
531 return _tree_next(parent, way, orientation, wrap);
537 DLOG(
"nothing to focus\n");
544 else next =
TAILQ_PREV(current, nodes_head, nodes);
551 if (
_tree_next(parent, way, orientation,
false))
560 else next =
TAILQ_LAST(&(parent->nodes_head), nodes_head);
593 Con *current, *child, *parent = con->
parent;
594 DLOG(
"Checking if I can flatten con = %p / %s\n", con, con->
name);
597 if (con->
type != CT_CON || con->
window != NULL)
602 if (child == NULL ||
TAILQ_NEXT(child, nodes) != NULL)
613 DLOG(
"Alright, I have to flatten this situation now. Stay calm.\n");
617 DLOG(
"detaching...\n");
621 DLOG(
"detaching current=%p / %s\n", current, current->
name);
623 DLOG(
"re-attaching\n");
630 DLOG(
"attaching to focus list\n");
634 DLOG(
"re-attached all\n");
637 if (focus_next != NULL &&
639 DLOG(
"restoring focus to focus_next=%p\n", focus_next);
640 TAILQ_REMOVE(&(parent->focus_head), focus_next, focused);
642 DLOG(
"restored focus.\n");
646 DLOG(
"closing redundant cons\n");
660 while (current != NULL) {
667 while (current != NULL) {