home *** CD-ROM | disk | FTP | other *** search
- 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
- From: stroyan@hpfcso.FC.HP.COM (Mike Stroyan)
- Newsgroups: comp.sys.hp
- Subject: Re: Problem using Motif with HP-PHIGS
- Message-ID: <7371519@hpfcso.FC.HP.COM>
- Date: 7 Jan 93 22:53:47 GMT
- References: <7126@m1.cs.man.ac.uk>
- Organization: Hewlett-Packard, Fort Collins, CO, USA
- Lines: 81
-
- Raju Gurung writes-
- > I've a phigs application with a Motif XmDrawingArea Widget as its
- > work-station. I've opened the work-station using pescape_5() and popen_ws()
- > functions.
- > It all seems to work fine unless I try to use the colour functions.
- > The phigs colormap doesn't seem to get installed when I open the workstation,
- > i.e. I do not get the 'technicolor' effect when the pointer is in the window.
- > I've a few programs that uses direct color environ and pick input which work
- > as expected in dumb windows but not in my motif windows.
- > Any idea what's wrong ?
-
- First, I want to advise you to get the HP-PHIGS 2.3 release, which has a
- PhigsDraw widget. This is a subclass of the DrawingArea Widget that
- takes care of many details of using a PHIGS workstation in a Motif
- program. The widget handles choosing the best visual, opening a
- workstation, rescaling on resizes, redrawing on exposes, and getting
- the right colormaps installed, among other things.
-
- The color problem that you are having occurs because the window manager
- does not know that your shell window has a descendent window with a
- different colormap. You can indicate that the other colormap is there
- and that it is more important than the shell window's colormap by
- setting a property on the shell window. After you have created all of
- the widgets, the following code will set a colormap windows property on
- the window of the toplevel widget "toplevel", to favor the colormap of
- the DrawingArea widget "gr".
-
- XtRealizeWidget(toplevel);
-
- {
- Window windows[2];
- Atom xa_WM_COLORMAP_WINDOWS;
-
- if (init_flag) {
- /* Set the WM_COLORMAP_WINDOWS property on the toplevel window so
- * the colormap for the DrawingArea widget is installed when the
- * application gets colormap focus.
- */
- xa_WM_COLORMAP_WINDOWS = XInternAtom(XtDisplay(gr),
- "WM_COLORMAP_WINDOWS", False);
- windows[1] = XtWindow(toplevel);
- windows[0] = XtWindow(gr);
- XChangeProperty(XtDisplay(gr), XtWindow(toplevel),
- xa_WM_COLORMAP_WINDOWS, XA_WINDOW, 32, PropModeReplace,
- (unsigned char *) windows, 2);
- }
- }
-
- You will have problems opening a PHIGS input workstation in a
- DrawingArea widget. This stems from the X standard, which specifies
- that an X server will only allow one client at a time to select for
- Button or Key events from a window. The Motif DrawingArea widget asks
- for events on one connection, and the PHIGS library will try to ask for
- events on a different connection. The request on the PHIGS's libraries
- connection fails. You could try to work around this by forcing the
- Motif connection to stop asking for these events. The following code
- could be used between the time the widget "gr" is realized and the time
- a PHIGS workstation is opened. This is a bit of a hack. It really is
- messing with window attributes that it shouldn't.
-
- {
- XWindowAttributes g;
- XSetWindowAttributes s;
-
- XGetWindowAttributes(XtDisplay(gr), XtWindow(gr), &g);
- s.event_mask = g.your_event_mask & ~(
- KeyPressMask | KeyReleaseMask |
- ButtonPressMask | ButtonReleaseMask);
- XChangeWindowAttributes(XtDisplay(gr), XtWindow(gr), CWEventMask, &s);
- XSync(XtDisplay(gr), 0);
- }
-
- Another way to do PICK operations in a DrawingArea widget is to use the
- "DIRECT PICK" escape calls to cause a pick when you get toolkit input.
- This escape first appeared in the HP-PHIGS 2.2 release. It depends on a
- PHIGS escape, but at least it uses a documented interface instead of
- working behind the back of the widgets. It also will make it much
- easier to integrate the PICK input code with the other toolkit input
- code. Everything will be able to come back from main loop callbacks.
-
- Mike Stroyan, mike_stroyan@fc.hp.com
-