2 #define I3__FILE__ "con.c"
38 while (parent && parent->
type != CT_WORKSPACE && parent->
type != CT_DOCKAREA) {
54 new->aspect_ratio = 0.0;
58 new->current_border_width = -1;
60 new->depth = window->
depth;
62 new->depth = XCB_COPY_FROM_PARENT;
64 DLOG(
"opening window %d\n", cnt);
68 new->name = strdup(
colors[cnt]);
71 if ((cnt % (
sizeof(
colors) /
sizeof(
char*))) == 0)
108 struct nodes_head *nodes_head = &(parent->nodes_head);
109 struct focus_head *focus_head = &(parent->focus_head);
113 if (con->
type == CT_WORKSPACE) {
114 DLOG(
"it's a workspace. num = %d\n", con->
num);
119 if (con->
num < current->
num) {
123 while (current->
num != -1 && con->
num > current->
num) {
136 goto add_to_focus_head;
139 if (con->
type == CT_FLOATING_CON) {
140 DLOG(
"Inserting into floating containers\n");
146 if (loop->
type == CT_FLOATING_CON)
160 if (con->
window != NULL &&
161 parent->
type == CT_WORKSPACE &&
163 DLOG(
"Parent is a workspace. Applying default layout...\n");
167 nodes_head = &(target->nodes_head);
168 focus_head = &(target->focus_head);
177 if (current && parent->
type != CT_OUTPUT) {
178 DLOG(
"Inserting con = %p after last focused tiling con %p\n",
198 if (con->
type == CT_FLOATING_CON) {
214 DLOG(
"con_focus = %p\n", con);
277 if (con->
type == CT_WORKSPACE)
281 DLOG(
"container %p does not accept windows, it is a split container.\n", con);
286 return (con->
window == NULL);
296 while (result != NULL && result->
type != CT_OUTPUT)
300 assert(result != NULL);
310 while (result != NULL && result->
type != CT_WORKSPACE)
321 DLOG(
"Searching for parent of Con %p with orientation %d\n", con, orientation);
323 if (parent->
type == CT_FLOATING_CON)
326 DLOG(
"Need to go one level further up\n");
330 (parent->
type == CT_FLOATING_CON ||
331 parent->
type == CT_OUTPUT ||
337 DLOG(
"Result: %p\n", parent);
357 Con *current, *child;
368 current = entry->
con;
388 TAILQ_FOREACH(child, &(current->floating_head), floating_windows) {
403 return (con->
name[0] ==
'_' && con->
name[1] ==
'_');
412 DLOG(
"checking if con %p is floating\n", con);
413 return (con->
floating >= FLOATING_AUTO_ON);
423 if (con->
type == CT_FLOATING_CON)
426 if (con->
floating >= FLOATING_AUTO_ON)
429 if (con->
type == CT_WORKSPACE || con->
type == CT_OUTPUT)
468 if (con->
frame == frame)
488 if (store_match != NULL)
489 *store_match = match;
497 TAILQ_FOREACH(child, &(con->floating_head), floating_windows) {
501 if (store_match != NULL)
502 *store_match = match;
540 int children_with_percent = 0;
544 ++children_with_percent;
550 if (children_with_percent != children) {
553 if (children_with_percent == 0)
554 total += (child->
percent = 1.0);
555 else total += (child->
percent = total / children_with_percent);
564 child->
percent = 1.0 / children;
565 }
else if (total != 1.0) {
578 Con *workspace, *fullscreen;
580 if (con->
type == CT_WORKSPACE) {
581 DLOG(
"You cannot make a workspace fullscreen.\n");
585 DLOG(
"toggling fullscreen for %p / %s\n", con, con->
name);
588 if (fullscreen_mode == CF_GLOBAL)
594 if (fullscreen != NULL) {
598 LOG(
"Disabling fullscreen for (%p/%s) upon user request\n",
599 fullscreen, fullscreen->
name);
619 unsigned int num = 0;
622 values[num++] = A__NET_WM_STATE_FULLSCREEN;
624 xcb_change_property(
conn, XCB_PROP_MODE_REPLACE, con->
window->
id,
648 LOG(
"Cannot move out of a fullscreen container");
653 DLOG(
"Using FLOATINGCON instead\n");
658 if (workspace == source_ws) {
659 DLOG(
"Not moving, already there\n");
663 if (con->
type == CT_WORKSPACE) {
666 while (!
TAILQ_EMPTY(&(source_ws->floating_head))) {
677 ELOG(
"Workspace failed to move its contents into a container!\n");
697 if (next->
type != CT_WORKSPACE) {
698 DLOG(
"next originally = %p / %s / type %d\n", next, next->
name, next->
type);
706 if (floatingcon != NULL) {
707 DLOG(
"floatingcon, going up even further\n");
708 next = floatingcon->
parent;
711 if (con->
type == CT_FLOATING_CON) {
713 DLOG(
"This is a floating window, using workspace %p / %s\n", ws, ws->
name);
717 if (source_output != dest_output) {
720 if (fix_coordinates && con->
type == CT_FLOATING_CON) {
722 }
else DLOG(
"Not fixing coordinates, fix_coordinates flag = %d\n", fix_coordinates);
747 DLOG(
"Re-attaching container to %p / %s\n", next, next->
name);
785 if (source_ws == current_ws)
791 xcb_get_property_cookie_t cookie;
792 xcb_get_property_reply_t *startup_id_reply;
800 cookie = xcb_get_property(
conn,
false, child->
window->
id,
801 A__NET_STARTUP_ID, XCB_GET_PROPERTY_TYPE_ANY, 0, 512);
802 startup_id_reply = xcb_get_property_reply(
conn, cookie, NULL);
805 if (sequence != NULL)
812 A__NET_STARTUP_ID, XCB_GET_PROPERTY_TYPE_ANY, 0, 512);
813 startup_id_reply = xcb_get_property_reply(
conn, cookie, NULL);
816 if (sequence != NULL)
820 CALL(parent, on_remove_child);
842 DLOG(
"Someone called con_orientation() on a con with L_DEFAULT, this is a bug in the code.\n");
848 DLOG(
"con_orientation() called on dockarea/output (%d) container %p\n", con->
layout, con);
853 DLOG(
"con_orientation() ran into default\n");
868 if (con->
type == CT_FLOATING_CON) {
869 DLOG(
"selecting next for CT_FLOATING_CON\n");
871 DLOG(
"next = %p\n", next);
873 next =
TAILQ_PREV(con, floating_head, floating_windows);
874 DLOG(
"using prev, next = %p\n", next);
879 DLOG(
"no more floating containers for next = %p, restoring workspace focus\n", next);
883 DLOG(
"skipping container itself, we want the next client\n");
887 if (next ==
TAILQ_END(&(ws->focus_head))) {
888 DLOG(
"Focus list empty, returning ws\n");
901 DLOG(
"selecting workspace for dock client\n");
909 DLOG(
"Using first entry %p\n", first);
933 DLOG(
"con_get_next(way=%c, orientation=%d)\n", way, orientation);
937 DLOG(
"need to go one level further up\n");
939 LOG(
"that's a workspace, we can't go further up\n");
950 if (next ==
TAILQ_END(&(parent->nodes_head)))
955 if (next ==
TAILQ_END(&(cur->nodes_head)))
958 DLOG(
"next = %p\n", next);
993 if (child->
type == CT_FLOATING_CON)
999 }
while (before != next && next !=
focused);
1014 DLOG(
"con_descend_direction(%p, orientation %d, direction %d)\n", con, orientation, direction);
1016 if (orientation ==
HORIZ) {
1021 else most =
TAILQ_LAST(&(con->nodes_head), nodes_head);
1022 }
else if (orientation ==
VERT) {
1027 if (current->
type != CT_FLOATING_CON) {
1039 if (direction ==
D_UP || direction ==
D_DOWN) {
1040 if (orientation ==
VERT) {
1043 if (direction ==
D_UP)
1044 most =
TAILQ_LAST(&(con->nodes_head), nodes_head);
1046 }
else if (orientation ==
HORIZ) {
1051 if (current->
type != CT_FLOATING_CON) {
1081 DLOG(
"Effective border width is set to: %d\n", border_width);
1085 return (
Rect){ 0, 0, 0, 0 };
1088 result = (
Rect){border_width, 0 , -(2 * border_width), -(border_width)};
1090 result = (
Rect){border_width, border_width, -(2 * border_width), -(2 * border_width)};
1099 result.
x -= border_width;
1100 result.
width += border_width;
1103 result.
width += border_width;
1106 result.
y -= border_width;
1107 result.
height += border_width;
1110 result.
height += border_width;
1147 DLOG(
"this one is fullscreen! overriding BS_NONE\n");
1181 DLOG(
"This is a floating container\n");
1215 DLOG(
"con_set_layout(%p, %d), con->type = %d\n",
1216 con, layout, con->
type);
1221 if (con->
type != CT_WORKSPACE)
1234 if (con->
type == CT_WORKSPACE &&
1237 DLOG(
"Setting workspace_layout to %d\n", layout);
1240 DLOG(
"Creating new split container\n");
1251 if (old_focused ==
TAILQ_END(&(con->focus_head)))
1255 DLOG(
"Moving cons\n");
1264 DLOG(
"Attaching new split to ws\n");
1308 if (con->
type != CT_WORKSPACE)
1310 DLOG(
"con_toggle_layout(%p, %s), parent = %p\n", con, toggle_mode, parent);
1312 if (strcmp(toggle_mode,
"split") == 0) {
1327 if (strcmp(toggle_mode,
"all") == 0)
1331 if (strcmp(toggle_mode,
"all") == 0) {
1352 DLOG(
"on_remove_child\n");
1356 if (con->
type == CT_OUTPUT ||
1357 con->
type == CT_ROOT ||
1358 con->
type == CT_DOCKAREA ||
1360 DLOG(
"not handling, type = %d, name = %s\n", con->
type, con->
name);
1365 if (con->
type == CT_WORKSPACE) {
1367 LOG(
"Closing old workspace (%p / %s), it is empty\n", con, con->
name);
1369 ipc_send_event(
"workspace", I3_IPC_EVENT_WORKSPACE,
"{\"change\":\"empty\"}");
1381 if (children == 0) {
1382 DLOG(
"Container empty, closing\n");
1394 DLOG(
"Determining minimum size for con %p\n", con);
1397 DLOG(
"leaf node, returning 75x50\n");
1398 return (
Rect){ 0, 0, 75, 50 };
1401 if (con->
type == CT_FLOATING_CON) {
1402 DLOG(
"floating con\n");
1408 uint32_t max_width = 0, max_height = 0, deco_height = 0;
1413 max_width =
max(max_width, min.
width);
1414 max_height =
max(max_height, min.
height);
1416 DLOG(
"stacked/tabbed now, returning %d x %d + deco_rect = %d\n",
1417 max_width, max_height, deco_height);
1418 return (
Rect){ 0, 0, max_width, max_height + deco_height };
1437 DLOG(
"split container, returning width = %d x height = %d\n", width,
height);
1441 ELOG(
"Unhandled case, type = %d, layout = %d, split = %d\n",
1483 if (fs->
type == CT_WORKSPACE)
1538 bool new_urgency_value = con->
urgent;
1539 while (parent && parent->
type != CT_WORKSPACE && parent->
type != CT_DOCKAREA) {
1540 if (new_urgency_value) {
1558 DLOG(
"Ignoring urgency flag for current client\n");
1567 DLOG(
"Discarding urgency WM_HINT because timer is running\n");
1581 if (con->
urgent == urgent)
1582 LOG(
"Urgency flag changed to %d\n", con->
urgent);
1629 ELOG(
"BUG: Code not updated to account for new layout type\n");
1640 (
TAILQ_FIRST(&(con->nodes_head)) == child ?
"" :
" "), child_txt);
1650 return complete_buf;