updated --clock option so that it still is displayed when -f opton is set

pull/47/head
Ark444 2015-12-05 18:54:11 +01:00
parent e04fb89171
commit ecf2641010
1 changed files with 36 additions and 15 deletions

View File

@ -211,21 +211,6 @@ xcb_pixmap_t draw_image(uint32_t *resolution) {
text = "wrong!";
break;
default:
if (display_clock) {
time_t tm;
tm = time(NULL);
if (tm != ((time_t) -1)) {
text = ctime(&tm);
while (*text && *text != ':')
++text;
if (*text && strlen(text) > 8) {
text -= 2;
text[8] = 0;
}
}
cairo_set_source_rgb(ctx, 0.75, 0.75, 0.75);
}
if (show_failed_attempts && failed_attempts > 0) {
if (failed_attempts > 999) {
text = "> 999";
@ -247,12 +232,48 @@ xcb_pixmap_t draw_image(uint32_t *resolution) {
x = BUTTON_CENTER - ((extents.width / 2) + extents.x_bearing);
y = BUTTON_CENTER - ((extents.height / 2) + extents.y_bearing);
if (display_clock && pam_state == STATE_PAM_IDLE) {
y += (extents.height);
}
cairo_move_to(ctx, x, y);
cairo_show_text(ctx, text);
cairo_close_path(ctx);
}
if (display_clock && pam_state == STATE_PAM_IDLE) {
char *time_ptr = NULL;
time_t tm;
tm = time(NULL);
if (tm != ((time_t) -1)) {
time_ptr = ctime(&tm);
while (*time_ptr && *time_ptr != ':')
++time_ptr;
if (*time_ptr && strlen(time_ptr) > 5) {
time_ptr -= 2;
time_ptr[5] = '\0';
}
}
cairo_set_font_size(ctx, 28.0);
cairo_set_source_rgb(ctx, 0.75, 0.75, 0.75);
cairo_text_extents_t extents;
double x, y;
cairo_text_extents(ctx, time_ptr, &extents);
x = BUTTON_CENTER - ((extents.width / 2) + extents.x_bearing);
y = BUTTON_CENTER - ((extents.height / 2) + extents.y_bearing);
if (text) {
y -= (extents.height);
}
cairo_move_to(ctx, x, y);
cairo_show_text(ctx, time_ptr);
cairo_close_path(ctx);
}
if (pam_state == STATE_PAM_WRONG && (modifier_string != NULL)) {
cairo_text_extents_t extents;
double x, y;