Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!elroy!gryphon!desint!geoff From: geoff@desint.UUCP (Geoff Kuenning) Newsgroups: comp.windows.x Subject: Re: visual depth vs. colormap_size Message-ID: <23@desint.UUCP> Date: 10 Apr 89 00:11:08 GMT References: <8904051242.AA12457@EXPIRE.LCS.MIT.EDU> Reply-To: geoff@desint.UUCP (Geoff Kuenning) Organization: Interrupt Technology Corp., Manhattan Beach, CA Lines: 38 > The Sun ddx simply allocates read-only entries out of the default colormap > (and I don't think it ever frees them). What I did in a 4-plane, 16-entry-colormap server was to make every attempt to satisfy the cursor color request, but to also allow the user to allocate the entire colormap. Here's how: Whenever I repainted the cursor, I first called a cursor-color allocation routine. (For efficiency, this routine checked a flag and only did any real work if the colormap had been changed or replaced since the last call). This routine first scanned the colormap to see if there were any free cells. If there were, it selected one arbitrarily, stored the cursor color in that cell, and used it -- but it did *not* allocate that cell from dix's point of view. (This was safe because if dix chose to allocate that cell, the routine would just pick a new one on the next cursor repaint). If the colormap had no free cells at all, the routine would search the colormap looking for an existing color that was "close" to the requested cursor color, and use the closest pixel found. (Actually, of course, this was all done in one loop). The result was that, if there were two free colormap cells, you got the cursor colors you requested. If no cells were free, but your cursor colors were selected from the colors you were using for the image itself, you still got the colors you requested. Only if you were trying to use 18 unique colors (16 for the image and 2 for the cursor) did you lose out, and then you got the server's "best effort" to achieve the cursor color you asked for. (If only one cell was free, the foreground color had priority). This solution obviously has flaws; in particular you could lose out on contrast with certain cursors and color choices. But I really couldn't see trying to explain to the user, "Yeah, it's a 16-color display, but you can only have 14 of them because you *might* want an aquamarine cursor." -- Geoff Kuenning geoff@ITcorp.com uunet!desint!geoff