118
133
Dimension passwd_field_x, passwd_field_y;
119
134
Dimension passwd_field_width, passwd_field_height;
136
Dimension login_button_x, login_button_y;
137
Dimension login_button_width, login_button_height;
121
139
Dimension thermo_field_x, thermo_field_y;
122
140
Dimension thermo_field_height;
124
142
Pixmap logo_pixmap;
143
Pixmap logo_clipmask;
125
144
int logo_npixels;
126
145
unsigned long *logo_pixels;
147
Cursor passwd_cursor;
148
Bool login_button_down_p;
150
Bool login_button_enabled_p;
128
152
Pixmap save_under;
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);
173
saver_screen_info *ssi = &si->screens [mouse_screen (si)];
175
/* Display the button only if the "newLoginCommand" pref is non-null.
177
pw->login_button_p = (si->prefs.new_login_command &&
178
*si->prefs.new_login_command);
180
if (pw->login_button_p)
181
pw->passwd_cursor = XCreateFontCursor (si->dpy, XC_top_left_arrow);
183
pw->passwd_cursor = 0;
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);
190
screen = pw->prompt_screen->screen;
191
cmap = DefaultColormapOfScreen (screen);
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");
159
206
pw->date_label = get_string_resource ("dateFormat", "DateFormat");
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)") ;
169
217
/* Put the version number in the label. */
182
230
if (!pw->heading_font) pw->heading_font = XLoadQueryFont (si->dpy, "fixed");
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");
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",
278
pw->button_foreground = get_pixel_resource ("splash.Button.foreground",
279
"Dialog.Button.Foreground",
281
pw->button_background = get_pixel_resource ("splash.Button.background",
282
"Dialog.Button.Background",
225
284
pw->thermo_foreground = get_pixel_resource ("passwd.thermometer.foreground",
226
285
"Dialog.Thermometer.Foreground",
274
333
pw->height += ascent + descent;
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";
281
340
/* Measure the user_label. */
313
372
w2 = w2 + w3 + (pw->shadow_width * 2);
314
373
h2 = MAX (h2, h3);
375
pw->login_button_width = 0;
376
pw->login_button_height = 0;
378
if (pw->login_button_p)
380
pw->login_button_enabled_p = True;
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;
389
/* Add some horizontal padding inside the buttons. */
392
button_w += ((ascent + descent) / 2) + (pw->shadow_width * 2);
393
button_h += ((ascent + descent) / 2) + (pw->shadow_width * 2);
395
pw->login_button_width = button_w;
396
pw->login_button_height = button_h;
398
w2 = MAX (w2, button_w);
399
h2 += button_h * 1.5;
316
402
if (w2 > pw->width) pw->width = w2;
317
403
pw->height += h2;
335
421
attrmask |= CWOverrideRedirect; attrs.override_redirect = True;
336
attrmask |= CWEventMask; attrs.event_mask = ExposureMask|KeyPressMask;
423
attrmask |= CWEventMask;
424
attrs.event_mask = (ExposureMask | KeyPressMask |
425
ButtonPressMask | ButtonReleaseMask);
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.
432
Window pointer_root, pointer_child;
433
int root_x, root_y, win_x, win_y;
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))
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);
448
else if (si->prefs.verbose_p)
449
fprintf (stderr, "%s: %d: unable to determine mouse position?\n",
450
blurb(), pw->prompt_screen->number);
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
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);
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,
362
487
&pw->logo_pixels, &pw->logo_npixels,
488
&pw->logo_clipmask, True);
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
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,
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
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);
551
if (pw->login_button_p)
552
height += ((pw->button_font->ascent + pw->button_font->descent) * 2 +
553
2 * pw->shadow_width);
555
spacing = (((pw->height
556
- ((pw->login_button_p ? 4 : 2) * pw->shadow_width)
557
- pw->internal_border - height))
422
560
if (spacing < 0) spacing = 0;
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),
603
y1 - pw->passwd_font->descent,
466
604
pw->user_label, strlen(pw->user_label));
468
606
/* the "Password:" prompt
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,
636
y1 - pw->passwd_font->descent,
497
637
pw->user_string, strlen(pw->user_string));
499
639
/* the "password" text field
543
683
XDrawString (si->dpy, si->passwd_dialog, gc1, x2, y1, buf, strlen(buf));
686
/* The "New Login" button
688
if (pw->login_button_p)
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);
694
sw = string_width (pw->button_font, pw->login_label);
696
x2 = pw->width - pw->internal_border - (pw->shadow_width * 2);
698
/* right aligned button */
699
/* x1 = x2 - pw->login_button_width; */
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;
706
y1 = (pw->height - pw->internal_border - pw->login_button_height +
709
((pw->login_button_height -
710
(pw->button_font->ascent + pw->button_font->descent))
712
pw->button_font->ascent);
714
pw->login_button_x = x1;
715
pw->login_button_y = y1;
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);
554
725
if (pw->logo_pixmap)
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));
563
736
XCopyPlane (si->dpy, pw->logo_pixmap, si->passwd_dialog, gc1,
578
751
XSetForeground (si->dpy, gc2, pw->thermo_background);
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);
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);
588
763
/* The shadow around the logo
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);
600
775
draw_shaded_rectangle (si->dpy, si->passwd_dialog,
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);
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);
616
791
/* The shadow around the whole window
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));
670
844
XSetClipMask (si->dpy, gc1, None);
704
879
MAX (0, pw->thermo_field_height - y - 2));
882
/* The "New Login" button
884
if (pw->login_button_p)
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);
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);
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))
904
pw->button_font->ascent);
906
XDrawString (si->dpy, si->passwd_dialog, gc1, x2, y2,
907
pw->login_label, strlen(pw->login_label));
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,
913
(pw->login_button_down_p
916
(pw->login_button_down_p
918
: pw->shadow_bottom));
707
921
XFreeGC (si->dpy, gc1);
708
922
XFreeGC (si->dpy, gc2);
709
923
XSync (si->dpy, False);
714
928
destroy_passwd_window (saver_info *si)
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);
938
memset (pw->typed_passwd, 0, sizeof(pw->typed_passwd));
939
memset (pw->passwd_string, 0, strlen(pw->passwd_string));
723
942
XtRemoveTimeOut (pw->timer);
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);
947
if (pw->passwd_cursor)
948
XFreeCursor (si->dpy, pw->passwd_cursor);
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);
955
XWarpPointer (si->dpy, None, RootWindowOfScreen (ssi->screen),
957
pw->previous_mouse_x, pw->previous_mouse_y);
959
XSync (si->dpy, False);
960
while (XCheckMaskEvent (si->dpy, PointerMotionMask, &event))
962
fprintf (stderr, "%s: discarding MotionNotify event.\n", blurb());
728
964
if (si->passwd_dialog)
738
974
gcv.function = GXcopy;
739
gc = XCreateGC (si->dpy, si->default_screen->screensaver_window,
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,
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);
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);
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)
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);
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;
1038
XFreePixmap (si->dpy, pw->save_under);
1041
XInstallColormap (si->dpy, cmap);
786
1043
memset (pw, 0, sizeof(*pw));
789
1045
si->pw_data = 0;
1049
static Bool error_handler_hit_p = False;
1052
ignore_all_errors_ehandler (Display *dpy, XErrorEvent *error)
1054
error_handler_hit_p = True;
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.)
817
1083
#endif /* HAVE_XHPDISABLERESET */
1086
#ifdef HAVE_XF86MISCSETGRABKEYSSTATE
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.
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.
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.
1101
xfree_lock_grab_smasher (saver_info *si, Bool lock_p)
1103
saver_preferences *p = &si->prefs;
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;
1115
if (!lock_p && status == MiscExtGrabStateAlready)
1116
status = MiscExtGrabStateSuccess; /* shut up, consider this success */
1118
if (p->verbose_p && status != MiscExtGrabStateSuccess)
1119
fprintf (stderr, "%s: error: XF86MiscSetGrabKeysState(%d) returned %s\n",
1121
(status == MiscExtGrabStateSuccess ? "MiscExtGrabStateSuccess" :
1122
status == MiscExtGrabStateLocked ? "MiscExtGrabStateLocked" :
1123
status == MiscExtGrabStateAlready ? "MiscExtGrabStateAlready" :
1124
status == 666 ? "an X error" :
1127
XSync (si->dpy, False);
1128
XSetErrorHandler (old_handler);
1129
XSync (si->dpy, False);
1131
#endif /* HAVE_XF86MISCSETGRABKEYSSTATE */
821
1136
/* This function enables and disables the C-Sh-F1 ... F12 hot-keys,
888
1203
#ifdef HAVE_XF86VMODE
890
static int ignore_all_errors_ehandler (Display *dpy, XErrorEvent *error);
891
static Bool vp_got_error = False;
894
1206
xfree_lock_mode_switch (saver_info *si, Bool lock_p)
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 */
899
1211
int event, error;
901
1213
XErrorHandler old_handler;
903
if (mode_locked_p == lock_p)
1215
if (any_mode_locked_p == lock_p)
905
1217
if (!XF86VidModeQueryExtension (si->dpy, &event, &error))
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;
916
mode_locked_p = lock_p;
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"));
930
ignore_all_errors_ehandler (Display *dpy, XErrorEvent *error)
1220
for (screen = 0; screen < (si->xinerama_p ? 1 : si->nscreens); screen++)
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;
1231
any_mode_locked_p = lock_p;
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"));
936
1244
#endif /* HAVE_XF86VMODE */
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;
953
if (ssi->blank_vp_x == -1 && ssi->blank_vp_y == -1)
955
1259
if (!XF86VidModeQueryExtension (si->dpy, &event, &error))
957
if (!XF86VidModeGetViewPort (si->dpy, 0, &x, &y))
959
if (ssi->blank_vp_x == x && ssi->blank_vp_y == y)
1262
for (screen = 0; screen < si->nscreens; screen++)
1264
saver_screen_info *ssi = &si->screens[screen];
1268
if (ssi->blank_vp_x == -1 && ssi->blank_vp_y == -1)
1270
if (!XF86VidModeGetViewPort (si->dpy, screen, &x, &y))
1272
if (ssi->blank_vp_x == x && ssi->blank_vp_y == y)
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.
968
XSync (si->dpy, False);
969
usleep (250000); /* 1/4 second */
970
XSync (si->dpy, False);
972
status = XF86VidModeSetViewPort (si->dpy, screen,
973
ssi->blank_vp_x, ssi->blank_vp_y);
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);
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.
1281
XSync (si->dpy, False);
1282
usleep (250000); /* 1/4 second */
1283
XSync (si->dpy, False);
1285
status = XF86VidModeSetViewPort (si->dpy, screen,
1286
ssi->blank_vp_x, ssi->blank_vp_y);
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)
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);
982
1297
#endif /* HAVE_XF86VMODE */
1015
idle_timer ((XtPointer) si, id);
1330
idle_timer ((XtPointer) si, 0);
1019
1334
static XComposeStatus *compose_status;
1337
handle_passwd_button (saver_info *si, XEvent *event)
1339
saver_preferences *p = &si->prefs;
1340
Bool mouse_in_box = False;
1342
passwd_dialog_data *pw = si->pw_data;
1343
saver_screen_info *ssi = pw->prompt_screen;
1345
if (! pw->login_button_enabled_p)
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);
1354
if (ButtonRelease == event->xany.type &&
1355
pw->login_button_down_p &&
1358
/* Only allow them to press the button once: don't want to
1359
accidentally launch a dozen gdm choosers if the machine
1363
pw->login_button_enabled_p = False;
1366
pw->login_button_down_p = (mouse_in_box &&
1367
ButtonRelease != event->xany.type);
1369
update_passwd_window (si, 0, pw->ratio);
1372
fork_and_exec (ssi, p->new_login_command);
1022
1377
handle_passwd_key (saver_info *si, XKeyEvent *event)
1024
1379
saver_preferences *p = &si->prefs;
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);
1460
handle_passwd_key (si, &event.xkey);
1461
caps_p = (event.xkey.state & LockMask);
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);
1104
1468
XtDispatchEvent (&event);