aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop/output.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-06-03 16:35:06 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-06-09 10:08:43 +1000
commit59c94887018bdfa578c4371c4275061ca6e71b3e (patch)
tree62bdaa6ac4777d1fcb292013bddd2043dad7765a /sway/desktop/output.c
parentMerge pull request #2115 from RedSoxFan/restore-workspaces (diff)
downloadsway-59c94887018bdfa578c4371c4275061ca6e71b3e.tar.gz
sway-59c94887018bdfa578c4371c4275061ca6e71b3e.tar.zst
sway-59c94887018bdfa578c4371c4275061ca6e71b3e.zip
WIP: Atomic layout updates ground work
Diffstat (limited to 'sway/desktop/output.c')
-rw-r--r--sway/desktop/output.c70
1 files changed, 63 insertions, 7 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index 3142bdb4..c5d445a6 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -69,6 +69,7 @@ struct render_data {
69 struct root_geometry root_geo; 69 struct root_geometry root_geo;
70 struct sway_output *output; 70 struct sway_output *output;
71 pixman_region32_t *damage; 71 pixman_region32_t *damage;
72 struct sway_view *view;
72 float alpha; 73 float alpha;
73}; 74};
74 75
@@ -108,6 +109,38 @@ static bool get_surface_box(struct root_geometry *geo,
108 return wlr_box_intersection(&output_box, &rotated_box, &intersection); 109 return wlr_box_intersection(&output_box, &rotated_box, &intersection);
109} 110}
110 111
112static bool get_view_box(struct root_geometry *geo,
113 struct sway_output *output, struct sway_view *view, int sx, int sy,
114 struct wlr_box *surface_box) {
115 int sw = view->width;
116 int sh = view->height;
117
118 double _sx = sx, _sy = sy;
119 rotate_child_position(&_sx, &_sy, sw, sh, geo->width, geo->height,
120 geo->rotation);
121
122 struct wlr_box box = {
123 .x = geo->x + _sx,
124 .y = geo->y + _sy,
125 .width = sw,
126 .height = sh,
127 };
128 if (surface_box != NULL) {
129 memcpy(surface_box, &box, sizeof(struct wlr_box));
130 }
131
132 struct wlr_box rotated_box;
133 wlr_box_rotated_bounds(&box, geo->rotation, &rotated_box);
134
135 struct wlr_box output_box = {
136 .width = output->swayc->width,
137 .height = output->swayc->height,
138 };
139
140 struct wlr_box intersection;
141 return wlr_box_intersection(&output_box, &rotated_box, &intersection);
142}
143
111static void surface_for_each_surface(struct wlr_surface *surface, 144static void surface_for_each_surface(struct wlr_surface *surface,
112 double ox, double oy, struct root_geometry *geo, 145 double ox, double oy, struct root_geometry *geo,
113 wlr_surface_iterator_func_t iterator, void *user_data) { 146 wlr_surface_iterator_func_t iterator, void *user_data) {
@@ -225,13 +258,26 @@ static void render_surface_iterator(struct wlr_surface *surface, int sx, int sy,
225 pixman_region32_t *output_damage = data->damage; 258 pixman_region32_t *output_damage = data->damage;
226 float alpha = data->alpha; 259 float alpha = data->alpha;
227 260
228 if (!wlr_surface_has_buffer(surface)) { 261 struct wlr_texture *texture = NULL;
229 return; 262 struct wlr_box box;
263 bool intersects;
264
265 // If this is the main surface of a view, render the saved_texture instead
266 // if it exists. It exists when we are mid-transaction.
267 if (data->view && data->view->saved_texture &&
268 data->view->surface == surface) {
269 texture = data->view->saved_texture;
270 intersects = get_view_box(&data->root_geo, data->output, data->view,
271 sx, sy, &box);
272 } else {
273 if (!wlr_surface_has_buffer(surface)) {
274 return;
275 }
276 texture = surface->texture;
277 intersects = get_surface_box(&data->root_geo, data->output, surface,
278 sx, sy, &box);
230 } 279 }
231 280
232 struct wlr_box box;
233 bool intersects = get_surface_box(&data->root_geo, data->output, surface,
234 sx, sy, &box);
235 if (!intersects) { 281 if (!intersects) {
236 return; 282 return;
237 } 283 }
@@ -244,8 +290,7 @@ static void render_surface_iterator(struct wlr_surface *surface, int sx, int sy,
244 wlr_matrix_project_box(matrix, &box, transform, rotation, 290 wlr_matrix_project_box(matrix, &box, transform, rotation,
245 wlr_output->transform_matrix); 291 wlr_output->transform_matrix);
246 292
247 render_texture(wlr_output, output_damage, surface->texture, &box, matrix, 293 render_texture(wlr_output, output_damage, texture, &box, matrix, alpha);
248 alpha);
249} 294}
250 295
251static void render_layer(struct sway_output *output, 296static void render_layer(struct sway_output *output,
@@ -315,6 +360,7 @@ static void render_view_surfaces(struct sway_view *view,
315 struct render_data data = { 360 struct render_data data = {
316 .output = output, 361 .output = output,
317 .damage = damage, 362 .damage = damage,
363 .view = view,
318 .alpha = alpha, 364 .alpha = alpha,
319 }; 365 };
320 output_view_for_each_surface( 366 output_view_for_each_surface(
@@ -1134,6 +1180,16 @@ void output_damage_from_view(struct sway_output *output,
1134 output_damage_view(output, view, false); 1180 output_damage_view(output, view, false);
1135} 1181}
1136 1182
1183// Expecting an unscaled box in layout coordinates
1184void output_damage_box(struct sway_output *output, struct wlr_box *_box) {
1185 struct wlr_box box;
1186 memcpy(&box, _box, sizeof(struct wlr_box));
1187 box.x -= output->swayc->x;
1188 box.y -= output->swayc->y;
1189 scale_box(&box, output->wlr_output->scale);
1190 wlr_output_damage_add_box(output->damage, &box);
1191}
1192
1137static void output_damage_whole_container_iterator(struct sway_container *con, 1193static void output_damage_whole_container_iterator(struct sway_container *con,
1138 void *data) { 1194 void *data) {
1139 struct sway_output *output = data; 1195 struct sway_output *output = data;