renamed container alpha vars

This commit is contained in:
William McKinnon 2023-05-23 01:38:50 -04:00
parent 3f5511d09e
commit f721ef703d
5 changed files with 15 additions and 16 deletions

View file

@ -119,10 +119,9 @@ struct sway_container {
float saturation; float saturation;
// TODO: move current_alpha to state? // TODO: move alpha to state?
float current_alpha;
// TODO: rename me to something like max_alpha?
float alpha; float alpha;
float target_alpha;
int corner_radius; int corner_radius;

View file

@ -24,9 +24,9 @@ struct cmd_results *cmd_opacity(int argc, char **argv) {
} }
if (!strcasecmp(argv[0], "plus")) { if (!strcasecmp(argv[0], "plus")) {
val = con->alpha + val; val = con->target_alpha + val;
} else if (!strcasecmp(argv[0], "minus")) { } else if (!strcasecmp(argv[0], "minus")) {
val = con->alpha - val; val = con->target_alpha - val;
} else if (argc > 1 && strcasecmp(argv[0], "set")) { } else if (argc > 1 && strcasecmp(argv[0], "set")) {
return cmd_results_new(CMD_INVALID, return cmd_results_new(CMD_INVALID,
"Expected: set|plus|minus <0..1>: %s", argv[0]); "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"); return cmd_results_new(CMD_FAILURE, "opacity value out of bounds");
} }
con->alpha = val; con->target_alpha = val;
container_damage_whole(con); container_damage_whole(con);
return cmd_results_new(CMD_SUCCESS, NULL); return cmd_results_new(CMD_SUCCESS, NULL);
} }

View file

@ -532,10 +532,10 @@ static void containers_tick_alpha(list_t *containers, struct sway_output *output
float alpha_step; float alpha_step;
for (int i = 0; i < containers->length; ++i) { for (int i = 0; i < containers->length; ++i) {
struct sway_container *con = containers->items[i]; struct sway_container *con = containers->items[i];
if (con->current_alpha < con->alpha) { if (con->alpha < con->target_alpha) {
alpha_step = (con->alpha) / num_refreshes; alpha_step = (con->target_alpha) / num_refreshes;
// ensure that the current alpha does not exceed the set alpha for the con // 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); output_damage_whole_container(output, con);
} }
} }

View file

@ -1430,7 +1430,7 @@ static void render_containers_linear(struct sway_output *output,
bool has_titlebar = state->border == B_NORMAL; bool has_titlebar = state->border == B_NORMAL;
struct decoration_data deco_data = { struct decoration_data deco_data = {
.alpha = child->current_alpha, .alpha = child->alpha,
.dim_color = view_is_urgent(view) .dim_color = view_is_urgent(view)
? config->dim_inactive_colors.urgent ? config->dim_inactive_colors.urgent
: config->dim_inactive_colors.unfocused, : config->dim_inactive_colors.unfocused,
@ -1481,7 +1481,7 @@ static void render_containers_tabbed(struct sway_output *output,
int tab_width = parent->box.width / parent->children->length; int tab_width = parent->box.width / parent->children->length;
struct decoration_data deco_data = { struct decoration_data deco_data = {
.alpha = current->current_alpha, .alpha = current->alpha,
.dim_color = current->view && view_is_urgent(current->view) .dim_color = current->view && view_is_urgent(current->view)
? config->dim_inactive_colors.urgent ? config->dim_inactive_colors.urgent
: config->dim_inactive_colors.unfocused, : config->dim_inactive_colors.unfocused,
@ -1579,7 +1579,7 @@ static void render_containers_stacked(struct sway_output *output,
size_t titlebar_height = container_titlebar_height(); size_t titlebar_height = container_titlebar_height();
struct decoration_data deco_data = { struct decoration_data deco_data = {
.alpha = current->current_alpha, .alpha = current->alpha,
.dim_color = current->view && view_is_urgent(current->view) .dim_color = current->view && view_is_urgent(current->view)
? config->dim_inactive_colors.urgent ? config->dim_inactive_colors.urgent
: config->dim_inactive_colors.unfocused, : config->dim_inactive_colors.unfocused,
@ -1730,7 +1730,7 @@ static void render_floating_container(struct sway_output *soutput,
bool has_titlebar = state->border == B_NORMAL; bool has_titlebar = state->border == B_NORMAL;
struct decoration_data deco_data = { struct decoration_data deco_data = {
.alpha = con->current_alpha, .alpha = con->alpha,
.dim_color = view_is_urgent(view) .dim_color = view_is_urgent(view)
? config->dim_inactive_colors.urgent ? config->dim_inactive_colors.urgent
: config->dim_inactive_colors.unfocused, : config->dim_inactive_colors.unfocused,
@ -1988,7 +1988,7 @@ void output_render(struct sway_output *output, struct timespec *when,
struct sway_container *focus = seat_get_focused_container(seat); struct sway_container *focus = seat_get_focused_container(seat);
if (focus && focus->view) { if (focus && focus->view) {
struct decoration_data deco_data = { struct decoration_data deco_data = {
.alpha = focus->current_alpha, .alpha = focus->alpha,
.dim_color = view_is_urgent(focus->view) .dim_color = view_is_urgent(focus->view)
? config->dim_inactive_colors.urgent ? config->dim_inactive_colors.urgent
: config->dim_inactive_colors.unfocused, : config->dim_inactive_colors.unfocused,

View file

@ -39,8 +39,8 @@ struct sway_container *container_create(struct sway_view *view) {
node_init(&c->node, N_CONTAINER, c); node_init(&c->node, N_CONTAINER, c);
c->pending.layout = L_NONE; c->pending.layout = L_NONE;
c->view = view; c->view = view;
c->current_alpha = 0.0f; c->alpha = 0.0f;
c->alpha = 1.0f; c->target_alpha = 1.0f;
c->saturation = 1.0f; c->saturation = 1.0f;
c->dim = config->default_dim_inactive; c->dim = config->default_dim_inactive;
c->shadow_enabled = config->shadow_enabled; c->shadow_enabled = config->shadow_enabled;