diff options
author | emersion <contact@emersion.fr> | 2018-05-05 19:43:12 +0100 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2018-05-10 23:03:50 +0100 |
commit | bec80f15519f686c64485685289155568c9bfa9e (patch) | |
tree | ce19c596754ac2413bddea4a6cd395882682567f | |
parent | Render borders with damage (diff) | |
download | sway-bec80f15519f686c64485685289155568c9bfa9e.tar.gz sway-bec80f15519f686c64485685289155568c9bfa9e.tar.zst sway-bec80f15519f686c64485685289155568c9bfa9e.zip |
Damage borders when damaging view
-rw-r--r-- | include/sway/output.h | 4 | ||||
-rw-r--r-- | include/sway/tree/view.h | 2 | ||||
-rw-r--r-- | sway/desktop/output.c | 17 | ||||
-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 | 2 | ||||
-rw-r--r-- | sway/tree/container.c | 11 | ||||
-rw-r--r-- | sway/tree/view.c | 26 |
8 files changed, 40 insertions, 26 deletions
diff --git a/include/sway/output.h b/include/sway/output.h index 56571548..be19d7b2 100644 --- a/include/sway/output.h +++ b/include/sway/output.h | |||
@@ -37,8 +37,8 @@ void output_damage_whole(struct sway_output *output); | |||
37 | void output_damage_surface(struct sway_output *output, double ox, double oy, | 37 | void output_damage_surface(struct sway_output *output, double ox, double oy, |
38 | struct wlr_surface *surface, bool whole); | 38 | struct wlr_surface *surface, bool whole); |
39 | 39 | ||
40 | void output_damage_view(struct sway_output *output, struct sway_view *view, | 40 | void output_damage_from_view(struct sway_output *output, |
41 | bool whole); | 41 | struct sway_view *view); |
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 9d4256f7..4ecd8c44 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h | |||
@@ -184,7 +184,7 @@ void view_set_fullscreen(struct sway_view *view, bool fullscreen); | |||
184 | 184 | ||
185 | void view_close(struct sway_view *view); | 185 | void view_close(struct sway_view *view); |
186 | 186 | ||
187 | void view_damage(struct sway_view *view, bool whole); | 187 | void view_damage_from(struct sway_view *view); |
188 | 188 | ||
189 | void view_for_each_surface(struct sway_view *view, | 189 | void view_for_each_surface(struct sway_view *view, |
190 | wlr_surface_iterator_func_t iterator, void *user_data); | 190 | wlr_surface_iterator_func_t iterator, void *user_data); |
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 47461736..907ad6c9 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -784,8 +784,8 @@ void output_damage_surface(struct sway_output *output, double ox, double oy, | |||
784 | damage_surface_iterator, &data); | 784 | damage_surface_iterator, &data); |
785 | } | 785 | } |
786 | 786 | ||
787 | void output_damage_view(struct sway_output *output, struct sway_view *view, | 787 | static void output_damage_view(struct sway_output *output, |
788 | bool whole) { | 788 | struct sway_view *view, bool whole) { |
789 | if (!sway_assert(view->swayc != NULL, "expected a view in the tree")) { | 789 | if (!sway_assert(view->swayc != NULL, "expected a view in the tree")) { |
790 | return; | 790 | return; |
791 | } | 791 | } |
@@ -805,6 +805,11 @@ void output_damage_view(struct sway_output *output, struct sway_view *view, | |||
805 | damage_surface_iterator, &data); | 805 | damage_surface_iterator, &data); |
806 | } | 806 | } |
807 | 807 | ||
808 | void output_damage_from_view(struct sway_output *output, | ||
809 | struct sway_view *view) { | ||
810 | output_damage_view(output, view, false); | ||
811 | } | ||
812 | |||
808 | static void output_damage_whole_container_iterator(struct sway_container *con, | 813 | static void output_damage_whole_container_iterator(struct sway_container *con, |
809 | void *data) { | 814 | void *data) { |
810 | struct sway_output *output = data; | 815 | struct sway_output *output = data; |
@@ -827,8 +832,12 @@ void output_damage_whole_container(struct sway_output *output, | |||
827 | }; | 832 | }; |
828 | wlr_output_damage_add_box(output->damage, &box); | 833 | wlr_output_damage_add_box(output->damage, &box); |
829 | 834 | ||
830 | container_descendants(con, C_VIEW, output_damage_whole_container_iterator, | 835 | if (con->type == C_VIEW) { |
831 | output); | 836 | output_damage_whole_container_iterator(con, output); |
837 | } else { | ||
838 | container_descendants(con, C_VIEW, | ||
839 | output_damage_whole_container_iterator, output); | ||
840 | } | ||
832 | } | 841 | } |
833 | 842 | ||
834 | static void damage_handle_destroy(struct wl_listener *listener, void *data) { | 843 | static void damage_handle_destroy(struct wl_listener *listener, void *data) { |
diff --git a/sway/desktop/wl_shell.c b/sway/desktop/wl_shell.c index e97a898e..99e8947b 100644 --- a/sway/desktop/wl_shell.c +++ b/sway/desktop/wl_shell.c | |||
@@ -85,7 +85,7 @@ static void handle_commit(struct wl_listener *listener, void *data) { | |||
85 | // TODO: Let floating views do whatever | 85 | // TODO: Let floating views do whatever |
86 | view_update_size(view, wl_shell_view->pending_width, | 86 | view_update_size(view, wl_shell_view->pending_width, |
87 | wl_shell_view->pending_height); | 87 | wl_shell_view->pending_height); |
88 | view_damage(view, false); | 88 | view_damage_from(view); |
89 | } | 89 | } |
90 | 90 | ||
91 | static void handle_destroy(struct wl_listener *listener, void *data) { | 91 | 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 fcee8ce9..8ecb330d 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c | |||
@@ -177,7 +177,7 @@ static void handle_commit(struct wl_listener *listener, void *data) { | |||
177 | view_update_size(view, xdg_shell_v6_view->pending_width, | 177 | view_update_size(view, xdg_shell_v6_view->pending_width, |
178 | xdg_shell_v6_view->pending_height); | 178 | xdg_shell_v6_view->pending_height); |
179 | view_update_title(view, false); | 179 | view_update_title(view, false); |
180 | view_damage(view, false); | 180 | view_damage_from(view); |
181 | } | 181 | } |
182 | 182 | ||
183 | static void handle_new_popup(struct wl_listener *listener, void *data) { | 183 | static void handle_new_popup(struct wl_listener *listener, void *data) { |
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index b4eda71f..8f935760 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c | |||
@@ -222,7 +222,7 @@ static void handle_commit(struct wl_listener *listener, void *data) { | |||
222 | // TODO: Let floating views do whatever | 222 | // TODO: Let floating views do whatever |
223 | view_update_size(view, xwayland_view->pending_width, | 223 | view_update_size(view, xwayland_view->pending_width, |
224 | xwayland_view->pending_height); | 224 | xwayland_view->pending_height); |
225 | view_damage(view, false); | 225 | view_damage_from(view); |
226 | view_update_title(view, false); | 226 | view_update_title(view, false); |
227 | } | 227 | } |
228 | 228 | ||
diff --git a/sway/tree/container.c b/sway/tree/container.c index 38db29c2..cc3bde0a 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -547,12 +547,13 @@ bool container_has_child(struct sway_container *con, | |||
547 | return container_find(con, find_child_func, child); | 547 | return container_find(con, find_child_func, child); |
548 | } | 548 | } |
549 | 549 | ||
550 | void container_damage_whole(struct sway_container *con) { | 550 | void container_damage_whole(struct sway_container *container) { |
551 | struct sway_container *output = con; | 551 | for (int i = 0; i < root_container.children->length; ++i) { |
552 | if (output->type != C_OUTPUT) { | 552 | struct sway_container *cont = root_container.children->items[i]; |
553 | output = container_parent(output, C_OUTPUT); | 553 | if (cont->type == C_OUTPUT) { |
554 | output_damage_whole_container(cont->sway_output, container); | ||
555 | } | ||
554 | } | 556 | } |
555 | output_damage_whole_container(output->sway_output, con); | ||
556 | } | 557 | } |
557 | 558 | ||
558 | static void update_title_texture(struct sway_container *con, | 559 | static void update_title_texture(struct sway_container *con, |
diff --git a/sway/tree/view.c b/sway/tree/view.c index fe944466..afd7eade 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -199,11 +199,11 @@ void view_close(struct sway_view *view) { | |||
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||
202 | void view_damage(struct sway_view *view, bool whole) { | 202 | void view_damage_from(struct sway_view *view) { |
203 | for (int i = 0; i < root_container.children->length; ++i) { | 203 | for (int i = 0; i < root_container.children->length; ++i) { |
204 | struct sway_container *cont = root_container.children->items[i]; | 204 | struct sway_container *cont = root_container.children->items[i]; |
205 | if (cont->type == C_OUTPUT) { | 205 | if (cont->type == C_OUTPUT) { |
206 | output_damage_view(cont->sway_output, view, whole); | 206 | output_damage_from_view(cont->sway_output, view); |
207 | } | 207 | } |
208 | } | 208 | } |
209 | } | 209 | } |
@@ -333,7 +333,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) { | |||
333 | arrange_children_of(cont->parent); | 333 | arrange_children_of(cont->parent); |
334 | input_manager_set_focus(input_manager, cont); | 334 | input_manager_set_focus(input_manager, cont); |
335 | 335 | ||
336 | view_damage(view, true); | 336 | container_damage_whole(cont); |
337 | view_handle_container_reparent(&view->container_reparent, NULL); | 337 | view_handle_container_reparent(&view->container_reparent, NULL); |
338 | 338 | ||
339 | view_execute_criteria(view); | 339 | view_execute_criteria(view); |
@@ -351,7 +351,7 @@ void view_unmap(struct sway_view *view) { | |||
351 | ws->sway_workspace->fullscreen = NULL; | 351 | ws->sway_workspace->fullscreen = NULL; |
352 | } | 352 | } |
353 | 353 | ||
354 | view_damage(view, true); | 354 | container_damage_whole(view->swayc); |
355 | 355 | ||
356 | wl_list_remove(&view->surface_new_subsurface.link); | 356 | wl_list_remove(&view->surface_new_subsurface.link); |
357 | wl_list_remove(&view->container_reparent.link); | 357 | wl_list_remove(&view->container_reparent.link); |
@@ -380,10 +380,10 @@ void view_update_position(struct sway_view *view, double ox, double oy) { | |||
380 | 380 | ||
381 | // TODO: Only allow this if the view is floating (this function will only be | 381 | // TODO: Only allow this if the view is floating (this function will only be |
382 | // called in response to wayland clients wanting to reposition themselves). | 382 | // called in response to wayland clients wanting to reposition themselves). |
383 | view_damage(view, true); | 383 | container_damage_whole(view->swayc); |
384 | view->swayc->x = ox; | 384 | view->swayc->x = ox; |
385 | view->swayc->y = oy; | 385 | view->swayc->y = oy; |
386 | view_damage(view, true); | 386 | container_damage_whole(view->swayc); |
387 | } | 387 | } |
388 | 388 | ||
389 | void view_update_size(struct sway_view *view, int width, int height) { | 389 | void view_update_size(struct sway_view *view, int width, int height) { |
@@ -391,11 +391,11 @@ void view_update_size(struct sway_view *view, int width, int height) { | |||
391 | return; | 391 | return; |
392 | } | 392 | } |
393 | 393 | ||
394 | view_damage(view, true); | 394 | container_damage_whole(view->swayc); |
395 | // Should we update the swayc width/height here too? | 395 | // Should we update the swayc width/height here too? |
396 | view->width = width; | 396 | view->width = width; |
397 | view->height = height; | 397 | view->height = height; |
398 | view_damage(view, true); | 398 | container_damage_whole(view->swayc); |
399 | } | 399 | } |
400 | 400 | ||
401 | 401 | ||
@@ -414,7 +414,7 @@ static void view_child_handle_surface_commit(struct wl_listener *listener, | |||
414 | struct sway_view_child *child = | 414 | struct sway_view_child *child = |
415 | wl_container_of(listener, child, surface_commit); | 415 | wl_container_of(listener, child, surface_commit); |
416 | // TODO: only accumulate damage from the child | 416 | // TODO: only accumulate damage from the child |
417 | view_damage(child->view, false); | 417 | view_damage_from(child->view); |
418 | } | 418 | } |
419 | 419 | ||
420 | static void view_child_handle_surface_new_subsurface( | 420 | static void view_child_handle_surface_new_subsurface( |
@@ -476,12 +476,16 @@ void view_child_init(struct sway_view_child *child, | |||
476 | view_init_subsurfaces(child->view, surface); | 476 | view_init_subsurfaces(child->view, surface); |
477 | 477 | ||
478 | // TODO: only damage the whole child | 478 | // TODO: only damage the whole child |
479 | view_damage(child->view, true); | 479 | if (child->view->swayc) { |
480 | container_damage_whole(child->view->swayc); | ||
481 | } | ||
480 | } | 482 | } |
481 | 483 | ||
482 | void view_child_destroy(struct sway_view_child *child) { | 484 | void view_child_destroy(struct sway_view_child *child) { |
483 | // TODO: only damage the whole child | 485 | // TODO: only damage the whole child |
484 | view_damage(child->view, true); | 486 | if (child->view->swayc) { |
487 | container_damage_whole(child->view->swayc); | ||
488 | } | ||
485 | 489 | ||
486 | wl_list_remove(&child->surface_commit.link); | 490 | wl_list_remove(&child->surface_commit.link); |
487 | wl_list_remove(&child->surface_destroy.link); | 491 | wl_list_remove(&child->surface_destroy.link); |