i3
Data Structures | Macros | Functions | Variables
con.c File Reference
#include "all.h"
Include dependency graph for con.c:

Go to the source code of this file.

Data Structures

struct  bfs_entry

Macros

#define I3__FILE__   "con.c"

Functions

static void con_on_remove_child (Con *con)
Concon_new (Con *parent, i3Window *window)
 Create a new container (and attach it to the given parent, if not NULL).
void con_attach (Con *con, Con *parent, bool ignore_focus)
 Attaches the given container to the given parent.
void con_detach (Con *con)
 Detaches the given container from its current parent.
void con_focus (Con *con)
 Sets input focus to the given container.
bool con_is_leaf (Con *con)
 Returns true when this node is a leaf node (has no children)
bool con_accepts_window (Con *con)
 Returns true if this node accepts a window (if the node swallows windows, it might already have swallowed enough and cannot hold any more).
Concon_get_output (Con *con)
 Gets the output container (first container with CT_OUTPUT in hierarchy) this node is on.
Concon_get_workspace (Con *con)
 Gets the workspace container this node is on.
Concon_parent_with_orientation (Con *con, orientation_t orientation)
 Searches parenst of the given 'con' until it reaches one with the specified 'orientation'.
Concon_get_fullscreen_con (Con *con, int fullscreen_mode)
 Returns the first fullscreen node below this node.
bool con_is_floating (Con *con)
 Returns true if the node is floating.
Concon_inside_floating (Con *con)
 Checks if the given container is either floating or inside some floating container.
bool con_inside_focused (Con *con)
 Checks if the given container is inside a focused container.
Concon_by_window_id (xcb_window_t window)
 Returns the container with the given client window ID or NULL if no such container exists.
Concon_by_frame_id (xcb_window_t frame)
 Returns the container with the given frame ID or NULL if no such container exists.
Concon_for_window (Con *con, i3Window *window, Match **store_match)
 Returns the first container below 'con' which wants to swallow this window TODO: priority.
int con_num_children (Con *con)
 Returns the number of children of this container.
void con_fix_percent (Con *con)
 Updates the percent attribute of the children of the given container.
void con_toggle_fullscreen (Con *con, int fullscreen_mode)
 Toggles fullscreen mode for the given container.
void con_move_to_workspace (Con *con, Con *workspace, bool fix_coordinates, bool dont_warp)
 Moves the given container to the currently focused container on the given workspace.
int con_orientation (Con *con)
 Returns the orientation of the given container (for stacked containers, vertical orientation is used regardless of the actual orientation of the container).
Concon_next_focused (Con *con)
 Returns the container which will be focused next when the given container is not available anymore.
Concon_get_next (Con *con, char way, orientation_t orientation)
 Get the next/previous container in the specified orientation.
Concon_descend_focused (Con *con)
 Returns the focused con inside this client, descending the tree as far as possible.
Concon_descend_tiling_focused (Con *con)
 Returns the focused con inside this client, descending the tree as far as possible.
Concon_descend_direction (Con *con, direction_t direction)
Rect con_border_style_rect (Con *con)
 Returns a "relative" Rect which contains the amount of pixels that need to be added to the original Rect to get the final position (obviously the amount of pixels for normal, 1pixel and borderless are different).
adjacent_t con_adjacent_borders (Con *con)
 Returns adjacent borders of the window.
int con_border_style (Con *con)
 Use this function to get a container’s border style.
void con_set_border_style (Con *con, int border_style)
 Sets the given border style on con, correctly keeping the position/size of a floating window.
void con_set_layout (Con *con, int layout)
 This function changes the layout of a given container.
void con_toggle_layout (Con *con, const char *toggle_mode)
 This function toggles the layout of a given container.
Rect con_minimum_size (Con *con)
 Determines the minimum size of the given con by looking at its children (for split/stacked/tabbed cons).
bool con_fullscreen_permits_focusing (Con *con)
 Returns true if changing the focus to con would be allowed considering the fullscreen focus constraints.

Variables

char * colors []

Macro Definition Documentation

#define I3__FILE__   "con.c"

Definition at line 2 of file con.c.

Function Documentation

bool con_accepts_window ( Con con)

Returns true if this node accepts a window (if the node swallows windows, it might already have swallowed enough and cannot hold any more).

Definition at line 217 of file con.c.

References DLOG, Con::split, Con::type, and Con::window.

Referenced by manage_window().

adjacent_t con_adjacent_borders ( Con con)

Returns adjacent borders of the window.

We need this if hide_edge_borders is enabled.

Definition at line 994 of file con.c.

References ADJ_LEFT_SCREEN_EDGE, ADJ_LOWER_SCREEN_EDGE, ADJ_NONE, ADJ_RIGHT_SCREEN_EDGE, ADJ_UPPER_SCREEN_EDGE, con_get_workspace(), Rect::height, Con::rect, Rect::width, Rect::x, and Rect::y.

Referenced by con_border_style_rect().

Here is the call graph for this function:

void con_attach ( Con con,
Con parent,
bool  ignore_focus 
)

Attaches the given container to the given parent.

This happens when moving a container or when inserting a new container at a specific place in the tree.

ignore_focus is to just insert the Con at the end (useful when creating a new split container around some containers, that is, detaching and attaching them in order without wanting to mess with the focus in between).

Definition at line 80 of file con.c.

References DLOG, focused, Con::num, Con::parent, TAILQ_EMPTY, TAILQ_END, TAILQ_FIRST, TAILQ_FOREACH, TAILQ_INSERT_AFTER, TAILQ_INSERT_BEFORE, TAILQ_INSERT_HEAD, TAILQ_INSERT_TAIL, TAILQ_NEXT, Con::type, Con::window, workspace_attach_to(), and Con::workspace_layout.

Referenced by _create___i3(), cmd_move_workspace_to_output(), cmd_rename_workspace(), con_move_to_workspace(), con_new(), con_set_layout(), create_workspace_on_output(), floating_disable(), floating_enable(), init_ws_for_output(), insert_con_into(), json_end_map(), output_init_con(), randr_query_outputs(), tree_split(), workspace_attach_to(), workspace_get(), and ws_force_orientation().

Here is the call graph for this function:

int con_border_style ( Con con)

Use this function to get a container’s border style.

This is important because when inside a stack, the border style is always BS_NORMAL. For tabbed mode, the same applies, with one exception: when the container is borderless and the only element in the tabbed container, the border is not rendered.

For children of a CT_DOCKAREA, the border style is always none.

Definition at line 1018 of file con.c.

References Con::border_style, BS_NONE, BS_NORMAL, con_get_fullscreen_con(), con_num_children(), DLOG, Con::layout, Con::parent, and Con::type.

Referenced by con_border_style_rect(), floating_enable(), and x_draw_decoration().

Here is the call graph for this function:

Rect con_border_style_rect ( Con con)

Returns a "relative" Rect which contains the amount of pixels that need to be added to the original Rect to get the final position (obviously the amount of pixels for normal, 1pixel and borderless are different).

Definition at line 940 of file con.c.

References ADJ_LEFT_SCREEN_EDGE, ADJ_LOWER_SCREEN_EDGE, ADJ_NONE, ADJ_RIGHT_SCREEN_EDGE, ADJ_UPPER_SCREEN_EDGE, BS_1PIXEL, BS_NONE, BS_NORMAL, con_adjacent_borders(), con_border_style(), config, Rect::height, Config::hide_edge_borders, Rect::width, Rect::x, and Rect::y.

Referenced by con_set_border_style(), floating_enable(), handle_configure_request(), render_con(), and tiling_resize().

Here is the call graph for this function:

Con* con_by_frame_id ( xcb_window_t  frame)

Returns the container with the given frame ID or NULL if no such container exists.

Definition at line 399 of file con.c.

References all_cons, bfs_entry::con, Con::frame, and TAILQ_FOREACH.

Referenced by handle_button_press(), handle_enter_notify(), handle_expose_event(), handle_motion_notify(), and handle_unmap_notify_event().

Con* con_by_window_id ( xcb_window_t  window)
Con* con_descend_direction ( Con con,
direction_t  direction 
)

Definition at line 887 of file con.c.

References bfs_entry::con, con_descend_direction(), con_orientation(), D_DOWN, D_LEFT, D_RIGHT, D_UP, DLOG, HORIZ, TAILQ_FIRST, TAILQ_LAST, and VERT.

Referenced by _tree_next(), and con_descend_direction().

Here is the call graph for this function:

Con* con_descend_focused ( Con con)

Returns the focused con inside this client, descending the tree as far as possible.

This comes in handy when attaching a con to a workspace at the currently focused position, for example.

Definition at line 846 of file con.c.

References bfs_entry::con, focused, TAILQ_EMPTY, and TAILQ_FIRST.

Referenced by _tree_next(), _workspace_show(), check_crossing_screen_boundary(), cmd_focus_window_mode(), con_move_to_workspace(), con_next_focused(), floating_maybe_reassign_ws(), handle_enter_notify(), main(), randr_query_outputs(), route_click(), scratchpad_show(), tree_close(), and tree_move().

Con* con_descend_tiling_focused ( Con con)

Returns the focused con inside this client, descending the tree as far as possible.

This comes in handy when attaching a con to a workspace at the currently focused position, for example.

Works like con_descend_focused but considers only tiling cons.

Definition at line 861 of file con.c.

References bfs_entry::con, focused, TAILQ_FOREACH, and Con::type.

Referenced by floating_disable(), manage_window(), and tree_open_con().

void con_detach ( Con con)
void con_fix_percent ( Con con)

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 container.

Definition at line 467 of file con.c.

References con_num_children(), Con::percent, and TAILQ_FOREACH.

Referenced by _create___i3(), attach_to_workspace(), con_move_to_workspace(), floating_disable(), floating_enable(), insert_con_into(), output_init_con(), resize_graphical_handler(), tree_close(), tree_open_con(), and ws_force_orientation().

Here is the call graph for this function:

void con_focus ( Con con)
Con* con_for_window ( Con con,
i3Window window,
Match **  store_match 
)

Returns the first container below 'con' which wants to swallow this window TODO: priority.

Definition at line 412 of file con.c.

References con_for_window(), match_matches_window(), and TAILQ_FOREACH.

Referenced by con_for_window(), manage_window(), and randr_query_outputs().

Here is the call graph for this function:

bool con_fullscreen_permits_focusing ( Con con)

Returns true if changing the focus to con would be allowed considering the fullscreen focus constraints.

Specifically, if a fullscreen container or any of its descendants is focused, this function returns true if and only if focusing con would mean that focus would still be visible on screen, i.e., the newly focused container would not be obscured by a fullscreen container.

In the simplest case, if a fullscreen container or any of its descendants is fullscreen, this functions returns true if con is the fullscreen container itself or any of its descendants, as this means focus wouldn't escape the boundaries of the fullscreen container.

In case the fullscreen container is of type CF_OUTPUT, this function returns true if con is on a different workspace, as focus wouldn't be obscured by the fullscreen container that is constrained to a different workspace.

Note that this same logic can be applied to moving containers. If a container can be focused under the fullscreen focus constraints, it can also become a parent or sibling to the currently focused container.

Definition at line 1333 of file con.c.

References con_get_workspace(), focused, Con::fullscreen_mode, Con::parent, and Con::type.

Referenced by _tree_next(), cmd_focus(), cmd_focus_level(), con_move_to_workspace(), and tree_move().

Here is the call graph for this function:

Con* con_get_fullscreen_con ( Con con,
int  fullscreen_mode 
)
Con* con_get_next ( Con con,
char  way,
orientation_t  orientation 
)

Get the next/previous container in the specified orientation.

This may travel up until it finds a container with suitable orientation.

Definition at line 809 of file con.c.

References bfs_entry::con, con_orientation(), DLOG, LOG, Con::parent, TAILQ_END, TAILQ_NEXT, TAILQ_PREV, and Con::type.

Here is the call graph for this function:

Con* con_get_output ( Con con)
Con* con_get_workspace ( Con con)
Con* con_inside_floating ( Con con)

Checks if the given container is either floating or inside some floating container.

It returns the FLOATING_CON container.

Definition at line 355 of file con.c.

References bfs_entry::con, con_inside_floating(), Con::floating, Con::parent, and Con::type.

Referenced by cmd_resize(), con_inside_floating(), con_move_to_workspace(), render_con(), route_click(), scratchpad_show(), and tree_move().

Here is the call graph for this function:

bool con_inside_focused ( Con con)

Checks if the given container is inside a focused container.

Definition at line 373 of file con.c.

References con_inside_focused(), focused, and Con::parent.

Referenced by con_inside_focused(), and x_draw_decoration().

Here is the call graph for this function:

bool con_is_floating ( Con con)
bool con_is_leaf ( Con con)

Returns true when this node is a leaf node (has no children)

Definition at line 208 of file con.c.

References TAILQ_EMPTY.

Referenced by con_minimum_size(), handle_configure_request(), render_con(), tiling_resize(), tree_move(), and x_draw_decoration().

Rect con_minimum_size ( Con con)

Determines the minimum size of the given con by looking at its children (for split/stacked/tabbed cons).

Will be called when resizing floating cons

Definition at line 1259 of file con.c.

References con_is_leaf(), con_minimum_size(), Con::deco_rect, DLOG, ELOG, Rect::height, height, Con::layout, max(), min(), Con::split, TAILQ_FIRST, TAILQ_FOREACH, Con::type, Rect::width, and width.

Referenced by con_minimum_size(), and DRAGGING_CB().

Here is the call graph for this function:

void con_move_to_workspace ( Con con,
Con workspace,
bool  fix_coordinates,
bool  dont_warp 
)

Moves the given container to the currently focused container on the given workspace.

The fix_coordinates flag will translate the current coordinates (offset from the monitor position basically) to appropriate coordinates on the destination workspace. Not enabling this behaviour comes in handy when this function gets called by floating_maybe_reassign_ws, which will only "move" a floating window when it already changed its coordinates to a different output.

The dont_warp flag disables pointer warping and will be set when this function is called while dragging a floating window.

TODO: is there a better place for this function?

Definition at line 578 of file con.c.

References CALL, con_attach(), con_descend_focused(), con_detach(), con_fix_percent(), con_focus(), con_fullscreen_permits_focusing(), con_get_fullscreen_con(), con_get_output(), con_get_workspace(), con_inside_floating(), con_is_floating(), con_next_focused(), DLOG, floating_fix_coordinates(), focused, LOG, Con::name, Con::parent, Con::percent, Con::rect, Con::type, workspace_is_visible(), workspace_show(), and x_set_warp_to().

Referenced by cmd_move_con_to_output(), cmd_move_con_to_workspace(), cmd_move_con_to_workspace_name(), cmd_move_con_to_workspace_number(), floating_maybe_reassign_ws(), scratchpad_move(), and scratchpad_show().

Here is the call graph for this function:

Con* con_new ( Con parent,
i3Window window 
)

Create a new container (and attach it to the given parent, if not NULL).

This function initializes the data structures and creates the appropriate X11 IDs using x_con_init().

Definition at line 37 of file con.c.

References all_cons, colors, con_attach(), con_on_remove_child(), config, Config::default_border, Window::depth, DLOG, scalloc(), TAILQ_INIT, TAILQ_INSERT_TAIL, and x_con_init().

Referenced by _create___i3(), con_set_layout(), create_workspace_on_output(), floating_enable(), output_init_con(), TAILQ_HEAD(), tree_init(), tree_open_con(), tree_restore(), tree_split(), workspace_attach_to(), workspace_get(), and ws_force_orientation().

Here is the call graph for this function:

Con* con_next_focused ( Con con)

Returns the container which will be focused next when the given container is not available anymore.

Called in tree_close and con_move_to_workspace to properly restore focus.

Definition at line 741 of file con.c.

References con_descend_focused(), con_get_workspace(), DLOG, focused, output_get_content(), Con::parent, TAILQ_EMPTY, TAILQ_END, TAILQ_FIRST, TAILQ_NEXT, TAILQ_PREV, and Con::type.

Referenced by con_move_to_workspace(), scratchpad_move(), and tree_close().

Here is the call graph for this function:

int con_num_children ( Con con)
static void con_on_remove_child ( Con con)
static

Definition at line 1222 of file con.c.

References con_num_children(), DLOG, DONT_KILL_WINDOW, ipc_send_event(), LOG, Con::name, TAILQ_EMPTY, tree_close(), Con::type, and workspace_is_visible().

Referenced by con_new().

Here is the call graph for this function:

int con_orientation ( Con con)

Returns the orientation of the given container (for stacked containers, vertical orientation is used regardless of the actual orientation of the container).

Definition at line 706 of file con.c.

References DLOG, HORIZ, Con::layout, and VERT.

Referenced by _tree_next(), cmd_resize_tiling_direction(), cmd_resize_tiling_width_height(), con_descend_direction(), con_get_next(), con_parent_with_orientation(), dump_node(), render_con(), tiling_resize(), tiling_resize_for_border(), and tree_flatten().

Con* con_parent_with_orientation ( Con con,
orientation_t  orientation 
)

Searches parenst of the given 'con' until it reaches one with the specified 'orientation'.

Aborts when it comes across a floating_con.

Definition at line 262 of file con.c.

References con_orientation(), DLOG, Con::parent, and Con::type.

Referenced by tree_move().

Here is the call graph for this function:

void con_set_border_style ( Con con,
int  border_style 
)

Sets the given border style on con, correctly keeping the position/size of a floating window.

Definition at line 1042 of file con.c.

References Con::border_style, BS_NORMAL, con_border_style_rect(), con_is_floating(), config, DLOG, Config::font, Font::height, Rect::height, Con::parent, Con::rect, Rect::width, Rect::x, and Rect::y.

Referenced by cmd_border().

Here is the call graph for this function:

void con_set_layout ( Con con,
int  layout 
)

This function changes the layout of a given container.

Use it to handle special cases like changing a whole workspace to stacked/tabbed (creates a new split container before).

Definition at line 1086 of file con.c.

References bfs_entry::con, con_attach(), con_detach(), con_focus(), con_new(), con_num_children(), croot, DLOG, Con::last_split_layout, Con::layout, Con::parent, Con::split, TAILQ_EMPTY, TAILQ_END, TAILQ_FIRST, tree_flatten(), Con::type, and Con::workspace_layout.

Referenced by cmd_layout(), and con_toggle_layout().

Here is the call graph for this function:

void con_toggle_fullscreen ( Con con,
int  fullscreen_mode 
)

Toggles fullscreen mode for the given container.

Fullscreen mode will not be entered when there already is a fullscreen container on this workspace.

Definition at line 510 of file con.c.

References con_get_fullscreen_con(), con_get_workspace(), conn, croot, DLOG, Con::fullscreen_mode, Window::id, LOG, Con::name, Con::type, Con::window, and XCB_ATOM_ATOM.

Referenced by cmd_fullscreen(), handle_client_message(), manage_window(), and scratchpad_show().

Here is the call graph for this function:

void con_toggle_layout ( Con con,
const char *  toggle_mode 
)

This function toggles the layout of a given container.

toggle_mode can be either 'default' (toggle only between stacked/tabbed/last_split_layout), 'split' (toggle only between splitv/splith) or 'all' (toggle between all layouts).

Definition at line 1174 of file con.c.

References bfs_entry::con, con_set_layout(), DLOG, Con::last_split_layout, Con::layout, Con::parent, and Con::type.

Referenced by cmd_layout_toggle().

Here is the call graph for this function:

Variable Documentation

char* colors[]
Initial value:
{
"#ff0000",
"#00FF00",
"#0000FF",
"#ff00ff",
"#00ffff",
"#ffff00",
"#aa0000",
"#00aa00",
"#0000aa",
"#aa00aa"
}

Definition at line 16 of file con.c.

Referenced by con_new().