home *** CD-ROM | disk | FTP | other *** search
/ ftp.pasteur.org/FAQ/ / ftp-pasteur-org-FAQ.zip / FAQ / motif-faq / part8 < prev    next >
Internet Message Format  |  2004-05-05  |  43KB

  1. Path: senator-bedfellow.mit.edu!dreaderd!not-for-mail
  2. Message-ID: <motif-faq/part8_1083675484@rtfm.mit.edu>
  3. Supersedes: <motif-faq/part8_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 8 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:12 GMT
  18. Lines: 1044
  19. NNTP-Posting-Host: penguin-lust.mit.edu
  20. X-Trace: 1083675552 senator-bedfellow.mit.edu 567 18.181.0.29
  21. Xref: senator-bedfellow.mit.edu comp.windows.x.motif:75191 comp.answers:57056 news.answers:270860
  22.  
  23. Archive-name: motif-faq/part8
  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: 250)  TOPIC: KEYSYMS
  32.  
  33. -----------------------------------------------------------------------------
  34. Subject: 251)  What is causing the messages "unknown keysym name osfDown..."?
  35. [Last modified: Oct 98]
  36.  
  37. Answer: There is an OSF supplied addition to the /usr/lib/X11/XKeysymDB file.
  38. It is found on the release tape and should have been automatically installed
  39. if the installation procedure was followed in the Release Notes.
  40.  
  41. You have to copy (or append) lib/Xm/XKeysymDB into /usr/lib/X11.  This may
  42. require root permission.  It is not clear how to fix the problem if you can't
  43. do this.  The error comes from Xt translation table parsing and can't be fixed
  44. in Motif, so if you can't get root permission you may be stuck.  The file is
  45. not copyrighted so you can install it on other systems.
  46.  
  47. If X has been built so that XKeysymDB is not in this directory, and you don't
  48. know where it is looking, run 'strings libX11.a | grep XKeysymDB' to find the
  49. path.
  50.  
  51. On a Sun running openwin with shared libraries, you may need to put the path
  52. for the library containing XKeysymDB *first* in the path list in
  53. LD_LIBRARY_PATH, or it may find the wrong XKeysymDB in the wrong directory.
  54.  
  55. XKeysymDB simply contains the registered keysym values for the OSF keysyms.
  56. The OSF values are server-independent.  And, all registered keysyms will be
  57. included in an XKeysymDB file to be shipped with X11R5.
  58.  
  59. In the meantime (till all systems are X11R5+), a list of the registered
  60. keysyms can be found in the X11R4 release in mit/doc/Registry/Xregistry.
  61.  
  62. Also note the XKEYSYMDB environment variable. Setting this to point to the
  63. XKeysymDB file often helps, but not always...
  64.  
  65. Some people have also reported getting this error if their Motif libraries
  66. were built with libc headers that are not compatible with those installed on
  67. their system.  For example, Linux has two incompatible libraries libc5 and
  68. glibc.  You may get keysym (and other) errors if your Motif was built with
  69. libc5 but you run your Motif application with glibc.  Contact your Motif
  70. vendor for information on the required libc.
  71.  
  72. Ken Lee
  73.  
  74. -----------------------------------------------------------------------------
  75. Subject: 252)  What happens if I can't install Motif Keysyms?
  76.  
  77. tessi!george@nosun.West.Sun.COM (George Mitchell) wrote:
  78.  
  79. Here's what appears to happen if you don't have XKeysymDB in place to define
  80. OSF's virtual keysyms:
  81.  
  82. 1. At class initialize time, for a widget (such as XmText) that uses virtual
  83. keysyms in its event translation table, all entries which refer to those
  84. keysyms fail to parse correctly.  In the case of XmText, instead of ending up
  85. with a translation table with roughly 90 entries, you end up with one that has
  86. 29.
  87.  
  88. 2. XKeysymDB doesn't exist, so you'd assume that KeyPress events will get
  89. translated to plain vanilla keysyms, right?  WRONG!  All Motif widgets install
  90. a virtual keysym translator ANYWAY!  Consequently, the backspace key (for
  91. example) gets translated to the keysym osfBackSpace.
  92.  
  93. 3. Therefore, if you augment or override your widget's translations with
  94. translations that refer to plain vanilla BackSpace, they will never be
  95. triggered, because you will NEVER see plain vanilla BackSpace, only
  96. osfBackSpace.
  97.  
  98. 4. But you can't use osfBackSpace in an event translation entry, because you
  99. don't have XKeysymDB installed!
  100.  
  101. Here's how I'm "dealing" with the problem right now: Motif installs its
  102. virtual keysym translator by calling XtSetKeyTranslator every time a
  103. VendorShell (or subclass) widget is created.  So every time I create a shell,
  104. I immediately call XtSetKeyTranslator (display, XtTranslateKey) to restore the
  105. default translator.  No more funny virtual keysyms!  Now I can reinstall non-
  106. osfKeySym translations and have them work the way I expect.
  107.  
  108. -----------------------------------------------------------------------------
  109. Subject: 253)  Why has OSF introduced Keysyms into Motif 1.1?  They weren't
  110. there in Motif 1.0.
  111.  
  112. Answer: ellis@osf.org wrote:
  113.  
  114. Virtual Keysyms are meant to provide a consistent keyboard model for Motif
  115. applications running in a heterogeneous environment in which proprietary (i.e.
  116. vendor specific) non-Motif applications may also be running.
  117.  
  118. First of all, for the sake of the rest of the readers, let's explain why this
  119. is an issue:
  120.  
  121. It would be lovely if Motif's translation tables could just use the obvious
  122. keysyms predefined by X.  For example, there are keysyms for XK_BackSpace,
  123. XK_Delete, XK_Left, XK_Right, etc.  Shouldn't these be the ones that are used
  124. in our translations?  Unfortunately, the problem is not so simple.  Some
  125. specific examples:
  126.  
  127. While most vendors bind XK_BackSpace to the key at the top right
  128. of the standard keyboard (often engraved with a leftwards
  129. pointing arrow), not all do.  In fact, some vendors (including DEC)
  130. bind that key to XK_Delete.
  131.  
  132. While most vendors bind the arrow keys to XK_Up, etc, a number of
  133. vendors (including Sun, on some servers) bind them to function key
  134. keysyms.
  135.  
  136. A simplistic solution would require the use of xmodmap to change the offending
  137. bindings.  That would work swell in an all Motif environment.  However, OSF's
  138. goal (not always perfectly achieved) is interoperability.  That is, we'd like
  139. to make sure that both Motif and non-Motif programs can happily run in the
  140. same environment.
  141.  
  142. It is expected that a vendor may have a wide variety of existing X-based
  143. software that uses the keysyms as established by that vendor for specific
  144. purposes.  It is expected that these applications may run at the same time as
  145. Motif-based software.  Using xmodmap to change keysyms on the server side
  146. could "break" the existing applications (or at the very least their
  147. documentation) by making some keys unavailable, or by moving the location.
  148.  
  149. So, we chose not to use xmodmap.  By the way, though OpenLook uses a different
  150. implementation (they recompile their virtual translation tables into actual
  151. translation tables), they basically adopted the same approach, presumably for
  152. similar reasons.
  153.  
  154. To work properly, the virtual keysym model we implemented depends on Xlib
  155. finding XKeysymDB installed appropriately (which standard Motif installation
  156. does).  This simply defines the keysyms (not the key they are bound to).  This
  157. unfortunate piece of stupidity is necessary because MIT only includes standard
  158. keysyms in keysymdef.h.  It should be said that our lives would be made easier
  159. if MIT would also see fit to include registered keysyms in keysymdef.h as
  160. well.
  161.  
  162. Motif applications determine how to bind virtual to actual keys by looking for
  163. either a resource or a property on the root window which describes what to do.
  164. Note that this information is on the server side, so that all applications use
  165. the same virtual bindings regardless of where they are running.  Mwm will
  166. happily create the property if it finds a .motifbind file in your home
  167. directory when it starts up.  (Actually, things generally work even if none of
  168. this is done, since if all else fails, the Motif toolkit chooses a virtual
  169. bindings table to use based on the identification of the server).
  170.  
  171. The actual implementation of virtual keys is made possible by a hook in the
  172. Intrinsics.  Undoubtably, the implementation would be simpler and cleaner if
  173. virtual key support was more directly supported by the Intrinsics.  We will be
  174. exploring this possibility in the future.
  175.  
  176. -- Ellis
  177.  
  178. -----------------------------------------------------------------------------
  179. Subject: 254)  Why do accented characters not work with Motif applications
  180. linked with X11R6? What is the Compose file?
  181. [Last modified: June 95]
  182.  
  183. Answer: Note: The list of codes below _should_ contain a backslash before
  184. every numeric value. My FAQ maintainence tools have been stripping the
  185. backslash.  Sorry for the confusion...ksall@cen.com.
  186.  
  187. Roman Czyborra (czyborra@cs.tu-berlin.de) writes:
  188.  
  189. I've xmodmapped a few accented characters onto my keyboard. They've worked
  190. fine in most every window, but were dead in the Motif applications linked with
  191. X11R6.  My LC_CTYPE has always been set to iso_8859_1, so that was not the
  192. problem.  It turns out that I can activate the keys by patching
  193. $XLOCALEDIR/iso8859-1/Compose to also include the lines listed below.
  194.  
  195. <nobreakspace>          : "240"
  196. <exclamdown>            : "241"
  197. <cent>                  : "242"
  198. <sterling>              : "243"
  199. <currency>              : "244"
  200. <yen>                   : "245"
  201. <brokenbar>             : "246"
  202. <section>               : "247"
  203. <diaeresis>             : "250"
  204. <copyright>             : "251"
  205. <ordfeminine>           : "252"
  206. <guillemotleft>         : "253"
  207. <notsign>               : "255"
  208. <hyphen>                : "255"
  209. <registered>            : "256"
  210. <macron>                : "257"
  211. <degree>                : "260"
  212. <plusminus>             : "261"
  213. <twosuperior>           : "262"
  214. <threesuperior>         : "263"
  215. <acute>                 : "264
  216. <mu>                    : "265"
  217. <paragraph>             : "266"
  218. <periodcentered>        : "267"
  219. <cedilla>               : "240"
  220. <onesuperior>           : "271"
  221. <masculine>             : "272"
  222. <guillemotright>        : "273"
  223. <onequarter>            : "274"
  224. <onehalf>               : "275"
  225. <threequarters>         : "276"
  226. <questiondown>          : "277"
  227. <Agrave>                : "300"
  228. <Aacute>                : "301"
  229. <Acircumflex>           : "302"
  230. <Atilde>                : "303"
  231. <Adiaeresis>            : "304"
  232. <Aring>                 : "305"
  233. <AE>                    : "306"
  234. <Ccedilla>              : "307"
  235. <Egrave>                : "310"
  236. <Eacute>                : "311"
  237. <Ecircumflex>           : "312"
  238. <Ediaeresis>            : "313"
  239. <Igrave>                : "314"
  240. <Iacute>                : "315"
  241. <Icircumflex>           : "316"
  242. <Idiaeresis>            : "317"
  243. <ETH>                   : "320"
  244. <Ntilde>                : "321"
  245. <Ograve>                : "322"
  246. <Oacute>                : "323"
  247. <Ocircumflex>           : "324"
  248. <Otilde>                : "325"
  249. <Odiaeresis>            : "326"
  250. <multiply>              : "327"
  251. <Ooblique>              : "330"
  252. <Ugrave>                : "331"
  253. <Uacute>                : "332"
  254. <Ucircumflex>           : "333"
  255. <Udiaeresis>            : "334"
  256. <Yacute>                : "335"
  257. <THORN>                 : "336"
  258. <ssharp>                : "337"
  259. <agrave>                : "340"
  260. <aacute>                : "341"
  261. <acircumflex>           : "342"
  262. <atilde>                : "343"
  263. <adiaeresis>            : "344"
  264. <aring>                 : "345"
  265. <ae>                    : "346"
  266. <ccedilla>              : "347"
  267. <egrave>                : "350"
  268. <eacute>                : "351"
  269. <ecircumflex>           : "352"
  270. <ediaeresis>            : "353"
  271. <igrave>                : "354"
  272. <iacute>                : "355"
  273. <icircumflex>           : "356"
  274. <idiaeresis>            : "357"
  275. <eth>                   : "360"
  276. <ntilde>                : "361"
  277. <ograve>                : "362"
  278. <oacute>                : "363"
  279. <ocircumflex>           : "364"
  280. <otilde>                : "365"
  281. <odiaeresis>            : "366"
  282. <division>              : "367"
  283. <oslash>                : "370"
  284. <ugrave>                : "371"
  285. <uacute>                : "372"
  286. <ucircumflex>           : "373"
  287. <udiaeresis>            : "374"
  288. <yacute>                : "375"
  289. <thorn>                 : "376"
  290. <ydiaeresis>            : "377"
  291.  
  292.  
  293. -----------------------------------------------------------------------------
  294. Subject: 255)  TOPIC: UIL
  295.  
  296. [NOTE: As you can see, this is a new topic area. Send me your ideas for
  297. answered questions pertaining to this topic.]
  298.  
  299. -----------------------------------------------------------------------------
  300. Subject: 256)  What is UIL and why is it so popular?
  301. [Last modified: Sept 94]
  302.  
  303. Answer: UIL is the acronym for "User Interface Language", a Motif standard
  304. which permits separation of the user interface from application code.  UIL is
  305. a textual description of the user interface which is compiled into binary form
  306. called UID ("User Interface Definition") using the Motif-provided compiler
  307. called "uil".
  308.  
  309. It is important to realize that UIL is a static description of the UI in that
  310. connections between buttons and the dialogs they invoke, for example, is not
  311. expressed here; dynamic UI behavior appears in C code.
  312.  
  313. The Period Table of Widgets, called "periodic" (delivered by many Motif
  314. vendors) is an example of a UIL application.
  315.  
  316. There are many advantages and disadvantages of UIL applications.  A few of the
  317. advantages are:
  318.  
  319. UIL is a standard format which encourages separation of the user interface
  320. from application code.
  321.  
  322. UIL can be read and/or written by many of the GUI builders and UIMS tools
  323. mentioned elsewhere in this FAQ, making your interface portable (to a degree)
  324. across builder tools.
  325.  
  326. UIL is a much better language than C for defining a widget hierarchy: in C,
  327. the widget hierarchy is expressed "linearly" by referencing a previously-
  328. created parent widget when creating a child widget; in UIL, widget trees are
  329. defined more naturally using nesting.
  330.  
  331. With UIL, you separate the definition of the widget tree from the application.
  332. You can make major changes to the look-and-feel without re-building the
  333. application.
  334.  
  335.  
  336. It is possible to write a "general-purpose" application that defines a library
  337. of callbacks.  The application may "execute" any UIL file that references
  338. callbacks from the library.
  339.  
  340.  
  341. For a good UIL reference, see "Motif Programming Manual", Volume 6A, published
  342. by O'Reilly and Associates. [See "BOOKS" for details.]
  343.  
  344. -----------------------------------------------------------------------------
  345. Subject: 257)  What is Mrm?
  346. [Last modified: Nov 94]
  347.  
  348. Answer: Mrm is the "Motif Resource Manager", a set of functions (whose names
  349. begin with Mrm, such as MrmFetchWidget and MrmRegisterNames) in libMrm.a which
  350. retrieve the widget hierarchy from the UID file, associate callbacks, and
  351. create the widgets.
  352.  
  353. Mrm is usually discussed in books which cover UIL.
  354.  
  355. Motif Programming Manual, Volume 6A
  356. OSF/Motif Programmers Guide
  357. OSF/Motif Programmers Reference Manual
  358.  
  359. See the BOOKS section for detailed references.
  360.  
  361. -----------------------------------------------------------------------------
  362. Subject: 258)  How do I specify a search path for ".uid" files?  Answer: Use
  363. the UIDPATH environment variable.  It is documented on the MrmOpenHierarchy()
  364. man page.
  365.  
  366. -----------------------------------------------------------------------------
  367. Subject: 259)  Can I specify callback functions in resource files?
  368.  
  369. Answer: To specify callbacks, you must use UIL in addition to or in place of
  370. resource files.  You can, however, specify translations in resource files,
  371. which give you most of the same functionality as callback functions.
  372.  
  373. Ken Lee, http://www.rahul.net/kenton/
  374.  
  375. -----------------------------------------------------------------------------
  376. Subject: 260)  How can I set a multi-line label in UIL?
  377. [Last modified: Sept 94]
  378.  
  379. Answer: In UIL, you have to explicitly create a compound string with a
  380. separator.  Here's what W. Scott Meeks suggests:
  381.  
  382. value nl : compound_string('', seperate=true);
  383.  
  384. object my_label : XmLabel
  385. {
  386. arguments
  387. {
  388. XmNlabelString = 'Here' & nl & 'is' & nl & 'the' & nl & 'Label';
  389. };
  390. };
  391.  
  392.  
  393. -----------------------------------------------------------------------------
  394. Subject: 261)  Is there a program that can convert a UIL file to tclMotif?  I
  395. have an old Motif program that I used on SCO unix. Now that I switched to
  396. Linux, I would like to "reprogram" it without the Motif libraries under Linux.
  397. [Last modified: Aug 95]
  398.  
  399. Answer: Jan Newmarch (jan@ise.canberra.edu.au) writes:
  400.  
  401. The latest version of tclMotif (v 1.3) will allow you to load uil files
  402. (actually, the uid files output from the uil compiler) directly into tclMotif.
  403. So you don't need to convert at all.
  404.  
  405. The source is available at ftp.x.org. This, plus a Linux binary are also at
  406. ftp://ftp.canberra.edu.au/pub/motif/tclMotif (Thanks to Ben Elliston
  407. (ben@ise.canberra.edu.au) for correcting this URL.)
  408.  
  409. -----------------------------------------------------------------------------
  410. Subject: 262)  Why does my SCO UIL application fail to open 60 UID files?
  411. [Last modified: Sept 95]
  412.  
  413. Answer: Make sure that you call MrmCloseHierarchy. There is no need to keep
  414. the file open after you fetch the widgets from it.
  415.  
  416. Thanks to Tom Schutter (tom@platte.com)
  417.  
  418. -----------------------------------------------------------------------------
  419. Subject: 263)  TOPIC: ICONIFICATION and DE-ICONIFICATION
  420.  
  421. Iconification/de-iconification is a co-operative process between a client and
  422. a window manager.  The relevant standards are set by ICCCM.  Mwm is ICCCM
  423. compliant.  The toplevel (non-override-redirect) windows of an application may
  424. be in three states: WithdrawnState (neither the window nor icon visible),
  425. NormalState (the window visible) or IconicState (the icon window or pixmap
  426. visible).  This information is contained in the WM_STATE property but ordinary
  427. clients are not supposed to look at that (its values have not yet been
  428. standardised).  Movement between the three states is standardised by ICCCM.
  429.  
  430. -----------------------------------------------------------------------------
  431. Subject: 264)  How can I keep track of changes to iconic/normal window state?
  432.  
  433. Answer: You can look at the WM_STATE property, but this breaks ICCCM
  434. guidelines.  ICCCM compliant window managers will map windows in changing them
  435. to normal state and unmap them in changing them to iconic state. Look for
  436. StructureNotify events and check the event type:
  437.  
  438. XtAddEventHandler (toplevel_widget,
  439.                 StructureNotifyMask,
  440.                 False,
  441.                 StateWatcher,
  442.                 (Opaque) NULL);
  443. void StateWatcher (w, unused, event)
  444. Widget w;
  445. caddr_t unused;
  446. XEvent *event;
  447. {
  448.         if (event->type == MapNotify)
  449.                 printf ("normal\n");
  450.         else if (event->type == UnmapNotify)
  451.                 printf ("iconified\n");
  452.         else    printf ("other event\n");
  453. }
  454.  
  455.  
  456. If you insist on looking at WM_STATE, here is some code (from Ken Sall) to do
  457. it:
  458.  
  459. /*
  460. ------------------------------------------------------------------
  461. Try a function such as CheckWinMgrState below which returns one of
  462. IconicState | NormalState | WithdrawnState | NULL :
  463. ------------------------------------------------------------------
  464. */
  465. #define WM_STATE_ELEMENTS 1
  466.  
  467. unsigned long *CheckWinMgrState (dpy, window)
  468. Display *dpy;
  469. Window window;
  470. {
  471.   unsigned long *property = NULL;
  472.   unsigned long nitems;
  473.   unsigned long leftover;
  474.   Atom xa_WM_STATE, actual_type;
  475.   int actual_format;
  476.   int status;
  477.  
  478.     xa_WM_STATE = XInternAtom (dpy, "WM_STATE", False);
  479.  
  480.     status = XGetWindowProperty (dpy, window,
  481.                   xa_WM_STATE, 0L, WM_STATE_ELEMENTS,
  482.                   False, xa_WM_STATE, &actual_type, &actual_format,
  483.                   &nitems, &leftover, (unsigned char **)&property);
  484.  
  485.     if ( ! ((status == Success) &&
  486.                 (actual_type == xa_WM_STATE) &&
  487.                 (nitems == WM_STATE_ELEMENTS)))
  488.         {
  489.         if (property)
  490.             {
  491.             XFree ((char *)property);
  492.             property = NULL;
  493.             }
  494.         }
  495.     return (property);
  496. } /* end CheckWinMgrState */
  497.  
  498.  
  499. One problem with testing WM_STATE is that a race condition is possible;
  500. immediately after testing it, it could change, and the logic proceeds to
  501. behave as if it were in the old state.
  502.  
  503. -----------------------------------------------------------------------------
  504. Subject: 265)  How can I check if my application has come up iconic?  I want
  505. to delay initialization code and other processing.
  506.  
  507. Answer: Use XtGetValues and check for the XmNinitialState value of the
  508. toplevel shell just before XtMainLoop. -- IconicState is iconic, NormalState
  509. is not iconic.
  510.  
  511.  
  512. -----------------------------------------------------------------------------
  513. Subject: 266)  How can I start my application in iconic state?
  514.  
  515. Answer: Try this from the command line:
  516.  
  517. application -iconic
  518.  
  519. Using the resource mechanism, set the resource XmNinitialState to IconicState
  520. of the toplevel shell widget (the one returned from XtInitialise).
  521.  
  522. -----------------------------------------------------------------------------
  523. Subject: 267)  How can an application iconify itself?
  524.  
  525. Answer: In R4 and later, use the call XIconifyWindow.  Ken Lee adds "Set
  526. XmNiconic on your shell.  This should work in X11R6 and later patch levels of
  527. X11R5."
  528.  
  529. For R3, send an event to the root window with a type of WM_CHANGE_STATE and
  530. data IconicState.
  531.  
  532. void
  533. IconifyMe (dpy, win)
  534. Display *dpy;
  535. Window win;     /* toplevel window to iconify */
  536. {
  537.     Atom xa_WM_CHANGE_STATE;
  538.     XClientMessageEvent ev;
  539.  
  540.     xa_WM_CHANGE_STATE = XInternAtom (dpy,
  541.                             "WM_CHANGE_STATE", False);
  542.  
  543.     ev.type = ClientMessage;
  544.     ev.display = dpy;
  545.     ev.message_type = xa_WM_CHANGE_STATE;
  546.     ev.format = 32;
  547.     ev.data.l[0] = IconicState;
  548.     ev.window = win;
  549.  
  550.     XSendEvent (dpy,
  551.             RootWindow (dpy, DefaultScreen(dpy)),
  552.             True,
  553.             (SubstructureRedirectMask | SubstructureNotifyMask),
  554.             &ev);
  555.     XFlush (dpy);
  556. }
  557.  
  558.  
  559. -----------------------------------------------------------------------------
  560. Subject: 268)  How can an application de-iconify itself?
  561. [Last modified: Aug 98]
  562.  
  563. Answer: Carolyn Allen writes:
  564.  
  565. if(XtIsRealized(shell_widget))
  566. {
  567.     Display *dpy = XtDisplay(shell_widget);
  568.     Window win = XtWindow(shell_widget);
  569.     Window client = XmuClientWindow(dpy,win);
  570.     XMapRaised(dpy,client);
  571. }
  572.  
  573.  
  574. If all you want to do is pop the icon to the top, use XRaiseWindow(dpy,client)
  575. instead.
  576.  
  577. -----------------------------------------------------------------------------
  578. Subject: 269)  Why doesn't MWM display an iconify button on my dialog windows?
  579. [Last modified: May 95]
  580.  
  581. Answer: MWM (and some other window managers) does not allow transient windows
  582. to be iconified.  Transients are automatically unmapped when the main shell is
  583. iconified and they are re-mapped when the main shell is restored.  If you do
  584. not want this transient behavior, you should use top a TopLevelShell widget
  585. instead of a XmDialogShell widget for your windows.
  586.  
  587. Ken Lee
  588.  
  589. -----------------------------------------------------------------------------
  590. Subject: 270)  TOPIC: SPECIALIZED WIDGETS
  591. [Last modified: Jan 95]
  592.  
  593. This section describes a few specialized widgets people have asked about.  A
  594. _far_ more comprehensive illustrated list is maintained by Richard Offer
  595. (offer@sgi.com).  His list covers these widget categories:
  596.  
  597. Complete Listing
  598. Composite Widgets
  599. Non-Composite Widgets
  600. Motif 1.1 Compatible
  601. Motif 1.2 Compatible
  602. Athena Compatible
  603. FWF Widget Set
  604. By Author
  605. Shareware Widgets
  606. Commercial Widgets
  607.  
  608. For Richard Offer's Widget FAQ Home Page, WWW users should see:
  609.  
  610. http://reality.sgi.com/widgetFAQ/
  611.  
  612.  
  613. The Widget FAQ is also available in ASCII as:
  614.  
  615. ftp://ftp.x.org/contrib/faqs/Widget.FAQ.Z
  616.  
  617.  
  618. If you don't have access to the World Wide Web, the Widget FAQ (sans pictures)
  619. can be obtained from ftp.x.org:
  620.  
  621. /contrib/faqs/Widget.FAQ.Z
  622.  
  623.  
  624. -----------------------------------------------------------------------------
  625. Subject: 271)  Where can I get ComboBox, SpinBox, or Tree graph widgets?
  626. [Last modified: Apr 98]
  627.  
  628. Motif 2.0 and later include an XmContainer widget which displays hierarchal
  629. trees. Motif 2.0 also includes XmComboBox and XmSpinBox, which many users
  630. requested.
  631.  
  632. For Motif 1.x versions of these widgets and listings of other types of
  633. widgets, see the widgets FAQ mentioned in the previous subject.
  634.  
  635. -----------------------------------------------------------------------------
  636. Subject: 272)  How can I create a transparent widget?
  637. [Last modified: Dec 98]
  638.  
  639. Answer: The simplest way is probably to use the SHAPE protocol extension.  The
  640. xeyes, xlogo, and oclock demo programs in X11R5 (and later) are good examples
  641. of using SHAPE with widgets. You should be able to use the same techniques
  642. with your Motif widget subclasses.
  643.  
  644. Ken Lee
  645.  
  646. Ken Sall (ksall@cen.com) adds: The official name for this extension is "X11
  647. Nonrectangular Window Shape Extension". If you have X11R5 source, the Shape
  648. extension document is $TOP/mit/hardcopy/extensions/shape.PS or
  649. $TOP/mit/doc/extensions/shape.ms. In X11R6, see
  650. $TOP/xc/doc/hardcopy/Xext/shape.PS or $TOP/xc/doc/specs/Xext/shape.ms.  There
  651. is also a terse man page: $TOP/mit/man/Xext/XShape.man (X11R5) and
  652. $TOP/xc/doc/man/Xext/XShape.man (X11R6).
  653.  
  654. Ken Lee adds:  Some graphics-oriented systems (e.g., SGI, HP) include hardware
  655. overlay planes that support transparency directly.  The APIs for accessing
  656. these capabilities from Motif programs are non-standard.  Read your system's
  657. documentation or contact your vendor for more details.
  658.  
  659. -----------------------------------------------------------------------------
  660. Subject: 273)  TOPIC: CREATING WIDGETS
  661.  
  662. [This section is for widget writers.]
  663.  
  664. -----------------------------------------------------------------------------
  665. Subject: 274)  What are some good references for creating widgets (subclassing
  666. widgets)?
  667. [Last modified: May 99]
  668.  
  669. Answer: Ken Sall (ksall@cen.com) writes:
  670.  
  671. If you have Motif 2.0 or later, see the new document provided by OSF called
  672. "OSF/Motif Widget Writer's Guide" in the directory:
  673. doc/widgetGuide/Output/draft/ps.
  674.  
  675. If you have Motif 1.*, try these references (details in the BOOKS topic):
  676.  
  677. Paul Asente, Donna Converse, and Ralph Swick, X Window System Toolkit,
  678. Second Edition, 1998.
  679.  
  680. Nye, Adrian & O'Reilly, Tim,
  681. X Toolkit Intrinsics Programming Manual.Motif Edition, Volume 4M
  682.  
  683. Flanagan, David, Editor,
  684. X Toolkit Intrinsics Reference Manual, Volume 5
  685.  
  686.  
  687. joe shelby (jshelby@autometric.com) writes:
  688.  
  689. Alastair Gourlay, a former member of the Motif Development group at OSF, has
  690. written 2 articles for _The X Resource_, published by O'Reilly and Associates.
  691.  
  692. The first, "Writing Motif Widgets : A Pragmatic Approach" can be found in
  693. Issue 6.  It covers writing a XmPrimitive-derived widget, deriving from that
  694. widget, and writing a XmManager-derived widget.  Also included are brief
  695. summaries of several _Xm private functions for widget writers, how to use the
  696. Motif 1.2 Representation Type functions, and adding the widgets to Mrm/Uil.
  697.  
  698. The second, "The One-Minute Manager : Custom Motif Layout Widgets Made Easy"
  699. can be found in Issue 10.  It expands and greatly simplifies creating
  700. composite widgets for Motif.  Gourlay has created and released a new widget,
  701. the XmpGeometry widget that handles all of the geometry management issues for
  702. you and provides convenience functions for determiningparent and child
  703. widgets' perfered sizes.  All the programmer has to do to derive from this
  704. widget is create the new resources and constraints and implement 2 new class
  705. methods to override the XmpGeometry's methods.  Included with the XmpGeometry
  706. class are 3 example derived widgets.
  707.  
  708. Donald L. McMinds and Joseph P. Whitty have written a book, _Writing Your Own
  709. OSF/Motif Widgets_, published by Prentice Hall for Hewlett-Packard
  710. Professional Books.  Both authors work at HP's Workstation Systems Division,
  711. and have been involved with Motif developement since its beginnings.  The book
  712. (which is mostly code with explanations) gives details on writing
  713. XmPrimitive-derived, XmManager-derived, and XmGadget-derived widgets, with one
  714. example widget for each.  In addition, the book provides "man-pages" for
  715. several _Xm private functions for programmer convenience.
  716.  
  717. -----------------------------------------------------------------------------
  718. Subject: 275)  How can I achieve binary compatibility using the
  719. XmResolvePartOffset API?
  720. [Last modified: July 96]
  721.  
  722. Answer: Daniel Dardailler (daniel@x.org) recently provided the following URL:
  723.  
  724. http://www.x.org/people/daniel/xmresolve
  725. Achieving Binary Compatibility using the XmResolvePartOffset API
  726.  
  727. which addresses the problem caused by the fact that many widget writers "never
  728. used the XmResolvePartOffsets API in their subclass code, therefore ensuring
  729. it will break when dynamically relinked with newer version of libXm".
  730.  
  731. Unfortunately, this URL is no longer valid.  Does anyone know of a new
  732. location?  Thanks.
  733.  
  734. -----------------------------------------------------------------------------
  735. Subject: 276)  TOPIC: MISCELLANEOUS
  736.  
  737. -----------------------------------------------------------------------------
  738. Subject: 277)  How can an application be informed of signals?
  739. [Last modified: Jun 98]
  740.  
  741. Answer: The answer differs depending on whether you're using X11R5 or X11R6.
  742. For those using X11R6, Ken Lee (http://www.rahul.net/kenton/) writes: In
  743. X11R6, the Xt library has the new XtAppAddSignal() function. Ken Lee's
  744. December, 1995 *The X Advisor* column has an example:
  745.  
  746. http://www.rahul.net/kenton/txa/dec95.html
  747.  
  748. For those using X11R5, these older responses apply:
  749.  
  750. blackman@hodgkin.med.upenn.edu (David Blackman) writes:
  751.  
  752. According to comp.windows.x FAQ, you shouldn't make Xt/Xlib calls from a Unix
  753. signal handler:
  754.  
  755. "You can work around the problem by setting a flag in the interrupt handler
  756. and later checking it with a work procedure or a timer event which has
  757. previously been added."
  758.  
  759. Kaleb KEITHLEY (fedora.x.org!kaleb) adds:
  760.  
  761. Xt is not reentrant and it is not safe to call any Xt functions from a signal
  762. handler...  I think [the signaling] technique is covered in the [X] FAQ. On
  763. most POSIX-type systems write(2) is guaranteed to be reentrant and atomic. If
  764. you establish a simple pipe with the pipe(2) system call, and add it as an
  765. XtInput with XtAppAddInput(), then you can write to the pipe in the signal
  766. handler. Xt will notice that input is available and call the input-handler
  767. proc. This technique is inherently better than setting the flag because the
  768. write to the pipe will result in XtAppNextEvent returning immediately without
  769. the latency you observe in using the flag technique.  In R6 you can use the
  770. XtAppAddSignal function.
  771.  
  772. Ken Sall (ksall@cen.com) adds: See the "Signal Handling" chapter of "Motif
  773. Programming Manual" by Heller and Ferguson, listed in the BOOKS topic.
  774.  
  775. Paul Davey (pd@uit.co.uk) adds: The write and XtAppAddInput input method is
  776. often the best - but be warned it does not work on some SVR3 based Unixes,
  777. where a pipe may not be selected on. SCO Unix exhibits this behaviour so here
  778. the external flag method should be used.
  779.  
  780. -----------------------------------------------------------------------------
  781. Subject: 278)  How do I control the repeat rate on a SUN keyboard?
  782.  
  783. Answer:
  784.  
  785. [...]
  786.  
  787. -ar1 milliseconds
  788.      This option specifies amount of time in milliseconds
  789.      before   which   a   pressed  key  should  begin  to
  790.      autorepeat.
  791.  
  792. -ar2 milliseconds
  793.      This option specifies the interval  in  milliseconds
  794.      between autorepeats of pressed keys.
  795.  
  796. Of course this presumes you're using a server based on the MIT sample server.
  797.  
  798. Thanks to kaleb@x.org (Kaleb Keithley)
  799.  
  800. -----------------------------------------------------------------------------
  801. Subject: 279)  How can I identify the children of a manager widget?
  802.  
  803. Answer: Use XtGetValues() on XmNchildren (array of widget IDs) and
  804. XmNnumChildren (number of widgets in array).
  805.  
  806. -----------------------------------------------------------------------------
  807. Subject: 280)  What functions can an application use to change the size or
  808. position of a widget?
  809.  
  810. Answer: Applications should set the values of the XmNx, XmNy, XmNwidth, and
  811. XmNheight resources.
  812.  
  813. Note that many manager widgets ignore the XmNx and XmNy resources of their
  814. children, relying instead on their internal layout algorithms.  If you really
  815. want specific positions, you must use a manager widget that allows them, e.g.,
  816. XmBulletinBoard.
  817.  
  818. Also note that some manager widgets reject size change requests from their
  819. children when certain resources are set (e.g., XmNresizable on XmForm).
  820. Others allow the the children to resize, but clip the results (e.g.,
  821. XmNallowShellResize on shell widgets).  Make sure you have these resources set
  822. to the policy you want.
  823.  
  824. Due to bugs, some widgets (third party widgets) do not respond to changes in
  825. their width and height.  Sometimes, you can get them to respond correctly by
  826. unmanaging them, setting the resources, then managing them again.
  827.  
  828. Under no circumstances should applications use routines like
  829. XtConfigureWidget() or XtResizeWidget().  These routines are reserved for
  830. widget internals and will seriously confuse many widgets.
  831.  
  832. Ken Lee
  833.  
  834. -----------------------------------------------------------------------------
  835. Subject: 281)  Can I use XtAddTimeOut, XtAddWorkProc, and XtAddInput with
  836. XtAppMainLoop?
  837.  
  838. Answer: On many systems, the obsolete XtAdd*() functions are not compatible
  839. with the XtAppMainLoop().  Instead, you should use newer XtAppAddTimeOut(),
  840. XtAppAddWorkProc(), and XtAppAddInput() functions with XtAppMainLoop()
  841.  
  842. Ken Lee
  843.  
  844. -----------------------------------------------------------------------------
  845. Subject: 282)  Why does XtGetValues for XmNx and XmNwidth return extremely
  846. large values?
  847.  
  848. Answer: You must use the 16 bit "Dimension" and "Position" data types for your
  849. arguments.  If you use 32 bit integers, some implementations will fill the
  850. remaining 16 bits with invalid data, causing incorrect return values.  The
  851. *Motif Programmer's Manual* and the widget man pages specify the correct data
  852. type for each resource.
  853.  
  854. Ken Lee
  855.  
  856. -----------------------------------------------------------------------------
  857. Subject: 283)  Can I use XmGetPixmap() with widgets that have non-default
  858. visual types?
  859.  
  860. Answer: XmGetPixmap() assumes that you are using the default screen depth.  If
  861. you're using a different depth, use XmGetPixmapByDepth() instead.
  862.  
  863. Ken Lee
  864.  
  865. -----------------------------------------------------------------------------
  866. Subject: 284)  What is the matter with Frame in Motif 1.2?
  867. [Last modified: November 92]
  868.  
  869. Answer: This announcement has been made by OSF:
  870.  
  871. "IMPORTANT NOTICE
  872.  
  873. We have discovered two problems in the new 1.2 child alignment resources in
  874. XmFrame. Because some vendors may have committed, or are soon to commit to
  875. field releases of Motif 1.2 and 1.2.1, OSF's options for fixing them are
  876. limited. We are trying to deal with these in a way that does not cause
  877. hardship for application developers who will develop applications against
  878. various point versions of Motif. OSF's future actions for correction are
  879. summarized.
  880.  
  881. WHAT YOU SHOULD DO AND KNOW
  882.  
  883. 1. Mark the following change in your documentation.
  884.  
  885. On page 1-512 of the OSF/Motif Programmer's Reference, change the descriptions
  886. under XmNchildVerticalAlignment as follows (what follows is the CORRECT
  887. wording to match the current implementation):
  888.  
  889. XmALIGNMENT_WIDGET_TOP
  890. Causes the BOTTOM edge of the title area to align
  891. vertically with the top shadow of the Frame.
  892.  
  893. XmALIGNMENT_WIDGET_BOTTOM
  894. Causes the TOP edge of the title area to align
  895. vertically with the top shadow of the Frame.
  896.  
  897. 2. Note the following limitation on resource converters for Motif 1.2 and
  898. 1.2.1 implementations.
  899.  
  900. The rep types for XmFrame's XmNentryVerticalAlignment resource were
  901. incorrected implemented, which means that converters will not work properly.
  902. The following resource settings will not work from a resource file in 1.2 and
  903. 1.2.1:
  904.  
  905. *childVerticalAlignment: alignment_baseline_bottom
  906. *childVerticalAlignment: alignment_baseline_top
  907. *childVerticalAlignment: alignment_widget_bottom
  908. *childVerticalAlignment: alignment_widget_top
  909.  
  910. If you wish to set these values for these resources (note they are new
  911. constraint resources in XmFrame) you will have to set them directly in C or
  912. via uil.
  913.  
  914. WHAT WE WILL DO
  915.  
  916. The problem described in note #1 above will not be fixed in the OSF/Motif
  917. implementation until the next MAJOR release of Motif.  At that time we will
  918. correct the documentation and modify the code to match those new descriptions,
  919. but we will preserve the existing enumerated values and their behavior for
  920. backward compatibility for that release.
  921.  
  922. The fix for the problem described in note #2 will be shipped by OSF in Motif
  923. 1.2.2.
  924.  
  925. SUMMARY
  926.  
  927. We are sorry for any difficulty this causes Motif users.  If you have any
  928. questions or flames (I suppose I deserve it) please send them directly to me.
  929. We sincerely hope this proactive response is better for our customers than you
  930. having to figure it out yourselves!
  931.  
  932. Libby
  933.  
  934.  
  935. -----------------------------------------------------------------------------
  936. Subject: 285)  What is IMUG and how do I join it?
  937. [Last modified: July 96]
  938.  
  939. Answer: CAUTION: As of March, 1996, IMUG could not be contacted. If anyone is
  940. aware of the status of IMUG, please send mail to me (kenton@nojunk.rahul.net).
  941. Thanks to Lou Farho (farho@harris.com) for this update.
  942.  
  943. IMUG is the International Motif User Group founded by Quest Windows
  944. Corporation and co-sponsored by FedUNIX.  IMUG is a non-profit organization
  945. working to keep users informed on technical and standards issues, to
  946. strengthen user groups on a local level, to increase communication among users
  947. internationally, and to promote the use of an international conference as a
  948. forum for sharing and learning more about Motif.  You can join it by
  949.  
  950.  1.  Pay the annual membership fee of $20 USD directly to IMUG.  Contact
  951.  
  952.      IMUG
  953.      5200 Great America Parkway
  954.      Santa Clara,  CA  95054
  955.      (408) 496-1900
  956.      imug@quest.com
  957.  
  958.  2.  Register at the International Motif User Conference, and automatically
  959.      become an IMUG member.
  960.  
  961.  3.  Donate a pd widget, widget tool or widget builder to the IMUG Widget
  962.      Depository and receive a free one year IMUG membership.
  963.  
  964. -----------------------------------------------------------------------------
  965. Subject: 286)  How do I set the title of a top level window?
  966. [Last modified: September 92]
  967.  
  968. Answer: Set XmNtitle (and optionally XmNtitleEncoding) for TopLevelShells.
  969. (Note that this is of type String rather than XmString.) You can also set
  970. XmNiconName if you want its icon to show this title.  For XmDialogShells, set
  971. the XmNdialogTitle of its immediate child, assuming it's a BulletinBoard
  972. subclass.  These can also be set in resource files.
  973.  
  974. -----------------------------------------------------------------------------
  975. Subject: 287)  How can I disable the color scheme mechanism in CDE or HP VUE?
  976. [Last modified: May 97]
  977.  
  978. Answer: Put this in your app-defaults file: *useColorObj: False
  979.  
  980. Ken Lee
  981.  
  982. -----------------------------------------------------------------------------
  983. Subject: 288)  Can I use editres with Motif? Is there an editres tutorial?
  984. [Last modified: Mar 96]
  985.  
  986. Answer: Editres, part of the MIT delivery, is a powerful widget tree analysis
  987. tool and is highly recommended.  There's negligible overhead in making editres
  988. available to an application and many projects keep the editres "hook" active
  989. even for operational programs.
  990.  
  991. It isn't built in to Motif (at 1.2.*), but you can do this in your
  992. application:
  993.  
  994. #include <X11/Xmu/Editres.h>
  995. XtAddEventHandler(shell_widget, (EventMask) 0, True,
  996.               (XtEventHandler) _XEditResCheckMessages, NULL);
  997.  
  998. once for each shell widget that you want to react to the "click to select
  999. client" protocol.  Then link your client with the R5 libXmu.
  1000.  
  1001. Thanks to David Brooks, OSF, for the original answer.  Jan Sandquist
  1002. (ehsjasa@ehs.ericsson.se) supplied the current code snipet above. Joachim
  1003. Fabini (jo@vmars.tuwien.ac.at) suggested that I remove the older use of
  1004. "extern void _XEditResCheckMessages()" which resulted in core dumps on some
  1005. platforms.
  1006.  
  1007. NOTE: Ken Lee has placed his November, 1994 editres tutorial on the Web:
  1008.  
  1009. http://www.rahul.net/kenton/editres.html
  1010.  
  1011.  
  1012. -----------------------------------------------------------------------------
  1013. Subject: 289)  Where is the editres protocol documented?
  1014. [Last modified: Apr 95]
  1015.  
  1016. Answer: In /usr/include/X11/Xmu/EditresP.h.
  1017.  
  1018. Ken Lee
  1019.  
  1020. -----------------------------------------------------------------------------
  1021. Subject: 290)  Why does an augment translation appear to act as replace for
  1022. some widgets?  When I use either augment or override translations in
  1023. .Xdefaults it seems to act as replace in both Motif 1.0 and 1.1
  1024.  
  1025. Answer: By default, the translation table is NULL.  If there is nothing
  1026. specified (either in resource file, or in args), the widget's Initialize
  1027. finds: Oh, there is NULL in translations, lets use our default ones.  If,
  1028. however, the translations have become non-NULL, the default translations are
  1029. NOT used at all. Thus, using #augment, #override or a new table has identical
  1030. effect: defines the new translations. The only way you can augment/override
  1031. Motif's default translations is AFTER Initialize, using XtSetValues.  Note,
  1032. however, that Motif managers do play with translation tables as well ... so
  1033. that results are not always easy to predict.
  1034.  
  1035. OSF wrote: A number of people have complained about not being able to
  1036. augment/override translations from the .Xdefaults.  This is due to the
  1037. complexity of the menu system/keyboard traversal and the necessary
  1038. translations changes required to support the Motif Style Guide in menus.  It
  1039. cannot be fixed in a simple way. Fixing it requires re-design of the
  1040. menus/buttons and it is planned to be fixed in 1.2.
  1041.  
  1042. -----------------------------------------------------------------------------
  1043. Subject: 291)  How do you "grey" out a widget so that it cannot be activated?
  1044.  
  1045. Answer: Use XtSetSensitive(widget, False). Do not set the XmNsensitive
  1046. resource directly yourself (by XtSetValues) since the widget may need to talk
  1047. to parents first.
  1048.  
  1049. -----------------------------------------------------------------------------
  1050. Subject: 292)  Can I change the graphics drawn by insensitive widgets?  Some
  1051. become very difficult to read.
  1052. [Last modified: Aug 97]
  1053.  
  1054. Answer: There is no general mechanism for this; each widget chooses its own
  1055. insensitive graphics.  Some are customizable, however.  Label and button
  1056. widgets have a XmNlabelInsensitivePixmap resource.  Others, such as the text
  1057. widgets, have an XmNeditable resource; setting this to false is similar to
  1058. insensitive, except tha the graphics do not change.
  1059.  
  1060. Other possibilities would be to install an empty translation table to ignore
  1061. input or to create an occluding InputOnly window to block input.
  1062.  
  1063. -----------------------------------------------------------------------------
  1064. END OF PART EIGHT
  1065.