~ubuntu-branches/ubuntu/dapper/xscreensaver/dapper-updates

« back to all changes in this revision

Viewing changes to driver/lock.c

  • Committer: Bazaar Package Importer
  • Author(s): Ralf Hildebrandt
  • Date: 2005-04-09 00:06:43 UTC
  • mfrom: (1.1.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20050409000643-z0abtifbt9s20pcc
Tags: 4.21-3
Patch by Joachim Breitner to check more frequently if DPMS kicked in (closes: #303374, #286664).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* lock.c --- handling the password dialog for locking-mode.
2
 
 * xscreensaver, Copyright (c) 1993-1998 Jamie Zawinski <jwz@jwz.org>
 
2
 * xscreensaver, Copyright (c) 1993-2005 Jamie Zawinski <jwz@jwz.org>
3
3
 *
4
4
 * Permission to use, copy, modify, distribute, and sell this software and its
5
5
 * documentation for any purpose is hereby granted without fee, provided that
18
18
#endif
19
19
 
20
20
#include <X11/Intrinsic.h>
 
21
#include <X11/cursorfont.h>
21
22
#include <X11/Xos.h>            /* for time() */
 
23
#include <time.h>
 
24
#include <sys/time.h>
22
25
#include "xscreensaver.h"
23
26
#include "resources.h"
24
27
 
45
48
  static void xfree_lock_mode_switch (saver_info *si, Bool lock_p);
46
49
#endif /* HAVE_XF86VMODE */
47
50
 
 
51
#ifdef HAVE_XF86MISCSETGRABKEYSSTATE
 
52
# include <X11/extensions/xf86misc.h>
 
53
  static void xfree_lock_grab_smasher (saver_info *si, Bool lock_p);
 
54
#endif /* HAVE_XF86MISCSETGRABKEYSSTATE */
 
55
 
48
56
 
49
57
#ifdef _VROOT_H_
50
58
ERROR!  You must not include vroot.h in this file.
75
83
 
76
84
struct passwd_dialog_data {
77
85
 
 
86
  saver_screen_info *prompt_screen;
 
87
  int previous_mouse_x, previous_mouse_y;
 
88
 
78
89
  enum passwd_state state;
79
90
  char typed_passwd [80];
80
91
  XtIntervalId timer;
93
104
  char *date_label;
94
105
  char *user_string;
95
106
  char *passwd_string;
 
107
  char *login_label;
96
108
 
97
109
  XFontStruct *heading_font;
98
110
  XFontStruct *body_font;
99
111
  XFontStruct *label_font;
100
112
  XFontStruct *passwd_font;
101
113
  XFontStruct *date_font;
 
114
  XFontStruct *button_font;
102
115
 
103
116
  Pixel foreground;
104
117
  Pixel background;
108
121
  Pixel thermo_background;
109
122
  Pixel shadow_top;
110
123
  Pixel shadow_bottom;
 
124
  Pixel button_foreground;
 
125
  Pixel button_background;
111
126
 
112
127
  Dimension logo_width;
113
128
  Dimension logo_height;
118
133
  Dimension passwd_field_x, passwd_field_y;
119
134
  Dimension passwd_field_width, passwd_field_height;
120
135
 
 
136
  Dimension login_button_x, login_button_y;
 
137
  Dimension login_button_width, login_button_height;
 
138
 
121
139
  Dimension thermo_field_x, thermo_field_y;
122
140
  Dimension thermo_field_height;
123
141
 
124
142
  Pixmap logo_pixmap;
 
143
  Pixmap logo_clipmask;
125
144
  int logo_npixels;
126
145
  unsigned long *logo_pixels;
127
146
 
 
147
  Cursor passwd_cursor;
 
148
  Bool login_button_down_p;
 
149
  Bool login_button_p;
 
150
  Bool login_button_enabled_p;
 
151
 
128
152
  Pixmap save_under;
129
153
};
130
154
 
133
157
                                  float ratio);
134
158
static void destroy_passwd_window (saver_info *si);
135
159
static void undo_vp_motion (saver_info *si);
 
160
static void handle_passwd_button (saver_info *si, XEvent *event);
136
161
 
137
162
 
138
163
static void
141
166
  struct passwd *p = getpwuid (getuid ());
142
167
  XSetWindowAttributes attrs;
143
168
  unsigned long attrmask = 0;
144
 
  Screen *screen = si->default_screen->screen;
145
169
  passwd_dialog_data *pw = (passwd_dialog_data *) calloc (1, sizeof(*pw));
146
 
  Colormap cmap = DefaultColormapOfScreen (screen);
 
170
  Screen *screen;
 
171
  Colormap cmap;
147
172
  char *f;
 
173
  saver_screen_info *ssi = &si->screens [mouse_screen (si)];
 
174
 
 
175
  /* Display the button only if the "newLoginCommand" pref is non-null.
 
176
   */
 
177
  pw->login_button_p = (si->prefs.new_login_command &&
 
178
                        *si->prefs.new_login_command);
 
179
 
 
180
  if (pw->login_button_p)
 
181
    pw->passwd_cursor = XCreateFontCursor (si->dpy, XC_top_left_arrow);
 
182
  else
 
183
    pw->passwd_cursor = 0;
 
184
 
 
185
  pw->prompt_screen = ssi;
 
186
  if (si->prefs.verbose_p)
 
187
    fprintf (stderr, "%s: %d: creating password dialog.\n",
 
188
             blurb(), pw->prompt_screen->number);
 
189
 
 
190
  screen = pw->prompt_screen->screen;
 
191
  cmap = DefaultColormapOfScreen (screen);
148
192
 
149
193
  pw->ratio = 1.0;
150
194
 
156
200
                                        "Dialog.Label.Label");
157
201
  pw->passwd_label = get_string_resource ("passwd.passwd.label",
158
202
                                          "Dialog.Label.Label");
 
203
  pw->login_label = get_string_resource ("passwd.login.label",
 
204
                                         "Dialog.Button.Label");
 
205
 
159
206
  pw->date_label = get_string_resource ("dateFormat", "DateFormat");
160
207
 
161
208
  if (!pw->heading_label)
162
 
    pw->heading_label = strdup("ERROR: REESOURCES NOT INSTALLED CORRECTLY");
 
209
    pw->heading_label = strdup("ERROR: RESOURCES NOT INSTALLED CORRECTLY");
163
210
  if (!pw->body_label)
164
 
    pw->body_label = strdup("ERROR: REESOURCES NOT INSTALLED CORRECTLY");
 
211
    pw->body_label = strdup("ERROR: RESOURCES NOT INSTALLED CORRECTLY");
165
212
  if (!pw->user_label) pw->user_label = strdup("ERROR");
166
213
  if (!pw->passwd_label) pw->passwd_label = strdup("ERROR");
167
214
  if (!pw->date_label) pw->date_label = strdup("ERROR");
 
215
  if (!pw->login_label) pw->login_label = strdup ("ERROR (LOGIN)") ;
168
216
 
169
217
  /* Put the version number in the label. */
170
218
  {
174
222
    pw->heading_label = s;
175
223
  }
176
224
 
177
 
  pw->user_string = (p && p->pw_name ? p->pw_name : "???");
 
225
  pw->user_string = strdup (p && p->pw_name ? p->pw_name : "???");
178
226
  pw->passwd_string = strdup("");
179
227
 
180
228
  f = get_string_resource ("passwd.headingFont", "Dialog.Font");
182
230
  if (!pw->heading_font) pw->heading_font = XLoadQueryFont (si->dpy, "fixed");
183
231
  if (f) free (f);
184
232
 
 
233
  f = get_string_resource ("passwd.buttonFont", "Dialog.Font");
 
234
  pw->button_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
 
235
  if (!pw->button_font) pw->button_font = XLoadQueryFont (si->dpy, "fixed");
 
236
  if (f) free (f);
 
237
 
185
238
  f = get_string_resource("passwd.bodyFont", "Dialog.Font");
186
239
  pw->body_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
187
240
  if (!pw->body_font) pw->body_font = XLoadQueryFont (si->dpy, "fixed");
222
275
  pw->passwd_background = get_pixel_resource ("passwd.text.background",
223
276
                                              "Dialog.Text.Background",
224
277
                                              si->dpy, cmap);
 
278
  pw->button_foreground = get_pixel_resource ("splash.Button.foreground",
 
279
                                              "Dialog.Button.Foreground",
 
280
                                              si->dpy, cmap);
 
281
  pw->button_background = get_pixel_resource ("splash.Button.background",
 
282
                                              "Dialog.Button.Background",
 
283
                                              si->dpy, cmap);
225
284
  pw->thermo_foreground = get_pixel_resource ("passwd.thermometer.foreground",
226
285
                                              "Dialog.Thermometer.Foreground",
227
286
                                              si->dpy, cmap);
274
333
    pw->height += ascent + descent;
275
334
 
276
335
    {
277
 
      Dimension w2 = 0, w3 = 0;
278
 
      Dimension h2 = 0, h3 = 0;
 
336
      Dimension w2 = 0, w3 = 0, button_w = 0;
 
337
      Dimension h2 = 0, h3 = 0, button_h = 0;
279
338
      const char *passwd_string = "MMMMMMMMMMMM";
280
339
 
281
340
      /* Measure the user_label. */
313
372
      w2 = w2 + w3 + (pw->shadow_width * 2);
314
373
      h2 = MAX (h2, h3);
315
374
 
 
375
      pw->login_button_width = 0;
 
376
      pw->login_button_height = 0;
 
377
 
 
378
      if (pw->login_button_p)
 
379
        {
 
380
          pw->login_button_enabled_p = True;
 
381
 
 
382
          /* Measure the "New Login" button */
 
383
          XTextExtents (pw->button_font, pw->login_label,
 
384
                        strlen (pw->login_label),
 
385
                        &direction, &ascent, &descent, &overall);
 
386
          button_w = overall.width;
 
387
          button_h = ascent + descent;
 
388
 
 
389
          /* Add some horizontal padding inside the buttons. */
 
390
          button_w += ascent;
 
391
 
 
392
          button_w += ((ascent + descent) / 2) + (pw->shadow_width * 2);
 
393
          button_h += ((ascent + descent) / 2) + (pw->shadow_width * 2);
 
394
 
 
395
          pw->login_button_width = button_w;
 
396
          pw->login_button_height = button_h;
 
397
 
 
398
          w2 = MAX (w2, button_w);
 
399
          h2 += button_h * 1.5;
 
400
        }
 
401
 
316
402
      if (w2 > pw->width)  pw->width  = w2;
317
403
      pw->height += h2;
318
404
    }
333
419
  }
334
420
 
335
421
  attrmask |= CWOverrideRedirect; attrs.override_redirect = True;
336
 
  attrmask |= CWEventMask; attrs.event_mask = ExposureMask|KeyPressMask;
337
 
 
 
422
 
 
423
  attrmask |= CWEventMask;
 
424
  attrs.event_mask = (ExposureMask | KeyPressMask |
 
425
                      ButtonPressMask | ButtonReleaseMask);
 
426
 
 
427
  /* We need to remember the mouse position and restore it afterward, or
 
428
     sometimes (perhaps only with Xinerama?) the mouse gets warped to
 
429
     inside the bounds of the lock dialog window.
 
430
   */
 
431
  {
 
432
    Window pointer_root, pointer_child;
 
433
    int root_x, root_y, win_x, win_y;
 
434
    unsigned int mask;
 
435
    pw->previous_mouse_x = 0;
 
436
    pw->previous_mouse_y = 0;
 
437
    if (XQueryPointer (si->dpy, RootWindowOfScreen (pw->prompt_screen->screen),
 
438
                       &pointer_root, &pointer_child,
 
439
                       &root_x, &root_y, &win_x, &win_y, &mask))
 
440
      {
 
441
        pw->previous_mouse_x = root_x;
 
442
        pw->previous_mouse_y = root_y;
 
443
        if (si->prefs.verbose_p)
 
444
          fprintf (stderr, "%s: %d: mouse is at %d,%d.\n",
 
445
                   blurb(), pw->prompt_screen->number,
 
446
                   pw->previous_mouse_x, pw->previous_mouse_y);
 
447
      }
 
448
    else if (si->prefs.verbose_p)
 
449
      fprintf (stderr, "%s: %d: unable to determine mouse position?\n",
 
450
               blurb(), pw->prompt_screen->number);
 
451
  }
 
452
 
 
453
  /* Figure out where on the desktop to place the window so that it will
 
454
     actually be visible; this takes into account virtual viewports as
 
455
     well as Xinerama. */
338
456
  {
339
457
    int x, y, w, h;
340
 
    get_screen_viewport (si->default_screen, &x, &y, &w, &h, False);
 
458
    get_screen_viewport (pw->prompt_screen, &x, &y, &w, &h,
 
459
                         pw->previous_mouse_x, pw->previous_mouse_y,
 
460
                         si->prefs.verbose_p);
341
461
    if (si->prefs.debug_p) w /= 2;
342
462
    pw->x = x + ((w + pw->width) / 2) - pw->width;
343
463
    pw->y = y + ((h + pw->height) / 2) - pw->height;
357
477
                   attrmask, &attrs);
358
478
  XSetWindowBackground (si->dpy, si->passwd_dialog, pw->background);
359
479
 
360
 
  pw->logo_pixmap = xscreensaver_logo (si->dpy, si->passwd_dialog, cmap,
 
480
  /* We use the default visual, not ssi->visual, so that the logo pixmap's
 
481
     visual matches that of the si->passwd_dialog window. */
 
482
  pw->logo_pixmap = xscreensaver_logo (ssi->screen,
 
483
                                       /* ssi->current_visual, */
 
484
                                       DefaultVisualOfScreen(screen),
 
485
                                       si->passwd_dialog, cmap,
361
486
                                       pw->background, 
362
487
                                       &pw->logo_pixels, &pw->logo_npixels,
363
 
                                       0, True);
 
488
                                       &pw->logo_clipmask, True);
364
489
 
365
490
  /* Before mapping the window, save the bits that are underneath the
366
491
     rectangle the window will occlude.  When we lower the window, we
371
496
    XGCValues gcv;
372
497
    GC gc;
373
498
    pw->save_under = XCreatePixmap (si->dpy,
374
 
                                    si->default_screen->screensaver_window,
 
499
                                    pw->prompt_screen->screensaver_window,
375
500
                                    pw->width + (pw->border_width*2) + 1,
376
501
                                    pw->height + (pw->border_width*2) + 1,
377
 
                                    si->default_screen->current_depth);
 
502
                                    pw->prompt_screen->current_depth);
378
503
    gcv.function = GXcopy;
379
504
    gc = XCreateGC (si->dpy, pw->save_under, GCFunction, &gcv);
380
 
    XCopyArea (si->dpy, si->default_screen->screensaver_window,
 
505
    XCopyArea (si->dpy, pw->prompt_screen->screensaver_window,
381
506
               pw->save_under, gc,
382
507
               pw->x - pw->border_width, pw->y - pw->border_width,
383
508
               pw->width + (pw->border_width*2) + 1,
389
514
  XMapRaised (si->dpy, si->passwd_dialog);
390
515
  XSync (si->dpy, False);
391
516
 
392
 
  move_mouse_grab (si, si->passwd_dialog, si->screens[0].cursor);
 
517
  move_mouse_grab (si, si->passwd_dialog,
 
518
                   (pw->passwd_cursor
 
519
                    ? pw->passwd_cursor
 
520
                    : pw->prompt_screen->cursor),
 
521
                   pw->prompt_screen->number);
393
522
  undo_vp_motion (si);
394
523
 
395
524
  si->pw_data = pw;
396
525
 
 
526
  if (cmap)
 
527
    XInstallColormap (si->dpy, cmap);
397
528
  draw_passwd_window (si);
398
529
  XSync (si->dpy, False);
399
530
}
411
542
  int tb_height;
412
543
 
413
544
  height = (pw->heading_font->ascent + pw->heading_font->descent +
414
 
            pw->body_font->ascent + pw->body_font->descent +
415
 
            (2 * MAX ((pw->label_font->ascent + pw->label_font->descent),
416
 
                      (pw->passwd_font->ascent + pw->passwd_font->descent +
417
 
                       (pw->shadow_width * 4)))) +
418
 
            pw->date_font->ascent + pw->date_font->descent
419
 
            );
420
 
  spacing = ((pw->height - (2 * pw->shadow_width) -
421
 
              pw->internal_border - height)) / 8;
 
545
            pw->body_font->ascent + pw->body_font->descent +
 
546
            (2 * MAX ((pw->label_font->ascent + pw->label_font->descent),
 
547
                      (pw->passwd_font->ascent + pw->passwd_font->descent +
 
548
                       (pw->shadow_width * 4)))) +
 
549
            pw->date_font->ascent + pw->date_font->descent);
 
550
 
 
551
  if (pw->login_button_p)
 
552
    height += ((pw->button_font->ascent + pw->button_font->descent) * 2 +
 
553
               2 * pw->shadow_width);
 
554
 
 
555
  spacing = (((pw->height
 
556
               - ((pw->login_button_p ? 4 : 2) * pw->shadow_width)
 
557
               - pw->internal_border - height))
 
558
             / 8);
 
559
 
422
560
  if (spacing < 0) spacing = 0;
423
561
 
424
562
  gcv.foreground = pw->foreground;
462
600
            string_width (pw->label_font, pw->passwd_label)));
463
601
  XDrawString (si->dpy, si->passwd_dialog, gc1,
464
602
               x2 - string_width (pw->label_font, pw->user_label),
465
 
               y1,
 
603
               y1 - pw->passwd_font->descent,
466
604
               pw->user_label, strlen(pw->user_label));
467
605
 
468
606
  /* the "Password:" prompt
470
608
  y1 += (spacing + tb_height);
471
609
  XDrawString (si->dpy, si->passwd_dialog, gc1,
472
610
               x2 - string_width (pw->label_font, pw->passwd_label),
473
 
               y1,
 
611
               y1 - pw->passwd_font->descent,
474
612
               pw->passwd_label, strlen(pw->passwd_label));
475
613
 
476
614
 
493
631
                  x2 - pw->shadow_width,
494
632
                  y1 - (pw->passwd_font->ascent + pw->passwd_font->descent),
495
633
                  pw->passwd_field_width, pw->passwd_field_height);
496
 
  XDrawString (si->dpy, si->passwd_dialog, gc1, x2, y1,
 
634
  XDrawString (si->dpy, si->passwd_dialog, gc1,
 
635
               x2,
 
636
               y1 - pw->passwd_font->descent,
497
637
               pw->user_string, strlen(pw->user_string));
498
638
 
499
639
  /* the "password" text field
543
683
    XDrawString (si->dpy, si->passwd_dialog, gc1, x2, y1, buf, strlen(buf));
544
684
  }
545
685
 
 
686
  /* The "New Login" button
 
687
   */
 
688
  if (pw->login_button_p)
 
689
    {
 
690
      XSetForeground (si->dpy, gc1, pw->button_foreground);
 
691
      XSetForeground (si->dpy, gc2, pw->button_background);
 
692
      XSetFont (si->dpy, gc1, pw->button_font->fid);
 
693
 
 
694
      sw = string_width (pw->button_font, pw->login_label);
 
695
 
 
696
      x2 = pw->width - pw->internal_border - (pw->shadow_width * 2);
 
697
 
 
698
      /* right aligned button */
 
699
      /* x1 = x2 - pw->login_button_width;  */
 
700
 
 
701
      /* centered button */
 
702
      x1 = (pw->logo_width + pw->thermo_width + (pw->shadow_width * 3) +
 
703
            pw->internal_border);
 
704
      x1 = x1 + (x2 - x1 - pw->login_button_width) / 2;
 
705
 
 
706
      y1 = (pw->height - pw->internal_border - pw->login_button_height +
 
707
            spacing);
 
708
      y2 = (y1 +
 
709
            ((pw->login_button_height -
 
710
              (pw->button_font->ascent + pw->button_font->descent))
 
711
             / 2) +
 
712
            pw->button_font->ascent);
 
713
 
 
714
      pw->login_button_x = x1;
 
715
      pw->login_button_y = y1;
 
716
    }
546
717
 
547
718
  /* The logo
548
719
   */
549
 
  x1 = pw->shadow_width * 3;
550
 
  y1 = pw->shadow_width * 3;
551
 
  x2 = pw->logo_width - (pw->shadow_width * 6);
552
 
  y2 = pw->logo_height - (pw->shadow_width * 6);
 
720
  x1 = pw->shadow_width * 6;
 
721
  y1 = pw->shadow_width * 6;
 
722
  x2 = pw->logo_width - (pw->shadow_width * 12);
 
723
  y2 = pw->logo_height - (pw->shadow_width * 12);
553
724
 
554
725
  if (pw->logo_pixmap)
555
726
    {
559
730
      XGetGeometry (si->dpy, pw->logo_pixmap, &root, &x, &y, &w, &h, &bw, &d);
560
731
      XSetForeground (si->dpy, gc1, pw->foreground);
561
732
      XSetBackground (si->dpy, gc1, pw->background);
 
733
      XSetClipMask (si->dpy, gc1, pw->logo_clipmask);
 
734
      XSetClipOrigin (si->dpy, gc1, x1 + ((x2 - (int)w) / 2), y1 + ((y2 - (int)h) / 2));
562
735
      if (d == 1)
563
736
        XCopyPlane (si->dpy, pw->logo_pixmap, si->passwd_dialog, gc1,
564
737
                    0, 0, w, h,
578
751
  XSetForeground (si->dpy, gc2, pw->thermo_background);
579
752
 
580
753
  pw->thermo_field_x = pw->logo_width + pw->shadow_width;
581
 
  pw->thermo_field_y = pw->shadow_width * 3;
582
 
  pw->thermo_field_height = pw->height - (pw->shadow_width * 6);
 
754
  pw->thermo_field_y = pw->shadow_width * 5;
 
755
  pw->thermo_field_height = pw->height - (pw->shadow_width * 10);
583
756
 
 
757
#if 0
584
758
  /* Solid border inside the logo box. */
585
759
  XSetForeground (si->dpy, gc1, pw->foreground);
586
760
  XDrawRectangle (si->dpy, si->passwd_dialog, gc1, x1, y1, x2-1, y2-1);
 
761
#endif
587
762
 
588
763
  /* The shadow around the logo
589
764
   */
590
765
  draw_shaded_rectangle (si->dpy, si->passwd_dialog,
591
 
                         pw->shadow_width * 2,
592
 
                         pw->shadow_width * 2,
593
 
                         pw->logo_width - (pw->shadow_width * 4),
594
 
                         pw->logo_height - (pw->shadow_width * 4),
 
766
                         pw->shadow_width * 4,
 
767
                         pw->shadow_width * 4,
 
768
                         pw->logo_width - (pw->shadow_width * 8),
 
769
                         pw->logo_height - (pw->shadow_width * 8),
595
770
                         pw->shadow_width,
596
771
                         pw->shadow_bottom, pw->shadow_top);
597
772
 
599
774
   */
600
775
  draw_shaded_rectangle (si->dpy, si->passwd_dialog,
601
776
                         pw->logo_width,
602
 
                         pw->shadow_width * 2,
 
777
                         pw->shadow_width * 4,
603
778
                         pw->thermo_width + (pw->shadow_width * 2),
604
 
                         pw->height - (pw->shadow_width * 4),
 
779
                         pw->height - (pw->shadow_width * 8),
605
780
                         pw->shadow_width,
606
781
                         pw->shadow_bottom, pw->shadow_top);
607
782
 
 
783
#if 1
608
784
  /* Solid border inside the thermometer. */
609
785
  XSetForeground (si->dpy, gc1, pw->foreground);
610
786
  XDrawRectangle (si->dpy, si->passwd_dialog, gc1, 
611
 
                  pw->logo_width + pw->shadow_width,
612
 
                  pw->shadow_width * 3,
613
 
                  pw->thermo_width - 1,
614
 
                  pw->height - (pw->shadow_width * 6) - 1);
 
787
                  pw->thermo_field_x, pw->thermo_field_y,
 
788
                  pw->thermo_width - 1, pw->thermo_field_height - 1);
 
789
#endif
615
790
 
616
791
  /* The shadow around the whole window
617
792
   */
663
838
 
664
839
  XDrawString (si->dpy, si->passwd_dialog, gc1,
665
840
               rects[0].x + pw->shadow_width,
666
 
               rects[0].y + (pw->passwd_font->ascent +
667
 
                             pw->passwd_font->descent),
 
841
               rects[0].y + pw->passwd_font->ascent,
668
842
               pw->passwd_string, strlen(pw->passwd_string));
669
843
 
670
844
  XSetClipMask (si->dpy, gc1, None);
680
854
      if (x > rects[0].x + rects[0].width - 1)
681
855
        x = rects[0].x + rects[0].width - 1;
682
856
      XDrawLine (si->dpy, si->passwd_dialog, gc1, 
683
 
                 x, y, x, y + pw->passwd_font->ascent);
 
857
                 x, y,
 
858
                 x, y + pw->passwd_font->ascent + pw->passwd_font->descent-1);
684
859
    }
685
860
 
686
861
  pw->i_beam = (pw->i_beam + 1) % 4;
688
863
 
689
864
  /* the thermometer
690
865
   */
691
 
  y = pw->thermo_field_height * (1.0 - pw->ratio);
 
866
  y = (pw->thermo_field_height - 2) * (1.0 - pw->ratio);
692
867
  if (y > 0)
693
868
    {
694
869
      XFillRectangle (si->dpy, si->passwd_dialog, gc2,
704
879
                      MAX (0, pw->thermo_field_height - y - 2));
705
880
    }
706
881
 
 
882
  /* The "New Login" button
 
883
   */
 
884
  if (pw->login_button_p)
 
885
    {
 
886
      int x2, y2, sw;
 
887
      XSetFont (si->dpy, gc1, pw->button_font->fid);
 
888
      XSetForeground (si->dpy, gc1,
 
889
                      (pw->login_button_enabled_p
 
890
                       ? pw->passwd_foreground
 
891
                       : pw->shadow_bottom));
 
892
      XSetForeground (si->dpy, gc2, pw->button_background);
 
893
 
 
894
      XFillRectangle (si->dpy, si->passwd_dialog, gc2,
 
895
                      pw->login_button_x, pw->login_button_y,
 
896
                      pw->login_button_width, pw->login_button_height);
 
897
 
 
898
      sw = string_width (pw->button_font, pw->login_label);
 
899
      x2 = pw->login_button_x + ((pw->login_button_width - sw) / 2);
 
900
      y2 = (pw->login_button_y +
 
901
            ((pw->login_button_height -
 
902
              (pw->button_font->ascent + pw->button_font->descent))
 
903
             / 2) +
 
904
            pw->button_font->ascent);
 
905
 
 
906
      XDrawString (si->dpy, si->passwd_dialog, gc1, x2, y2,
 
907
                   pw->login_label, strlen(pw->login_label));
 
908
 
 
909
      draw_shaded_rectangle (si->dpy, si->passwd_dialog,
 
910
                             pw->login_button_x, pw->login_button_y, 
 
911
                             pw->login_button_width, pw->login_button_height,
 
912
                             pw->shadow_width,
 
913
                             (pw->login_button_down_p
 
914
                              ? pw->shadow_bottom
 
915
                              : pw->shadow_top), 
 
916
                             (pw->login_button_down_p
 
917
                              ? pw->shadow_top
 
918
                              : pw->shadow_bottom));
 
919
    }
 
920
 
707
921
  XFreeGC (si->dpy, gc1);
708
922
  XFreeGC (si->dpy, gc2);
709
923
  XSync (si->dpy, False);
713
927
static void
714
928
destroy_passwd_window (saver_info *si)
715
929
{
 
930
  saver_preferences *p = &si->prefs;
716
931
  passwd_dialog_data *pw = si->pw_data;
717
 
  Screen *screen = si->default_screen->screen;
718
 
  Colormap cmap = DefaultColormapOfScreen (screen);
719
 
  Pixel black = BlackPixelOfScreen (screen);
720
 
  Pixel white = WhitePixelOfScreen (screen);
 
932
  saver_screen_info *ssi = pw->prompt_screen;
 
933
  Colormap cmap = DefaultColormapOfScreen (ssi->screen);
 
934
  Pixel black = BlackPixelOfScreen (ssi->screen);
 
935
  Pixel white = WhitePixelOfScreen (ssi->screen);
 
936
  XEvent event;
 
937
 
 
938
  memset (pw->typed_passwd, 0, sizeof(pw->typed_passwd));
 
939
  memset (pw->passwd_string, 0, strlen(pw->passwd_string));
721
940
 
722
941
  if (pw->timer)
723
942
    XtRemoveTimeOut (pw->timer);
724
943
 
725
 
  move_mouse_grab (si, RootWindowOfScreen(si->screens[0].screen),
726
 
                   si->screens[0].cursor);
 
944
  move_mouse_grab (si, RootWindowOfScreen (ssi->screen),
 
945
                   ssi->cursor, ssi->number);
 
946
 
 
947
  if (pw->passwd_cursor)
 
948
    XFreeCursor (si->dpy, pw->passwd_cursor);
 
949
 
 
950
  if (p->verbose_p)
 
951
    fprintf (stderr, "%s: %d: moving mouse back to %d,%d.\n",
 
952
             blurb(), ssi->number,
 
953
             pw->previous_mouse_x, pw->previous_mouse_y);
 
954
 
 
955
  XWarpPointer (si->dpy, None, RootWindowOfScreen (ssi->screen),
 
956
                0, 0, 0, 0,
 
957
                pw->previous_mouse_x, pw->previous_mouse_y);
 
958
 
 
959
  XSync (si->dpy, False);
 
960
  while (XCheckMaskEvent (si->dpy, PointerMotionMask, &event))
 
961
    if (p->verbose_p)
 
962
      fprintf (stderr, "%s: discarding MotionNotify event.\n", blurb());
727
963
 
728
964
  if (si->passwd_dialog)
729
965
    {
736
972
      XGCValues gcv;
737
973
      GC gc;
738
974
      gcv.function = GXcopy;
739
 
      gc = XCreateGC (si->dpy, si->default_screen->screensaver_window,
740
 
                      GCFunction, &gcv);
 
975
      gc = XCreateGC (si->dpy, ssi->screensaver_window, GCFunction, &gcv);
741
976
      XCopyArea (si->dpy, pw->save_under,
742
 
                 si->default_screen->screensaver_window, gc,
 
977
                 ssi->screensaver_window, gc,
743
978
                 0, 0,
744
979
                 pw->width + (pw->border_width*2) + 1,
745
980
                 pw->height + (pw->border_width*2) + 1,
753
988
  if (pw->body_label)    free (pw->body_label);
754
989
  if (pw->user_label)    free (pw->user_label);
755
990
  if (pw->passwd_label)  free (pw->passwd_label);
 
991
  if (pw->date_label)    free (pw->date_label);
 
992
  if (pw->login_label)   free (pw->login_label);
 
993
  if (pw->user_string)   free (pw->user_string);
 
994
  if (pw->passwd_string) free (pw->passwd_string);
756
995
 
757
996
  if (pw->heading_font) XFreeFont (si->dpy, pw->heading_font);
758
997
  if (pw->body_font)    XFreeFont (si->dpy, pw->body_font);
759
998
  if (pw->label_font)   XFreeFont (si->dpy, pw->label_font);
760
999
  if (pw->passwd_font)  XFreeFont (si->dpy, pw->passwd_font);
 
1000
  if (pw->date_font)    XFreeFont (si->dpy, pw->date_font);
 
1001
  if (pw->button_font)  XFreeFont (si->dpy, pw->button_font);
761
1002
 
762
1003
  if (pw->foreground != black && pw->foreground != white)
763
1004
    XFreeColors (si->dpy, cmap, &pw->foreground, 1, 0L);
764
1005
  if (pw->background != black && pw->background != white)
765
1006
    XFreeColors (si->dpy, cmap, &pw->background, 1, 0L);
 
1007
  if (!(pw->button_foreground == black || pw->button_foreground == white))
 
1008
    XFreeColors (si->dpy, cmap, &pw->button_foreground, 1, 0L);
 
1009
  if (!(pw->button_background == black || pw->button_background == white))
 
1010
    XFreeColors (si->dpy, cmap, &pw->button_background, 1, 0L);
766
1011
  if (pw->passwd_foreground != black && pw->passwd_foreground != white)
767
1012
    XFreeColors (si->dpy, cmap, &pw->passwd_foreground, 1, 0L);
768
1013
  if (pw->passwd_background != black && pw->passwd_background != white)
778
1023
 
779
1024
  if (pw->logo_pixmap)
780
1025
    XFreePixmap (si->dpy, pw->logo_pixmap);
781
 
  if (pw->logo_npixels && pw->logo_pixels)
782
 
    XFreeColors (si->dpy, cmap, pw->logo_pixels, pw->logo_npixels, 0L);
 
1026
  if (pw-> logo_clipmask)
 
1027
    XFreePixmap (si->dpy, pw->logo_clipmask);
783
1028
  if (pw->logo_pixels)
784
 
    free (pw->logo_pixels);
 
1029
    {
 
1030
      if (pw->logo_npixels)
 
1031
        XFreeColors (si->dpy, cmap, pw->logo_pixels, pw->logo_npixels, 0L);
 
1032
      free (pw->logo_pixels);
 
1033
      pw->logo_pixels = 0;
 
1034
      pw->logo_npixels = 0;
 
1035
    }
 
1036
 
 
1037
  if (pw->save_under)
 
1038
    XFreePixmap (si->dpy, pw->save_under);
 
1039
 
 
1040
  if (cmap)
 
1041
    XInstallColormap (si->dpy, cmap);
785
1042
 
786
1043
  memset (pw, 0, sizeof(*pw));
787
1044
  free (pw);
788
 
 
789
1045
  si->pw_data = 0;
790
1046
}
791
1047
 
792
1048
 
 
1049
static Bool error_handler_hit_p = False;
 
1050
 
 
1051
static int
 
1052
ignore_all_errors_ehandler (Display *dpy, XErrorEvent *error)
 
1053
{
 
1054
  error_handler_hit_p = True;
 
1055
  return 0;
 
1056
}
 
1057
 
 
1058
 
793
1059
#ifdef HAVE_XHPDISABLERESET
794
1060
/* This function enables and disables the C-Sh-Reset hot-key, which
795
1061
   normally resets the X server (logging out the logged-in user.)
816
1082
}
817
1083
#endif /* HAVE_XHPDISABLERESET */
818
1084
 
 
1085
 
 
1086
#ifdef HAVE_XF86MISCSETGRABKEYSSTATE
 
1087
 
 
1088
/* This function enables and disables the Ctrl-Alt-KP_star and 
 
1089
   Ctrl-Alt-KP_slash hot-keys, which (in XFree86 4.2) break any
 
1090
   grabs and/or kill the grabbing client.  That would effectively
 
1091
   unlock the screen, so we don't like that.
 
1092
 
 
1093
   The Ctrl-Alt-KP_star and Ctrl-Alt-KP_slash hot-keys only exist
 
1094
   if AllowDeactivateGrabs and/or AllowClosedownGrabs are turned on
 
1095
   in XF86Config.  I believe they are disabled by default.
 
1096
 
 
1097
   This does not affect any other keys (specifically Ctrl-Alt-BS or
 
1098
   Ctrl-Alt-F1) but I wish it did.  Maybe it will someday.
 
1099
 */
 
1100
static void
 
1101
xfree_lock_grab_smasher (saver_info *si, Bool lock_p)
 
1102
{
 
1103
  saver_preferences *p = &si->prefs;
 
1104
  int status;
 
1105
 
 
1106
  XErrorHandler old_handler;
 
1107
  XSync (si->dpy, False);
 
1108
  error_handler_hit_p = False;
 
1109
  old_handler = XSetErrorHandler (ignore_all_errors_ehandler);
 
1110
  XSync (si->dpy, False);
 
1111
  status = XF86MiscSetGrabKeysState (si->dpy, !lock_p);
 
1112
  XSync (si->dpy, False);
 
1113
  if (error_handler_hit_p) status = 666;
 
1114
 
 
1115
  if (!lock_p && status == MiscExtGrabStateAlready)
 
1116
    status = MiscExtGrabStateSuccess;  /* shut up, consider this success */
 
1117
 
 
1118
  if (p->verbose_p && status != MiscExtGrabStateSuccess)
 
1119
    fprintf (stderr, "%s: error: XF86MiscSetGrabKeysState(%d) returned %s\n",
 
1120
             blurb(), !lock_p,
 
1121
             (status == MiscExtGrabStateSuccess ? "MiscExtGrabStateSuccess" :
 
1122
              status == MiscExtGrabStateLocked  ? "MiscExtGrabStateLocked"  :
 
1123
              status == MiscExtGrabStateAlready ? "MiscExtGrabStateAlready" :
 
1124
              status == 666 ? "an X error" :
 
1125
              "unknown value"));
 
1126
 
 
1127
  XSync (si->dpy, False);
 
1128
  XSetErrorHandler (old_handler);
 
1129
  XSync (si->dpy, False);
 
1130
}
 
1131
#endif /* HAVE_XF86MISCSETGRABKEYSSTATE */
 
1132
 
 
1133
 
819
1134
 
820
1135
 
821
1136
/* This function enables and disables the C-Sh-F1 ... F12 hot-keys,
887
1202
 */
888
1203
#ifdef HAVE_XF86VMODE
889
1204
 
890
 
static int ignore_all_errors_ehandler (Display *dpy, XErrorEvent *error);
891
 
static Bool vp_got_error = False;
892
 
 
893
1205
static void
894
1206
xfree_lock_mode_switch (saver_info *si, Bool lock_p)
895
1207
{
896
 
  static Bool mode_locked_p = False;
 
1208
  static Bool any_mode_locked_p = False;
897
1209
  saver_preferences *p = &si->prefs;
898
 
  int screen = 0;  /* always screen 0 */
 
1210
  int screen;
899
1211
  int event, error;
900
1212
  Bool status;
901
1213
  XErrorHandler old_handler;
902
1214
 
903
 
  if (mode_locked_p == lock_p)
 
1215
  if (any_mode_locked_p == lock_p)
904
1216
    return;
905
1217
  if (!XF86VidModeQueryExtension (si->dpy, &event, &error))
906
1218
    return;
907
1219
 
908
 
  XSync (si->dpy, False);
909
 
  old_handler = XSetErrorHandler (ignore_all_errors_ehandler);
910
 
  status = XF86VidModeLockModeSwitch (si->dpy, screen, lock_p);
911
 
  XSync (si->dpy, False);
912
 
  XSetErrorHandler (old_handler);
913
 
  if (vp_got_error) status = False;
914
 
 
915
 
  if (status)
916
 
    mode_locked_p = lock_p;
917
 
 
918
 
  if (!status && (p->verbose_p || !lock_p))
919
 
    /* Only print this when verbose, or when we locked but can't unlock.
920
 
       I tried printing this message whenever it comes up, but
921
 
       mode-locking always fails if DontZoom is set in XF86Config. */
922
 
    fprintf (stderr, "%s: unable to %s mode switching!\n",
923
 
             blurb(), (lock_p ? "lock" : "unlock"));
924
 
  else if (p->verbose_p)
925
 
    fprintf (stderr, "%s: %s mode switching.\n",
926
 
             blurb(), (lock_p ? "locked" : "unlocked"));
927
 
}
928
 
 
929
 
static int
930
 
ignore_all_errors_ehandler (Display *dpy, XErrorEvent *error)
931
 
{
932
 
  vp_got_error = True;
933
 
  return 0;
934
 
}
935
 
 
 
1220
  for (screen = 0; screen < (si->xinerama_p ? 1 : si->nscreens); screen++)
 
1221
    {
 
1222
      XSync (si->dpy, False);
 
1223
      old_handler = XSetErrorHandler (ignore_all_errors_ehandler);
 
1224
      error_handler_hit_p = False;
 
1225
      status = XF86VidModeLockModeSwitch (si->dpy, screen, lock_p);
 
1226
      XSync (si->dpy, False);
 
1227
      XSetErrorHandler (old_handler);
 
1228
      if (error_handler_hit_p) status = False;
 
1229
 
 
1230
      if (status)
 
1231
        any_mode_locked_p = lock_p;
 
1232
 
 
1233
      if (!status && (p->verbose_p || !lock_p))
 
1234
        /* Only print this when verbose, or when we locked but can't unlock.
 
1235
           I tried printing this message whenever it comes up, but
 
1236
           mode-locking always fails if DontZoom is set in XF86Config. */
 
1237
        fprintf (stderr, "%s: %d: unable to %s mode switching!\n",
 
1238
                 blurb(), screen, (lock_p ? "lock" : "unlock"));
 
1239
      else if (p->verbose_p)
 
1240
        fprintf (stderr, "%s: %d: %s mode switching.\n",
 
1241
                 blurb(), screen, (lock_p ? "locked" : "unlocked"));
 
1242
    }
 
1243
}
936
1244
#endif /* HAVE_XF86VMODE */
937
1245
 
938
1246
 
945
1253
{
946
1254
#ifdef HAVE_XF86VMODE
947
1255
  saver_preferences *p = &si->prefs;
948
 
  int screen = 0;  /* always screen 0 */
949
 
  saver_screen_info *ssi = &si->screens[screen];
950
 
  int event, error, x, y;
951
 
  Bool status;
 
1256
  int screen;
 
1257
  int event, error;
952
1258
 
953
 
  if (ssi->blank_vp_x == -1 && ssi->blank_vp_y == -1)
954
 
    return;
955
1259
  if (!XF86VidModeQueryExtension (si->dpy, &event, &error))
956
1260
    return;
957
 
  if (!XF86VidModeGetViewPort (si->dpy, 0, &x, &y))
958
 
    return;
959
 
  if (ssi->blank_vp_x == x && ssi->blank_vp_y == y)
960
 
    return;
 
1261
 
 
1262
  for (screen = 0; screen < si->nscreens; screen++)
 
1263
    {
 
1264
      saver_screen_info *ssi = &si->screens[screen];
 
1265
      int x, y;
 
1266
      Bool status;
 
1267
 
 
1268
      if (ssi->blank_vp_x == -1 && ssi->blank_vp_y == -1)
 
1269
        break;
 
1270
      if (!XF86VidModeGetViewPort (si->dpy, screen, &x, &y))
 
1271
        return;
 
1272
      if (ssi->blank_vp_x == x && ssi->blank_vp_y == y)
 
1273
        return;
961
1274
    
962
 
  /* We're going to move the viewport.  The mouse has just been grabbed on
963
 
     (and constrained to, thus warped to) the password window, so it is no
964
 
     longer near the edge of the screen.  However, wait a bit anyway, just
965
 
     to make sure the server drains its last motion event, so that the
966
 
     screen doesn't continue to scroll after we've reset the viewport.
967
 
   */
968
 
  XSync (si->dpy, False);
969
 
  usleep (250000);  /* 1/4 second */
970
 
  XSync (si->dpy, False);
971
 
 
972
 
  status = XF86VidModeSetViewPort (si->dpy, screen,
973
 
                                   ssi->blank_vp_x, ssi->blank_vp_y);
974
 
 
975
 
  if (!status)
976
 
    fprintf (stderr, "%s: unable to move vp from (%d,%d) back to (%d,%d)!\n",
977
 
             blurb(), x, y, ssi->blank_vp_x, ssi->blank_vp_y);
978
 
  else if (p->verbose_p)
979
 
    fprintf (stderr, "%s: vp moved to (%d,%d); moved it back to (%d,%d).\n",
980
 
             blurb(), x, y, ssi->blank_vp_x, ssi->blank_vp_y);
981
 
 
 
1275
      /* We're going to move the viewport.  The mouse has just been grabbed on
 
1276
         (and constrained to, thus warped to) the password window, so it is no
 
1277
         longer near the edge of the screen.  However, wait a bit anyway, just
 
1278
         to make sure the server drains its last motion event, so that the
 
1279
         screen doesn't continue to scroll after we've reset the viewport.
 
1280
       */
 
1281
      XSync (si->dpy, False);
 
1282
      usleep (250000);  /* 1/4 second */
 
1283
      XSync (si->dpy, False);
 
1284
 
 
1285
      status = XF86VidModeSetViewPort (si->dpy, screen,
 
1286
                                       ssi->blank_vp_x, ssi->blank_vp_y);
 
1287
 
 
1288
      if (!status)
 
1289
        fprintf (stderr,
 
1290
                 "%s: %d: unable to move vp from (%d,%d) back to (%d,%d)!\n",
 
1291
                 blurb(), screen, x, y, ssi->blank_vp_x, ssi->blank_vp_y);
 
1292
      else if (p->verbose_p)
 
1293
        fprintf (stderr,
 
1294
                 "%s: %d: vp moved to (%d,%d); moved it back to (%d,%d).\n",
 
1295
                 blurb(), screen, x, y, ssi->blank_vp_x, ssi->blank_vp_y);
 
1296
    }
982
1297
#endif /* HAVE_XF86VMODE */
983
1298
}
984
1299
 
1012
1327
  else
1013
1328
    pw->timer = 0;
1014
1329
 
1015
 
  idle_timer ((XtPointer) si, id);
 
1330
  idle_timer ((XtPointer) si, 0);
1016
1331
}
1017
1332
 
1018
1333
 
1019
1334
static XComposeStatus *compose_status;
1020
1335
 
1021
1336
static void
 
1337
handle_passwd_button (saver_info *si, XEvent *event)
 
1338
{
 
1339
  saver_preferences *p = &si->prefs;
 
1340
  Bool mouse_in_box = False;
 
1341
  Bool hit_p = False;
 
1342
  passwd_dialog_data *pw = si->pw_data;
 
1343
  saver_screen_info *ssi = pw->prompt_screen;
 
1344
 
 
1345
  if (! pw->login_button_enabled_p)
 
1346
    return;
 
1347
 
 
1348
  mouse_in_box = 
 
1349
    (event->xbutton.x >= pw->login_button_x &&
 
1350
     event->xbutton.x <= pw->login_button_x + pw->login_button_width &&
 
1351
     event->xbutton.y >= pw->login_button_y &&
 
1352
     event->xbutton.y <= pw->login_button_y + pw->login_button_height);
 
1353
 
 
1354
  if (ButtonRelease == event->xany.type &&
 
1355
      pw->login_button_down_p &&
 
1356
      mouse_in_box)
 
1357
    {
 
1358
      /* Only allow them to press the button once: don't want to
 
1359
         accidentally launch a dozen gdm choosers if the machine
 
1360
         is being slow.
 
1361
       */
 
1362
      hit_p = True;
 
1363
      pw->login_button_enabled_p = False;
 
1364
    }
 
1365
 
 
1366
  pw->login_button_down_p = (mouse_in_box &&
 
1367
                             ButtonRelease != event->xany.type);
 
1368
 
 
1369
  update_passwd_window (si, 0, pw->ratio);
 
1370
 
 
1371
  if (hit_p)
 
1372
    fork_and_exec (ssi, p->new_login_command);
 
1373
}
 
1374
 
 
1375
 
 
1376
static void
1022
1377
handle_passwd_key (saver_info *si, XKeyEvent *event)
1023
1378
{
1024
1379
  saver_preferences *p = &si->prefs;
1091
1446
  saver_preferences *p = &si->prefs;
1092
1447
  char *msg = 0;
1093
1448
  XEvent event;
 
1449
  unsigned int caps_p = 0;
 
1450
 
1094
1451
  passwd_animate_timer ((XtPointer) si, 0);
1095
1452
 
1096
1453
  while (si->pw_data && si->pw_data->state == pw_read)
1099
1456
      if (event.xany.window == si->passwd_dialog && event.xany.type == Expose)
1100
1457
        draw_passwd_window (si);
1101
1458
      else if (event.xany.type == KeyPress)
1102
 
        handle_passwd_key (si, &event.xkey);
 
1459
        {
 
1460
          handle_passwd_key (si, &event.xkey);
 
1461
          caps_p = (event.xkey.state & LockMask);
 
1462
        }
 
1463
      else if ((event.xany.type == ButtonPress || 
 
1464
                event.xany.type == ButtonRelease) && 
 
1465
               si->pw_data->login_button_p)
 
1466
        handle_passwd_button (si, &event);
1103
1467
      else
1104
1468
        XtDispatchEvent (&event);
1105
1469
    }
1109
1473
    case pw_ok:   msg = 0; break;
1110
1474
    case pw_null: msg = ""; break;
1111
1475
    case pw_time: msg = "Timed out!"; break;
1112
 
    default:      msg = "Sorry!"; break;
 
1476
    default:      msg = (caps_p ? "CapsLock?" : "Sorry!"); break;
1113
1477
    }
1114
1478
 
1115
1479
  if (si->pw_data->state == pw_fail)
1121
1485
      case pw_ok:
1122
1486
        fprintf (stderr, "%s: password correct.\n", blurb()); break;
1123
1487
      case pw_fail:
1124
 
        fprintf (stderr, "%s: password incorrect!\n", blurb()); break;
 
1488
        fprintf (stderr, "%s: password incorrect!%s\n", blurb(),
 
1489
                 (caps_p ? "  (CapsLock)" : ""));
 
1490
        break;
1125
1491
      case pw_null:
1126
1492
      case pw_cancel:
1127
1493
        fprintf (stderr, "%s: password entry cancelled.\n", blurb()); break;
1225
1591
unlock_p (saver_info *si)
1226
1592
{
1227
1593
  saver_preferences *p = &si->prefs;
1228
 
  Screen *screen = si->default_screen->screen;
1229
 
  Colormap cmap = DefaultColormapOfScreen (screen);
1230
1594
  Bool status;
1231
1595
 
1232
1596
  raise_window (si, True, True, True);
1238
1602
    destroy_passwd_window (si);
1239
1603
 
1240
1604
  make_passwd_window (si);
1241
 
  if (cmap) XInstallColormap (si->dpy, cmap);
1242
1605
 
1243
1606
  compose_status = calloc (1, sizeof (*compose_status));
1244
1607
 
1251
1614
  free (compose_status);
1252
1615
  compose_status = 0;
1253
1616
 
1254
 
  cmap = si->default_screen->cmap;
1255
 
  if (cmap) XInstallColormap (si->dpy, cmap);
1256
 
 
1257
1617
  return status;
1258
1618
}
1259
1619
 
1272
1632
#ifdef HAVE_XF86VMODE
1273
1633
  xfree_lock_mode_switch (si, locked_p);        /* turn off/on C-Alt-Plus */
1274
1634
#endif
 
1635
#ifdef HAVE_XF86MISCSETGRABKEYSSTATE
 
1636
  xfree_lock_grab_smasher (si, locked_p);       /* turn off/on C-Alt-KP-*,/ */
 
1637
#endif
1275
1638
 
1276
1639
  store_saver_status (si);                      /* store locked-p */
1277
1640
}