home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!bu.edu!news.bbn.com!noc.near.net!news.centerline.com!jimf
- From: jimf@centerline.com (Jim Frost)
- Newsgroups: comp.windows.x
- Subject: Re: Finding out the number of 'free' cells in the color map
- Keywords: color map, color cells
- Message-ID: <1ebsobINNp9u@armory.centerline.com>
- Date: 17 Nov 92 22:46:35 GMT
- References: <1992Nov13.072332.27682@mailhost.ocs.mq.edu.au> <1992Nov15.193125.19911@thunder.mcrcim.mcgill.edu>
- Organization: CenterLine Software, Inc.
- Lines: 40
- NNTP-Posting-Host: 140.239.3.202
-
- mouse@thunder.mcrcim.mcgill.edu (der Mouse) writes:
- >In article <1992Nov13.072332.27682@mailhost.ocs.mq.edu.au>, s8923098@macnab.mqcs.mq.oz.au (Josef WIDJAJA) writes:
-
- >> I want to use XAllocColor many times to allocate color cells that can
- >> be shared by other applications. But I want to know in advance how
- >> many of these will be available. How can I do this ?
-
- >You can't.
-
- That's not strictly true, although doing it is rather painful.
-
- 1. Grab the server.
- 2. Allocate as many writable colors as you can to eat up all unshared
- colors.
- 3. Allocate and free each color you want to allocate sharable -- those
- that succeed are already available, those that fail are not.
-
- At this point you know what colors are available and how many
- additional ones you can allocate at will. You can do whatever
- manipulations you want to fit the color usage you want into the
- resources you have.
-
- 4. Free the colors you allocated writable and reallocate them shared
- in the colors you want.
- 5. Ungrab the server.
-
- Grabbing the server locks other applications from allocating or
- freeing colors for the duration of your color manipulation.
-
- A slightly simpler technique, and the one I use, is to merely assume
- that you can't allocate more than the number of colors you can
- allocate writable. Simply grab the server, allocate as many private
- colors as you can, figure out what colors you want given the number
- you can get, free the colors you allocated, reallocate them shared,
- and ungrab the server.
-
- Informationally yours,
-
- jim frost
- jimf@centerline.com
-