diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/sway/desktop/transaction.h | 62 | ||||
-rw-r--r-- | include/sway/input/seat.h | 11 | ||||
-rw-r--r-- | include/sway/output.h | 2 | ||||
-rw-r--r-- | include/sway/server.h | 9 | ||||
-rw-r--r-- | include/sway/tree/arrange.h | 34 | ||||
-rw-r--r-- | include/sway/tree/container.h | 48 | ||||
-rw-r--r-- | include/sway/tree/view.h | 22 |
7 files changed, 165 insertions, 23 deletions
diff --git a/include/sway/desktop/transaction.h b/include/sway/desktop/transaction.h new file mode 100644 index 00000000..fcfed297 --- /dev/null +++ b/include/sway/desktop/transaction.h | |||
@@ -0,0 +1,62 @@ | |||
1 | #ifndef _SWAY_TRANSACTION_H | ||
2 | #define _SWAY_TRANSACTION_H | ||
3 | #include <wlr/render/wlr_texture.h> | ||
4 | #include "sway/tree/container.h" | ||
5 | |||
6 | /** | ||
7 | * Transactions enable us to perform atomic layout updates. | ||
8 | * | ||
9 | * When we want to make adjustments to the layout, we create a transaction. | ||
10 | * A transaction contains a list of affected containers and their new state. | ||
11 | * A state might contain a new size, or new border settings, or new parent/child | ||
12 | * relationships. | ||
13 | * | ||
14 | * Calling transaction_commit() makes sway notify of all the affected clients | ||
15 | * with their new sizes. We then wait for all the views to respond with their | ||
16 | * new surface sizes. When all are ready, or when a timeout has passed, we apply | ||
17 | * the updates all at the same time. | ||
18 | */ | ||
19 | |||
20 | struct sway_transaction; | ||
21 | |||
22 | /** | ||
23 | * Create a new transaction. | ||
24 | */ | ||
25 | struct sway_transaction *transaction_create(void); | ||
26 | |||
27 | /** | ||
28 | * Add a container's pending state to the transaction. | ||
29 | */ | ||
30 | void transaction_add_container(struct sway_transaction *transaction, | ||
31 | struct sway_container *container); | ||
32 | |||
33 | /** | ||
34 | * Submit a transaction to the client views for configuration. | ||
35 | */ | ||
36 | void transaction_commit(struct sway_transaction *transaction); | ||
37 | |||
38 | /** | ||
39 | * Notify the transaction system that a view is ready for the new layout. | ||
40 | * | ||
41 | * When all views in the transaction are ready, the layout will be applied. | ||
42 | */ | ||
43 | void transaction_notify_view_ready(struct sway_view *view, uint32_t serial); | ||
44 | |||
45 | /** | ||
46 | * Notify the transaction system that a view is ready for the new layout, but | ||
47 | * identifying the instruction by width and height rather than by serial. | ||
48 | * | ||
49 | * This is used by xwayland views, as they don't have serials. | ||
50 | */ | ||
51 | void transaction_notify_view_ready_by_size(struct sway_view *view, | ||
52 | int width, int height); | ||
53 | |||
54 | /** | ||
55 | * Get the texture that should be rendered for a view. | ||
56 | * | ||
57 | * In most cases this will return the normal live texture for a view, but if the | ||
58 | * view is in a transaction then it'll return a saved texture. | ||
59 | */ | ||
60 | struct wlr_texture *transaction_get_texture(struct sway_view *view); | ||
61 | |||
62 | #endif | ||
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index 1f7792ba..0e440701 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h | |||
@@ -119,6 +119,17 @@ struct sway_container *seat_get_active_child(struct sway_seat *seat, | |||
119 | struct sway_container *container); | 119 | struct sway_container *container); |
120 | 120 | ||
121 | /** | 121 | /** |
122 | * Return the immediate child of container which was most recently focused, with | ||
123 | * fallback to selecting the child in the parent's `current` (rendered) children | ||
124 | * list. | ||
125 | * | ||
126 | * This is useful for when a tabbed container and its children are destroyed but | ||
127 | * still being rendered, and we have to render an appropriate child. | ||
128 | */ | ||
129 | struct sway_container *seat_get_active_current_child(struct sway_seat *seat, | ||
130 | struct sway_container *container); | ||
131 | |||
132 | /** | ||
122 | * Iterate over the focus-inactive children of the container calling the | 133 | * Iterate over the focus-inactive children of the container calling the |
123 | * function on each. | 134 | * function on each. |
124 | */ | 135 | */ |
diff --git a/include/sway/output.h b/include/sway/output.h index 8180ce3d..19fc5e99 100644 --- a/include/sway/output.h +++ b/include/sway/output.h | |||
@@ -46,6 +46,8 @@ void output_damage_surface(struct sway_output *output, double ox, double oy, | |||
46 | void output_damage_from_view(struct sway_output *output, | 46 | void output_damage_from_view(struct sway_output *output, |
47 | struct sway_view *view); | 47 | struct sway_view *view); |
48 | 48 | ||
49 | void output_damage_box(struct sway_output *output, struct wlr_box *box); | ||
50 | |||
49 | void output_damage_whole_container(struct sway_output *output, | 51 | void output_damage_whole_container(struct sway_output *output, |
50 | struct sway_container *con); | 52 | struct sway_container *con); |
51 | 53 | ||
diff --git a/include/sway/server.h b/include/sway/server.h index b016aba8..1e1aa3cc 100644 --- a/include/sway/server.h +++ b/include/sway/server.h | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <wlr/types/wlr_xdg_shell.h> | 11 | #include <wlr/types/wlr_xdg_shell.h> |
12 | #include <wlr/render/wlr_renderer.h> | 12 | #include <wlr/render/wlr_renderer.h> |
13 | // TODO WLR: make Xwayland optional | 13 | // TODO WLR: make Xwayland optional |
14 | #include "list.h" | ||
14 | #include "sway/xwayland.h" | 15 | #include "sway/xwayland.h" |
15 | 16 | ||
16 | struct sway_server { | 17 | struct sway_server { |
@@ -40,6 +41,14 @@ struct sway_server { | |||
40 | struct sway_xwayland xwayland; | 41 | struct sway_xwayland xwayland; |
41 | struct wl_listener xwayland_surface; | 42 | struct wl_listener xwayland_surface; |
42 | struct wl_listener xwayland_ready; | 43 | struct wl_listener xwayland_ready; |
44 | |||
45 | bool debug_txn_timings; | ||
46 | |||
47 | list_t *transactions; | ||
48 | |||
49 | // When a view is being destroyed and is waiting for a transaction to | ||
50 | // complete it will be stored here. | ||
51 | list_t *destroying_containers; | ||
43 | }; | 52 | }; |
44 | 53 | ||
45 | struct sway_server server; | 54 | struct sway_server server; |
diff --git a/include/sway/tree/arrange.h b/include/sway/tree/arrange.h index a14bc5dc..58235642 100644 --- a/include/sway/tree/arrange.h +++ b/include/sway/tree/arrange.h | |||
@@ -1,5 +1,6 @@ | |||
1 | #ifndef _SWAY_ARRANGE_H | 1 | #ifndef _SWAY_ARRANGE_H |
2 | #define _SWAY_ARRANGE_H | 2 | #define _SWAY_ARRANGE_H |
3 | #include "sway/desktop/transaction.h" | ||
3 | 4 | ||
4 | struct sway_container; | 5 | struct sway_container; |
5 | 6 | ||
@@ -9,16 +10,27 @@ void remove_gaps(struct sway_container *c); | |||
9 | // Add gaps around container | 10 | // Add gaps around container |
10 | void add_gaps(struct sway_container *c); | 11 | void add_gaps(struct sway_container *c); |
11 | 12 | ||
12 | // Determine the root container's geometry, then iterate to everything below | 13 | /** |
13 | void arrange_root(void); | 14 | * Arrange layout for all the children of the given container, and add them to |
14 | 15 | * the given transaction. | |
15 | // Determine the output's geometry, then iterate to everything below | 16 | * |
16 | void arrange_output(struct sway_container *output); | 17 | * Use this function if you need to arrange multiple sections of the tree in one |
17 | 18 | * transaction. | |
18 | // Determine the workspace's geometry, then iterate to everything below | 19 | * |
19 | void arrange_workspace(struct sway_container *workspace); | 20 | * You must set the desired state of the container before calling |
20 | 21 | * arrange_windows, then don't change any state-tracked properties in the | |
21 | // Arrange layout for all the children of the given workspace/container | 22 | * container until you've called transaction_commit. |
22 | void arrange_children_of(struct sway_container *parent); | 23 | */ |
24 | void arrange_windows(struct sway_container *container, | ||
25 | struct sway_transaction *transaction); | ||
26 | |||
27 | /** | ||
28 | * Arrange layout for the given container and commit the transaction. | ||
29 | * | ||
30 | * This function is a wrapper around arrange_windows, and handles creating and | ||
31 | * committing the transaction for you. Use this function if you're only doing | ||
32 | * one arrange operation. | ||
33 | */ | ||
34 | void arrange_and_commit(struct sway_container *container); | ||
23 | 35 | ||
24 | #endif | 36 | #endif |
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index b3406bbe..728daa84 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h | |||
@@ -54,6 +54,37 @@ struct sway_output; | |||
54 | struct sway_workspace; | 54 | struct sway_workspace; |
55 | struct sway_view; | 55 | struct sway_view; |
56 | 56 | ||
57 | struct sway_container_state { | ||
58 | // Container/swayc properties | ||
59 | enum sway_container_layout layout; | ||
60 | double swayc_x, swayc_y; | ||
61 | double swayc_width, swayc_height; | ||
62 | |||
63 | bool has_gaps; | ||
64 | double current_gaps; | ||
65 | double gaps_inner; | ||
66 | double gaps_outer; | ||
67 | |||
68 | struct sway_container *parent; | ||
69 | list_t *children; | ||
70 | |||
71 | // View properties | ||
72 | double view_x, view_y; | ||
73 | double view_width, view_height; | ||
74 | bool is_fullscreen; | ||
75 | |||
76 | enum sway_container_border border; | ||
77 | int border_thickness; | ||
78 | bool border_top; | ||
79 | bool border_bottom; | ||
80 | bool border_left; | ||
81 | bool border_right; | ||
82 | |||
83 | // Workspace properties | ||
84 | struct sway_view *ws_fullscreen; | ||
85 | struct sway_container *ws_floating; | ||
86 | }; | ||
87 | |||
57 | struct sway_container { | 88 | struct sway_container { |
58 | union { | 89 | union { |
59 | // TODO: Encapsulate state for other node types as well like C_CONTAINER | 90 | // TODO: Encapsulate state for other node types as well like C_CONTAINER |
@@ -69,6 +100,10 @@ struct sway_container { | |||
69 | */ | 100 | */ |
70 | size_t id; | 101 | size_t id; |
71 | 102 | ||
103 | // The pending state is the main container properties, and the current state is in the below struct. | ||
104 | // This means most places of the code can refer to the main variables (pending state) and it'll just work. | ||
105 | struct sway_container_state current; | ||
106 | |||
72 | char *name; // The view's title (unformatted) | 107 | char *name; // The view's title (unformatted) |
73 | char *formatted_title; // The title displayed in the title bar | 108 | char *formatted_title; // The title displayed in the title bar |
74 | 109 | ||
@@ -97,8 +132,6 @@ struct sway_container { | |||
97 | 132 | ||
98 | struct sway_container *parent; | 133 | struct sway_container *parent; |
99 | 134 | ||
100 | list_t *marks; // list of char* | ||
101 | |||
102 | float alpha; | 135 | float alpha; |
103 | 136 | ||
104 | struct wlr_texture *title_focused; | 137 | struct wlr_texture *title_focused; |
@@ -107,6 +140,10 @@ struct sway_container { | |||
107 | struct wlr_texture *title_urgent; | 140 | struct wlr_texture *title_urgent; |
108 | size_t title_height; | 141 | size_t title_height; |
109 | 142 | ||
143 | list_t *instructions; // struct sway_transaction_instruction * | ||
144 | |||
145 | bool destroying; | ||
146 | |||
110 | struct { | 147 | struct { |
111 | struct wl_signal destroy; | 148 | struct wl_signal destroy; |
112 | // Raised after the tree updates, but before arrange_windows | 149 | // Raised after the tree updates, but before arrange_windows |
@@ -150,6 +187,8 @@ struct sway_container *workspace_create(struct sway_container *output, | |||
150 | struct sway_container *container_view_create( | 187 | struct sway_container *container_view_create( |
151 | struct sway_container *sibling, struct sway_view *sway_view); | 188 | struct sway_container *sibling, struct sway_view *sway_view); |
152 | 189 | ||
190 | void container_free(struct sway_container *cont); | ||
191 | |||
153 | struct sway_container *container_destroy(struct sway_container *container); | 192 | struct sway_container *container_destroy(struct sway_container *container); |
154 | 193 | ||
155 | struct sway_container *container_close(struct sway_container *container); | 194 | struct sway_container *container_close(struct sway_container *container); |
@@ -253,4 +292,9 @@ void container_set_geometry_from_floating_view(struct sway_container *con); | |||
253 | */ | 292 | */ |
254 | bool container_is_floating(struct sway_container *container); | 293 | bool container_is_floating(struct sway_container *container); |
255 | 294 | ||
295 | /** | ||
296 | * Get a container's box in layout coordinates. | ||
297 | */ | ||
298 | void container_get_box(struct sway_container *container, struct wlr_box *box); | ||
299 | |||
256 | #endif | 300 | #endif |
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 3df38e2d..1bcb0582 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h | |||
@@ -29,8 +29,8 @@ struct sway_view_impl { | |||
29 | const char *(*get_string_prop)(struct sway_view *view, | 29 | const char *(*get_string_prop)(struct sway_view *view, |
30 | enum sway_view_prop prop); | 30 | enum sway_view_prop prop); |
31 | uint32_t (*get_int_prop)(struct sway_view *view, enum sway_view_prop prop); | 31 | uint32_t (*get_int_prop)(struct sway_view *view, enum sway_view_prop prop); |
32 | void (*configure)(struct sway_view *view, double lx, double ly, int width, | 32 | uint32_t (*configure)(struct sway_view *view, double lx, double ly, |
33 | int height); | 33 | int width, int height); |
34 | void (*set_activated)(struct sway_view *view, bool activated); | 34 | void (*set_activated)(struct sway_view *view, bool activated); |
35 | void (*set_fullscreen)(struct sway_view *view, bool fullscreen); | 35 | void (*set_fullscreen)(struct sway_view *view, bool fullscreen); |
36 | bool (*wants_floating)(struct sway_view *view); | 36 | bool (*wants_floating)(struct sway_view *view); |
@@ -68,6 +68,8 @@ struct sway_view { | |||
68 | bool border_left; | 68 | bool border_left; |
69 | bool border_right; | 69 | bool border_right; |
70 | 70 | ||
71 | bool destroying; | ||
72 | |||
71 | list_t *executed_criteria; // struct criteria * | 73 | list_t *executed_criteria; // struct criteria * |
72 | list_t *marks; // char * | 74 | list_t *marks; // char * |
73 | 75 | ||
@@ -103,8 +105,6 @@ struct sway_xdg_shell_v6_view { | |||
103 | struct wl_listener map; | 105 | struct wl_listener map; |
104 | struct wl_listener unmap; | 106 | struct wl_listener unmap; |
105 | struct wl_listener destroy; | 107 | struct wl_listener destroy; |
106 | |||
107 | int pending_width, pending_height; | ||
108 | }; | 108 | }; |
109 | 109 | ||
110 | struct sway_xdg_shell_view { | 110 | struct sway_xdg_shell_view { |
@@ -119,8 +119,6 @@ struct sway_xdg_shell_view { | |||
119 | struct wl_listener map; | 119 | struct wl_listener map; |
120 | struct wl_listener unmap; | 120 | struct wl_listener unmap; |
121 | struct wl_listener destroy; | 121 | struct wl_listener destroy; |
122 | |||
123 | int pending_width, pending_height; | ||
124 | }; | 122 | }; |
125 | 123 | ||
126 | struct sway_xwayland_view { | 124 | struct sway_xwayland_view { |
@@ -138,9 +136,6 @@ struct sway_xwayland_view { | |||
138 | struct wl_listener map; | 136 | struct wl_listener map; |
139 | struct wl_listener unmap; | 137 | struct wl_listener unmap; |
140 | struct wl_listener destroy; | 138 | struct wl_listener destroy; |
141 | |||
142 | int pending_lx, pending_ly; | ||
143 | int pending_width, pending_height; | ||
144 | }; | 139 | }; |
145 | 140 | ||
146 | struct sway_xwayland_unmanaged { | 141 | struct sway_xwayland_unmanaged { |
@@ -212,10 +207,15 @@ uint32_t view_get_window_type(struct sway_view *view); | |||
212 | 207 | ||
213 | const char *view_get_shell(struct sway_view *view); | 208 | const char *view_get_shell(struct sway_view *view); |
214 | 209 | ||
215 | void view_configure(struct sway_view *view, double ox, double oy, int width, | 210 | uint32_t view_configure(struct sway_view *view, double lx, double ly, int width, |
216 | int height); | 211 | int height); |
217 | 212 | ||
218 | /** | 213 | /** |
214 | * Center the view in its workspace and build the swayc decorations around it. | ||
215 | */ | ||
216 | void view_init_floating(struct sway_view *view); | ||
217 | |||
218 | /** | ||
219 | * Configure the view's position and size based on the swayc's position and | 219 | * Configure the view's position and size based on the swayc's position and |
220 | * size, taking borders into consideration. | 220 | * size, taking borders into consideration. |
221 | */ | 221 | */ |
@@ -239,6 +239,8 @@ void view_for_each_surface(struct sway_view *view, | |||
239 | void view_init(struct sway_view *view, enum sway_view_type type, | 239 | void view_init(struct sway_view *view, enum sway_view_type type, |
240 | const struct sway_view_impl *impl); | 240 | const struct sway_view_impl *impl); |
241 | 241 | ||
242 | void view_free(struct sway_view *view); | ||
243 | |||
242 | void view_destroy(struct sway_view *view); | 244 | void view_destroy(struct sway_view *view); |
243 | 245 | ||
244 | void view_map(struct sway_view *view, struct wlr_surface *wlr_surface); | 246 | void view_map(struct sway_view *view, struct wlr_surface *wlr_surface); |