X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=include%2Fcon.h;h=2c991b0cb6ec90b91ccbe82fc314a7f3edfe6e9c;hb=HEAD;hp=20e83df935bdf7501ec0da3a8c7918245d8f36a1;hpb=4622cde7b785b522b29d66c7d9bdcc9aa1eeb452;p=i3%2Fi3 diff --git a/include/con.h b/include/con.h index 20e83df9..2c991b0c 100644 --- a/include/con.h +++ b/include/con.h @@ -2,24 +2,36 @@ * vim:ts=4:sw=4:expandtab * * i3 - an improved dynamic tiling window manager - * © 2009-2011 Michael Stapelberg and contributors (see also: LICENSE) + * © 2009 Michael Stapelberg and contributors (see also: LICENSE) * * con.c: Functions which deal with containers directly (creating containers, * searching containers, getting specific properties from containers, * …). * */ -#ifndef _CON_H -#define _CON_H +#pragma once + +#include /** * 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(). + * This function only initializes the data structures. + * + */ +Con *con_new_skeleton(Con *parent, i3Window *window); + +/** + * A wrapper for con_new_skeleton, to retain the old con_new behaviour * */ Con *con_new(Con *parent, i3Window *window); +/** + * Frees the specified container. + * + */ +void con_free(Con *con); + /** * Sets input focus to the given container. Will be updated in X11 in the next * run of x_push_changes(). @@ -27,12 +39,55 @@ Con *con_new(Con *parent, i3Window *window); */ void con_focus(Con *con); +/** + * Sets input focus to the given container and raises it to the top. + * + */ +void con_activate(Con *con); + +/** + * Closes the given container. + * + */ +void con_close(Con *con, kill_window_t kill_window); + /** * Returns true when this node is a leaf node (has no children) * */ bool con_is_leaf(Con *con); +/** + * Returns true when this con is a leaf node with a managed X11 window (e.g., + * excluding dock containers) + */ +bool con_has_managed_window(Con *con); + +/** + * Returns true if a container should be considered split. + * + */ +bool con_is_split(Con *con); + +/** + * This will only return true for containers which have some parent with + * a tabbed / stacked parent of which they are not the currently focused child. + * + */ +bool con_is_hidden(Con *con); + +/** + * Returns whether the container or any of its children is sticky. + * + */ +bool con_is_sticky(Con *con); + +/** + * Returns true if this node has regular or floating children. + * + */ +bool con_has_children(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). @@ -54,7 +109,7 @@ Con *con_get_output(Con *con); Con *con_get_workspace(Con *con); /** - * Searches parenst of the given 'con' until it reaches one with the specified + * Searches parents of the given 'con' until it reaches one with the specified * 'orientation'. Aborts when it comes across a floating_con. * */ @@ -64,7 +119,21 @@ Con *con_parent_with_orientation(Con *con, orientation_t orientation); * Returns the first fullscreen node below this node. * */ -Con *con_get_fullscreen_con(Con *con, int fullscreen_mode); +Con *con_get_fullscreen_con(Con *con, fullscreen_mode_t fullscreen_mode); + +/** + * Returns the fullscreen node that covers the given workspace if it exists. + * This is either a CF_GLOBAL fullscreen container anywhere or a CF_OUTPUT + * fullscreen container in the workspace. + * + */ +Con *con_get_fullscreen_covering_ws(Con *ws); + +/** + * Returns true if the container is internal, such as __i3_scratch + * + */ +bool con_is_internal(Con *con); /** * Returns true if the node is floating. @@ -72,6 +141,12 @@ Con *con_get_fullscreen_con(Con *con, int fullscreen_mode); */ bool con_is_floating(Con *con); +/** + * Returns true if the container is a docked container. + * + */ +bool con_is_docked(Con *con); + /** * Checks if the given container is either floating or inside some floating * container. It returns the FLOATING_CON container. @@ -85,6 +160,12 @@ Con *con_inside_floating(Con *con); */ bool con_inside_focused(Con *con); +/** + * Checks if the container has the given parent as an actual parent. + * + */ +bool con_has_parent(Con *con, Con *parent); + /** * Returns the container with the given client window ID or NULL if no such * container exists. @@ -92,6 +173,20 @@ bool con_inside_focused(Con *con); */ Con *con_by_window_id(xcb_window_t window); +/** + * Returns the container with the given container ID or NULL if no such + * container exists. + * + */ +Con *con_by_con_id(long target); + +/** + * Returns true if the given container (still) exists. + * This can be used, e.g., to make sure a container hasn't been closed in the meantime. + * + */ +bool con_exists(Con *con); + /** * Returns the container with the given frame ID or NULL if no such container * exists. @@ -99,6 +194,42 @@ Con *con_by_window_id(xcb_window_t window); */ Con *con_by_frame_id(xcb_window_t frame); +/** + * Returns the container with the given mark or NULL if no such container + * exists. + * + */ +Con *con_by_mark(const char *mark); + +/** + * Returns true if and only if the given containers holds the mark. + * + */ +bool con_has_mark(Con *con, const char *mark); + +/** + * Toggles the mark on a container. + * If the container already has this mark, the mark is removed. + * Otherwise, the mark is assigned to the container. + * + */ +void con_mark_toggle(Con *con, const char *mark, mark_mode_t mode); + +/** + * Assigns a mark to the container. + * + */ +void con_mark(Con *con, const char *mark, mark_mode_t mode); + +/** + * Removes marks from containers. + * If con is NULL, all containers are considered. + * If name is NULL, this removes all existing marks. + * Otherwise, it will only remove the given mark (if it is present). + * + */ +void con_unmark(Con *con, const char *name); + /** * Returns the first container below 'con' which wants to swallow this window * TODO: priority @@ -106,12 +237,41 @@ Con *con_by_frame_id(xcb_window_t frame); */ Con *con_for_window(Con *con, i3Window *window, Match **store_match); +/** + * Iterate over the container's focus stack and return an array with the + * containers inside it, ordered from higher focus order to lowest. + * + */ +Con **get_focus_order(Con *con); + +/** + * Clear the container's focus stack and re-add it using the provided container + * array. The function doesn't check if the provided array contains the same + * containers with the previous focus stack but will not add floating containers + * in the new focus stack if container is not a workspace. + * + */ +void set_focus_order(Con *con, Con **focus_order); + /** * Returns the number of children of this container. * */ int con_num_children(Con *con); +/** + * Returns the number of visible non-floating children of this container. + * For example, if the container contains a hsplit which has two children, + * this will return 2 instead of 1. + */ +int con_num_visible_children(Con *con); + +/** + * Count the number of windows (i.e., leaf containers). + * + */ +int con_num_windows(Con *con); + /** * 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 @@ -145,6 +305,18 @@ void con_fix_percent(Con *con); */ void con_toggle_fullscreen(Con *con, int fullscreen_mode); +/** + * Enables fullscreen mode for the given container, if necessary. + * + */ +void con_enable_fullscreen(Con *con, fullscreen_mode_t fullscreen_mode); + +/** + * Disables fullscreen mode for the given container, if necessary. + * + */ +void con_disable_fullscreen(Con *con); + /** * Moves the given container to the currently focused container on the given * workspace. @@ -159,10 +331,36 @@ void con_toggle_fullscreen(Con *con, int fullscreen_mode); * The dont_warp flag disables pointer warping and will be set when this * function is called while dragging a floating window. * + * If ignore_focus is set, the container will be moved without modifying focus + * at all. + * * TODO: is there a better place for this function? * */ -void con_move_to_workspace(Con *con, Con *workspace, bool fix_coordinates, bool dont_warp); +void con_move_to_workspace(Con *con, Con *workspace, bool fix_coordinates, + bool dont_warp, bool ignore_focus); + +/** + * Moves the given container to the currently focused container on the + * visible workspace on the given output. + * + */ +void con_move_to_output(Con *con, Output *output, bool fix_coordinates); + +/** + * Moves the given container to the currently focused container on the + * visible workspace on the output specified by the given name. + * The current output for the container is used to resolve relative names + * such as left, right, up, down. + * + */ +bool con_move_to_output_name(Con *con, const char *name, bool fix_coordinates); + +/** + * Moves the given container to the given mark. + * + */ +bool con_move_to_mark(Con *con, const char *mark); /** * Returns the orientation of the given container (for stacked containers, @@ -170,11 +368,11 @@ void con_move_to_workspace(Con *con, Con *workspace, bool fix_coordinates, bool * container). * */ -int con_orientation(Con *con); +orientation_t con_orientation(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 + * is not available anymore. Called in tree_close_internal and con_move_to_workspace * to properly restore focus. * */ @@ -205,7 +403,7 @@ Con *con_descend_focused(Con *con); */ Con *con_descend_tiling_focused(Con *con); -/* +/** * Returns the leftmost, rightmost, etc. container in sub-tree. For example, if * direction is D_LEFT, then we return the rightmost container and if direction * is D_RIGHT, we return the leftmost container. This is because if we are @@ -244,7 +442,7 @@ int con_border_style(Con *con); * floating window. * */ -void con_set_border_style(Con *con, int border_style); +void con_set_border_style(Con *con, int border_style, int border_width); /** * This function changes the layout of a given container. Use it to handle @@ -252,7 +450,7 @@ void con_set_border_style(Con *con, int border_style); * new split container before). * */ -void con_set_layout(Con *con, int layout); +void con_set_layout(Con *con, layout_t layout); /** * This function toggles the layout of a given container. toggle_mode can be @@ -293,4 +491,45 @@ Rect con_minimum_size(Con *con); */ bool con_fullscreen_permits_focusing(Con *con); -#endif +/** + * Checks if the given container has an urgent child. + * + */ +bool con_has_urgent_child(Con *con); + +/** + * Make all parent containers urgent if con is urgent or clear the urgent flag + * of all parent containers if there are no more urgent children left. + * + */ +void con_update_parents_urgency(Con *con); + +/** + * Set urgency flag to the container, all the parent containers and the workspace. + * + */ +void con_set_urgency(Con *con, bool urgent); + +/** + * Create a string representing the subtree under con. + * + */ +char *con_get_tree_representation(Con *con); + +/** + * force parent split containers to be redrawn + * + */ +void con_force_split_parents_redraw(Con *con); + +/** + * Returns the window title considering the current title format. + * + */ +i3String *con_parse_title_format(Con *con); + +/** + * Swaps the two containers. + * + */ +bool con_swap(Con *first, Con *second);