summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-06-30 06:27:39 -0700
committerLibravatar GitHub <noreply@github.com>2018-06-30 06:27:39 -0700
commitd8c61c976372eedf271f505ffd82c461b6503f6f (patch)
tree323739dc80680dd774acfdcf43eb76cfe93aa64c /include
parentMerge pull request #2179 from atomnuker/master (diff)
parentMerge remote-tracking branch 'upstream/master' into atomic (diff)
downloadsway-d8c61c976372eedf271f505ffd82c461b6503f6f.tar.gz
sway-d8c61c976372eedf271f505ffd82c461b6503f6f.tar.zst
sway-d8c61c976372eedf271f505ffd82c461b6503f6f.zip
Merge pull request #2072 from RyanDwyer/atomic
Atomic layout updates
Diffstat (limited to 'include')
-rw-r--r--include/sway/desktop/transaction.h67
-rw-r--r--include/sway/input/seat.h11
-rw-r--r--include/sway/output.h2
-rw-r--r--include/sway/server.h9
-rw-r--r--include/sway/tree/arrange.h34
-rw-r--r--include/sway/tree/container.h48
-rw-r--r--include/sway/tree/view.h22
7 files changed, 170 insertions, 23 deletions
diff --git a/include/sway/desktop/transaction.h b/include/sway/desktop/transaction.h
new file mode 100644
index 00000000..7ab80eb8
--- /dev/null
+++ b/include/sway/desktop/transaction.h
@@ -0,0 +1,67 @@
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
20struct sway_transaction;
21
22/**
23 * Create a new transaction.
24 */
25struct sway_transaction *transaction_create(void);
26
27/**
28 * Add a container's pending state to the transaction.
29 */
30void 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 */
36void 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 */
43void 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 */
51void transaction_notify_view_ready_by_size(struct sway_view *view,
52 int width, int height);
53
54/**
55 * Get the saved texture that should be rendered for a view.
56 *
57 * The addresses pointed at by the width and height pointers will be populated
58 * with the surface's dimensions, which may be different to the texture's
59 * dimensions if output scaling is used.
60 *
61 * This function should only be called if it is known that the view has
62 * instructions.
63 */
64struct wlr_texture *transaction_get_saved_texture(struct sway_view *view,
65 int *width, int *height);
66
67#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 */
129struct 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,
46void output_damage_from_view(struct sway_output *output, 46void output_damage_from_view(struct sway_output *output,
47 struct sway_view *view); 47 struct sway_view *view);
48 48
49void output_damage_box(struct sway_output *output, struct wlr_box *box);
50
49void output_damage_whole_container(struct sway_output *output, 51void 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
16struct sway_server { 17struct 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
45struct sway_server server; 54struct 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
4struct sway_container; 5struct 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
10void add_gaps(struct sway_container *c); 11void add_gaps(struct sway_container *c);
11 12
12// Determine the root container's geometry, then iterate to everything below 13/**
13void 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 *
16void 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 *
19void 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.
22void arrange_children_of(struct sway_container *parent); 23 */
24void 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 */
34void 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;
54struct sway_workspace; 54struct sway_workspace;
55struct sway_view; 55struct sway_view;
56 56
57struct 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
57struct sway_container { 88struct 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,
150struct sway_container *container_view_create( 187struct 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
190void container_free(struct sway_container *cont);
191
153struct sway_container *container_destroy(struct sway_container *container); 192struct sway_container *container_destroy(struct sway_container *container);
154 193
155struct sway_container *container_close(struct sway_container *container); 194struct 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 */
254bool container_is_floating(struct sway_container *container); 293bool container_is_floating(struct sway_container *container);
255 294
295/**
296 * Get a container's box in layout coordinates.
297 */
298void 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 91865232..b99044d3 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_tiled)(struct sway_view *view, bool tiled); 35 void (*set_tiled)(struct sway_view *view, bool tiled);
36 void (*set_fullscreen)(struct sway_view *view, bool fullscreen); 36 void (*set_fullscreen)(struct sway_view *view, bool fullscreen);
@@ -69,6 +69,8 @@ struct sway_view {
69 bool border_left; 69 bool border_left;
70 bool border_right; 70 bool border_right;
71 71
72 bool destroying;
73
72 list_t *executed_criteria; // struct criteria * 74 list_t *executed_criteria; // struct criteria *
73 list_t *marks; // char * 75 list_t *marks; // char *
74 76
@@ -104,8 +106,6 @@ struct sway_xdg_shell_v6_view {
104 struct wl_listener map; 106 struct wl_listener map;
105 struct wl_listener unmap; 107 struct wl_listener unmap;
106 struct wl_listener destroy; 108 struct wl_listener destroy;
107
108 int pending_width, pending_height;
109}; 109};
110 110
111struct sway_xdg_shell_view { 111struct sway_xdg_shell_view {
@@ -120,8 +120,6 @@ struct sway_xdg_shell_view {
120 struct wl_listener map; 120 struct wl_listener map;
121 struct wl_listener unmap; 121 struct wl_listener unmap;
122 struct wl_listener destroy; 122 struct wl_listener destroy;
123
124 int pending_width, pending_height;
125}; 123};
126 124
127struct sway_xwayland_view { 125struct sway_xwayland_view {
@@ -139,9 +137,6 @@ struct sway_xwayland_view {
139 struct wl_listener map; 137 struct wl_listener map;
140 struct wl_listener unmap; 138 struct wl_listener unmap;
141 struct wl_listener destroy; 139 struct wl_listener destroy;
142
143 int pending_lx, pending_ly;
144 int pending_width, pending_height;
145}; 140};
146 141
147struct sway_xwayland_unmanaged { 142struct sway_xwayland_unmanaged {
@@ -213,10 +208,15 @@ uint32_t view_get_window_type(struct sway_view *view);
213 208
214const char *view_get_shell(struct sway_view *view); 209const char *view_get_shell(struct sway_view *view);
215 210
216void view_configure(struct sway_view *view, double ox, double oy, int width, 211uint32_t view_configure(struct sway_view *view, double lx, double ly, int width,
217 int height); 212 int height);
218 213
219/** 214/**
215 * Center the view in its workspace and build the swayc decorations around it.
216 */
217void view_init_floating(struct sway_view *view);
218
219/**
220 * Configure the view's position and size based on the swayc's position and 220 * Configure the view's position and size based on the swayc's position and
221 * size, taking borders into consideration. 221 * size, taking borders into consideration.
222 */ 222 */
@@ -242,6 +242,8 @@ void view_for_each_surface(struct sway_view *view,
242void view_init(struct sway_view *view, enum sway_view_type type, 242void view_init(struct sway_view *view, enum sway_view_type type,
243 const struct sway_view_impl *impl); 243 const struct sway_view_impl *impl);
244 244
245void view_free(struct sway_view *view);
246
245void view_destroy(struct sway_view *view); 247void view_destroy(struct sway_view *view);
246 248
247void view_map(struct sway_view *view, struct wlr_surface *wlr_surface); 249void view_map(struct sway_view *view, struct wlr_surface *wlr_surface);