From db4fb1c85c132e001fb1ae18f03f7585def1ae19 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sun, 19 Nov 2017 17:04:28 -0500 Subject: Add outputs to the tree --- include/sway/container.h | 130 +++++++++++++++++++++++++++++++++++++++++++++++ include/sway/layout.h | 9 ++++ include/sway/output.h | 2 + 3 files changed, 141 insertions(+) create mode 100644 include/sway/container.h create mode 100644 include/sway/layout.h (limited to 'include') diff --git a/include/sway/container.h b/include/sway/container.h new file mode 100644 index 00000000..35d1c146 --- /dev/null +++ b/include/sway/container.h @@ -0,0 +1,130 @@ +#ifndef _SWAY_CONTAINER_H +#define _SWAY_CONTAINER_H +#include +#include +#include +#include "list.h" + +typedef struct sway_container swayc_t; + +extern swayc_t root_container; + +struct sway_view; + +/** + * Different kinds of containers. + * + * This enum is in order. A container will never be inside of a container below + * it on this list. + */ +enum swayc_types { + C_ROOT, /**< The root container. Only one of these ever exists. */ + C_OUTPUT, /**< An output (aka monitor, head, etc). */ + C_WORKSPACE, /**< A workspace. */ + C_CONTAINER, /**< A manually created container. */ + C_VIEW, /**< A view (aka window). */ + + C_TYPES, +}; + +/** + * Different ways to arrange a container. + */ +enum swayc_layouts { + L_NONE, /**< Used for containers that have no layout (views, root) */ + L_HORIZ, + L_VERT, + L_STACKED, + L_TABBED, + L_FLOATING, /**< A psuedo-container, removed from the tree, to hold floating windows */ + + /* Awesome/Monad style auto layouts */ + L_AUTO_LEFT, + L_AUTO_RIGHT, + L_AUTO_TOP, + L_AUTO_BOTTOM, + + L_AUTO_FIRST = L_AUTO_LEFT, + L_AUTO_LAST = L_AUTO_BOTTOM, + + // Keep last + L_LAYOUTS, +}; + +enum swayc_border_types { + B_NONE, /**< No border */ + B_PIXEL, /**< 1px border */ + B_NORMAL, /**< Normal border with title bar */ +}; + +struct sway_output; +struct sway_view; +struct wlr_output_layout; + +/** + * Stores information about a container. + * + * The tree is made of these. Views are containers that cannot have children. + */ +struct sway_container { + union { + // TODO: Encapsulate state for other node types as well like C_CONTAINER + struct wlr_output_layout *output_layout; // C_ROOT + struct sway_output *sway_output; // C_OUTPUT + struct sway_view *sway_view; // C_VIEW + }; + + /** + * A unique ID to identify this container. Primarily used in the + * get_tree JSON output. + */ + size_t id; + + char *name; + + enum swayc_types type; + enum swayc_layouts layout; + enum swayc_layouts prev_layout; + enum swayc_layouts workspace_layout; + + /** + * The coordinates that this view appear at, relative to the output they + * are located on (output containers have absolute coordinates). + */ + double x, y; + + /** + * Width and height of this container, without borders or gaps. + */ + double width, height; + + list_t *children; + + /** + * The parent of this container. NULL for the root container. + */ + struct sway_container *parent; + /** + * Which of this container's children has focus. + */ + struct sway_container *focused; + + /** + * Number of master views in auto layouts. + */ + size_t nb_master; + + /** + * Number of slave groups (e.g. columns) in auto layouts. + */ + size_t nb_slave_groups; + + /** + * Marks applied to the container, list_t of char*. + */ + list_t *marks; +}; + +swayc_t *new_output(struct sway_output *sway_output); + +#endif diff --git a/include/sway/layout.h b/include/sway/layout.h new file mode 100644 index 00000000..7e7a9c35 --- /dev/null +++ b/include/sway/layout.h @@ -0,0 +1,9 @@ +#ifndef _SWAY_LAYOUT_H +#define _SWAY_LAYOUT_H + +struct sway_container; + +void init_layout(void); +void add_child(struct sway_container *parent, struct sway_container *child); + +#endif diff --git a/include/sway/output.h b/include/sway/output.h index ffc6708d..e2f81bcb 100644 --- a/include/sway/output.h +++ b/include/sway/output.h @@ -5,9 +5,11 @@ #include struct sway_server; +struct sway_container; struct sway_output { struct wlr_output *wlr_output; + struct sway_container *swayc; struct sway_server *server; struct timespec last_frame; struct wl_listener frame; -- cgit v1.2.3-54-g00ecf