X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fbsod.c;h=bbbc2ca29b011d4ac3b1fb2b22d88822b6e9d8c7;hb=a719ec12b8b2563112366a8ac3196816fd64d2c7;hp=3f3cd346fb69de8f803e41174e2ddbe5ac1963b2;hpb=c31d10b6605cd8dc1a7b61fef4256f06198767e5;p=xscreensaver diff --git a/hacks/bsod.c b/hacks/bsod.c index 3f3cd346..bbbc2ca2 100644 --- a/hacks/bsod.c +++ b/hacks/bsod.c @@ -157,22 +157,36 @@ double_pixmap(Display *dpy, GC gc, Visual *visual, int depth, Pixmap pixmap, static Bool bsod_sleep(Display *dpy, int seconds) { - XEvent event; int q = seconds * 4; - int mask = KeyPressMask|ButtonPressMask; + int quantum = 250000; + + if (seconds == -1) + q = 1, quantum = 100000; + do { XSync(dpy, False); - if (XCheckMaskEvent(dpy, mask, &event)) - { - while (XCheckMaskEvent(dpy, mask, &event)) - ; - return True; - } + while (XPending (dpy)) + { + XEvent event; + XNextEvent (dpy, &event); + if (event.xany.type == ButtonPress) + return True; + if (event.xany.type == KeyPress) + { + KeySym keysym; + char c = 0; + XLookupString (&event.xkey, &c, 1, &keysym, 0); + if (c == ' ' || c == '\t' || c == '\r' || c == '\n') + return True; + } + screenhack_handle_event (dpy, &event); + } + if (q > 0) { q--; - usleep(250000); + usleep(quantum); } } while (q > 0); @@ -310,10 +324,10 @@ sco (Display *dpy, Window window, int delay) const char *def_font = "fixed"; XFontStruct *font; GC gc; - int lines = 1; + int lines_1 = 0, lines_2 = 0, lines_3 = 0, lines_4 = 0; const char *s; - const char *sco_panic = + const char *sco_panic_1 = ("Unexpected trap in kernel mode:\n" "\n" "cr0 0x80010013 cr2 0x00000014 cr3 0x00000000 tlb 0x00000000\n" @@ -325,11 +339,17 @@ sco (Display *dpy, Window window, int delay) "\n" "PANIC: k_trap - kernel mode trap type 0x0000000E\n" "Trying to dump 5023 pages to dumpdev hd (1/41), 63 pages per '.'\n" - "...............................................................................\n" - "5023 pages dumped\n" + ); + const char *sco_panic_2 = + ("...............................................................................\n" + ); + const char *sco_panic_3 = + ("5023 pages dumped\n" "\n" "\n" - "** Safe to Power Off **\n" + ); + const char *sco_panic_4 = + ("** Safe to Power Off **\n" " - or -\n" "** Press Any Key to Reboot **\n" ); @@ -337,7 +357,10 @@ sco (Display *dpy, Window window, int delay) if (!get_boolean_resource("doSCO", "DoSCO")) return False; - for (s = sco_panic; *s; s++) if (*s == '\n') lines++; + for (s = sco_panic_1; *s; s++) if (*s == '\n') lines_1++; + for (s = sco_panic_2; *s; s++) if (*s == '\n') lines_2++; + for (s = sco_panic_3; *s; s++) if (*s == '\n') lines_3++; + for (s = sco_panic_4; *s; s++) if (*s == '\n') lines_4++; XGetWindowAttributes (dpy, window, &xgwa); @@ -365,13 +388,45 @@ sco (Display *dpy, Window window, int delay) gc = XCreateGC(dpy, window, GCFont|GCForeground|GCBackground, &gcv); draw_string(dpy, window, gc, &gcv, font, - 10, xgwa.height - (lines * (font->ascent + font->descent + 1)), + 10, xgwa.height - ((lines_1 + lines_2 + lines_3 + lines_4 + 1) * + (font->ascent + font->descent + 1)), 10, 10, - sco_panic, 0); - XFreeGC(dpy, gc); + sco_panic_1, 0); XSync(dpy, False); + for (s = sco_panic_2; *s; s++) + { + char *ss = strdup(sco_panic_2); + ss[s - sco_panic_2] = 0; + draw_string(dpy, window, gc, &gcv, font, + 10, xgwa.height - ((lines_2 + lines_3 + lines_4 + 1) * + (font->ascent + font->descent + 1)), + 10, 10, + ss, 0); + XSync(dpy, False); + free(ss); + if (bsod_sleep (dpy, -1)) + goto DONE; + } + + draw_string(dpy, window, gc, &gcv, font, + 10, xgwa.height - ((lines_3 + lines_4 + 1) * + (font->ascent + font->descent + 1)), + 10, 10, + sco_panic_3, 0); + XSync(dpy, False); + if (bsod_sleep(dpy, 1)) + goto DONE; + draw_string(dpy, window, gc, &gcv, font, + 10, xgwa.height - ((lines_4 + 1) * + (font->ascent + font->descent + 1)), + 10, 10, + sco_panic_4, 0); + XSync(dpy, False); + bsod_sleep(dpy, delay); + DONE: XClearWindow(dpy, window); + XFreeGC(dpy, gc); XFreeFont(dpy, font); return True; } @@ -467,7 +522,7 @@ amiga (Display *dpy, Window window, int delay) int height; unsigned long fg, bg, bg2; Pixmap pixmap = 0; - int pix_w, pix_h; + int pix_w = 0, pix_h = 0; const char *string = ("_Software failure. Press left mouse button to continue.\n" @@ -654,15 +709,17 @@ atari (Display *dpy, Window window, int delay) } for (i=7 ; i<10 ; i++) { - bsod_sleep(dpy, 1); + if (bsod_sleep(dpy, 1)) + goto DONE; XCopyArea(dpy, pixmap, window, gc, 0, 0, pix_w, pix_h, (x + (i*offset)), y); } + bsod_sleep(dpy, delay); + DONE: XFreePixmap(dpy, pixmap); XFreeGC(dpy, gc); XSync(dpy, False); - bsod_sleep(dpy, delay); XClearWindow(dpy, window); XFreeFont(dpy, font); return True; @@ -1031,7 +1088,12 @@ screenhack (Display *dpy, Window window) if (delay < 3) delay = 3; if (!get_boolean_resource ("root", "Boolean")) - XSelectInput(dpy, window, KeyPressMask|ButtonPressMask); + { + XWindowAttributes xgwa; + XGetWindowAttributes (dpy, window, &xgwa); + XSelectInput (dpy, window, + xgwa.your_event_mask | KeyPressMask | ButtonPressMask); + } while (1) { @@ -1053,7 +1115,7 @@ screenhack (Display *dpy, Window window) if (loop > 100) j = -1; if (loop > 200) exit(-1); if (!did) continue; - XSync (dpy, True); + XSync (dpy, False); j = i; loop = 0; }