summaryrefslogtreecommitdiff
path: root/unlock_indicator.c
diff options
context:
space:
mode:
authorkoebi <koebischnell@googlemail.com>2014-07-24 22:32:07 +0200
committerMichael Stapelberg <michael@stapelberg.de>2014-08-24 23:27:00 +0200
commit0cbf483cb4a1597343df90642ac475b288ae9e80 (patch)
tree66dadbe94de7d2d2066d50f1a19f4b94e6b7e483 /unlock_indicator.c
parent7f450a52f60ac543540a8ef50fd6d440bf0d4c8a (diff)
implemented logging the number of failed attempts
This closes #1243
Diffstat (limited to 'unlock_indicator.c')
-rw-r--r--unlock_indicator.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/unlock_indicator.c b/unlock_indicator.c
index ac7db09..e543f96 100644
--- a/unlock_indicator.c
+++ b/unlock_indicator.c
@@ -52,6 +52,11 @@ extern bool tile;
/* The background color to use (in hex). */
extern char color[7];
+/* Whether the failed attempts should be displayed. */
+extern bool show_failed_attempts;
+/* Number of failed unlock attempts. */
+extern int failed_attempts;
+
/*******************************************************************************
* Variables defined in xcb.c.
******************************************************************************/
@@ -185,6 +190,11 @@ xcb_pixmap_t draw_image(uint32_t *resolution) {
/* Display a (centered) text of the current PAM state. */
char *text = NULL;
+ /* We don't want to show more than a 3-digit number. */
+ char buf[4];
+
+ cairo_set_source_rgb(ctx, 0, 0, 0);
+ cairo_set_font_size(ctx, 28.0);
switch (pam_state) {
case STATE_PAM_VERIFY:
text = "verifying…";
@@ -193,6 +203,16 @@ xcb_pixmap_t draw_image(uint32_t *resolution) {
text = "wrong!";
break;
default:
+ if (show_failed_attempts && failed_attempts > 0){
+ if (failed_attempts > 999) {
+ text = "> 999";
+ } else {
+ snprintf(buf, sizeof(buf), "%d", failed_attempts);
+ text = buf;
+ }
+ cairo_set_source_rgb(ctx, 1, 0, 0);
+ cairo_set_font_size(ctx, 32.0);
+ }
break;
}
@@ -200,9 +220,6 @@ xcb_pixmap_t draw_image(uint32_t *resolution) {
cairo_text_extents_t extents;
double x, y;
- cairo_set_source_rgb(ctx, 0, 0, 0);
- cairo_set_font_size(ctx, 28.0);
-
cairo_text_extents(ctx, text, &extents);
x = BUTTON_CENTER - ((extents.width / 2) + extents.x_bearing);
y = BUTTON_CENTER - ((extents.height / 2) + extents.y_bearing);