home *** CD-ROM | disk | FTP | other *** search
/ ftp.pasteur.org/FAQ/ / ftp-pasteur-org-FAQ.zip / FAQ / motif-faq / part3 < prev    next >
Encoding:
Text File  |  2004-05-05  |  38.9 KB  |  1,077 lines

  1. Path: senator-bedfellow.mit.edu!dreaderd!not-for-mail
  2. Message-ID: <motif-faq/part3_1083675484@rtfm.mit.edu>
  3. Supersedes: <motif-faq/part3_1082292761@rtfm.mit.edu>
  4. Expires: 17 Jun 2004 12:58:04 GMT
  5. References: <motif-faq/part1_1083675484@rtfm.mit.edu>
  6. X-Last-Updated: 2002/01/31
  7. Organization: none
  8. Subject: Motif FAQ (Part 3 of 9)
  9. Newsgroups: comp.windows.x.motif,comp.answers,news.answers
  10. Keywords: FAQ question answer
  11. From: kenton@rahul.net (Ken Lee)
  12. Reply-To: kenton@rahul.net (Ken Lee)
  13. Approved: news-answers-request@MIT.EDU
  14. Followup-To: poster
  15. Summary: Motif Frequently Asked Questions (with answers).
  16. Originator: faqserv@penguin-lust.MIT.EDU
  17. Date: 04 May 2004 12:59:10 GMT
  18. Lines: 1056
  19. NNTP-Posting-Host: penguin-lust.mit.edu
  20. X-Trace: 1083675550 senator-bedfellow.mit.edu 559 18.181.0.29
  21. Xref: senator-bedfellow.mit.edu comp.windows.x.motif:75186 comp.answers:57051 news.answers:270855
  22.  
  23. Archive-name: motif-faq/part3
  24. Last-modified: 1 FEB 2002
  25. Posting-Frequency: irregular
  26. Organization: Kenton Lee, X/Motif Consultant, http://www.rahul.net/kenton/
  27. URL:  http://www.rahul.net/kenton/mfaq.html
  28. Version: 8.1
  29.  
  30. -----------------------------------------------------------------------------
  31. Subject: 40)  How does Motif work with X11R5?
  32.  
  33. Answer: Motif 1.1.X is only intended to be built with X11R4.  Motif 1.2.X is
  34. for X11R5.  however, Motif 1.1.4 has been set to also work with X11R5.
  35.  
  36. For Motif 1.1.1, 1.1.2 and 1.1.3 you will need to compile Xlib and Xt with a
  37. MOTIFBC flag set to YES (page 8, section 3.3 of the R5 release notes), or
  38. you'll also have a link problem (LowerCase) and a fatal run time problem
  39. (XContext manager).  If your applications come up with "Unknown keysym name:
  40. osfActivate" errors, check the variable ProjectRoot. The name
  41. /$PROJECTROOT/lib/XKeysymDB will have been wired into your Xlib.
  42.  
  43. In Motif 1.1.0, XtCallCallback uses NULL as the first argument instead of a
  44. widget ID. This was ok under R4, but must be changed in the source for R5. It
  45. was changed by OSF from Motif 1.1.1 onward.
  46.  
  47. Mrm won't work at all (can't link since it uses an X private variable that has
  48. disappeared in R5).  There is an MIT patch that may fix this??
  49.  
  50. -----------------------------------------------------------------------------
  51. Subject: 41)  Where can I find X technical info on the WWW?
  52. [Last modified: Mar 96]
  53.  
  54. Answer:
  55.  
  56.     Technical X Window System and OSF/Motif WWW sites
  57.     http://www.rahul.net/kenton/xsites.html
  58.  
  59. This web site currently lists over 700 X Window System links, including
  60. technical papers, tutorials, FAQs, product reviews, etc.
  61.  
  62. -----------------------------------------------------------------------------
  63. Subject: 42)  What is Broadway?  I've heard it called "X on the Web".
  64. [Last modified: Jun 98]
  65.  
  66. Answer: Broadway was the X Consortium's internal code name for the X11R6.3
  67. release.  It includes a collection of X-based technologies for the World Wide
  68. Web.  For details, see:
  69.  
  70.     http://www.camb.opengroup.org/tech/desktop/x/broadway.htm
  71.  
  72. And if you're wondering. "Why did they call it Broadway?", the X Consortium
  73. was located at 201 Broadway, Cambridge, MA.... ksall@cen.com
  74.  
  75. -----------------------------------------------------------------------------
  76. Subject: 43)  Where's an HTML version of the Motif FAQ on World Wide Web
  77. (WWW)?
  78. [Last modified: Feb 95]
  79.  
  80. Answer: An automatically generated HTML version of this Motif FAQ can be found
  81. at WWW URL:
  82.  
  83.     http://www.cis.ohio-state.edu/hypertext/faq/usenet/motif-faq/top.html
  84.  
  85. For a searchable version of the Motif FAQ and other FAQs (via WAIS), see:
  86.  
  87.     http://www.cs.ruu.nl/cgi-bin/faqwais
  88.  
  89. The WAIS search is great way to find a topic which may appear in several FAQs
  90. (Motif, X, Xt, Widget FAQ, etc.)
  91.  
  92. -----------------------------------------------------------------------------
  93. Subject: 44)  Where can I get the HTML widget used in Mosaic?
  94. [Last modified: Mar 96]
  95.  
  96. Answer: Thanks to Matthew Freedman (mattf@cac.washington.edu) and
  97. intasoft@cix.compulink.co.u for updates to the URLs mentioned in this answer.
  98.  
  99. Ken Sall (ksall@cen.com) writes: The HTML (HyperText Markup Language) widget
  100. is part of the NCSA Mosaic source code available from ftp.ncsa.uiuc.edu.  Look
  101. in the "libhtmlw" subdirectory of the "Mosaic-src-*" subdirectory of:
  102.  
  103.     ftp://ftp.ncsa.uiuc.edu/Mosaic/Unix/source/
  104.  
  105. or, more generally, look for the files HTML.c, HTML.h, HTMLP.h, etc. in your
  106. "libhtmlw" subdirectory of the Mosaic source.
  107.  
  108. For (old) documentation, see
  109.  
  110. http://www.ncsa.uiuc.edu/SDG/Software/Mosaic/Docs/htmlwidget.html.
  111.  
  112. However, Matthew M. Freedman (mattf@cac.washington.edu) pointed out the
  113. document is out of date: "One important thing to know is that the on-line
  114. documentation for the Mosaic html widget is out of synch with the source code.
  115. I e-mailed NCSA about this in May, but they seem to have ignored the report.
  116. The one that I wasted half a day because of is HTMLSetText(). The on-line docs
  117. list four arguments, but in fact there are seven. I have no idea what the
  118. extra three undocumented parameters are used for, I just plugged in NULL's and
  119. it works. The other error I noticed is that they document a "page" field in
  120. WbAnchorCallbackData, but it does not actually exist.  Also, at least for me,
  121. after I call HTMLSetText() the first time, the widget remains blank. I have to
  122. lower and raise the window for it to be drawn. Anybody know what is wrong? I
  123. guess will probably just spoof an expose in my code."
  124.  
  125.  
  126. For information on using Mosaic by remote control, see
  127.  
  128.     http://www.ncsa.uiuc.edu/SDG/Software/XMosaic/CCI/cci-spec.html
  129. and
  130.     http://www.ncsa.uiuc.edu/SDG/Software/Mosaic/Docs/remote-control.html
  131.  
  132.  
  133. Here are more details from ah627@FreeNet.Carleton.CA (Samuel Effah):
  134.  
  135. To the numerous request for the NCSA HTML widget information.
  136.  
  137. Everything not already copyrighted by CERN is copyrighted by NCSA (including
  138. the contents of the libhtmlw, libnet, libXmx, and src directories, but not
  139. including the contents of libdtm, which is entirely public domain). ...
  140.  
  141.  * The UI grants you (hereafter, Licensee) a license to use the Software    *
  142.  * for academic, research and internal business purposes only, without a    *
  143.  * fee.  Licensee may distribute the binary and source code (if released)   *
  144.  * to third parties provided that the copyright notice and this statement   *
  145.  * appears on all copies and that no charge is associated with such         *
  146.  * copies.                                                                  *
  147.  *                                                                          *
  148. ( you can read more about the copyright in the Mosaic source code ).
  149.  
  150.  
  151. Documentation on the HTML widget can be located at:
  152.  
  153.   http://www.ncsa.uiuc.edu/SDG/Software/Mosaic/Docs/htmlwidget.html
  154.   ( it's on the older version, I think Mosaic1.x )
  155.  
  156. For starters, you can compile directory Mosaic2.4/libhtmlw for the widget.
  157. Using: To create widget:
  158.   htlmWid = XtCreateManagedWidget( "htlmWid",
  159. htmlWidgetClass,                                      parent,
  160.                                      htlmArgs,
  161.                                      XtNumber( htlmArgs ));
  162.  
  163. Callback for anchors:
  164.   XtAddCallback(htlmWid, WbNanchorCallback, htmlRef, NULL);
  165.  
  166. where htmlRef() looks like:
  167.  
  168. static void htmlRef(widget, client_data, call_data) Widget widget; XtPointer
  169. client_data; WbAnchorCallbackData* call_data; {
  170.         buffer = readHTMLFile( call_data->href );
  171.         XtVaSetValues( widget, WbNtext, buffer, NULL ); }
  172.  
  173. where readHTMLFile() is
  174.  
  175. char * readHTMLFile( in_file ) char *in_flie; {
  176.   /* function to read a file and return its content, given
  177.      the file's name */ }
  178.  
  179. I think this is enough to start you off.
  180.  
  181.  
  182. Thanks to: Samuel Effah
  183.  
  184. -----------------------------------------------------------------------------
  185. Subject: 45)*  What widgets does Netscape use for its bookmarks list and
  186. preference panels?
  187. [Last modified: Jan 02]
  188.  
  189. Answer: Netscape uses the Microline widget set.  Microline was purchased by
  190. Neuron Data (http://www.neurondata.com/), but they no longer sell the
  191. Microline widget set.
  192.  
  193. Some of the Microline widgets are available in the Mozilla source code:
  194. http://lxr.mozilla.org/classic/source/cmd/xfe/Microline3.0/
  195.  
  196. Ken Lee, http://www.rahul.net/kenton/
  197.  
  198. -----------------------------------------------------------------------------
  199. Subject: 46)  TOPIC: BOOKS and JOURNALS
  200.  
  201. -----------------------------------------------------------------------------
  202. Subject: 47)  Is there a Motif tutorial? Xt tutorial? X11 tutorial?
  203. [Last modified: Nov 96]
  204.  
  205. Answer: For the most up-to-date links to Motif/X11/Xt tutorials, see:
  206.  
  207.     http://www.rahul.net/kenton/xsites.html#Xtutorials
  208.     On-line X programming tutorials (Kenton Lee's multi-lingual links)
  209.  
  210.  
  211. See http://www.cm.cf.ac.uk/Dave/X_lecture/X_lecture.html
  212. for a hypertext Motif tutorial (by David Marshall) with source code and
  213. illustrations.
  214.  
  215. Marshall Brain at brain@adm.csc.ncsu.edu posted a set of simple and useful
  216. Motif tutorials at http://www.iftech.com/ .
  217.  
  218. Jan Borchers <borchers@stanford.edu> writes about his Xmtutor:
  219.  
  220. "Xmtutor" is an interactive tutorial teaching you how to write Motif
  221. applications. While it comes with a complete printable book file, its key
  222. component is the online version of the tutorial: It's a Motif application
  223. itself, and its examples are actual running Motif applications. You can modify
  224. their resource settings from within the tutorial, and then play with them to
  225. see how their interface reacts.  For the free version, screen shots,
  226. registration, and more information check out the Xmtutor home page at:
  227.  
  228.     http://www.stanford.edu/~borchers/xmtutor/
  229.  
  230.  
  231. More on-line Motif tutorials and technical papers are listed on my web site:
  232.  
  233. http://www.rahul.net/kenton/
  234.  
  235.  
  236. -----------------------------------------------------------------------------
  237. Subject: 48)  What books are available for Motif application programmers?
  238. [Last modified: Mar 98]
  239.  
  240. Answer: NOTE: This subject is impossible to keep meaningfully up to date and
  241. has been deleted.
  242.  
  243. -----------------------------------------------------------------------------
  244. Subject: 49)  What relevant journals are available?
  245. [Last modified: Jun 98]
  246.  
  247. Answer: In October, 1997, ICS has launched The Motif Zone at
  248.  
  249.     http://www.motifzone.com/
  250.  
  251. This web site contains a Motif reference section and an on-line magazine
  252. called *The Motif Developer*.
  253.  
  254. Several other Motif-oriented magazines have existed in the past, but are
  255. ceased publishing.  Their back issues are still very interesting, though.
  256. Back issues of the print magazines may be available from their publishers or
  257. at better technical libraries.  Back issues of "The X Advisor" are no longer
  258. on line.
  259.  
  260. "The X Journal" was published bimonthly by SIGS Publications, +1-212-274-0640.
  261. "The X Resource: A Practical Journal of the X Window System" was published
  262. quarterly by O'Reilly and Associates, +1-800-998-9938.
  263.  
  264. -----------------------------------------------------------------------------
  265. Subject: 50)  TOPIC: MWM and the SHELL WIDGET
  266.  
  267. -----------------------------------------------------------------------------
  268. Subject: 51)  What is the difference between Motif and mwm?
  269.  
  270. Answer: mwm is a window manager.
  271.  
  272. Motif itself is made up of four parts: a User Interface Style Guide, an API
  273. toolkit of `C' routines which helps in the building of applications which
  274. conform to the style guide, the window manager mwm, and a language UIL which
  275. is designed to ease user interface development.
  276.  
  277. In general mwm will run any application built with any X Window System API,
  278. and in general an application built using the Motif toolkit will run under any
  279. window manager.
  280.  
  281. -----------------------------------------------------------------------------
  282. Subject: 52)  Does anyone have an alternative set of 3-D defaults for a
  283. monochrome screen?
  284.  
  285. Answer: This is obviously a matter of taste. Some alternatives suggested
  286. include
  287.  
  288. !Benjamin Schreiber, bs@osf.osf.org, bs@cs.brandeis.edu
  289. Mwm*foreground:                 black           ! Actually, when a window is
  290. Mwm*background:                 white           ! deactivated, the background
  291. Mwm*backgroundPixmap:           50_foreground   ! becomes white, insted of
  292. Mwm*topShadowPixmap:            white           ! 50% foreground (grey)
  293.  
  294. Mwm*activeForeground:           black
  295. Mwm*activeBackground:           white
  296. Mwm*activeBackgroundPixmap:     50_foreground
  297. Mwm*activeTopShadowPixmap:      white
  298.  
  299. Mwm*menu*backgroundPixmap:      background
  300. Mwm*menu*topShadowPixmap:       50_foreground
  301.  
  302. Mwm*title*foreground:                   black
  303. Mwm*title*background:                   white
  304. Mwm*title*backgroundPixmap:             white
  305. Mwm*title*topShadowPixmap:              50_foreground
  306. Mwm*title*activeForeground:             white
  307. Mwm*title*activeBackground:             black
  308. Mwm*title*activeBackgroundPixmap:       black
  309. Mwm*title*activeBottomShadowPixmap:     50_foreground
  310.  
  311. Mwm*feedback*backgroundPixmap:          white
  312.  
  313. or
  314.  
  315. ! From: tsang@isi.com (Kam C. Tsang)
  316. Mwm*background:                      White
  317. Mwm*activeBackground:                White
  318. Mwm*activeBackgroundPixmap:          25_foreground
  319. Mwm*foreground:                      Black
  320. Mwm*activeForeground:                Black
  321. Mwm*menu*background:                 white
  322. Mwm*menu*foreground:                 black
  323. xterm*Foreground:                    black
  324. xterm*Background:                    white
  325.  
  326. or
  327.  
  328. ! From: ucsd.edu!usc!snorkelwacker!paperboy!yee  (Michael K. Yee)
  329. Mwm*cleanText:                          True
  330.  
  331. Mwm*activeBackground:           white
  332. Mwm*activeForeground:           black
  333. Mwm*background:                 white
  334. Mwm*foreground:                 black
  335.  
  336. Mwm*client*activeBackgroundPixmap:      50_foreground
  337. Mwm*client*activeTopShadowPixmap:       foreground
  338. Mwm*client*activeBottomShadowPixmap:    background
  339.  
  340. !Mwm*client*background:                 white
  341. !Mwm*client*foreground:                 black
  342. Mwm*client*backgroundPixmap:            75_foreground
  343. Mwm*client*topShadowPixmap:             foreground
  344. Mwm*client*bottomShadowPixmap:          background
  345.  
  346. !Mwm*feedback*background:               white
  347. !Mwm*feedback*foreground:               black
  348. Mwm*feedback*backgroundPixmap:          50_foreground
  349. !Mwm*feedback*topShadowPixmap:          25_foreground
  350. !Mwm*feedback*bottomShadowPixmap:       background
  351.  
  352. !Mwm*menu*background:                   white
  353. !Mwm*menu*foreground:                   black
  354. Mwm*menu*backgroundPixmap:              foreground
  355. !Mwm*menu*topShadowPixmap:              foreground
  356. !Mwm*menu*bottomShadowPixmap:           background
  357.  
  358. !Mwm*icon*background:                   white
  359. !Mwm*icon*foreground:                   black
  360. Mwm*icon*activeBackgroundPixmap:        50_foreground
  361. Mwm*icon*activeBottomShadowPixmap:      foreground
  362. Mwm*icon*backgroundPixmap:              75_foreground
  363.  
  364.  
  365. -----------------------------------------------------------------------------
  366. Subject: 53)  What are some useful mwm resources I can control?
  367. [Last modified: Sept 95]
  368.  
  369. Answer: Ken Sall (ksall@cen.com) writes: The following are described in the
  370. mwm(1) man page:
  371.  
  372.     clientAutoPlace (class ClientAutoPlace)
  373.     focusAutoRaise (class FocusAutoRaise)
  374.     interactivePlacement (class InteractivePlacement)
  375.     positionIsFrame (class PositionIsFrame)
  376.     positionOnScreen (class PositionOnScreen)
  377.     useIconBox (class UseIconBox)
  378.  
  379.  
  380. -----------------------------------------------------------------------------
  381. Subject: 54)  How can I configure mwm, such as changing or adding to root
  382. menus?
  383. [Last modified: Oct 95]
  384.  
  385. Answer: Read the mwm(1) man page which describes how to configure mwm using
  386. the .mwmrc file. The default location of the system-wide version of this file
  387. is /usr/lib/X11/system.mwmrc. You can override settings in the global file by
  388. creating your own $HOME/.mwmrc.
  389.  
  390. -----------------------------------------------------------------------------
  391. Subject: 55)  How can my program determine which window manager is running?
  392. [Last modified: Nov 97]
  393.  
  394. Answer: Each window manager has its own signature, but unfortunately there is
  395. no standard query mechanism.  Motif provides XmIsMotifWMRunning() to test for
  396. mwm.
  397.  
  398. -----------------------------------------------------------------------------
  399.  
  400. Subject: 56)  How can I modify the mwm's window decorations with a resource
  401. file?
  402. [Last modified: Dec 97]
  403.  
  404. Answer: Set mwm's client resource "clientDecoration" for your particular
  405. application.  For example,
  406.  
  407. Mwm*XClock.clientDecoration: none
  408.  
  409. turns off all clock decorations.  See the mwm man page for other options and
  410. other mwm client resources.
  411.  
  412. -----------------------------------------------------------------------------
  413.  
  414. Subject: 57)  How can I programatically modify the mwm's window decorations?
  415. [Last modified: July 95]
  416.  
  417. Answer: Programmatically, set the VendorShell resource XmNmwmDecorations to 0,
  418. such as:
  419.  
  420.   #include <Xm/MwmUtil.h> /* see MWM_DECOR_* and MWM_FUNC_* */
  421.   #include <Xm/DialogS.h>
  422.   popupShell =
  423.       XtVaCreatePopupShell( "PopupShell",
  424.                             xmDialogShellWidgetClass, toplevel,
  425.                             XmNmwmDecorations, 0,
  426.                             NULL );
  427.  
  428. With the 0, you have no decorations at all, but if you want just a little
  429. frame, use MWM_DECOR_BORDER instead.
  430.  
  431. Thanks to Guillaume.Gallais@asm.thomson.fr for the code fragment and pointing
  432. out that there is no MWM_DECOR_NONE.
  433.  
  434. Reinhard M. Weiss (weissrm@execpc.com) also pointed out that MWM_DECOR_NONE
  435. was fictitious. He also added:
  436.  
  437. "I have found that the resource XtNoverrideRedirect does cause the olwm to
  438. remove all decorations (my guess is that it would work in mwm roughly the
  439. same).  This works programmatically as well as in resource files (i.e.
  440. *.className*overrideRedirect: true). There are some undesirable effects to
  441. this, however, particularly with focus and managing dialogs and popups."
  442.  
  443. -----------------------------------------------------------------------------
  444. Subject: 58)  Is there an ICCCM compliant way of setting window manager
  445. decorations?
  446.  
  447. Answer: Tom LaStrange (toml@LaStrange.COM) writes: "No, there is no ICCCM
  448. portable way to alter decorations."
  449.  
  450. -----------------------------------------------------------------------------
  451. Subject: 59)  How can I put decorations on transient windows using olwm?
  452.  
  453. Answer: This code is from Jean-Philippe Martin-Flatin <syj@ecmwf.int>:
  454.  
  455. /**********************************************************************
  456. ** WindowDecorations.c
  457. **
  458. ** Manages window decorations under the OpenLook window manager (OLWM).
  459. **
  460. ** Adapted from a C++ program posted to comp.windows.x.motif by:
  461. **
  462. **    +--------------------------------------------------------------+
  463. **    | Ron Edmark                          User Interface Group     |
  464. **    | Tel:        (408) 980-1500 x282     Integrated Systems, Inc. |
  465. **    | Internet:   edmark@isi.com          3260 Jay St.             |
  466. **    | Voice mail: (408) 980-1590 x282     Santa Clara, CA 95054    |
  467. **    +--------------------------------------------------------------+
  468. ***********************************************************************/
  469.  
  470. #include <X11/X.h>
  471. #include <X11/Xlib.h>
  472. #include <X11/Xatom.h>
  473. #include <X11/Intrinsic.h>
  474. #include <X11/StringDefs.h>
  475. #include <X11/Protocols.h>
  476. #include <Xm/Xm.h>
  477. #include <Xm/AtomMgr.h>
  478.  
  479. /*
  480. ** Decorations for OpenLook:
  481. ** The caller can OR different mask options to change the frame decoration.
  482. */
  483. #define OLWM_Header     (long)(1<<0)
  484. #define OLWM_Resize     (long)(1<<1)
  485. #define OLWM_Close      (long)(1<<2)
  486.  
  487. /*
  488. ** Prototypes
  489. */
  490. static void InstallOLWMAtoms  (Widget w);
  491. static void AddOLWMDialogFrame(Widget widget, long decorationMask);
  492.  
  493.  
  494. /*
  495. ** Global variables
  496. */
  497. static Atom AtomWinAttr;
  498. static Atom AtomWTOther;
  499. static Atom AtomDecor;
  500. static Atom AtomResize;
  501. static Atom AtomHeader;
  502. static Atom AtomClose;
  503. static int  not_installed_yet = TRUE;
  504.  
  505.  
  506. static void InstallOLWMAtoms(Widget w)
  507. {
  508.         AtomWinAttr = XInternAtom(XtDisplay(w), "_OL_WIN_ATTR" ,    FALSE);
  509.         AtomWTOther = XInternAtom(XtDisplay(w), "_OL_WT_OTHER",     FALSE);
  510.         AtomDecor   = XInternAtom(XtDisplay(w), "_OL_DECOR_ADD",    FALSE);
  511.         AtomResize  = XInternAtom(XtDisplay(w), "_OL_DECOR_RESIZE", FALSE);
  512.         AtomHeader  = XInternAtom(XtDisplay(w), "_OL_DECOR_HEADER", FALSE);
  513.         AtomClose   = XInternAtom(XtDisplay(w), "_OL_DECOR_CLOSE",  FALSE);
  514.  
  515.         not_installed_yet = FALSE;
  516. }
  517.  
  518. static void AddOLWMDialogFrame(Widget widget, long decorationMask)
  519. {
  520.         Atom   winAttrs[2];
  521.         Atom   winDecor[3];
  522.         Widget shell = widget;
  523.         Window win;
  524.         int    numberOfDecorations = 0;
  525.  
  526.         /*
  527.         ** Make sure atoms for OpenLook are installed only once
  528.         */
  529.         if (not_installed_yet) InstallOLWMAtoms(widget);
  530.  
  531.         while (!XtIsShell(shell)) shell = XtParent(shell);
  532.  
  533.         win = XtWindow(shell);
  534.  
  535.         /*
  536.         ** Tell Open Look that our window is not one of the standard OLWM window
  537.         ** types. See OLIT Widget Set Programmer's Guide pp.70-73.
  538.         */
  539.  
  540.         winAttrs[0] = AtomWTOther;
  541.  
  542.         XChangeProperty(XtDisplay(shell),
  543.                         win,
  544.                         AtomWinAttr,
  545.                         XA_ATOM,
  546.                         32,
  547.                         PropModeReplace,
  548.                         (unsigned char*)winAttrs,
  549.                         1);
  550.  
  551.         /*
  552.         ** Tell Open Look to add some decorations to our window
  553.         */
  554.         numberOfDecorations = 0;
  555.         if (decorationMask & OLWM_Header)
  556.                 winDecor[numberOfDecorations++] = AtomHeader;
  557.         if (decorationMask & OLWM_Resize)
  558.                 winDecor[numberOfDecorations++] = AtomResize;
  559.         if (decorationMask & OLWM_Close)
  560.         {
  561.                 winDecor[numberOfDecorations++] = AtomClose;
  562.  
  563.                 /*
  564.                 ** If the close button is specified, the header must be
  565.                 ** specified. If the header bit is not set, set it.
  566.                 */
  567.                 if (!(decorationMask & OLWM_Header))
  568.                         winDecor[numberOfDecorations++] = AtomHeader;
  569.         }
  570.  
  571.         XChangeProperty(XtDisplay(shell),
  572.                         win,
  573.                         AtomDecor,
  574.                         XA_ATOM,
  575.                         32,
  576.                         PropModeReplace,
  577.                         (unsigned char*)winDecor,
  578.                         numberOfDecorations);
  579. }
  580.  
  581.  
  582. /*
  583. ** Example of use of AddOLWMDialogFrame, with a bit of extra stuff
  584. */
  585. void register_dialog_to_WM(Widget shell, XtCallbackProc Cbk_func)
  586. {
  587.         Atom atom;
  588.  
  589.         /*
  590.         ** Alias the "Close" item in system menu attached to dialog shell
  591.         ** to the activate callback of "Exit" in the menubar
  592.         */
  593.         if (Cbk_func)
  594.         {
  595.             atom = XmInternAtom(XtDisplay(shell),"WM_DELETE_WINDOW",TRUE);
  596.             XmAddWMProtocolCallback(shell,atom, Cbk_func,NULL);
  597.         }
  598.  
  599.         /*
  600.         ** If Motif is the window manager, skip OpenLook specific stuff
  601.         */
  602.         if (XmIsMotifWMRunning(shell)) return;
  603.  
  604.         /*
  605.         ** Register dialog shell to OpenLook.
  606.         **
  607.         ** WARNING: on some systems, adding the "Close" button allows the title
  608.         ** to be properly centered in the title bar. On others, activating
  609.         ** "Close" crashes OpenLook. The reason is not clear yet, but it seems
  610.         ** the first case occurs with OpenWindows 2 while the second occurs with
  611.         ** Openwindows 3. Thus, comment out one of the two following lines as
  612.         ** suitable for your site, and send e-mail to syj@ecmwf.int if you
  613.         ** find out what is going on !
  614.         */
  615.         AddOLWMDialogFrame(shell,(OLWM_Header | OLWM_Resize));
  616. /*      AddOLWMDialogFrame(shell,(OLWM_Header | OLWM_Resize | OLWM_Close)); */
  617. }
  618.  
  619.  
  620. -----------------------------------------------------------------------------
  621. Subject: 60)  How can I turn off the Motif window manager functions from the
  622. system menu?
  623. [Last modified: October 92]
  624.  
  625. Answer: The user of an application can control functions in the system menu
  626. for an application using the mwm resource clientFunctions:
  627.  
  628.     mwm.application_name.clientFunctions: -resize -close
  629.  
  630. Note that mwm will have to be restarted after putting this in their resource
  631. database.
  632.  
  633.  
  634. Answer: The writer of an application can only remove items.  Be warned that
  635. your users will probably gnash their teeth, swear furiously at your product
  636. and stop using it if they discover that you have done this.  (Especially if
  637. you have removed the Close button, your application has hung and it has taken
  638. up all of memory and swap so it can't be killed.) Much better is to catch the
  639. action gracefully as in the next question.
  640.  
  641.     #include <Xm/MwmUtil.h>
  642.  
  643.     XtVaGetValues(shell, XmNmwmFunctions, &int_val, NULL);
  644.     int_val &= ~(MWM_FUNC_CLOSE | MWM_FUNC_ALL);
  645.     XtVaSetValues(shell, XmNmwmFunctions, int_val, NULL);
  646.  
  647.  
  648. -----------------------------------------------------------------------------
  649. Subject: 61)  How can I create a multi-colored window manager icon?
  650. [Last modified: Oct 95]
  651.  
  652. Answer: The only portable way to do this is with icon windows.  The WMShell
  653. widget supports icon windows with its XmNiconWindow resource.  Set this to a
  654. window  that your application has created.  The window could be the XtWindow()
  655. of a realized shell widget.  The window must be created with the default
  656. visual and colormap of its screen.  Other requirements on icon windows are
  657. specified in section 4.1.9 of the X11R6 ICCCM.  Note that some window managers
  658. provide alternate techniques for creating color icons; none of these are
  659. standard or portable.
  660.  
  661. Ken Lee
  662.  
  663. -----------------------------------------------------------------------------
  664. Subject: 62)  How can I keep my shell windows fixed in size?
  665. [Last modified: Apr 95]
  666.  
  667. Answer: In addition to the decoration controls mentioned in the previous few
  668. subjects of this FAQ, you can also specify size hints for your shell widget's
  669. windows with these resources:  XmNminWidth, XmNmaxWidth, XmNminHeight,
  670. XmNmaxHeight.  If you set the min and max values to the same size, most window
  671. managers will not allow the user to resize the window.
  672.  
  673. Ken Lee
  674.  
  675. -----------------------------------------------------------------------------
  676. Subject: 63)  Why is XtGetValues of XmNx and XmNy of my toplevel shell wrong?
  677. [Last modified: Oct 95]
  678.  
  679. Answer: [Note: This answer is borrowed from the Xt FAQ,
  680. ftp://ftp.x.org/contrib/faqs/FAQ-Xt, devoted to X Toolkit Intrinsics.]
  681.  
  682. XmNx and XmNy are the coordinates relative to your shell's parent window,
  683. which is usually a window manager's frame window.  To translate to the root
  684. coordinate space, use XtTranslateCoords().
  685.  
  686. -----------------------------------------------------------------------------
  687. Subject: 64)  How do I get XmNx and XmNy positions to be honored correctly?
  688. [Last modified: Nov 96]
  689.  
  690. Answer: One answer is to pass the right hints to the window manager, perhaps
  691. using XSetWMNormalHints.  Another approach comes from Shane Burgess
  692. (shane@radionics.com) who writes:
  693.  
  694. By setting the XmNdefaultPosition resource (on XmBulletinBoard or its
  695. subclasses, including the message dialogs) to False, I've found that all my
  696. XmNx & XmNy requests gets set correctly.
  697.  
  698. Pete Sakalaukus (sakalauk@pelican.st.usm.edu) says that XmNdefaultPosition
  699. only works with olwm, not mwm.
  700.  
  701. -----------------------------------------------------------------------------
  702. Subject: 65)  How can my application know when the user has quit Mwm?
  703. [Last modified: Feb 95]
  704.  
  705. Answer: Looking for an answer to this one. ANY TAKERS? (Still looking.)
  706.  
  707. -----------------------------------------------------------------------------
  708. Subject: 66)  How can I tell if the user has selected "Close" from the system
  709. menu? How do I catch the "Close"?  I need to do some clean up before exiting.
  710. [Last modified: Aug 95]
  711.  
  712. Answer: Catching the mwm Close involves using XmAddWMProtocolCallback and
  713. possibly setting the XmNdeleteResponse resource. Note that whether your
  714. application involves multiple applicationShells vs. a single applicationShell
  715. and multiple toplevelShells is significant. Following the two older code
  716. fragments is a complete test application which can be compiled with different
  717. #defines to alter the behavior.
  718.  
  719. This works with R4 Intrinsics
  720.  
  721.         #include <Xm/Protocols.h>
  722.  
  723.         void FinalCleanupCB(w, client_data, call_data)
  724.         Widget   w;
  725.         caddr_t  client_data, call_data;
  726.         {
  727.                 /* tidy up stuff here */
  728.                 ...
  729.                 /* exit if you want to */
  730.                 exit (0);
  731.         }
  732.  
  733.         main()
  734.         {
  735.                 Atom wm_delete_window;
  736.  
  737.                 ...
  738.                 XtRealizeWidget(toplevel);
  739.                 ...
  740.                 wm_delete_window =
  741.                         XmInternAtom(XtDisplay(toplevel),
  742.                                 "WM_DELETE_WINDOW", False);
  743.                 XmAddWMProtocolCallback(toplevel, wm_delete_window,
  744.                         FinalCleanupCB, NULL);
  745.                 XtMainLoop();
  746.         }
  747.  
  748. This will still kill the application.  To turn this behaviour off so that the
  749. application is not killed, set the shell resource XmNdeleteResponse to
  750. XmDO_NOTHING.  This means that users cannot kill your application via the
  751. system menu, and may be a bad thing.
  752.  
  753. If you are running R3, Bob Hays (bobhays@spss.com) has suggested this:
  754. "Trapping on the delete window atom does not work as I cannot force my action
  755. routine to the top of the action list for the activity desired, so the window
  756. manager kills my window anyway BEFORE I can do anything about it.  And, to
  757. make matters worse, the window manager (Motif in this case) tacks its atoms
  758. and handlers onto the window at some unknown point down the line after the
  759. creation of the shell widget as far as I can tell.  So....
  760.  
  761. I have a procedure as an action routine for ClientMessage.  Then, if I get a
  762. property change event on the window manager protocols, I then tack on
  763. WM_SAVE_YOURSELF.  If I get this request, I clean up (it seems to happen on
  764. WM_DELETE_WINDOW, BTW, if you remove WM_DELETE_WINDOW from the WM protocols
  765. atom) and exit.  Works great and is less filling overall:-)."
  766.  
  767. The following similar code fragment is from Dave Mink
  768. (mink@cadcam.pms.ford.com):
  769.  
  770. void setupCloseCallback(Widget shell, XtCallbackProc closeProc)
  771. {
  772.     /* get window manager delete protocol atom */
  773.     Atom deletewin_protocol = XmInternAtom(
  774.         XtDisplay(shell), "WM_DELETE_WINDOW", True
  775.         );
  776.     /* turn off default delete response */
  777.     XtVaSetValues( shell,
  778.         XmNdeleteResponse, XmDO_NOTHING,
  779.         NULL);
  780.     /* add callback for window manager delete protocol */
  781.     XmAddWMProtocolCallback(shell, deletewin_protocol, closeProc, NULL);
  782. }
  783.  
  784.  
  785. Here is a complete code example which can be compiled several different ways,
  786. as per the comments in the code.
  787.  
  788.  
  789. /*
  790.  * MWM Close test program.
  791.  *
  792.  * Creates 4 shells, testing each of 3 different values of XmNdeleteResponse.
  793.  * Compile will -DMULTIPLE_APP_SHELLS to make all 4 shells of type
  794.  * applicationShellWidgetClass. Otherwise, first shell created is
  795.  * applicationShellWidgetClass, but other 3 are topLevelShellWidgetClass.
  796.  * Results differ. You can also experiment with #defining POPUP_SHELL,
  797.  * BEFORE_CREATE, or AFTER_CREATE.
  798.  *
  799.  * Ken Sall (ksall@cen.com)
  800.  */
  801.  
  802. #include <stdio.h>
  803.  
  804. #include <X11/IntrinsicP.h>
  805. #include <X11/StringDefs.h>
  806.  
  807. #include <X11/Shell.h>
  808. #include <Xm/Xm.h>
  809. #include <Xm/XmP.h>
  810.  
  811. #include <Xm/RowColumn.h> /* for popup */
  812. #include <Xm/Label.h>
  813.  
  814. #include <X11/Protocols.h>
  815. #include <X11/AtomMgr.h>
  816. #include <X11/MwmUtil.h>
  817.  
  818. void CloseCB();
  819. void popup_handler();
  820.  
  821. #ifdef MULTIPLE_APP_SHELLS
  822. #define P1_TITLE        "P1: applicationShell: XmDO_NOTHING"
  823. #define P2_TITLE        "P2: applicationShell: XmDESTROY"
  824. #define P3_TITLE        "P3: applicationShell: XmUNMAP"
  825. #define P4_TITLE        "P4: applicationShell: default"
  826. #else
  827. #define P1_TITLE        "P1: applicationShell: XmDO_NOTHING"
  828. #define P2_TITLE        "P2: topLevelShell: XmDESTROY"
  829. #define P3_TITLE        "P3: topLevelShell: XmUNMAP"
  830. #define P4_TITLE        "P4: topLevelShell: XmDO_NOTHING"
  831. #endif
  832.  
  833. void CloseCB (w, client_data, call_data)
  834. Widget  w;              /*  widget id           */
  835. caddr_t client_data;    /*  data from application   */
  836. caddr_t call_data;      /*  data from widget class  */
  837. {
  838.     XmAnyCallbackStruct *cb = (XmAnyCallbackStruct *) call_data;
  839.  
  840.     printf ("caught Close from: %s\n", (char *)client_data );
  841.     if (strcmp ( P1_TITLE, (char *)client_data ) == 0 )
  842.             {
  843.             /* do something */
  844.             }
  845.     else if (strcmp ( P2_TITLE, (char *)client_data ) == 0 )
  846.             {
  847.             /* do something else */
  848.             }
  849.     else if (strcmp ( P3_TITLE, (char *)client_data ) == 0 )
  850.             {
  851.             /* do something else */
  852.             }
  853.     else if (strcmp ( P4_TITLE, (char *)client_data ) == 0 )
  854.             {
  855.             /* do something else */
  856.             }
  857.     else        /* unreachable */
  858.             {
  859.             printf ("oops\n");
  860.             }
  861. }
  862.  
  863. void popup_handler()
  864. {
  865.     printf ("popup handler\n");
  866. }
  867.  
  868. int main (argc,argv, envp)
  869.     int  argc;
  870.     char **argv;
  871.     char **envp;
  872. {
  873.    XtAppContext  app_context;
  874.    Display       *theDisplay;
  875.    Widget        shell1, shell2, shell3, shell4;
  876.    Widget        label, DrawWindow, WindowPopupMenu;
  877.    Arg           al[10];
  878.    int           ac;
  879.    Atom          delwinAtom1, delwinAtom2, delwinAtom3, delwinAtom4;
  880.    XmString      xms;
  881.  
  882. #ifdef MULTIPLE_APP_SHELLS
  883.    printf ("This version will demonstrate a problem if you Close P2.\n");
  884.    printf ("Since there are multiple appshells, closing (destroying) P2 cause the app to exit.\n");
  885. #else
  886. #ifdef POPUP_SHELL
  887.    printf ("This version uses XtCreatePopupShell rather than XtAppCreateShell \n");
  888. #else
  889.    printf ("Compile with '-DMULTIPLE_APP_SHELLS' to demonstrate a problem.\n");
  890. #endif
  891. #endif
  892.  
  893. #ifdef BEFORE_CREATE
  894.    printf ("This version adds the XmNdeleteResponse _before_ the shell is created.\n");
  895. #else
  896.    printf ("This version adds the XmNdeleteResponse _after the shell is created.\n");
  897. #endif
  898.  
  899.    XtToolkitInitialize ();
  900.    app_context = XtCreateApplicationContext ();
  901.  
  902.    theDisplay = XtOpenDisplay ( app_context, NULL,
  903.                                "my_program", "ProgramClass",
  904.                                 NULL, 0, &argc, argv);
  905.  
  906.    /* ---------------------   BEGIN P1  -------------------- */
  907.    ac = 0;
  908.    XtSetArg(al[ac], XmNx, 0); ac++;
  909.    XtSetArg(al[ac], XmNy, 0); ac++;
  910.    XtSetArg(al[ac], XmNwidth, 350); ac++;
  911.    XtSetArg(al[ac], XmNheight, 200); ac++;
  912.    XtSetArg (al[ac], XmNtitle, P1_TITLE); ac++;
  913. #ifdef BEFORE_CREATE
  914.    XtSetArg (al[ac], XmNdeleteResponse, XmDO_NOTHING); ac++;
  915. #endif
  916.  
  917.    /* The ONLY applicationShell unless MULTIPLE_APP_SHELLS is defined. */
  918.  
  919.    shell1 = XtAppCreateShell ("shell1", "ProgramClass",
  920.                 applicationShellWidgetClass, theDisplay, al, ac);
  921.  
  922.    /* Tell mwm to exec CloseCB when close is detected. */
  923.    delwinAtom1 = XmInternAtom (XtDisplay(shell1),
  924.                                     "WM_DELETE_WINDOW", False);
  925.    XmAddWMProtocolCallback (shell1, delwinAtom1, CloseCB, P1_TITLE);
  926.  
  927. #ifndef BEFORE_CREATE
  928.    XtVaSetValues( shell1, XmNdeleteResponse, XmDO_NOTHING, NULL);
  929. #endif
  930.  
  931.    /* ---------------------   BEGIN P2  -------------------- */
  932.    ac = 0;
  933.    XtSetArg(al[ac], XmNx, 375); ac++;
  934.    XtSetArg(al[ac], XmNy, 0); ac++;
  935.    XtSetArg(al[ac], XmNwidth, 350); ac++;
  936.    XtSetArg(al[ac], XmNheight, 200); ac++;
  937.    XtSetArg (al[ac], XmNtitle, P2_TITLE); ac++;
  938. #ifdef BEFORE_CREATE
  939.    XtSetArg (al[ac], XmNdeleteResponse, XmDESTROY); ac++;
  940. #endif
  941.  
  942. #ifdef MULTIPLE_APP_SHELLS
  943.    shell2 = XtAppCreateShell ("shell2", "ProgramClass",
  944.                 applicationShellWidgetClass, theDisplay, al, ac);
  945. #else
  946. #ifdef POPUP_SHELL
  947.    /*
  948.     * NOTE use of XtCreatePopupShell (not XtCreateMAnagedWidget) and
  949.     * topLevelShellWidgetClass (not applicationShellWidgetClass).
  950.     * Parent of topLevelShell is applicationShell.
  951.     * Use XtPopup rather than XtRealize for topLevelShell.
  952.     */
  953.    shell2 = XtCreatePopupShell ("shell2",
  954.                 topLevelShellWidgetClass, shell1, al, ac);
  955. #else
  956.    shell2 = XtAppCreateShell ("shell2", "ProgramClass",
  957.                 topLevelShellWidgetClass, theDisplay, al, ac);
  958. #endif
  959. #endif
  960.  
  961.    /* Tell mwm to exec CloseCB when close is detected. */
  962.    delwinAtom2 = XmInternAtom (XtDisplay(shell2),
  963.                                     "WM_DELETE_WINDOW", False);
  964.    XmAddWMProtocolCallback (shell2, delwinAtom2, CloseCB, P2_TITLE);
  965.  
  966. #ifndef BEFORE_CREATE
  967.    XtVaSetValues( shell2, XmNdeleteResponse, XmDESTROY, NULL);
  968. #endif
  969.  
  970.    /* ---------------------   BEGIN P3  -------------------- */
  971.    ac = 0;
  972.    XtSetArg(al[ac], XmNx, 750); ac++;
  973.    XtSetArg(al[ac], XmNy, 0); ac++;
  974.    XtSetArg(al[ac], XmNwidth, 350); ac++;
  975.    XtSetArg(al[ac], XmNheight, 200); ac++;
  976.    XtSetArg (al[ac], XmNtitle, P3_TITLE); ac++;
  977. #ifdef BEFORE_CREATE
  978.    XtSetArg (al[ac], XmNdeleteResponse, XmUNMAP); ac++;
  979. #endif
  980.  
  981. #ifdef MULTIPLE_APP_SHELLS
  982.    shell3 = XtAppCreateShell ("shell3", "ProgramClass",
  983.                 applicationShellWidgetClass, theDisplay, al, ac);
  984. #else
  985. #ifdef POPUP_SHELL
  986.    /* See comments for shell2 */
  987.    shell3 = XtCreatePopupShell ("shell3",
  988.                 topLevelShellWidgetClass, shell1, al, ac);
  989. #else
  990.    shell3 = XtAppCreateShell ("shell3", "ProgramClass",
  991.                 topLevelShellWidgetClass, theDisplay, al, ac);
  992. #endif
  993. #endif
  994.  
  995.    /* Tell mwm to exec CloseCB when close is detected. */
  996.    delwinAtom3 = XmInternAtom (XtDisplay(shell3),
  997.                                     "WM_DELETE_WINDOW", False);
  998.    XmAddWMProtocolCallback (shell3, delwinAtom3, CloseCB, P3_TITLE);
  999.  
  1000. #ifndef BEFORE_CREATE
  1001.    XtVaSetValues( shell3, XmNdeleteResponse, XmUNMAP, NULL);
  1002. #endif
  1003.  
  1004.    /* ---------------------   BEGIN P4  -------------------- */
  1005.    ac = 0;
  1006.    XtSetArg(al[ac], XmNx, 0); ac++;
  1007.    XtSetArg(al[ac], XmNy, 250); ac++;
  1008.    XtSetArg(al[ac], XmNwidth, 350); ac++;
  1009.    XtSetArg(al[ac], XmNheight, 200); ac++;
  1010.    XtSetArg (al[ac], XmNtitle, P4_TITLE); ac++;
  1011. #ifdef BEFORE_CREATE
  1012.    XtSetArg (al[ac], XmNdeleteResponse, XmDO_NOTHING); ac++;
  1013. #endif
  1014.  
  1015. #ifdef MULTIPLE_APP_SHELLS
  1016.    shell4 = XtAppCreateShell ("shell4", "ProgramClass",
  1017.                 applicationShellWidgetClass, theDisplay, al, ac);
  1018. #else
  1019. #ifdef POPUP_SHELL
  1020.    /* See comments for shell2 */
  1021.    shell4 = XtCreatePopupShell ("shell4",
  1022.                 topLevelShellWidgetClass, shell1, al, ac);
  1023. #else
  1024.    shell4 = XtAppCreateShell ("shell4", "ProgramClass",
  1025.                 topLevelShellWidgetClass, theDisplay, al, ac);
  1026. #endif
  1027. #endif
  1028.  
  1029.    /* Tell mwm to exec CloseCB when close is detected. */
  1030.    delwinAtom4 = XmInternAtom (XtDisplay(shell4),
  1031.                                     "WM_DELETE_WINDOW", False);
  1032.    XmAddWMProtocolCallback (shell4, delwinAtom4, CloseCB, P4_TITLE);
  1033.  
  1034. #ifndef BEFORE_CREATE
  1035.    XtVaSetValues( shell4, XmNdeleteResponse, XmDO_NOTHING, NULL);
  1036. #endif
  1037.  
  1038.    /* just for fun */
  1039.    ac = 0;
  1040.    WindowPopupMenu = XmCreatePopupMenu(shell1, "PopupMenu", al, ac);
  1041.    XtAddEventHandler( shell1, ButtonPressMask, FALSE, popup_handler,
  1042.                       WindowPopupMenu);
  1043.  
  1044.    ac = 0;
  1045.    xms = (XmString) XmStringCreateLocalized ( "Button3 = popup; Button2 = DnD.");
  1046.    XtSetArg(al[ac], XmNlabelString, xms); ac++;
  1047.    XtSetArg(al[ac], XmNshadowThickness, 2); ac++;
  1048.    label = XmCreateLabel (shell1, "label", al, ac);
  1049.    XtManageChild ( label );
  1050.  
  1051.    XtRealizeWidget( shell1 );
  1052.  
  1053.    /* NOTE use of XtPopup rather than XtRealizeWidget for topLevels */
  1054.  
  1055. #ifdef MULTIPLE_APP_SHELLS
  1056.    XtRealizeWidget( shell2 );
  1057.    XtRealizeWidget( shell3 );
  1058.    XtRealizeWidget( shell4 );
  1059. #else
  1060. #ifdef POPUP_SHELL
  1061.    XtPopup ( shell2, XtGrabNone );
  1062.    XtPopup ( shell3, XtGrabNone );
  1063.    XtPopup ( shell4, XtGrabNone );
  1064. #else
  1065.    XtRealizeWidget( shell2 );
  1066.    XtRealizeWidget( shell3 );
  1067.    XtRealizeWidget( shell4 );
  1068. #endif
  1069. #endif
  1070.  
  1071.    XtAppMainLoop (app_context);
  1072. }
  1073.  
  1074.  
  1075. -----------------------------------------------------------------------------
  1076. END OF PART THREE
  1077.