X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fcon.c;h=dbb6d6014559a895d006198dceee1b932bab14e4;hb=4bec3b9d24fe0bd7bab4792497bbd02bffaa6620;hp=51b2a3f606e5c9ad533d4fc9d27d16ba1e7e93d2;hpb=08976f7a2a836a81731c45f6e8bbb8b8738d0a05;p=i3%2Fi3 diff --git a/src/con.c b/src/con.c index 51b2a3f6..dbb6d601 100644 --- a/src/con.c +++ b/src/con.c @@ -68,7 +68,7 @@ Con *con_new_skeleton(Con *parent, i3Window *window) { */ Con *con_new(Con *parent, i3Window *window) { Con *new = con_new_skeleton(parent, window); - x_con_init(new, new->depth); + x_con_init(new); return new; } @@ -727,6 +727,49 @@ int con_num_children(Con *con) { return children; } +/** + * Returns the number of visible non-floating children of this container. + * For example, if the container contains a hsplit which has two children, + * this will return 2 instead of 1. + */ +int con_num_visible_children(Con *con) { + if (con == NULL) + return 0; + + int children = 0; + Con *current = NULL; + TAILQ_FOREACH(current, &(con->nodes_head), nodes) { + /* Visible leaf nodes are a child. */ + if (!con_is_hidden(current) && con_is_leaf(current)) + children++; + /* All other containers need to be recursed. */ + else + children += con_num_visible_children(current); + } + + return children; +} + +/* + * Count the number of windows (i.e., leaf containers). + * + */ +int con_num_windows(Con *con) { + if (con == NULL) + return 0; + + if (con_has_managed_window(con)) + return 1; + + int num = 0; + Con *current = NULL; + TAILQ_FOREACH(current, &(con->nodes_head), nodes) { + num += con_num_windows(current); + } + + return num; +} + /* * Updates the percent attribute of the children of the given container. This * function needs to be called when a window is added or removed from a @@ -1080,6 +1123,7 @@ static bool _con_move_to_con(Con *con, Con *target, bool behind_focused, bool fi CALL(parent, on_remove_child); ipc_send_window_event("move", con); + ewmh_update_wm_desktop(); return true; } @@ -1156,6 +1200,19 @@ void con_move_to_workspace(Con *con, Con *workspace, bool fix_coordinates, bool _con_move_to_con(con, target, true, fix_coordinates, dont_warp, ignore_focus); } +/* + * Moves the given container to the currently focused container on the + * visible workspace on the given output. + * + */ +void con_move_to_output(Con *con, Output *output) { + Con *ws = NULL; + GREP_FIRST(ws, output_get_content(output->con), workspace_is_visible(child)); + assert(ws != NULL); + DLOG("Moving con %p to output %s\n", con, output->name); + con_move_to_workspace(con, ws, false, false, false); +} + /* * Returns the orientation of the given container (for stacked containers, * vertical orientation is used regardless of the actual orientation of the @@ -1410,6 +1467,12 @@ Con *con_descend_direction(Con *con, direction_t direction) { * */ Rect con_border_style_rect(Con *con) { + if (config.hide_edge_borders == HEBM_SMART && con_num_visible_children(con_get_workspace(con)) <= 1) { + if (!con_is_floating(con)) { + return (Rect){0, 0, 0, 0}; + } + } + adjacent_t borders_to_hide = ADJ_NONE; int border_width = con->current_border_width; DLOG("The border width for con is set to: %d\n", con->current_border_width); @@ -1992,6 +2055,7 @@ char *con_get_tree_representation(Con *con) { (TAILQ_FIRST(&(con->nodes_head)) == child ? "" : " "), child_txt); free(buf); buf = tmp_buf; + free(child_txt); } /* 3) close the brackets */