26 __i3->
type = CT_OUTPUT;
29 x_set_name(__i3,
"[i3 con] pseudo-output __i3");
39 DLOG(
"adding main content container\n");
41 content->
type = CT_CON;
51 ws->
type = CT_WORKSPACE;
56 x_set_name(ws,
"[i3 con] workspace __i3_scratch");
66 bool tree_restore(
const char *path, xcb_get_geometry_reply_t *geometry) {
70 LOG(
"%s does not exist, not restoring tree\n", globbed);
87 DLOG(
"appended tree, using new root\n");
89 DLOG(
"new root = %p\n", croot);
91 DLOG(
"out = %p\n", out);
93 DLOG(
"ws = %p\n", ws);
97 if (strcmp(out->
name,
"__i3") != 0) {
98 DLOG(
"Adding pseudo-output __i3 during inplace restart\n");
119 croot->
name =
"root";
120 croot->
type = CT_ROOT;
148 if (con->
type == CT_FLOATING_CON) {
150 if (con->
type != CT_WORKSPACE)
153 DLOG(
"con = %p\n", con);
192 bool was_mapped = con->
mapped;
211 DLOG(
"next = %p, focused = %p\n", next, focused);
213 DLOG(
"closing %p, kill_window = %d\n", con, kill_window);
214 Con *child, *nextchild;
215 bool abort_kill =
false;
218 for (child =
TAILQ_FIRST(&(con->nodes_head)); child;) {
220 DLOG(
"killing child=%p\n", child);
227 DLOG(
"One of the children could not be killed immediately (WM_DELETE sent), aborting.\n");
231 if (con->
window != NULL) {
236 xcb_void_cookie_t cookie;
241 XCB_CW_EVENT_MASK, (uint32_t[]){XCB_NONE});
251 long data[] = {XCB_ICCCM_WM_STATE_WITHDRAWN, XCB_NONE};
252 cookie = xcb_change_property(
conn, XCB_PROP_MODE_REPLACE,
253 con->
window->
id, A_WM_STATE, A_WM_STATE, 32, 2, data);
260 xcb_change_save_set(
conn, XCB_SET_MODE_DELETE, con->
window->
id);
275 if (con == focused) {
276 DLOG(
"This is the focused container, i need to find another one to focus. I start looking at ws = %p\n", ws);
279 dont_kill_parent =
true;
280 DLOG(
"Alright, focusing %p\n", next);
291 DLOG(
"Removing urgency timer of con %p\n", con);
297 if (con->
type != CT_FLOATING_CON) {
311 if (!dont_kill_parent)
318 DLOG(
"Container was floating, killing floating container\n");
320 DLOG(
"parent container killed\n");
337 DLOG(
"No next container, i will just exit now\n");
341 if (was_mapped || con == focused) {
342 if ((kill_window !=
DONT_KILL_WINDOW) || !dont_kill_parent || con == focused) {
343 DLOG(
"focusing %p / %s\n", next, next->
name);
344 if (next->
type == CT_DOCKAREA) {
348 if (!force_set_focus && con != focused)
349 DLOG(
"not changing focus, the container was not focused before\n");
354 DLOG(
"not focusing because we're not killing anybody\n");
357 DLOG(
"not focusing, was not mapped\n");
361 if (!dont_kill_parent)
362 CALL(parent, on_remove_child);
374 DLOG(
"Floating containers can't be split.\n");
378 if (con->
type == CT_WORKSPACE) {
380 DLOG(
"Just changing orientation of workspace\n");
402 DLOG(
"Just changing orientation of existing container\n");
406 DLOG(
"Splitting in orientation %d\n", orientation);
412 new->parent = parent;
430 if (focused->
parent->
type == CT_FLOATING_CON) {
438 focused->
type == CT_WORKSPACE) {
439 ELOG(
"'focus parent': Focus is already on the workspace, cannot go higher than that.\n");
453 if (next ==
TAILQ_END(&(focused->focus_head))) {
454 DLOG(
"cannot go down\n");
456 }
else if (next->
type == CT_FLOATING_CON) {
460 if (child ==
TAILQ_END(&(next->focus_head))) {
461 DLOG(
"cannot go down\n");
477 if (con->
type == CT_WORKSPACE) {
480 TAILQ_FOREACH(current, &(con->floating_head), floating_windows)
494 DLOG(
"-- BEGIN RENDERING --\n");
503 DLOG(
"-- END RENDERING --\n");
520 if (con->
type == CT_WORKSPACE) {
522 DLOG(
"Cannot change workspace while in global fullscreen mode.\n");
530 DLOG(
"Current output is %s\n", current_output->
name);
534 if (way ==
'n' && orientation ==
HORIZ)
536 else if (way ==
'p' && orientation ==
HORIZ)
538 else if (way ==
'n' && orientation ==
VERT)
540 else if (way ==
'p' && orientation ==
VERT)
548 DLOG(
"Next output is %s\n", next_output->
name);
551 Con *workspace = NULL;
571 if (focus == workspace)
583 if (con->
type == CT_FLOATING_CON) {
584 if (orientation !=
HORIZ)
592 next =
TAILQ_PREV(con, floating_head, floating_windows);
599 next =
TAILQ_LAST(&(parent->floating_head), floating_head);
608 while (
TAILQ_LAST(&(parent->floating_head), floating_head) != next) {
609 Con *last =
TAILQ_LAST(&(parent->floating_head), floating_head);
610 TAILQ_REMOVE(&(parent->floating_head), last, floating_windows);
622 return _tree_next(parent, way, orientation, wrap);
628 DLOG(
"nothing to focus\n");
636 next =
TAILQ_PREV(current, nodes_head, nodes);
643 if (
_tree_next(parent, way, orientation,
false))
653 next =
TAILQ_LAST(&(parent->nodes_head), nodes_head);
690 Con *current, *child, *parent = con->
parent;
691 DLOG(
"Checking if I can flatten con = %p / %s\n", con, con->
name);
694 if (con->
type != CT_CON ||
701 if (child == NULL ||
TAILQ_NEXT(child, nodes) != NULL)
704 DLOG(
"child = %p, con = %p, parent = %p\n", child, con, parent);
716 DLOG(
"Alright, I have to flatten this situation now. Stay calm.\n");
720 DLOG(
"detaching...\n");
724 DLOG(
"detaching current=%p / %s\n", current, current->
name);
726 DLOG(
"re-attaching\n");
733 DLOG(
"attaching to focus list\n");
737 DLOG(
"re-attached all\n");
740 if (focus_next != NULL &&
742 DLOG(
"restoring focus to focus_next=%p\n", focus_next);
743 TAILQ_REMOVE(&(parent->focus_head), focus_next, focused);
745 DLOG(
"restored focus.\n");
749 DLOG(
"closing redundant cons\n");
763 while (current != NULL) {
770 while (current != NULL) {
static void mark_unmapped(Con *con)
bool workspace_is_visible(Con *ws)
Returns true if the workspace is currently visible.
bool con_fullscreen_permits_focusing(Con *con)
Returns true if changing the focus to con would be allowed considering the fullscreen focus constrain...
#define TAILQ_EMPTY(head)
struct all_cons_head all_cons
#define TAILQ_INSERT_TAIL(head, elm, field)
Con * tree_open_con(Con *con, i3Window *window)
Opens an empty container in the current container.
#define TAILQ_PREV(elm, headname, field)
int con_num_children(Con *con)
Returns the number of children of this container.
bool force_focus_wrapping
Think of the following layout: Horizontal workspace with a tabbed con on the left of the screen and a...
void workspace_show(Con *workspace)
Switches to the given workspace.
void con_force_split_parents_redraw(Con *con)
force parent split containers to be redrawn
struct ev_loop * main_loop
void window_free(i3Window *win)
Frees an i3Window and all its members.
void con_set_urgency(Con *con, bool urgent)
Set urgency flag to the container, all the parent containers and the workspace.
void tree_append_json(Con *con, const char *filename, char **errormsg)
void add_ignore_event(const int sequence, const int response_type)
Adds the given sequence to the list of events which are ignored.
bool path_exists(const char *path)
Checks if the given path exists by calling stat().
static Con * _create___i3(void)
void tree_next(char way, orientation_t orientation)
Changes focus in the given way (next/previous) and given orientation (horizontal/vertical).
Output * get_output_containing(unsigned int x, unsigned int y)
Returns the active (!) output which contains the coordinates x, y or NULL if there is no output which...
void x_set_warp_to(Rect *rect)
Set warp_to coordinates.
#define TAILQ_REPLACE(head, elm, elm2, field)
void x_push_changes(Con *con)
Pushes all changes (state of each node, see x_push_node() and the window stack) to X11...
static bool _is_con_mapped(Con *con)
void restore_open_placeholder_windows(Con *parent)
Open placeholder windows for all children of parent.
orientation_t con_orientation(Con *con)
Returns the orientation of the given container (for stacked containers, vertical orientation is used ...
A 'Window' is a type which contains an xcb_window_t and all the related information (hints like _NET_...
bool tree_close_internal(Con *con, kill_window_t kill_window, bool dont_kill_parent, bool force_set_focus)
Closes the given container including all children.
#define TAILQ_HEAD_INITIALIZER(head)
Con * con_get_workspace(Con *con)
Gets the workspace container this node is on.
bool tree_restore(const char *path, xcb_get_geometry_reply_t *geometry)
Loads tree from ~/.i3/_restart.json (used for in-place restarts).
#define TAILQ_LAST(head, headname)
kill_window_t
parameter to specify whether tree_close_internal() and x_window_kill() should kill only this specific...
Con * con_descend_focused(Con *con)
Returns the focused con inside this client, descending the tree as far as possible.
void con_focus(Con *con)
Sets input focus to the given container.
void con_fix_percent(Con *con)
Updates the percent attribute of the children of the given container.
#define TAILQ_NEXT(elm, field)
A 'Con' represents everything from the X11 root window down to a single X11 window.
bool level_up(void)
Moves focus one level up.
void ipc_send_window_event(const char *property, Con *con)
For the window events we send, along the usual "change" field, also the window container, in "container".
Con * con_new(Con *parent, i3Window *window)
Con * workspace_encapsulate(Con *ws)
Creates a new container and re-parents all of children from the given workspace into it...
A "match" is a data structure which acts like a mask or expression to match certain windows or not...
char * name
Name of the output.
void con_attach(Con *con, Con *parent, bool ignore_focus)
Attaches the given container to the given parent.
#define TAILQ_REMOVE(head, elm, field)
#define TAILQ_FOREACH(var, head, field)
void x_window_kill(xcb_window_t window, kill_window_t kill_window)
Kills the given X11 window using WM_DELETE_WINDOW (if supported).
void con_update_parents_urgency(Con *con)
Make all parent containers urgent if con is urgent or clear the urgent flag of all parent containers ...
int num
the workspace number, if this Con is of type CT_WORKSPACE and the workspace is not a named workspace ...
fullscreen_mode_t fullscreen_mode
Con * con_next_focused(Con *con)
Returns the container which will be focused next when the given container is not available anymore...
void con_detach(Con *con)
Detaches the given container from its current parent.
void tree_split(Con *con, orientation_t orientation)
Splits (horizontally or vertically) the given container by creating a new container which contains th...
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 rand...
#define GREP_FIRST(dest, head, condition)
struct deco_render_params * deco_render_params
Cache for the decoration rendering.
Con * output_get_content(Con *output)
Returns the output container below the given output container.
An Output is a physical output on your graphics driver.
Con * con
Pointer to the Con which represents this output.
Con * con_descend_tiling_focused(Con *con)
Returns the focused con inside this client, descending the tree as far as possible.
void workspace_update_urgent_flag(Con *ws)
Goes through all clients on the given workspace and updates the workspace’s urgent flag accordingly...
xcb_connection_t * conn
XCB connection and root screen.
bool level_down(void)
Moves focus one level down.
struct ev_timer * urgency_timer
#define TAILQ_INSERT_BEFORE(listelm, elm, field)
#define TAILQ_INSERT_HEAD(head, elm, field)
static bool _tree_next(Con *con, char way, orientation_t orientation, bool wrap)
void render_con(Con *con, bool render_fullscreen)
"Renders" the given container (and its children), meaning that all rects are updated correctly...
Output * get_output_next(direction_t direction, Output *current, output_close_far_t close_far)
Gets the output which is the next one in the given direction.
void match_free(Match *match)
Frees the given match.
void tree_flatten(Con *con)
tree_flatten() removes pairs of redundant split containers, e.g.
bool con_is_split(Con *con)
Returns true if a container should be considered split.
void x_con_kill(Con *con)
Kills the window decoration associated with the given container.
#define TAILQ_FIRST(head)
bool con_is_floating(Con *con)
Returns true if the node is floating.
void tree_render(void)
Renders the tree, that is rendering all outputs using render_con() and pushing the changes to X11 usi...
Con * con_descend_direction(Con *con, direction_t direction)
#define CALL(obj, member,...)
void x_set_name(Con *con, const char *name)
Sets the WM_NAME property (so, no UTF8, but used only for debugging anyways) of the given name...
Con * con_get_fullscreen_con(Con *con, fullscreen_mode_t fullscreen_mode)
Returns the first fullscreen node below this node.
char * resolve_tilde(const char *path)
This function resolves ~ in pathnames.
char * sstrdup(const char *str)
Safe-wrapper around strdup which exits if malloc returns NULL (meaning that there is no more memory a...