# include "config.h"
#endif
-#ifndef NO_LOCKING /* whole file */
-
#include <X11/Intrinsic.h>
#include <X11/Xos.h> /* for time() */
#include "xscreensaver.h"
#include "resources.h"
+#ifndef NO_LOCKING /* (mostly) whole file */
+
#ifdef HAVE_SYSLOG
# include <syslog.h>
#endif /* HAVE_SYSLOG */
pw->heading_label = s;
}
- pw->user_string = (p->pw_name ? p->pw_name : "???");
+ pw->user_string = (p && p->pw_name ? p->pw_name : "???");
pw->passwd_string = strdup("");
f = get_string_resource ("passwd.headingFont", "Dialog.Font");
}
+static XComposeStatus *compose_status;
+
static void
handle_passwd_key (saver_info *si, XKeyEvent *event)
{
char s[2];
char *stars = 0;
int i;
- int size = XLookupString (event, s, 1, 0, 0);
+ int size = XLookupString (event, s, 1, 0, compose_status);
if (size != 1) return;
}
+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)
{
make_passwd_window (si);
if (cmap) XInstallColormap (si->dpy, cmap);
+ compose_status = calloc (1, sizeof (*compose_status));
+
+ handle_typeahead (si);
passwd_event_loop (si);
status = (si->pw_data->state == pw_ok);
destroy_passwd_window (si);
+ free (compose_status);
+ compose_status = 0;
+
cmap = si->default_screen->cmap;
if (cmap) XInstallColormap (si->dpy, cmap);
#ifdef HAVE_XF86VMODE
xfree_lock_mode_switch (si, locked_p); /* turn off/on C-Alt-Plus */
#endif
+
+ store_saver_status (si); /* store locked-p */
}