minor perf improvements, fixed render saved view race con
This commit is contained in:
parent
e8f7a90104
commit
ad0b9171b2
2 changed files with 19 additions and 21 deletions
|
@ -98,16 +98,15 @@ static int animation_timer(void *data) {
|
||||||
int num_containers;
|
int num_containers;
|
||||||
memcpy(&num_containers, &server->animated_containers->length, sizeof(int));
|
memcpy(&num_containers, &server->animated_containers->length, sizeof(int));
|
||||||
if (num_containers == 0) {
|
if (num_containers == 0) {
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int num_animations_complete = 0;
|
|
||||||
int completed_animation_indices[100]; // TODO: this can be better
|
|
||||||
bool is_container_close_animation_complete = false;
|
bool is_container_close_animation_complete = false;
|
||||||
bool should_delay_transaction_commit = false;
|
bool should_delay_transaction_commit = false;
|
||||||
|
|
||||||
// update state
|
// update state from end to start of list: this ensures removing containers from the list won't
|
||||||
for (int i = 0; i < num_containers; i++) {
|
// impact indices of later list members that are iterated through
|
||||||
|
for (int i = num_containers - 1; i >= 0; i--) {
|
||||||
struct sway_container *con = server->animated_containers->items[i];
|
struct sway_container *con = server->animated_containers->items[i];
|
||||||
sway_assert(con->view, "container being animated is not a view container");
|
sway_assert(con->view, "container being animated is not a view container");
|
||||||
|
|
||||||
|
@ -119,8 +118,7 @@ static int animation_timer(void *data) {
|
||||||
MIN(con->alpha + alpha_step, con->target_alpha);
|
MIN(con->alpha + alpha_step, con->target_alpha);
|
||||||
|
|
||||||
if (con->alpha == con->target_alpha) {
|
if (con->alpha == con->target_alpha) {
|
||||||
completed_animation_indices[num_animations_complete] = i;
|
list_del(server->animated_containers, i);
|
||||||
num_animations_complete++;
|
|
||||||
if (con->alpha == 0) {
|
if (con->alpha == 0) {
|
||||||
view_remove_container(con);
|
view_remove_container(con);
|
||||||
is_container_close_animation_complete = true;
|
is_container_close_animation_complete = true;
|
||||||
|
@ -128,24 +126,15 @@ static int animation_timer(void *data) {
|
||||||
} else if (is_closing) {
|
} else if (is_closing) {
|
||||||
should_delay_transaction_commit = true;
|
should_delay_transaction_commit = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (view_is_visible(con->view)) {
|
||||||
|
container_damage_whole(con);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// damage track
|
// damage track
|
||||||
if (is_container_close_animation_complete && !should_delay_transaction_commit) {
|
if (is_container_close_animation_complete && !should_delay_transaction_commit) {
|
||||||
transaction_commit_dirty();
|
transaction_commit_dirty();
|
||||||
} else {
|
|
||||||
for (int i = 0; i < num_containers; i++) {
|
|
||||||
struct sway_container *con = server->animated_containers->items[i];
|
|
||||||
if (view_is_visible(con->view)) {
|
|
||||||
container_damage_whole(con);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// clean up list: del containers that are done animating from last to first in order prevent later indices being incorrect
|
|
||||||
for (int i = num_animations_complete - 1; i >= 0; i--) {
|
|
||||||
int container_index = completed_animation_indices[i];
|
|
||||||
list_del(server->animated_containers, container_index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -78,6 +78,10 @@ void view_destroy(struct sway_view *view) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void view_remove_container(struct sway_container *container) {
|
void view_remove_container(struct sway_container *container) {
|
||||||
|
if (!wl_list_empty(&container->view->saved_buffers)) {
|
||||||
|
view_remove_saved_buffer(container->view);
|
||||||
|
}
|
||||||
|
|
||||||
struct sway_container *parent = container->pending.parent;
|
struct sway_container *parent = container->pending.parent;
|
||||||
struct sway_workspace *ws = container->pending.workspace;
|
struct sway_workspace *ws = container->pending.workspace;
|
||||||
container_begin_destroy(container);
|
container_begin_destroy(container);
|
||||||
|
@ -960,7 +964,9 @@ void view_unmap(struct sway_view *view) {
|
||||||
transaction_commit_dirty();
|
transaction_commit_dirty();
|
||||||
} else {*/
|
} else {*/
|
||||||
wl_signal_emit_mutable(&view->container->node.events.destroy, &view->container->node);
|
wl_signal_emit_mutable(&view->container->node.events.destroy, &view->container->node);
|
||||||
view_save_buffer(view);
|
if (wl_list_empty(&view->saved_buffers)) {
|
||||||
|
view_save_buffer(view);
|
||||||
|
}
|
||||||
view->container->target_alpha = 0;
|
view->container->target_alpha = 0;
|
||||||
list_add(server.animated_containers, view->container);
|
list_add(server.animated_containers, view->container);
|
||||||
//}
|
//}
|
||||||
|
@ -1384,6 +1390,9 @@ void view_update_title(struct sway_view *view, bool force) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool view_is_visible(struct sway_view *view) {
|
bool view_is_visible(struct sway_view *view) {
|
||||||
|
if (!view->container) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (view->container->node.destroying) {
|
if (view->container->node.destroying) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue