X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=driver%2Flock.c;h=194752d1cf5e4404882a4b95ef725dc0b6a8f4f1;hb=72c1f4c1dc6ab07fe121a327ff1c30bf51ef74c1;hp=31d9138fc98aacd87a8173f42d1a5a5d3b6efe6c;hpb=af290bcdf2d1c61efc8aaaff653745c900cbe98c;p=xscreensaver diff --git a/driver/lock.c b/driver/lock.c index 31d9138f..194752d1 100644 --- a/driver/lock.c +++ b/driver/lock.c @@ -17,12 +17,13 @@ # include "config.h" #endif -#ifndef NO_LOCKING /* whole file */ - #include +#include /* for time() */ #include "xscreensaver.h" #include "resources.h" +#ifndef NO_LOCKING /* (mostly) whole file */ + #ifdef HAVE_SYSLOG # include #endif /* HAVE_SYSLOG */ @@ -89,6 +90,7 @@ struct passwd_dialog_data { char *body_label; char *user_label; char *passwd_label; + char *date_label; char *user_string; char *passwd_string; @@ -96,6 +98,7 @@ struct passwd_dialog_data { XFontStruct *body_font; XFontStruct *label_font; XFontStruct *passwd_font; + XFontStruct *date_font; Pixel foreground; Pixel background; @@ -149,6 +152,7 @@ make_passwd_window (saver_info *si) "Dialog.Label.Label"); pw->passwd_label = get_string_resource ("passwd.passwd.label", "Dialog.Label.Label"); + pw->date_label = get_string_resource ("dateFormat", "DateFormat"); if (!pw->heading_label) pw->heading_label = strdup("ERROR: REESOURCES NOT INSTALLED CORRECTLY"); @@ -156,6 +160,7 @@ make_passwd_window (saver_info *si) pw->body_label = strdup("ERROR: REESOURCES NOT INSTALLED CORRECTLY"); if (!pw->user_label) pw->user_label = strdup("ERROR"); if (!pw->passwd_label) pw->passwd_label = strdup("ERROR"); + if (!pw->date_label) pw->date_label = strdup("ERROR"); /* Put the version number in the label. */ { @@ -188,6 +193,11 @@ make_passwd_window (saver_info *si) if (!pw->passwd_font) pw->passwd_font = XLoadQueryFont (si->dpy, "fixed"); if (f) free (f); + f = get_string_resource("passwd.dateFont", "Dialog.Font"); + pw->date_font = XLoadQueryFont (si->dpy, (f ? f : "fixed")); + if (!pw->date_font) pw->date_font = XLoadQueryFont (si->dpy, "fixed"); + if (f) free (f); + pw->foreground = get_pixel_resource ("passwd.foreground", "Dialog.Foreground", si->dpy, cmap); @@ -396,7 +406,9 @@ draw_passwd_window (saver_info *si) pw->body_font->ascent + pw->body_font->descent + (2 * MAX ((pw->label_font->ascent + pw->label_font->descent), (pw->passwd_font->ascent + pw->passwd_font->descent + - (pw->shadow_width * 4))))); + (pw->shadow_width * 4)))) + + pw->date_font->ascent + pw->date_font->descent + ); spacing = ((pw->height - (2 * pw->shadow_width) - pw->internal_border - height)) / 8; if (spacing < 0) spacing = 0; @@ -504,6 +516,26 @@ draw_passwd_window (saver_info *si) pw->shadow_width, pw->shadow_bottom, pw->shadow_top); + + /* The date, below the text fields + */ + { + char buf[100]; + time_t now = time ((time_t *) 0); + struct tm *tm = localtime (&now); + memset (buf, 0, sizeof(buf)); + strftime (buf, sizeof(buf)-1, pw->date_label, tm); + + XSetFont (si->dpy, gc1, pw->date_font->fid); + y1 += pw->shadow_width; + y1 += (spacing + tb_height); + y1 += spacing/2; + sw = string_width (pw->date_font, buf); + x2 = x1 + x2 - sw; + XDrawString (si->dpy, si->passwd_dialog, gc1, x2, y1, buf, strlen(buf)); + } + + /* the logo */ XSetForeground (si->dpy, gc1, pw->logo_foreground); @@ -1132,6 +1164,30 @@ passwd_event_loop (saver_info *si) } +static void +handle_typeahead (saver_info *si) +{ + passwd_dialog_data *pw = si->pw_data; + int i; + if (!si->unlock_typeahead) + return; + + i = strlen (si->unlock_typeahead); + if (i >= sizeof(pw->typed_passwd) - 1) + i = sizeof(pw->typed_passwd) - 1; + + memcpy (pw->typed_passwd, si->unlock_typeahead, i); + pw->typed_passwd [i] = 0; + + memset (si->unlock_typeahead, '*', strlen(si->unlock_typeahead)); + si->unlock_typeahead[i] = 0; + update_passwd_window (si, si->unlock_typeahead, pw->ratio); + + free (si->unlock_typeahead); + si->unlock_typeahead = 0; +} + + Bool unlock_p (saver_info *si) { @@ -1151,6 +1207,7 @@ unlock_p (saver_info *si) make_passwd_window (si); if (cmap) XInstallColormap (si->dpy, cmap); + handle_typeahead (si); passwd_event_loop (si); status = (si->pw_data->state == pw_ok); @@ -1177,6 +1234,8 @@ set_locked_p (saver_info *si, Bool locked_p) #ifdef HAVE_XF86VMODE xfree_lock_mode_switch (si, locked_p); /* turn off/on C-Alt-Plus */ #endif + + store_saver_status (si); /* store locked-p */ }