1 XCOMM! CDE_INSTALLATION_TOP/bin/dtksh
2 XCOMM $XConsortium: SessionTest.src /main/6 1996/04/23 20:18:46 drk $
4 XCOMM #########################################################################
5 XCOMM (c) Copyright 1993, 1994 Hewlett-Packard Company
6 XCOMM (c) Copyright 1993, 1994 International Business Machines Corp.
7 XCOMM (c) Copyright 1993, 1994 Sun Microsystems, Inc.
8 XCOMM (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
10 XCOMM #########################################################################
14 XCOMM This sample shell script demonstrates the steps necessary for tying into
15 XCOMM session management. To run, simply run this script, and then save the
16 XCOMM current session. When the session is restored, this script should again
17 XCOMM restore to its previous state.
21 XCOMM This function is invoked when the user attempts to save the current session.
22 XCOMM It will save off its state information (whether it is iconified, and the
23 XCOMM list of workspaces it occupies) into a session file, and then tell the
24 XCOMM session manager how to reinvoke it when the session is restored.
27 XCOMM Get the name of our session file
28 if DtSessionSavePath $TOPLEVEL PATH SAVEFILE; then
31 XCOMM Save our iconification state
32 if DtShellIsIconified $TOPLEVEL ; then
35 print -u9 'Deiconified'
38 XCOMM Save the list of workspace we occupy
39 if DtWsmGetWorkspacesOccupied $(XtDisplay "-" $TOPLEVEL) \
40 $(XtWindow "-" $TOPLEVEL) \
45 for item in $CURRENT_WS_LIST;
47 XmGetAtomName NAME $(XtDisplay "-" $TOPLEVEL) $item
55 XCOMM Tell the session manager how to restart us
56 DtSetStartupCommand $TOPLEVEL \
57 "/usr/dt/share/examples/dtksh/SessionTest $SAVEFILE"
59 echo "DtSessionSavePath FAILED!!"
65 XCOMM This function is invoked when we are restarted at session restore time.
66 XCOMM It is passed the name of the session file as $1. It will extract our
67 XCOMM session information from the session file, and will restore our state
71 XCOMM Get the full path of our session file
72 if DtSessionRestorePath $TOPLEVEL PATH $1; then
76 XCOMM Restore our iconification state
78 Iconified) DtSetIconifyHint $TOPLEVEL True;;
79 *) DtSetIconifyHint $TOPLEVEL False;;
82 XCOMM Place us into the indicated set of workspaces
86 XmInternAtom ATOM $(XtDisplay "-" $TOPLEVEL) $NAME False
87 if [ ${#WS_LIST} -gt 0 ]; then
88 WS_LIST=$WS_LIST,$ATOM
94 DtWsmSetWorkspacesOccupied $(XtDisplay "-" $TOPLEVEL) \
95 $(XtWindow "-" $TOPLEVEL) \
100 echo "DtSessionRestorePath FAILED!!"
107 XCOMM ###################### Create the Main UI ###############################
109 XtInitialize TOPLEVEL wmProtTest WmProtTest "$0" "$@"
111 XtCreateManagedWidget DA da XmDrawingArea $TOPLEVEL
112 XtSetValues $DA height:200 width:200
114 XmInternAtom SAVE_SESSION_ATOM $(XtDisplay "-" $TOPLEVEL) "WM_SAVE_YOURSELF" False
117 XCOMM If we are invoked with any command line parameters, then we will assume
118 XCOMM that it is the name of our session file, and will restore to the indicated
122 XtSetValues $TOPLEVEL mappedWhenManaged:False
123 XtRealizeWidget $TOPLEVEL
124 XSync $(XtDisplay "-" $TOPLEVEL) False
126 XtSetValues $TOPLEVEL mappedWhenManaged:True
127 XtPopup $TOPLEVEL GrabNone
129 XtRealizeWidget $TOPLEVEL
130 XSync $(XtDisplay "-" $TOPLEVEL) False
133 XCOMM Register our interest in participating in session management.
134 XmAddWMProtocols $TOPLEVEL $SAVE_SESSION_ATOM
135 XmAddWMProtocolCallback $TOPLEVEL $SAVE_SESSION_ATOM SessionCallback