Lines 23-28
Link Here
|
23 |
#include <X11/Xos.h> /* for time() */ |
23 |
#include <X11/Xos.h> /* for time() */ |
24 |
#include <time.h> |
24 |
#include <time.h> |
25 |
#include <sys/time.h> |
25 |
#include <sys/time.h> |
|
|
26 |
#include <errno.h> |
27 |
#include <signal.h> |
26 |
#include "xscreensaver.h" |
28 |
#include "xscreensaver.h" |
27 |
#include "resources.h" |
29 |
#include "resources.h" |
28 |
|
30 |
|
Lines 156-161
Link Here
|
156 |
Bool login_button_enabled_p; |
158 |
Bool login_button_enabled_p; |
157 |
|
159 |
|
158 |
Pixmap save_under; |
160 |
Pixmap save_under; |
|
|
161 |
|
162 |
#ifdef HAVE_XSCREENSAVER_LOCK |
163 |
/* extern passwd dialog stuff */ |
164 |
XtInputId stdout_input_id; |
165 |
int stdin_fd; |
166 |
int stdout_fd; |
167 |
Bool got_windowid; |
168 |
FILE *input_file; |
169 |
#endif |
159 |
}; |
170 |
}; |
160 |
|
171 |
|
161 |
static void draw_passwd_window (saver_info *si); |
172 |
static void draw_passwd_window (saver_info *si); |
Lines 165-170
Link Here
|
165 |
static void undo_vp_motion (saver_info *si); |
176 |
static void undo_vp_motion (saver_info *si); |
166 |
static void handle_passwd_button (saver_info *si, XEvent *event); |
177 |
static void handle_passwd_button (saver_info *si, XEvent *event); |
167 |
|
178 |
|
|
|
179 |
extern Atom XA_UNLOCK_RATIO; |
180 |
|
181 |
#if defined (HAVE_XF86VMODE) || defined (HAVE_XSCREENSAVER_LOCK) |
182 |
static Bool vp_got_error = False; |
183 |
static int |
184 |
ignore_all_errors_ehandler (Display *dpy, XErrorEvent *error) |
185 |
{ |
186 |
vp_got_error = True; |
187 |
return 0; |
188 |
} |
189 |
#endif /* defined (HAVE_XF86VMODE) || defined (HAVE_XSCREENSAVER_LOCK) */ |
190 |
#ifdef HAVE_XSCREENSAVER_LOCK |
191 |
static int |
192 |
sane_dup2 (int fd1, int fd2) |
193 |
{ |
194 |
int ret; |
195 |
|
196 |
retry: |
197 |
ret = dup2 (fd1, fd2); |
198 |
if (ret < 0 && errno == EINTR) |
199 |
goto retry; |
200 |
|
201 |
return ret; |
202 |
} |
203 |
|
204 |
static int |
205 |
close_and_invalidate (int *fd) |
206 |
{ |
207 |
int ret; |
208 |
|
209 |
ret = close (*fd); |
210 |
*fd = -1; |
211 |
|
212 |
return ret; |
213 |
} |
214 |
|
215 |
static void |
216 |
handle_passwd_input (XtPointer data, int *fd, XtInputId *id) |
217 |
{ |
218 |
saver_info *si = (saver_info *)data; |
219 |
saver_preferences *p = &si->prefs; |
220 |
char buffer[1024]; |
221 |
char *s; |
222 |
|
223 |
if (si->prefs.verbose_p) |
224 |
fprintf (stderr, "passwd input handler\n"); |
225 |
|
226 |
s = fgets (buffer, sizeof (buffer), si->pw_data->input_file); |
227 |
if (!s) |
228 |
{ |
229 |
if (si->prefs.verbose_p) |
230 |
{ |
231 |
fprintf (stderr, "done reading...\n"); |
232 |
fprintf (stderr, "removing input handler...\n"); |
233 |
} |
234 |
XtRemoveInput (*id); |
235 |
si->pw_data->stdout_input_id = 0; |
236 |
|
237 |
if (si->pw_data->state == pw_read) |
238 |
si->pw_data->state = pw_null; |
239 |
|
240 |
return; |
241 |
} |
242 |
|
243 |
if (si->pw_data->got_windowid) |
244 |
{ |
245 |
char *nl; |
246 |
if (si->prefs.verbose_p) |
247 |
fprintf (stderr, "got a password\n"); |
248 |
nl = strchr (s, '\n'); |
249 |
if (nl) |
250 |
*nl = '\0'; |
251 |
if (passwd_valid_p (s, p->verbose_p)) |
252 |
si->pw_data->state = pw_ok; |
253 |
else |
254 |
si->pw_data->state = pw_fail; |
255 |
} |
256 |
else |
257 |
{ |
258 |
Window window = strtoul (s, NULL, 0); |
259 |
/* FIXME: what to revert to? */ |
260 |
XSetInputFocus (si->dpy, window, RevertToParent, CurrentTime); |
261 |
si->pw_data->got_windowid = True; |
262 |
si->passwd_dialog = window; |
263 |
if (si->prefs.verbose_p) |
264 |
fprintf (stderr, "tried to focus: %lu\n", (unsigned long)window); |
265 |
} |
266 |
} |
267 |
|
268 |
/* returns successful fork/exec */ |
269 |
static Bool |
270 |
spawn_external_passwd_process (saver_info *si, passwd_dialog_data *pw) |
271 |
{ |
272 |
saver_preferences *p = &si->prefs; |
273 |
pid_t forked; |
274 |
const char *command = LOCKDIR "/xscreensaver-lock"; |
275 |
int stdin_pipe[2] = { -1, -1 }; |
276 |
int stdout_pipe[2] = { -1, -1 }; |
277 |
|
278 |
si->passwd_pid = 0; |
279 |
pw->stdin_fd = pw->stdout_fd = -1; |
280 |
pw->got_windowid = False; |
281 |
|
282 |
if (pipe (stdin_pipe) < 0) |
283 |
return False; |
284 |
|
285 |
if (pipe (stdout_pipe) < 0) |
286 |
{ |
287 |
close_and_invalidate (&stdin_pipe[0]); |
288 |
close_and_invalidate (&stdin_pipe[1]); |
289 |
return False; |
290 |
} |
291 |
switch ((int) (forked = fork ())) |
292 |
{ |
293 |
case -1: |
294 |
fprintf (stderr, "%s: ", blurb ()); |
295 |
perror ("couldn't fork"); |
296 |
|
297 |
close_and_invalidate (&stdin_pipe[0]); |
298 |
close_and_invalidate (&stdin_pipe[1]); |
299 |
close_and_invalidate (&stdout_pipe[0]); |
300 |
close_and_invalidate (&stdout_pipe[1]); |
301 |
|
302 |
return False; |
303 |
|
304 |
case 0: |
305 |
close (ConnectionNumber (si->dpy)); /* close display fd */ |
306 |
/* limit_subproc_memory (p->inferior_memory_limit, p->verbose_p); */ |
307 |
/* hack_subproc_environment (ssi); */ /* FIX $DISPLAY */ |
308 |
|
309 |
if (p->verbose_p) |
310 |
fprintf (stderr, "%s: spawning \"%s\" in pid %lu.\n", |
311 |
blurb(), command, (unsigned long) getpid ()); |
312 |
|
313 |
close_and_invalidate (&stdin_pipe[1]); |
314 |
close_and_invalidate (&stdout_pipe[0]); |
315 |
|
316 |
sane_dup2 (stdin_pipe[0], 0); |
317 |
sane_dup2 (stdout_pipe[1], 1); |
318 |
|
319 |
exec_command (p->shell, command, 0); |
320 |
/* print_path_error (command); */ |
321 |
fprintf (stderr, "%s: couldn't exec: %s\n", |
322 |
blurb (), command); |
323 |
abort (); |
324 |
|
325 |
default: |
326 |
|
327 |
close_and_invalidate (&stdin_pipe[0]); |
328 |
close_and_invalidate (&stdout_pipe[1]); |
329 |
|
330 |
pw->stdin_fd = stdin_pipe[1]; |
331 |
pw->stdout_fd = stdout_pipe[0]; |
332 |
si->passwd_pid = forked; |
333 |
|
334 |
pw->input_file = fdopen (pw->stdout_fd, "r"); |
335 |
|
336 |
pw->stdout_input_id = XtAppAddInput (si->app, pw->stdout_fd, |
337 |
(XtPointer) XtInputReadMask, |
338 |
handle_passwd_input, |
339 |
si); |
340 |
return True; |
341 |
} |
342 |
|
343 |
/* shouldn't reach */ |
344 |
abort (); |
345 |
return False; |
346 |
} |
347 |
#endif /* HAVE_XSCREENSAVER_LOCK */ |
168 |
|
348 |
|
169 |
static void |
349 |
static void |
170 |
make_passwd_window (saver_info *si) |
350 |
make_passwd_window (saver_info *si) |
Lines 178-183
Link Here
|
178 |
char *f; |
358 |
char *f; |
179 |
saver_screen_info *ssi = &si->screens [mouse_screen (si)]; |
359 |
saver_screen_info *ssi = &si->screens [mouse_screen (si)]; |
180 |
|
360 |
|
|
|
361 |
#ifdef HAVE_XSCREENSAVER_LOCK |
362 |
if (spawn_external_passwd_process (si, pw)) |
363 |
{ |
364 |
pw->ratio = 1.0; |
365 |
si->pw_data = pw; |
366 |
si->external_passwd = True; |
367 |
return; |
368 |
} |
369 |
|
370 |
si->external_passwd = False; |
371 |
/* FIXME: don't abort() */ |
372 |
abort (); |
373 |
#endif |
374 |
|
181 |
/* Display the button only if the "newLoginCommand" pref is non-null. |
375 |
/* Display the button only if the "newLoginCommand" pref is non-null. |
182 |
*/ |
376 |
*/ |
183 |
pw->login_button_p = (si->prefs.new_login_command && |
377 |
pw->login_button_p = (si->prefs.new_login_command && |
Lines 993-1110
Link Here
|
993 |
{ |
1187 |
{ |
994 |
saver_preferences *p = &si->prefs; |
1188 |
saver_preferences *p = &si->prefs; |
995 |
passwd_dialog_data *pw = si->pw_data; |
1189 |
passwd_dialog_data *pw = si->pw_data; |
996 |
saver_screen_info *ssi = pw->prompt_screen; |
1190 |
saver_screen_info *ssi; |
997 |
Colormap cmap = DefaultColormapOfScreen (ssi->screen); |
1191 |
Colormap cmap; |
998 |
Pixel black = BlackPixelOfScreen (ssi->screen); |
1192 |
Pixel black, white; |
999 |
Pixel white = WhitePixelOfScreen (ssi->screen); |
|
|
1000 |
XEvent event; |
1193 |
XEvent event; |
1001 |
|
1194 |
|
1002 |
memset (pw->typed_passwd, 0, sizeof(pw->typed_passwd)); |
1195 |
if (si->prefs.verbose_p) |
1003 |
memset (pw->passwd_string, 0, strlen(pw->passwd_string)); |
1196 |
fprintf (stderr, "destroy_passwd_window\n"); |
1004 |
|
1197 |
|
1005 |
if (pw->timer) |
1198 |
if (pw->timer) |
1006 |
XtRemoveTimeOut (pw->timer); |
1199 |
XtRemoveTimeOut (pw->timer); |
1007 |
|
1200 |
|
1008 |
move_mouse_grab (si, RootWindowOfScreen (ssi->screen), |
1201 |
#ifdef HAVE_XSCREENSAVER_LOCK |
1009 |
ssi->cursor, ssi->number); |
1202 |
if (si->external_passwd) |
|
|
1203 |
{ |
1204 |
/* kill the child etc. */ |
1010 |
|
1205 |
|
|
|
1206 |
|
1011 |
if (pw->passwd_cursor) |
1207 |
if (pw->passwd_cursor) |
1012 |
XFreeCursor (si->dpy, pw->passwd_cursor); |
1208 |
XFreeCursor (si->dpy, pw->passwd_cursor); |
1013 |
|
1209 |
|
1014 |
if (p->verbose_p) |
1210 |
if (si->passwd_dialog) |
1015 |
fprintf (stderr, "%s: %d: moving mouse back to %d,%d.\n", |
1211 |
{ |
1016 |
blurb(), ssi->number, |
1212 |
XErrorHandler old_handler; |
1017 |
pw->previous_mouse_x, pw->previous_mouse_y); |
1213 |
|
1018 |
|
1214 |
XSync (si->dpy, False); |
1019 |
XWarpPointer (si->dpy, None, RootWindowOfScreen (ssi->screen), |
1215 |
old_handler = XSetErrorHandler (ignore_all_errors_ehandler); |
1020 |
0, 0, 0, 0, |
1216 |
|
1021 |
pw->previous_mouse_x, pw->previous_mouse_y); |
1217 |
XDestroyWindow (si->dpy, si->passwd_dialog); |
|
|
1218 |
XSync (si->dpy, False); |
1219 |
XSetErrorHandler (old_handler); |
1220 |
si->passwd_dialog = 0; |
1221 |
} |
1022 |
|
1222 |
|
1023 |
XSync (si->dpy, False); |
1223 |
if (pw->stdout_input_id) |
1024 |
while (XCheckMaskEvent (si->dpy, PointerMotionMask, &event)) |
1224 |
XtRemoveInput (pw->stdout_input_id); |
1025 |
if (p->verbose_p) |
1225 |
if (pw->stdin_fd != -1) |
1026 |
fprintf (stderr, "%s: discarding MotionNotify event.\n", blurb()); |
1226 |
close_and_invalidate (&pw->stdin_fd); |
|
|
1227 |
if (pw->input_file) |
1228 |
fclose (pw->input_file); |
1229 |
else if (pw->stdout_fd != -1) |
1230 |
close_and_invalidate (&pw->stdout_fd); |
1027 |
|
1231 |
|
1028 |
if (si->passwd_dialog) |
1232 |
block_sigchld (); |
1029 |
{ |
1233 |
|
1030 |
XDestroyWindow (si->dpy, si->passwd_dialog); |
1234 |
if (si->passwd_pid) |
1031 |
si->passwd_dialog = 0; |
1235 |
{ |
1032 |
} |
1236 |
int status = -1; |
|
|
1237 |
|
1238 |
status = kill (si->passwd_pid, SIGTERM); |
1239 |
|
1240 |
await_dying_children (si); |
1241 |
|
1242 |
si->passwd_pid = 0; |
1243 |
} |
1244 |
|
1245 |
unblock_sigchld (); |
1246 |
|
1247 |
si->external_passwd = False; |
1248 |
} |
1033 |
|
1249 |
|
1034 |
if (pw->save_under) |
1250 |
else |
1035 |
{ |
1251 |
#endif /* HAVE_XSCREENSAVER_LOCK */ |
1036 |
XGCValues gcv; |
1252 |
{ |
1037 |
GC gc; |
|
|
1038 |
gcv.function = GXcopy; |
1039 |
gc = XCreateGC (si->dpy, ssi->screensaver_window, GCFunction, &gcv); |
1040 |
XCopyArea (si->dpy, pw->save_under, |
1041 |
ssi->screensaver_window, gc, |
1042 |
0, 0, |
1043 |
pw->width + (pw->border_width*2) + 1, |
1044 |
pw->height + (pw->border_width*2) + 1, |
1045 |
pw->x - pw->border_width, pw->y - pw->border_width); |
1046 |
XFreePixmap (si->dpy, pw->save_under); |
1047 |
pw->save_under = 0; |
1048 |
XFreeGC (si->dpy, gc); |
1049 |
} |
1050 |
|
1051 |
if (pw->heading_label) free (pw->heading_label); |
1052 |
if (pw->body_label) free (pw->body_label); |
1053 |
if (pw->user_label) free (pw->user_label); |
1054 |
if (pw->passwd_label) free (pw->passwd_label); |
1055 |
if (pw->date_label) free (pw->date_label); |
1056 |
if (pw->login_label) free (pw->login_label); |
1057 |
if (pw->user_string) free (pw->user_string); |
1058 |
if (pw->passwd_string) free (pw->passwd_string); |
1059 |
if (pw->uname_label) free (pw->uname_label); |
1060 |
|
1061 |
if (pw->heading_font) XFreeFont (si->dpy, pw->heading_font); |
1062 |
if (pw->body_font) XFreeFont (si->dpy, pw->body_font); |
1063 |
if (pw->label_font) XFreeFont (si->dpy, pw->label_font); |
1064 |
if (pw->passwd_font) XFreeFont (si->dpy, pw->passwd_font); |
1065 |
if (pw->date_font) XFreeFont (si->dpy, pw->date_font); |
1066 |
if (pw->button_font) XFreeFont (si->dpy, pw->button_font); |
1067 |
if (pw->uname_font) XFreeFont (si->dpy, pw->uname_font); |
1068 |
|
1069 |
if (pw->foreground != black && pw->foreground != white) |
1070 |
XFreeColors (si->dpy, cmap, &pw->foreground, 1, 0L); |
1071 |
if (pw->background != black && pw->background != white) |
1072 |
XFreeColors (si->dpy, cmap, &pw->background, 1, 0L); |
1073 |
if (!(pw->button_foreground == black || pw->button_foreground == white)) |
1074 |
XFreeColors (si->dpy, cmap, &pw->button_foreground, 1, 0L); |
1075 |
if (!(pw->button_background == black || pw->button_background == white)) |
1076 |
XFreeColors (si->dpy, cmap, &pw->button_background, 1, 0L); |
1077 |
if (pw->passwd_foreground != black && pw->passwd_foreground != white) |
1078 |
XFreeColors (si->dpy, cmap, &pw->passwd_foreground, 1, 0L); |
1079 |
if (pw->passwd_background != black && pw->passwd_background != white) |
1080 |
XFreeColors (si->dpy, cmap, &pw->passwd_background, 1, 0L); |
1081 |
if (pw->thermo_foreground != black && pw->thermo_foreground != white) |
1082 |
XFreeColors (si->dpy, cmap, &pw->thermo_foreground, 1, 0L); |
1083 |
if (pw->thermo_background != black && pw->thermo_background != white) |
1084 |
XFreeColors (si->dpy, cmap, &pw->thermo_background, 1, 0L); |
1085 |
if (pw->shadow_top != black && pw->shadow_top != white) |
1086 |
XFreeColors (si->dpy, cmap, &pw->shadow_top, 1, 0L); |
1087 |
if (pw->shadow_bottom != black && pw->shadow_bottom != white) |
1088 |
XFreeColors (si->dpy, cmap, &pw->shadow_bottom, 1, 0L); |
1089 |
|
1253 |
|
1090 |
if (pw->logo_pixmap) |
1254 |
memset (pw->typed_passwd, 0, sizeof(pw->typed_passwd)); |
1091 |
XFreePixmap (si->dpy, pw->logo_pixmap); |
1255 |
memset (pw->passwd_string, 0, strlen(pw->passwd_string)); |
1092 |
if (pw-> logo_clipmask) |
1256 |
|
1093 |
XFreePixmap (si->dpy, pw->logo_clipmask); |
1257 |
ssi = pw->prompt_screen; |
1094 |
if (pw->logo_pixels) |
1258 |
cmap = DefaultColormapOfScreen (ssi->screen); |
1095 |
{ |
1259 |
black = BlackPixelOfScreen (ssi->screen); |
1096 |
if (pw->logo_npixels) |
1260 |
white = WhitePixelOfScreen (ssi->screen); |
1097 |
XFreeColors (si->dpy, cmap, pw->logo_pixels, pw->logo_npixels, 0L); |
1261 |
|
1098 |
free (pw->logo_pixels); |
1262 |
move_mouse_grab (si, RootWindowOfScreen (ssi->screen), |
1099 |
pw->logo_pixels = 0; |
1263 |
ssi->cursor, ssi->number); |
1100 |
pw->logo_npixels = 0; |
1264 |
|
1101 |
} |
1265 |
if (p->verbose_p) |
|
|
1266 |
fprintf (stderr, "%s: %d: moving mouse back to %d,%d.\n", |
1267 |
blurb(), ssi->number, |
1268 |
pw->previous_mouse_x, pw->previous_mouse_y); |
1269 |
|
1270 |
XWarpPointer (si->dpy, None, RootWindowOfScreen (ssi->screen), |
1271 |
0, 0, 0, 0, |
1272 |
pw->previous_mouse_x, pw->previous_mouse_y); |
1273 |
|
1274 |
XSync (si->dpy, False); |
1275 |
while (XCheckMaskEvent (si->dpy, PointerMotionMask, &event)) |
1276 |
if (p->verbose_p) |
1277 |
fprintf (stderr, "%s: discarding MotionNotify event.\n", blurb()); |
1278 |
|
1279 |
if (si->passwd_dialog) |
1280 |
{ |
1281 |
XDestroyWindow (si->dpy, si->passwd_dialog); |
1282 |
si->passwd_dialog = 0; |
1283 |
} |
1284 |
|
1285 |
if (pw->save_under) |
1286 |
{ |
1287 |
XGCValues gcv; |
1288 |
GC gc; |
1289 |
gcv.function = GXcopy; |
1290 |
gc = XCreateGC (si->dpy, ssi->screensaver_window, GCFunction, &gcv); |
1291 |
XCopyArea (si->dpy, pw->save_under, |
1292 |
ssi->screensaver_window, gc, |
1293 |
0, 0, |
1294 |
pw->width + (pw->border_width*2) + 1, |
1295 |
pw->height + (pw->border_width*2) + 1, |
1296 |
pw->x - pw->border_width, pw->y - pw->border_width); |
1297 |
XFreePixmap (si->dpy, pw->save_under); |
1298 |
pw->save_under = 0; |
1299 |
XFreeGC (si->dpy, gc); |
1300 |
} |
1301 |
|
1302 |
if (pw->heading_label) free (pw->heading_label); |
1303 |
if (pw->body_label) free (pw->body_label); |
1304 |
if (pw->user_label) free (pw->user_label); |
1305 |
if (pw->passwd_label) free (pw->passwd_label); |
1306 |
if (pw->date_label) free (pw->date_label); |
1307 |
if (pw->user_string) free (pw->user_string); |
1308 |
if (pw->passwd_string) free (pw->passwd_string); |
1309 |
|
1310 |
if (pw->heading_font) XFreeFont (si->dpy, pw->heading_font); |
1311 |
if (pw->body_font) XFreeFont (si->dpy, pw->body_font); |
1312 |
if (pw->label_font) XFreeFont (si->dpy, pw->label_font); |
1313 |
if (pw->passwd_font) XFreeFont (si->dpy, pw->passwd_font); |
1314 |
if (pw->date_font) XFreeFont (si->dpy, pw->date_font); |
1315 |
|
1316 |
if (pw->foreground != black && pw->foreground != white) |
1317 |
XFreeColors (si->dpy, cmap, &pw->foreground, 1, 0L); |
1318 |
if (pw->background != black && pw->background != white) |
1319 |
XFreeColors (si->dpy, cmap, &pw->background, 1, 0L); |
1320 |
if (pw->passwd_foreground != black && pw->passwd_foreground != white) |
1321 |
XFreeColors (si->dpy, cmap, &pw->passwd_foreground, 1, 0L); |
1322 |
if (pw->passwd_background != black && pw->passwd_background != white) |
1323 |
XFreeColors (si->dpy, cmap, &pw->passwd_background, 1, 0L); |
1324 |
if (pw->thermo_foreground != black && pw->thermo_foreground != white) |
1325 |
XFreeColors (si->dpy, cmap, &pw->thermo_foreground, 1, 0L); |
1326 |
if (pw->thermo_background != black && pw->thermo_background != white) |
1327 |
XFreeColors (si->dpy, cmap, &pw->thermo_background, 1, 0L); |
1328 |
if (pw->shadow_top != black && pw->shadow_top != white) |
1329 |
XFreeColors (si->dpy, cmap, &pw->shadow_top, 1, 0L); |
1330 |
if (pw->shadow_bottom != black && pw->shadow_bottom != white) |
1331 |
XFreeColors (si->dpy, cmap, &pw->shadow_bottom, 1, 0L); |
1332 |
|
1333 |
if (pw->logo_pixmap) |
1334 |
XFreePixmap (si->dpy, pw->logo_pixmap); |
1335 |
if (pw->logo_pixels) |
1336 |
{ |
1337 |
if (pw->logo_npixels) |
1338 |
XFreeColors (si->dpy, cmap, pw->logo_pixels, pw->logo_npixels, 0L); |
1339 |
free (pw->logo_pixels); |
1340 |
pw->logo_pixels = 0; |
1341 |
pw->logo_npixels = 0; |
1342 |
} |
1102 |
|
1343 |
|
1103 |
if (pw->save_under) |
1344 |
if (pw->save_under) |
1104 |
XFreePixmap (si->dpy, pw->save_under); |
1345 |
XFreePixmap (si->dpy, pw->save_under); |
1105 |
|
1346 |
|
1106 |
if (cmap) |
1347 |
if (cmap) |
1107 |
XInstallColormap (si->dpy, cmap); |
1348 |
XInstallColormap (si->dpy, cmap); |
|
|
1349 |
} |
1108 |
|
1350 |
|
1109 |
memset (pw, 0, sizeof(*pw)); |
1351 |
memset (pw, 0, sizeof(*pw)); |
1110 |
free (pw); |
1352 |
free (pw); |
Lines 1114-1127
Link Here
|
1114 |
|
1356 |
|
1115 |
static Bool error_handler_hit_p = False; |
1357 |
static Bool error_handler_hit_p = False; |
1116 |
|
1358 |
|
1117 |
static int |
|
|
1118 |
ignore_all_errors_ehandler (Display *dpy, XErrorEvent *error) |
1119 |
{ |
1120 |
error_handler_hit_p = True; |
1121 |
return 0; |
1122 |
} |
1123 |
|
1124 |
|
1125 |
#ifdef HAVE_XHPDISABLERESET |
1359 |
#ifdef HAVE_XHPDISABLERESET |
1126 |
/* This function enables and disables the C-Sh-Reset hot-key, which |
1360 |
/* This function enables and disables the C-Sh-Reset hot-key, which |
1127 |
normally resets the X server (logging out the logged-in user.) |
1361 |
normally resets the X server (logging out the logged-in user.) |
Lines 1323-1330
Link Here
|
1323 |
if (pw->state == pw_read) |
1557 |
if (pw->state == pw_read) |
1324 |
pw->state = pw_time; |
1558 |
pw->state = pw_time; |
1325 |
} |
1559 |
} |
|
|
1560 |
#ifdef HAVE_XSCREENSAVER_LOCK |
1561 |
if (si->passwd_dialog) |
1562 |
{ |
1563 |
XEvent event; |
1564 |
Bool status; |
1565 |
XErrorHandler old_handler; |
1566 |
|
1567 |
event.xany.type = ClientMessage; |
1568 |
event.xclient.display = si->dpy; |
1569 |
event.xclient.window = si->passwd_dialog; |
1570 |
event.xclient.message_type = XA_UNLOCK_RATIO; |
1571 |
event.xclient.format = 32; |
1572 |
memset (&event.xclient.data, 0, sizeof (event.xclient.data)); |
1573 |
event.xclient.data.l[0] = (long)(pw->ratio * 100); |
1574 |
event.xclient.data.l[1] = 0; |
1575 |
event.xclient.data.l[2] = 0; |
1576 |
|
1577 |
XSync (si->dpy, False); |
1578 |
old_handler = XSetErrorHandler (ignore_all_errors_ehandler); |
1579 |
|
1580 |
status = XSendEvent (si->dpy, si->passwd_dialog, False, 0L, &event); |
1581 |
|
1582 |
XSync (si->dpy, False); |
1583 |
XSetErrorHandler (old_handler); |
1326 |
|
1584 |
|
|
|
1585 |
if (!status) |
1586 |
fprintf (stderr, "%s: error sending ratio to lock dialog\n", blurb ()); |
1587 |
|
1588 |
} |
1589 |
#else /* !HAVE_XSCREENSAVER_LOCK */ |
1327 |
update_passwd_window (si, 0, pw->ratio); |
1590 |
update_passwd_window (si, 0, pw->ratio); |
|
|
1591 |
#endif /* !HAVE_XSCREENSAVER_LOCK */ |
1328 |
|
1592 |
|
1329 |
if (pw->state == pw_read) |
1593 |
if (pw->state == pw_read) |
1330 |
pw->timer = XtAppAddTimeOut (si->app, tick, passwd_animate_timer, |
1594 |
pw->timer = XtAppAddTimeOut (si->app, tick, passwd_animate_timer, |
Lines 1480-1485
Link Here
|
1480 |
while (si->pw_data && si->pw_data->state == pw_read) |
1744 |
while (si->pw_data && si->pw_data->state == pw_read) |
1481 |
{ |
1745 |
{ |
1482 |
XtAppNextEvent (si->app, &event); |
1746 |
XtAppNextEvent (si->app, &event); |
|
|
1747 |
#ifdef HAVE_XSCREENSAVER_LOCK |
1748 |
if (event.xany.type == KeyPress) |
1749 |
{ |
1750 |
if (si->pw_data->got_windowid) |
1751 |
{ |
1752 |
Bool status; |
1753 |
XErrorHandler old_handler; |
1754 |
|
1755 |
event.xany.window = si->passwd_dialog; |
1756 |
|
1757 |
XSync (si->dpy, False); |
1758 |
old_handler = XSetErrorHandler (ignore_all_errors_ehandler); |
1759 |
|
1760 |
status = XSendEvent (si->dpy, si->passwd_dialog, False, KeyPressMask, &event); |
1761 |
|
1762 |
XSync (si->dpy, False); |
1763 |
XSetErrorHandler (old_handler); |
1764 |
|
1765 |
if (p->verbose_p) |
1766 |
{ |
1767 |
if (status) |
1768 |
fprintf (stderr, "sent key...\n"); |
1769 |
else |
1770 |
fprintf (stderr, "error sending key...\n"); |
1771 |
} |
1772 |
} |
1773 |
else |
1774 |
{ |
1775 |
if (p->verbose_p) |
1776 |
fprintf (stderr, "got keypress but no window id yet :(\n"); |
1777 |
XtDispatchEvent (&event); |
1778 |
} |
1779 |
} |
1780 |
#else /* !HAVE_XSCREENSAVER_LOCK */ |
1781 |
|
1483 |
if (event.xany.window == si->passwd_dialog && event.xany.type == Expose) |
1782 |
if (event.xany.window == si->passwd_dialog && event.xany.type == Expose) |
1484 |
draw_passwd_window (si); |
1783 |
draw_passwd_window (si); |
1485 |
else if (event.xany.type == KeyPress) |
1784 |
else if (event.xany.type == KeyPress) |
Lines 1487-1492
Link Here
|
1487 |
handle_passwd_key (si, &event.xkey); |
1786 |
handle_passwd_key (si, &event.xkey); |
1488 |
caps_p = (event.xkey.state & LockMask); |
1787 |
caps_p = (event.xkey.state & LockMask); |
1489 |
} |
1788 |
} |
|
|
1789 |
#endif /* !HAVE_XSCREENSAVER_LOCK */ |
1490 |
else if ((event.xany.type == ButtonPress || |
1790 |
else if ((event.xany.type == ButtonPress || |
1491 |
event.xany.type == ButtonRelease) && |
1791 |
event.xany.type == ButtonRelease) && |
1492 |
si->pw_data->login_button_p) |
1792 |
si->pw_data->login_button_p) |
Lines 1575-1582
Link Here
|
1575 |
|
1875 |
|
1576 |
if (msg) |
1876 |
if (msg) |
1577 |
{ |
1877 |
{ |
1578 |
si->pw_data->i_beam = 0; |
1878 |
#ifdef HAVE_XSCREENSAVER_LOCK |
1579 |
update_passwd_window (si, msg, 0.0); |
1879 |
if (si->external_passwd && si->pw_data->stdin_fd != -1) |
|
|
1880 |
{ |
1881 |
ssize_t len; |
1882 |
char *nlmsg; |
1883 |
|
1884 |
nlmsg = (char *)malloc (strlen (msg) + 2); |
1885 |
sprintf (nlmsg, "%s\n", msg); |
1886 |
|
1887 |
write_msg: |
1888 |
len = write (si->pw_data->stdin_fd, nlmsg, strlen (nlmsg)); |
1889 |
if (len < 0 && errno == EINTR) |
1890 |
goto write_msg; |
1891 |
|
1892 |
free (nlmsg); |
1893 |
} |
1894 |
else |
1895 |
#endif /* HAVE_XSCREENSAVER_LOCK */ |
1896 |
{ |
1897 |
si->pw_data->i_beam = 0; |
1898 |
update_passwd_window (si, msg, 0.0); |
1899 |
} |
1900 |
|
1580 |
XSync (si->dpy, False); |
1901 |
XSync (si->dpy, False); |
1581 |
sleep (1); |
1902 |
sleep (1); |
1582 |
|
1903 |
|
Lines 1607-1612
Link Here
|
1607 |
|
1928 |
|
1608 |
memset (si->unlock_typeahead, '*', strlen(si->unlock_typeahead)); |
1929 |
memset (si->unlock_typeahead, '*', strlen(si->unlock_typeahead)); |
1609 |
si->unlock_typeahead[i] = 0; |
1930 |
si->unlock_typeahead[i] = 0; |
|
|
1931 |
#ifdef HAVE_XSCREENSAVER_LOCK |
1932 |
/* FIXME: bugzilla.gnome.org #77077 */ |
1933 |
/* need to handle this in the external dialog case */ |
1934 |
#else |
1935 |
update_passwd_window (si, si->unlock_typeahead, pw->ratio); |
1936 |
#endif /* !HAVE_XSCREENSAVER_LOCK */ |
1937 |
|
1938 |
|
1610 |
update_passwd_window (si, si->unlock_typeahead, pw->ratio); |
1939 |
update_passwd_window (si, si->unlock_typeahead, pw->ratio); |
1611 |
|
1940 |
|
1612 |
free (si->unlock_typeahead); |
1941 |
free (si->unlock_typeahead); |