commit 5300d9cac2b8568c29f8898f04f2bc115adf7f11
parent 663b34e4e032efe783cebcba6e0802a7e23356bb
Author: Rio6 <rio.liu@r26.me>
Date: Sun, 24 Jan 2021 15:17:29 -0500
Update draw_bar to match old behaviour
Diffstat:
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/unlock_indicator.c b/unlock_indicator.c
@@ -319,8 +319,7 @@ static void draw_single_bar(cairo_t *ctx, double pos, double offset, double widt
if (bar_reversed) {
offset -= height;
} else if (bar_bidirectional) {
- offset -= height;
- height *= 2;
+ offset -= height / 2;
}
if (bar_orientation == BAR_VERT)
@@ -332,6 +331,8 @@ static void draw_single_bar(cairo_t *ctx, double pos, double offset, double widt
static void draw_bar(cairo_t *ctx, double bar_offset, double screen_x, double screen_y, double screen_w, double screen_h) {
+ cairo_save(ctx);
+
switch (auth_state) {
case STATE_AUTH_VERIFY:
case STATE_AUTH_LOCK:
@@ -356,6 +357,8 @@ static void draw_bar(cairo_t *ctx, double bar_offset, double screen_x, double sc
else
cairo_set_source_rgba(ctx, keyhl16.red, keyhl16.green, keyhl16.blue, keyhl16.alpha);
+ cairo_set_operator(ctx, CAIRO_OPERATOR_SOURCE);
+
double bar_width, screen_pos;
if (bar_orientation == BAR_VERT) {
bar_width = screen_h / bar_count;
@@ -367,6 +370,7 @@ static void draw_bar(cairo_t *ctx, double bar_offset, double screen_x, double sc
for (int i = 0; i < bar_count; ++i) {
double bar_height = bar_heights[i];
+ if (bar_bidirectional) bar_height *= 2;
if (bar_height > 0) {
draw_single_bar(ctx, screen_pos + i * bar_width, bar_offset, bar_width, bar_height);
}
@@ -377,6 +381,8 @@ static void draw_bar(cairo_t *ctx, double bar_offset, double screen_x, double sc
bar_heights[i] -= bar_periodic_step;
}
}
+
+ cairo_restore(ctx);
}
static void draw_indic(cairo_t *ctx, double ind_x, double ind_y) {