home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / fj / maillis / xwindow / 17631 < prev    next >
Encoding:
Internet Message Format  |  1992-11-18  |  2.2 KB

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