diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/sway/container.h | 130 | ||||
-rw-r--r-- | include/sway/layout.h | 9 | ||||
-rw-r--r-- | include/sway/output.h | 2 |
3 files changed, 141 insertions, 0 deletions
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 @@ | |||
1 | #ifndef _SWAY_CONTAINER_H | ||
2 | #define _SWAY_CONTAINER_H | ||
3 | #include <stdint.h> | ||
4 | #include <sys/types.h> | ||
5 | #include <wlr/types/wlr_box.h> | ||
6 | #include "list.h" | ||
7 | |||
8 | typedef struct sway_container swayc_t; | ||
9 | |||
10 | extern swayc_t root_container; | ||
11 | |||
12 | struct sway_view; | ||
13 | |||
14 | /** | ||
15 | * Different kinds of containers. | ||
16 | * | ||
17 | * This enum is in order. A container will never be inside of a container below | ||
18 | * it on this list. | ||
19 | */ | ||
20 | enum swayc_types { | ||
21 | C_ROOT, /**< The root container. Only one of these ever exists. */ | ||
22 | C_OUTPUT, /**< An output (aka monitor, head, etc). */ | ||
23 | C_WORKSPACE, /**< A workspace. */ | ||
24 | C_CONTAINER, /**< A manually created container. */ | ||
25 | C_VIEW, /**< A view (aka window). */ | ||
26 | |||
27 | C_TYPES, | ||
28 | }; | ||
29 | |||
30 | /** | ||
31 | * Different ways to arrange a container. | ||
32 | */ | ||
33 | enum swayc_layouts { | ||
34 | L_NONE, /**< Used for containers that have no layout (views, root) */ | ||
35 | L_HORIZ, | ||
36 | L_VERT, | ||
37 | L_STACKED, | ||
38 | L_TABBED, | ||
39 | L_FLOATING, /**< A psuedo-container, removed from the tree, to hold floating windows */ | ||
40 | |||
41 | /* Awesome/Monad style auto layouts */ | ||
42 | L_AUTO_LEFT, | ||
43 | L_AUTO_RIGHT, | ||
44 | L_AUTO_TOP, | ||
45 | L_AUTO_BOTTOM, | ||
46 | |||
47 | L_AUTO_FIRST = L_AUTO_LEFT, | ||
48 | L_AUTO_LAST = L_AUTO_BOTTOM, | ||
49 | |||
50 | // Keep last | ||
51 | L_LAYOUTS, | ||
52 | }; | ||
53 | |||
54 | enum swayc_border_types { | ||
55 | B_NONE, /**< No border */ | ||
56 | B_PIXEL, /**< 1px border */ | ||
57 | B_NORMAL, /**< Normal border with title bar */ | ||
58 | }; | ||
59 | |||
60 | struct sway_output; | ||
61 | struct sway_view; | ||
62 | struct wlr_output_layout; | ||
63 | |||
64 | /** | ||
65 | * Stores information about a container. | ||
66 | * | ||
67 | * The tree is made of these. Views are containers that cannot have children. | ||
68 | */ | ||
69 | struct sway_container { | ||
70 | union { | ||
71 | // TODO: Encapsulate state for other node types as well like C_CONTAINER | ||
72 | struct wlr_output_layout *output_layout; // C_ROOT | ||
73 | struct sway_output *sway_output; // C_OUTPUT | ||
74 | struct sway_view *sway_view; // C_VIEW | ||
75 | }; | ||
76 | |||
77 | /** | ||
78 | * A unique ID to identify this container. Primarily used in the | ||
79 | * get_tree JSON output. | ||
80 | */ | ||
81 | size_t id; | ||
82 | |||
83 | char *name; | ||
84 | |||
85 | enum swayc_types type; | ||
86 | enum swayc_layouts layout; | ||
87 | enum swayc_layouts prev_layout; | ||
88 | enum swayc_layouts workspace_layout; | ||
89 | |||
90 | /** | ||
91 | * The coordinates that this view appear at, relative to the output they | ||
92 | * are located on (output containers have absolute coordinates). | ||
93 | */ | ||
94 | double x, y; | ||
95 | |||
96 | /** | ||
97 | * Width and height of this container, without borders or gaps. | ||
98 | */ | ||
99 | double width, height; | ||
100 | |||
101 | list_t *children; | ||
102 | |||
103 | /** | ||
104 | * The parent of this container. NULL for the root container. | ||
105 | */ | ||
106 | struct sway_container *parent; | ||
107 | /** | ||
108 | * Which of this container's children has focus. | ||
109 | */ | ||
110 | struct sway_container *focused; | ||
111 | |||
112 | /** | ||
113 | * Number of master views in auto layouts. | ||
114 | */ | ||
115 | size_t nb_master; | ||
116 | |||
117 | /** | ||
118 | * Number of slave groups (e.g. columns) in auto layouts. | ||
119 | */ | ||
120 | size_t nb_slave_groups; | ||
121 | |||
122 | /** | ||
123 | * Marks applied to the container, list_t of char*. | ||
124 | */ | ||
125 | list_t *marks; | ||
126 | }; | ||
127 | |||
128 | swayc_t *new_output(struct sway_output *sway_output); | ||
129 | |||
130 | #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 @@ | |||
1 | #ifndef _SWAY_LAYOUT_H | ||
2 | #define _SWAY_LAYOUT_H | ||
3 | |||
4 | struct sway_container; | ||
5 | |||
6 | void init_layout(void); | ||
7 | void add_child(struct sway_container *parent, struct sway_container *child); | ||
8 | |||
9 | #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 @@ | |||
5 | #include <wlr/types/wlr_output.h> | 5 | #include <wlr/types/wlr_output.h> |
6 | 6 | ||
7 | struct sway_server; | 7 | struct sway_server; |
8 | struct sway_container; | ||
8 | 9 | ||
9 | struct sway_output { | 10 | struct sway_output { |
10 | struct wlr_output *wlr_output; | 11 | struct wlr_output *wlr_output; |
12 | struct sway_container *swayc; | ||
11 | struct sway_server *server; | 13 | struct sway_server *server; |
12 | struct timespec last_frame; | 14 | struct timespec last_frame; |
13 | struct wl_listener frame; | 15 | struct wl_listener frame; |