diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-06-03 16:35:06 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-06-09 10:08:43 +1000 |
commit | 59c94887018bdfa578c4371c4275061ca6e71b3e (patch) | |
tree | 62bdaa6ac4777d1fcb292013bddd2043dad7765a /include | |
parent | Merge pull request #2115 from RedSoxFan/restore-workspaces (diff) | |
download | sway-59c94887018bdfa578c4371c4275061ca6e71b3e.tar.gz sway-59c94887018bdfa578c4371c4275061ca6e71b3e.tar.zst sway-59c94887018bdfa578c4371c4275061ca6e71b3e.zip |
WIP: Atomic layout updates ground work
Diffstat (limited to 'include')
-rw-r--r-- | include/sway/desktop/transaction.h | 56 | ||||
-rw-r--r-- | include/sway/output.h | 2 | ||||
-rw-r--r-- | include/sway/tree/arrange.h | 33 | ||||
-rw-r--r-- | include/sway/tree/container.h | 29 | ||||
-rw-r--r-- | include/sway/tree/view.h | 19 |
5 files changed, 120 insertions, 19 deletions
diff --git a/include/sway/desktop/transaction.h b/include/sway/desktop/transaction.h new file mode 100644 index 00000000..575d28c8 --- /dev/null +++ b/include/sway/desktop/transaction.h | |||
@@ -0,0 +1,56 @@ | |||
1 | #ifndef _SWAY_TRANSACTION_H | ||
2 | #define _SWAY_TRANSACTION_H | ||
3 | #include "sway/tree/container.h" | ||
4 | |||
5 | /** | ||
6 | * Transactions enable us to perform atomic layout updates. | ||
7 | * | ||
8 | * When we want to make adjustments to the layout, we create a transaction. | ||
9 | * A transaction contains a list of affected containers and their new state. | ||
10 | * A state might contain a new size, or new border settings, or new parent/child | ||
11 | * relationships. | ||
12 | * | ||
13 | * Calling transaction_commit() makes sway notify of all the affected clients | ||
14 | * with their new sizes. We then wait for all the views to respond with their | ||
15 | * new surface sizes. When all are ready, or when a timeout has passed, we apply | ||
16 | * the updates all at the same time. | ||
17 | */ | ||
18 | |||
19 | struct sway_transaction { | ||
20 | struct wl_event_source *timer; | ||
21 | list_t *instructions; // struct sway_transaction_instruction * | ||
22 | list_t *damage; // struct wlr_box * | ||
23 | size_t num_waiting; | ||
24 | }; | ||
25 | |||
26 | /** | ||
27 | * Create a new transaction. | ||
28 | */ | ||
29 | struct sway_transaction *transaction_create(void); | ||
30 | |||
31 | /** | ||
32 | * Add a container's pending state to the transaction. | ||
33 | */ | ||
34 | void transaction_add_container(struct sway_transaction *transaction, | ||
35 | struct sway_container *container); | ||
36 | |||
37 | /** | ||
38 | * Add a box to be damaged when the transaction is applied. | ||
39 | * The box should be in layout coordinates. | ||
40 | */ | ||
41 | void transaction_add_damage(struct sway_transaction *transaction, | ||
42 | struct wlr_box *box); | ||
43 | |||
44 | /** | ||
45 | * Submit a transaction to the client views for configuration. | ||
46 | */ | ||
47 | void transaction_commit(struct sway_transaction *transaction); | ||
48 | |||
49 | /** | ||
50 | * Notify the transaction system that a view is ready for the new layout. | ||
51 | * | ||
52 | * When all views in the transaction are ready, the layout will be applied. | ||
53 | */ | ||
54 | void transaction_notify_view_ready(struct sway_view *view, uint32_t serial); | ||
55 | |||
56 | #endif | ||
diff --git a/include/sway/output.h b/include/sway/output.h index 70f746dc..e6ca0d02 100644 --- a/include/sway/output.h +++ b/include/sway/output.h | |||
@@ -42,6 +42,8 @@ void output_damage_surface(struct sway_output *output, double ox, double oy, | |||
42 | void output_damage_from_view(struct sway_output *output, | 42 | void output_damage_from_view(struct sway_output *output, |
43 | struct sway_view *view); | 43 | struct sway_view *view); |
44 | 44 | ||
45 | void output_damage_box(struct sway_output *output, struct wlr_box *box); | ||
46 | |||
45 | void output_damage_whole_container(struct sway_output *output, | 47 | void output_damage_whole_container(struct sway_output *output, |
46 | struct sway_container *con); | 48 | struct sway_container *con); |
47 | 49 | ||
diff --git a/include/sway/tree/arrange.h b/include/sway/tree/arrange.h index ce95cfe9..23cd66dc 100644 --- a/include/sway/tree/arrange.h +++ b/include/sway/tree/arrange.h | |||
@@ -1,18 +1,33 @@ | |||
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 | ||
6 | // Determine the root container's geometry, then iterate to everything below | 7 | /** |
7 | void arrange_root(void); | 8 | * Arrange layout for all the children of the given container, and add them to |
8 | 9 | * the given transaction. | |
9 | // Determine the output's geometry, then iterate to everything below | 10 | * |
10 | void arrange_output(struct sway_container *output); | 11 | * Use this function if you need to arrange multiple sections of the tree in one |
12 | * transaction. | ||
13 | */ | ||
14 | void arrange_windows(struct sway_container *container, | ||
15 | struct sway_transaction *transaction); | ||
11 | 16 | ||
12 | // Determine the workspace's geometry, then iterate to everything below | 17 | /** |
13 | void arrange_workspace(struct sway_container *workspace); | 18 | * Arrange layout for the given container and commit the transaction. |
19 | * | ||
20 | * This function is a wrapper around arrange_windows, and handles creating and | ||
21 | * committing the transaction for you. Use this function if you're only doing | ||
22 | * one arrange operation. | ||
23 | */ | ||
24 | void arrange_and_commit(struct sway_container *container); | ||
14 | 25 | ||
15 | // Arrange layout for all the children of the given workspace/container | 26 | // These functions are temporary and are only here to make everything compile. |
16 | void arrange_children_of(struct sway_container *parent); | 27 | // They are wrappers around arrange_and_commit. |
28 | void arrange_root(void); | ||
29 | void arrange_output(struct sway_container *container); | ||
30 | void arrange_workspace(struct sway_container *container); | ||
31 | void arrange_children_of(struct sway_container *container); | ||
17 | 32 | ||
18 | #endif | 33 | #endif |
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index 7ed6aab1..dd5bd47c 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h | |||
@@ -54,6 +54,28 @@ 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 | //struct sway_container *parent; | ||
64 | //list_t *children; | ||
65 | |||
66 | // View properties | ||
67 | double view_x, view_y; | ||
68 | double view_width, view_height; | ||
69 | bool is_fullscreen; | ||
70 | |||
71 | enum sway_container_border border; | ||
72 | int border_thickness; | ||
73 | bool border_top; | ||
74 | bool border_bottom; | ||
75 | bool border_left; | ||
76 | bool border_right; | ||
77 | }; | ||
78 | |||
57 | struct sway_container { | 79 | struct sway_container { |
58 | union { | 80 | union { |
59 | // TODO: Encapsulate state for other node types as well like C_CONTAINER | 81 | // TODO: Encapsulate state for other node types as well like C_CONTAINER |
@@ -69,6 +91,8 @@ struct sway_container { | |||
69 | */ | 91 | */ |
70 | size_t id; | 92 | size_t id; |
71 | 93 | ||
94 | struct sway_container_state pending; | ||
95 | |||
72 | char *name; // The view's title (unformatted) | 96 | char *name; // The view's title (unformatted) |
73 | char *formatted_title; // The title displayed in the title bar | 97 | char *formatted_title; // The title displayed in the title bar |
74 | 98 | ||
@@ -246,4 +270,9 @@ void container_set_geometry_from_floating_view(struct sway_container *con); | |||
246 | */ | 270 | */ |
247 | bool container_is_floating(struct sway_container *container); | 271 | bool container_is_floating(struct sway_container *container); |
248 | 272 | ||
273 | /** | ||
274 | * Get a container's box in layout coordinates. | ||
275 | */ | ||
276 | struct wlr_box *container_get_box(struct sway_container *container); | ||
277 | |||
249 | #endif | 278 | #endif |
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 3df38e2d..f47db567 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); |
@@ -70,6 +70,12 @@ struct sway_view { | |||
70 | 70 | ||
71 | list_t *executed_criteria; // struct criteria * | 71 | list_t *executed_criteria; // struct criteria * |
72 | list_t *marks; // char * | 72 | list_t *marks; // char * |
73 | list_t *instructions; // struct sway_transaction_instruction * | ||
74 | |||
75 | // If saved_texture is set, the main surface of the view will render this | ||
76 | // texture instead of its own. This is used while waiting for transactions | ||
77 | // to complete. | ||
78 | struct wlr_texture *saved_texture; | ||
73 | 79 | ||
74 | struct wlr_texture *marks_focused; | 80 | struct wlr_texture *marks_focused; |
75 | struct wlr_texture *marks_focused_inactive; | 81 | struct wlr_texture *marks_focused_inactive; |
@@ -103,8 +109,6 @@ struct sway_xdg_shell_v6_view { | |||
103 | struct wl_listener map; | 109 | struct wl_listener map; |
104 | struct wl_listener unmap; | 110 | struct wl_listener unmap; |
105 | struct wl_listener destroy; | 111 | struct wl_listener destroy; |
106 | |||
107 | int pending_width, pending_height; | ||
108 | }; | 112 | }; |
109 | 113 | ||
110 | struct sway_xdg_shell_view { | 114 | struct sway_xdg_shell_view { |
@@ -119,8 +123,6 @@ struct sway_xdg_shell_view { | |||
119 | struct wl_listener map; | 123 | struct wl_listener map; |
120 | struct wl_listener unmap; | 124 | struct wl_listener unmap; |
121 | struct wl_listener destroy; | 125 | struct wl_listener destroy; |
122 | |||
123 | int pending_width, pending_height; | ||
124 | }; | 126 | }; |
125 | 127 | ||
126 | struct sway_xwayland_view { | 128 | struct sway_xwayland_view { |
@@ -138,9 +140,6 @@ struct sway_xwayland_view { | |||
138 | struct wl_listener map; | 140 | struct wl_listener map; |
139 | struct wl_listener unmap; | 141 | struct wl_listener unmap; |
140 | struct wl_listener destroy; | 142 | struct wl_listener destroy; |
141 | |||
142 | int pending_lx, pending_ly; | ||
143 | int pending_width, pending_height; | ||
144 | }; | 143 | }; |
145 | 144 | ||
146 | struct sway_xwayland_unmanaged { | 145 | struct sway_xwayland_unmanaged { |
@@ -212,7 +211,7 @@ uint32_t view_get_window_type(struct sway_view *view); | |||
212 | 211 | ||
213 | const char *view_get_shell(struct sway_view *view); | 212 | const char *view_get_shell(struct sway_view *view); |
214 | 213 | ||
215 | void view_configure(struct sway_view *view, double ox, double oy, int width, | 214 | uint32_t view_configure(struct sway_view *view, double lx, double ly, int width, |
216 | int height); | 215 | int height); |
217 | 216 | ||
218 | /** | 217 | /** |