diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/log.h | 2 | ||||
-rw-r--r-- | include/sway/config.h | 7 | ||||
-rw-r--r-- | include/sway/desktop/transaction.h | 4 | ||||
-rw-r--r-- | include/sway/input/input-manager.h | 4 | ||||
-rw-r--r-- | include/sway/input/seat.h | 41 | ||||
-rw-r--r-- | include/sway/ipc-json.h | 4 | ||||
-rw-r--r-- | include/sway/ipc-server.h | 4 | ||||
-rw-r--r-- | include/sway/output.h | 62 | ||||
-rw-r--r-- | include/sway/server.h | 2 | ||||
-rw-r--r-- | include/sway/tree/arrange.h | 9 | ||||
-rw-r--r-- | include/sway/tree/container.h | 146 | ||||
-rw-r--r-- | include/sway/tree/node.h | 74 | ||||
-rw-r--r-- | include/sway/tree/root.h | 28 | ||||
-rw-r--r-- | include/sway/tree/view.h | 4 | ||||
-rw-r--r-- | include/sway/tree/workspace.h | 105 |
15 files changed, 295 insertions, 201 deletions
diff --git a/include/log.h b/include/log.h index dd526143..6fb2f277 100644 --- a/include/log.h +++ b/include/log.h | |||
@@ -15,7 +15,7 @@ void _sway_abort(const char *filename, ...) ATTRIB_PRINTF(1, 2); | |||
15 | 15 | ||
16 | bool _sway_assert(bool condition, const char* format, ...) ATTRIB_PRINTF(2, 3); | 16 | bool _sway_assert(bool condition, const char* format, ...) ATTRIB_PRINTF(2, 3); |
17 | #define sway_assert(COND, FMT, ...) \ | 17 | #define sway_assert(COND, FMT, ...) \ |
18 | _sway_assert(COND, "[%s:%d] %s:" FMT, _wlr_strip_path(__FILE__), __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__) | 18 | _sway_assert(COND, "[%s:%d] %s:" FMT, _wlr_strip_path(__FILE__), __LINE__, __func__, ##__VA_ARGS__) |
19 | 19 | ||
20 | void error_handler(int sig); | 20 | void error_handler(int sig); |
21 | 21 | ||
diff --git a/include/sway/config.h b/include/sway/config.h index 6024f0f6..2fef0081 100644 --- a/include/sway/config.h +++ b/include/sway/config.h | |||
@@ -407,7 +407,9 @@ struct sway_config { | |||
407 | struct output_config *output_config; | 407 | struct output_config *output_config; |
408 | struct seat_config *seat_config; | 408 | struct seat_config *seat_config; |
409 | struct sway_seat *seat; | 409 | struct sway_seat *seat; |
410 | struct sway_container *current_container; | 410 | struct sway_node *node; |
411 | struct sway_container *container; | ||
412 | struct sway_workspace *workspace; | ||
411 | bool using_criteria; | 413 | bool using_criteria; |
412 | struct { | 414 | struct { |
413 | int argc; | 415 | int argc; |
@@ -486,8 +488,7 @@ struct output_config *new_output_config(const char *name); | |||
486 | 488 | ||
487 | void merge_output_config(struct output_config *dst, struct output_config *src); | 489 | void merge_output_config(struct output_config *dst, struct output_config *src); |
488 | 490 | ||
489 | void apply_output_config(struct output_config *oc, | 491 | void apply_output_config(struct output_config *oc, struct sway_output *output); |
490 | struct sway_container *output); | ||
491 | 492 | ||
492 | struct output_config *store_output_config(struct output_config *oc); | 493 | struct output_config *store_output_config(struct output_config *oc); |
493 | 494 | ||
diff --git a/include/sway/desktop/transaction.h b/include/sway/desktop/transaction.h index 7ac924e7..66e8c9a2 100644 --- a/include/sway/desktop/transaction.h +++ b/include/sway/desktop/transaction.h | |||
@@ -1,7 +1,6 @@ | |||
1 | #ifndef _SWAY_TRANSACTION_H | 1 | #ifndef _SWAY_TRANSACTION_H |
2 | #define _SWAY_TRANSACTION_H | 2 | #define _SWAY_TRANSACTION_H |
3 | #include <wlr/render/wlr_texture.h> | 3 | #include <stdint.h> |
4 | #include "sway/tree/container.h" | ||
5 | 4 | ||
6 | /** | 5 | /** |
7 | * Transactions enable us to perform atomic layout updates. | 6 | * Transactions enable us to perform atomic layout updates. |
@@ -21,6 +20,7 @@ | |||
21 | */ | 20 | */ |
22 | 21 | ||
23 | struct sway_transaction_instruction; | 22 | struct sway_transaction_instruction; |
23 | struct sway_view; | ||
24 | 24 | ||
25 | /** | 25 | /** |
26 | * Find all dirty containers, create and commit a transaction containing them, | 26 | * Find all dirty containers, create and commit a transaction containing them, |
diff --git a/include/sway/input/input-manager.h b/include/sway/input/input-manager.h index aa2f6f19..bde3cf46 100644 --- a/include/sway/input/input-manager.h +++ b/include/sway/input/input-manager.h | |||
@@ -37,10 +37,10 @@ struct sway_input_manager { | |||
37 | struct sway_input_manager *input_manager_create(struct sway_server *server); | 37 | struct sway_input_manager *input_manager_create(struct sway_server *server); |
38 | 38 | ||
39 | bool input_manager_has_focus(struct sway_input_manager *input, | 39 | bool input_manager_has_focus(struct sway_input_manager *input, |
40 | struct sway_container *container); | 40 | struct sway_node *node); |
41 | 41 | ||
42 | void input_manager_set_focus(struct sway_input_manager *input, | 42 | void input_manager_set_focus(struct sway_input_manager *input, |
43 | struct sway_container *container); | 43 | struct sway_node *node); |
44 | 44 | ||
45 | void input_manager_configure_xcursor(struct sway_input_manager *input); | 45 | void input_manager_configure_xcursor(struct sway_input_manager *input); |
46 | 46 | ||
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index 5c404ecd..b07d200d 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h | |||
@@ -13,9 +13,9 @@ struct sway_seat_device { | |||
13 | struct wl_list link; // sway_seat::devices | 13 | struct wl_list link; // sway_seat::devices |
14 | }; | 14 | }; |
15 | 15 | ||
16 | struct sway_seat_container { | 16 | struct sway_seat_node { |
17 | struct sway_seat *seat; | 17 | struct sway_seat *seat; |
18 | struct sway_container *container; | 18 | struct sway_node *node; |
19 | 19 | ||
20 | struct wl_list link; // sway_seat::focus_stack | 20 | struct wl_list link; // sway_seat::focus_stack |
21 | 21 | ||
@@ -76,7 +76,7 @@ struct sway_seat { | |||
76 | uint32_t last_button_serial; | 76 | uint32_t last_button_serial; |
77 | 77 | ||
78 | struct wl_listener focus_destroy; | 78 | struct wl_listener focus_destroy; |
79 | struct wl_listener new_container; | 79 | struct wl_listener new_node; |
80 | struct wl_listener new_drag_icon; | 80 | struct wl_listener new_drag_icon; |
81 | 81 | ||
82 | struct wl_list devices; // sway_seat_device::link | 82 | struct wl_list devices; // sway_seat_device::link |
@@ -100,10 +100,16 @@ void seat_remove_device(struct sway_seat *seat, | |||
100 | 100 | ||
101 | void seat_configure_xcursor(struct sway_seat *seat); | 101 | void seat_configure_xcursor(struct sway_seat *seat); |
102 | 102 | ||
103 | void seat_set_focus(struct sway_seat *seat, struct sway_container *container); | 103 | void seat_set_focus(struct sway_seat *seat, struct sway_node *node); |
104 | |||
105 | void seat_set_focus_container(struct sway_seat *seat, | ||
106 | struct sway_container *con); | ||
107 | |||
108 | void seat_set_focus_workspace(struct sway_seat *seat, | ||
109 | struct sway_workspace *ws); | ||
104 | 110 | ||
105 | void seat_set_focus_warp(struct sway_seat *seat, | 111 | void seat_set_focus_warp(struct sway_seat *seat, |
106 | struct sway_container *container, bool warp, bool notify); | 112 | struct sway_node *node, bool warp, bool notify); |
107 | 113 | ||
108 | void seat_set_focus_surface(struct sway_seat *seat, | 114 | void seat_set_focus_surface(struct sway_seat *seat, |
109 | struct wlr_surface *surface, bool unfocus); | 115 | struct wlr_surface *surface, bool unfocus); |
@@ -114,7 +120,11 @@ void seat_set_focus_layer(struct sway_seat *seat, | |||
114 | void seat_set_exclusive_client(struct sway_seat *seat, | 120 | void seat_set_exclusive_client(struct sway_seat *seat, |
115 | struct wl_client *client); | 121 | struct wl_client *client); |
116 | 122 | ||
117 | struct sway_container *seat_get_focus(struct sway_seat *seat); | 123 | struct sway_node *seat_get_focus(struct sway_seat *seat); |
124 | |||
125 | struct sway_workspace *seat_get_focused_workspace(struct sway_seat *seat); | ||
126 | |||
127 | struct sway_container *seat_get_focused_container(struct sway_seat *seat); | ||
118 | 128 | ||
119 | /** | 129 | /** |
120 | * Return the last container to be focused for the seat (or the most recently | 130 | * Return the last container to be focused for the seat (or the most recently |
@@ -125,32 +135,31 @@ struct sway_container *seat_get_focus(struct sway_seat *seat); | |||
125 | * is destroyed, or focus moves to a container with children and we need to | 135 | * is destroyed, or focus moves to a container with children and we need to |
126 | * descend into the next leaf in focus order. | 136 | * descend into the next leaf in focus order. |
127 | */ | 137 | */ |
128 | struct sway_container *seat_get_focus_inactive(struct sway_seat *seat, | 138 | struct sway_node *seat_get_focus_inactive(struct sway_seat *seat, |
129 | struct sway_container *container); | 139 | struct sway_node *node); |
130 | 140 | ||
131 | struct sway_container *seat_get_focus_inactive_tiling(struct sway_seat *seat, | 141 | struct sway_container *seat_get_focus_inactive_tiling(struct sway_seat *seat, |
132 | struct sway_container *container); | 142 | struct sway_workspace *workspace); |
133 | 143 | ||
134 | /** | 144 | /** |
135 | * Descend into the focus stack to find the focus-inactive view. Useful for | 145 | * Descend into the focus stack to find the focus-inactive view. Useful for |
136 | * container placement when they change position in the tree. | 146 | * container placement when they change position in the tree. |
137 | */ | 147 | */ |
138 | struct sway_container *seat_get_focus_inactive_view(struct sway_seat *seat, | 148 | struct sway_container *seat_get_focus_inactive_view(struct sway_seat *seat, |
139 | struct sway_container *container); | 149 | struct sway_node *ancestor); |
140 | 150 | ||
141 | /** | 151 | /** |
142 | * Return the immediate child of container which was most recently focused. | 152 | * Return the immediate child of container which was most recently focused. |
143 | */ | 153 | */ |
144 | struct sway_container *seat_get_active_child(struct sway_seat *seat, | 154 | struct sway_node *seat_get_active_child(struct sway_seat *seat, |
145 | struct sway_container *container); | 155 | struct sway_node *parent); |
146 | 156 | ||
147 | /** | 157 | /** |
148 | * Iterate over the focus-inactive children of the container calling the | 158 | * Iterate over the focus-inactive children of the container calling the |
149 | * function on each. | 159 | * function on each. |
150 | */ | 160 | */ |
151 | void seat_focus_inactive_children_for_each(struct sway_seat *seat, | 161 | void seat_for_each_node(struct sway_seat *seat, |
152 | struct sway_container *container, | 162 | void (*f)(struct sway_node *node, void *data), void *data); |
153 | void (*f)(struct sway_container *container, void *data), void *data); | ||
154 | 163 | ||
155 | void seat_apply_config(struct sway_seat *seat, struct seat_config *seat_config); | 164 | void seat_apply_config(struct sway_seat *seat, struct seat_config *seat_config); |
156 | 165 | ||
@@ -173,7 +182,7 @@ void seat_begin_resize_tiling(struct sway_seat *seat, | |||
173 | struct sway_container *con, uint32_t button, enum wlr_edges edge); | 182 | struct sway_container *con, uint32_t button, enum wlr_edges edge); |
174 | 183 | ||
175 | struct sway_container *seat_get_focus_inactive_floating(struct sway_seat *seat, | 184 | struct sway_container *seat_get_focus_inactive_floating(struct sway_seat *seat, |
176 | struct sway_container *container); | 185 | struct sway_workspace *workspace); |
177 | 186 | ||
178 | void seat_end_mouse_operation(struct sway_seat *seat); | 187 | void seat_end_mouse_operation(struct sway_seat *seat); |
179 | 188 | ||
diff --git a/include/sway/ipc-json.h b/include/sway/ipc-json.h index eaaa2164..fef243e3 100644 --- a/include/sway/ipc-json.h +++ b/include/sway/ipc-json.h | |||
@@ -7,8 +7,8 @@ | |||
7 | json_object *ipc_json_get_version(); | 7 | json_object *ipc_json_get_version(); |
8 | 8 | ||
9 | json_object *ipc_json_describe_disabled_output(struct sway_output *o); | 9 | json_object *ipc_json_describe_disabled_output(struct sway_output *o); |
10 | json_object *ipc_json_describe_container(struct sway_container *c); | 10 | json_object *ipc_json_describe_node(struct sway_node *node); |
11 | json_object *ipc_json_describe_container_recursive(struct sway_container *c); | 11 | json_object *ipc_json_describe_node_recursive(struct sway_node *node); |
12 | json_object *ipc_json_describe_input(struct sway_input_device *device); | 12 | json_object *ipc_json_describe_input(struct sway_input_device *device); |
13 | json_object *ipc_json_describe_seat(struct sway_seat *seat); | 13 | json_object *ipc_json_describe_seat(struct sway_seat *seat); |
14 | json_object *ipc_json_describe_bar_config(struct bar_config *bar); | 14 | json_object *ipc_json_describe_bar_config(struct bar_config *bar); |
diff --git a/include/sway/ipc-server.h b/include/sway/ipc-server.h index 4b6d0e25..80180ec4 100644 --- a/include/sway/ipc-server.h +++ b/include/sway/ipc-server.h | |||
@@ -11,8 +11,8 @@ void ipc_init(struct sway_server *server); | |||
11 | 11 | ||
12 | struct sockaddr_un *ipc_user_sockaddr(void); | 12 | struct sockaddr_un *ipc_user_sockaddr(void); |
13 | 13 | ||
14 | void ipc_event_workspace(struct sway_container *old, | 14 | void ipc_event_workspace(struct sway_workspace *old, |
15 | struct sway_container *new, const char *change); | 15 | struct sway_workspace *new, const char *change); |
16 | void ipc_event_window(struct sway_container *window, const char *change); | 16 | void ipc_event_window(struct sway_container *window, const char *change); |
17 | void ipc_event_barconfig_update(struct bar_config *bar); | 17 | void ipc_event_barconfig_update(struct bar_config *bar); |
18 | void ipc_event_mode(const char *mode, bool pango); | 18 | void ipc_event_mode(const char *mode, bool pango); |
diff --git a/include/sway/output.h b/include/sway/output.h index 651fdfe7..19a61175 100644 --- a/include/sway/output.h +++ b/include/sway/output.h | |||
@@ -6,14 +6,20 @@ | |||
6 | #include <wlr/types/wlr_box.h> | 6 | #include <wlr/types/wlr_box.h> |
7 | #include <wlr/types/wlr_output.h> | 7 | #include <wlr/types/wlr_output.h> |
8 | #include "config.h" | 8 | #include "config.h" |
9 | #include "sway/tree/node.h" | ||
9 | #include "sway/tree/view.h" | 10 | #include "sway/tree/view.h" |
10 | 11 | ||
11 | struct sway_server; | 12 | struct sway_server; |
12 | struct sway_container; | 13 | struct sway_container; |
13 | 14 | ||
15 | struct sway_output_state { | ||
16 | list_t *workspaces; | ||
17 | struct sway_workspace *active_workspace; | ||
18 | }; | ||
19 | |||
14 | struct sway_output { | 20 | struct sway_output { |
21 | struct sway_node node; | ||
15 | struct wlr_output *wlr_output; | 22 | struct wlr_output *wlr_output; |
16 | struct sway_container *swayc; | ||
17 | struct sway_server *server; | 23 | struct sway_server *server; |
18 | 24 | ||
19 | struct wl_list layers[4]; // sway_layer_surface::link | 25 | struct wl_list layers[4]; // sway_layer_surface::link |
@@ -22,11 +28,18 @@ struct sway_output { | |||
22 | struct timespec last_frame; | 28 | struct timespec last_frame; |
23 | struct wlr_output_damage *damage; | 29 | struct wlr_output_damage *damage; |
24 | 30 | ||
31 | int lx, ly; | ||
32 | int width, height; | ||
33 | |||
34 | bool enabled; | ||
35 | list_t *workspaces; | ||
36 | |||
37 | struct sway_output_state current; | ||
38 | |||
25 | struct wl_listener destroy; | 39 | struct wl_listener destroy; |
26 | struct wl_listener mode; | 40 | struct wl_listener mode; |
27 | struct wl_listener transform; | 41 | struct wl_listener transform; |
28 | struct wl_listener scale; | 42 | struct wl_listener scale; |
29 | |||
30 | struct wl_listener damage_destroy; | 43 | struct wl_listener damage_destroy; |
31 | struct wl_listener damage_frame; | 44 | struct wl_listener damage_frame; |
32 | 45 | ||
@@ -39,13 +52,19 @@ struct sway_output { | |||
39 | } events; | 52 | } events; |
40 | }; | 53 | }; |
41 | 54 | ||
42 | struct sway_container *output_create(struct sway_output *sway_output); | 55 | struct sway_output *output_create(struct wlr_output *wlr_output); |
56 | |||
57 | void output_destroy(struct sway_output *output); | ||
58 | |||
59 | void output_begin_destroy(struct sway_output *output); | ||
43 | 60 | ||
44 | void output_destroy(struct sway_container *output); | 61 | struct sway_output *output_from_wlr_output(struct wlr_output *output); |
45 | 62 | ||
46 | void output_begin_destroy(struct sway_container *output); | 63 | struct sway_output *output_get_in_direction(struct sway_output *reference, |
64 | enum movement_direction direction); | ||
47 | 65 | ||
48 | struct sway_container *output_from_wlr_output(struct wlr_output *output); | 66 | void output_add_workspace(struct sway_output *output, |
67 | struct sway_workspace *workspace); | ||
49 | 68 | ||
50 | typedef void (*sway_surface_iterator_func_t)(struct sway_output *output, | 69 | typedef void (*sway_surface_iterator_func_t)(struct sway_output *output, |
51 | struct wlr_surface *surface, struct wlr_box *box, float rotation, | 70 | struct wlr_surface *surface, struct wlr_box *box, float rotation, |
@@ -64,15 +83,19 @@ void output_damage_box(struct sway_output *output, struct wlr_box *box); | |||
64 | void output_damage_whole_container(struct sway_output *output, | 83 | void output_damage_whole_container(struct sway_output *output, |
65 | struct sway_container *con); | 84 | struct sway_container *con); |
66 | 85 | ||
67 | struct sway_container *output_by_name(const char *name); | 86 | struct sway_output *output_by_name(const char *name); |
68 | 87 | ||
69 | void output_sort_workspaces(struct sway_container *output); | 88 | void output_sort_workspaces(struct sway_output *output); |
70 | 89 | ||
71 | void output_enable(struct sway_output *output); | 90 | struct output_config *output_find_config(struct sway_output *output); |
91 | |||
92 | void output_enable(struct sway_output *output, struct output_config *oc); | ||
93 | |||
94 | void output_disable(struct sway_output *output); | ||
72 | 95 | ||
73 | bool output_has_opaque_overlay_layer_surface(struct sway_output *output); | 96 | bool output_has_opaque_overlay_layer_surface(struct sway_output *output); |
74 | 97 | ||
75 | struct sway_container *output_get_active_workspace(struct sway_output *output); | 98 | struct sway_workspace *output_get_active_workspace(struct sway_output *output); |
76 | 99 | ||
77 | void output_render(struct sway_output *output, struct timespec *when, | 100 | void output_render(struct sway_output *output, struct timespec *when, |
78 | pixman_region32_t *damage); | 101 | pixman_region32_t *damage); |
@@ -103,16 +126,23 @@ void output_drag_icons_for_each_surface(struct sway_output *output, | |||
103 | struct wl_list *drag_icons, sway_surface_iterator_func_t iterator, | 126 | struct wl_list *drag_icons, sway_surface_iterator_func_t iterator, |
104 | void *user_data); | 127 | void *user_data); |
105 | 128 | ||
106 | void output_for_each_workspace(struct sway_container *output, | 129 | void output_for_each_workspace(struct sway_output *output, |
107 | void (*f)(struct sway_container *con, void *data), void *data); | 130 | void (*f)(struct sway_workspace *ws, void *data), void *data); |
108 | 131 | ||
109 | void output_for_each_container(struct sway_container *output, | 132 | void output_for_each_container(struct sway_output *output, |
110 | void (*f)(struct sway_container *con, void *data), void *data); | 133 | void (*f)(struct sway_container *con, void *data), void *data); |
111 | 134 | ||
112 | struct sway_container *output_find_workspace(struct sway_container *output, | 135 | struct sway_workspace *output_find_workspace(struct sway_output *output, |
113 | bool (*test)(struct sway_container *con, void *data), void *data); | 136 | bool (*test)(struct sway_workspace *ws, void *data), void *data); |
114 | 137 | ||
115 | struct sway_container *output_find_container(struct sway_container *output, | 138 | struct sway_container *output_find_container(struct sway_output *output, |
116 | bool (*test)(struct sway_container *con, void *data), void *data); | 139 | bool (*test)(struct sway_container *con, void *data), void *data); |
117 | 140 | ||
141 | void output_get_box(struct sway_output *output, struct wlr_box *box); | ||
142 | |||
143 | enum sway_container_layout output_get_default_layout( | ||
144 | struct sway_output *output); | ||
145 | |||
146 | void output_add_listeners(struct sway_output *output); | ||
147 | |||
118 | #endif | 148 | #endif |
diff --git a/include/sway/server.h b/include/sway/server.h index 1e20f2c8..07e0949a 100644 --- a/include/sway/server.h +++ b/include/sway/server.h | |||
@@ -56,7 +56,7 @@ struct sway_server { | |||
56 | 56 | ||
57 | size_t txn_timeout_ms; | 57 | size_t txn_timeout_ms; |
58 | list_t *transactions; | 58 | list_t *transactions; |
59 | list_t *dirty_containers; | 59 | list_t *dirty_nodes; |
60 | }; | 60 | }; |
61 | 61 | ||
62 | struct sway_server server; | 62 | struct sway_server server; |
diff --git a/include/sway/tree/arrange.h b/include/sway/tree/arrange.h index f47e8db5..06a2279c 100644 --- a/include/sway/tree/arrange.h +++ b/include/sway/tree/arrange.h | |||
@@ -1,16 +1,19 @@ | |||
1 | #ifndef _SWAY_ARRANGE_H | 1 | #ifndef _SWAY_ARRANGE_H |
2 | #define _SWAY_ARRANGE_H | 2 | #define _SWAY_ARRANGE_H |
3 | 3 | ||
4 | struct sway_output; | ||
5 | struct sway_workspace; | ||
4 | struct sway_container; | 6 | struct sway_container; |
7 | struct sway_node; | ||
5 | 8 | ||
6 | void arrange_container(struct sway_container *container); | 9 | void arrange_container(struct sway_container *container); |
7 | 10 | ||
8 | void arrange_workspace(struct sway_container *workspace); | 11 | void arrange_workspace(struct sway_workspace *workspace); |
9 | 12 | ||
10 | void arrange_output(struct sway_container *output); | 13 | void arrange_output(struct sway_output *output); |
11 | 14 | ||
12 | void arrange_root(void); | 15 | void arrange_root(void); |
13 | 16 | ||
14 | void arrange_windows(struct sway_container *container); | 17 | void arrange_node(struct sway_node *node); |
15 | 18 | ||
16 | #endif | 19 | #endif |
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index e4071cfe..6efecf7c 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h | |||
@@ -5,8 +5,7 @@ | |||
5 | #include <wlr/types/wlr_box.h> | 5 | #include <wlr/types/wlr_box.h> |
6 | #include <wlr/types/wlr_surface.h> | 6 | #include <wlr/types/wlr_surface.h> |
7 | #include "list.h" | 7 | #include "list.h" |
8 | 8 | #include "sway/tree/node.h" | |
9 | extern struct sway_container root_container; | ||
10 | 9 | ||
11 | struct sway_view; | 10 | struct sway_view; |
12 | struct sway_seat; | 11 | struct sway_seat; |
@@ -17,23 +16,6 @@ struct sway_seat; | |||
17 | #define TITLEBAR_H_PADDING 3 | 16 | #define TITLEBAR_H_PADDING 3 |
18 | #define TITLEBAR_V_PADDING 4 | 17 | #define TITLEBAR_V_PADDING 4 |
19 | 18 | ||
20 | /** | ||
21 | * Different kinds of containers. | ||
22 | * | ||
23 | * This enum is in order. A container will never be inside of a container below | ||
24 | * it on this list. | ||
25 | */ | ||
26 | enum sway_container_type { | ||
27 | C_ROOT, | ||
28 | C_OUTPUT, | ||
29 | C_WORKSPACE, | ||
30 | C_CONTAINER, | ||
31 | C_VIEW, | ||
32 | |||
33 | // Keep last | ||
34 | C_TYPES, | ||
35 | }; | ||
36 | |||
37 | enum sway_container_layout { | 19 | enum sway_container_layout { |
38 | L_NONE, | 20 | L_NONE, |
39 | L_HORIZ, | 21 | L_HORIZ, |
@@ -57,18 +39,14 @@ enum movement_direction; | |||
57 | enum wlr_direction; | 39 | enum wlr_direction; |
58 | 40 | ||
59 | struct sway_container_state { | 41 | struct sway_container_state { |
60 | // Container/swayc properties | 42 | // Container properties |
61 | enum sway_container_layout layout; | 43 | enum sway_container_layout layout; |
62 | double swayc_x, swayc_y; | 44 | double con_x, con_y; |
63 | double swayc_width, swayc_height; | 45 | double con_width, con_height; |
64 | 46 | ||
65 | bool is_fullscreen; | 47 | bool is_fullscreen; |
66 | 48 | ||
67 | bool has_gaps; | 49 | struct sway_workspace *workspace; |
68 | double current_gaps; | ||
69 | double gaps_inner; | ||
70 | double gaps_outer; | ||
71 | |||
72 | struct sway_container *parent; | 50 | struct sway_container *parent; |
73 | list_t *children; | 51 | list_t *children; |
74 | 52 | ||
@@ -86,35 +64,19 @@ struct sway_container_state { | |||
86 | bool border_left; | 64 | bool border_left; |
87 | bool border_right; | 65 | bool border_right; |
88 | bool using_csd; | 66 | bool using_csd; |
89 | |||
90 | // Workspace properties | ||
91 | struct sway_container *ws_fullscreen; | ||
92 | list_t *ws_floating; | ||
93 | }; | 67 | }; |
94 | 68 | ||
95 | struct sway_container { | 69 | struct sway_container { |
96 | union { | 70 | struct sway_node node; |
97 | // TODO: Encapsulate state for other node types as well like C_CONTAINER | 71 | struct sway_view *view; |
98 | struct sway_root *sway_root; | ||
99 | struct sway_output *sway_output; | ||
100 | struct sway_workspace *sway_workspace; | ||
101 | struct sway_view *sway_view; | ||
102 | }; | ||
103 | |||
104 | /** | ||
105 | * A unique ID to identify this container. Primarily used in the | ||
106 | * get_tree JSON output. | ||
107 | */ | ||
108 | size_t id; | ||
109 | 72 | ||
110 | // The pending state is the main container properties, and the current state is in the below struct. | 73 | // The pending state is the main container properties, and the current state is in the below struct. |
111 | // This means most places of the code can refer to the main variables (pending state) and it'll just work. | 74 | // This means most places of the code can refer to the main variables (pending state) and it'll just work. |
112 | struct sway_container_state current; | 75 | struct sway_container_state current; |
113 | 76 | ||
114 | char *name; // The view's title (unformatted) | 77 | char *title; // The view's title (unformatted) |
115 | char *formatted_title; // The title displayed in the title bar | 78 | char *formatted_title; // The title displayed in the title bar |
116 | 79 | ||
117 | enum sway_container_type type; | ||
118 | enum sway_container_layout layout; | 80 | enum sway_container_layout layout; |
119 | enum sway_container_layout prev_split_layout; | 81 | enum sway_container_layout prev_split_layout; |
120 | 82 | ||
@@ -132,14 +94,13 @@ struct sway_container { | |||
132 | 94 | ||
133 | // The gaps currently applied to the container. | 95 | // The gaps currently applied to the container. |
134 | double current_gaps; | 96 | double current_gaps; |
135 | |||
136 | bool has_gaps; | 97 | bool has_gaps; |
137 | double gaps_inner; | 98 | double gaps_inner; |
138 | double gaps_outer; | 99 | double gaps_outer; |
139 | 100 | ||
140 | list_t *children; | 101 | struct sway_workspace *workspace; // NULL when hidden in the scratchpad |
141 | 102 | struct sway_container *parent; // NULL if container in root of workspace | |
142 | struct sway_container *parent; | 103 | list_t *children; // struct sway_container |
143 | 104 | ||
144 | // Outputs currently being intersected | 105 | // Outputs currently being intersected |
145 | list_t *outputs; // struct sway_output | 106 | list_t *outputs; // struct sway_output |
@@ -157,42 +118,17 @@ struct sway_container { | |||
157 | struct wlr_texture *title_urgent; | 118 | struct wlr_texture *title_urgent; |
158 | size_t title_height; | 119 | size_t title_height; |
159 | 120 | ||
160 | // The number of transactions which reference this container. | ||
161 | size_t ntxnrefs; | ||
162 | |||
163 | // If this container is a view and is waiting for the client to respond to a | ||
164 | // configure then this will be populated, otherwise NULL. | ||
165 | struct sway_transaction_instruction *instruction; | ||
166 | |||
167 | bool destroying; | ||
168 | |||
169 | // If true, indicates that the container has pending state that differs from | ||
170 | // the current. | ||
171 | bool dirty; | ||
172 | |||
173 | struct { | 121 | struct { |
174 | struct wl_signal destroy; | 122 | struct wl_signal destroy; |
175 | } events; | 123 | } events; |
176 | }; | 124 | }; |
177 | 125 | ||
178 | struct sway_container *container_create(enum sway_container_type type); | 126 | struct sway_container *container_create(struct sway_view *view); |
179 | |||
180 | const char *container_type_to_str(enum sway_container_type type); | ||
181 | |||
182 | /* | ||
183 | * Create a new view container. A view can be a child of a workspace container | ||
184 | * or a container container and are rendered in the order and structure of | ||
185 | * how they are attached to the tree. | ||
186 | */ | ||
187 | struct sway_container *container_view_create( | ||
188 | struct sway_container *sibling, struct sway_view *sway_view); | ||
189 | 127 | ||
190 | void container_destroy(struct sway_container *con); | 128 | void container_destroy(struct sway_container *con); |
191 | 129 | ||
192 | void container_begin_destroy(struct sway_container *con); | 130 | void container_begin_destroy(struct sway_container *con); |
193 | 131 | ||
194 | struct sway_container *container_close(struct sway_container *container); | ||
195 | |||
196 | /** | 132 | /** |
197 | * Search a container's descendants a container based on test criteria. Returns | 133 | * Search a container's descendants a container based on test criteria. Returns |
198 | * the first container that passes the test. | 134 | * the first container that passes the test. |
@@ -201,22 +137,16 @@ struct sway_container *container_find_child(struct sway_container *container, | |||
201 | bool (*test)(struct sway_container *view, void *data), void *data); | 137 | bool (*test)(struct sway_container *view, void *data), void *data); |
202 | 138 | ||
203 | /** | 139 | /** |
204 | * Finds a parent container with the given struct sway_containerype. | ||
205 | */ | ||
206 | struct sway_container *container_parent(struct sway_container *container, | ||
207 | enum sway_container_type type); | ||
208 | |||
209 | /** | ||
210 | * Find a container at the given coordinates. Returns the the surface and | 140 | * Find a container at the given coordinates. Returns the the surface and |
211 | * surface-local coordinates of the given layout coordinates if the container | 141 | * surface-local coordinates of the given layout coordinates if the container |
212 | * is a view and the view contains a surface at those coordinates. | 142 | * is a view and the view contains a surface at those coordinates. |
213 | */ | 143 | */ |
214 | struct sway_container *container_at(struct sway_container *workspace, | 144 | struct sway_container *container_at(struct sway_workspace *workspace, |
215 | double lx, double ly, struct wlr_surface **surface, | 145 | double lx, double ly, struct wlr_surface **surface, |
216 | double *sx, double *sy); | 146 | double *sx, double *sy); |
217 | 147 | ||
218 | struct sway_container *tiling_container_at( | 148 | struct sway_container *tiling_container_at( |
219 | struct sway_container *con, double lx, double ly, | 149 | struct sway_node *parent, double lx, double ly, |
220 | struct wlr_surface **surface, double *sx, double *sy); | 150 | struct wlr_surface **surface, double *sx, double *sy); |
221 | 151 | ||
222 | void container_for_each_child(struct sway_container *container, | 152 | void container_for_each_child(struct sway_container *container, |
@@ -228,16 +158,11 @@ void container_for_each_child(struct sway_container *container, | |||
228 | bool container_has_ancestor(struct sway_container *container, | 158 | bool container_has_ancestor(struct sway_container *container, |
229 | struct sway_container *ancestor); | 159 | struct sway_container *ancestor); |
230 | 160 | ||
231 | int container_count_descendants_of_type(struct sway_container *con, | ||
232 | enum sway_container_type type); | ||
233 | |||
234 | void container_create_notify(struct sway_container *container); | ||
235 | |||
236 | void container_update_textures_recursive(struct sway_container *con); | 161 | void container_update_textures_recursive(struct sway_container *con); |
237 | 162 | ||
238 | void container_damage_whole(struct sway_container *container); | 163 | void container_damage_whole(struct sway_container *container); |
239 | 164 | ||
240 | struct sway_container *container_reap_empty(struct sway_container *con); | 165 | void container_reap_empty(struct sway_container *con); |
241 | 166 | ||
242 | struct sway_container *container_flatten(struct sway_container *container); | 167 | struct sway_container *container_flatten(struct sway_container *container); |
243 | 168 | ||
@@ -248,11 +173,10 @@ void container_update_title_textures(struct sway_container *container); | |||
248 | */ | 173 | */ |
249 | void container_calculate_title_height(struct sway_container *container); | 174 | void container_calculate_title_height(struct sway_container *container); |
250 | 175 | ||
251 | /** | 176 | size_t container_build_representation(enum sway_container_layout layout, |
252 | * Notify a container that a tree modification has changed in its children, | 177 | list_t *children, char *buffer); |
253 | * so the container can update its tree representation. | 178 | |
254 | */ | 179 | void container_update_representation(struct sway_container *container); |
255 | void container_notify_subtree_changed(struct sway_container *container); | ||
256 | 180 | ||
257 | /** | 181 | /** |
258 | * Return the height of a regular title bar. | 182 | * Return the height of a regular title bar. |
@@ -288,8 +212,7 @@ void container_floating_translate(struct sway_container *con, | |||
288 | /** | 212 | /** |
289 | * Choose an output for the floating container's new position. | 213 | * Choose an output for the floating container's new position. |
290 | */ | 214 | */ |
291 | struct sway_container *container_floating_find_output( | 215 | struct sway_output *container_floating_find_output(struct sway_container *con); |
292 | struct sway_container *con); | ||
293 | 216 | ||
294 | /** | 217 | /** |
295 | * Move a floating container to a new layout-local position. | 218 | * Move a floating container to a new layout-local position. |
@@ -302,12 +225,6 @@ void container_floating_move_to(struct sway_container *con, | |||
302 | */ | 225 | */ |
303 | void container_floating_move_to_center(struct sway_container *con); | 226 | void container_floating_move_to_center(struct sway_container *con); |
304 | 227 | ||
305 | /** | ||
306 | * Mark a container as dirty if it isn't already. Dirty containers will be | ||
307 | * included in the next transaction then unmarked as dirty. | ||
308 | */ | ||
309 | void container_set_dirty(struct sway_container *container); | ||
310 | |||
311 | bool container_has_urgent_child(struct sway_container *container); | 228 | bool container_has_urgent_child(struct sway_container *container); |
312 | 229 | ||
313 | /** | 230 | /** |
@@ -342,10 +259,18 @@ void container_remove_gaps(struct sway_container *container); | |||
342 | 259 | ||
343 | void container_add_gaps(struct sway_container *container); | 260 | void container_add_gaps(struct sway_container *container); |
344 | 261 | ||
262 | enum sway_container_layout container_parent_layout(struct sway_container *con); | ||
263 | |||
264 | enum sway_container_layout container_current_parent_layout( | ||
265 | struct sway_container *con); | ||
266 | |||
267 | list_t *container_get_siblings(const struct sway_container *container); | ||
268 | |||
345 | int container_sibling_index(const struct sway_container *child); | 269 | int container_sibling_index(const struct sway_container *child); |
346 | 270 | ||
347 | void container_handle_fullscreen_reparent(struct sway_container *con, | 271 | list_t *container_get_current_siblings(struct sway_container *container); |
348 | struct sway_container *old_parent); | 272 | |
273 | void container_handle_fullscreen_reparent(struct sway_container *con); | ||
349 | 274 | ||
350 | void container_add_child(struct sway_container *parent, | 275 | void container_add_child(struct sway_container *parent, |
351 | struct sway_container *child); | 276 | struct sway_container *child); |
@@ -353,19 +278,16 @@ void container_add_child(struct sway_container *parent, | |||
353 | void container_insert_child(struct sway_container *parent, | 278 | void container_insert_child(struct sway_container *parent, |
354 | struct sway_container *child, int i); | 279 | struct sway_container *child, int i); |
355 | 280 | ||
356 | struct sway_container *container_add_sibling(struct sway_container *parent, | 281 | void container_add_sibling(struct sway_container *parent, |
357 | struct sway_container *child); | 282 | struct sway_container *child); |
358 | 283 | ||
359 | struct sway_container *container_remove_child(struct sway_container *child); | 284 | void container_detach(struct sway_container *child); |
360 | 285 | ||
361 | struct sway_container *container_replace_child(struct sway_container *child, | 286 | void container_replace(struct sway_container *container, |
362 | struct sway_container *new_child); | 287 | struct sway_container *replacement); |
363 | 288 | ||
364 | bool sway_dir_to_wlr(enum movement_direction dir, enum wlr_direction *out); | 289 | bool sway_dir_to_wlr(enum movement_direction dir, enum wlr_direction *out); |
365 | 290 | ||
366 | enum sway_container_layout container_get_default_layout( | ||
367 | struct sway_container *con); | ||
368 | |||
369 | struct sway_container *container_split(struct sway_container *child, | 291 | struct sway_container *container_split(struct sway_container *child, |
370 | enum sway_container_layout layout); | 292 | enum sway_container_layout layout); |
371 | 293 | ||
diff --git a/include/sway/tree/node.h b/include/sway/tree/node.h new file mode 100644 index 00000000..5b8c1909 --- /dev/null +++ b/include/sway/tree/node.h | |||
@@ -0,0 +1,74 @@ | |||
1 | #ifndef _SWAY_NODE_H | ||
2 | #define _SWAY_NODE_H | ||
3 | #include <stdbool.h> | ||
4 | #include "list.h" | ||
5 | |||
6 | struct sway_root; | ||
7 | struct sway_output; | ||
8 | struct sway_workspace; | ||
9 | struct sway_container; | ||
10 | struct sway_transaction_instruction; | ||
11 | struct wlr_box; | ||
12 | |||
13 | enum sway_node_type { | ||
14 | N_ROOT, | ||
15 | N_OUTPUT, | ||
16 | N_WORKSPACE, | ||
17 | N_CONTAINER, | ||
18 | }; | ||
19 | |||
20 | struct sway_node { | ||
21 | enum sway_node_type type; | ||
22 | union { | ||
23 | struct sway_root *sway_root; | ||
24 | struct sway_output *sway_output; | ||
25 | struct sway_workspace *sway_workspace; | ||
26 | struct sway_container *sway_container; | ||
27 | }; | ||
28 | |||
29 | /** | ||
30 | * A unique ID to identify this node. | ||
31 | * Primarily used in the get_tree JSON output. | ||
32 | */ | ||
33 | size_t id; | ||
34 | |||
35 | struct sway_transaction_instruction *instruction; | ||
36 | size_t ntxnrefs; | ||
37 | bool destroying; | ||
38 | |||
39 | // If true, indicates that the container has pending state that differs from | ||
40 | // the current. | ||
41 | bool dirty; | ||
42 | |||
43 | struct { | ||
44 | struct wl_signal destroy; | ||
45 | } events; | ||
46 | }; | ||
47 | |||
48 | void node_init(struct sway_node *node, enum sway_node_type type, void *thing); | ||
49 | |||
50 | const char *node_type_to_str(enum sway_node_type type); | ||
51 | |||
52 | /** | ||
53 | * Mark a node as dirty if it isn't already. Dirty nodes will be included in the | ||
54 | * next transaction then unmarked as dirty. | ||
55 | */ | ||
56 | void node_set_dirty(struct sway_node *node); | ||
57 | |||
58 | bool node_is_view(struct sway_node *node); | ||
59 | |||
60 | char *node_get_name(struct sway_node *node); | ||
61 | |||
62 | void node_get_box(struct sway_node *node, struct wlr_box *box); | ||
63 | |||
64 | struct sway_output *node_get_output(struct sway_node *node); | ||
65 | |||
66 | enum sway_container_layout node_get_layout(struct sway_node *node); | ||
67 | |||
68 | struct sway_node *node_get_parent(struct sway_node *node); | ||
69 | |||
70 | list_t *node_get_children(struct sway_node *node); | ||
71 | |||
72 | bool node_has_ancestor(struct sway_node *node, struct sway_node *ancestor); | ||
73 | |||
74 | #endif | ||
diff --git a/include/sway/tree/root.h b/include/sway/tree/root.h index ec6516c9..a2d464f9 100644 --- a/include/sway/tree/root.h +++ b/include/sway/tree/root.h | |||
@@ -5,12 +5,14 @@ | |||
5 | #include <wlr/types/wlr_output_layout.h> | 5 | #include <wlr/types/wlr_output_layout.h> |
6 | #include <wlr/render/wlr_texture.h> | 6 | #include <wlr/render/wlr_texture.h> |
7 | #include "sway/tree/container.h" | 7 | #include "sway/tree/container.h" |
8 | #include "sway/tree/node.h" | ||
8 | #include "config.h" | 9 | #include "config.h" |
9 | #include "list.h" | 10 | #include "list.h" |
10 | 11 | ||
11 | extern struct sway_container root_container; | 12 | extern struct sway_root *root; |
12 | 13 | ||
13 | struct sway_root { | 14 | struct sway_root { |
15 | struct sway_node node; | ||
14 | struct wlr_output_layout *output_layout; | 16 | struct wlr_output_layout *output_layout; |
15 | 17 | ||
16 | struct wl_listener output_layout_change; | 18 | struct wl_listener output_layout_change; |
@@ -24,17 +26,21 @@ struct sway_root { | |||
24 | // Includes disabled outputs | 26 | // Includes disabled outputs |
25 | struct wl_list all_outputs; // sway_output::link | 27 | struct wl_list all_outputs; // sway_output::link |
26 | 28 | ||
29 | double x, y; | ||
30 | double width, height; | ||
31 | |||
32 | list_t *outputs; // struct sway_output | ||
27 | list_t *scratchpad; // struct sway_container | 33 | list_t *scratchpad; // struct sway_container |
28 | list_t *saved_workspaces; // For when there's no connected outputs | 34 | list_t *saved_workspaces; // For when there's no connected outputs |
29 | 35 | ||
30 | struct { | 36 | struct { |
31 | struct wl_signal new_container; | 37 | struct wl_signal new_node; |
32 | } events; | 38 | } events; |
33 | }; | 39 | }; |
34 | 40 | ||
35 | void root_create(void); | 41 | struct sway_root *root_create(void); |
36 | 42 | ||
37 | void root_destroy(void); | 43 | void root_destroy(struct sway_root *root); |
38 | 44 | ||
39 | /** | 45 | /** |
40 | * Move a container to the scratchpad. | 46 | * Move a container to the scratchpad. |
@@ -56,23 +62,25 @@ void root_scratchpad_show(struct sway_container *con); | |||
56 | */ | 62 | */ |
57 | void root_scratchpad_hide(struct sway_container *con); | 63 | void root_scratchpad_hide(struct sway_container *con); |
58 | 64 | ||
59 | struct sway_container *root_workspace_for_pid(pid_t pid); | 65 | struct sway_workspace *root_workspace_for_pid(pid_t pid); |
60 | 66 | ||
61 | void root_record_workspace_pid(pid_t pid); | 67 | void root_record_workspace_pid(pid_t pid); |
62 | 68 | ||
63 | void root_for_each_workspace(void (*f)(struct sway_container *con, void *data), | 69 | void root_for_each_workspace(void (*f)(struct sway_workspace *ws, void *data), |
64 | void *data); | 70 | void *data); |
65 | 71 | ||
66 | void root_for_each_container(void (*f)(struct sway_container *con, void *data), | 72 | void root_for_each_container(void (*f)(struct sway_container *con, void *data), |
67 | void *data); | 73 | void *data); |
68 | 74 | ||
69 | struct sway_container *root_find_output( | 75 | struct sway_output *root_find_output( |
70 | bool (*test)(struct sway_container *con, void *data), void *data); | 76 | bool (*test)(struct sway_output *output, void *data), void *data); |
71 | 77 | ||
72 | struct sway_container *root_find_workspace( | 78 | struct sway_workspace *root_find_workspace( |
73 | bool (*test)(struct sway_container *con, void *data), void *data); | 79 | bool (*test)(struct sway_workspace *ws, void *data), void *data); |
74 | 80 | ||
75 | struct sway_container *root_find_container( | 81 | struct sway_container *root_find_container( |
76 | bool (*test)(struct sway_container *con, void *data), void *data); | 82 | bool (*test)(struct sway_container *con, void *data), void *data); |
77 | 83 | ||
84 | void root_get_box(struct sway_root *root, struct wlr_box *box); | ||
85 | |||
78 | #endif | 86 | #endif |
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 30d3e742..439dc1bf 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h | |||
@@ -58,7 +58,7 @@ struct sway_view { | |||
58 | enum sway_view_type type; | 58 | enum sway_view_type type; |
59 | const struct sway_view_impl *impl; | 59 | const struct sway_view_impl *impl; |
60 | 60 | ||
61 | struct sway_container *swayc; // NULL for unmapped views | 61 | struct sway_container *container; // NULL if unmapped and transactions finished |
62 | struct wlr_surface *surface; // NULL for unmapped views | 62 | struct wlr_surface *surface; // NULL for unmapped views |
63 | 63 | ||
64 | // Geometry of the view itself (excludes borders) in layout coordinates | 64 | // Geometry of the view itself (excludes borders) in layout coordinates |
@@ -254,7 +254,7 @@ uint32_t view_configure(struct sway_view *view, double lx, double ly, int width, | |||
254 | int height); | 254 | int height); |
255 | 255 | ||
256 | /** | 256 | /** |
257 | * Configure the view's position and size based on the swayc's position and | 257 | * Configure the view's position and size based on the container's position and |
258 | * size, taking borders into consideration. | 258 | * size, taking borders into consideration. |
259 | */ | 259 | */ |
260 | void view_autoconfigure(struct sway_view *view); | 260 | void view_autoconfigure(struct sway_view *view); |
diff --git a/include/sway/tree/workspace.h b/include/sway/tree/workspace.h index 04325919..af9a071a 100644 --- a/include/sway/tree/workspace.h +++ b/include/sway/tree/workspace.h | |||
@@ -3,66 +3,98 @@ | |||
3 | 3 | ||
4 | #include <stdbool.h> | 4 | #include <stdbool.h> |
5 | #include "sway/tree/container.h" | 5 | #include "sway/tree/container.h" |
6 | #include "sway/tree/node.h" | ||
6 | 7 | ||
7 | struct sway_view; | 8 | struct sway_view; |
8 | 9 | ||
10 | struct sway_workspace_state { | ||
11 | struct sway_container *fullscreen; | ||
12 | double x, y; | ||
13 | int width, height; | ||
14 | enum sway_container_layout layout; | ||
15 | struct sway_output *output; | ||
16 | list_t *floating; | ||
17 | list_t *tiling; | ||
18 | |||
19 | struct sway_container *focused_inactive_child; | ||
20 | bool focused; | ||
21 | }; | ||
22 | |||
9 | struct sway_workspace { | 23 | struct sway_workspace { |
10 | struct sway_container *swayc; | 24 | struct sway_node node; |
11 | struct sway_container *fullscreen; | 25 | struct sway_container *fullscreen; |
12 | list_t *floating; // struct sway_container | 26 | |
27 | char *name; | ||
28 | char *representation; | ||
29 | |||
30 | double x, y; | ||
31 | int width, height; | ||
32 | enum sway_container_layout layout; | ||
33 | enum sway_container_layout prev_split_layout; | ||
34 | |||
35 | double current_gaps; | ||
36 | bool has_gaps; | ||
37 | double gaps_inner; | ||
38 | double gaps_outer; | ||
39 | |||
40 | struct sway_output *output; // NULL if no outputs are connected | ||
41 | list_t *floating; // struct sway_container | ||
42 | list_t *tiling; // struct sway_container | ||
13 | list_t *output_priority; | 43 | list_t *output_priority; |
14 | bool urgent; | 44 | bool urgent; |
45 | |||
46 | struct sway_workspace_state current; | ||
15 | }; | 47 | }; |
16 | 48 | ||
17 | extern char *prev_workspace_name; | 49 | extern char *prev_workspace_name; |
18 | 50 | ||
19 | struct sway_container *workspace_get_initial_output(const char *name); | 51 | struct sway_output *workspace_get_initial_output(const char *name); |
20 | 52 | ||
21 | struct sway_container *workspace_create(struct sway_container *output, | 53 | struct sway_workspace *workspace_create(struct sway_output *output, |
22 | const char *name); | 54 | const char *name); |
23 | 55 | ||
24 | void workspace_destroy(struct sway_container *workspace); | 56 | void workspace_destroy(struct sway_workspace *workspace); |
25 | 57 | ||
26 | void workspace_begin_destroy(struct sway_container *workspace); | 58 | void workspace_begin_destroy(struct sway_workspace *workspace); |
27 | 59 | ||
28 | void workspace_consider_destroy(struct sway_container *ws); | 60 | void workspace_consider_destroy(struct sway_workspace *ws); |
29 | 61 | ||
30 | char *workspace_next_name(const char *output_name); | 62 | char *workspace_next_name(const char *output_name); |
31 | 63 | ||
32 | bool workspace_switch(struct sway_container *workspace, | 64 | bool workspace_switch(struct sway_workspace *workspace, |
33 | bool no_auto_back_and_forth); | 65 | bool no_auto_back_and_forth); |
34 | 66 | ||
35 | struct sway_container *workspace_by_number(const char* name); | 67 | struct sway_workspace *workspace_by_number(const char* name); |
36 | 68 | ||
37 | struct sway_container *workspace_by_name(const char*); | 69 | struct sway_workspace *workspace_by_name(const char*); |
38 | 70 | ||
39 | struct sway_container *workspace_output_next(struct sway_container *current); | 71 | struct sway_workspace *workspace_output_next(struct sway_workspace *current); |
40 | 72 | ||
41 | struct sway_container *workspace_next(struct sway_container *current); | 73 | struct sway_workspace *workspace_next(struct sway_workspace *current); |
42 | 74 | ||
43 | struct sway_container *workspace_output_prev(struct sway_container *current); | 75 | struct sway_workspace *workspace_output_prev(struct sway_workspace *current); |
44 | 76 | ||
45 | struct sway_container *workspace_prev(struct sway_container *current); | 77 | struct sway_workspace *workspace_prev(struct sway_workspace *current); |
46 | 78 | ||
47 | bool workspace_is_visible(struct sway_container *ws); | 79 | bool workspace_is_visible(struct sway_workspace *ws); |
48 | 80 | ||
49 | bool workspace_is_empty(struct sway_container *ws); | 81 | bool workspace_is_empty(struct sway_workspace *ws); |
50 | 82 | ||
51 | void workspace_output_raise_priority(struct sway_container *workspace, | 83 | void workspace_output_raise_priority(struct sway_workspace *workspace, |
52 | struct sway_container *old_output, struct sway_container *new_output); | 84 | struct sway_output *old_output, struct sway_output *new_output); |
53 | 85 | ||
54 | void workspace_output_add_priority(struct sway_container *workspace, | 86 | void workspace_output_add_priority(struct sway_workspace *workspace, |
55 | struct sway_container *output); | 87 | struct sway_output *output); |
56 | 88 | ||
57 | struct sway_container *workspace_output_get_highest_available( | 89 | struct sway_output *workspace_output_get_highest_available( |
58 | struct sway_container *ws, struct sway_container *exclude); | 90 | struct sway_workspace *ws, struct sway_output *exclude); |
59 | 91 | ||
60 | void workspace_detect_urgent(struct sway_container *workspace); | 92 | void workspace_detect_urgent(struct sway_workspace *workspace); |
61 | 93 | ||
62 | void workspace_for_each_container(struct sway_container *ws, | 94 | void workspace_for_each_container(struct sway_workspace *ws, |
63 | void (*f)(struct sway_container *con, void *data), void *data); | 95 | void (*f)(struct sway_container *con, void *data), void *data); |
64 | 96 | ||
65 | struct sway_container *workspace_find_container(struct sway_container *ws, | 97 | struct sway_container *workspace_find_container(struct sway_workspace *ws, |
66 | bool (*test)(struct sway_container *con, void *data), void *data); | 98 | bool (*test)(struct sway_container *con, void *data), void *data); |
67 | 99 | ||
68 | /** | 100 | /** |
@@ -70,13 +102,28 @@ struct sway_container *workspace_find_container(struct sway_container *ws, | |||
70 | * The new container will be the only direct tiling child of the workspace. | 102 | * The new container will be the only direct tiling child of the workspace. |
71 | * The new container is returned. | 103 | * The new container is returned. |
72 | */ | 104 | */ |
73 | struct sway_container *workspace_wrap_children(struct sway_container *ws); | 105 | struct sway_container *workspace_wrap_children(struct sway_workspace *ws); |
74 | 106 | ||
75 | void workspace_add_floating(struct sway_container *workspace, | 107 | void workspace_detach(struct sway_workspace *workspace); |
108 | |||
109 | void workspace_add_tiling(struct sway_workspace *workspace, | ||
110 | struct sway_container *con); | ||
111 | |||
112 | void workspace_add_floating(struct sway_workspace *workspace, | ||
76 | struct sway_container *con); | 113 | struct sway_container *con); |
77 | 114 | ||
78 | void workspace_remove_gaps(struct sway_container *ws); | 115 | void workspace_insert_tiling(struct sway_workspace *workspace, |
116 | struct sway_container *con, int index); | ||
117 | |||
118 | void workspace_remove_gaps(struct sway_workspace *ws); | ||
119 | |||
120 | void workspace_add_gaps(struct sway_workspace *ws); | ||
121 | |||
122 | struct sway_container *workspace_split(struct sway_workspace *workspace, | ||
123 | enum sway_container_layout layout); | ||
124 | |||
125 | void workspace_update_representation(struct sway_workspace *ws); | ||
79 | 126 | ||
80 | void workspace_add_gaps(struct sway_container *ws); | 127 | void workspace_get_box(struct sway_workspace *workspace, struct wlr_box *box); |
81 | 128 | ||
82 | #endif | 129 | #endif |