home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / fj / maillis / xwindow / 18907 < prev    next >
Encoding:
Text File  |  1992-12-24  |  3.9 KB  |  113 lines

  1. Path: sparky!uunet!stanford.edu!sun-barr!sh.wide!wnoc-tyo-news!scslwide!wsgw!wsservra!onoe
  2. From: hstroyan@hpfcso.FC.HP.COM (Howard Stroyan)
  3. Newsgroups: fj.mail-lists.x-window
  4. Subject: Re: Help with Colormaps
  5. Message-ID: <1992Dec24.220617.19933@sm.sony.co.jp>
  6. Date: 24 Dec 92 22:06:17 GMT
  7. Sender: onoe@sm.sony.co.jp (Atsushi Onoe)
  8. Distribution: fj
  9. Organization: Hewlett-Packard, Fort Collins, CO, USA
  10. Lines: 100
  11. Approved: michael@sm.sony.co.jp
  12.  
  13. Date: Wed, 23 Dec 1992 17:40:43 GMT
  14. Message-Id: <7320057@hpfcso.FC.HP.COM>
  15. Newsgroups: comp.windows.x
  16. References: <1h5ac3INN11v@rave.larc.nasa.gov>
  17. Sender: xpert-request@expo.lcs.mit.edu
  18.  
  19. In comp.windows.x, judith@mermaid.larc.nasa.gov (Judith Moore) writes:
  20.  
  21. > Thanks for the attention to my problem. Unfortunately,
  22. > I must be misinterpreting the suggestions. This is what
  23. > I do:
  24. >     (misc setup)
  25. >    winAttrib.colormap = DefaultColormap(theDisplay, theScreen);
  26. >    mainWindow =    XCreateWindow (theDisplay, ...., &winAttrib);
  27. >    XMapWindow (theDisplay, mainWindow);
  28. >    anImage = XCreateImage (theDisplay, theVisual, 8, ZPixmap, ...); 
  29. >    XPutImage (theDisplay, mainWindow, theGC, anImage, ...);
  30. >    XFlush (theDisplay);
  31. >    sleep (5);
  32. >     grayMap = XCreateColormap (theDisplay, mainWindow, theVisual, AllocAll);
  33. >     for (i = 0; i < 255; i++) {
  34. >         aColor.pixel = i;    
  35. >         aColor.red = aColor.blue = aColor.green = i << 8;
  36. >         XStoreColor (theDisplay, grayMap, &aColor);
  37. >         }
  38. >     
  39. >     XSetWindowColormap (theDisplay, mainWindow, grayMap);
  40. >     XFlush (theDisplay);
  41. >     sleep (5);
  42. > What happens is, my image appears in the window with the default
  43. > colormap, and just sits there.  The XSetWindowColormap() call
  44. > appears to have no effect whatsoever.  
  45. > If I do the XSetWindowColormap() _before_ XMapWindow(), I get the
  46. > grayscale I expect.  But then I can't change _that_ to anything 
  47. > else.
  48.   
  49. I suspect that your problem is in the Window Manager's colormap focus
  50. policy.  Your application is only empowered to tell the window mgr
  51. which colormap(s) is associated with the window.  It is the window mgr's
  52. responsibility to install the colormap in the 1 or more hardware colormaps
  53. based on the current ColormapFocusPolicy.  The proper behaviour of a
  54. window manager is described in the ICCCM (Inter-Client Communications 
  55. Conventions Manual).  (I hear they have some pretty wild conventions :-)
  56. Beware, window managers don't always live up to these standards.
  57.  
  58. Try setting your ColormapFocusPolicy resource to pointer in .Xdefaults 
  59. or your equivalent.  The other options are (keyboard and explicit).
  60.  
  61. Use the xwininfo utility to inspect the current colormap associated 
  62. with your application's window to make sure that a new cmap is being
  63. correctly applied to the window.
  64.  
  65. The program included below will tell you what the current set
  66. of installed colormaps are.  If your display has a single hardware
  67. colormap this will always be just one colormap at any time. 
  68.  
  69. --
  70. Howard Stroyan                                         
  71. Hewlett-Packard                                        hstroyan@fc.hp.com
  72. Systems Technology Division                     
  73. ----------------------------------------------------------------------
  74. #include <X11/Xlib.h>
  75.  
  76. #define TRUE 1
  77. #define NULL 0
  78.  
  79. main()
  80. {
  81.     Display *mydisplay;
  82.     int myscreen;
  83.     Window mywindow;
  84.     GC mygc;
  85.     XEvent myevent;
  86.     KeySym mykey;
  87.     char text[10];
  88.     int count, i;
  89.     Colormap *list, *start;
  90.  
  91.     mydisplay = XOpenDisplay(getenv("DISPLAY"));
  92.     myscreen = DefaultScreen(mydisplay);
  93.  
  94.     mywindow = XCreateSimpleWindow(mydisplay,
  95.         RootWindow(mydisplay, myscreen),
  96.         100, 100, 300, 300,
  97.         2,
  98.         BlackPixel(mydisplay, myscreen),
  99.         WhitePixel(mydisplay, myscreen));
  100.  
  101.     start = list = XListInstalledColormaps(mydisplay, mywindow, &count);
  102.  
  103.     printf(" %d colormaps installed:\n",count);
  104.     for (i = 0; i < count; i++)
  105.     {
  106.         printf("\t 0x%x \n",*(list++));
  107.     }
  108.     XFree(start);
  109. }
  110.