Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!decwrl!pyramid!hplabs!hpcea!hpfcdc!hpfcdq!dp From: dp@hpfcdq.HP.COM (David Pinedo) Newsgroups: comp.sys.hp Subject: Re: Need screen blanker for HP9000/300 Message-ID: <350001@hpfcdq.HP.COM> Date: Thu, 29-Oct-87 15:37:22 EST Article-I.D.: hpfcdq.350001 Posted: Thu Oct 29 15:37:22 1987 Date-Received: Sat, 7-Nov-87 00:01:34 EST References: <1145@puff.wisc.edu> Organization: Hewlett-Packard - Fort Collins, CO Lines: 162 Here's my version of a screen saver. It's advantages are that it's a lot smaller than Mike Stroyan's. :-) Like Mike's version, it too decides that it is time to clear the screen when a certain amount has elapsed since the keyboard and locator have been inactive. There is one problem with any screen saver on HP Windows -- there is no good way to detect that graphics output has occurred during some time interval, short of reading all the pixels on the screen. This is due to the fact that graphics output does not involve having the window manager run. Even making changes to the window manager could not solve this problem. David Pinedo Hewlett-Packard Technical Workstation Operation hpfcla!dp /********************************************************************* screensaver program for HP Windows Usage: screensaver minutes where minutes is the number of minutes of inactivity from the keyboard or locator to wait before clearing the screen. After screensaver has cleared the screen, the original screen may be recovered by pressing any key or moving the locator. The best way to start the screensaver program is from a script to be invoked by wmstart: screensaver 10 wsh -ka wconsole When starting window manager, use: wmstart script Compile screensaver as follows: cc -o screensaver screensaver.c -ldd -lwindow -lsb1 -lsb2 *********************************************************************/ #include #include #include #include #include #include #include int signalreceived = FALSE; signal_handler() { signalreceived = TRUE; } main(argc,argv) int argc; char *argv[]; { int wmfd; int gfd; int rval; long delay; char wmdriver[20]; char wmkbd[40]; char wmlocator[40]; long timestart; time_t kbd_access_time, loc_access_time; struct stat statbuf; struct event_code winevent; extern long time(); if (argc < 1 || sscanf(argv[1], "%d", &delay) < 0) { fprintf(stderr,"Usage: screensaver minutes\n"); exit(1); } rval = fork(); if (rval < 0) fprintf(stderr, "screensaver: fork failed\n"); if (rval != 0) exit(0); wmfd=open("/dev/screen/wm", O_RDWR); winit(wmfd); wminquire(wmfd,"WMDRIVER",wmdriver); wminquire(wmfd,"WMKBD",wmkbd); wminquire(wmfd,"WMLOCATOR",wmlocator); /* Create a window */ if (wcreate_graphics(wmfd,"/dev/screen/screensaver",0,0,1280,1024,1280,1024, SETNORETAIN,SETNOBANNER) < 0) { fprintf(stderr,"screensaver: wcreate_graphics failed\n"); exit(1); } /* Establish communication with the window */ signal(SIGHUP, signal_handler); setpgrp(); /* We'll get a SIGHUP when the window is destroyed by wmstop */ gfd=gopen("/dev/screen/screensaver", OUTDEV, wmdriver, 0); if (gfd < 0) { fprintf(stderr,"screensaver: gopen failed\n"); exit(1); } winit(gfd); wautodestroy(gfd, 1); wrecover(gfd, 1); while (!signalreceived) { restart: /* Wait for inactivity for the specified amount of time */ stat(wmkbd,&statbuf); kbd_access_time = statbuf.st_atime; stat(wmlocator,&statbuf); loc_access_time = statbuf.st_atime; timestart = time(0)/60; while (!signalreceived && time(0)/60 - timestart < delay) { sleep(60); stat(wmkbd,&statbuf); if (kbd_access_time != statbuf.st_atime) goto restart; kbd_access_time = statbuf.st_atime; stat(wmlocator,&statbuf); if (loc_access_time != statbuf.st_atime) goto restart; } if (signalreceived) break; /* Clear the window (and thus the screen) */ wmove(gfd, 0,0); wsize(gfd, 1280,10240); wtop(gfd,1); clear_view_surface(gfd); /* Wait for a locator or keyboard event */ wselect(gfd,1); wgskbd(gfd,2); winput_conf(gfd,K_TRACK, 1); /* Request locator movements */ wsetecho(gfd, 0); /* Turn off locator echo */ winput_read(gfd, &winevent, 1); wgskbd(gfd,0); wconceal(gfd,1); wselect(gfd,0); } wterminate(gfd); gclose(gfd); wterminate(wmfd); close(wmfd); exit(0); }