diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/sway/config.h | 17 | ||||
-rw-r--r-- | include/sway/container.h | 169 | ||||
-rw-r--r-- | include/sway/criteria.h | 6 | ||||
-rw-r--r-- | include/sway/input/input-manager.h | 4 | ||||
-rw-r--r-- | include/sway/input/seat.h | 13 | ||||
-rw-r--r-- | include/sway/ipc-json.h | 6 | ||||
-rw-r--r-- | include/sway/ipc-server.h | 6 | ||||
-rw-r--r-- | include/sway/layout.h | 43 | ||||
-rw-r--r-- | include/sway/tree/container.h | 137 | ||||
-rw-r--r-- | include/sway/tree/layout.h | 52 | ||||
-rw-r--r-- | include/sway/tree/workspace.h | 26 | ||||
-rw-r--r-- | include/sway/view.h (renamed from include/sway/tree/view.h) | 4 | ||||
-rw-r--r-- | include/sway/workspace.h | 20 |
13 files changed, 260 insertions, 243 deletions
diff --git a/include/sway/config.h b/include/sway/config.h index 7fdd0be0..48a8b0ab 100644 --- a/include/sway/config.h +++ b/include/sway/config.h | |||
@@ -10,8 +10,8 @@ | |||
10 | #include <xkbcommon/xkbcommon.h> | 10 | #include <xkbcommon/xkbcommon.h> |
11 | #include <time.h> | 11 | #include <time.h> |
12 | #include "list.h" | 12 | #include "list.h" |
13 | #include "tree/layout.h" | 13 | #include "layout.h" |
14 | #include "tree/container.h" | 14 | #include "container.h" |
15 | 15 | ||
16 | /** | 16 | /** |
17 | * Describes a variable created via the `set` command. | 17 | * Describes a variable created via the `set` command. |
@@ -299,8 +299,8 @@ struct sway_config { | |||
299 | char *floating_scroll_down_cmd; | 299 | char *floating_scroll_down_cmd; |
300 | char *floating_scroll_left_cmd; | 300 | char *floating_scroll_left_cmd; |
301 | char *floating_scroll_right_cmd; | 301 | char *floating_scroll_right_cmd; |
302 | enum sway_container_layout default_orientation; | 302 | enum swayc_layouts default_orientation; |
303 | enum sway_container_layout default_layout; | 303 | enum swayc_layouts default_layout; |
304 | char *font; | 304 | char *font; |
305 | int font_height; | 305 | int font_height; |
306 | 306 | ||
@@ -324,8 +324,8 @@ struct sway_config { | |||
324 | list_t *config_chain; | 324 | list_t *config_chain; |
325 | const char *current_config; | 325 | const char *current_config; |
326 | 326 | ||
327 | enum sway_container_border border; | 327 | enum swayc_border_types border; |
328 | enum sway_container_border floating_border; | 328 | enum swayc_border_types floating_border; |
329 | int border_thickness; | 329 | int border_thickness; |
330 | int floating_border_thickness; | 330 | int floating_border_thickness; |
331 | enum edge_border_types hide_edge_borders; | 331 | enum edge_border_types hide_edge_borders; |
@@ -356,7 +356,7 @@ struct sway_config { | |||
356 | struct input_config *input_config; | 356 | struct input_config *input_config; |
357 | struct seat_config *seat_config; | 357 | struct seat_config *seat_config; |
358 | struct sway_seat *seat; | 358 | struct sway_seat *seat; |
359 | struct sway_container *current_container; | 359 | swayc_t *current_container; |
360 | } handler_context; | 360 | } handler_context; |
361 | }; | 361 | }; |
362 | 362 | ||
@@ -416,8 +416,7 @@ void output_get_identifier(char *identifier, size_t len, | |||
416 | struct sway_output *output); | 416 | struct sway_output *output); |
417 | struct output_config *new_output_config(const char *name); | 417 | struct output_config *new_output_config(const char *name); |
418 | void merge_output_config(struct output_config *dst, struct output_config *src); | 418 | void merge_output_config(struct output_config *dst, struct output_config *src); |
419 | void apply_output_config(struct output_config *oc, | 419 | void apply_output_config(struct output_config *oc, swayc_t *output); |
420 | struct sway_container *output); | ||
421 | void free_output_config(struct output_config *oc); | 420 | void free_output_config(struct output_config *oc); |
422 | 421 | ||
423 | /** | 422 | /** |
diff --git a/include/sway/container.h b/include/sway/container.h new file mode 100644 index 00000000..f200a1a2 --- /dev/null +++ b/include/sway/container.h | |||
@@ -0,0 +1,169 @@ | |||
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 <wlr/types/wlr_surface.h> | ||
7 | #include "list.h" | ||
8 | |||
9 | typedef struct sway_container swayc_t; | ||
10 | |||
11 | extern swayc_t root_container; | ||
12 | |||
13 | struct sway_view; | ||
14 | struct sway_seat; | ||
15 | |||
16 | /** | ||
17 | * Different kinds of containers. | ||
18 | * | ||
19 | * This enum is in order. A container will never be inside of a container below | ||
20 | * it on this list. | ||
21 | */ | ||
22 | enum swayc_types { | ||
23 | C_ROOT, /**< The root container. Only one of these ever exists. */ | ||
24 | C_OUTPUT, /**< An output (aka monitor, head, etc). */ | ||
25 | C_WORKSPACE, /**< A workspace. */ | ||
26 | C_CONTAINER, /**< A manually created container. */ | ||
27 | C_VIEW, /**< A view (aka window). */ | ||
28 | |||
29 | C_TYPES, | ||
30 | }; | ||
31 | |||
32 | /** | ||
33 | * Different ways to arrange a container. | ||
34 | */ | ||
35 | enum swayc_layouts { | ||
36 | L_NONE, /**< Used for containers that have no layout (views, root) */ | ||
37 | L_HORIZ, | ||
38 | L_VERT, | ||
39 | L_STACKED, | ||
40 | L_TABBED, | ||
41 | L_FLOATING, /**< A psuedo-container, removed from the tree, to hold floating windows */ | ||
42 | |||
43 | /* Awesome/Monad style auto layouts */ | ||
44 | L_AUTO_LEFT, | ||
45 | L_AUTO_RIGHT, | ||
46 | L_AUTO_TOP, | ||
47 | L_AUTO_BOTTOM, | ||
48 | |||
49 | L_AUTO_FIRST = L_AUTO_LEFT, | ||
50 | L_AUTO_LAST = L_AUTO_BOTTOM, | ||
51 | |||
52 | // Keep last | ||
53 | L_LAYOUTS, | ||
54 | }; | ||
55 | |||
56 | enum swayc_border_types { | ||
57 | B_NONE, /**< No border */ | ||
58 | B_PIXEL, /**< 1px border */ | ||
59 | B_NORMAL, /**< Normal border with title bar */ | ||
60 | }; | ||
61 | |||
62 | struct sway_root; | ||
63 | struct sway_output; | ||
64 | struct sway_view; | ||
65 | |||
66 | /** | ||
67 | * Stores information about a container. | ||
68 | * | ||
69 | * The tree is made of these. Views are containers that cannot have children. | ||
70 | */ | ||
71 | struct sway_container { | ||
72 | union { | ||
73 | // TODO: Encapsulate state for other node types as well like C_CONTAINER | ||
74 | struct sway_root *sway_root; // C_ROOT | ||
75 | struct sway_output *sway_output; // C_OUTPUT | ||
76 | struct sway_view *sway_view; // C_VIEW | ||
77 | }; | ||
78 | |||
79 | /** | ||
80 | * A unique ID to identify this container. Primarily used in the | ||
81 | * get_tree JSON output. | ||
82 | */ | ||
83 | size_t id; | ||
84 | |||
85 | char *name; | ||
86 | |||
87 | enum swayc_types type; | ||
88 | enum swayc_layouts layout; | ||
89 | enum swayc_layouts prev_layout; | ||
90 | enum swayc_layouts workspace_layout; | ||
91 | |||
92 | /** | ||
93 | * The coordinates that this view appear at, relative to the output they | ||
94 | * are located on (output containers have absolute coordinates). | ||
95 | */ | ||
96 | double x, y; | ||
97 | |||
98 | /** | ||
99 | * Width and height of this container, without borders or gaps. | ||
100 | */ | ||
101 | double width, height; | ||
102 | |||
103 | list_t *children; | ||
104 | |||
105 | /** | ||
106 | * The parent of this container. NULL for the root container. | ||
107 | */ | ||
108 | struct sway_container *parent; | ||
109 | |||
110 | /** | ||
111 | * Number of master views in auto layouts. | ||
112 | */ | ||
113 | size_t nb_master; | ||
114 | |||
115 | /** | ||
116 | * Number of slave groups (e.g. columns) in auto layouts. | ||
117 | */ | ||
118 | size_t nb_slave_groups; | ||
119 | |||
120 | /** | ||
121 | * Marks applied to the container, list_t of char*. | ||
122 | */ | ||
123 | list_t *marks; | ||
124 | |||
125 | struct { | ||
126 | struct wl_signal destroy; | ||
127 | } events; | ||
128 | }; | ||
129 | |||
130 | void swayc_descendants_of_type(swayc_t *root, enum swayc_types type, | ||
131 | void (*func)(swayc_t *item, void *data), void *data); | ||
132 | |||
133 | swayc_t *new_output(struct sway_output *sway_output); | ||
134 | swayc_t *new_workspace(swayc_t *output, const char *name); | ||
135 | swayc_t *new_view(swayc_t *sibling, struct sway_view *sway_view); | ||
136 | |||
137 | swayc_t *destroy_output(swayc_t *output); | ||
138 | swayc_t *destroy_view(swayc_t *view); | ||
139 | |||
140 | swayc_t *next_view_sibling(struct sway_seat *seat); | ||
141 | |||
142 | /** | ||
143 | * Finds a container based on test criteria. Returns the first container that | ||
144 | * passes the test. | ||
145 | */ | ||
146 | swayc_t *swayc_by_test(swayc_t *container, | ||
147 | bool (*test)(swayc_t *view, void *data), void *data); | ||
148 | /** | ||
149 | * Finds a parent container with the given swayc_type. | ||
150 | */ | ||
151 | swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types type); | ||
152 | /** | ||
153 | * Maps a container's children over a function. | ||
154 | */ | ||
155 | void container_map(swayc_t *container, | ||
156 | void (*f)(swayc_t *view, void *data), void *data); | ||
157 | |||
158 | swayc_t *swayc_at(swayc_t *parent, double lx, double ly, | ||
159 | struct wlr_surface **surface, double *sx, double *sy); | ||
160 | |||
161 | /** | ||
162 | * Apply the function for each child of the container breadth first. | ||
163 | */ | ||
164 | void container_for_each_bfs(swayc_t *con, void (*f)(swayc_t *con, void *data), | ||
165 | void *data); | ||
166 | |||
167 | swayc_t *swayc_change_layout(swayc_t *container, enum swayc_layouts layout); | ||
168 | |||
169 | #endif | ||
diff --git a/include/sway/criteria.h b/include/sway/criteria.h index ec256ddb..9b4b4bef 100644 --- a/include/sway/criteria.h +++ b/include/sway/criteria.h | |||
@@ -1,7 +1,7 @@ | |||
1 | #ifndef _SWAY_CRITERIA_H | 1 | #ifndef _SWAY_CRITERIA_H |
2 | #define _SWAY_CRITERIA_H | 2 | #define _SWAY_CRITERIA_H |
3 | 3 | ||
4 | #include "tree/container.h" | 4 | #include "container.h" |
5 | #include "list.h" | 5 | #include "list.h" |
6 | 6 | ||
7 | /** | 7 | /** |
@@ -31,12 +31,12 @@ char *extract_crit_tokens(list_t *tokens, const char *criteria); | |||
31 | 31 | ||
32 | // Returns list of criteria that match given container. These criteria have | 32 | // Returns list of criteria that match given container. These criteria have |
33 | // been set with `for_window` commands and have an associated cmdlist. | 33 | // been set with `for_window` commands and have an associated cmdlist. |
34 | list_t *criteria_for(struct sway_container *cont); | 34 | list_t *criteria_for(swayc_t *cont); |
35 | 35 | ||
36 | // Returns a list of all containers that match the given list of tokens. | 36 | // Returns a list of all containers that match the given list of tokens. |
37 | list_t *container_for_crit_tokens(list_t *tokens); | 37 | list_t *container_for_crit_tokens(list_t *tokens); |
38 | 38 | ||
39 | // Returns true if any criteria in the given list matches this container | 39 | // Returns true if any criteria in the given list matches this container |
40 | bool criteria_any(struct sway_container *cont, list_t *criteria); | 40 | bool criteria_any(swayc_t *cont, list_t *criteria); |
41 | 41 | ||
42 | #endif | 42 | #endif |
diff --git a/include/sway/input/input-manager.h b/include/sway/input/input-manager.h index c6c73dba..eab7dc90 100644 --- a/include/sway/input/input-manager.h +++ b/include/sway/input/input-manager.h | |||
@@ -31,10 +31,10 @@ struct sway_input_manager *sway_input_manager_create( | |||
31 | struct sway_server *server); | 31 | struct sway_server *server); |
32 | 32 | ||
33 | bool sway_input_manager_has_focus(struct sway_input_manager *input, | 33 | bool sway_input_manager_has_focus(struct sway_input_manager *input, |
34 | struct sway_container *container); | 34 | swayc_t *container); |
35 | 35 | ||
36 | void sway_input_manager_set_focus(struct sway_input_manager *input, | 36 | void sway_input_manager_set_focus(struct sway_input_manager *input, |
37 | struct sway_container *container); | 37 | swayc_t *container); |
38 | 38 | ||
39 | void sway_input_manager_configure_xcursor(struct sway_input_manager *input); | 39 | void sway_input_manager_configure_xcursor(struct sway_input_manager *input); |
40 | 40 | ||
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index 496bfd5d..1d55bec7 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h | |||
@@ -14,7 +14,7 @@ struct sway_seat_device { | |||
14 | 14 | ||
15 | struct sway_seat_container { | 15 | struct sway_seat_container { |
16 | struct sway_seat *seat; | 16 | struct sway_seat *seat; |
17 | struct sway_container *container; | 17 | swayc_t *container; |
18 | 18 | ||
19 | struct wl_list link; // sway_seat::focus_stack | 19 | struct wl_list link; // sway_seat::focus_stack |
20 | 20 | ||
@@ -54,9 +54,9 @@ void sway_seat_remove_device(struct sway_seat *seat, | |||
54 | 54 | ||
55 | void sway_seat_configure_xcursor(struct sway_seat *seat); | 55 | void sway_seat_configure_xcursor(struct sway_seat *seat); |
56 | 56 | ||
57 | void sway_seat_set_focus(struct sway_seat *seat, struct sway_container *container); | 57 | void sway_seat_set_focus(struct sway_seat *seat, swayc_t *container); |
58 | 58 | ||
59 | struct sway_container *sway_seat_get_focus(struct sway_seat *seat); | 59 | swayc_t *sway_seat_get_focus(struct sway_seat *seat); |
60 | 60 | ||
61 | /** | 61 | /** |
62 | * Return the last container to be focused for the seat (or the most recently | 62 | * Return the last container to be focused for the seat (or the most recently |
@@ -67,11 +67,10 @@ struct sway_container *sway_seat_get_focus(struct sway_seat *seat); | |||
67 | * is destroyed, or focus moves to a container with children and we need to | 67 | * is destroyed, or focus moves to a container with children and we need to |
68 | * descend into the next leaf in focus order. | 68 | * descend into the next leaf in focus order. |
69 | */ | 69 | */ |
70 | struct sway_container *sway_seat_get_focus_inactive(struct sway_seat *seat, | 70 | swayc_t *sway_seat_get_focus_inactive(struct sway_seat *seat, swayc_t *container); |
71 | struct sway_container *container); | ||
72 | 71 | ||
73 | struct sway_container *sway_seat_get_focus_by_type(struct sway_seat *seat, | 72 | swayc_t *sway_seat_get_focus_by_type(struct sway_seat *seat, |
74 | enum sway_container_type type); | 73 | enum swayc_types type); |
75 | 74 | ||
76 | void sway_seat_set_config(struct sway_seat *seat, struct seat_config *seat_config); | 75 | void sway_seat_set_config(struct sway_seat *seat, struct seat_config *seat_config); |
77 | 76 | ||
diff --git a/include/sway/ipc-json.h b/include/sway/ipc-json.h index 3d2fdc4f..eef5a018 100644 --- a/include/sway/ipc-json.h +++ b/include/sway/ipc-json.h | |||
@@ -1,13 +1,13 @@ | |||
1 | #ifndef _SWAY_IPC_JSON_H | 1 | #ifndef _SWAY_IPC_JSON_H |
2 | #define _SWAY_IPC_JSON_H | 2 | #define _SWAY_IPC_JSON_H |
3 | #include <json-c/json.h> | 3 | #include <json-c/json.h> |
4 | #include "sway/tree/container.h" | 4 | #include "sway/container.h" |
5 | #include "sway/input/input-manager.h" | 5 | #include "sway/input/input-manager.h" |
6 | 6 | ||
7 | json_object *ipc_json_get_version(); | 7 | json_object *ipc_json_get_version(); |
8 | 8 | ||
9 | json_object *ipc_json_describe_container(struct sway_container *c); | 9 | json_object *ipc_json_describe_container(swayc_t *c); |
10 | json_object *ipc_json_describe_container_recursive(struct sway_container *c); | 10 | json_object *ipc_json_describe_container_recursive(swayc_t *c); |
11 | json_object *ipc_json_describe_input(struct sway_input_device *device); | 11 | json_object *ipc_json_describe_input(struct sway_input_device *device); |
12 | 12 | ||
13 | #endif | 13 | #endif |
diff --git a/include/sway/ipc-server.h b/include/sway/ipc-server.h index d73006dc..bcf1c433 100644 --- a/include/sway/ipc-server.h +++ b/include/sway/ipc-server.h | |||
@@ -1,17 +1,15 @@ | |||
1 | #ifndef _SWAY_IPC_SERVER_H | 1 | #ifndef _SWAY_IPC_SERVER_H |
2 | #define _SWAY_IPC_SERVER_H | 2 | #define _SWAY_IPC_SERVER_H |
3 | #include <sys/socket.h> | 3 | #include <sys/socket.h> |
4 | #include "sway/tree/container.h" | 4 | #include "sway/container.h" |
5 | #include "ipc.h" | 5 | #include "ipc.h" |
6 | 6 | ||
7 | struct sway_server; | 7 | struct sway_server; |
8 | 8 | ||
9 | void ipc_init(struct sway_server *server); | 9 | void ipc_init(struct sway_server *server); |
10 | |||
11 | void ipc_terminate(void); | 10 | void ipc_terminate(void); |
12 | |||
13 | struct sockaddr_un *ipc_user_sockaddr(void); | 11 | struct sockaddr_un *ipc_user_sockaddr(void); |
14 | 12 | ||
15 | void ipc_event_window(struct sway_container *window, const char *change); | 13 | void ipc_event_window(swayc_t *window, const char *change); |
16 | 14 | ||
17 | #endif | 15 | #endif |
diff --git a/include/sway/layout.h b/include/sway/layout.h new file mode 100644 index 00000000..e82c4442 --- /dev/null +++ b/include/sway/layout.h | |||
@@ -0,0 +1,43 @@ | |||
1 | #ifndef _SWAY_LAYOUT_H | ||
2 | #define _SWAY_LAYOUT_H | ||
3 | |||
4 | #include <wlr/types/wlr_output_layout.h> | ||
5 | #include "sway/container.h" | ||
6 | |||
7 | enum movement_direction { | ||
8 | MOVE_LEFT, | ||
9 | MOVE_RIGHT, | ||
10 | MOVE_UP, | ||
11 | MOVE_DOWN, | ||
12 | MOVE_PARENT, | ||
13 | MOVE_CHILD, | ||
14 | MOVE_NEXT, | ||
15 | MOVE_PREV, | ||
16 | MOVE_FIRST | ||
17 | }; | ||
18 | |||
19 | struct sway_container; | ||
20 | |||
21 | struct sway_root { | ||
22 | struct wlr_output_layout *output_layout; | ||
23 | |||
24 | struct wl_listener output_layout_change; | ||
25 | |||
26 | struct wl_list unmanaged_views; // sway_view::unmanaged_view_link | ||
27 | |||
28 | struct { | ||
29 | struct wl_signal new_container; | ||
30 | } events; | ||
31 | }; | ||
32 | |||
33 | void init_layout(void); | ||
34 | void add_child(struct sway_container *parent, struct sway_container *child); | ||
35 | swayc_t *add_sibling(swayc_t *parent, swayc_t *child); | ||
36 | struct sway_container *remove_child(struct sway_container *child); | ||
37 | enum swayc_layouts default_layout(struct sway_container *output); | ||
38 | void sort_workspaces(struct sway_container *output); | ||
39 | void arrange_windows(struct sway_container *container, double width, double height); | ||
40 | swayc_t *get_swayc_in_direction(swayc_t *container, | ||
41 | struct sway_seat *seat, enum movement_direction dir); | ||
42 | |||
43 | #endif | ||
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h deleted file mode 100644 index 16df3ee7..00000000 --- a/include/sway/tree/container.h +++ /dev/null | |||
@@ -1,137 +0,0 @@ | |||
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 <wlr/types/wlr_surface.h> | ||
7 | #include "list.h" | ||
8 | |||
9 | extern struct sway_container root_container; | ||
10 | |||
11 | struct sway_view; | ||
12 | struct sway_seat; | ||
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 sway_container_type { | ||
21 | C_ROOT, | ||
22 | C_OUTPUT, | ||
23 | C_WORKSPACE, | ||
24 | C_CONTAINER, | ||
25 | C_VIEW, | ||
26 | |||
27 | C_TYPES, | ||
28 | }; | ||
29 | |||
30 | enum sway_container_layout { | ||
31 | L_NONE, | ||
32 | L_HORIZ, | ||
33 | L_VERT, | ||
34 | L_STACKED, | ||
35 | L_TABBED, | ||
36 | L_FLOATING, | ||
37 | |||
38 | // Keep last | ||
39 | L_LAYOUTS, | ||
40 | }; | ||
41 | |||
42 | enum sway_container_border { | ||
43 | B_NONE, | ||
44 | B_PIXEL, | ||
45 | B_NORMAL, | ||
46 | }; | ||
47 | |||
48 | struct sway_root; | ||
49 | struct sway_output; | ||
50 | struct sway_view; | ||
51 | |||
52 | struct sway_container { | ||
53 | union { | ||
54 | // TODO: Encapsulate state for other node types as well like C_CONTAINER | ||
55 | struct sway_root *sway_root; | ||
56 | struct sway_output *sway_output; | ||
57 | struct sway_view *sway_view; | ||
58 | }; | ||
59 | |||
60 | /** | ||
61 | * A unique ID to identify this container. Primarily used in the | ||
62 | * get_tree JSON output. | ||
63 | */ | ||
64 | size_t id; | ||
65 | |||
66 | char *name; | ||
67 | |||
68 | enum sway_container_type type; | ||
69 | enum sway_container_layout layout; | ||
70 | enum sway_container_layout prev_layout; | ||
71 | enum sway_container_layout workspace_layout; | ||
72 | |||
73 | // TODO convert to layout coordinates | ||
74 | double x, y; | ||
75 | |||
76 | // does not include borders or gaps. | ||
77 | double width, height; | ||
78 | |||
79 | list_t *children; | ||
80 | |||
81 | struct sway_container *parent; | ||
82 | |||
83 | list_t *marks; // list of char* | ||
84 | |||
85 | struct { | ||
86 | struct wl_signal destroy; | ||
87 | } events; | ||
88 | }; | ||
89 | |||
90 | // TODO only one container create function and pass the type? | ||
91 | struct sway_container *container_output_create( | ||
92 | struct sway_output *sway_output); | ||
93 | |||
94 | struct sway_container *container_workspace_create( | ||
95 | struct sway_container *output, const char *name); | ||
96 | |||
97 | struct sway_container *container_view_create( | ||
98 | struct sway_container *sibling, struct sway_view *sway_view); | ||
99 | |||
100 | struct sway_container *container_output_destroy(struct sway_container *output); | ||
101 | |||
102 | struct sway_container *container_view_destroy(struct sway_container *view); | ||
103 | |||
104 | struct sway_container *container_set_layout(struct sway_container *container, | ||
105 | enum sway_container_layout layout); | ||
106 | |||
107 | void container_descendents(struct sway_container *root, | ||
108 | enum sway_container_type type, | ||
109 | void (*func)(struct sway_container *item, void *data), void *data); | ||
110 | |||
111 | /** | ||
112 | * Finds a container based on test criteria. Returns the first container that | ||
113 | * passes the test. | ||
114 | */ | ||
115 | struct sway_container *container_find(struct sway_container *container, | ||
116 | bool (*test)(struct sway_container *view, void *data), void *data); | ||
117 | |||
118 | /** | ||
119 | * Finds a parent container with the given struct sway_containerype. | ||
120 | */ | ||
121 | struct sway_container *container_parent(struct sway_container *container, | ||
122 | enum sway_container_type type); | ||
123 | |||
124 | /** | ||
125 | * Find a container at the given coordinates. | ||
126 | */ | ||
127 | struct sway_container *container_at(struct sway_container *parent, | ||
128 | double lx, double ly, struct wlr_surface **surface, | ||
129 | double *sx, double *sy); | ||
130 | |||
131 | /** | ||
132 | * Apply the function for each child of the container breadth first. | ||
133 | */ | ||
134 | void container_for_each_descendent(struct sway_container *container, | ||
135 | void (*f)(struct sway_container *container, void *data), void *data); | ||
136 | |||
137 | #endif | ||
diff --git a/include/sway/tree/layout.h b/include/sway/tree/layout.h deleted file mode 100644 index ad52bdb0..00000000 --- a/include/sway/tree/layout.h +++ /dev/null | |||
@@ -1,52 +0,0 @@ | |||
1 | #ifndef _SWAY_LAYOUT_H | ||
2 | #define _SWAY_LAYOUT_H | ||
3 | |||
4 | #include <wlr/types/wlr_output_layout.h> | ||
5 | #include "sway/tree/container.h" | ||
6 | |||
7 | enum movement_direction { | ||
8 | MOVE_LEFT, | ||
9 | MOVE_RIGHT, | ||
10 | MOVE_UP, | ||
11 | MOVE_DOWN, | ||
12 | MOVE_PARENT, | ||
13 | MOVE_CHILD, | ||
14 | MOVE_NEXT, | ||
15 | MOVE_PREV, | ||
16 | MOVE_FIRST | ||
17 | }; | ||
18 | |||
19 | struct sway_container; | ||
20 | |||
21 | struct sway_root { | ||
22 | struct wlr_output_layout *output_layout; | ||
23 | |||
24 | struct wl_listener output_layout_change; | ||
25 | |||
26 | struct wl_list unmanaged_views; // sway_view::unmanaged_view_link | ||
27 | |||
28 | struct { | ||
29 | struct wl_signal new_container; | ||
30 | } events; | ||
31 | }; | ||
32 | |||
33 | void layout_init(void); | ||
34 | |||
35 | void container_add_child(struct sway_container *parent, struct sway_container *child); | ||
36 | |||
37 | struct sway_container *container_add_sibling(struct sway_container *parent, | ||
38 | struct sway_container *child); | ||
39 | |||
40 | struct sway_container *container_remove_child(struct sway_container *child); | ||
41 | |||
42 | enum sway_container_layout container_get_default_layout(struct sway_container *output); | ||
43 | |||
44 | void container_sort_workspaces(struct sway_container *output); | ||
45 | |||
46 | void arrange_windows(struct sway_container *container, | ||
47 | double width, double height); | ||
48 | |||
49 | struct sway_container *container_get_in_direction(struct sway_container | ||
50 | *container, struct sway_seat *seat, enum movement_direction dir); | ||
51 | |||
52 | #endif | ||
diff --git a/include/sway/tree/workspace.h b/include/sway/tree/workspace.h deleted file mode 100644 index d73b29c1..00000000 --- a/include/sway/tree/workspace.h +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
1 | #ifndef _SWAY_WORKSPACE_H | ||
2 | #define _SWAY_WORKSPACE_H | ||
3 | |||
4 | #include "sway/tree/container.h" | ||
5 | |||
6 | extern char *prev_workspace_name; | ||
7 | |||
8 | char *workspace_next_name(const char *output_name); | ||
9 | |||
10 | struct sway_container *workspace_create(const char *name); | ||
11 | |||
12 | bool workspace_switch(struct sway_container *workspace); | ||
13 | |||
14 | struct sway_container *workspace_by_number(const char* name); | ||
15 | |||
16 | struct sway_container *workspace_by_name(const char*); | ||
17 | |||
18 | struct sway_container *workspace_output_next(struct sway_container *current); | ||
19 | |||
20 | struct sway_container *workspace_next(struct sway_container *current); | ||
21 | |||
22 | struct sway_container *workspace_output_prev(struct sway_container *current); | ||
23 | |||
24 | struct sway_container *workspace_prev(struct sway_container *current); | ||
25 | |||
26 | #endif | ||
diff --git a/include/sway/tree/view.h b/include/sway/view.h index e5f53f4e..b2886211 100644 --- a/include/sway/tree/view.h +++ b/include/sway/view.h | |||
@@ -62,6 +62,10 @@ enum sway_view_prop { | |||
62 | VIEW_PROP_INSTANCE, | 62 | VIEW_PROP_INSTANCE, |
63 | }; | 63 | }; |
64 | 64 | ||
65 | /** | ||
66 | * sway_view is a state container for surfaces that are arranged in the sway | ||
67 | * tree (shell surfaces). | ||
68 | */ | ||
65 | struct sway_view { | 69 | struct sway_view { |
66 | enum sway_view_type type; | 70 | enum sway_view_type type; |
67 | struct sway_container *swayc; | 71 | struct sway_container *swayc; |
diff --git a/include/sway/workspace.h b/include/sway/workspace.h new file mode 100644 index 00000000..fee54255 --- /dev/null +++ b/include/sway/workspace.h | |||
@@ -0,0 +1,20 @@ | |||
1 | #ifndef _SWAY_WORKSPACE_H | ||
2 | #define _SWAY_WORKSPACE_H | ||
3 | |||
4 | #include "sway/container.h" | ||
5 | |||
6 | extern char *prev_workspace_name; | ||
7 | |||
8 | char *workspace_next_name(const char *output_name); | ||
9 | swayc_t *workspace_create(const char *name); | ||
10 | bool workspace_switch(swayc_t *workspace); | ||
11 | |||
12 | struct sway_container *workspace_by_number(const char* name); | ||
13 | swayc_t *workspace_by_name(const char*); | ||
14 | |||
15 | struct sway_container *workspace_output_next(swayc_t *current); | ||
16 | struct sway_container *workspace_next(swayc_t *current); | ||
17 | struct sway_container *workspace_output_prev(swayc_t *current); | ||
18 | struct sway_container *workspace_prev(swayc_t *current); | ||
19 | |||
20 | #endif | ||