diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index a34eaa504..0707a6054 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h @@ -119,10 +119,9 @@ struct sway_container { float saturation; - // TODO: move current_alpha to state? - float current_alpha; - // TODO: rename me to something like max_alpha? + // TODO: move alpha to state? float alpha; + float target_alpha; int corner_radius; diff --git a/sway/commands/opacity.c b/sway/commands/opacity.c index 96e6228ed..f8c10645a 100644 --- a/sway/commands/opacity.c +++ b/sway/commands/opacity.c @@ -24,9 +24,9 @@ struct cmd_results *cmd_opacity(int argc, char **argv) { } if (!strcasecmp(argv[0], "plus")) { - val = con->alpha + val; + val = con->target_alpha + val; } else if (!strcasecmp(argv[0], "minus")) { - val = con->alpha - val; + val = con->target_alpha - val; } else if (argc > 1 && strcasecmp(argv[0], "set")) { return cmd_results_new(CMD_INVALID, "Expected: set|plus|minus <0..1>: %s", argv[0]); @@ -36,7 +36,7 @@ struct cmd_results *cmd_opacity(int argc, char **argv) { return cmd_results_new(CMD_FAILURE, "opacity value out of bounds"); } - con->alpha = val; + con->target_alpha = val; container_damage_whole(con); return cmd_results_new(CMD_SUCCESS, NULL); } diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 0d8ce1e43..21bba715b 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -531,10 +531,10 @@ static void containers_tick_alpha(list_t *containers, struct sway_output *output float alpha_step; for (int i = 0; i < containers->length; ++i) { struct sway_container *con = containers->items[i]; - if (con->current_alpha < con->alpha) { - alpha_step = (con->alpha) / num_refreshes; + if (con->alpha < con->target_alpha) { + alpha_step = (con->target_alpha) / num_refreshes; // ensure that the current alpha does not exceed the set alpha for the con - con->current_alpha = MIN(con->current_alpha + alpha_step, con->alpha); + con->alpha = MIN(con->alpha + alpha_step, con->target_alpha); output_damage_whole_container(output, con); } } diff --git a/sway/desktop/render.c b/sway/desktop/render.c index f5206e5c0..6efeaf5dc 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c @@ -1409,7 +1409,7 @@ static void render_containers_linear(struct sway_output *output, bool has_titlebar = state->border == B_NORMAL; struct decoration_data deco_data = { - .alpha = child->current_alpha, + .alpha = child->alpha, .dim_color = view_is_urgent(view) ? config->dim_inactive_colors.urgent : config->dim_inactive_colors.unfocused, @@ -1459,7 +1459,7 @@ static void render_containers_tabbed(struct sway_output *output, int tab_width = parent->box.width / parent->children->length; struct decoration_data deco_data = { - .alpha = current->current_alpha, + .alpha = current->alpha, .dim_color = view_is_urgent(current->view) ? config->dim_inactive_colors.urgent : config->dim_inactive_colors.unfocused, @@ -1556,7 +1556,7 @@ static void render_containers_stacked(struct sway_output *output, size_t titlebar_height = container_titlebar_height(); struct decoration_data deco_data = { - .alpha = current->current_alpha, + .alpha = current->alpha, .dim_color = view_is_urgent(current->view) ? config->dim_inactive_colors.urgent : config->dim_inactive_colors.unfocused, @@ -1706,7 +1706,7 @@ static void render_floating_container(struct sway_output *soutput, bool has_titlebar = state->border == B_NORMAL; struct decoration_data deco_data = { - .alpha = con->current_alpha, + .alpha = con->alpha, .dim_color = view_is_urgent(view) ? config->dim_inactive_colors.urgent : config->dim_inactive_colors.unfocused, @@ -1939,7 +1939,7 @@ void output_render(struct sway_output *output, struct timespec *when, struct sway_container *focus = seat_get_focused_container(seat); if (focus && focus->view) { struct decoration_data deco_data = { - .alpha = focus->current_alpha, + .alpha = focus->alpha, .dim_color = view_is_urgent(focus->view) ? config->dim_inactive_colors.urgent : config->dim_inactive_colors.unfocused, diff --git a/sway/tree/container.c b/sway/tree/container.c index 04aacbffd..14e012256 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -39,8 +39,8 @@ struct sway_container *container_create(struct sway_view *view) { node_init(&c->node, N_CONTAINER, c); c->pending.layout = L_NONE; c->view = view; - c->current_alpha = 0.0f; - c->alpha = 1.0f; + c->alpha = 0.0f; + c->target_alpha = 1.0f; c->saturation = 1.0f; c->dim = config->default_dim_inactive; c->shadow_enabled = config->shadow_enabled;