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

  1. Path: sparky!uunet!stanford.edu!sun-barr!sh.wide!wnoc-tyo-news!scslwide!wsgw!wsservra!daemon
  2. From: 6500msd@ucsbuxa.ucsb.edu (Michael D'Errico)
  3. Newsgroups: fj.mail-lists.x-window
  4. Subject: Re: Finding out the number of 'free' cells in the color map
  5. Message-ID: <1992Nov18.191446.5837@sm.sony.co.jp>
  6. Date: 18 Nov 92 19:14:46 GMT
  7. Sender: daemon@sm.sony.co.jp (The devil himself)
  8. Distribution: fj
  9. Organization: Workstation Div., Supermicro Systems Group, Sony Corporation
  10. Lines: 54
  11. Approved: michael@sm.sony.co.jp
  12.  
  13. Date: 18 Nov 92 01:08:25 GMT
  14. Message-Id: <6747@ucsbcsl.ucsb.edu>
  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. In article <1992Nov15.193125.19911@thunder.mcrcim.mcgill.edu> mouse@thunder.mcrcim.mcgill.edu (der Mouse) writes:
  20.  
  21. |In article <1992Nov13.072332.27682@mailhost.ocs.mq.edu.au>, s8923098@macnab.mqcs.mq.oz.au (Josef WIDJAJA) writes:
  22.  
  23. |> I want to use XAllocColor many times to allocate color cells that can
  24. |> be shared by other applications.  But I want to know in advance how
  25. |> many of these will be available.  How can I do this ?
  26.  
  27. |You can't.  For one thing, it depends on exactly what colors you're
  28. |allocating, because you may match colors that are already allocated and
  29. |hence get an already-allocated cell instead of a new one.  Even if you
  30. |rephrase it to ask "how many cells are unallocated", there is no simple
  31. |way to answer it; you have to try it and see.  (Unless you want to
  32. |design and implement an extension, of course.)
  33.  
  34. |> [code example]
  35.  
  36. |> I want to know how many color cells are going to be available so that
  37. |> I can adjust the value of maxno, and prepare data[i]'s accordingly.
  38. |> More specifically, I want to make sure that result is always
  39. |> succesful(true).
  40.  
  41. |Can't be done.  Even if you did contrive somehow to find out how many
  42. |cells are free, other clients could allocate cells while you're
  43. |working.  You'd have to grab the server to prevent this....
  44.  
  45. I agree that there is no way (at least not yet) to query the number of unused
  46. color cells in a colormap.  You could probably get around this with the
  47. following approach:  use a loop that adjusts maxno until you successfully
  48. allocate the colormap.  The following pseudo-code shows what I would try:
  49.  
  50.         maxno = desired_maxno;
  51.         done = False;
  52.  
  53.         while (!done && maxno>=min_allowable_maxno)  {
  54.           if (try_to_allocate_maxno_colors)
  55.             done = True;
  56.           else  {
  57.             free_any_allocated_colors;
  58.             maxno--;
  59.             }
  60.  
  61.         if (!done)
  62.           error;
  63.  
  64.  
  65. Michael D'Errico
  66. 6500msd@ucsbuxa.ucsb.edu
  67.