Damage borders when damaging view

This commit is contained in:
emersion 2018-05-05 19:43:12 +01:00
parent 98f7ee8f59
commit bec80f1551
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
8 changed files with 40 additions and 26 deletions

View file

@ -37,8 +37,8 @@ void output_damage_whole(struct sway_output *output);
void output_damage_surface(struct sway_output *output, double ox, double oy, void output_damage_surface(struct sway_output *output, double ox, double oy,
struct wlr_surface *surface, bool whole); struct wlr_surface *surface, bool whole);
void output_damage_view(struct sway_output *output, struct sway_view *view, void output_damage_from_view(struct sway_output *output,
bool whole); struct sway_view *view);
void output_damage_whole_container(struct sway_output *output, void output_damage_whole_container(struct sway_output *output,
struct sway_container *con); struct sway_container *con);

View file

@ -184,7 +184,7 @@ void view_set_fullscreen(struct sway_view *view, bool fullscreen);
void view_close(struct sway_view *view); void view_close(struct sway_view *view);
void view_damage(struct sway_view *view, bool whole); void view_damage_from(struct sway_view *view);
void view_for_each_surface(struct sway_view *view, void view_for_each_surface(struct sway_view *view,
wlr_surface_iterator_func_t iterator, void *user_data); wlr_surface_iterator_func_t iterator, void *user_data);

View file

@ -784,8 +784,8 @@ void output_damage_surface(struct sway_output *output, double ox, double oy,
damage_surface_iterator, &data); damage_surface_iterator, &data);
} }
void output_damage_view(struct sway_output *output, struct sway_view *view, static void output_damage_view(struct sway_output *output,
bool whole) { struct sway_view *view, bool whole) {
if (!sway_assert(view->swayc != NULL, "expected a view in the tree")) { if (!sway_assert(view->swayc != NULL, "expected a view in the tree")) {
return; return;
} }
@ -805,6 +805,11 @@ void output_damage_view(struct sway_output *output, struct sway_view *view,
damage_surface_iterator, &data); damage_surface_iterator, &data);
} }
void output_damage_from_view(struct sway_output *output,
struct sway_view *view) {
output_damage_view(output, view, false);
}
static void output_damage_whole_container_iterator(struct sway_container *con, static void output_damage_whole_container_iterator(struct sway_container *con,
void *data) { void *data) {
struct sway_output *output = data; struct sway_output *output = data;
@ -827,8 +832,12 @@ void output_damage_whole_container(struct sway_output *output,
}; };
wlr_output_damage_add_box(output->damage, &box); wlr_output_damage_add_box(output->damage, &box);
container_descendants(con, C_VIEW, output_damage_whole_container_iterator, if (con->type == C_VIEW) {
output); output_damage_whole_container_iterator(con, output);
} else {
container_descendants(con, C_VIEW,
output_damage_whole_container_iterator, output);
}
} }
static void damage_handle_destroy(struct wl_listener *listener, void *data) { static void damage_handle_destroy(struct wl_listener *listener, void *data) {

View file

@ -85,7 +85,7 @@ static void handle_commit(struct wl_listener *listener, void *data) {
// TODO: Let floating views do whatever // TODO: Let floating views do whatever
view_update_size(view, wl_shell_view->pending_width, view_update_size(view, wl_shell_view->pending_width,
wl_shell_view->pending_height); wl_shell_view->pending_height);
view_damage(view, false); view_damage_from(view);
} }
static void handle_destroy(struct wl_listener *listener, void *data) { static void handle_destroy(struct wl_listener *listener, void *data) {

View file

@ -177,7 +177,7 @@ static void handle_commit(struct wl_listener *listener, void *data) {
view_update_size(view, xdg_shell_v6_view->pending_width, view_update_size(view, xdg_shell_v6_view->pending_width,
xdg_shell_v6_view->pending_height); xdg_shell_v6_view->pending_height);
view_update_title(view, false); view_update_title(view, false);
view_damage(view, false); view_damage_from(view);
} }
static void handle_new_popup(struct wl_listener *listener, void *data) { static void handle_new_popup(struct wl_listener *listener, void *data) {

View file

@ -222,7 +222,7 @@ static void handle_commit(struct wl_listener *listener, void *data) {
// TODO: Let floating views do whatever // TODO: Let floating views do whatever
view_update_size(view, xwayland_view->pending_width, view_update_size(view, xwayland_view->pending_width,
xwayland_view->pending_height); xwayland_view->pending_height);
view_damage(view, false); view_damage_from(view);
view_update_title(view, false); view_update_title(view, false);
} }

View file

@ -547,12 +547,13 @@ bool container_has_child(struct sway_container *con,
return container_find(con, find_child_func, child); return container_find(con, find_child_func, child);
} }
void container_damage_whole(struct sway_container *con) { void container_damage_whole(struct sway_container *container) {
struct sway_container *output = con; for (int i = 0; i < root_container.children->length; ++i) {
if (output->type != C_OUTPUT) { struct sway_container *cont = root_container.children->items[i];
output = container_parent(output, C_OUTPUT); if (cont->type == C_OUTPUT) {
output_damage_whole_container(cont->sway_output, container);
}
} }
output_damage_whole_container(output->sway_output, con);
} }
static void update_title_texture(struct sway_container *con, static void update_title_texture(struct sway_container *con,

View file

@ -199,11 +199,11 @@ void view_close(struct sway_view *view) {
} }
} }
void view_damage(struct sway_view *view, bool whole) { void view_damage_from(struct sway_view *view) {
for (int i = 0; i < root_container.children->length; ++i) { for (int i = 0; i < root_container.children->length; ++i) {
struct sway_container *cont = root_container.children->items[i]; struct sway_container *cont = root_container.children->items[i];
if (cont->type == C_OUTPUT) { if (cont->type == C_OUTPUT) {
output_damage_view(cont->sway_output, view, whole); output_damage_from_view(cont->sway_output, view);
} }
} }
} }
@ -333,7 +333,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) {
arrange_children_of(cont->parent); arrange_children_of(cont->parent);
input_manager_set_focus(input_manager, cont); input_manager_set_focus(input_manager, cont);
view_damage(view, true); container_damage_whole(cont);
view_handle_container_reparent(&view->container_reparent, NULL); view_handle_container_reparent(&view->container_reparent, NULL);
view_execute_criteria(view); view_execute_criteria(view);
@ -351,7 +351,7 @@ void view_unmap(struct sway_view *view) {
ws->sway_workspace->fullscreen = NULL; ws->sway_workspace->fullscreen = NULL;
} }
view_damage(view, true); container_damage_whole(view->swayc);
wl_list_remove(&view->surface_new_subsurface.link); wl_list_remove(&view->surface_new_subsurface.link);
wl_list_remove(&view->container_reparent.link); wl_list_remove(&view->container_reparent.link);
@ -380,10 +380,10 @@ void view_update_position(struct sway_view *view, double ox, double oy) {
// TODO: Only allow this if the view is floating (this function will only be // TODO: Only allow this if the view is floating (this function will only be
// called in response to wayland clients wanting to reposition themselves). // called in response to wayland clients wanting to reposition themselves).
view_damage(view, true); container_damage_whole(view->swayc);
view->swayc->x = ox; view->swayc->x = ox;
view->swayc->y = oy; view->swayc->y = oy;
view_damage(view, true); container_damage_whole(view->swayc);
} }
void view_update_size(struct sway_view *view, int width, int height) { 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) {
return; return;
} }
view_damage(view, true); container_damage_whole(view->swayc);
// Should we update the swayc width/height here too? // Should we update the swayc width/height here too?
view->width = width; view->width = width;
view->height = height; view->height = height;
view_damage(view, true); container_damage_whole(view->swayc);
} }
@ -414,7 +414,7 @@ static void view_child_handle_surface_commit(struct wl_listener *listener,
struct sway_view_child *child = struct sway_view_child *child =
wl_container_of(listener, child, surface_commit); wl_container_of(listener, child, surface_commit);
// TODO: only accumulate damage from the child // TODO: only accumulate damage from the child
view_damage(child->view, false); view_damage_from(child->view);
} }
static void view_child_handle_surface_new_subsurface( static void view_child_handle_surface_new_subsurface(
@ -476,12 +476,16 @@ void view_child_init(struct sway_view_child *child,
view_init_subsurfaces(child->view, surface); view_init_subsurfaces(child->view, surface);
// TODO: only damage the whole child // TODO: only damage the whole child
view_damage(child->view, true); if (child->view->swayc) {
container_damage_whole(child->view->swayc);
}
} }
void view_child_destroy(struct sway_view_child *child) { void view_child_destroy(struct sway_view_child *child) {
// TODO: only damage the whole child // TODO: only damage the whole child
view_damage(child->view, true); if (child->view->swayc) {
container_damage_whole(child->view->swayc);
}
wl_list_remove(&child->surface_commit.link); wl_list_remove(&child->surface_commit.link);
wl_list_remove(&child->surface_destroy.link); wl_list_remove(&child->surface_destroy.link);