Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!ucsd!ucbvax!lta.com!xug From: xug@lta.com (X User's Group) Newsgroups: comp.windows.x.motif Subject: Frequently Asked Questions about X with Answers 2/2 [long monthly posting] Message-ID: <9011032141.AA04448@lta.UUCP> Date: 3 Nov 90 21:41:13 GMT Sender: daemon@ucbvax.BERKELEY.EDU Distribution: inet Organization: The Internet Lines: 951 This article contains the second half of a set of answers to some Frequently Asked Questions (FAQ) often seen in comp.windows.x. It is posted to help reduce volume in this newsgroup and to provide hard-to-find information of general interest. Please redistribute this article! -------------------------------------------------- Subject: 21) What terminal emulators other than xterm are available? Century Software (801-268-3088) sells a VT220 terminal emulator for X. VT102, Wyse 50 and SCO Color Console emulation is also available. Grafpoint's TGRAF-X provides emulation of the Tektronix 41xx and 42xx series. Information: 408-446-1919. [5/90] IXI's X.deskterm, a package for integrating character-based applications into an X environment, includes a number of terminal-emulation modules. Information: +44 (0223) 462131. [5/90] Pericom produces Teem-X, a set of several emulation packages for a number of Tek, DEC, Westward, and Data General terminals. The software runs on Sun 3, Sun 4, Apollo, DEC, ISC, IBM/AIX. Information: US: 609-895-0404, UK: +44 (0908) 560022. [5/90] -------------------------------------------------- Subject: 22) How can I get an X server on a Macintosh running MacOS? eXodus from White Pine Software (603-886-9050) runs on any Mac with at least 1MB of memory and runs the X server within a standard Macintosh window. eXodus II uses the math co-processor and other features of high-end Macs. [info current as of 6/89] Version 2.0 supports DECWindows colors, fonts, and cursors, and session management, and supports color and multiple screens. [5/90] Apple's MacX runs on MacPlus or newer machines with >= 2MB of memory and system software 6.0.4 or later. It is an "X11R3.5" server that includes support for an optional built-in ICCCM-compliant window manager, X11R4 fonts and colors, a built-in BDF font compiler, and built-in standard colormaps, and it supports the X11R4 notion "all visuals that make sense" for color displays. Version 1.0 started shipping at the end of May. [courtesy Alan Mimms (alan@apple.com], 3/90] "X for the rest of us." [Note: MacX is also the name of a vax-mac xmodem transfer utility.] -------------------------------------------------- Subject: 23)* Where can I obtain an X-based editor or word-processor? You can ftp the latest version of emacs, including X11 support, from prep.ai.mit.edu [18.71.0.38]. The file you probably want is ~ftp/pub/gnu/emacs-18.55.tar.Z, or similarly-named files. Epoch is a modified version of Gnu Emacs with additional facilities useful in an X environment. Epoch is available by anonymous ftp from cs.uiuc.edu (128.174.252.1), in the directory pub/epoch-files. There are two subdirectories: epoch contains the epoch source, and gwm contains the source to the programmable window manager GWM, with which epoch works well. The Andrew system on the X11R4 tape has been described as one of the best word-processing packages available. It supports word processing with multi-media embedded objects: rasters, tables/spread sheets, drawings, style editor, application builder, embedded programming language, &c. [Fred Hansen (wjh+@ANDREW.CMU.EDU)] In addition: Elan Computer Group (Mountain View, CA; 415-964-2200) has announced the Avalon Publisher, an X11/OpenLook WYSIWYG electronic publishing system. FrameMaker and FrameWriter are available as X-based binary products for several machines. Frame is at 800-843-7263 (CA: 408-433-3311). WX2 (formerly InDepthEdit) is available from Non Standard Logics (+33 (1) 43 36 77 50; requests@nsl.fr). DECwrite is available from DEC for some DEC hardware and SunWrite is available from Sun. IslandWrite will soon be available from Island Graphics (415-491-1000) for some HP & Apollo platforms. Interleaf is currently available from Interleaf (800-241-7700, MA: 617-577-9800) on all Sun and DEC platforms; others are under development. The Alis office-productivity tool from Applix (1-800-8APPLIX, MA: 508-870-0300) includes a multi-font WYSIWG document composer; for several systems. ArborText, Inc. provides an X11 version of its Electronic Publishing program called "The Publisher". The Publisher is available on Sun, HP and Apollo workstations. Contact Arbortext at 313-996-3566. [5/90] Iris Computing Laboratories (615-886-3429) makes the "ie" editor. -------------------------------------------------- Subject: 24) Just what is Open Windows? Open Windows (2.0) is a Sun product that encompasses: a window system that combines a NeWS and X11R4-compliant server (X/NeWS); a user-interface specification (Open Look) and a series of toolkits that implement it (including the SunView-like XView and the Xt-based OLIT); Xlib and Xt implementations; and a number of utilities (olwm window manager, filemgr, shelltool, etc.). [thanks to Frank Greco (fgreco@govt.shearson.COM), 8/90] -------------------------------------------------- Subject: 25) Just what is DECWindows? DECWindows is a DEC product that encompasses: an X11 server; the XUI toolkit, including the Dwt widget set and UIL; Xlib and Xt implementations; a session manager; and a number of utilities (dxwm window manager, dxcalendar, dxpsview, etc.). (At some point Motif flavors of the toolkit and applications will be shipped.) [8/90] -------------------------------------------------- Subject: 26) Where can I obtain an X-based paint/draw program? xpic is an object-oriented drawing program. It supports multiple font styles and sizes and variable line widths; there are no rotations or zooms. xpic is quite suitable as an interactive front-end to pic, though the xpic-format produced can be converted into PostScript. (The latest version is on the R4 contrib tape in clients/xpic.) xfig is an object-oriented drawing program supporting compound objects. The text-handling is limited. The xfig-format can be converted in PostScript or other formats. One version is on the R4 contrib tape in clients/xfig; it is one of the several 'xfig' programs which several groups independently developed parallel versions of from the R3 xfig. idraw 2.5 supports numerous fonts and various line styles and arbitrary rotations. It supports zoom and scroll and color draws and fills. On the R4 tape; see also interviews-request@interviews.stanford.edu. [courtesy Jim Helman (jim@kaos.Stanford.EDU) 7/89; some comments added by XUG] In addition: dxpaint is a bitmap-oriented drawing program most like MacPaint; it's good for use by artists but commonly held to be bad for drawing figures or drafting. dxpaint is part of the Ultrix 3.x release. FrameMaker has some draw capabilities. [4/90] ArborText (313-996-3566) offers PubDraw, an X11-based drawing program, on Sun, HP and Apollo workstations. -------------------------------------------------- Subject: 27) Where can I obtain an X-based spreadsheet? Vendor Product Phone ------ ------- ----- Access Technology 20/20 (508) 655-9191 Informix WingZ (800) 331-1763 Quality Software Products Q-Calc/eXclaim 800-628-3999 (CA:213-410-0303) Unipress Q-Calc (201) 985-8000 Uniplex Uniplex (214) 717-0068, (800) 356-8063 [above from Walter E. Gillett (gillett@AI.MIT.EDU)] Digital DECdecision 1-800-DIGITAL BBN Software Products BBN/Slate 617-873-3984 (Scott Richardson) (the product includes WordProcessing, Spreadsheet, Graphics, Image Processing, Foreign Language WordProcessing, Electronic Mail, and Elecronic Conferencing) AIS's (919-942-7801) XESS spreadsheet for VMS/Ultrix has either DECWindows or Motif look/feel. The Alis office-productivity tool from Applix (1-800-8APPLIX, MA: 508-870-0300) includes a spreadsheet. There is a spreadsheet program in the Andrew Toolkit on the R4 contrib tape. Applied Information Systems (Chapel Hill, North Carolina; 1 800 334 5510) will begin shipping in mid-October an X11/Motif spreadsheet called Xess. -------------------------------------------------- Subject: 28)* Where can I get a PostScript previewer for X? xps is available from almost everywhere that the X11 contributed source can be found. The version currently on expo is based on Crispin Goswell's PostScript interpreter with fixes and speedups by John Myers and Barry Shein and an X11 driver by Terry Weissman. There are known problems with fonts. The package is good for lowering the edit-print-edit cycle in experimenting with particular PostScript effects. [ralpage, also widely available, apparently shares with xps a common ancestor, and should also be considered.] Ghostscript is distributed by the Free Software Foundation (617-876-3296) and includes a PostScript interpreter and a library of graphics primitives. The README for the widely-distributed version 1.3 points out that it doesn't take advantage of many of the facilities offered by X but that this is intended to change in the future; version 2.0 is now available. [10/90] In addition: ScriptWorks is Harlequin's software package for previewing and printing PostScript(R) descriptions of text and graphics images; previewers for X are available. For information call +44-223-872522 or send email to scriptworks-request@uk.co.harlqn. Digital's dxpsview runs on UWS 2.1 and 2.2. Sun's pageview runs with the X11/NeWS server. -------------------------------------------------- Subject: 29) Where can I get a troff previewer for X? X11R4 has two previewers for device-independent troff: the supported client xditview, and the contributed-but-well-maintained xtroff. An earlier version of xtroff also appeared on the R3 contributed source. In addition: xproof, an X previewer for ditroff has been contributed by Marvin Solomon (solomon@cs.wisc.edu); version 3.5 is available on expo in contrib/xproof*. [8/90] Elan Computer Group (CA: 415-964-2200) produces eroff, a modified troff implementation, and Elan/Express, an X11 eroff previewer (misleadingly) labeled "WYSIWYG". SoftQuad (416-963-8337; USA only 800-387-2777, mail@sq.uu.net or mail@sq.com) offers SoftQuad Publishing Software, including a substantially- rewritten troff formatter, a better intermediate language with backwards compatibility, and an X11[R3,R4] previewer. (This is the package adopted by AT&T's own MIS department, and used in and re-sold by many parts of AT&T). [information from Ian Darwin, SoftQuad (ian@sq.com) 3/90] Image Network (1-800-TOXROFF; CA: 415-967-0542) has the 'xroff' package, which includes a fine modified troff implementation and a set of X11-based page previewers. (This is the package OEM'ed by several hardware vendors.) [mostly courtesy moraes@cs.toronto.edu (Mark Moraes)] [2/90] -------------------------------------------------- Subject: 30) How can I design my own font? One way is to use the "bitmap" client or some other bitmap-editor (e.g. Sun's icon-editor tool, post-processed with pbmplus) to design the individual characters and then to do some large amount of post-processing to concatenate them into the BDF format. The R3 contrib/ area (in fonts/utils/ and in clients/xtroff) contained a number of useful utilities, including some to convert between BDF font format and a simple character format which can be edited with any text editor. An easier way is to use the "xfed" client to modify an existing font; a recent version is on the R4 tape in contrib/clients/xfed; there are older versions on the R3 contrib tape. -------------------------------------------------- Subject: 31) What is PEX? The PHiGS Extension to X is a proposed X Consortium standard awaiting proof of concept; PHiGS stands for "Programmer's Hierarchical Interactive Graphics System" and is essentially a library of functions that simplifies the creation and manipulation of 3D graphics. Many platforms are capable of performing in hardware the computations involved in rendering 3D objects; the server extension would allow the client (PHIGS in this case) to take advantage of the specialized hardware for 3D graphics. Sun Microsystems is currently contracted to develop a freely redistributable (copyright similar to the current X copyright) sample implementation. The current schedule calls for this implementation to be publicly available in early 1991. Several vendors are currently selling independently-developed PEX servers for their workstations. [8/90] -------------------------------------------------- Subject: 32)* How do I convert Mac/TIFF/GIF/Sun/PICT/Face/img/FAX images to X? The likeliest program is an incarnation of Jef Poskanzer's useful++ Portable Bitmap Toolkit, which includes a number of programs for converting among various image formats. It includes support for many types of bitmaps, gray-scale images, and full-color images. The latest version, PBMPLUS, was posted to the net about 11/22/89; it is also on the R4 tape under contrib/clients/pbmplus. The package has been independently updated to support XPM images for pixmaps. There are also several patches to various modules floating around. Useful for viewing some image-formats is Jim Frost's xloadimage, a version of which is in the R4 directory contrib/clients/xloadimage. [Both PBMPLUS and xloadimage are under active development; watch for updated versions.] xtiff is a tool for viewing a TIFF file in an X window. It was written to handle as many different kinds of TIFF files as possible while remaining simple, portable and efficient. xtiff illustrates some common problems with building pixmaps and using different visual classes. It is distributed as part of Sam Leffler's libtiff package and it is also available on expo.lcs.mit.edu, uunet.uu.net and comp.sources.x. [dbs@decwrl.dec.com, 10/90] -------------------------------------------------- Subject: 33) How do I use another window manager with DEC's session manager? DEC's session manager will start dxwm up by default. To override this, add to your .Xdefaults file something like this line, naming the full pathname: sm.windowManagerName: /usr/bin/X11/your_favorite_wm -------------------------------------------------- Subject: 34) How do I build X with gcc? MIT is now using regularly the Free Software Foundation's GNU-CC to build the X distribution and uses gcc-built servers to test performance increases. [These options are gathered from several descriptions of building X with gcc 1.34, 1.35, and 1.36]: Use the options -O -fstrength-reduce -fpcc-struct-return -traditional may also be necessary if your version of gcc is sufficiently old. Do not use -finline-functions, particularly on the R4 server. ---> Make sure to run 'fixincludes' from the gcc distribution ---> before doing anything, or you will get fatal errors such as: ---> xterm: Error 15, errno 25: Inappropriate ioctl for device. HOWEVER, there is a bug in gcc 1.34 and 1.36 (but not in 1.35 or 1.37) which miscompiles things of the form (expr == 0 ? exp1 : exp2). The fix needed in X11R4 (and probably X11R3) is to change the definition of XtNewString in Intrinsic.h to: #define XtNewString(str) \ ((str) != NULL ? (strcpy(XtMalloc((unsigned)strlen(str) + 1), str)) : NULL) A work-around is also in fix-2 to X11R4. -------------------------------------------------- Subject: 35) Why doesn't gcc work with X11R4 on my SPARC? I used gcc to compile the whole distribution, but I get several segmentation faults when running X. Note first that gcc on RISC machines does not necessarily result in any performance increase; it certainly is not as noticeable as it is on the 680x0 or VAX platforms. Here is the problem: gcc and cc use incompatible methods of passing structures as arguments and returning them as function values, so when gcc-compiled parts of X are linked with Sun-supplied functions that pass or return structs, run-time errors occur. Affected programs include rgb and the server. This is from the GCC manual: On the Sparc, GNU CC uses an incompatible calling convention for structures. It passes them by including their contents in the argument list, whereas the standard compiler passes them effectively by reference. This really ought to be fixed, but such calling conventions are not yet supported in GNU CC, so it isn't straightforward to fix it. The convention for structure returning is also incompatible, and `-fpcc-struct-return' does not help. You can duck the problem either by using cc throughout or by using it for just the routines which cause incompatibilities; the problem cannot be solved with compilation flags. Files which need to be compiled using cc include: server/os/4.2bsd/oscolor.c rgb/rgb.c In addition, several of the "init_" functions use structs as args or return values: clients/xhost/xhost.c clients/xauth/gethost.c. Calls to inet_addr in /lib/CLX/socket.c and lib/X/XConnDis.c are possibly harmless as they don't involve structs. [collected by bashford@scripps.edu (Don Bashford); 8/90] -------------------------------------------------- Subject: 36) What are these problems building X with gcc? When I try to run xinit or the Xsun server I get the error "Getting interface configuration: Operation not supported on socket. Fatal server bug! no screens found." Running the gcc fixincludes script apparently didn't work. You can do this simple test: #include SIOCGIFCONF Run that through cc -E and gcc -E. The last line of output is the piece of interest; it should be identical (modulo irrelevant differences like whitespace). If the gcc version has 'x' where the cc version has 'i', your fixincludes run didn't work for some reason or other. If they are identical, try running a make clean in mit/server and rebuilding, just to make sure everything gets compiled with the proper include files. [courtesy der Mouse, mouse@LARRY.MCRCIM.MCGILL.EDU; 9/90] -------------------------------------------------- Subject: 37) What are these funny problems compiling X11R3 on the Sun4? cc -c -O -I. -I../../include -I../../.././X11 -I../mfb cfbbitblt.c cc: Fatal error in iropt: Illegal instruction (core dumped) Known problems with the Sun4 optimizer render the -O flag unusable on this file. In addition, there is a problem in all of the procedures that return a parameter that was never referenced. Instead of returning the string, the compiler with optimization seems to be returning the last value computed. You can compile lib/Xt/TMparse.c without optimization; alternatively, you can replace the "return str" in various routines to use that parameter [courtesy of Jim Fulton, MIT X Consortium]: #ifdef sparc /* * The silly optimizer in SunOS 4.0.3 and below generates bogus code that * causes the value of the most recently used variable to be returned instead * of the value passed in. */ static String silly_optimizer_kludge; #define BROKEN_OPTIMIZER_HACK(val) silly_optimizer_kludge = (val) #else #define BROKEN_OPTIMIZER_HACK(val) val #endif and have routines end with return BROKEN_OPTIMIZER_HACK(str); Note also that the SPARCstation1 has a bug in its use of -misalign; a fix to cc should be obtained from Sun. -------------------------------------------------- Subject: 38) What are these problems installing R4 on the Sun running SunOS 4? All of the executables that I try to run have the following results: ld.so: libXmu.so.4: not found or even: ld.so: call to undefined procedure __GetHostname from 0xf776a96c If you are building with shared libraries on a Sun, remember that you need to run "ldconfig" as root after installing the shared libraries (if you've installed X on a file-server, run it on the server's clients, too). While building and installing the distribution, you need to be careful to avoid linking against any existing X shared libraries you might have (e.g. those distributed with OpenWindows). You should make sure you do not have LD_LIBRARY_PATH set in your environment during the build or the installation. If you are going to keep xterm and xload as setuid programs, please note that the shared libraries must be installed in /usr/lib, /usr/local/lib, or /usr/5lib for these programs to work (or else those programs must be linked statically). [courtesy MIT X Consortium] Note also that the program mkfontdir is run as part of the build; it attempts, however, to use the shared libraries before they have been installed. You can avoid the errors by building mkfontdir statically (pass -Bstatic to most C compilers). -------------------------------------------------- Subject: 39) Why doesn't XtAppAddInput work as described? I am using XtAppAddInput to read from a file, but the function is called even when there isn't input pending. XtAppAddInput is actually working as it is supposed to. When used on files, it is called whenever the file is READY to be read, not when there is new data to be read. The file is almost always ready to be read, however, if only because you can spin back to the beginning and read data you've read before. The result is that your function will almost always be called every time around XtMainLoop(). To get the type of interaction you are expecting, add this line to the beginning of your function to test whether there is new data: if (ioctl(fd, FIONREAD, &n) == -1 || n == 0) return; [courtesy Dan Heller (argv@ora.com); 8/90] -------------------------------------------------- Subject: 40) Where can I get a fast X server for a workstation? The R4 server should be among the fastest available for most machines. The "Purdue" speedups significantly speed up the X11R3 server. Look on expo.lcs.mit.edu:contrib/Purdue.2.[01]-tar.Z. (You'll also need gcc.) International Quest Corporation (408-988-8289) has an optimized R3 server for Sun3/4/386i under SunOS 4.0 and also an optimized R4 server. Unipalm XTech (+44 954 211244) makes several R3-based and R4-based tuned servers, most notably for Sun 3 and Sun 4. (Note: the original work was inherited from Torch Technology.) Xgraph's Xtool (408-492-9031) is an X server implemented in SunView which boasts impressive results on Sun 3 and SPARC systems. [6/90] Several companies are making hardware accellerator boards: Dupont Pixel Systems (302-992-6911), for Sun. Megatek's (619-455-5590) X-cellerator board for the Sun 3 and Sun 4 is based on the TI 34020; the company claims performance improvements of 5x to 10x over the sample X11R3 server. -------------------------------------------------- Subject: 41) Where can I find X tools callable from shell scripts? I want to have a shell script pop up menus and yes/no dialog boxes if the user is running X. Several tools in the R3 contrib/ area were developed to satisfy these needs: yorn pops up a yes/no box, xmessage displays a string, etc. There are several versions of these tools; few, if any, have made it to the R4 contrib/ area, though they may still be available on various archive sites. In addition, Richard Hesketh (rlh2@ukc.ac.uk) has posted the xmenu package to comp.sources.x ("v08i008: xmenu") for 1-of-n choices. [7/90] -------------------------------------------------- Subject: 42) How do I make a screendump of the X display? The xwd client in the R3 and R4 distributions can be used to select a window or the background. It produces an XWD-format file of the image of that window. The file can be post-processed into something useful or printed with the xpr client and your local printing mechanism. You can use this command: csh% sleep 10; xwd -root > output.xwd & and then spend 10 seconds or so setting up your screen; the entire current display will be saved into the file output.xwd. Note that xwd also has an undocumented -id flag for specifying the window id on the command-line. Two publicly-available programs which allow interactive definition of arbitrary portions of the display and built-in delays are asnap and xgrabsc. Xgrabsc was both recently [8/90] posted to comp.sources.x; asnap is on expo. In addition, xwd2ps, also on expo, converts an xwd-format file to PostScript with trimmings suitable for use in presentations. Also: some vendors' implementations of X (e.g. DECWindows and OpenWindows 2.0) include session managers or other desktop programs which include "print portion of screen" or "take a snapshot" options. Also: some platforms have tools which can be used to grab the frame-buffer directly. The Sun systems, for example, have a 'screendump' program which produces a Sun raster file. PBMPLUS or other packages can be used to massage the output into a useful format. Also: some vendors' implementations of lpr (e.g. Sony) include direct support for printing xwd files. -------------------------------------------------- Subject: 43)+ Why can't I compile my R3 Xaw contrib programs under R4? I have a program that worked well under X11R3. When I try to link it under X11R4, I get this message: Undefined: _XtScrollBarSetThumb _XtTextSetInsertionPoint _XtTextReplace There were several name changes in the Athena widget set (in addition to the header files moving into ); these are mentioned in the R4 release notes. In this case, these functions are not really Xt functions but are part of the Xaw text widget and so have been renamed from Xt* to Xaw*. [10/90] -------------------------------------------------- Subject: 44)+ Is there a way for my wm to produce my .xinitrc, a la toolplaces? Although no known window manager directly supports such a feature, there is a contributed application which does much of what you are looking for, although it is not as complete as the SunView toolplaces. Look for the application "xplaces" on an archive-server near you. There are several versions of this program floating around; look for a recent vintage. [10/90] -------------------------------------------------- Subject: 45) How can I change the titlebar of my xterm window? The solution involves sending an escape sequence to xterm which will cause it to update the property which the window manager relies upon for the string which appears in the window titlebar. A solution is as easy as typing this in an xterm running a shell: echo "ESC]2;TEXT^G" where ESC is the escape key, TEXT is the string you wish to have displayed, and ^G is a Control-G (the BEL character). Here is a more complicated csh alias which changes the titlebar to the current working directory when you change directories: alias newcd 'cd \!* ; echo ESC]2\;$cwd^G' The digit '2' in these strings indicates to xterm that it should change only the title of the window; to change both the title and the name used in the icon, use the digit '0' instead, and use '1' to change only the icon name. These sequences work for both R3 and R4 xterm windows; the R4 xterm, however, does not accept the looser sequences which worked under R3 and demands a semicolon, above, for example, where the R3 xterm allowed any character. [For more information, see the article by Skip Montanaro of GE CR&D on Xterm control sequences in the December 1989 XNextEvent.] -------------------------------------------------- Subject: 46) Why doesn't anything appear when I run this simple program? > ... > the_window = XCreateSimpleWindow(the_display, > root_window,size_hints.x,size_hints.y, > size_hints.width,size_hints.height,BORDER_WIDTH, > BlackPixel(the_display,the_screen), > WhitePixel(the_display,the_screen)); > ... > XSelectInput(the_display,the_window,ExposureMask|ButtonPressMask| > ButtonReleaseMask); > XMapWindow(the_display,the_window); > ... > XDrawLine(the_display,the_window,the_GC,5,5,100,100); > ... You are right to map the window before drawing into it. However, the window is not ready to be drawn into until it actually appears on the screen -- until your application receives an Expose event. Drawing done before that will generally not appear. You'll see code like this in many programs; this code would appear after window was created and mapped: while (!done) { XNextEvent(the_display,&the_event); switch (the_event.type) { case Expose: /* On expose events, redraw */ XDrawLine(the_display,the_window,the_GC,5,5,100,100); break; ... } } Note that there is a second problem: some X servers don't set up the default graphics context to have reasonable foreground/background colors, and your program should not assume that the server does, so this program could previously include this code to prevent the case of having the foreground and background colors the same: ... the_GC_values.foreground=BlackPixel(the_display,the_screen); /* e.g. */ the_GC_values.background=WhitePixel(the_display,the_screen); /* e.g. */ the_GC = XCreateGC(the_display,the_window, GCForeground|GCBackground,&the_GC_values); ... Note: the code uses BlackPixel and WhitePixel to avoid assuming that 1 is black and 0 is white or vice-versa. The relationship between pixels 0 and 1 and the colors black and white is implementation-dependent. They may be reversed, or they may not even correspond to black and white at all. -------------------------------------------------- Subject: 47) What is the difference between a Screen and a screen? The 'Screen' is an Xlib structure which includes the information about one of the monitors or virtual monitors which a single X display supports. A server can support several independent screens. They are numbered unix:0.0, unix:0.1, unix:0.2, etc; the 'screen' or 'screen_number' is the second digit -- the 0, 1, 2 which can be thought of as an index into the array of available Screens on this particular Display connection. The macros which you can use to obtain information about the particular Screen on which your application is running typically have two forms -- one which takes a Screen and one with takes both the Display and the screen_number. In Xt-based programs, you typically use XtScreen(widget) to determine the Screen on which your application is running, if it uses a single screen. (Part of the confusion may arise from the fact that some of the macros which return characteristics of the Screen have "Display" in the names -- XDisplayWidth, XDisplayHeight, etc.) -------------------------------------------------- Subject: 48) How do I determine the name of an existing widget? I have a widget ID and need to know what the name of that widget is. R4 users are best off using the XtName() function, which will work on both widgets and non-widget objects. If you are still using R3, you can use this simple bit of code to do what you want. Note that it depends on the widget's internal data structures and is not portable to future versions of Xt, including R4. #include String XtName (widget) Widget widget; /* will not work with non-widget objects */ { return widget->core.name; } [7/90] -------------------------------------------------- Subject: 49) Why do I get a BadDrawable error drawing to XtWindow(widget)? I'm doing this in order to get a window into which I can do Xlib graphics within my Xt-based program: > canvas = XtCreateManagedWidget ( ...,widgetClass,...) /* drawing area */ > ... > window = XtWindow(canvas); /* get the window associated with the widget */ > ... > XDrawLine (...,window,...); /* produces error */ The window associated with the widget is created as a part of the realization of the widget. Using a window id of NULL ("no window") could create the error that you describe. It is necessary to call XtRealizeWidget() before attempting to use the window associated with a widget. Note that the window will be created after the XtRealizeWidget() call, but that the server may not have actually mapped it yet, so you should also wait for an Expose event on the window before drawing into it. -------------------------------------------------- Subject: 50) Can XGetWindowAttributes get a window's background pixel/pixmap? No. Once set, the background pixel or pixmap of a window cannot be re-read by clients. The reason for this is that a client can create a pixmap, set it to be the background pixmap of a window, and then free the pixmap. The window keeps this background, but the pixmap itself is destroyed. If you're sure a window has a background pixel (not a pixmap), you can use XClearArea() to clear a region to the background color and then use XGetImage() to read back that pixel. However, this action alters the contents of the window, and it suffers from race conditions with exposures. [courtesy Dave Lemke of NCD and Stuart Marks of Sun] Note that the same applies to the border pixel/pixmap. This is a (mis)feature of the protocol which allows the server is free to manipulate the pixel/pixmap however it wants. By not requiring the server to keep the original pixel or pixmap, some (potentially a lot of) space can be saved. [courtesy Jim Fulton, MIT X Consortium] -------------------------------------------------- Subject: 51) Why does the pixmap I copy to the screen show up as garbage? The initial contents of pixmaps are undefined. This means that most servers will allocate the memory and leave around whatever happens to be there -- which is usually garbage. You probably want to clear the pixmap first using XFillRectangle() with a function of GXcopy and a foreground pixel of whatever color you want as your background (or 0L if you are using the pixmap as a mask). [courtesy Dave Lemke of NCD and Stuart Marks of Sun] -------------------------------------------------- Subject: 52) Why doesn't my program get the keystrokes I select for? The window manager controls how the input focus is transferred from one window to another. In order to get keystrokes, your program must ask the window manager for the input focus. To do this, you must set up what are called "hints" for the window manager. If your applications is Xlib-based, you can use something like the following: XWMHints wmhints; ... wmhints.flags = InputHint; wmhints.input = True; XSetWMHints(dpy, window, &hints) If your application is based on the Xt Intrinsics, you can set the XtNinput resource to be True (as you probably want to in any case); if you don't have source, you can start up the application with the resource '*input:True'. Certain window managers, notably dxwm and olwm, are very picky about having this done. If you are using Sun's OpenWindows olwm, you can also add this resource to your defaults file to use clients that aren't ICCCM-compliant. OpenWindows.FocusLenience: true [mostly courtesy Dave Lemke of NCD and Stuart Marks of Sun] -------------------------------------------------- Subject: 53) How can my application iconify itself? The ICCCM provides a mechanism for this; your application sends a client message which includes a data value indicating that it wishes to be iconified. Here is a sample callback that will iconify the application shell, wait 3 seconds, and pop it back up. Note that ApplicationShellWidget below is global; it would make more sense in real use to walk up the tree via XtParent() to find the shell containing the active widget. void IconifyShell(w, d1, d2) Widget w; caddr_t d1, d2; { XClientMessageEvent event; Window win; Display *dpy; event.type = ClientMessage; event.send_event = True; dpy = event.display = XtDisplay(w); win = event.window = XtWindow(ApplicationShellWidget); event.message_type = XInternAtom(dpy, "WM_CHANGE_STATE", False); event.format = 32; event.data.l[0] = IconicState; XSendEvent(dpy, DefaultRootWindow(dpy), False, SubstructureRedirectMask | SubstructureNotifyMask, &event); XFlush(dpy); sleep(3); XMapWindow(dpy,win); } [courtesy David Brooks (dbrooks@osf.osf.org), 4/90] R4 users may find it easier to use this routine: /* * This function instructs the window manager to change this window from * NormalState to IconicState. */ Status XIconifyWindow (dpy, w, screen) Display *dpy; Window w; int screen; [courtesy Jim Fulton, MIT X Consortium, 6/90] -------------------------------------------------- Subject: 54) How do I check whether a window ID is valid? My program has the ID of a window on a remote display. I want to check whether the window exists before doing anything with it. Because X is asynchronous, there isn't a guarantee that the window would still exist between the time that you got the ID and the time you sent an event to the window or otherwise manipulated it. What you should do is send the event without checking, but install an error handler to catch any BadWindow errors, which would indicate that the window no longer exists. This scheme will work except on the [rare] occasion that the original window has been destroyed and its ID reallocated to another window. [courtesy Ken Lee (klee@wsl.dec.com), 4/90] -------------------------------------------------- Subject: 55) Can I have two applications draw to the same window? Yes. The X server assigns IDs to windows and other resources, and any application that knows the ID can manipulate the resource. The problem you face is how to disseminate the window ID to multiple applications. A simple way to handle this (and which solves the problem of the applications' running on different machines) is in the first application to create a specially-named property on the root-window and put the window ID into it. The second application then retrieves the property, whose name it also knows, and then can draw whatever it wants into the window. [Note: this scheme works iff there is only one instance of the first application running, and the scheme is subject to the limitations mentioned in the Question about using window IDs on remote displays.] [Note also that you will still need to coordinate any higher-level cooperation among your applications.] [mostly courtesy Phil Karlton (karlton@wpd.sgi.com) 6/90] -------------------------------------------------- Subject: 56) Why can't I set the backgroundPixmap resource in my defaults file? I want to be able to do something like this: xclock*backgroundPixmap: /usr/include/X11/bitmaps/rootweave You can't do this. The backgroundPixmap resource is a pixmap of the same depth as the screen, not a bitmap (which is a pixmap of depth 1). Because of this, writing a generic String to Pixmap converter is impossible, since there is no accepted convention for a file format for pixmaps. Therefore, neither the X Toolkit or the Athena widget set define a String to Pixmap converter; because there is no converter you cannot specify this value as a resource. The Athena widget set does define a String to Bitmap converter for use in many of its widgets, however. [courtesy Chris D. Peterson (kit@expo.lcs.mit.edu), 4/90] [Note: the leading general-purpose format for pixmaps is the XPM format used by Groupe Bull in several of its programs, including the GWM window manager, by AT&T in its olpixmap editor, and by ICS in its interface builder. XPM is being now handled by Richard Hess (rhess@cimshop.uu.net). The XPM distribution, available on expo as contrib/xpm.tar.Z, includes read/write routines which can easily be adapted to converters by new widgets which want to allow specification of pixmap resources in the above manner.] -------------------------------------------------- Subject: 57) Why does the R3 xterm, et al, fail against the R4 server? The value given to a window's do_not_propagate mask is the likely culprit. R3 allowed bogus values to be set, and early version of both Andrew and Interviews did, as well. Similar problems also occur in the R3 Motif PanedWindow widget. If it is impossible to fix client source, use 'xset bc' to put the X11R4 server into bug-compatibility mode. -------------------------------------------------- Subject: 58)+ Why doesn't xlock work on my R4 server? The version of xlock that went out on the R4 contrib tapes was not quite R4-conformant; when built and run, it will produce an X_GrabPointer protocol error. This can be fixed by making the R4 server run in bug- compatibility mode; just say `xset bc`. xlock has been fixed since; in addition, a major revision just came out (to comp.sources.x) and can be used instead. [10/90] -------------------------------------------------- Subject: 59)+ Why am I suddenly unable to connect to my Sun X server? After a seemingly random amount of time after the X server has been started, no other clients are able to connect to it. The default cron cleanup jobs supplied by Sun (for 4.0.3, at least) delete "old" (unreferenced) files from /tmp -- including /tmp/.X11-unix, which contains the socket descriptor used by X. The solution is to add "! -type s" to the find exclusion in the cron job. [10/90] -------------------------------------------------- Subject: 60)* Does Motif 1.0 work with X11R4? Applications based on OSF/Motif 1.0 will run against an R4 server if it is set to bug-compatibility mode or if a patch (part of the 1.0.3 upgrade) to the XmPanedWindow is obtained. Applications based on OSF/Motif 1.0 can be built or linked on a system with X11R4 libraries provided that the Motif version of the R3 Intrinsics is used; the R4 Xt should not be used with Motif 1.0 programs. Motif 1.1, available in source form from OSF in August, uses the "vanilla" X11R4 Intrinsics, where "vanilla" means "with just a few patches"; the file fix-osf which OSF distributes is obsoleted by MIT's patches 15-17. -------------------------------------------------- Subject: 61) Where can I obtain alternate language bindings to X? Versions of the CLX Lisp bindings are part of the X11R3 and X11R4 core source distributions. The latest version of CLX (R4.3) is available from expo for ftp as contrib/CLX.R4.3.tar.Z; this version fixes bugs reported against the R4 distribution. Ada bindings were written by Mark Nelson and Stephen Hyland at SAIC for the DOD. The bindings can be found on hapo.sei.cmu.edu or on wsmr-simtel20.army.mil and are also in the Ada Software Repository (ASR). R3 bindings should be available by the end of 1/90. [1/90] Prolog bindings (called "XWIP") written by Ted Kim at UCLA while supported in part by DARPA are available by anonymous FTP from expo.lcs.mit.edu:contrib/xwip.tar.Z or ftp.cs.ucla.edu:pub/xwip.tar.Z. These prolog language bindings depend on having a Quintus-type foreign function interface in your prolog. The developer has gotten it to work with Quintus and SICStus prolog. Inquiries should go to xwip@cs.ucla.edu. [3/90] GHG is developing X bindings and a complete Ada re-implementation of X; check Lionel Hanley at 713-488-8806. [4/90] Ada bindings to Motif, explicitly, will eventually be made available by the Jet Propulsion Laboratories, probably through the normal electronic means. Advance information can be obtained from dsouleles@dsfvax.jpl.nasa.gov, who may respond as time permits. -------------------------------------------------- Local Variables: mode: outline outline-regexp: "Subject: [0-9]+)" eval: (hide-body) End: -------------------------------------------------- The X User's Group xug@expo.lcs.mit.edu +1 617 547 0634 "No, I'm a member of the X User's Group, not the Ex-User's Group."