diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -14,6 +14,7 @@ #include <stdlib.h> #include <time.h> #include <unistd.h> +#include <locale.h> static const int kXSecureLockCharFD = 0; @@ -93,7 +94,9 @@ static void handle_xsl_key_input(saver_state_t *state, const char c) break; case '\r': // Return. case '\n': // Return. - accept_password(state); + if(pw_len > 0) { + accept_password(state); + } break; default: if (pw_len + 1 < kMaxPasswordLength) { @@ -108,6 +111,7 @@ static void handle_xsl_key_input(saver_state_t *state, const char c) // (See comment above for why this is separate) static bool handle_key_event(saver_state_t *state, XKeyEvent *event) { + static int forceEmptyPass = 0; if (!state->input_allowed) return false; KeySym key; @@ -123,7 +127,14 @@ static bool handle_key_event(saver_state_t *state, XKeyEvent *event) password_buf[length - 1] = '\0'; } } else if (XK_Return == key) { - accept_password(state); + char *password_buf = state->password_buffer; + size_t pw_len = strlen(password_buf); + + if( pw_len > 0 || forceEmptyPass) { + accept_password(state); + } else { + forceEmptyPass = 4; + } } else if (strlen(keybuf) > 0) { if (length + 1 < kMaxPasswordLength) { password_buf[length] = keybuf[0]; @@ -133,6 +144,8 @@ static bool handle_key_event(saver_state_t *state, XKeyEvent *event) handled = false; } + forceEmptyPass >>= 1; + return handled; } @@ -355,6 +368,8 @@ static void draw(saver_state_t *state) draw_logo(state); } + draw_date_field(state); + draw_password_field(state); // Automatically reset this after every draw call @@ -456,6 +471,7 @@ static int runloop(cairo_surface_t *surface) int main(int argc, char **argv) { + setlocale(LC_ALL, ""); cairo_surface_t *surface = x11_helper_acquire_cairo_surface(); if (surface == NULL) { fprintf(stderr, "Error creating cairo surface\n"); |