2010-03-27 10:25:51 -04:00
|
|
|
/*
|
|
|
|
* vim:ts=4:sw=4:expandtab
|
2011-10-25 16:19:38 -04:00
|
|
|
*
|
|
|
|
* i3 - an improved dynamic tiling window manager
|
2015-04-03 20:17:56 -04:00
|
|
|
* © 2009 Michael Stapelberg and contributors (see also: LICENSE)
|
2011-10-25 16:19:38 -04:00
|
|
|
*
|
|
|
|
* tree.c: Everything that primarily modifies the layout tree data structure.
|
|
|
|
*
|
2010-03-27 10:25:51 -04:00
|
|
|
*/
|
2013-12-28 21:11:50 -05:00
|
|
|
#pragma once
|
2010-03-27 10:25:51 -04:00
|
|
|
|
|
|
|
extern Con *croot;
|
|
|
|
/* TODO: i am not sure yet how much access to the focused container should
|
|
|
|
* be permitted to source files */
|
|
|
|
extern Con *focused;
|
|
|
|
TAILQ_HEAD(all_cons_head, Con);
|
|
|
|
extern struct all_cons_head all_cons;
|
|
|
|
|
2010-07-13 05:35:05 -04:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
2011-06-10 12:27:20 -04:00
|
|
|
void tree_init(xcb_get_geometry_reply_t *geometry);
|
2010-07-13 05:35:05 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Opens an empty container in the current container
|
|
|
|
*
|
|
|
|
*/
|
2011-06-02 11:21:38 -04:00
|
|
|
Con *tree_open_con(Con *con, i3Window *window);
|
2010-07-13 05:35:05 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Splits (horizontally or vertically) the given container by creating a new
|
|
|
|
* container which contains the old one and the future ones.
|
|
|
|
*
|
|
|
|
*/
|
2010-03-27 10:25:51 -04:00
|
|
|
void tree_split(Con *con, orientation_t orientation);
|
2010-07-13 05:35:05 -04:00
|
|
|
|
|
|
|
/**
|
2012-05-26 17:36:25 -04:00
|
|
|
* Moves focus one level up. Returns true if focus changed.
|
2010-07-13 05:35:05 -04:00
|
|
|
*
|
|
|
|
*/
|
2012-05-26 17:36:25 -04:00
|
|
|
bool level_up(void);
|
2010-07-13 05:35:05 -04:00
|
|
|
|
|
|
|
/**
|
2012-05-26 17:36:25 -04:00
|
|
|
* Moves focus one level down. Returns true if focus changed.
|
2010-07-13 05:35:05 -04:00
|
|
|
*
|
|
|
|
*/
|
2012-05-26 17:36:25 -04:00
|
|
|
bool level_down(void);
|
2010-07-13 05:35:05 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders the tree, that is rendering all outputs using render_con() and
|
|
|
|
* pushing the changes to X11 using x_push_changes().
|
|
|
|
*
|
|
|
|
*/
|
2012-03-31 04:53:04 -04:00
|
|
|
void tree_render(void);
|
2010-07-13 05:35:05 -04:00
|
|
|
|
|
|
|
/**
|
2015-12-27 20:58:35 -05:00
|
|
|
* Closes the current container using tree_close_internal().
|
2010-07-13 05:35:05 -04:00
|
|
|
*
|
|
|
|
*/
|
2011-05-13 14:41:03 -04:00
|
|
|
void tree_close_con(kill_window_t kill_window);
|
2010-07-13 05:35:05 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Changes focus in the given way (next/previous) and given orientation
|
|
|
|
* (horizontal/vertical).
|
|
|
|
*
|
|
|
|
*/
|
2010-03-27 10:25:51 -04:00
|
|
|
void tree_next(char way, orientation_t orientation);
|
2010-07-13 05:35:05 -04:00
|
|
|
|
|
|
|
/**
|
2011-05-11 14:22:47 -04:00
|
|
|
* 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.
|
2010-07-13 05:35:05 -04:00
|
|
|
*
|
2011-09-21 18:28:01 -04:00
|
|
|
* The dont_kill_parent flag is specified when the function calls itself
|
|
|
|
* recursively while deleting a containers children.
|
|
|
|
*
|
|
|
|
* The force_set_focus flag is specified in the case of killing a floating
|
2015-12-27 20:58:35 -05:00
|
|
|
* window: tree_close_internal() will be invoked for the CT_FLOATINGCON (the parent
|
2011-09-21 18:28:01 -04:00
|
|
|
* container) and focus should be set there.
|
|
|
|
*
|
2010-07-13 05:35:05 -04:00
|
|
|
*/
|
2015-12-27 20:58:35 -05:00
|
|
|
bool tree_close_internal(Con *con, kill_window_t kill_window, bool dont_kill_parent, bool force_set_focus);
|
2010-07-13 05:35:05 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Loads tree from ~/.i3/_restart.json (used for in-place restarts).
|
|
|
|
*
|
|
|
|
*/
|
2011-06-10 12:27:20 -04:00
|
|
|
bool tree_restore(const char *path, xcb_get_geometry_reply_t *geometry);
|
2010-03-27 10:25:51 -04:00
|
|
|
|
2011-01-07 16:21:41 -05:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void tree_flatten(Con *child);
|