gri3-wm/include/tree.h

104 lines
2.7 KiB
C
Raw Normal View History

/*
* vim:ts=4:sw=4:expandtab
*
* i3 - an improved dynamic tiling window manager
* © 2009 Michael Stapelberg and contributors (see also: LICENSE)
*
* tree.c: Everything that primarily modifies the layout tree data structure.
*
*/
#pragma once
#include <config.h>
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;
/**
* 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 18:27:20 +02:00
void tree_init(xcb_get_geometry_reply_t *geometry);
/**
* Opens an empty container in the current container
*
*/
Con *tree_open_con(Con *con, i3Window *window);
/**
* Splits (horizontally or vertically) the given container by creating a new
* container which contains the old one and the future ones.
*
*/
void tree_split(Con *con, orientation_t orientation);
/**
* Moves focus one level up. Returns true if focus changed.
*
*/
bool level_up(void);
/**
* Moves focus one level down. Returns true if focus changed.
*
*/
bool level_down(void);
/**
* Renders the tree, that is rendering all outputs using render_con() and
* pushing the changes to X11 using x_push_changes().
*
*/
void tree_render(void);
/**
* Changes focus in the given direction
*
*/
void tree_next(Con *con, direction_t direction);
/**
* Get the previous / next sibling
*
*/
Con *get_tree_next_sibling(Con *con, position_t direction);
/**
* 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.
*
*/
Simplify tree_close_internal This commit makes multiple changes in tree_close_internal. I didn't split them because they are not completely independent. - Remove force_set_focus parameter This parameter was always set to `false` throughout the code base except for one case where it was set to `(con == focused)`, when killing a floating con's parent (the one with type CT_FLOATING_CON). But this case is not needed anymore since the special handling of CT_FLOATING_CONs in con_next_focused was removed in #2941. - Assume that con_next_focused does not returned a container of type CT_DOCKAREA. This is reasonable since con_next_focused uses the focus_head stack and has special handling of CT_DOCKAREA containers. - Remove is_mapped This variable was only used in the if block towards the end of tree_close_internal. Ignoring the, now removed, dockarea code and the use of force_set_focus this block performed only one useful action: focus the `next` container when `con == focused`. `con == focused` was a necessary and sufficient condition for the con_activate call: if `con != focused` we could reach the inner if blocks because of the other conditions but would never focus another container. If `con == focused` then all other conditions would be irrelevant. - Remove special handling of floating containers Since the `next` focused container is calculated through the parent for floating containers, I moved this code to con_next_focused. Also, because of the removal of force_set_focus, it appears that we can call con_on_remove_child for floating containers as well.
2018-07-30 00:56:51 +02:00
bool tree_close_internal(Con *con, kill_window_t kill_window, bool dont_kill_parent);
/**
* Loads tree from ~/.i3/_restart.json (used for in-place restarts).
*
*/
2011-06-10 18:27:20 +02:00
bool tree_restore(const char *path, xcb_get_geometry_reply_t *geometry);
/**
* 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);