home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / windows / x / 19263 < prev    next >
Encoding:
Internet Message Format  |  1992-11-17  |  2.1 KB

  1. 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
  2. From: jimf@centerline.com (Jim Frost)
  3. Newsgroups: comp.windows.x
  4. Subject: Re: Finding out the number of 'free' cells in the color map
  5. Keywords: color map, color cells
  6. Message-ID: <1ebsobINNp9u@armory.centerline.com>
  7. Date: 17 Nov 92 22:46:35 GMT
  8. References: <1992Nov13.072332.27682@mailhost.ocs.mq.edu.au> <1992Nov15.193125.19911@thunder.mcrcim.mcgill.edu>
  9. Organization: CenterLine Software, Inc.
  10. Lines: 40
  11. NNTP-Posting-Host: 140.239.3.202
  12.  
  13. mouse@thunder.mcrcim.mcgill.edu (der Mouse) writes:
  14. >In article <1992Nov13.072332.27682@mailhost.ocs.mq.edu.au>, s8923098@macnab.mqcs.mq.oz.au (Josef WIDJAJA) writes:
  15.  
  16. >> I want to use XAllocColor many times to allocate color cells that can
  17. >> be shared by other applications.  But I want to know in advance how
  18. >> many of these will be available.  How can I do this ?
  19.  
  20. >You can't.
  21.  
  22. That's not strictly true, although doing it is rather painful.
  23.  
  24. 1. Grab the server.
  25. 2. Allocate as many writable colors as you can to eat up all unshared
  26.    colors.
  27. 3. Allocate and free each color you want to allocate sharable -- those
  28.    that succeed are already available, those that fail are not.
  29.  
  30. At this point you know what colors are available and how many
  31. additional ones you can allocate at will.  You can do whatever
  32. manipulations you want to fit the color usage you want into the
  33. resources you have.
  34.  
  35. 4. Free the colors you allocated writable and reallocate them shared
  36.    in the colors you want.
  37. 5. Ungrab the server.
  38.  
  39. Grabbing the server locks other applications from allocating or
  40. freeing colors for the duration of your color manipulation.
  41.  
  42. A slightly simpler technique, and the one I use, is to merely assume
  43. that you can't allocate more than the number of colors you can
  44. allocate writable.  Simply grab the server, allocate as many private
  45. colors as you can, figure out what colors you want given the number
  46. you can get, free the colors you allocated, reallocate them shared,
  47. and ungrab the server.
  48.  
  49. Informationally yours,
  50.  
  51. jim frost
  52. jimf@centerline.com
  53.