home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!sun-barr!sh.wide!wnoc-tyo-news!scslwide!wsgw!wsservra!daemon
- From: jimf@centerline.com (Jim Frost)
- Newsgroups: fj.mail-lists.x-window
- Subject: Re: Finding out the number of 'free' cells in the color map
- Message-ID: <1992Nov19.042523.28182@sm.sony.co.jp>
- Date: 19 Nov 92 04:25:23 GMT
- Sender: daemon@sm.sony.co.jp (The devil himself)
- Distribution: fj
- Organization: CenterLine Software, Inc.
- Lines: 46
- Approved: michael@sm.sony.co.jp
-
- Date: 17 Nov 1992 22:46:35 GMT
- Message-Id: <1ebsobINNp9u@armory.centerline.com>
- Newsgroups: comp.windows.x
- References: <1992Nov13.072332.27682@mailhost.ocs.mq.edu.au>, <1992Nov15.193125.19911@thunder.mcrcim.mcgill.edu>
- Sender: xpert-request@expo.lcs.mit.edu
-
- 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
-