home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / windows / x / 20545 < prev    next >
Encoding:
Internet Message Format  |  1992-12-24  |  3.6 KB

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