[comp.windows.x] Xlib questions

tek@CS.UCLA.EDU (Ted Kim (ATW)) (08/25/88)

	QUESTION 1
Timestamps are (according to the glossary) expressed in milliseconds
since the last server reset. The server is supposed to treat half of
the timestamps as being in the future, half in the past. Suppose the
current server time is T.  

Type "Time" is an unsigned long in "X.h". (on my machine that's 32
bits) 

Which half of the timestamps are in the future? 
	Is it the interval [T+1,  T+2^31], excluding the constant
	CurrentTime if it is in the interval, with T+2^31 being
	furthest in the future?  
Conversly, which timestamps are in the past?

	QUESTION 2
How do you use XFreeColors? I have read the description and tried
various things, but I still can't get it to work. 

To make things concrete, suppose I called XAllocColorCells and got 2
planes (1,2) and 2 pixels (24,28). Now suppose, I want to free all of
these colors. What arguments should I use with XFreeColors to do this?

-ted

RWS@ZERMATT.LCS.MIT.EDU (Robert Scheifler) (08/26/88)

    Date: 24 Aug 88 17:25:52 GMT
    From: CS.UCLA.EDU!tek@bloom-beacon.mit.edu  (Ted Kim (ATW))

    Which half of the timestamps are in the future? 
    Conversly, which timestamps are in the past?

Here's the relevant code from the MIT server:

#define HALFMONTH ((unsigned long) 1<<31)
TimeStamp
ClientTimeToServerTime(c)
     CARD32 c;
{
    TimeStamp ts;
    if (c == CurrentTime)
	return currentTime;
    ts.months = currentTime.months;
    ts.milliseconds = c;
    if (c > currentTime.milliseconds)
    {
	if (((unsigned long) c - currentTime.milliseconds) > HALFMONTH)
	    ts.months -= 1;
    }
    else if (c < currentTime.milliseconds)
    {
	if (((unsigned long)currentTime.milliseconds - c) > HALFMONTH)
	    ts.months += 1;
    }
    return ts;
}



    To make things concrete, suppose I called XAllocColorCells and got 2
    planes (1,2) and 2 pixels (24,28). Now suppose, I want to free all of
    these colors. What arguments should I use with XFreeColors to do this?

The "planes" value should be the OR of the (2) planes you got from
XAllocColorCells, and "pixels" should be the list of pixels.