home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: alt.sources
- Path: sparky!uunet!stanford.edu!nntp.Stanford.EDU!eillihca@grizzle.Stanford.EDU
- From: eillihca@drizzle.StanFord.EDU ( Achille Hui, the Day Dreamer )
- Subject: Re: Binary clock for X Windows.
- Message-ID: <eillihca.92122318162010574@grizzle.Stanford.EDU>
- Sender: ?@leland.Stanford.EDU
- X-Transfer-Agent: nntp.stanford.edu (NNTP)
- Organization: Dept. of Physics, Stanford University.
- Date: 24 Dec 92 02:16:20 GMT
- Lines: 79
-
- markus@octavia.anu.edu.au (Markus Buchhorn) writes:
-
- >
- >doug@jhunix.hcf.jhu.edu (Douglas W O'Neal) and norm@bnr.ca and
- >bret@muppet.bt.co.uk (Bret Giddings) all wrote
- >>
- >> ->|> What! another clock for wimps. I use a real clock, one that displa...
- >> ->|> of seconds since Jan 1st 1970.
- >> ->This is starting to sound like the "We were *so* poor..." skit from M...
- >> ->Python. BTW, (let's see what I can come up with), *I* use the number...
- >> ->since Jan 1, 1970 but in Greenwich Mean Time :-)
- >>
- >> *I* use the number of seconds since Nov 17, 1858. (I can't help it, I ...
- >> raised on VMS and UN*X time doesn't come naturally to me.)
- >>
- >
- >
- >Ye gods - it must be the silly season, otherwise I would NEVER followup :-)
- >
- Yup, it is a silly season and I can't stand people bragging about
- their vapourware. Here is the ObSource of my clock with milli-second
- resolution. What? you don't know how to interpret the time? It works
- fine for me ;-)
- ------------------------------------achille (eillihca@drizzle.stanford.edu)
- #include <X11/Intrinsic.h>
- #include <X11/StringDefs.h>
- #include <X11/Xmu/Drawing.h>
- #include <sys/time.h>
- unsigned long pixels[2];
- XColor colors[2];
- int delay = 666;
- int
- updateit(Widget widget,XtIntervalId *id){
- struct timeval tv;
- struct timezone tz;
- int tmp, r0, g0, b0, r1, g1, b1;
- gettimeofday(&tv,&tz);
- tmp = tv.tv_usec / 250;
- r0 = (tmp & (0x3<<10))>>4; r1 = (tmp & (0x3<<4))<<2;
- g0 = (tmp & (0x3<<8))>>2; g1 = (tmp & (0x3<<2))<<4;
- b0 = (tmp & (0x3<<6)); b1 = (tmp & (0x3))<<6;
- tmp = tv.tv_sec;
- r0 |= (tmp & (0x1f<<25))>>24; r1 |= (tmp & (0x1f<<10))>>9;
- g0 |= (tmp & (0x1f<<20))>>19; g1 |= (tmp & (0x1f<<5))>>4;
- b0 |= (tmp & (0x1f<<15))>>14; b1 |= (tmp & (0x1f))<<1;
- colors[0].red = (r0<<8)|r0; colors[1].red = (r1<<8)|r1;
- colors[0].green = (g0<<8)|g0; colors[1].green = (g1<<8)|g1;
- colors[0].blue = (b0<<8)|b0; colors[1].blue = (b1<<8)|b1;
- XStoreColors(XtDisplay(widget),DefaultColormapOfScreen(XtScreen(widget)),
- colors,2);
- XtAddTimeOut(delay,updateit,widget);
- }
- main(int argc,char *argv[]){
- Widget stupid = XtInitialize(NULL,"Stupid",NULL,0,&argc,argv);
- argc--; argv++;
- if((argc-- > 0) && (((delay = atoi(*argv++))<= 4)||(delay > 10000)))
- delay = 666;
- XAllocColorCells(XtDisplay(stupid),
- DefaultColormapOfScreen(XtScreen(stupid)),
- False,0,0,pixels,2);
- colors[0].flags = colors[1].flags = DoRed|DoGreen|DoBlue;
- colors[0].pixel = pixels[0]; colors[1].pixel = pixels[1];
- XSetWindowBackgroundPixmap(
- XtDisplay(stupid),RootWindowOfScreen(XtScreen(stupid)),
- XmuCreateStippledPixmap(XtScreen(stupid),pixels[0],pixels[1],
- DefaultDepthOfScreen(XtScreen(stupid))));
- XClearWindow(XtDisplay(stupid),
- RootWindowOfScreen(XtScreen(stupid)));
- updateit(stupid,(XtIntervalId *)0);
- XtMainLoop();
- }
-
-
-
-
-
-
-
-
-