You should have read Chapter 13.1 - 13.3 in Nye and O'Reilly, Vol. 4, before starting this exercise.
How does the behavior change if you print to stdout instead? Explain.
Start by implementing the mechanism to pop up the dialog, but not to pop it back down. You will need to add the header files for both the Dialog widget class and X11's Shell.h file. Call the shell for your popup dshell and the dialog widget itself, input_dialog. Mimic the book's Example 3-6, but in the simplest possible way: all you will need to add are the lines to create dshell and input_dialog, plus a call to XtPopup in the callback for your button; no new resource settings are needed. At this point, don't worry about desensitizing the buttons, popping the dialog down, or positioning it. Compile and run your code in the foreground (so you can kill it with Control-C).
What factors determined the size and placement of the popup?
Why can't you continue interacting with the application?
Try using XtGrabNone instead of XtGrabNonexclusive.
How does that change the application's behavior?
Traditionally, buttons in the main window are desensitized (dimmed) and the keyboard focus is "grabbed" by a dialog, whenever the user's response to a dialog are critical before the application can continue. This is a modal dialog. If the dialog provides supplementary information that the user might want to continue viewing, the keyboard focus is not grabbed and buttons are not dimmed; such a dialog is referred to as non-modal.
If the function of your dialog is to change the file being viewed, should the dialog be modal or non-modal?
Implement the correct modality in your program.
Another difference between Done and Cancel is that cancelling a dialog will "ignore" any text editing the user has done.
Right now, what controls the contents of the text input field the first time the dialog is popped up? For subsequent displaying of the dialog?
Modify your program so that any previously assigned string value is restored whenever Cancel is selected instead of Done.
What happens if the user moves the application so it's in the lower right side of the screen, then clicks the cursor from a position low in the window?
Fix this problem by adding code which checks to make sure that there is room to display the whole popup. If not, modify the position so that the whole popup is visible.
What resource setting accomplished this?
Why did the constraints have to be hard-coded rather than being in the defaults file?
Which is it? Were you able to add it via the defaults file, or did it have to be hard-coded?