Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 144488
Collapse All | Expand All

(-)xscreensaver-5.00/driver/lock.c (-104 / +433 lines)
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);
(-)xscreensaver-5.00/driver/lock-Gtk.c (+413 lines)
Line 0 Link Here
1
/* lock-Gtk.c -- a GTK+ password dialog for xscreensaver
2
 * xscreensaver, Copyright (c) 2993-1998 Jamie Zawinski <jwz@jwz.org>
3
 * 
4
 * Permission to use, copy, modify, distribute, and sell this software and its
5
 * documentation for any purpose is hereby granted without fee, provided that
6
 * the above copyright notice appear in all copies and that both that
7
 * copyright notice and this permission notice appear in supporting
8
 * documentation.  No representations are made about the suitability of this
9
 * software for any purpose.  It is provided "as is" without express or 
10
 * implied warranty.
11
 */
12
13
/* GTK+ locking code written by Jacob Berkman  <jacob@ximian.com
14
 * Copyright 2002 Sun Microsystems, Inc. */
15
16
#ifdef HAVE_CONFIG_H
17
# include "config.h"
18
#endif
19
20
#ifdef HAVE_GTK2 /* whole file */
21
22
#include <xscreensaver-intl.h>
23
24
#include <unistd.h>
25
#include <errno.h>
26
#include <string.h>
27
#include <time.h>
28
#include <stdlib.h>
29
#include <stdio.h>
30
#include <libintl.h>
31
#include <locale.h>
32
33
#include <gtk/gtk.h>
34
#include <gdk/gdkx.h>
35
36
#include "remote.h"
37
#include "utils/images/logo-180.xpm"
38
39
static Atom XA_UNLOCK_RATIO;
40
Atom XA_VROOT;
41
Atom XA_SCREENSAVER, XA_SCREENSAVER_RESPONSE, XA_SCREENSAVER_VERSION;
42
Atom XA_SCREENSAVER_ID, XA_SCREENSAVER_STATUS, XA_SELECT, XA_DEMO;
43
Atom XA_ACTIVATE, XA_BLANK, XA_LOCK, XA_RESTART, XA_EXIT;
44
45
typedef struct {
46
  GtkWidget *dialog;
47
  GtkWidget *passwd_entry;
48
  GtkWidget *progress;
49
  GtkWidget *button;
50
  GtkWidget *msg_label;
51
} PasswdDialog;
52
53
char *progname = 0;
54
55
static ssize_t
56
write_string (const char *s)
57
{
58
  ssize_t len;
59
60
  g_return_val_if_fail (s != NULL, -1);
61
62
 do_write:
63
  len = write (STDOUT_FILENO, s, strlen (s));
64
  if (len < 0 && errno == EINTR)
65
    goto do_write;
66
67
  return len;
68
}
69
70
static PasswdDialog *
71
make_dialog (void)
72
{
73
  GtkWidget *dialog;
74
  GtkWidget *frame;
75
  GtkWidget *vbox;
76
  GtkWidget *hbox;
77
  GtkWidget *bbox;
78
  GtkWidget *vbox2;
79
  GtkWidget *entry;
80
  GtkWidget *label;
81
  GtkWidget *button;
82
  GtkWidget *image;
83
  GtkWidget *progress;
84
  GtkWidget *table;
85
  GdkPixbuf *pb;
86
  PasswdDialog *pwd;
87
  char *version;
88
  char *user;
89
  char *host;
90
  char *s;
91
92
  /* taken from lock.c */
93
  char buf[100];
94
  time_t now = time (NULL);
95
  struct tm* tm = localtime (&now);
96
  memset (buf, 0, sizeof (buf));
97
  strftime (buf, sizeof (buf) - 1, _("%d-%b-%y (%a); %I:%M %p"), tm);
98
99
  server_xscreensaver_version (GDK_DISPLAY (), &version, &user, &host);
100
101
  if (!version)
102
    {
103
      fprintf (stderr, "%s: no xscreensaver running on display %s, exiting.\n", progname, gdk_get_display ());
104
      exit (1);
105
    }
106
  
107
  pwd = g_new0 (PasswdDialog, 1);
108
109
  dialog = gtk_window_new (GTK_WINDOW_POPUP);
110
  pwd->dialog = dialog;
111
  gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ALWAYS);
112
113
  /* frame */
114
  frame = g_object_new (GTK_TYPE_FRAME,
115
			"shadow", GTK_SHADOW_OUT,
116
			NULL);
117
  gtk_container_add (GTK_CONTAINER (dialog), frame);
118
119
  /* vbox */
120
  vbox = gtk_vbox_new (FALSE, 10);
121
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 10);
122
  gtk_container_add (GTK_CONTAINER (frame), vbox);
123
  
124
  /* hbox */
125
  hbox = gtk_hbox_new (FALSE, 5);
126
  gtk_box_pack_start (GTK_BOX (vbox), hbox,
127
		      TRUE, TRUE, 0);
128
129
  /* image frame */
130
  frame = g_object_new (GTK_TYPE_FRAME,
131
			"shadow", GTK_SHADOW_IN,
132
			NULL);
133
  gtk_box_pack_start (GTK_BOX (hbox), frame,
134
		      TRUE, TRUE, 0);
135
136
  /* image */
137
  pb = gdk_pixbuf_new_from_xpm_data (logo_180_xpm);
138
  image = gtk_image_new_from_pixbuf (pb);
139
  g_object_unref (pb);
140
  gtk_container_add (GTK_CONTAINER (frame), image);
141
142
  /* progress thingie */
143
  progress = g_object_new (GTK_TYPE_PROGRESS_BAR,
144
			   "orientation", GTK_PROGRESS_BOTTOM_TO_TOP,
145
			   "fraction", 1.0,
146
			   NULL);
147
  atk_object_set_description (gtk_widget_get_accessible (progress), 
148
			      _("Percent of time you have to enter the password."));
149
  pwd->progress = progress;
150
  gtk_box_pack_start (GTK_BOX (hbox), progress,
151
		      FALSE, FALSE, 0);
152
153
  /* text fields */
154
  vbox2 = gtk_vbox_new (TRUE, 0);
155
  gtk_box_pack_start (GTK_BOX (hbox), vbox2,
156
		      TRUE, TRUE, 0);
157
158
  s = g_strdup_printf ("<span size=\"xx-large\"><b>XScreenSaver %s</b></span>", version);
159
  /* XScreenSaver foo label */
160
  label = g_object_new (GTK_TYPE_LABEL,
161
			"use-markup", TRUE,
162
			"label", s,
163
			NULL);
164
  gtk_box_pack_start (GTK_BOX (vbox2), label,
165
		      FALSE, FALSE, 0);
166
  g_free (s);
167
168
  /* This display is locked. */
169
  label = g_object_new (GTK_TYPE_LABEL,
170
			"use-markup", TRUE,
171
			"label", _("<b>This display is locked.</b>"),
172
			NULL);
173
  pwd->msg_label = label;
174
  gtk_box_pack_start (GTK_BOX (vbox2), label,
175
		      FALSE, FALSE, 0);
176
177
  /* table with password things */
178
  table = g_object_new (GTK_TYPE_TABLE,
179
			"n-rows", 2,
180
			"n-columns", 2,
181
			"homogeneous", FALSE,
182
			"row-spacing", 5,
183
			"column-spacing", 5,
184
			NULL);
185
  gtk_box_pack_start (GTK_BOX (vbox2), table,
186
		      FALSE, FALSE, 0);
187
188
  /* User: */
189
  label = g_object_new (GTK_TYPE_LABEL,
190
			"label", "User:",
191
			"xalign", 1.0,
192
			NULL);
193
  gtk_table_attach (GTK_TABLE (table), label,
194
		    0, 1, 0, 1,
195
		    GTK_FILL, 0,
196
		    0, 0);
197
198
  /* Password: */
199
  label = g_object_new (GTK_TYPE_LABEL,
200
			"label", "Password:",
201
			"xalign", 1.0,
202
			NULL);
203
  gtk_table_attach (GTK_TABLE (table), label,
204
		    0, 1, 1, 2,
205
		    GTK_FILL, 0,
206
		    0, 0);
207
208
  /* name */
209
  entry = g_object_new (GTK_TYPE_ENTRY,
210
			"editable", FALSE,
211
			"text", user,
212
			NULL);
213
  gtk_table_attach (GTK_TABLE (table), entry,
214
		    1, 2, 0, 1,
215
		    GTK_FILL, 0,
216
		    0, 0);
217
  GTK_WIDGET_UNSET_FLAGS (entry, GTK_CAN_FOCUS);
218
219
  /* passwd */
220
  entry = g_object_new (GTK_TYPE_ENTRY,
221
			"visibility", FALSE,
222
			/* "activates-default", TRUE, */
223
			NULL);
224
  pwd->passwd_entry = entry;
225
  gtk_table_attach (GTK_TABLE (table), entry,
226
		    1, 2, 1, 2,
227
		    GTK_FILL, 0,
228
		    0, 0);
229
  gtk_widget_grab_focus (entry);
230
  
231
  s = g_strdup_printf ("<small>%s</small>", buf);
232
  /* date string */
233
  label = g_object_new (GTK_TYPE_LABEL,
234
			"use-markup", TRUE,
235
			"label",  s,
236
			NULL);
237
  gtk_box_pack_start (GTK_BOX (vbox2), label,
238
		      FALSE, FALSE, 0);
239
  g_free (s);
240
241
  /* button box */
242
  bbox = g_object_new (GTK_TYPE_HBUTTON_BOX,
243
		       "layout-style", GTK_BUTTONBOX_END,
244
		       "spacing", 10,
245
		       NULL);
246
#if 0
247
  gtk_box_pack_start (GTK_BOX (vbox), bbox,
248
		      FALSE, FALSE, 0);
249
#endif
250
251
  /* Ok button */
252
  button = gtk_button_new_from_stock (GTK_STOCK_OK);
253
  pwd->button = button;
254
  gtk_box_pack_end (GTK_BOX (bbox), button,
255
		    FALSE, TRUE, 0);
256
#if 0
257
  GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
258
  gtk_widget_grab_default (button);
259
#endif
260
261
  free (version);
262
  free (user);
263
  free (host);
264
265
  return pwd;
266
}
267
268
static void
269
desensitize_entry (PasswdDialog *pwd)
270
{
271
  g_object_set (pwd->passwd_entry,
272
		"editable", FALSE,
273
		"sensitive", FALSE,
274
		NULL);
275
}
276
277
static void
278
ok_clicked_cb (GtkWidget *button, PasswdDialog *pwd)
279
{
280
  char *s;
281
282
  desensitize_entry (pwd);
283
  g_object_set (pwd->msg_label, "label", _("<b>Checking...</b>"), NULL);
284
285
  s = g_strdup_printf ("%s\n", gtk_entry_get_text (GTK_ENTRY (pwd->passwd_entry)));
286
  write_string (s);
287
  g_free (s);
288
}
289
290
static void
291
connect_signals (PasswdDialog *pwd)
292
{
293
  g_signal_connect (pwd->button, "clicked",
294
		    G_CALLBACK (ok_clicked_cb),
295
		    pwd);
296
297
  g_signal_connect (pwd->passwd_entry, "activate",
298
		    G_CALLBACK (ok_clicked_cb),
299
		    pwd);
300
301
  g_signal_connect (pwd->dialog, "delete-event",
302
		    G_CALLBACK (gtk_main_quit),
303
		    NULL);
304
}
305
306
static GdkFilterReturn
307
dialog_filter_func (GdkXEvent *xevent, GdkEvent *gevent, gpointer data)
308
{
309
  PasswdDialog *pwd = data;
310
  XEvent *event = xevent;
311
  gdouble ratio;
312
  
313
  if (event->xany.type != ClientMessage || event->xclient.message_type != XA_UNLOCK_RATIO)
314
    return GDK_FILTER_CONTINUE;
315
  
316
  ratio = event->xclient.data.l[0] / (gdouble)100.0;
317
  
318
  g_object_set (pwd->progress, "fraction", ratio, NULL);
319
  
320
  return GDK_FILTER_REMOVE;
321
}
322
323
static gboolean
324
handle_input (GIOChannel *source, GIOCondition cond, gpointer data)
325
{
326
  PasswdDialog *pwd = data;
327
  GIOStatus status;
328
  char *str;
329
  char *label;
330
331
  desensitize_entry (pwd);
332
333
 read_line:
334
  status = g_io_channel_read_line (source, &str, NULL, NULL, NULL);
335
  if (status == G_IO_STATUS_AGAIN)
336
    goto read_line;
337
338
  if (str)
339
    {
340
      label = g_strdup_printf ("<b>%s</b>", str);
341
      g_object_set (pwd->msg_label, "label", label, NULL);
342
      g_free (label);
343
      g_free (str);
344
    }
345
346
  return (status == G_IO_STATUS_NORMAL);
347
}
348
349
int
350
main (int argc, char *argv[])
351
{
352
  GIOChannel *ioc;
353
  PasswdDialog *pwd;
354
  char *s;
355
  char *real_progname = argv[0];
356
357
#ifdef ENABLE_NLS
358
  textdomain (GETTEXT_PACKAGE);
359
360
# ifdef HAVE_GTK2
361
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
362
# else /* ! HAVE_GTK2 */
363
  if (!setlocale (LC_ALL, ""))
364
    fprintf (stderr, "%s: locale not supported by C library\n", real_progname);
365
# endif /* ! HAVE_GTK2 */
366
367
#endif /* ENABLE_NLS */
368
369
  s = strrchr (real_progname, '/');
370
  if (s) real_progname = s+1;
371
  progname = real_progname;
372
373
  gtk_init (&argc, &argv);
374
375
  /* Intern the atoms that xscreensaver_command() needs.
376
   */
377
  XA_VROOT = XInternAtom (GDK_DISPLAY (), "__SWM_VROOT", False);
378
  XA_SCREENSAVER = XInternAtom (GDK_DISPLAY (), "SCREENSAVER", False);
379
  XA_SCREENSAVER_VERSION = XInternAtom (GDK_DISPLAY (), "_SCREENSAVER_VERSION",False);
380
  XA_SCREENSAVER_STATUS = XInternAtom (GDK_DISPLAY (), "_SCREENSAVER_STATUS", False);
381
  XA_SCREENSAVER_ID = XInternAtom (GDK_DISPLAY (), "_SCREENSAVER_ID", False);
382
  XA_SCREENSAVER_RESPONSE = XInternAtom (GDK_DISPLAY (), "_SCREENSAVER_RESPONSE", False);
383
  XA_SELECT = XInternAtom (GDK_DISPLAY (), "SELECT", False);
384
  XA_DEMO = XInternAtom (GDK_DISPLAY (), "DEMO", False);
385
  XA_ACTIVATE = XInternAtom (GDK_DISPLAY (), "ACTIVATE", False);
386
  XA_BLANK = XInternAtom (GDK_DISPLAY (), "BLANK", False);
387
  XA_LOCK = XInternAtom (GDK_DISPLAY (), "LOCK", False);
388
  XA_EXIT = XInternAtom (GDK_DISPLAY (), "EXIT", False);
389
  XA_RESTART = XInternAtom (GDK_DISPLAY (), "RESTART", False);
390
  XA_UNLOCK_RATIO = XInternAtom (GDK_DISPLAY (), "UNLOCK_RATIO", False);
391
392
  pwd = make_dialog ();
393
  connect_signals (pwd);
394
395
  gtk_widget_show_all (pwd->dialog);
396
  gtk_window_present (GTK_WINDOW (pwd->dialog));
397
  gtk_widget_map (pwd->dialog);
398
399
  gdk_window_add_filter (pwd->dialog->window, dialog_filter_func, pwd);
400
401
  s = g_strdup_printf ("%lu\n", GDK_WINDOW_XID (pwd->dialog->window));
402
  write_string (s);
403
  g_free (s);
404
405
  ioc = g_io_channel_unix_new (0);
406
  g_io_add_watch (ioc, G_IO_IN, handle_input, pwd);
407
408
  gtk_main ();
409
  
410
  return 0;
411
}
412
413
#endif /* HAVE_GTK2 */
(-)xscreensaver-5.00/driver/Makefile.in (-4 / +38 lines)
Lines 14-19 Link Here
14
prefix		= @prefix@
14
prefix		= @prefix@
15
exec_prefix	= @exec_prefix@
15
exec_prefix	= @exec_prefix@
16
bindir		= @bindir@
16
bindir		= @bindir@
17
libexecdir	= $(exec_prefix)/libexec
17
datadir		= @datadir@
18
datadir		= @datadir@
18
localedir	= $(datadir)/locale
19
localedir	= $(datadir)/locale
19
mandir		= @mandir@
20
mandir		= @mandir@
Lines 38-43 Link Here
38
SUBP_DEFS	= $(DEFS) -DDEFAULT_PATH_PREFIX='"@HACKDIR@"'
39
SUBP_DEFS	= $(DEFS) -DDEFAULT_PATH_PREFIX='"@HACKDIR@"'
39
GTK_DEFS	= $(DEFS) -DDEFAULT_ICONDIR='"$(GTK_GLADEDIR)"'
40
GTK_DEFS	= $(DEFS) -DDEFAULT_ICONDIR='"$(GTK_GLADEDIR)"'
40
CONF_DEFS	= -DHACK_CONFIGURATION_PATH='"$(HACK_CONF_DIR)"'
41
CONF_DEFS	= -DHACK_CONFIGURATION_PATH='"$(HACK_CONF_DIR)"'
42
LOCK_DEFS	= $(DEFS) -DLOCKDIR=\"$(libexecdir)/xscreensaver\"
43
41
44
42
LIBS		= @LIBS@
45
LIBS		= @LIBS@
43
INTL_LIBS	= @INTLLIBS@
46
INTL_LIBS	= @INTLLIBS@
Lines 95-100 Link Here
95
		  demo-Gtk-widgets.c demo-Gtk-support.c
98
		  demo-Gtk-widgets.c demo-Gtk-support.c
96
GTK_EXTRA_OBJS  = demo-Gtk-widgets.o demo-Gtk-support.o
99
GTK_EXTRA_OBJS  = demo-Gtk-widgets.o demo-Gtk-support.o
97
GTK_OBJS	= demo-Gtk.o demo-Gtk-conf.o @GTK_EXTRA_OBJS@
100
GTK_OBJS	= demo-Gtk.o demo-Gtk-conf.o @GTK_EXTRA_OBJS@
101
GTK_LOCK_SRCS	= lock-Gtk.c remote.c
102
GTK_LOCK_OBJS	= lock-Gtk.o remote.o
103
 
104
98
105
99
PWENT_SRCS	= passwd-pwent.c
106
PWENT_SRCS	= passwd-pwent.c
100
PWENT_OBJS	= passwd-pwent.o
107
PWENT_OBJS	= passwd-pwent.o
Lines 213-220 Link Here
213
		  $(X_PRE_LIBS) -lXt -lX11 $(XMU_LIBS) -lXext $(X_EXTRA_LIBS)
220
		  $(X_PRE_LIBS) -lXt -lX11 $(XMU_LIBS) -lXext $(X_EXTRA_LIBS)
214
221
215
EXES		= xscreensaver xscreensaver-command xscreensaver-demo \
222
EXES		= xscreensaver xscreensaver-command xscreensaver-demo \
216
		  xscreensaver-getimage @EXES_OSX@
223
		  xscreensaver-getimage @PREFERRED_LOCK_PROGRAM@
217
EXES2		= @ALL_DEMO_PROGRAMS@
224
EXES2		= @ALL_DEMO_PROGRAMS@ @ALL_LOCK_PROGRAMS@
225
218
EXES_OSX	= pdf2jpeg
226
EXES_OSX	= pdf2jpeg
219
227
220
SCRIPTS_1	= xscreensaver-getimage-file xscreensaver-getimage-video \
228
SCRIPTS_1	= xscreensaver-getimage-file xscreensaver-getimage-video \
Lines 269-274 Link Here
269
	@if [ ! -d $(install_prefix)$(bindir) ]; then			\
277
	@if [ ! -d $(install_prefix)$(bindir) ]; then			\
270
	  $(INSTALL_DIRS) $(install_prefix)$(bindir) ;			\
278
	  $(INSTALL_DIRS) $(install_prefix)$(bindir) ;			\
271
	 fi
279
	 fi
280
	@if [ -n "@LOCK_PROGRAM@" -a ! -d $(install_prefix)$(libexecdir)/xscreensaver ]; then \
281
	  $(INSTALL_DIRS) $(install_prefix)$(libexecdir)/xscreensaver ; \
282
	 fi
283
272
	@inst="$(INSTALL_PROGRAM)" ;					\
284
	@inst="$(INSTALL_PROGRAM)" ;					\
273
	if [ @NEED_SETUID@ = yes ]; then				\
285
	if [ @NEED_SETUID@ = yes ]; then				\
274
	   me=`PATH="$$PATH:/usr/ucb" whoami` ;				\
286
	   me=`PATH="$$PATH:/usr/ucb" whoami` ;				\
Lines 297-303 Link Here
297
	  echo $(INSTALL_PROGRAM) $$exe $(install_prefix)$(bindir)/$$exe ; \
309
	  echo $(INSTALL_PROGRAM) $$exe $(install_prefix)$(bindir)/$$exe ; \
298
	       $(INSTALL_PROGRAM) $$exe $(install_prefix)$(bindir)/$$exe ; \
310
	       $(INSTALL_PROGRAM) $$exe $(install_prefix)$(bindir)/$$exe ; \
299
	 done
311
	 done
300
312
	@if [ -n "@LOCK_PROGRAM@" ]; then				     \
313
	  echo $(INSTALL_PROGRAM) xscreensaver-lock \
314
	$(install_prefix)$(libexecdir)/xscreensaver/xscreensaver-lock ; \
315
	$(INSTALL_PROGRAM) @PREFERRED_LOCK_PROGRAM@ \
316
	    $(install_prefix)$(libexecdir)/xscreensaver/xscreensaver-lock ; \
317
	fi
301
install-ad: XScreenSaver.ad
318
install-ad: XScreenSaver.ad
302
	@if [ ! -d $(install_prefix)$(AD_DIR) ]; then			      \
319
	@if [ ! -d $(install_prefix)$(AD_DIR) ]; then			      \
303
	  $(INSTALL_DIRS) $(install_prefix)$(AD_DIR) ;			      \
320
	  $(INSTALL_DIRS) $(install_prefix)$(AD_DIR) ;			      \
Lines 741-746 Link Here
741
	$(CC) -c $(INCLUDES) $(SUBP_DEFS) $(CFLAGS) $(X_CFLAGS) \
758
	$(CC) -c $(INCLUDES) $(SUBP_DEFS) $(CFLAGS) $(X_CFLAGS) \
742
	  $(srcdir)/subprocs.c
759
	  $(srcdir)/subprocs.c
743
760
761
# lock takes an extra -D option.
762
lock.o:
763
	$(CC) -c $(INCLUDES) $(LOCK_DEFS) $(CFLAGS) $(X_CFLAGS) \
764
	  $(srcdir)/lock.c
765
766
744
# demo-Gtk takes extra -D options, and an extra -I option.
767
# demo-Gtk takes extra -D options, and an extra -I option.
745
demo-Gtk.o: demo-Gtk.c
768
demo-Gtk.o: demo-Gtk.c
746
	$(CC) -c $(INCLUDES) $(SUBP_DEFS) -I$(ICON_SRC) \
769
	$(CC) -c $(INCLUDES) $(SUBP_DEFS) -I$(ICON_SRC) \
Lines 782-787 Link Here
782
	       cp -p @PREFERRED_DEMO_PROGRAM@@EXEEXT@ $@@EXEEXT@      ;	\
805
	       cp -p @PREFERRED_DEMO_PROGRAM@@EXEEXT@ $@@EXEEXT@      ;	\
783
	fi
806
	fi
784
807
808
xscreensaver-lock: @PREFERRED_LOCK_PROGRAM@
809
	$(INSTALL_PROGRAM) @PREFERRED_LOCK_PROGRAM@ $@
810
811
785
xscreensaver-demo-Xm: $(DEMO_OBJS) $(MOTIF_OBJS)
812
xscreensaver-demo-Xm: $(DEMO_OBJS) $(MOTIF_OBJS)
786
	$(CC) $(LDFLAGS) -o $@ $(DEMO_OBJS) $(MOTIF_OBJS) $(LIBS) $(X_LIBS) \
813
	$(CC) $(LDFLAGS) -o $@ $(DEMO_OBJS) $(MOTIF_OBJS) $(LIBS) $(X_LIBS) \
787
	$(MOTIF_LIBS) $(INTL_LIBS) $(X_PRE_LIBS) -lXt -lX11 \
814
	$(MOTIF_LIBS) $(INTL_LIBS) $(X_PRE_LIBS) -lXt -lX11 \
Lines 795-800 Link Here
795
demo-Gtk.o: XScreenSaver_ad.h
822
demo-Gtk.o: XScreenSaver_ad.h
796
demo-Xm.o:  XScreenSaver_ad_Xm.h
823
demo-Xm.o:  XScreenSaver_ad_Xm.h
797
824
825
xscreensaver-lock-Gtk: $(GTK_LOCK_OBJS)
826
	$(CC) $(LDFLAGS) -o $@ $(GTK_LOCK_OBJS) $(LIBS) $(X_LIBS) \
827
	$(GTK_LIBS) $(XML_LIBS) $(X_PRE_LIBS) -lXt -lX11 $(XDPMS_LIBS) -lXext \
828
	$(X_EXTRA_LIBS)
829
830
831
798
xscreensaver-getimage: $(GETIMG_OBJS)
832
xscreensaver-getimage: $(GETIMG_OBJS)
799
	$(CC) $(LDFLAGS) -o $@ $(GETIMG_OBJS) $(GETIMG_LIBS) -lm
833
	$(CC) $(LDFLAGS) -o $@ $(GETIMG_OBJS) $(GETIMG_LIBS) -lm
800
834
Lines 803-809 Link Here
803
837
804
838
805
TEST_PASSWD_OBJS = test-passwd.o $(LOCK_OBJS_1) $(PASSWD_OBJS) \
839
TEST_PASSWD_OBJS = test-passwd.o $(LOCK_OBJS_1) $(PASSWD_OBJS) \
806
	 subprocs.o setuid.o splash.o prefs.o \
840
	 subprocs.o setuid.o splash.o prefs.o exec.o stderr.o\
807
	$(SAVER_UTIL_OBJS)
841
	$(SAVER_UTIL_OBJS)
808
test-passwd.o: XScreenSaver_ad.h
842
test-passwd.o: XScreenSaver_ad.h
809
843
(-)xscreensaver-5.00/driver/xscreensaver.c (+2 lines)
Lines 189-194 Link Here
189
static Atom XA_RESTART, XA_SELECT;
189
static Atom XA_RESTART, XA_SELECT;
190
static Atom XA_THROTTLE, XA_UNTHROTTLE;
190
static Atom XA_THROTTLE, XA_UNTHROTTLE;
191
Atom XA_DEMO, XA_PREFS, XA_EXIT, XA_LOCK, XA_BLANK;
191
Atom XA_DEMO, XA_PREFS, XA_EXIT, XA_LOCK, XA_BLANK;
192
Atom XA_UNLOCK_RATIO;
192
193
193
194
194
static XrmOptionDescRec options [] = {
195
static XrmOptionDescRec options [] = {
Lines 597-602 Link Here
597
  XA_BLANK = XInternAtom (si->dpy, "BLANK", False);
598
  XA_BLANK = XInternAtom (si->dpy, "BLANK", False);
598
  XA_THROTTLE = XInternAtom (si->dpy, "THROTTLE", False);
599
  XA_THROTTLE = XInternAtom (si->dpy, "THROTTLE", False);
599
  XA_UNTHROTTLE = XInternAtom (si->dpy, "UNTHROTTLE", False);
600
  XA_UNTHROTTLE = XInternAtom (si->dpy, "UNTHROTTLE", False);
601
  XA_UNLOCK_RATIO = XInternAtom (si->dpy, "UNLOCK_RATIO", False);
600
602
601
  return toplevel_shell;
603
  return toplevel_shell;
602
}
604
}
(-)xscreensaver-5.00/driver/xscreensaver.h (+7 lines)
Lines 126-131 Link Here
126
				   privileged user. */
126
				   privileged user. */
127
127
128
  Window passwd_dialog;		/* The password dialog, if its up. */
128
  Window passwd_dialog;		/* The password dialog, if its up. */
129
#ifdef HAVE_XSCREENSAVER_LOCK
130
  pid_t passwd_pid;             /* The pid of the password dialog if
131
				   we ran an external process for
132
				   it. */
133
  Bool external_passwd;
134
#endif /* HAVE_XSCREENSAVER_LOCK */
135
129
  passwd_dialog_data *pw_data;	/* Other info necessary to draw it. */
136
  passwd_dialog_data *pw_data;	/* Other info necessary to draw it. */
130
137
131
  int unlock_failures;		/* Counts failed login attempts while the
138
  int unlock_failures;		/* Counts failed login attempts while the
(-)xscreensaver-5.00/config.h.in (+4 lines)
Lines 110-115 Link Here
110
110
111
/* Define this if you have Gtk 2.x. */
111
/* Define this if you have Gtk 2.x. */
112
#undef HAVE_GTK2
112
#undef HAVE_GTK2
113
/*  Define this to build the external lock dialog */
114
#undef HAVE_XSCREENSAVER_LOCK
115
116
113
117
114
/* Define this if you are running HPUX with so-called ``Secure Passwords'' (if
118
/* Define this if you are running HPUX with so-called ``Secure Passwords'' (if
115
   you have /usr/include/hpsecurity.h, you probably have this.) I haven't
119
   you have /usr/include/hpsecurity.h, you probably have this.) I haven't
(-)xscreensaver-5.00/driver/subprocs.c (-13 / +32 lines)
Lines 340-346 Link Here
340
  return 0;
340
  return 0;
341
}
341
}
342
342
343
static void await_dying_children (saver_info *si);
343
void await_dying_children (saver_info *si);
344
#ifndef VMS
344
#ifndef VMS
345
static void describe_dead_child (saver_info *, pid_t, int wait_status);
345
static void describe_dead_child (saver_info *, pid_t, int wait_status);
346
#endif
346
#endif
Lines 500-506 Link Here
500
500
501
#ifndef VMS
501
#ifndef VMS
502
502
503
static void
503
void
504
await_dying_children (saver_info *si)
504
await_dying_children (saver_info *si)
505
{
505
{
506
  while (1)
506
  while (1)
Lines 573-581 Link Here
573
	 mention them) if we've just killed the subprocess.  But mention them
573
	 mention them) if we've just killed the subprocess.  But mention them
574
	 if they happen on their own.
574
	 if they happen on their own.
575
       */
575
       */
576
      if (!job ||
576
      if ((!job 
577
#ifdef HAVE_XSCREENSAVER_LOCK
578
	   && kid != si->passwd_pid
579
#endif /* HAVE_XSCREENSAVER_LOCK */
580
		  ) ||
577
	  (exit_status != 0 &&
581
	  (exit_status != 0 &&
578
	   (p->verbose_p || job->status != job_killed)))
582
	  (p->verbose_p || (job && job->status != job_killed))))
579
        {
583
        {
580
          /* Don't call fprintf() from signal handlers, as it might malloc.
584
          /* Don't call fprintf() from signal handlers, as it might malloc.
581
	  fprintf (stderr,
585
	  fprintf (stderr,
Lines 615-622 Link Here
615
  else if (WIFSIGNALED (wait_status))
619
  else if (WIFSIGNALED (wait_status))
616
    {
620
    {
617
      if (p->verbose_p ||
621
      if (p->verbose_p ||
618
	  !job ||
622
	(!job
619
	  job->status != job_killed ||
623
#ifdef HAVE_XSCREENSAVER_LOCK
624
	   && kid != si->passwd_pid
625
#endif /* HAVE_XSCREENSAVER_LOCK */
626
		  ) ||
627
	  (job && job->status != job_killed) ||
620
	  WTERMSIG (wait_status) != SIGTERM)
628
	  WTERMSIG (wait_status) != SIGTERM)
621
        {
629
        {
622
          /* Don't call fprintf() from signal handlers, as it might malloc.
630
          /* Don't call fprintf() from signal handlers, as it might malloc.
Lines 684-696 Link Here
684
  /* Clear out the pid so that screenhack_running_p() knows it's dead.
692
  /* Clear out the pid so that screenhack_running_p() knows it's dead.
685
   */
693
   */
686
  if (!job || job->status == job_dead)
694
  if (!job || job->status == job_dead)
687
    for (i = 0; i < si->nscreens; i++)
695
   {
688
      {
696
      for (i = 0; i < si->nscreens; i++)
689
	saver_screen_info *ssi = &si->screens[i];
697
	{
690
	if (kid == ssi->pid)
698
	  saver_screen_info *ssi = &si->screens[i];
691
	  ssi->pid = 0;
699
	  if (kid == ssi->pid)
692
      }
700
	    ssi->pid = 0;
693
}
701
	}
702
#ifdef HAVE_XSCREENSAVER_LOCK
703
      if (kid == si->passwd_pid)
704
	{
705
	  if (p->verbose_p)
706
	    fprintf (stderr, "passwd dialog died!\n");
707
	  si->passwd_pid = 0;
708
	}
709
#endif
710
    }
711
712
  }
694
713
695
#else  /* VMS */
714
#else  /* VMS */
696
static void await_dying_children (saver_info *si) { return; }
715
static void await_dying_children (saver_info *si) { return; }
(-)xscreensaver-5.00/configure.in (+10 lines)
Lines 118-123 Link Here
118
118
119
AH_TEMPLATE([HAVE_GTK],[Define this if you have Gtk (any version.)])
119
AH_TEMPLATE([HAVE_GTK],[Define this if you have Gtk (any version.)])
120
AH_TEMPLATE([HAVE_GTK2],[Define this if you have Gtk 2.x.])
120
AH_TEMPLATE([HAVE_GTK2],[Define this if you have Gtk 2.x.])
121
AH_TEMPLATE([HAVE_XSCREENSAVER_LOCK], [Define this if you want Gtk2 lock widget.])
121
122
122
AH_TEMPLATE([HAVE_CRAPPLET],
123
AH_TEMPLATE([HAVE_CRAPPLET],
123
	    [Define this if you have Gnome and want to build support for the
124
	    [Define this if you have Gnome and want to build support for the
Lines 2423-2428 Link Here
2423
    GTK_LIBS="$GTK_LIBS $ac_gtk_config_libs"
2424
    GTK_LIBS="$GTK_LIBS $ac_gtk_config_libs"
2424
    AC_DEFINE(HAVE_GTK)
2425
    AC_DEFINE(HAVE_GTK)
2425
    AC_DEFINE(HAVE_GTK2)
2426
    AC_DEFINE(HAVE_GTK2)
2427
    AC_DEFINE(HAVE_XSCREENSAVER_LOCK)
2426
    AC_DEFINE(HAVE_XML)
2428
    AC_DEFINE(HAVE_XML)
2427
  fi
2429
  fi
2428
2430
Lines 3406-3418 Link Here
3406
3408
3407
PREFERRED_DEMO_PROGRAM=''
3409
PREFERRED_DEMO_PROGRAM=''
3408
ALL_DEMO_PROGRAMS=
3410
ALL_DEMO_PROGRAMS=
3411
PREFERRED_LOCK_PROGRAM=
3412
ALL_LOCK_PROGRAMS=
3409
if test "$have_motif" = yes; then
3413
if test "$have_motif" = yes; then
3410
  PREFERRED_DEMO_PROGRAM=xscreensaver-demo-Xm
3414
  PREFERRED_DEMO_PROGRAM=xscreensaver-demo-Xm
3415
  PREFERRED_LOCK_PROGRAM=xscreensaver-lock-Xm
3411
  ALL_DEMO_PROGRAMS="$PREFERRED_DEMO_PROGRAM $ALL_DEMO_PROGRAMS"
3416
  ALL_DEMO_PROGRAMS="$PREFERRED_DEMO_PROGRAM $ALL_DEMO_PROGRAMS"
3417
  ALL_LOCK_PROGRAMS="$PREFERRED_LOCK_PROGRAM $ALL_LOCK_PROGRAMS"
3412
fi
3418
fi
3413
if test "$have_gtk" = yes; then
3419
if test "$have_gtk" = yes; then
3414
  PREFERRED_DEMO_PROGRAM=xscreensaver-demo-Gtk
3420
  PREFERRED_DEMO_PROGRAM=xscreensaver-demo-Gtk
3421
  PREFERRED_LOCK_PROGRAM=xscreensaver-lock-Gtk
3415
  ALL_DEMO_PROGRAMS="$PREFERRED_DEMO_PROGRAM $ALL_DEMO_PROGRAMS"
3422
  ALL_DEMO_PROGRAMS="$PREFERRED_DEMO_PROGRAM $ALL_DEMO_PROGRAMS"
3423
  ALL_LOCK_PROGRAMS="$PREFERRED_LOCK_PROGRAM $ALL_LOCK_PROGRAMS"
3416
fi
3424
fi
3417
3425
3418
3426
Lines 3557-3562 Link Here
3557
3565
3558
AC_SUBST(PREFERRED_DEMO_PROGRAM)
3566
AC_SUBST(PREFERRED_DEMO_PROGRAM)
3559
AC_SUBST(ALL_DEMO_PROGRAMS)
3567
AC_SUBST(ALL_DEMO_PROGRAMS)
3568
AC_SUBST(PREFERRED_LOCK_PROGRAM)
3569
AC_SUBST(ALL_LOCK_PROGRAMS)
3560
AC_SUBST(SAVER_LIBS)
3570
AC_SUBST(SAVER_LIBS)
3561
AC_SUBST(MOTIF_LIBS)
3571
AC_SUBST(MOTIF_LIBS)
3562
AC_SUBST(GTK_LIBS)
3572
AC_SUBST(GTK_LIBS)

Return to bug 144488