43 DLOG(
"opening window %d\n", cnt);
47 new->name = strdup(
colors[cnt]);
50 if ((cnt % (
sizeof(
colors) /
sizeof(
char*))) == 0)
82 struct nodes_head *nodes_head = &(parent->nodes_head);
83 struct focus_head *focus_head = &(parent->focus_head);
87 if (con->
type == CT_WORKSPACE) {
88 DLOG(
"it's a workspace. num = %d\n", con->
num);
93 if (con->
num < current->
num) {
97 while (current->
num != -1 && con->
num > current->
num) {
110 goto add_to_focus_head;
113 if (con->
type == CT_FLOATING_CON) {
114 DLOG(
"Inserting into floating containers\n");
120 if (loop->
type == CT_FLOATING_CON)
134 if (con->
window != NULL &&
135 parent->
type == CT_WORKSPACE &&
137 DLOG(
"Parent is a workspace. Applying default layout...\n");
141 nodes_head = &(target->nodes_head);
142 focus_head = &(target->focus_head);
151 if (current && parent->
type != CT_OUTPUT) {
152 DLOG(
"Inserting con = %p after last focused tiling con %p\n",
170 if (con->
type == CT_FLOATING_CON) {
186 DLOG(
"con_focus = %p\n", con);
217 if (con->
type == CT_WORKSPACE)
221 DLOG(
"container %p does not accepts windows, orientation != NO_ORIENTATION\n", con);
226 return (con->
window == NULL);
236 while (result != NULL && result->
type != CT_OUTPUT)
240 assert(result != NULL);
250 while (result != NULL && result->
type != CT_WORKSPACE)
261 DLOG(
"Searching for parent of Con %p with orientation %d\n", con, orientation);
263 if (parent->
type == CT_FLOATING_CON)
266 DLOG(
"Need to go one level further up\n");
269 if (parent && parent->
type == CT_FLOATING_CON)
274 DLOG(
"Result: %p\n", parent);
294 Con *current, *child;
305 current = entry->
con;
325 TAILQ_FOREACH(child, &(current->floating_head), floating_windows) {
341 DLOG(
"checking if con %p is floating\n", con);
342 return (con->
floating >= FLOATING_AUTO_ON);
352 if (con->
type == CT_FLOATING_CON)
355 if (con->
floating >= FLOATING_AUTO_ON)
358 if (con->
type == CT_WORKSPACE || con->
type == CT_OUTPUT)
397 if (con->
frame == frame)
417 if (store_match != NULL)
418 *store_match = match;
426 TAILQ_FOREACH(child, &(con->floating_head), floating_windows) {
430 if (store_match != NULL)
431 *store_match = match;
469 int children_with_percent = 0;
473 ++children_with_percent;
479 if (children_with_percent != children) {
482 if (children_with_percent == 0)
483 total += (child->
percent = 1.0);
484 else total += (child->
percent = total / children_with_percent);
493 child->
percent = 1.0 / children;
494 }
else if (total != 1.0) {
506 Con *workspace, *fullscreen;
508 if (con->
type == CT_WORKSPACE) {
509 DLOG(
"You cannot make a workspace fullscreen.\n");
513 DLOG(
"toggling fullscreen for %p / %s\n", con, con->
name);
516 if (fullscreen_mode == CF_GLOBAL)
522 if (fullscreen != NULL) {
526 LOG(
"Disabling fullscreen for (%p/%s) upon user request\n",
527 fullscreen, fullscreen->
name);
547 unsigned int num = 0;
550 values[num++] = A__NET_WM_STATE_FULLSCREEN;
552 xcb_change_property(
conn, XCB_PROP_MODE_REPLACE, con->
window->
id,
574 if (con->
type == CT_WORKSPACE) {
575 DLOG(
"Moving workspaces is not yet implemented.\n");
580 DLOG(
"Using FLOATINGCON instead\n");
595 if (next->
type != CT_WORKSPACE) {
596 DLOG(
"next originally = %p / %s / type %d\n", next, next->
name, next->
type);
604 if (floatingcon != NULL) {
605 DLOG(
"floatingcon, going up even further\n");
606 next = floatingcon->
parent;
609 if (con->
type == CT_FLOATING_CON) {
611 DLOG(
"This is a floating window, using workspace %p / %s\n", ws, ws->
name);
615 if (source_output != dest_output) {
618 if (fix_coordinates && con->
type == CT_FLOATING_CON) {
620 }
else DLOG(
"Not fixing coordinates, fix_coordinates flag = %d\n", fix_coordinates);
637 DLOG(
"Re-attaching container to %p / %s\n", next, next->
name);
652 if ((workspace->
name[0] !=
'_' || workspace->
name[1] !=
'_') &&
659 if (source_output != dest_output &&
661 DLOG(
"Moved to a different output, focusing target\n");
670 CALL(parent, on_remove_child);
681 if (con->
layout == L_STACKED)
684 if (con->
layout == L_TABBED)
700 if (con->
type == CT_FLOATING_CON) {
701 DLOG(
"selecting next for CT_FLOATING_CON\n");
703 DLOG(
"next = %p\n", next);
705 next =
TAILQ_PREV(con, floating_head, floating_windows);
706 DLOG(
"using prev, next = %p\n", next);
711 DLOG(
"no more floating containers for next = %p, restoring workspace focus\n", next);
715 DLOG(
"skipping container itself, we want the next client\n");
719 if (next ==
TAILQ_END(&(ws->focus_head))) {
720 DLOG(
"Focus list empty, returning ws\n");
733 DLOG(
"selecting workspace for dock client\n");
741 DLOG(
"Using first entry %p\n", first);
765 DLOG(
"con_get_next(way=%c, orientation=%d)\n", way, orientation);
769 DLOG(
"need to go one level further up\n");
771 LOG(
"that's a workspace, we can't go further up\n");
782 if (next ==
TAILQ_END(&(parent->nodes_head)))
787 if (next ==
TAILQ_END(&(cur->nodes_head)))
790 DLOG(
"next = %p\n", next);
825 if (child->
type == CT_FLOATING_CON)
831 }
while (before != next && next !=
focused);
845 DLOG(
"con_descend_direction(%p, orientation %d, direction %d)\n", con, orientation, direction);
847 if (orientation ==
HORIZ) {
852 else most =
TAILQ_LAST(&(con->nodes_head), nodes_head);
853 }
else if (orientation ==
VERT) {
865 if (direction ==
D_UP || direction ==
D_DOWN) {
866 if (orientation ==
VERT) {
869 if (direction ==
D_UP)
870 most =
TAILQ_LAST(&(con->nodes_head), nodes_head);
872 }
else if (orientation ==
HORIZ) {
898 return (
Rect){2, 0, -(2 * 2), -2};
901 return (
Rect){1, 1, -2, -2};
904 return (
Rect){0, 0, 0, 0};
924 DLOG(
"this one is fullscreen! overriding BS_NONE\n");
957 DLOG(
"This is a floating container\n");
994 if (con->
type == CT_WORKSPACE) {
995 DLOG(
"Creating new split container\n");
1013 if (old_focused ==
TAILQ_END(&(con->focus_head)))
1017 DLOG(
"Moving cons\n");
1026 DLOG(
"Attaching new split to ws\n");
1047 DLOG(
"on_remove_child\n");
1051 if (con->
type == CT_OUTPUT ||
1052 con->
type == CT_ROOT ||
1053 con->
type == CT_DOCKAREA) {
1054 DLOG(
"not handling, type = %d\n", con->
type);
1059 if (con->
type == CT_WORKSPACE) {
1061 LOG(
"Closing old workspace (%p / %s), it is empty\n", con, con->
name);
1063 ipc_send_event(
"workspace", I3_IPC_EVENT_WORKSPACE,
"{\"change\":\"empty\"}");
1071 if (children == 0) {
1072 DLOG(
"Container empty, closing\n");
1084 DLOG(
"Determining minimum size for con %p\n", con);
1087 DLOG(
"leaf node, returning 75x50\n");
1088 return (
Rect){ 0, 0, 75, 50 };
1091 if (con->
type == CT_FLOATING_CON) {
1092 DLOG(
"floating con\n");
1097 if (con->
layout == L_STACKED || con->
layout == L_TABBED) {
1098 uint32_t max_width = 0, max_height = 0, deco_height = 0;
1103 max_width =
max(max_width, min.
width);
1104 max_height =
max(max_height, min.
height);
1106 DLOG(
"stacked/tabbed now, returning %d x %d + deco_rect = %d\n",
1107 max_width, max_height, deco_height);
1108 return (
Rect){ 0, 0, max_width, max_height + deco_height };
1127 DLOG(
"split container, returning width = %d x height = %d\n", width,
height);
1131 ELOG(
"Unhandled case, type = %d, layout = %d, orientation = %d\n",