home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume8 / wscrawl / part01 next >
Internet Message Format  |  1990-07-15  |  59KB

  1. Path: uunet!munnari.oz.au!metro!sunaus.oz!newstop!sun!hpcvlx.cv.hp.com
  2. From: brianw@hpcvlx.cv.hp.com (Brian Wilson)
  3. Newsgroups: comp.sources.x
  4. Subject: v08i053: wscrawl, Part01/05
  5. Message-ID: <138938@sun.Eng.Sun.COM>
  6. Date: 15 Jul 90 18:57:10 GMT
  7. Sender: news@sun.Eng.Sun.COM
  8. Lines: 1505
  9. Approved: argv@sun.com
  10.  
  11. Submitted-by: Brian Wilson <brianw@hpcvlx.cv.hp.com>
  12. Posting-number: Volume 8, Issue 53
  13. Archive-name: wscrawl/part01
  14.  
  15. [ moderator's note:
  16.     this archive consists of a file wscrawl.c, which is about 185K.
  17.     I had to split the file into parts (labeled xaa, xab, xac...).
  18.     You need to do:
  19.     % cat xa? > wscrawl.c
  20.     before you attempt to "make" anything.
  21.     --dan
  22. ]
  23.  
  24.                   wscrawl
  25.  
  26. If you have never used wscrawl before, it can be thought of as a paint
  27. program shared between multiple people, displays, and workstations.  Any
  28. number of people can draw independantly of each other, yet they all work
  29. on the same picture.
  30.  
  31. This is a complete reposting of the program wscrawl.  Many enhancements have
  32. been made to the original, including File I/O in standard "xwd" format, and
  33. adding displays to the session by anyone in the session, during the session.
  34. Other enhancements include the drawing of shapes, and a Rubber Pointer for
  35. pointing (without drawing) on other member's displays.  Resizing the window
  36. no longer clears the contents, and on MOST systems, the menus will not clear
  37. the drawing away like they used to.
  38.  
  39. Thanks to the people who sent me ideas and bug reports.  They were all very
  40. helpful.
  41.  
  42.  
  43.    File Name            Archive #       Description
  44. ----------------------------------------------------------
  45.  wscrawl                    1
  46.  wscrawl/Imakefile          1
  47.  wscrawl/Makefile           1
  48.  wscrawl/README             2
  49.  wscrawl/image_f_io.c       5
  50.  wscrawl/patchlevel.h       1
  51.  wscrawl/pause_curs.h       1
  52.  wscrawl/wscrawl.1          1
  53.  wscrawl/xaa                4
  54.  wscrawl/xab                5
  55.  wscrawl/xac                2
  56.  wscrawl/xad                3
  57.  wscrawl/xae                1
  58.  wscrawl/xaf                1
  59.  
  60. You can annonymous ftp a file called "wscrawl.shar" from machine 
  61. "15.255.72.15".  Use login "ftp" and passwd "ftp" and once logged in, "cd pub"
  62. then "get wscrawl.shar".  This file contains my posting, but in the shar
  63. format I am more familiar with.
  64.  
  65. Thanks,
  66. Brian Wilson
  67. (503) 750-3929
  68.  
  69. #! /bin/sh
  70. # This is a shell archive.  Remove anything before this line, then feed it
  71. # into a shell via "sh file" or similar.  To overwrite existing files,
  72. # type "sh file -c".
  73. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  74. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  75. # If this archive is complete, you will see the following message at the end:
  76. #        "End of archive 1 (of 5)."
  77. # Contents:  wscrawl wscrawl/Imakefile wscrawl/Makefile
  78. #   wscrawl/patchlevel.h wscrawl/pause_curs.h wscrawl/wscrawl.1
  79. #   wscrawl/xae wscrawl/xaf
  80. # Wrapped by argv@turnpike on Sun Jul 15 11:47:10 1990
  81. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  82. if test ! -d 'wscrawl' ; then
  83.     echo shar: Creating directory \"'wscrawl'\"
  84.     mkdir 'wscrawl'
  85. fi
  86. if test -f 'wscrawl/Imakefile' -a "${1}" != "-c" ; then 
  87.   echo shar: Will not clobber existing file \"'wscrawl/Imakefile'\"
  88. else
  89. echo shar: Extracting \"'wscrawl/Imakefile'\" \(230 characters\)
  90. sed "s/^X//" >'wscrawl/Imakefile' <<'END_OF_FILE'
  91. XINCLUDES = -I. -I$(INCLUDESRC)
  92. XLOCAL_LIBRARIES = $(XLIB)
  93. X           SRCS = wscrawl.c image_f_io.c
  94. X           OBJS = wscrawl.o image_f_io.o
  95. X
  96. XNormalLibraryObjectRule()
  97. XComplexProgramTarget(wscrawl)
  98. XInstallProgram(wscrawl,$(BINDIR))
  99. END_OF_FILE
  100. if test 230 -ne `wc -c <'wscrawl/Imakefile'`; then
  101.     echo shar: \"'wscrawl/Imakefile'\" unpacked with wrong size!
  102. fi
  103. # end of 'wscrawl/Imakefile'
  104. fi
  105. if test -f 'wscrawl/Makefile' -a "${1}" != "-c" ; then 
  106.   echo shar: Will not clobber existing file \"'wscrawl/Makefile'\"
  107. else
  108. echo shar: Extracting \"'wscrawl/Makefile'\" \(201 characters\)
  109. sed "s/^X//" >'wscrawl/Makefile' <<'END_OF_FILE'
  110. X# Makefile for wscrawl
  111. X
  112. Xwscrawl: wscrawl.o image_f_io.o
  113. X    cc -o wscrawl wscrawl.o image_f_io.o -lX11
  114. X
  115. Xwscrawl.o: wscrawl.c pause_curs.h
  116. X    cc -c wscrawl.c
  117. X
  118. Ximage_f_io.o: image_f_io.c
  119. X    cc -c image_f_io.c
  120. X
  121. END_OF_FILE
  122. if test 201 -ne `wc -c <'wscrawl/Makefile'`; then
  123.     echo shar: \"'wscrawl/Makefile'\" unpacked with wrong size!
  124. fi
  125. # end of 'wscrawl/Makefile'
  126. fi
  127. if test -f 'wscrawl/patchlevel.h' -a "${1}" != "-c" ; then 
  128.   echo shar: Will not clobber existing file \"'wscrawl/patchlevel.h'\"
  129. else
  130. echo shar: Extracting \"'wscrawl/patchlevel.h'\" \(21 characters\)
  131. sed "s/^X//" >'wscrawl/patchlevel.h' <<'END_OF_FILE'
  132. X#define PATCHLEVEL 0
  133. END_OF_FILE
  134. if test 21 -ne `wc -c <'wscrawl/patchlevel.h'`; then
  135.     echo shar: \"'wscrawl/patchlevel.h'\" unpacked with wrong size!
  136. fi
  137. # end of 'wscrawl/patchlevel.h'
  138. fi
  139. if test -f 'wscrawl/pause_curs.h' -a "${1}" != "-c" ; then 
  140.   echo shar: Will not clobber existing file \"'wscrawl/pause_curs.h'\"
  141. else
  142. echo shar: Extracting \"'wscrawl/pause_curs.h'\" \(3349 characters\)
  143. sed "s/^X//" >'wscrawl/pause_curs.h' <<'END_OF_FILE'
  144. X#define pause_curs_width 64
  145. X#define pause_curs_height 64
  146. X#define pause_curs_x_hot 32
  147. X#define pause_curs_y_hot 31
  148. Xstatic char pause_curs_bits[] = {
  149. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  150. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  151. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  152. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  153. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  154. X   0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00,
  155. X   0x86, 0x01, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x07, 0x22, 0x00,
  156. X   0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00,
  157. X   0x02, 0x04, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x0c, 0x11, 0x00,
  158. X   0x00, 0x00, 0x00, 0x00, 0x02, 0x84, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00,
  159. X   0x02, 0x84, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x84, 0x08, 0x00,
  160. X   0x00, 0x00, 0x00, 0x00, 0x02, 0xc4, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
  161. X   0x02, 0x44, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x42, 0x04, 0x00,
  162. X   0x00, 0x00, 0x00, 0x00, 0xba, 0x43, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18,
  163. X   0xe2, 0x40, 0x02, 0x7c, 0xe0, 0x00, 0x07, 0x36, 0x02, 0x40, 0x02, 0x83,
  164. X   0x18, 0x81, 0x01, 0x63, 0x02, 0x40, 0x03, 0x41, 0x08, 0x81, 0x01, 0x41,
  165. X   0x02, 0xc0, 0x01, 0x23, 0x04, 0x01, 0x83, 0x7f, 0x02, 0xc0, 0x00, 0x1f,
  166. X   0x84, 0x01, 0x86, 0x00, 0x02, 0xc0, 0x00, 0x01, 0x84, 0x20, 0xc4, 0x00,
  167. X   0x02, 0xa0, 0x00, 0x01, 0x84, 0x21, 0x48, 0x00, 0x02, 0x10, 0x01, 0x01,
  168. X   0x4c, 0x61, 0x48, 0x00, 0x03, 0x18, 0x03, 0x02, 0x38, 0xc3, 0xcf, 0x40,
  169. X   0x03, 0x0e, 0x0c, 0x86, 0x00, 0x00, 0x80, 0x60, 0x02, 0x02, 0x00, 0x78,
  170. X   0x00, 0x00, 0x80, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b,
  171. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00,
  172. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  173. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  174. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  175. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  176. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00,
  177. X   0x00, 0x10, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x20,
  178. X   0x00, 0xc0, 0x07, 0x00, 0x00, 0x10, 0x00, 0x20, 0x00, 0x40, 0x04, 0x00,
  179. X   0x00, 0x10, 0x00, 0x10, 0x00, 0x40, 0x04, 0x00, 0x00, 0x10, 0x00, 0x10,
  180. X   0x00, 0xc0, 0x84, 0x01, 0x00, 0x10, 0x00, 0x10, 0x00, 0x80, 0x87, 0x00,
  181. X   0x00, 0x10, 0x00, 0x18, 0x00, 0x00, 0x40, 0x00, 0x00, 0x20, 0x00, 0x08,
  182. X   0x00, 0x00, 0x40, 0x00, 0x00, 0x20, 0x00, 0x08, 0xc0, 0x41, 0xf8, 0x07,
  183. X   0x00, 0x20, 0x08, 0x04, 0xb8, 0x41, 0x40, 0x00, 0x00, 0x20, 0x1c, 0x04,
  184. X   0x8c, 0x41, 0x60, 0x00, 0x00, 0x40, 0x34, 0x06, 0x84, 0x41, 0x20, 0x00,
  185. X   0x00, 0x40, 0x26, 0x03, 0x82, 0x20, 0x20, 0x00, 0x00, 0x40, 0x62, 0x01,
  186. X   0xc2, 0x20, 0x20, 0x00, 0x00, 0xc0, 0xc2, 0x01, 0xc2, 0x20, 0x20, 0x00,
  187. X   0x00, 0x80, 0xc1, 0x00, 0xe2, 0x21, 0x40, 0x04, 0x00, 0x80, 0xc1, 0x00,
  188. X   0x3c, 0x67, 0xc1, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00,
  189. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  190. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  191. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  192. END_OF_FILE
  193. if test 3349 -ne `wc -c <'wscrawl/pause_curs.h'`; then
  194.     echo shar: \"'wscrawl/pause_curs.h'\" unpacked with wrong size!
  195. fi
  196. # end of 'wscrawl/pause_curs.h'
  197. fi
  198. if test -f 'wscrawl/wscrawl.1' -a "${1}" != "-c" ; then 
  199.   echo shar: Will not clobber existing file \"'wscrawl/wscrawl.1'\"
  200. else
  201. echo shar: Extracting \"'wscrawl/wscrawl.1'\" \(3719 characters\)
  202. sed "s/^X//" >'wscrawl/wscrawl.1' <<'END_OF_FILE'
  203. X.TH WSCRAWL 1
  204. X.ds )H eXcess engineering
  205. X.ds ]W July 1990
  206. X.SH NAME
  207. Xwscrawl \- a multiple person paint program shared between displays
  208. X.SH SYNOPSIS
  209. X.B wscrawl 
  210. X[
  211. X.I options
  212. X]
  213. X.SH DESCRIPTION
  214. X.I Wscrawl\^
  215. Xpaints or types on single or multiple displays. The
  216. X.B [\-d displayname]
  217. Xoption causes 
  218. X.I wscrawl
  219. Xto wscrawl on both the invoker's display and on a target display.
  220. XAny person on a target display may scrawl back in the window provided.
  221. XAll members of the session will always see the same thing in their 
  222. Xrespective wscrawl windows.
  223. X.SS Options
  224. X.PP
  225. XThere are several options:
  226. X.TP
  227. X.B  \-d displayname1 \-d displayname2 . . .
  228. Xopen a wscrawl window on displayname1 and displayname2 at the same time as 
  229. Xthe HOME display
  230. X.TP
  231. X.B  \-pc pen_color
  232. Xset the pen color
  233. X.TP
  234. X.B  \-pw pen_width
  235. Xset the pen width
  236. X.TP
  237. X.B  \-ps pen_style
  238. Xpen style can be one of the following: dot, airbrush, draw_shapes, eraser
  239. X.TP
  240. X.B  \-cs pen_style
  241. Xcap style can be one of the following: CapButt, CapNotLast, CapRound, 
  242. XCapProjecting
  243. X.TP
  244. X.B  \-nd num_dots
  245. Xset the number of dots in the airbrush (airbrush density)
  246. X.TP
  247. X.B  \-tm
  248. Xtype a message, don't wscrawl
  249. X.TP
  250. X.B  \-fn font
  251. Xspecify the font if typing a message
  252. X.TP
  253. X.B  \-sh shape
  254. Xspecify the shape to use if the pen_style is "draw_shapes"
  255. X.SH FILE INPUT AND OUTPUT
  256. XThere are several forms of File I\/O available during a session of wscrawl.
  257. X.PP
  258. XForms of I/O include:
  259. X.TP
  260. X.B  Save Bitmap
  261. XAfter selecting this menu option, click and drag the mouse over the
  262. Xregion you wish to convert to a standard X-Windows bitmap file.  Upon
  263. Xrelease of the button, you will be prompted for a file name.  The background
  264. Xcolor is converted to a "0" in the bitmap, while anything other than background
  265. Xis converted to a "1" in the bitmap.
  266. X.TP
  267. X.B  Read In Bitmap
  268. XAfter selecting this menu option, type the name of the bitmap file into
  269. Xthe dialog box provided.  Upon hitting return, a rubber band type box will
  270. Xappear indicating the size and location of the bitmap.  To place the bitmap,
  271. Xclick the left button.  The bitmap is drawn in using the current PenColor as
  272. Xthe foreground and the background color as the background.
  273. X.TP
  274. X.B  Read Text File
  275. XAfter selecting this menu option, type the name of the text file into
  276. Xthe dialog box provided.  Upon hitting return, a rubber band type box will
  277. Xappear indicating the size and location of the text.  To place the text,
  278. Xclick the left mouse button.
  279. X.TP
  280. X.B  Save Image
  281. XAfter selecting this menu option, click and drag the mouse over the
  282. Xregion you wish to convert to an "image" file.  Upon
  283. Xrelease of the button, you will be prompted for a file name.  The region
  284. Xselected will be saved in a form that the MIT client "xwud" can read.
  285. X.TP
  286. X.B  Read In Image
  287. XAfter selecting this menu option, type the name of the image file into
  288. Xthe dialog box provided.  Upon hitting return, a rubber band type box will
  289. Xappear indicating the size and location of the image.  To place the bitmap,
  290. Xclick the left button.  The image is restored to any wscrawl windows open
  291. Xthat are the same depth as the original image.  Image files can either be
  292. Xcreated earlier by wscrawl, or by the MIT client "xwd".
  293. X.SH DIAGNOSTICS
  294. XThere are no diagnostics.  Source is available.
  295. X.SH EXAMPLES
  296. XThis command opens a wscrawl window on the HOME display, the "dove:0" 
  297. Xdisplay and the "hawk:0" display ready to type messages in the color cyan, 
  298. Xand the font "vgl-40".
  299. X.IP
  300. Xwscrawl -d dove:0 -d hawk:0 -tm -pc cyan -fn vgl-40
  301. X.SH AUTHOR
  302. X.I wscrawl
  303. Xwas developed by Brian Wilson of Hewlett-Packard.
  304. X.SH EXTERNAL INFLUENCES
  305. X.SS Environment Variables
  306. X.SM DISPLAY
  307. Xdetermines the home display which wscrawl will wscrawl to regardless of
  308. Xcommand line displays.
  309. X.PP
  310. X.SH "STANDARDS CONFORMANCE"
  311. X.IR wscrawl ": X11, Xlib, R4"
  312. END_OF_FILE
  313. if test 3719 -ne `wc -c <'wscrawl/wscrawl.1'`; then
  314.     echo shar: \"'wscrawl/wscrawl.1'\" unpacked with wrong size!
  315. fi
  316. # end of 'wscrawl/wscrawl.1'
  317. fi
  318. if test -f 'wscrawl/xae' -a "${1}" != "-c" ; then 
  319.   echo shar: Will not clobber existing file \"'wscrawl/xae'\"
  320. else
  321. echo shar: Extracting \"'wscrawl/xae'\" \(39069 characters\)
  322. sed "s/^X//" >'wscrawl/xae' <<'END_OF_FILE'
  323. X    XColor curs_foregrexact, curs_foregr, curs_backgr, curs_backgrexact;
  324. X    Pixmap source, mask;
  325. X    int i, j, k, menu_num;
  326. X    GC *(old_win_gc[MAX_NUM_DISPS]);
  327. X    int menu_x_val;
  328. X    XWindowAttributes attr_ret;
  329. X    XFontStruct *the_font_struct;
  330. X    char tmp_str[50], tmp_str2[50];
  331. X    XGCValues cursor_gc_values;
  332. X
  333. X    /*
  334. X     * The following opens the new display and window and initializes some
  335. X     * of the disp_info fields.  The cursor is defined for the window, and
  336. X     * the window manager is instructed how to behave with the new window.
  337. X     */
  338. X
  339. X    /*open this particular display*/
  340. X    if ((disp_info[disp_num].disp = XOpenDisplay(disp_args[disp_num])) == NULL)
  341. X    {
  342. X        printf("ERROR: XOpenDisplay failed on display: %s\n", 
  343. X           disp_args[disp_num]);
  344. X        exit(0);
  345. X    }
  346. X
  347. X    winvals.backing_store = Always;
  348. X    if (!XAllocNamedColor(disp_info[disp_num].disp, 
  349. X                DefaultColormap(disp_info[disp_num].disp, 
  350. X            DefaultScreen(disp_info[disp_num].disp)), BACKGROUND_COLOR, 
  351. X            &scrn_def_ret, &exact_def_ret))
  352. X    {
  353. X        printf("\nThe color %s is not supported", BACKGROUND_COLOR);
  354. X        printf(" on the display %s.\n", disp_args[disp_num]);
  355. X        exit(0);
  356. X    }
  357. X    winvals.background_pixel = scrn_def_ret.pixel;
  358. X    winvals.bit_gravity = NorthWestGravity;
  359. X    disp_info[disp_num].background = scrn_def_ret.pixel;
  360. X
  361. X    disp_info[disp_num].win_id = XCreateWindow(disp_info[disp_num].disp, 
  362. X          RootWindow(disp_info[disp_num].disp, DefaultScreen(
  363. X          disp_info[disp_num].disp)), 5+(disp_num*80), 5+(disp_num*80),
  364. X          WSCRAWL_WIN_WIDTH, WSCRAWL_WIN_HEIGHT, 3, 0,
  365. X          CopyFromParent,CopyFromParent,alter_these2_mask, &winvals);
  366. X
  367. X
  368. X    disp_info[disp_num].connection_num = 
  369. X                    ConnectionNumber(disp_info[disp_num].disp);
  370. X    disp_info[disp_num].first_point_bool = FALSE;
  371. X    disp_info[disp_num].pointer_state = NOT_PRESSED;
  372. X    disp_info[disp_num].scrawl_mode = SCRAWLING;
  373. X    disp_info[disp_num].current_shape = OUTLINE_RECT;
  374. X    disp_info[disp_num].just_placed_something_bool = FALSE;
  375. X    disp_info[disp_num].type_history = NULL;
  376. X
  377. X    cursor_gc_values.line_width = 5;
  378. X    cursor_gc_values.function = GXinvert;
  379. X    cursor_gc_values.background =  BlackPixelOfScreen(
  380. X                     DefaultScreenOfDisplay(disp_info[disp_num].disp));
  381. X    cursor_gc_values.foreground =  WhitePixelOfScreen(
  382. X                     DefaultScreenOfDisplay(disp_info[disp_num].disp));
  383. X    disp_info[disp_num].cursor_gc = XCreateGC(disp_info[disp_num].disp, 
  384. X                  disp_info[disp_num].win_id,
  385. X                  GCFunction | GCBackground | GCForeground | GCLineWidth, 
  386. X              &cursor_gc_values);
  387. X
  388. X    if (!TYPE_NOT_DRAW)
  389. X        the_cursor = XCreateFontCursor(disp_info[disp_num].disp, XC_dot);
  390. X
  391. X    XDefineCursor(disp_info[disp_num].disp, disp_info[disp_num].win_id, 
  392. X           the_cursor);
  393. X
  394. X    win_size_hints.flags = USPosition | PPosition;
  395. X    win_size_hints.x = 5 + (disp_num * 80);
  396. X    win_size_hints.y = 5 + (disp_num * 80);
  397. X
  398. X    XSetStandardProperties(disp_info[disp_num].disp, disp_info[disp_num].win_id,
  399. X            "WSCRAWL: a product of eXcess engineering", "wscrawl", None, 
  400. X        NULL, 0, &win_size_hints);
  401. X
  402. X    /* the following three calls are to change window manager behavior*/
  403. X    disp_info[disp_num].xa_WM_PROTOCOLS = XInternAtom(disp_info[disp_num].disp, 
  404. X                           "WM_PROTOCOLS", FALSE);
  405. X    disp_info[disp_num].xa_WM_DELETE_WINDOW = XInternAtom(
  406. X                            disp_info[disp_num].disp, 
  407. X                                "WM_DELETE_WINDOW", FALSE);
  408. X    XChangeProperty(disp_info[disp_num].disp, disp_info[disp_num].win_id, 
  409. X        disp_info[disp_num].xa_WM_PROTOCOLS, 
  410. X        disp_info[disp_num].xa_WM_PROTOCOLS, 32, 
  411. X        PropModeReplace,
  412. X        (char *) &(disp_info[disp_num].xa_WM_DELETE_WINDOW), 1);
  413. X
  414. X    /*
  415. X     * The following changes the names in the "disp_args[]" array to reflect
  416. X     * the ACTUAL machine and display instead of things like "local:0" etc.
  417. X     */
  418. X    if ((strncmp(disp_args[disp_num], "local", 5) == 0) ||
  419. X        (strncmp(disp_args[disp_num], "unix", 4) == 0) ||
  420. X        (strncmp(disp_args[disp_num], ":", 1) == 0))
  421. X    {
  422. X        /*
  423. X         * this is a wscrawl window on the invoker's home display, so
  424. X         * change it to be meaningful.
  425. X         */
  426. X        gethostname(tmp_str, 30);
  427. X        sprintf(tmp_str2, "%s%s", tmp_str, strpbrk(disp_args[disp_num], ":"));
  428. X        strncpy(disp_args[disp_num], tmp_str2, 30);
  429. X    }
  430. X
  431. X    for (i=0; i<num_of_disps; i++)
  432. X    if (disp_info[i].in_session_bool)  /*only if this session is in use*/
  433. X            old_win_gc[i] = disp_info[i].win_gc;  /*save the old array of GCs*/
  434. X
  435. X    for (i=0; i<num_of_disps; i++)                /*malloc new array of GCs*/
  436. X    if (disp_info[i].in_session_bool)  /*only if this session is wanted*/
  437. X            disp_info[i].win_gc = (GC *) malloc(num_of_disps * sizeof(GC));
  438. X    /*
  439. X     * The following assigns each "user" N graphics contexts, where N
  440. X     * is the number of open displays.  This "user" wants his particular
  441. X     * color on every display, and since gc's are attached to displays,
  442. X     * we need one with this color loaded on every display.  These gc's
  443. X     * are then used for pen width, pen caps, etc.
  444. X     *
  445. X     * The complex part (well, one of the complex parts) comes in when 
  446. X     * you want a user to retain his or her same GC.  In some cases, this
  447. X     * is simply a copy over from the former one.  But one doesn't exist
  448. X     * yet for the new display, so we create it as close as possible.
  449. X     */
  450. X    for (i=0; i<num_of_disps; i++)
  451. X    { 
  452. X    if (disp_info[i].in_session_bool)  /*only if this session is wanted*/
  453. X    {
  454. X        /*
  455. X         * The following assigns this "user" N graphics contexts, where N
  456. X         * is the number of open displays.  This "user" wants his particular
  457. X         * color on every display, and since gc's are attached to displays,
  458. X         * we need one with this color loaded on every display.  These gc's
  459. X         * are then used for pen width, pen caps, etc.
  460. X         */
  461. X        for (j=0; j<num_of_disps; j++)
  462. X        {
  463. X            if (disp_info[j].in_session_bool) /*only if session is wanted*/
  464. X            {
  465. X            if ((i != disp_num) && (j != disp_num))
  466. X            {
  467. X                        disp_info[i].win_gc[j] = XCreateGC(disp_info[j].disp, 
  468. X                                   disp_info[j].win_id, nothing_mask, 
  469. X                       &gcvalues);
  470. X                        XCopyGC(disp_info[j].disp, old_win_gc[i][j], 
  471. X                gc_copy_mask, disp_info[i].win_gc[j]);
  472. X            XFreeGC(disp_info[j].disp, old_win_gc[i][j]);
  473. X            }
  474. X            else
  475. X            {
  476. X            if (i == disp_num) /*this is the new guy, set defaults*/
  477. X            {
  478. X                            disp_info[i].pen_width = PEN_WIDTH;
  479. X                        disp_info[i].pen_widths.scrawl = 8;
  480. X                        disp_info[i].pen_widths.airbrush = 40;
  481. X                        disp_info[i].pen_widths.eraser = 40;
  482. X                        disp_info[i].pen_widths.shape = 8;
  483. X                            disp_info[i].capstyle = CAP_STYLE;
  484. X                strncpy(disp_info[i].pen_color_str, PEN_COLOR, 40);
  485. X                strncpy(disp_info[i].font_str, FONT, 250);
  486. X            }
  487. X
  488. X                        /*
  489. X             * create the gc from scratch
  490. X             */
  491. X                        if (XAllocNamedColor(disp_info[j].disp,DefaultColormap(
  492. X                     disp_info[j].disp, 
  493. X                 DefaultScreen(disp_info[j].disp)), 
  494. X                 disp_info[i].pen_color_str, 
  495. X                 &scrn_def_ret, &exact_def_ret))
  496. X                    {
  497. X                    ;  /*great!  it worked!*/
  498. X                    }
  499. X                    else if (!XAllocNamedColor(disp_info[j].disp, 
  500. X                 DefaultColormap(disp_info[j].disp, 
  501. X                 DefaultScreen(disp_info[j].disp)), 
  502. X                     "black", &scrn_def_ret, &exact_def_ret))
  503. X                    {
  504. X                        printf("The color %s is not", PEN_COLOR);
  505. X                        printf(" supported on the display %s.\n", 
  506. X                   disp_args[i]);
  507. X                        exit(0);
  508. X                    }
  509. X                        gcvalues.foreground = scrn_def_ret.pixel;
  510. X            
  511. X                        gcvalues.background =
  512. X                     WhitePixelOfScreen(DefaultScreenOfDisplay(
  513. X                     disp_info[j].disp));
  514. X        
  515. X                gcvalues.line_width = disp_info[i].pen_width;
  516. X                        gcvalues.cap_style = disp_info[i].capstyle;
  517. X                        gcvalues.graphics_exposures = False;
  518. X            
  519. X                        if ((the_font_struct =XLoadQueryFont(disp_info[j].disp,
  520. X                 disp_info[i].font_str)) != NULL)
  521. X                    {
  522. X                        gcvalues.font = the_font_struct->fid;
  523. X                    }
  524. X                    else if ((the_font_struct=XLoadQueryFont(
  525. X                  disp_info[j].disp, "fixed")) != NULL)
  526. X                    {
  527. X                        printf("WARNING: Couldn't allocate font: %s",FONT);
  528. X                        printf(" on display %s.  Using fixed.\n",
  529. X                    disp_args[j]);
  530. X                        gcvalues.font = the_font_struct->fid;
  531. X                    }
  532. X                    else
  533. X                    {
  534. X                        printf("\nERROR: Couldn't allocate a font ");
  535. X                    printf("on display: %s.\n", disp_args[j]);
  536. X                        exit(0);
  537. X                        }
  538. X            
  539. X                        disp_info[i].win_gc[j] = XCreateGC(disp_info[j].disp, 
  540. X                     disp_info[j].win_id, alter_these_mask, &gcvalues);
  541. X                    disp_info[i].the_font_struct = the_font_struct;
  542. X            }
  543. X            }
  544. X            }
  545. X    }
  546. X    }
  547. X    
  548. X    /*
  549. X     * create the rubber_band_gc's for all the scrawl windows
  550. X     */
  551. X    gcvalues.function = GXinvert;
  552. X    gcvalues.line_width = 0;
  553. X    disp_info[disp_num].rubber_band_gc = XCreateGC(disp_info[disp_num].disp, 
  554. X              disp_info[disp_num].win_id, GCLineWidth | GCFunction, &gcvalues);
  555. X
  556. X    /*
  557. X     * create and initialize the menus on this scrawl window
  558. X     */
  559. X    for (menu_num=0; menu_num<NUM_OF_MENUS; menu_num++)
  560. X    {
  561. X        if (XAllocNamedColor(disp_info[disp_num].disp, 
  562. X            DefaultColormap(disp_info[disp_num].disp, 
  563. X                DefaultScreen(disp_info[disp_num].disp)), 
  564. X            MENU_BACKGROUND_COLOR, 
  565. X                &scrn_def_ret, &exact_def_ret))
  566. X        {
  567. X            menuwinvals.background_pixel = scrn_def_ret.pixel;
  568. X        }
  569. X        else if (XAllocNamedColor(disp_info[disp_num].disp, 
  570. X            DefaultColormap(disp_info[disp_num].disp, 
  571. X                DefaultScreen(disp_info[disp_num].disp)), "white", 
  572. X                &scrn_def_ret, &exact_def_ret))
  573. X        {
  574. X            printf("The color %s is not", MENU_BACKGROUND_COLOR);
  575. X        printf(" supported on display %s.\n", disp_args[disp_num]);
  576. X        printf("Using white for the menu background color.\n");
  577. X        strcpy(MENU_BACKGROUND_COLOR, "white");
  578. X        menuwinvals.background_pixel = scrn_def_ret.pixel;
  579. X        }
  580. X        else
  581. X        {
  582. X        printf("The menu background color had extra problems on");
  583. X        printf(" display %s.\n", disp_args[disp_num]);
  584. X        return(0);
  585. X        }
  586. X    
  587. X    menu_x_val = menu_num*MENU_ITEM_WIDTH + (menu_num*2);
  588. X        menuwinvals.save_under = True;
  589. X    
  590. X    disp_info[disp_num].menu[menu_num].win_id =
  591. X             XCreateWindow(disp_info[disp_num].disp, 
  592. X             disp_info[disp_num].win_id, 
  593. X             menu_x_val, 0, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT, 2, 
  594. X             0, CopyFromParent, CopyFromParent, alter_menu2_mask, 
  595. X             &menuwinvals);
  596. X        XMapWindow(disp_info[disp_num].disp,
  597. X                disp_info[disp_num].menu[menu_num].win_id);
  598. X    
  599. X    menu_cursor =XCreateFontCursor(disp_info[disp_num].disp,XC_right_ptr);
  600. X    XDefineCursor(disp_info[disp_num].disp, 
  601. X                  disp_info[disp_num].menu[menu_num].win_id, menu_cursor);
  602. X    
  603. X    disp_info[disp_num].menu[menu_num].item_selected = NO_ITEM_SELECTED;
  604. X    }
  605. X    
  606. X    /*
  607. X     * find the num of items in each menu and assign it to the correct
  608. X     * variable in the structure. "k" is the menu_item_num.
  609. X     */
  610. X    for (menu_num=0; menu_num < NUM_OF_MENUS; menu_num++)
  611. X    {
  612. X        for (k=0; strcmp(menu_text[menu_num][k], "****") != 0; k++)
  613. X            ;
  614. X        disp_info[disp_num].menu[menu_num].num_items = k;
  615. X
  616. X    switch(menu_num)  /*set default checkmark*/
  617. X    {
  618. X        case 0:                   /*Control menu*/
  619. X            disp_info[disp_num].menu[menu_num].checked_item = 1;
  620. X        break;
  621. X        case 1:                   /*PenColor menu*/
  622. X            disp_info[disp_num].menu[menu_num].checked_item = 2;
  623. X        break;
  624. X        case 2:                   /*PenWidth menu*/
  625. X            disp_info[disp_num].menu[menu_num].checked_item = 4;
  626. X        break;
  627. X        case 3:                   /*PenCapStyle menu*/
  628. X            disp_info[disp_num].menu[menu_num].checked_item = 1;
  629. X        break;
  630. X        case 4:                   /*Font menu*/
  631. X            disp_info[disp_num].menu[menu_num].checked_item = 14;
  632. X        break;
  633. X        case 5:                   /*Shapes menu*/
  634. X            disp_info[disp_num].menu[menu_num].checked_item = 2;
  635. X        break;
  636. X        default:
  637. X        break;
  638. X    }
  639. X    }
  640. X    
  641. X    if (!XAllocNamedColor(disp_info[disp_num].disp, 
  642. X            DefaultColormap(disp_info[disp_num].disp, 
  643. X                DefaultScreen(disp_info[disp_num].disp)), 
  644. X            MENU_HIGHLIGHT_COLOR, 
  645. X                &scrn_def_ret, &exact_def_ret))
  646. X    {
  647. X        printf("The color %s is not", MENU_HIGHLIGHT_COLOR);
  648. X        printf(" supported on the display %s.\n", disp_args[disp_num]);
  649. X        return(0);
  650. X    }
  651. X    menugcvalues.foreground = scrn_def_ret.pixel;
  652. X    
  653. X    if (!XAllocNamedColor(disp_info[disp_num].disp, 
  654. X            DefaultColormap(disp_info[disp_num].disp, 
  655. X            DefaultScreen(disp_info[disp_num].disp)), 
  656. X        MENU_BACKGROUND_COLOR, 
  657. X            &scrn_def_ret2, &exact_def_ret2))
  658. X    {
  659. X            printf("The menu background color had second round problems ");
  660. X                printf("on the display %s.\n", disp_args[disp_num]);
  661. X            return(0);
  662. X    }
  663. X    
  664. X    menugcvalues.background = scrn_def_ret2.pixel;
  665. X    
  666. X    menugcvalues.line_width = 2;
  667. X    menugcvalues.font = XLoadFont(disp_info[disp_num].disp, "fixed");
  668. X    disp_info[disp_num].hi_menu_gc = XCreateGC(disp_info[disp_num].disp, 
  669. X          disp_info[disp_num].menu[0].win_id, alter_menu_mask, &menugcvalues);
  670. X    
  671. X    /*
  672. X     * switch foreground and background colors for bg_menu_gc
  673. X     */
  674. X    menugcvalues.foreground = scrn_def_ret2.pixel;
  675. X    menugcvalues.background = scrn_def_ret.pixel;
  676. X    disp_info[disp_num].bg_menu_gc = XCreateGC(disp_info[disp_num].disp, 
  677. X    disp_info[disp_num].menu[0].win_id, alter_menu_mask, &menugcvalues);
  678. X    
  679. X    if (!XAllocNamedColor(disp_info[disp_num].disp, 
  680. X        DefaultColormap(disp_info[disp_num].disp, 
  681. X            DefaultScreen(disp_info[disp_num].disp)), MENU_FOREGROUND_COLOR, 
  682. X            &scrn_def_ret, &exact_def_ret))
  683. X    {
  684. X        printf("The color %s is not", MENU_FOREGROUND_COLOR);
  685. X        printf(" supported on the display %s.\n", disp_args[disp_num]);
  686. X        return(0);
  687. X    }
  688. X    menugcvalues.foreground = scrn_def_ret.pixel;
  689. X    menugcvalues.background = scrn_def_ret2.pixel;
  690. X    disp_info[disp_num].fg_menu_gc = XCreateGC(disp_info[disp_num].disp, 
  691. X    disp_info[disp_num].menu[0].win_id, alter_menu_mask, &menugcvalues);
  692. X    
  693. X    for (menu_num=0; menu_num<NUM_OF_MENUS; menu_num++)
  694. X    {
  695. X        disp_info[disp_num].current_menu = menu_num;
  696. X        draw_menu(disp_num);
  697. X    }
  698. X    
  699. X    /*
  700. X     * create the status window and eraser window, and dialog window for 
  701. X     * this scrawl window 
  702. X     */
  703. X    if (!XAllocNamedColor(disp_info[disp_num].disp, 
  704. X        DefaultColormap(disp_info[disp_num].disp, 
  705. X            DefaultScreen(disp_info[disp_num].disp)), 
  706. X        MENU_BACKGROUND_COLOR, 
  707. X            &scrn_def_ret, &exact_def_ret))
  708. X    {
  709. X        printf("The color %s is not", MENU_BACKGROUND_COLOR);
  710. X    printf(" supported on the display %s.\n", disp_args[disp_num]);
  711. X    return(0);
  712. X    }
  713. X    menuwinvals.background_pixel = scrn_def_ret.pixel;
  714. X    menuwinvals.save_under = True;
  715. X    disp_info[disp_num].eraser_win_id = XCreateWindow(disp_info[disp_num].disp,
  716. X            disp_info[disp_num].win_id, 0, 350, 550, 20, 2, 0, CopyFromParent, 
  717. X        CopyFromParent, alter_menu2_mask, &menuwinvals);
  718. X    disp_info[disp_num].status_win_id = XCreateWindow(disp_info[disp_num].disp,
  719. X       disp_info[disp_num].win_id, 0, 350, 550, 20, 2, 0, CopyFromParent, 
  720. X       CopyFromParent, alter_menu2_mask, &menuwinvals);
  721. X    disp_info[disp_num].dialog_win_id = XCreateWindow(disp_info[disp_num].disp,
  722. X       disp_info[disp_num].win_id, 50, 80, DIALOG_WIN_WIDTH, 
  723. X       DIALOG_WIN_HEIGHT, 2, 0, CopyFromParent, 
  724. X       CopyFromParent, alter_menu2_mask, &menuwinvals);
  725. X    XMapWindow(disp_info[disp_num].disp, disp_info[disp_num].status_win_id);
  726. X    XDefineCursor(disp_info[disp_num].disp, disp_info[disp_num].status_win_id,
  727. X              XCreateFontCursor(disp_info[disp_num].disp, XC_star));
  728. X    XDefineCursor(disp_info[disp_num].disp, disp_info[disp_num].eraser_win_id,
  729. X              XCreateFontCursor(disp_info[disp_num].disp, 
  730. X              XC_draped_box));
  731. X    XDefineCursor(disp_info[disp_num].disp, disp_info[disp_num].dialog_win_id,
  732. X              XCreateFontCursor(disp_info[disp_num].disp, 
  733. X              XC_xterm));
  734. X    XLowerWindow(disp_info[disp_num].disp, disp_info[disp_num].eraser_win_id);
  735. X
  736. X    /*
  737. X     * if typing, set cursor, font, etc correctly with a call to 
  738. X     * menu_selection (which is usually called when you pull down a menu).
  739. X     */
  740. X    if (TYPE_NOT_DRAW)
  741. X        menu_selection(disp_num, 0, num_people_drawing, 3);
  742. X
  743. X    /*
  744. X     * create the pause cursor for the new display
  745. X     */
  746. X    source = XCreatePixmapFromBitmapData(disp_info[disp_num].disp, 
  747. X          disp_info[disp_num].win_id, pause_curs_bits, pause_curs_width, 
  748. X          pause_curs_height, WhitePixel(disp_info[disp_num].disp, 
  749. X          DefaultScreen(disp_info[disp_num].disp)), 
  750. X          BlackPixel(disp_info[disp_num].disp, 
  751. X          DefaultScreen(disp_info[disp_num].disp)), 1);
  752. X    mask = XCreatePixmapFromBitmapData(disp_info[disp_num].disp, 
  753. X          disp_info[disp_num].win_id, pause_curs_bits, pause_curs_width, 
  754. X          pause_curs_height, WhitePixel(disp_info[disp_num].disp, 
  755. X          DefaultScreen(disp_info[disp_num].disp)), 
  756. X          BlackPixel(disp_info[disp_num].disp, 
  757. X          DefaultScreen(disp_info[disp_num].disp)), 1);
  758. X
  759. X    XAllocNamedColor(disp_info[disp_num].disp, DefaultColormapOfScreen(
  760. X                 DefaultScreenOfDisplay(disp_info[disp_num].disp)),
  761. X             "white", &curs_backgr, &curs_backgrexact);
  762. X    XAllocNamedColor(disp_info[disp_num].disp, DefaultColormapOfScreen(
  763. X                 DefaultScreenOfDisplay(disp_info[disp_num].disp)),
  764. X             "black", &curs_foregr, &curs_foregrexact);
  765. X
  766. X    disp_info[disp_num].pause_cursor = 
  767. X              XCreatePixmapCursor(disp_info[disp_num].disp, 
  768. X              source, mask, &curs_foregrexact, &curs_backgrexact, 
  769. X              pause_curs_x_hot, pause_curs_y_hot);
  770. X
  771. X    XDefineCursor(disp_info[disp_num].disp, disp_info[disp_num].win_id,
  772. X              disp_info[disp_num].pause_cursor);
  773. X    XDefineCursor(disp_info[disp_num].disp, disp_info[disp_num].status_win_id, 
  774. X                  disp_info[disp_num].pause_cursor);
  775. X    for (j=0; j<NUM_OF_MENUS; j++)
  776. X    XDefineCursor(disp_info[disp_num].disp, 
  777. X                  disp_info[disp_num].menu[j].win_id, 
  778. X                  disp_info[disp_num].pause_cursor);
  779. X
  780. X    /*
  781. X     * create the rubber cursor pixmaps for all the displays that don't have 
  782. X     * them yet
  783. X     */
  784. X    for (i=0; i<num_of_disps; i++)
  785. X    {
  786. X    if (disp_info[i].in_session_bool)  /*only if this session is wanted*/
  787. X    {
  788. X            the_font_struct = XLoadQueryFont(disp_info[i].disp, "fixed");
  789. X            disp_info[i].rubber_pointer.width = 15 + 
  790. X                      XTextWidth(the_font_struct,
  791. X                                  disp_args[i], strlen(disp_args[i]));
  792. X            disp_info[i].rubber_pointer.height =
  793. X                   15 + the_font_struct->max_bounds.ascent + 
  794. X                   the_font_struct->max_bounds.descent;
  795. X            disp_info[i].rubber_pointer.is_mapped_bool = FALSE;
  796. X
  797. X            for (j=0; j<num_of_disps; j++)
  798. X            {
  799. X            if (disp_info[j].in_session_bool)
  800. X            {
  801. X                if ((i == disp_num) || (j == disp_num))
  802. X                {
  803. X                    disp_info[i].rubber_pointer.rubber_pointer_pix[j] = 
  804. X                 XCreatePixmap(
  805. X                     disp_info[j].disp, disp_info[j].win_id,
  806. X                                 disp_info[i].rubber_pointer.width, 
  807. X                     disp_info[i].rubber_pointer.height, 
  808. X                     DefaultDepth(disp_info[j].disp, 
  809. X                     DefaultScreen(disp_info[j].disp)));
  810. X                    }
  811. X            }
  812. X        }
  813. X    }
  814. X    }
  815. X
  816. X    /*
  817. X     * size the new window correctly
  818. X     */
  819. X    for (i=0; i<num_of_disps; i++)
  820. X    {
  821. X        if ((disp_info[i].in_session_bool==TRUE) && (i!=disp_num))
  822. X        {
  823. X             XGetWindowAttributes(disp_info[i].disp, disp_info[i].win_id,
  824. X             &attr_ret);
  825. X         XResizeWindow(disp_info[disp_num].disp, disp_info[disp_num].win_id,
  826. X               attr_ret.width, attr_ret.height);
  827. X             disp_info[disp_num].win_width = attr_ret.width;
  828. X             disp_info[disp_num].win_height = attr_ret.height;
  829. X         break;
  830. X    }
  831. X    }
  832. X
  833. X    /*
  834. X     * bring this window up with all this fun new information.
  835. X     */
  836. X    XMapWindow(disp_info[disp_num].disp, disp_info[disp_num].win_id);
  837. X    XSync(disp_info[disp_num].disp, False);
  838. X    place_and_draw_status_win(disp_num);
  839. X
  840. X    return(TRUE);   /*it was successful, we are ready to rock and roll*/
  841. X}
  842. X
  843. X
  844. X/*
  845. X * initialize_displays - this function opens all the displays, including
  846. X *                       the home one, opens a window on each and assigns
  847. X *                       each window a gc, window id, menus, etc.
  848. X */
  849. Xinitialize_displays(num_people_drawing)
  850. Xint *num_people_drawing;
  851. X{
  852. X    unsigned long alter_these_mask = GCSubwindowMode | GCLineWidth | 
  853. X                     GCForeground | GCCapStyle | GCFont |
  854. X                     GCBackground | GCGraphicsExposures;
  855. X    unsigned long alter_menu_mask =  GCSubwindowMode | GCForeground | GCFont |
  856. X                     GCBackground | GCLineWidth;
  857. X    unsigned long alter_these2_mask = CWEventMask | CWBackPixel | 
  858. X                   CWBackingStore | CWWinGravity |
  859. X                   CWBitGravity | CWSaveUnder;
  860. X    unsigned long alter_menu2_mask = CWEventMask | CWBackPixel | CWSaveUnder |
  861. X                     CWBackingStore | CWWinGravity;
  862. X    XSizeHints win_size_hints;
  863. X    Cursor the_cursor, menu_cursor;
  864. X    XColor scrn_def_ret, exact_def_ret, scrn_def_ret2, exact_def_ret2;
  865. X    XColor curs_foregrexact, curs_foregr, curs_backgr, curs_backgrexact;
  866. X    Pixmap source, mask;
  867. X    int i, j, k, menu_num;
  868. X    int menu_x_val;
  869. X    XWindowAttributes attr_ret;
  870. X    XFontStruct *the_font_struct;
  871. X    char tmp_str[50], tmp_str2[50];
  872. X    XGCValues cursor_gc_values;
  873. X
  874. X    menu_text[0] = menu_text0;   /*connect the menu text to the global struct*/
  875. X    menu_text[1] = menu_text1;
  876. X    menu_text[2] = menu_text2;
  877. X    menu_text[3] = menu_text3;
  878. X    menu_text[4] = menu_text4;
  879. X    menu_text[5] = menu_text5;
  880. X    menu_text[6] = menu_text6;
  881. X
  882. X    for (i=0; i<MAX_NUM_DISPS; i++)
  883. X        disp_info[i].in_session_bool = FALSE;
  884. X
  885. X    for (i=0; i<num_of_disps; i++)
  886. X        disp_info[i].in_session_bool = TRUE;
  887. X
  888. X    /*
  889. X     * The following opens all the displays and windows and initializes some
  890. X     * of the disp_info fields.  The cursor is defined for the window, and
  891. X     * the window manager is instructed how to behave with these new windows.
  892. X     */
  893. X    for (i=0; i<num_of_disps; i++)
  894. X    { 
  895. X    if (i==0)     /*open home display*/
  896. X    {
  897. X        if (disp_info[0].in_session_bool)/*only if this session is wanted*/
  898. X        {
  899. X                if (strcmp(disp_args[0], "") == 0) /*not written into yet*/
  900. X        {
  901. X                    if ((disp_info[0].disp = XOpenDisplay(NULL)) == NULL)
  902. X                    {
  903. X                       printf("XOpenDisplay failed on DISPLAY env variable.\n");
  904. X                   disp_info[0].in_session_bool = FALSE; /*not in session*/
  905. X               if (num_of_disps <= 1)
  906. X               exit(0);         /*bag it*/
  907. X               else
  908. X               continue;
  909. X                    }
  910. X                else
  911. X               strncpy(disp_args[0], 
  912. X                DisplayString(disp_info[0].disp), 30);
  913. X        }
  914. X                else if ((disp_info[0].disp=XOpenDisplay(disp_args[0]))== NULL)
  915. X                {
  916. X                   printf("XOpenDisplay failed on display: %s\n",disp_args[0]);
  917. X                   exit(0);
  918. X                }
  919. X        }
  920. X    }
  921. X    else         /*open this particular away display*/
  922. X    {
  923. X        if (disp_info[i].in_session_bool)/*only if this session is wanted*/
  924. X        {
  925. X                if ((disp_info[i].disp = XOpenDisplay (disp_args[i])) == NULL)
  926. X                {
  927. X                   printf("XOpenDisplay failed on display: %s\n", disp_args[i]);
  928. X                   exit(0);
  929. X                }
  930. X        }
  931. X        }
  932. X
  933. X    if (disp_info[i].in_session_bool)  /*only if this session is wanted*/
  934. X    {
  935. X        winvals.backing_store = Always;
  936. X            if (!XAllocNamedColor(disp_info[i].disp, 
  937. X        DefaultColormap(disp_info[i].disp, 
  938. X            DefaultScreen(disp_info[i].disp)), BACKGROUND_COLOR, 
  939. X            &scrn_def_ret, &exact_def_ret))
  940. X            {
  941. X             printf("\nThe color %s is not supported", BACKGROUND_COLOR);
  942. X             printf(" on the display %s.\n", disp_args[i]);
  943. X             exit(0);
  944. X        }
  945. X        winvals.background_pixel = scrn_def_ret.pixel;
  946. X        winvals.bit_gravity = NorthWestGravity;
  947. X            disp_info[i].background = scrn_def_ret.pixel;
  948. X
  949. X        disp_info[i].win_id = XCreateWindow(disp_info[i].disp, RootWindow(
  950. X          disp_info[i].disp, DefaultScreen(disp_info[i].disp)), 
  951. X          5+(i*80), 5+(i*80), WSCRAWL_WIN_WIDTH, WSCRAWL_WIN_HEIGHT, 3,
  952. X          0,CopyFromParent,CopyFromParent,alter_these2_mask, &winvals);
  953. X
  954. X
  955. X            disp_info[i].win_gc = (GC *) malloc(num_of_disps * sizeof(GC));
  956. X
  957. X        disp_info[i].connection_num = ConnectionNumber(disp_info[i].disp);
  958. X            disp_info[i].first_point_bool = FALSE;
  959. X            disp_info[i].pointer_state = NOT_PRESSED;
  960. X        disp_info[i].scrawl_mode = SCRAWLING;
  961. X        disp_info[i].current_shape = OUTLINE_RECT;
  962. X            disp_info[i].type_history = NULL;
  963. X            disp_info[i].just_placed_something_bool = FALSE;
  964. X
  965. X        cursor_gc_values.line_width = 5;
  966. X        cursor_gc_values.function = GXinvert;
  967. X        cursor_gc_values.background =  BlackPixelOfScreen(
  968. X                       DefaultScreenOfDisplay(disp_info[i].disp));
  969. X            cursor_gc_values.foreground =  WhitePixelOfScreen(
  970. X                       DefaultScreenOfDisplay(disp_info[i].disp));
  971. X            disp_info[i].cursor_gc = XCreateGC(disp_info[i].disp, 
  972. X                  disp_info[i].win_id,
  973. X                  GCFunction | GCBackground | GCForeground | GCLineWidth, 
  974. X              &cursor_gc_values);
  975. X
  976. X            if (!TYPE_NOT_DRAW)
  977. X                the_cursor = XCreateFontCursor(disp_info[i].disp, XC_dot);
  978. X
  979. X            XDefineCursor(disp_info[i].disp, disp_info[i].win_id, the_cursor);
  980. X
  981. X        win_size_hints.flags = USPosition | PPosition;
  982. X        win_size_hints.x = 5 + (i * 80);
  983. X        win_size_hints.y = 5 + (i * 80);
  984. X
  985. X        XSetStandardProperties(disp_info[i].disp, disp_info[i].win_id, 
  986. X            "WSCRAWL: a product of eXcess engineering", "wscrawl", None, 
  987. X        NULL, 0, &win_size_hints);
  988. X
  989. X        /* the following three calls are to change window manager behavior*/
  990. X            disp_info[i].xa_WM_PROTOCOLS = XInternAtom(disp_info[i].disp, 
  991. X                           "WM_PROTOCOLS", FALSE);
  992. X            disp_info[i].xa_WM_DELETE_WINDOW = XInternAtom(disp_info[i].disp, 
  993. X                                "WM_DELETE_WINDOW", FALSE);
  994. X            XChangeProperty(disp_info[i].disp, disp_info[i].win_id, 
  995. X            disp_info[i].xa_WM_PROTOCOLS, 
  996. X            disp_info[i].xa_WM_PROTOCOLS, 32, PropModeReplace,
  997. X                (char *) &(disp_info[i].xa_WM_DELETE_WINDOW), 1);
  998. X    }
  999. X    }
  1000. X
  1001. X    /*
  1002. X     * The following changes the names in the "disp_args[]" array to reflect
  1003. X     * the ACTUAL machine and display instead of things like "local:0" etc.
  1004. X     */
  1005. X    for (i=0; i<num_of_disps; i++)
  1006. X    { 
  1007. X    if (disp_info[i].in_session_bool)  /*only if this session is wanted*/
  1008. X    {
  1009. X            if ((strncmp(disp_args[i], "local", 5) == 0) ||
  1010. X                (strncmp(disp_args[i], "unix", 4) == 0) ||
  1011. X                (strncmp(disp_args[i], ":", 1) == 0))
  1012. X        {
  1013. X                /*
  1014. X             * this is a wscrawl window on the invoker's home display, so
  1015. X             * change it to be meaningful.
  1016. X             */
  1017. X                gethostname(tmp_str, 30);
  1018. X                sprintf(tmp_str2, "%s%s", tmp_str, strpbrk(disp_args[i], ":"));
  1019. X                strncpy(disp_args[i], tmp_str2, 30);
  1020. X        }
  1021. X    }
  1022. X    }
  1023. X
  1024. X    /*
  1025. X     * The following initializes the win_gc's for all the displays.
  1026. X     */
  1027. X    for (i=0; i<num_of_disps; i++)
  1028. X    { 
  1029. X    if (disp_info[i].in_session_bool)  /*only if this session is wanted*/
  1030. X    {
  1031. X        /*
  1032. X         * The following assigns this "user" N graphics contexts, where N
  1033. X         * is the number of open displays.  This "user" wants his particular
  1034. X         * color on every display, and since gc's are attached to displays,
  1035. X         * we need one with this color loaded on every display.  These gc's
  1036. X         * are then used for pen width, pen caps, etc.
  1037. X         */
  1038. X        strncpy(disp_info[i].pen_color_str, PEN_COLOR, 40);
  1039. X        strncpy(disp_info[i].font_str, FONT, 250);
  1040. X        disp_info[i].capstyle = CAP_STYLE;
  1041. X
  1042. X        for (j=0; j<num_of_disps; j++)
  1043. X        {
  1044. X            if (disp_info[j].in_session_bool) /*only if session is wanted*/
  1045. X            {
  1046. X                    if (XAllocNamedColor(disp_info[j].disp, DefaultColormap(
  1047. X                 disp_info[j].disp, DefaultScreen(disp_info[j].disp)), 
  1048. X                 PEN_COLOR, &scrn_def_ret, &exact_def_ret))
  1049. X                {
  1050. X                ;  /*great!  it worked!*/
  1051. X                }
  1052. X                else if (!XAllocNamedColor(disp_info[j].disp, 
  1053. X             DefaultColormap(
  1054. X                 disp_info[j].disp, DefaultScreen(disp_info[j].disp)), 
  1055. X                 "black", &scrn_def_ret, &exact_def_ret))
  1056. X                {
  1057. X                    printf("The color %s is not", PEN_COLOR);
  1058. X                    printf(" supported on the display %s.\n", disp_args[i]);
  1059. X                    exit(0);
  1060. X                }
  1061. X                    gcvalues.foreground = scrn_def_ret.pixel;
  1062. X        
  1063. X                    gcvalues.background =
  1064. X                     WhitePixelOfScreen(DefaultScreenOfDisplay(
  1065. X                             disp_info[j].disp));
  1066. X    
  1067. X            gcvalues.line_width = PEN_WIDTH;
  1068. X                    gcvalues.cap_style = CAP_STYLE;
  1069. X                    gcvalues.graphics_exposures = False;
  1070. X        
  1071. X                    if ((the_font_struct = XLoadQueryFont(disp_info[j].disp, 
  1072. X             FONT)) != NULL)
  1073. X                {
  1074. X                     gcvalues.font = the_font_struct->fid;
  1075. X                }
  1076. X                else if ((the_font_struct=XLoadQueryFont(disp_info[j].disp,
  1077. X                "fixed")) != NULL)
  1078. X                {
  1079. X                     printf("WARNING: Couldn't allocate font: %s", FONT);
  1080. X                     printf(" on display %s.  Using fixed.\n",disp_args[j]);
  1081. X                     gcvalues.font = the_font_struct->fid;
  1082. X                }
  1083. X                else
  1084. X                {
  1085. X                    printf("\nERROR: Couldn't allocate a font ");
  1086. X                printf("on display: %s.\n", disp_args[j]);
  1087. X                    exit(0);
  1088. X                    }
  1089. X        
  1090. X                    disp_info[i].win_gc[j] = XCreateGC(disp_info[j].disp, 
  1091. X                     disp_info[j].win_id, alter_these_mask, &gcvalues);
  1092. X                disp_info[i].the_font_struct = the_font_struct;
  1093. X            }
  1094. X            }
  1095. X    }
  1096. X    }
  1097. X    
  1098. X    /*
  1099. X     * create the rubber_band_gc's for all the scrawl windows
  1100. X     */
  1101. X    for (i=0; i<num_of_disps; i++)
  1102. X    { 
  1103. X    if (disp_info[i].in_session_bool)  /*only if this session is wanted*/
  1104. X    {
  1105. X        gcvalues.function = GXinvert;
  1106. X        gcvalues.line_width = 0;
  1107. X            disp_info[i].rubber_band_gc = XCreateGC(disp_info[i].disp, 
  1108. X         disp_info[i].win_id, GCLineWidth | GCFunction, &gcvalues);
  1109. X    }
  1110. X    }
  1111. X
  1112. X    /*
  1113. X     * create and initialize the menus on each scrawl window
  1114. X     */
  1115. X    for (i=0; i<num_of_disps; i++)
  1116. X    { 
  1117. X    if (disp_info[i].in_session_bool)  /*only if this session is wanted*/
  1118. X    {
  1119. X        for (menu_num=0; menu_num<NUM_OF_MENUS; menu_num++)
  1120. X        {
  1121. X                if (XAllocNamedColor(disp_info[i].disp, 
  1122. X            DefaultColormap(disp_info[i].disp, 
  1123. X                DefaultScreen(disp_info[i].disp)), MENU_BACKGROUND_COLOR, 
  1124. X                &scrn_def_ret, &exact_def_ret))
  1125. X                {
  1126. X                menuwinvals.background_pixel = scrn_def_ret.pixel;
  1127. X            }
  1128. X                else if (XAllocNamedColor(disp_info[i].disp, 
  1129. X            DefaultColormap(disp_info[i].disp, 
  1130. X                DefaultScreen(disp_info[i].disp)), "white", 
  1131. X                &scrn_def_ret, &exact_def_ret))
  1132. X                {
  1133. X                printf("The color %s is not", MENU_BACKGROUND_COLOR);
  1134. X                printf(" supported on display %s.\n", disp_args[i]);
  1135. X                printf("Using white for the menu background color.\n");
  1136. X            strcpy(MENU_BACKGROUND_COLOR, "white");
  1137. X                menuwinvals.background_pixel = scrn_def_ret.pixel;
  1138. X            }
  1139. X            else
  1140. X            {
  1141. X                printf("The menu background color had extra problems on");
  1142. X            printf(" display %s.\n", disp_args[i]);
  1143. X            exit(0);
  1144. X                }
  1145. X    
  1146. X            menu_x_val = menu_num*MENU_ITEM_WIDTH + (menu_num*2);
  1147. X    
  1148. X            /* uncomment this line to reproduce HP backingstore bug
  1149. X            menuwinvals.backing_store = Always;
  1150. X                 */
  1151. X    
  1152. X            menuwinvals.save_under = True;
  1153. X            disp_info[i].menu[menu_num].win_id =
  1154. X             XCreateWindow(disp_info[i].disp, disp_info[i].win_id, 
  1155. X               menu_x_val, 0, MENU_ITEM_WIDTH, MENU_ITEM_HEIGHT, 2, 
  1156. X               0, CopyFromParent, CopyFromParent, alter_menu2_mask, 
  1157. X               &menuwinvals);
  1158. X                XMapWindow(disp_info[i].disp,
  1159. X                disp_info[i].menu[menu_num].win_id);
  1160. X    
  1161. X            menu_cursor =XCreateFontCursor(disp_info[i].disp,XC_right_ptr);
  1162. X            XDefineCursor(disp_info[i].disp, 
  1163. X                disp_info[i].menu[menu_num].win_id, menu_cursor);
  1164. X    
  1165. X            disp_info[i].menu[menu_num].item_selected = NO_ITEM_SELECTED;
  1166. X            }
  1167. X    
  1168. X        /*
  1169. X         * find the num of items in each menu and assign it to the correct
  1170. X         * variable in the structure. "k" is the menu_item_num.
  1171. X         */
  1172. X        for (menu_num=0; menu_num < NUM_OF_MENUS; menu_num++)
  1173. X        {
  1174. X            for (k=0; strcmp(menu_text[menu_num][k], "****") != 0; k++)
  1175. X                ;
  1176. X                disp_info[i].menu[menu_num].num_items = k;
  1177. X        switch(menu_num)
  1178. X        {
  1179. X            case 0:                   /*Control menu*/
  1180. X                disp_info[i].menu[menu_num].checked_item = 1;
  1181. X            break;
  1182. X            case 1:                   /*PenColor menu*/
  1183. X                disp_info[i].menu[menu_num].checked_item = 2;
  1184. X            break;
  1185. X            case 2:                   /*PenWidth menu*/
  1186. X                disp_info[i].menu[menu_num].checked_item = 4;
  1187. X            break;
  1188. X            case 3:                   /*PenCapStyle menu*/
  1189. X                disp_info[i].menu[menu_num].checked_item = 1;
  1190. X            break;
  1191. X            case 4:                   /*Font menu*/
  1192. X                disp_info[i].menu[menu_num].checked_item = 14;
  1193. X            break;
  1194. X            case 5:                   /*Shapes menu*/
  1195. X                disp_info[i].menu[menu_num].checked_item = 2;
  1196. X            break;
  1197. X            default:
  1198. X            break;
  1199. X        }
  1200. X            }
  1201. X    
  1202. X            if (!XAllocNamedColor(disp_info[i].disp, 
  1203. X            DefaultColormap(disp_info[i].disp, 
  1204. X                DefaultScreen(disp_info[i].disp)), MENU_HIGHLIGHT_COLOR, 
  1205. X                &scrn_def_ret, &exact_def_ret))
  1206. X            {
  1207. X                printf("The color %s is not", MENU_HIGHLIGHT_COLOR);
  1208. X                printf(" supported on the display %s.\n", disp_args[i]);
  1209. X                exit(0);
  1210. X            }
  1211. X            menugcvalues.foreground = scrn_def_ret.pixel;
  1212. X    
  1213. X            if (!XAllocNamedColor(disp_info[i].disp, 
  1214. X            DefaultColormap(disp_info[i].disp, 
  1215. X            DefaultScreen(disp_info[i].disp)), MENU_BACKGROUND_COLOR, 
  1216. X            &scrn_def_ret2, &exact_def_ret2))
  1217. X            {
  1218. X            printf("The menu background color had second round problems ");
  1219. X                printf("on the display %s.\n", disp_args[i]);
  1220. X            exit(0);
  1221. X            }
  1222. X    
  1223. X            menugcvalues.background = scrn_def_ret2.pixel;
  1224. X    
  1225. X            menugcvalues.line_width = 2;
  1226. X            menugcvalues.font = XLoadFont(disp_info[i].disp, "fixed");
  1227. X        disp_info[i].hi_menu_gc = XCreateGC(disp_info[i].disp, 
  1228. X              disp_info[i].menu[0].win_id, alter_menu_mask, &menugcvalues);
  1229. X    
  1230. X        /*
  1231. X         * switch foreground and background colors for bg_menu_gc
  1232. X         */
  1233. X            menugcvalues.foreground = scrn_def_ret2.pixel;
  1234. X            menugcvalues.background = scrn_def_ret.pixel;
  1235. X        disp_info[i].bg_menu_gc = XCreateGC(disp_info[i].disp, 
  1236. X              disp_info[i].menu[0].win_id, alter_menu_mask, &menugcvalues);
  1237. X    
  1238. X            if (!XAllocNamedColor(disp_info[i].disp, 
  1239. X            DefaultColormap(disp_info[i].disp, 
  1240. X                DefaultScreen(disp_info[i].disp)), MENU_FOREGROUND_COLOR, 
  1241. X                &scrn_def_ret, &exact_def_ret))
  1242. X            {
  1243. X                printf("The color %s is not", MENU_FOREGROUND_COLOR);
  1244. X                printf(" supported on the display %s.\n", disp_args[i]);
  1245. X                exit(0);
  1246. X            }
  1247. X            menugcvalues.foreground = scrn_def_ret.pixel;
  1248. X            menugcvalues.background = scrn_def_ret2.pixel;
  1249. X        disp_info[i].fg_menu_gc = XCreateGC(disp_info[i].disp, 
  1250. X            disp_info[i].menu[0].win_id, alter_menu_mask, &menugcvalues);
  1251. X    
  1252. X        for (menu_num=0; menu_num<NUM_OF_MENUS; menu_num++)
  1253. X        {
  1254. X            disp_info[i].current_menu = menu_num;
  1255. X            draw_menu(i);
  1256. X        }
  1257. X        }
  1258. X    }
  1259. X    
  1260. X    /*
  1261. X     * create the status window and eraser window, and dialog window for 
  1262. X     * each scrawl window 
  1263. X     */
  1264. X    for (i=0; i<num_of_disps; i++)
  1265. X    { 
  1266. X    if (disp_info[i].in_session_bool)  /*only if this session is wanted*/
  1267. X    {
  1268. X            if (!XAllocNamedColor(disp_info[i].disp, 
  1269. X        DefaultColormap(disp_info[i].disp, 
  1270. X            DefaultScreen(disp_info[i].disp)), MENU_BACKGROUND_COLOR, 
  1271. X            &scrn_def_ret, &exact_def_ret))
  1272. X            {
  1273. X            printf("The color %s is not", MENU_BACKGROUND_COLOR);
  1274. X            printf(" supported on the display %s.\n", disp_args[i]);
  1275. X            exit(0);
  1276. X            }
  1277. X            menuwinvals.background_pixel = scrn_def_ret.pixel;
  1278. X            menuwinvals.save_under = True;
  1279. X        disp_info[i].eraser_win_id = XCreateWindow(disp_info[i].disp,
  1280. X           disp_info[i].win_id, 0, 350, 550, 20, 2, 0, CopyFromParent, 
  1281. X           CopyFromParent, alter_menu2_mask, &menuwinvals);
  1282. X        disp_info[i].status_win_id = XCreateWindow(disp_info[i].disp,
  1283. X           disp_info[i].win_id, 0, 350, 550, 20, 2, 0, CopyFromParent, 
  1284. X           CopyFromParent, alter_menu2_mask, &menuwinvals);
  1285. X        disp_info[i].dialog_win_id = XCreateWindow(disp_info[i].disp,
  1286. X           disp_info[i].win_id, 50, 80, DIALOG_WIN_WIDTH, 
  1287. X           DIALOG_WIN_HEIGHT, 2, 0, CopyFromParent, 
  1288. X           CopyFromParent, alter_menu2_mask, &menuwinvals);
  1289. X            XMapWindow(disp_info[i].disp, disp_info[i].status_win_id);
  1290. X        XDefineCursor(disp_info[i].disp, disp_info[i].status_win_id,
  1291. X              XCreateFontCursor(disp_info[i].disp, XC_star));
  1292. X        XDefineCursor(disp_info[i].disp, disp_info[i].eraser_win_id,
  1293. X              XCreateFontCursor(disp_info[i].disp, XC_draped_box));
  1294. X        XDefineCursor(disp_info[i].disp, disp_info[i].dialog_win_id,
  1295. X              XCreateFontCursor(disp_info[i].disp, XC_xterm));
  1296. X        XLowerWindow(disp_info[i].disp, disp_info[i].eraser_win_id);
  1297. X        }
  1298. X    }
  1299. X
  1300. X    /*
  1301. X     * if typing, set cursor, font, etc correctly with a call to 
  1302. X     * menu_selection (which is usually called when you pull down a menu).
  1303. X     */
  1304. X    for (i=0; i<num_of_disps; i++)
  1305. X    {
  1306. X    if (disp_info[i].in_session_bool)  /*only if this session is wanted*/
  1307. X    {
  1308. X            if (TYPE_NOT_DRAW)
  1309. X                 menu_selection(i, 0, num_people_drawing, 3);
  1310. X    }
  1311. X    }
  1312. X
  1313. X    /*
  1314. X     * create the "pause cursor" for each display
  1315. X     */
  1316. X    for (i=0; i<num_of_disps; i++)
  1317. X    {
  1318. X    if (disp_info[i].in_session_bool)  /*only if this session is wanted*/
  1319. X    {
  1320. X            source = XCreatePixmapFromBitmapData(disp_info[i].disp, 
  1321. X          disp_info[i].win_id, pause_curs_bits, pause_curs_width, 
  1322. X          pause_curs_height, 
  1323. END_OF_FILE
  1324. if test 39069 -ne `wc -c <'wscrawl/xae'`; then
  1325.     echo shar: \"'wscrawl/xae'\" unpacked with wrong size!
  1326. fi
  1327. # end of 'wscrawl/xae'
  1328. fi
  1329. if test -f 'wscrawl/xaf' -a "${1}" != "-c" ; then 
  1330.   echo shar: Will not clobber existing file \"'wscrawl/xaf'\"
  1331. else
  1332. echo shar: Extracting \"'wscrawl/xaf'\" \(4708 characters\)
  1333. sed "s/^X//" >'wscrawl/xaf' <<'END_OF_FILE'
  1334. X          WhitePixel(disp_info[i].disp, DefaultScreen(disp_info[i].disp)), 
  1335. X          BlackPixel(disp_info[i].disp, DefaultScreen(disp_info[i].disp)), 
  1336. X          1);
  1337. X
  1338. X            mask = XCreatePixmapFromBitmapData(disp_info[i].disp, 
  1339. X          disp_info[i].win_id, pause_curs_bits, pause_curs_width, 
  1340. X          pause_curs_height, 
  1341. X          WhitePixel(disp_info[i].disp, DefaultScreen(disp_info[i].disp)), 
  1342. X          BlackPixel(disp_info[i].disp, DefaultScreen(disp_info[i].disp)), 
  1343. X          1);
  1344. X
  1345. X        XAllocNamedColor(disp_info[i].disp, DefaultColormapOfScreen(
  1346. X                 DefaultScreenOfDisplay(disp_info[i].disp)),
  1347. X             "white", &curs_backgr, &curs_backgrexact);
  1348. X        XAllocNamedColor(disp_info[i].disp, DefaultColormapOfScreen(
  1349. X                 DefaultScreenOfDisplay(disp_info[i].disp)),
  1350. X             "black", &curs_foregr, &curs_foregrexact);
  1351. X
  1352. X            disp_info[i].pause_cursor = XCreatePixmapCursor(disp_info[i].disp, 
  1353. X              source, mask, &curs_foregrexact, &curs_backgrexact, 
  1354. X              pause_curs_x_hot, pause_curs_y_hot);
  1355. X     }
  1356. X    }
  1357. X
  1358. X    /*
  1359. X     * create the rubber cursor pixmaps for all the displays
  1360. X     */
  1361. X    for (i=0; i<num_of_disps; i++)
  1362. X    {
  1363. X    if (disp_info[i].in_session_bool)  /*only if this session is wanted*/
  1364. X    {
  1365. X            the_font_struct = XLoadQueryFont(disp_info[i].disp, "fixed");
  1366. X            disp_info[i].rubber_pointer.width = 15 + XTextWidth(the_font_struct,
  1367. X                                  disp_args[i], strlen(disp_args[i]));
  1368. X            disp_info[i].rubber_pointer.height =
  1369. X                   15 + the_font_struct->max_bounds.ascent + 
  1370. X                   the_font_struct->max_bounds.descent;
  1371. X            disp_info[i].rubber_pointer.is_mapped_bool = FALSE;
  1372. X
  1373. X            for (j=0; j<num_of_disps; j++)
  1374. X            {
  1375. X            if (disp_info[j].in_session_bool)
  1376. X            {
  1377. X                disp_info[i].rubber_pointer.rubber_pointer_pix[j] = 
  1378. X                 XCreatePixmap(
  1379. X                     disp_info[j].disp, disp_info[j].win_id,
  1380. X                                 disp_info[i].rubber_pointer.width, 
  1381. X                     disp_info[i].rubber_pointer.height, 
  1382. X                     DefaultDepth(disp_info[j].disp, 
  1383. X                     DefaultScreen(disp_info[j].disp)));
  1384. X                }
  1385. X        }
  1386. X    }
  1387. X    }
  1388. X
  1389. X    /*
  1390. X     * set the default penwidths
  1391. X     */
  1392. X    for (i=0; i<num_of_disps; i++)
  1393. X    { 
  1394. X    if (disp_info[i].in_session_bool)  /*only if this session is wanted*/
  1395. X    {
  1396. X        disp_info[i].pen_widths.scrawl = 8;
  1397. X        disp_info[i].pen_widths.airbrush = 40;
  1398. X        disp_info[i].pen_widths.eraser = 40;
  1399. X        disp_info[i].pen_widths.shape = 8;
  1400. X    }
  1401. X    }
  1402. X
  1403. X    /*
  1404. X     * bring all the windows up with all this fun new information.
  1405. X     */
  1406. X    for (i=0; i<num_of_disps; i++)
  1407. X    { 
  1408. X    if (disp_info[i].in_session_bool)  /*only if this session is wanted*/
  1409. X    {
  1410. X        XMapWindow(disp_info[i].disp, disp_info[i].win_id);
  1411. X            XSync(disp_info[i].disp, False);
  1412. X    }
  1413. X    }
  1414. X
  1415. X    for (i=0; i<num_of_disps; i++)
  1416. X    {
  1417. X    if (disp_info[i].in_session_bool)  /*only if this session is wanted*/
  1418. X        place_and_draw_status_win(i);
  1419. X    }
  1420. X
  1421. X    for (i=0; i<num_of_disps; i++)
  1422. X    { 
  1423. X    if (disp_info[i].in_session_bool)  /*only if this session is wanted*/
  1424. X    {
  1425. X            XGetWindowAttributes(disp_info[i].disp, disp_info[i].win_id,
  1426. X                 &attr_ret);
  1427. X        disp_info[i].win_width = attr_ret.width;
  1428. X        disp_info[i].win_height = attr_ret.height;
  1429. X        }
  1430. X    }
  1431. X    NOTHING_DRAWN_YET = TRUE;
  1432. X}
  1433. X
  1434. X
  1435. X/*
  1436. X * airbrush - this function draws a "spray can" type stipple on the window
  1437. X *            window passed as an argument.  Thanks to Mark Cook for supplying
  1438. X *            this algorithm.
  1439. X */
  1440. Xairbrush(input_disp, disp, win, win_gc, win_x, win_y)
  1441. XDisplay *disp;
  1442. XWindow win; 
  1443. XGC win_gc;
  1444. Xint win_x, win_y;
  1445. X{
  1446. X    int i, rx, ry, RADIUS;
  1447. X    XPoint spray_points[502];
  1448. X
  1449. X    RADIUS = (disp_info[input_disp].pen_width)/2;
  1450. X
  1451. X    for (i=0; i<NUM_DOTS; i++)
  1452. X    {
  1453. X        rx = (my_rand()*RADIUS) - (my_rand()*RADIUS);
  1454. X        ry = (my_rand()*RADIUS) - (my_rand()*RADIUS);
  1455. X        if (rx < (-RADIUS))
  1456. X        rx = (-RADIUS);
  1457. X        if (rx > (RADIUS))
  1458. X        rx = RADIUS;
  1459. X        if (ry < (-RADIUS))
  1460. X        ry = (-RADIUS);
  1461. X        if (ry > (RADIUS))
  1462. X        ry = RADIUS;
  1463. X        spray_points[i].x = win_x + rx;
  1464. X        spray_points[i].y = win_y + ry;
  1465. X    }
  1466. X    XDrawPoints(disp, win, win_gc, spray_points, NUM_DOTS, CoordModeOrigin);
  1467. X}
  1468. X
  1469. X
  1470. X/*
  1471. X * my_rand - NOTE: THIS MAY REQUIRE A PORT: due to the non-standard "rand"
  1472. X *           function, this routine is not entirely portable.  The reason
  1473. X *           this function is here is to allow you to hack on it to get it
  1474. X *           to return a value between 0 and 1.  This only affects the 
  1475. X *           airbrush.
  1476. X */
  1477. Xfloat my_rand()
  1478. X{
  1479. X    float ret_val;
  1480. X
  1481. X    ret_val = (float) ((double)rand()/(double)MAX_RAND);
  1482. X
  1483. X    if (ret_val > 1.0)
  1484. X        ret_val = (ret_val - ((float) (1 * ((int) ret_val))));
  1485. X
  1486. X    return(ret_val);
  1487. X}
  1488. X
  1489. END_OF_FILE
  1490. if test 4708 -ne `wc -c <'wscrawl/xaf'`; then
  1491.     echo shar: \"'wscrawl/xaf'\" unpacked with wrong size!
  1492. fi
  1493. # end of 'wscrawl/xaf'
  1494. fi
  1495. echo shar: End of archive 1 \(of 5\).
  1496. cp /dev/null ark1isdone
  1497. MISSING=""
  1498. for I in 1 2 3 4 5 ; do
  1499.     if test ! -f ark${I}isdone ; then
  1500.     MISSING="${MISSING} ${I}"
  1501.     fi
  1502. done
  1503. if test "${MISSING}" = "" ; then
  1504.     echo You have unpacked all 5 archives.
  1505.     rm -f ark[1-9]isdone
  1506. else
  1507.     echo You still need to unpack the following archives:
  1508.     echo "        " ${MISSING}
  1509. fi
  1510. ##  End of shell archive.
  1511. exit 0
  1512. dan
  1513. ----------------------------------------------------
  1514. O'Reilly && Associates   argv@sun.com / argv@ora.com
  1515. Opinions expressed reflect those of the author only.
  1516.