home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / hp / 14621 < prev    next >
Encoding:
Internet Message Format  |  1993-01-07  |  4.2 KB

  1. Path: sparky!uunet!dtix!darwin.sura.net!spool.mu.edu!yale.edu!qt.cs.utexas.edu!cs.utexas.edu!sdd.hp.com!hpscit.sc.hp.com!hplextra!hpfcso!stroyan
  2. From: stroyan@hpfcso.FC.HP.COM (Mike Stroyan)
  3. Newsgroups: comp.sys.hp
  4. Subject: Re: Problem using Motif with HP-PHIGS
  5. Message-ID: <7371519@hpfcso.FC.HP.COM>
  6. Date: 7 Jan 93 22:53:47 GMT
  7. References: <7126@m1.cs.man.ac.uk>
  8. Organization: Hewlett-Packard, Fort Collins, CO, USA
  9. Lines: 81
  10.  
  11. Raju Gurung writes-
  12. >     I've a phigs application with a Motif XmDrawingArea Widget as its
  13. > work-station. I've opened the work-station using pescape_5() and popen_ws()
  14. > functions. 
  15. >     It all seems to work fine unless I try to use the colour functions.
  16. > The phigs colormap doesn't seem to get installed when I open the workstation,
  17. > i.e. I do not get the 'technicolor' effect when the pointer is in the window.
  18. > I've a few programs that uses direct color environ and pick input which work
  19. > as expected in dumb windows but not in my motif windows.
  20. >     Any idea what's wrong ?
  21.  
  22. First, I want to advise you to get the HP-PHIGS 2.3 release, which has a
  23. PhigsDraw widget.  This is a subclass of the DrawingArea Widget that
  24. takes care of many details of using a PHIGS workstation in a Motif
  25. program.  The widget handles choosing the best visual, opening a
  26. workstation, rescaling on resizes, redrawing on exposes, and getting
  27. the right colormaps installed, among other things.
  28.  
  29. The color problem that you are having occurs because the window manager
  30. does not know that your shell window has a descendent window with a
  31. different colormap.  You can indicate that the other colormap is there
  32. and that it is more important than the shell window's colormap by
  33. setting a property on the shell window.  After you have created all of
  34. the widgets, the following code will set a colormap windows property on
  35. the window of the toplevel widget "toplevel", to favor the colormap of
  36. the DrawingArea widget "gr".
  37.  
  38.     XtRealizeWidget(toplevel);
  39.  
  40.     {
  41.         Window windows[2];
  42.         Atom xa_WM_COLORMAP_WINDOWS;
  43.  
  44.         if (init_flag) {
  45.             /* Set the WM_COLORMAP_WINDOWS property on the toplevel window so
  46.              * the colormap for the DrawingArea widget is installed when the
  47.              * application gets colormap focus.
  48.              */
  49.             xa_WM_COLORMAP_WINDOWS = XInternAtom(XtDisplay(gr),
  50.                 "WM_COLORMAP_WINDOWS", False);
  51.             windows[1] = XtWindow(toplevel);
  52.             windows[0] = XtWindow(gr);
  53.             XChangeProperty(XtDisplay(gr), XtWindow(toplevel),
  54.                 xa_WM_COLORMAP_WINDOWS, XA_WINDOW, 32, PropModeReplace,
  55.                 (unsigned char *) windows, 2);
  56.         }
  57.     }
  58.  
  59. You will have problems opening a PHIGS input workstation in a
  60. DrawingArea widget.  This stems from the X standard, which specifies
  61. that an X server will only allow one client at a time to select for
  62. Button or Key events from a window.  The Motif DrawingArea widget asks
  63. for events on one connection, and the PHIGS library will try to ask for
  64. events on a different connection.  The request on the PHIGS's libraries
  65. connection fails.  You could try to work around this by forcing the
  66. Motif connection to stop asking for these events.  The following code
  67. could be used between the time the widget "gr" is realized and the time
  68. a PHIGS workstation is opened.  This is a bit of a hack.  It really is
  69. messing with window attributes that it shouldn't.
  70.  
  71.     {
  72.         XWindowAttributes g;
  73.         XSetWindowAttributes s;
  74.  
  75.         XGetWindowAttributes(XtDisplay(gr), XtWindow(gr), &g);
  76.         s.event_mask = g.your_event_mask & ~(
  77.             KeyPressMask | KeyReleaseMask |
  78.             ButtonPressMask | ButtonReleaseMask);
  79.         XChangeWindowAttributes(XtDisplay(gr), XtWindow(gr), CWEventMask, &s);
  80.         XSync(XtDisplay(gr), 0);
  81.     }
  82.  
  83. Another way to do PICK operations in a DrawingArea widget is to use the
  84. "DIRECT PICK" escape calls to cause a pick when you get toolkit input.
  85. This escape first appeared in the HP-PHIGS 2.2 release.  It depends on a
  86. PHIGS escape, but at least it uses a documented interface instead of
  87. working behind the back of the widgets.  It also will make it much
  88. easier to integrate the PICK input code with the other toolkit input
  89. code.  Everything will be able to come back from main loop callbacks.
  90.  
  91. Mike Stroyan, mike_stroyan@fc.hp.com
  92.