diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/sway/desktop/transaction.h | 51 | ||||
-rw-r--r-- | include/sway/output.h | 2 | ||||
-rw-r--r-- | include/sway/tree/arrange.h | 30 | ||||
-rw-r--r-- | include/sway/tree/container.h | 36 | ||||
-rw-r--r-- | include/sway/tree/view.h | 24 |
5 files changed, 122 insertions, 21 deletions
diff --git a/include/sway/desktop/transaction.h b/include/sway/desktop/transaction.h new file mode 100644 index 00000000..5aff28e9 --- /dev/null +++ b/include/sway/desktop/transaction.h | |||
@@ -0,0 +1,51 @@ | |||
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 | |||
21 | /** | ||
22 | * Create a new transaction. | ||
23 | */ | ||
24 | struct sway_transaction *transaction_create(void); | ||
25 | |||
26 | /** | ||
27 | * Add a container's pending state to the transaction. | ||
28 | */ | ||
29 | void transaction_add_container(struct sway_transaction *transaction, | ||
30 | struct sway_container *container); | ||
31 | |||
32 | /** | ||
33 | * Add a box to be damaged when the transaction is applied. | ||
34 | * The box should be in layout coordinates. | ||
35 | */ | ||
36 | void transaction_add_damage(struct sway_transaction *transaction, | ||
37 | struct wlr_box *box); | ||
38 | |||
39 | /** | ||
40 | * Submit a transaction to the client views for configuration. | ||
41 | */ | ||
42 | void transaction_commit(struct sway_transaction *transaction); | ||
43 | |||
44 | /** | ||
45 | * Notify the transaction system that a view is ready for the new layout. | ||
46 | * | ||
47 | * When all views in the transaction are ready, the layout will be applied. | ||
48 | */ | ||
49 | void transaction_notify_view_ready(struct sway_view *view, uint32_t serial); | ||
50 | |||
51 | #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 a14bc5dc..6c8c0dba 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,23 @@ 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 | void arrange_windows(struct sway_container *container, |
20 | 21 | struct sway_transaction *transaction); | |
21 | // Arrange layout for all the children of the given workspace/container | 22 | |
22 | void arrange_children_of(struct sway_container *parent); | 23 | /** |
24 | * Arrange layout for the given container and commit the transaction. | ||
25 | * | ||
26 | * This function is a wrapper around arrange_windows, and handles creating and | ||
27 | * committing the transaction for you. Use this function if you're only doing | ||
28 | * one arrange operation. | ||
29 | */ | ||
30 | void arrange_and_commit(struct sway_container *container); | ||
23 | 31 | ||
24 | #endif | 32 | #endif |
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index b3406bbe..f4e978ea 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h | |||
@@ -54,6 +54,33 @@ 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 | |||
57 | struct sway_container { | 84 | struct sway_container { |
58 | union { | 85 | union { |
59 | // TODO: Encapsulate state for other node types as well like C_CONTAINER | 86 | // TODO: Encapsulate state for other node types as well like C_CONTAINER |
@@ -69,6 +96,10 @@ struct sway_container { | |||
69 | */ | 96 | */ |
70 | size_t id; | 97 | size_t id; |
71 | 98 | ||
99 | // The pending state is the main container properties, and the current state is in the below struct. | ||
100 | // This means most places of the code can refer to the main variables (pending state) and it'll just work. | ||
101 | struct sway_container_state current; | ||
102 | |||
72 | char *name; // The view's title (unformatted) | 103 | char *name; // The view's title (unformatted) |
73 | char *formatted_title; // The title displayed in the title bar | 104 | char *formatted_title; // The title displayed in the title bar |
74 | 105 | ||
@@ -253,4 +284,9 @@ void container_set_geometry_from_floating_view(struct sway_container *con); | |||
253 | */ | 284 | */ |
254 | bool container_is_floating(struct sway_container *container); | 285 | bool container_is_floating(struct sway_container *container); |
255 | 286 | ||
287 | /** | ||
288 | * Get a container's box in layout coordinates. | ||
289 | */ | ||
290 | struct wlr_box *container_get_box(struct sway_container *container); | ||
291 | |||
256 | #endif | 292 | #endif |
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 3df38e2d..d0093db5 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,10 +211,15 @@ 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 | /** |
218 | * Center the view in its workspace and build the swayc decorations around it. | ||
219 | */ | ||
220 | void view_init_floating(struct sway_view *view); | ||
221 | |||
222 | /** | ||
219 | * Configure the view's position and size based on the swayc's position and | 223 | * Configure the view's position and size based on the swayc's position and |
220 | * size, taking borders into consideration. | 224 | * size, taking borders into consideration. |
221 | */ | 225 | */ |