================================================================================ 
The xedit and altfontsel illustrate use of tooltalk in more realistic
applications.  This exercise demonstrates how to modify a message, and
provides some experience with static types.

The xedit program is basically the x window distribution xedit,
with additions made for tooltalk interaction, and the altfontsel program
knows how to handle requests for font selection.  

The 'before' version of xedit allows you to change the font used.  However 
the altfontsel font selector does not show xedit's current default font
when it comes up.  The 'after' version modifies xedit and altfontsel such that
xedit sends along its current font when sending a GetFontName request.  Altfontsel
then uses this to set it's current selection.

The diffs file shows the differences between the before and after versions.

================================================================================ 
To try the programs, perform the following steps.

1. cd to the before/altfontsel directory.

2. enter tt_type_comp altfontsel.ptype  (this compiles the type file for altfontsel)

3. do a ps -ef | grep ttsession to find the pid of ttsession (Don't do this under
   a process tree session as xedit wants to use the ttsession for X) Have ttsession
   re-read the types database by performing kill -USR2 <ttsessions_PID>.

4. cd to ../xedit and run this xedit (./xedit)

5. Enter a bit of text into xedit, then click on change font.

6. Select a new font when altfontsel appears, then select apply.  Play around
   with this xedit/altfontsel combination to get a feel for its operation.
   Try running multiple xedits and performing changefonts in both at the same time.
   Manually start an altfontsel and see what happens.  Quit the altfontsels.
   Note the behavior of the altfontsels when started or when a request if received.

7. Quit all the xedits and altfontsels.

8. cd to  ../../after/altfontsel, and repeat steps 2 through 7

================================================================================ 
SUGGESTED EXCERCISES:

Non code Exercises:

A.  Run ttsnoop to watch the messages that flow.
    Use ttsnoop to manually construct GetFontName messages.

B. Turn on the trace for the ttsession involved and watch 
   it work. {ps -ef | grep ttsession, then kill -USR1 <ttsession_pid>}

C. Try clicking change font a bunch of times and see what happens.   Can you explain
   what's happening? (hint: 'ptype-blocking', TT_WRN_START_MESSAGE)


Non code-modifying Exercises:

D. Examine the code for the programs.  Try to determine the flow of control.

E. What would happen if xedit's FinishChangeFont function didn't return TT_CALLBACK_PROCESSED?


Code-modifying Exercises:

F. Try to apply tt_message_accept() to change the behavior seen in C.

G. Add code to close down altfontsel when xedit exits. 

H.  Arrange it so each xedit uses its own dedicated altfontsel.

I. Add code and modify the type file so that altfontsel can deal with
   both the 'before' and 'after' kinds of xedit.

J. Add code to tell the user that xedit is waiting for altfontsel to start 
   (base it on message states).


 
