Skip to content

Commit

Permalink
renamed container alpha vars
Browse files Browse the repository at this point in the history
  • Loading branch information
WillPower3309 committed May 23, 2023
1 parent a4be8ef commit 475ab70
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
5 changes: 2 additions & 3 deletions include/sway/tree/container.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions sway/commands/opacity.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand All @@ -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);
}
6 changes: 3 additions & 3 deletions sway/desktop/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
10 changes: 5 additions & 5 deletions sway/desktop/render.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions sway/tree/container.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 475ab70

Please sign in to comment.