i3
tree.c File Reference
#include "all.h"
Include dependency graph for tree.c:

Go to the source code of this file.

Functions

static Con_create___i3 (void)
 
bool tree_restore (const char *path, xcb_get_geometry_reply_t *geometry)
 Loads tree from ~/.i3/_restart.json (used for in-place restarts).
 
void tree_init (xcb_get_geometry_reply_t *geometry)
 Initializes the tree by creating the root node, adding all RandR outputs to the tree (that means randr_init() has to be called before) and assigning a workspace to each RandR output.
 
Contree_open_con (Con *con, i3Window *window)
 Opens an empty container in the current container.
 
bool tree_close_internal (Con *con, kill_window_t kill_window, bool dont_kill_parent)
 Closes the given container including all children.
 
void tree_split (Con *con, orientation_t orientation)
 Splits (horizontally or vertically) the given container by creating a new container which contains the old one and the future ones.
 
bool level_up (void)
 Moves focus one level up.
 
bool level_down (void)
 Moves focus one level down.
 
static void mark_unmapped (Con *con)
 
void tree_render (void)
 Renders the tree, that is rendering all outputs using render_con() and pushing the changes to X11 using x_push_changes().
 
static Conget_tree_next_workspace (Con *con, direction_t direction)
 
static Conget_tree_next (Con *con, direction_t direction)
 
void tree_next (Con *con, direction_t direction)
 Changes focus in the given direction.
 
Conget_tree_next_sibling (Con *con, position_t direction)
 Get the previous / next sibling.
 
void tree_flatten (Con *con)
 tree_flatten() removes pairs of redundant split containers, e.g.: [workspace, horizontal] [v-split] [child3] [h-split] [child1] [child2] In this example, the v-split and h-split container are redundant.
 

Variables

struct Concroot
 
struct Confocused
 
struct all_cons_head all_cons = TAILQ_HEAD_INITIALIZER(all_cons)
 

Function Documentation

◆ _create___i3()

static Con * _create___i3 ( void )
static

Definition at line 22 of file tree.c.

References CF_OUTPUT, con_attach(), con_fix_percent(), con_new(), croot, DLOG, FREE, Con::fullscreen_mode, Rect::height, L_OUTPUT, L_SPLITH, Con::layout, Con::name, Con::num, Con::rect, sstrdup(), Con::type, Rect::width, and x_set_name().

Referenced by tree_init(), and tree_restore().

Here is the call graph for this function:

◆ get_tree_next()

◆ get_tree_next_sibling()

Con * get_tree_next_sibling ( Con * con,
position_t direction )

Get the previous / next sibling.

Definition at line 638 of file tree.c.

References BEFORE, con_fullscreen_permits_focusing(), TAILQ_NEXT, TAILQ_PREV, and to_focus.

Referenced by cmd_focus_sibling(), and route_click().

Here is the call graph for this function:

◆ get_tree_next_workspace()

static Con * get_tree_next_workspace ( Con * con,
direction_t direction )
static

◆ level_down()

bool level_down ( void )

Moves focus one level down.

Returns true if focus changed.

Definition at line 412 of file tree.c.

References con_activate(), DLOG, focused, TAILQ_END, TAILQ_FIRST, and Con::type.

Referenced by cmd_focus_level().

Here is the call graph for this function:

◆ level_up()

bool level_up ( void )

Moves focus one level up.

Returns true if focus changed.

Definition at line 389 of file tree.c.

References con_activate(), ELOG, focused, Con::parent, and Con::type.

Referenced by cmd_focus_level().

Here is the call graph for this function:

◆ mark_unmapped()

static void mark_unmapped ( Con * con)
static

Definition at line 434 of file tree.c.

References Con::mapped, mark_unmapped(), TAILQ_FOREACH, and Con::type.

Referenced by mark_unmapped(), and tree_render().

Here is the call graph for this function:

◆ tree_close_internal()

bool tree_close_internal ( Con * con,
kill_window_t kill_window,
bool dont_kill_parent )

Closes the given container including all children.

Returns true if the container was killed or false if just WM_DELETE was sent and the window is expected to kill itself.

The dont_kill_parent flag is specified when the function calls itself recursively while deleting a containers children.

Definition at line 192 of file tree.c.

References add_ignore_event(), CALL, con_activate(), con_detach(), con_fix_percent(), con_free(), con_get_workspace(), con_next_focused(), con_set_urgency(), con_update_parents_urgency(), conn, DLOG, DONT_KILL_WINDOW, ewmh_update_desktop_properties(), focused, FREE, Window::id, ipc_send_window_event(), main_loop, Con::name, Con::parent, Con::rect, root, shape_supported, TAILQ_FIRST, TAILQ_NEXT, tree_close_internal(), tree_render(), Con::type, Con::urgency_timer, Con::urgent, Con::window, window_free(), workspace_update_urgent_flag(), Rect::x, x_con_kill(), x_window_kill(), and Rect::y.

Referenced by con_close(), con_merge_into(), con_on_remove_child(), con_set_layout(), floating_disable(), floating_enable(), handle_client_message(), handle_unmap_notify_event(), move_content(), tree_close_internal(), tree_flatten(), and workspace_show().

Here is the call graph for this function:

◆ tree_flatten()

void tree_flatten ( Con * child)

tree_flatten() removes pairs of redundant split containers, e.g.: [workspace, horizontal] [v-split] [child3] [h-split] [child1] [child2] In this example, the v-split and h-split container are redundant.

Such a situation can be created by moving containers in a direction which is not the orientation of their parent container. i3 needs to create a new split container then and if you move containers this way multiple times, redundant chains of split-containers can be the result.

Definition at line 660 of file tree.c.

References con_detach(), con_is_split(), con_orientation(), DLOG, DONT_KILL_WINDOW, focused, L_OUTPUT, L_SPLITH, L_SPLITV, Con::layout, Con::name, Con::parent, Con::percent, TAILQ_EMPTY, TAILQ_FIRST, TAILQ_INSERT_BEFORE, TAILQ_INSERT_HEAD, TAILQ_INSERT_TAIL, TAILQ_NEXT, TAILQ_REMOVE, tree_close_internal(), tree_flatten(), Con::type, and Con::window.

Referenced by con_set_layout(), move_to_output_directed(), tree_flatten(), and tree_move().

Here is the call graph for this function:

◆ tree_init()

void tree_init ( xcb_get_geometry_reply_t * geometry)

Initializes the tree by creating the root node, adding all RandR outputs to the tree (that means randr_init() has to be called before) and assigning a workspace to each RandR output.

Definition at line 130 of file tree.c.

References _create___i3(), con_new(), croot, FREE, L_SPLITH, Con::layout, Con::name, Con::rect, and Con::type.

Referenced by main().

Here is the call graph for this function:

◆ tree_next()

void tree_next ( Con * con,
direction_t direction )

Changes focus in the given direction.

Definition at line 596 of file tree.c.

References CF_NONE, con_activate(), con_descend_focused(), con_descend_tiling_focused(), con_get_workspace(), Con::fullscreen_mode, get_tree_next(), Con::parent, Con::rect, TAILQ_INSERT_HEAD, TAILQ_LAST, TAILQ_REMOVE, Con::type, workspace_show(), and x_set_warp_to().

Referenced by cmd_focus_direction().

Here is the call graph for this function:

◆ tree_open_con()

Con * tree_open_con ( Con * con,
i3Window * window )

Opens an empty container in the current container.

Definition at line 149 of file tree.c.

References con_descend_tiling_focused(), con_fix_percent(), con_new(), DLOG, focused, L_SPLITH, Con::parent, and Con::type.

Referenced by cmd_open(), and manage_window().

Here is the call graph for this function:

◆ tree_render()

◆ tree_restore()

bool tree_restore ( const char * path,
xcb_get_geometry_reply_t * geometry )

Loads tree from ~/.i3/_restart.json (used for in-place restarts).

Definition at line 66 of file tree.c.

References _create___i3(), con_new(), croot, DLOG, focused, LOG, Con::name, path_exists(), Con::rect, resolve_tilde(), restore_open_placeholder_windows(), slurp(), TAILQ_FIRST, TAILQ_INSERT_HEAD, TAILQ_REMOVE, and tree_append_json().

Referenced by main().

Here is the call graph for this function:

◆ tree_split()

void tree_split ( Con * con,
orientation_t orientation )

Splits (horizontally or vertically) the given container by creating a new container which contains the old one and the future ones.

Definition at line 330 of file tree.c.

References con_attach(), con_force_split_parents_redraw(), con_is_floating(), con_new(), con_num_children(), DLOG, focused, HORIZ, L_DEFAULT, L_SPLITH, L_SPLITV, Con::layout, Con::parent, Con::percent, TAILQ_REPLACE, Con::type, workspace_encapsulate(), and Con::workspace_layout.

Referenced by cmd_split(), and tiling_drag().

Here is the call graph for this function:

Variable Documentation

◆ all_cons

◆ croot

◆ focused

struct Con* focused

Definition at line 13 of file tree.c.

Referenced by _con_attach(), _con_move_to_con(), attach_to_workspace(), CFGFUN(), check_crossing_screen_boundary(), cmd_append_layout(), cmd_focus_level(), cmd_focus_output(), cmd_focus_window_mode(), cmd_layout_toggle(), cmd_move_con_to_workspace(), cmd_rename_workspace(), cmd_sticky(), con_activate_unblock(), con_close(), con_descend_direction(), con_descend_focused(), con_descend_tiling_focused(), con_detach(), con_enable_fullscreen(), con_focus(), con_fullscreen_permits_focusing(), con_inside_focused(), con_next_focused(), con_set_urgency(), con_swap(), drain_drag_events(), dump_node(), ewmh_update_current_desktop(), floating_enable(), gaps_update(), get_focus_order(), get_output_from_string(), handle_button_press(), handle_client_message(), handle_enter_notify(), handle_focus_in(), handle_net_wm_state_change(), has_drop_targets(), init_ws_for_output(), insert_con_into(), IPC_HANDLER(), json_end_array(), level_down(), level_up(), manage_window(), match_matches_window(), match_parse_property(), maybe_auto_back_and_forth_workspace(), maybe_back_and_forth(), move_content(), move_to_output_directed(), num_focus_heads(), output_init_con(), output_push_sticky_windows(), render_con(), route_click(), scratchpad_move(), scratchpad_show(), set_focus_order(), start_application(), tiling_drag(), tree_close_internal(), tree_flatten(), tree_open_con(), tree_restore(), tree_split(), workspace_get(), workspace_next(), workspace_next_on_output(), workspace_prev(), workspace_prev_on_output(), workspace_show(), x_draw_decoration(), x_push_changes(), and x_push_node().