diff options
-rw-r--r-- | include/sway/desktop.h | 7 | ||||
-rw-r--r-- | include/sway/output.h | 8 | ||||
-rw-r--r-- | include/sway/tree/view.h | 4 | ||||
-rw-r--r-- | sway/commands/opacity.c | 5 | ||||
-rw-r--r-- | sway/desktop/desktop.c | 14 | ||||
-rw-r--r-- | sway/desktop/layer_shell.c | 44 | ||||
-rw-r--r-- | sway/desktop/output.c | 8 | ||||
-rw-r--r-- | sway/desktop/wl_shell.c | 2 | ||||
-rw-r--r-- | sway/desktop/xdg_shell_v6.c | 2 | ||||
-rw-r--r-- | sway/desktop/xwayland.c | 18 | ||||
-rw-r--r-- | sway/tree/view.c | 27 |
11 files changed, 64 insertions, 75 deletions
diff --git a/include/sway/desktop.h b/include/sway/desktop.h index 96bdc94c..f1ad759a 100644 --- a/include/sway/desktop.h +++ b/include/sway/desktop.h | |||
@@ -1,7 +1,4 @@ | |||
1 | #include <wlr/types/wlr_surface.h> | 1 | #include <wlr/types/wlr_surface.h> |
2 | 2 | ||
3 | void desktop_damage_whole_surface(struct wlr_surface *surface, double lx, | 3 | void desktop_damage_surface(struct wlr_surface *surface, double lx, double ly, |
4 | double ly); | 4 | bool whole); |
5 | |||
6 | void desktop_damage_from_surface(struct wlr_surface *surface, double lx, | ||
7 | double ly); | ||
diff --git a/include/sway/output.h b/include/sway/output.h index 4bffa2b7..56571548 100644 --- a/include/sway/output.h +++ b/include/sway/output.h | |||
@@ -34,11 +34,11 @@ struct sway_output { | |||
34 | 34 | ||
35 | void output_damage_whole(struct sway_output *output); | 35 | void output_damage_whole(struct sway_output *output); |
36 | 36 | ||
37 | void output_damage_whole_surface(struct sway_output *output, | 37 | void output_damage_surface(struct sway_output *output, double ox, double oy, |
38 | double ox, double oy, struct wlr_surface *surface); | 38 | struct wlr_surface *surface, bool whole); |
39 | 39 | ||
40 | void output_damage_whole_view(struct sway_output *output, | 40 | void output_damage_view(struct sway_output *output, struct sway_view *view, |
41 | struct sway_view *view); | 41 | bool whole); |
42 | 42 | ||
43 | void output_damage_whole_container(struct sway_output *output, | 43 | void output_damage_whole_container(struct sway_output *output, |
44 | struct sway_container *con); | 44 | struct sway_container *con); |
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 611c4f0b..b51c54b5 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h | |||
@@ -157,9 +157,7 @@ void view_set_activated(struct sway_view *view, bool activated); | |||
157 | 157 | ||
158 | void view_close(struct sway_view *view); | 158 | void view_close(struct sway_view *view); |
159 | 159 | ||
160 | void view_damage_whole(struct sway_view *view); | 160 | void view_damage(struct sway_view *view, bool whole); |
161 | |||
162 | void view_damage_from(struct sway_view *view); | ||
163 | 161 | ||
164 | void view_for_each_surface(struct sway_view *view, | 162 | void view_for_each_surface(struct sway_view *view, |
165 | wlr_surface_iterator_func_t iterator, void *user_data); | 163 | wlr_surface_iterator_func_t iterator, void *user_data); |
diff --git a/sway/commands/opacity.c b/sway/commands/opacity.c index b8cd1f09..68fd9f42 100644 --- a/sway/commands/opacity.c +++ b/sway/commands/opacity.c | |||
@@ -30,10 +30,7 @@ struct cmd_results *cmd_opacity(int argc, char **argv) { | |||
30 | } | 30 | } |
31 | 31 | ||
32 | con->alpha = opacity; | 32 | con->alpha = opacity; |
33 | 33 | container_damage_whole(con); | |
34 | if (con->type == C_VIEW) { | ||
35 | view_damage_whole(con->sway_view); | ||
36 | } | ||
37 | 34 | ||
38 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 35 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
39 | } | 36 | } |
diff --git a/sway/desktop/desktop.c b/sway/desktop/desktop.c index 3a13191f..66f33151 100644 --- a/sway/desktop/desktop.c +++ b/sway/desktop/desktop.c | |||
@@ -2,19 +2,13 @@ | |||
2 | #include "sway/desktop.h" | 2 | #include "sway/desktop.h" |
3 | #include "sway/output.h" | 3 | #include "sway/output.h" |
4 | 4 | ||
5 | void desktop_damage_whole_surface(struct wlr_surface *surface, double lx, | 5 | void desktop_damage_surface(struct wlr_surface *surface, double lx, double ly, |
6 | double ly) { | 6 | bool whole) { |
7 | for (int i = 0; i < root_container.children->length; ++i) { | 7 | for (int i = 0; i < root_container.children->length; ++i) { |
8 | struct sway_container *cont = root_container.children->items[i]; | 8 | struct sway_container *cont = root_container.children->items[i]; |
9 | if (cont->type == C_OUTPUT) { | 9 | if (cont->type == C_OUTPUT) { |
10 | output_damage_whole_surface(cont->sway_output, | 10 | output_damage_surface(cont->sway_output, lx - cont->x, ly - cont->y, |
11 | lx - cont->x, ly - cont->y, surface); | 11 | surface, whole); |
12 | } | 12 | } |
13 | } | 13 | } |
14 | } | 14 | } |
15 | |||
16 | void desktop_damage_from_surface(struct wlr_surface *surface, double lx, | ||
17 | double ly) { | ||
18 | // TODO | ||
19 | desktop_damage_whole_surface(surface, lx, ly); | ||
20 | } | ||
diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c index 663ec7ba..f841e5f1 100644 --- a/sway/desktop/layer_shell.c +++ b/sway/desktop/layer_shell.c | |||
@@ -229,33 +229,39 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) { | |||
229 | wl_container_of(listener, layer, surface_commit); | 229 | wl_container_of(listener, layer, surface_commit); |
230 | struct wlr_layer_surface *layer_surface = layer->layer_surface; | 230 | struct wlr_layer_surface *layer_surface = layer->layer_surface; |
231 | struct wlr_output *wlr_output = layer_surface->output; | 231 | struct wlr_output *wlr_output = layer_surface->output; |
232 | if (wlr_output != NULL) { | 232 | if (wlr_output == NULL) { |
233 | struct sway_output *output = wlr_output->data; | 233 | return; |
234 | struct wlr_box old_geo = layer->geo; | 234 | } |
235 | arrange_layers(output); | 235 | |
236 | if (memcmp(&old_geo, &layer->geo, sizeof(struct wlr_box)) != 0) { | 236 | struct sway_output *output = wlr_output->data; |
237 | // TODO DAMAGE apply whole surface from previous and new geos | 237 | struct wlr_box old_geo = layer->geo; |
238 | } else { | 238 | arrange_layers(output); |
239 | // TODO DAMAGE from surface damage | 239 | if (memcmp(&old_geo, &layer->geo, sizeof(struct wlr_box)) != 0) { |
240 | } | 240 | output_damage_surface(output, old_geo.x, old_geo.y, |
241 | wlr_output_damage_add_box(output->damage, &old_geo); | 241 | layer_surface->surface, true); |
242 | wlr_output_damage_add_box(output->damage, &layer->geo); | 242 | output_damage_surface(output, layer->geo.x, layer->geo.y, |
243 | layer_surface->surface, true); | ||
244 | } else { | ||
245 | output_damage_surface(output, layer->geo.x, layer->geo.y, | ||
246 | layer_surface->surface, false); | ||
243 | } | 247 | } |
244 | } | 248 | } |
245 | 249 | ||
246 | static void unmap(struct sway_layer_surface *sway_layer) { | 250 | static void unmap(struct sway_layer_surface *sway_layer) { |
247 | struct wlr_output *wlr_output = sway_layer->layer_surface->output; | 251 | struct wlr_output *wlr_output = sway_layer->layer_surface->output; |
248 | if (wlr_output != NULL) { | 252 | if (wlr_output == NULL) { |
249 | struct sway_output *output = wlr_output->data; | 253 | return; |
250 | wlr_output_damage_add_box(output->damage, &sway_layer->geo); | ||
251 | } | 254 | } |
255 | struct sway_output *output = wlr_output->data; | ||
256 | output_damage_surface(output, sway_layer->geo.x, sway_layer->geo.y, | ||
257 | sway_layer->layer_surface->surface, true); | ||
252 | } | 258 | } |
253 | 259 | ||
254 | static void handle_destroy(struct wl_listener *listener, void *data) { | 260 | static void handle_destroy(struct wl_listener *listener, void *data) { |
255 | struct sway_layer_surface *sway_layer = wl_container_of(listener, | 261 | struct sway_layer_surface *sway_layer = |
256 | sway_layer, destroy); | 262 | wl_container_of(listener, sway_layer, destroy); |
257 | wlr_log(L_DEBUG, "Layer surface destroyed (%s)", | 263 | wlr_log(L_DEBUG, "Layer surface destroyed (%s)", |
258 | sway_layer->layer_surface->namespace); | 264 | sway_layer->layer_surface->namespace); |
259 | if (sway_layer->layer_surface->mapped) { | 265 | if (sway_layer->layer_surface->mapped) { |
260 | unmap(sway_layer); | 266 | unmap(sway_layer); |
261 | } | 267 | } |
@@ -277,7 +283,9 @@ static void handle_map(struct wl_listener *listener, void *data) { | |||
277 | struct sway_layer_surface *sway_layer = wl_container_of(listener, | 283 | struct sway_layer_surface *sway_layer = wl_container_of(listener, |
278 | sway_layer, map); | 284 | sway_layer, map); |
279 | struct sway_output *output = sway_layer->layer_surface->output->data; | 285 | struct sway_output *output = sway_layer->layer_surface->output->data; |
280 | wlr_output_damage_add_box(output->damage, &sway_layer->geo); | 286 | output_damage_surface(output, sway_layer->geo.x, sway_layer->geo.y, |
287 | sway_layer->layer_surface->surface, true); | ||
288 | // TODO: send enter to subsurfaces and popups | ||
281 | wlr_surface_send_enter(sway_layer->layer_surface->surface, | 289 | wlr_surface_send_enter(sway_layer->layer_surface->surface, |
282 | sway_layer->layer_surface->output); | 290 | sway_layer->layer_surface->output); |
283 | } | 291 | } |
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index aa18f1b8..3bbd0bb2 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -332,14 +332,14 @@ void output_damage_whole(struct sway_output *output) { | |||
332 | wlr_output_damage_add_whole(output->damage); | 332 | wlr_output_damage_add_whole(output->damage); |
333 | } | 333 | } |
334 | 334 | ||
335 | void output_damage_whole_surface(struct sway_output *output, | 335 | void output_damage_surface(struct sway_output *output, double ox, double oy, |
336 | double ox, double oy, struct wlr_surface *surface) { | 336 | struct wlr_surface *surface, bool whole) { |
337 | // TODO | 337 | // TODO |
338 | output_damage_whole(output); | 338 | output_damage_whole(output); |
339 | } | 339 | } |
340 | 340 | ||
341 | void output_damage_whole_view(struct sway_output *output, | 341 | void output_damage_view(struct sway_output *output, struct sway_view *view, |
342 | struct sway_view *view) { | 342 | bool whole) { |
343 | // TODO | 343 | // TODO |
344 | output_damage_whole(output); | 344 | output_damage_whole(output); |
345 | } | 345 | } |
diff --git a/sway/desktop/wl_shell.c b/sway/desktop/wl_shell.c index fff31da8..b63c220c 100644 --- a/sway/desktop/wl_shell.c +++ b/sway/desktop/wl_shell.c | |||
@@ -79,7 +79,7 @@ static void handle_commit(struct wl_listener *listener, void *data) { | |||
79 | // TODO: Let floating views do whatever | 79 | // TODO: Let floating views do whatever |
80 | view_update_size(view, wl_shell_view->pending_width, | 80 | view_update_size(view, wl_shell_view->pending_width, |
81 | wl_shell_view->pending_height); | 81 | wl_shell_view->pending_height); |
82 | view_damage_from(view); | 82 | view_damage(view, false); |
83 | } | 83 | } |
84 | 84 | ||
85 | static void handle_destroy(struct wl_listener *listener, void *data) { | 85 | static void handle_destroy(struct wl_listener *listener, void *data) { |
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index 8361aab3..b82eec8f 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c | |||
@@ -169,7 +169,7 @@ static void handle_commit(struct wl_listener *listener, void *data) { | |||
169 | // TODO: Let floating views do whatever | 169 | // TODO: Let floating views do whatever |
170 | view_update_size(view, xdg_shell_v6_view->pending_width, | 170 | view_update_size(view, xdg_shell_v6_view->pending_width, |
171 | xdg_shell_v6_view->pending_height); | 171 | xdg_shell_v6_view->pending_height); |
172 | view_damage_from(view); | 172 | view_damage(view, false); |
173 | } | 173 | } |
174 | 174 | ||
175 | static void handle_new_popup(struct wl_listener *listener, void *data) { | 175 | static void handle_new_popup(struct wl_listener *listener, void *data) { |
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 10bfcc89..6de1365d 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c | |||
@@ -32,15 +32,15 @@ static void unmanaged_handle_commit(struct wl_listener *listener, void *data) { | |||
32 | 32 | ||
33 | if (xsurface->x != surface->lx || xsurface->y != surface->ly) { | 33 | if (xsurface->x != surface->lx || xsurface->y != surface->ly) { |
34 | // Surface has moved | 34 | // Surface has moved |
35 | desktop_damage_whole_surface(xsurface->surface, | 35 | desktop_damage_surface(xsurface->surface, surface->lx, surface->ly, |
36 | surface->lx, surface->ly); | 36 | true); |
37 | surface->lx = xsurface->x; | 37 | surface->lx = xsurface->x; |
38 | surface->ly = xsurface->y; | 38 | surface->ly = xsurface->y; |
39 | desktop_damage_whole_surface(xsurface->surface, | 39 | desktop_damage_surface(xsurface->surface, surface->lx, surface->ly, |
40 | surface->lx, surface->ly); | 40 | true); |
41 | } else { | 41 | } else { |
42 | desktop_damage_from_surface(xsurface->surface, | 42 | desktop_damage_surface(xsurface->surface, xsurface->x, xsurface->y, |
43 | xsurface->x, xsurface->y); | 43 | false); |
44 | } | 44 | } |
45 | } | 45 | } |
46 | 46 | ||
@@ -57,7 +57,7 @@ static void unmanaged_handle_map(struct wl_listener *listener, void *data) { | |||
57 | 57 | ||
58 | surface->lx = xsurface->x; | 58 | surface->lx = xsurface->x; |
59 | surface->ly = xsurface->y; | 59 | surface->ly = xsurface->y; |
60 | desktop_damage_whole_surface(xsurface->surface, surface->lx, surface->ly); | 60 | desktop_damage_surface(xsurface->surface, surface->lx, surface->ly, true); |
61 | 61 | ||
62 | // TODO: we don't send surface enter/leave events to xwayland unmanaged | 62 | // TODO: we don't send surface enter/leave events to xwayland unmanaged |
63 | // surfaces, but xwayland doesn't support HiDPI anyway | 63 | // surfaces, but xwayland doesn't support HiDPI anyway |
@@ -67,7 +67,7 @@ static void unmanaged_handle_unmap(struct wl_listener *listener, void *data) { | |||
67 | struct sway_xwayland_unmanaged *surface = | 67 | struct sway_xwayland_unmanaged *surface = |
68 | wl_container_of(listener, surface, unmap); | 68 | wl_container_of(listener, surface, unmap); |
69 | struct wlr_xwayland_surface *xsurface = surface->wlr_xwayland_surface; | 69 | struct wlr_xwayland_surface *xsurface = surface->wlr_xwayland_surface; |
70 | desktop_damage_whole_surface(xsurface->surface, xsurface->x, xsurface->y); | 70 | desktop_damage_surface(xsurface->surface, xsurface->x, xsurface->y, true); |
71 | wl_list_remove(&surface->link); | 71 | wl_list_remove(&surface->link); |
72 | wl_list_remove(&surface->commit.link); | 72 | wl_list_remove(&surface->commit.link); |
73 | } | 73 | } |
@@ -209,7 +209,7 @@ static void handle_commit(struct wl_listener *listener, void *data) { | |||
209 | // TODO: Let floating views do whatever | 209 | // TODO: Let floating views do whatever |
210 | view_update_size(view, xwayland_view->pending_width, | 210 | view_update_size(view, xwayland_view->pending_width, |
211 | xwayland_view->pending_height); | 211 | xwayland_view->pending_height); |
212 | view_damage_from(view); | 212 | view_damage(view, false); |
213 | } | 213 | } |
214 | 214 | ||
215 | static void handle_unmap(struct wl_listener *listener, void *data) { | 215 | static void handle_unmap(struct wl_listener *listener, void *data) { |
diff --git a/sway/tree/view.c b/sway/tree/view.c index 9855c5e1..99b44720 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -79,20 +79,15 @@ void view_close(struct sway_view *view) { | |||
79 | } | 79 | } |
80 | } | 80 | } |
81 | 81 | ||
82 | void view_damage_whole(struct sway_view *view) { | 82 | void view_damage(struct sway_view *view, bool whole) { |
83 | for (int i = 0; i < root_container.children->length; ++i) { | 83 | for (int i = 0; i < root_container.children->length; ++i) { |
84 | struct sway_container *cont = root_container.children->items[i]; | 84 | struct sway_container *cont = root_container.children->items[i]; |
85 | if (cont->type == C_OUTPUT) { | 85 | if (cont->type == C_OUTPUT) { |
86 | output_damage_whole_view(cont->sway_output, view); | 86 | output_damage_view(cont->sway_output, view, whole); |
87 | } | 87 | } |
88 | } | 88 | } |
89 | } | 89 | } |
90 | 90 | ||
91 | void view_damage_from(struct sway_view *view) { | ||
92 | // TODO | ||
93 | view_damage_whole(view); | ||
94 | } | ||
95 | |||
96 | static void view_get_layout_box(struct sway_view *view, struct wlr_box *box) { | 91 | static void view_get_layout_box(struct sway_view *view, struct wlr_box *box) { |
97 | struct sway_container *output = container_parent(view->swayc, C_OUTPUT); | 92 | struct sway_container *output = container_parent(view->swayc, C_OUTPUT); |
98 | 93 | ||
@@ -191,7 +186,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) { | |||
191 | arrange_windows(cont->parent, -1, -1); | 186 | arrange_windows(cont->parent, -1, -1); |
192 | input_manager_set_focus(input_manager, cont); | 187 | input_manager_set_focus(input_manager, cont); |
193 | 188 | ||
194 | view_damage_whole(view); | 189 | view_damage(view, true); |
195 | view_handle_container_reparent(&view->container_reparent, NULL); | 190 | view_handle_container_reparent(&view->container_reparent, NULL); |
196 | } | 191 | } |
197 | 192 | ||
@@ -202,7 +197,7 @@ void view_unmap(struct sway_view *view) { | |||
202 | 197 | ||
203 | wl_signal_emit(&view->events.unmap, view); | 198 | wl_signal_emit(&view->events.unmap, view); |
204 | 199 | ||
205 | view_damage_whole(view); | 200 | view_damage(view, true); |
206 | 201 | ||
207 | wl_list_remove(&view->surface_new_subsurface.link); | 202 | wl_list_remove(&view->surface_new_subsurface.link); |
208 | wl_list_remove(&view->container_reparent.link); | 203 | wl_list_remove(&view->container_reparent.link); |
@@ -220,10 +215,10 @@ void view_update_position(struct sway_view *view, double ox, double oy) { | |||
220 | return; | 215 | return; |
221 | } | 216 | } |
222 | 217 | ||
223 | view_damage_whole(view); | 218 | view_damage(view, true); |
224 | view->swayc->x = ox; | 219 | view->swayc->x = ox; |
225 | view->swayc->y = oy; | 220 | view->swayc->y = oy; |
226 | view_damage_whole(view); | 221 | view_damage(view, true); |
227 | } | 222 | } |
228 | 223 | ||
229 | void view_update_size(struct sway_view *view, int width, int height) { | 224 | void view_update_size(struct sway_view *view, int width, int height) { |
@@ -231,10 +226,10 @@ void view_update_size(struct sway_view *view, int width, int height) { | |||
231 | return; | 226 | return; |
232 | } | 227 | } |
233 | 228 | ||
234 | view_damage_whole(view); | 229 | view_damage(view, true); |
235 | view->width = width; | 230 | view->width = width; |
236 | view->height = height; | 231 | view->height = height; |
237 | view_damage_whole(view); | 232 | view_damage(view, true); |
238 | } | 233 | } |
239 | 234 | ||
240 | 235 | ||
@@ -253,7 +248,7 @@ static void view_child_handle_surface_commit(struct wl_listener *listener, | |||
253 | struct sway_view_child *child = | 248 | struct sway_view_child *child = |
254 | wl_container_of(listener, child, surface_commit); | 249 | wl_container_of(listener, child, surface_commit); |
255 | // TODO: only accumulate damage from the child | 250 | // TODO: only accumulate damage from the child |
256 | view_damage_from(child->view); | 251 | view_damage(child->view, false); |
257 | } | 252 | } |
258 | 253 | ||
259 | static void view_child_handle_surface_new_subsurface( | 254 | static void view_child_handle_surface_new_subsurface( |
@@ -315,12 +310,12 @@ void view_child_init(struct sway_view_child *child, | |||
315 | view_init_subsurfaces(child->view, surface); | 310 | view_init_subsurfaces(child->view, surface); |
316 | 311 | ||
317 | // TODO: only damage the whole child | 312 | // TODO: only damage the whole child |
318 | view_damage_whole(child->view); | 313 | view_damage(child->view, true); |
319 | } | 314 | } |
320 | 315 | ||
321 | void view_child_destroy(struct sway_view_child *child) { | 316 | void view_child_destroy(struct sway_view_child *child) { |
322 | // TODO: only damage the whole child | 317 | // TODO: only damage the whole child |
323 | view_damage_whole(child->view); | 318 | view_damage(child->view, true); |
324 | 319 | ||
325 | wl_list_remove(&child->surface_commit.link); | 320 | wl_list_remove(&child->surface_commit.link); |
326 | wl_list_remove(&child->surface_destroy.link); | 321 | wl_list_remove(&child->surface_destroy.link); |