logic improvements
This commit is contained in:
parent
107bcde87c
commit
819572a8d9
2 changed files with 11 additions and 5 deletions
|
@ -97,6 +97,10 @@ 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) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int num_animations_complete = 0;
|
int num_animations_complete = 0;
|
||||||
int completed_animation_indices[100]; // TODO: this can be better
|
int completed_animation_indices[100]; // TODO: this can be better
|
||||||
bool is_container_close_animation_complete = false;
|
bool is_container_close_animation_complete = false;
|
||||||
|
@ -105,6 +109,8 @@ static int animation_timer(void *data) {
|
||||||
// update state
|
// update state
|
||||||
for (int i = 0; i < num_containers; i++) {
|
for (int i = 0; i < num_containers; 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");
|
||||||
|
|
||||||
bool is_closing = con->alpha > con->target_alpha;
|
bool is_closing = con->alpha > con->target_alpha;
|
||||||
float alpha_step = config->animation_duration ?
|
float alpha_step = config->animation_duration ?
|
||||||
(con->max_alpha * fastest_output_refresh_s) / config->animation_duration : con->max_alpha;
|
(con->max_alpha * fastest_output_refresh_s) / config->animation_duration : con->max_alpha;
|
||||||
|
@ -130,15 +136,14 @@ static int animation_timer(void *data) {
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < num_containers; i++) {
|
for (int i = 0; i < num_containers; i++) {
|
||||||
struct sway_container *con = server->animated_containers->items[i];
|
struct sway_container *con = server->animated_containers->items[i];
|
||||||
// TODO: remove add assertion for con->view & investigate what happens when split h containers are spawned
|
if (view_is_visible(con->view)) {
|
||||||
if (con->view && view_is_visible(con->view)) {
|
|
||||||
container_damage_whole(con);
|
container_damage_whole(con);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// clean up list
|
// clean up list: del containers that are done animating from last to first in order prevent later indices being incorrect
|
||||||
for (int i = 0; i < num_animations_complete; i++) {
|
for (int i = num_animations_complete - 1; i >= 0; i--) {
|
||||||
int container_index = completed_animation_indices[i];
|
int container_index = completed_animation_indices[i];
|
||||||
list_del(server->animated_containers, container_index);
|
list_del(server->animated_containers, container_index);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,8 @@ struct sway_container *container_create(struct sway_view *view) {
|
||||||
if (!view) {
|
if (!view) {
|
||||||
c->pending.children = create_list();
|
c->pending.children = create_list();
|
||||||
c->current.children = create_list();
|
c->current.children = create_list();
|
||||||
|
} else {
|
||||||
|
list_add(server.animated_containers, c);
|
||||||
}
|
}
|
||||||
c->marks = create_list();
|
c->marks = create_list();
|
||||||
c->outputs = create_list();
|
c->outputs = create_list();
|
||||||
|
@ -55,7 +57,6 @@ struct sway_container *container_create(struct sway_view *view) {
|
||||||
wl_signal_init(&c->events.destroy);
|
wl_signal_init(&c->events.destroy);
|
||||||
|
|
||||||
wl_signal_emit_mutable(&root->events.new_node, &c->node);
|
wl_signal_emit_mutable(&root->events.new_node, &c->node);
|
||||||
list_add(server.animated_containers, c);
|
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue