1 XCOMM! CDE_INSTALLATION_TOP/bin/dtksh
2 XCOMM $XConsortium: DtWsTest1.src /main/3 1996/04/23 20:18:06 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 how to interact with the workspace
15 XCOMM manager. It demonstrates the following capabilities:
17 XCOMM 1) How to query which workspaces the widgets currently reside it.
18 XCOMM 2) How to set the current workspace.
19 XCOMM 3) How to be notified when the current workspace changes.
25 XCOMM Pushbutton Callback: This function asks the workspace manager to change
26 XCOMM to the workspace indicated by $1; $1 is an X atom
27 XCOMM which identifies the new workspace. At some point
28 XCOMM after our request to the workspace manager, the
29 XCOMM workspace manager will activate our WsCB function,
30 XCOMM letting us know that the change has actually taken
35 if DtWsmSetCurrentWorkspace $TOPLEVEL $1; then
36 echo "Changing to new workspace"
38 XmGetAtomName NAME $(XtDisplay "-" $TOPLEVEL) $1
39 echo "Unable to Change to workspace " $NAME
43 XCOMM Workspace Changed Callback: This function is invoked whenever the workspace
44 XCOMM manager changes workspaces. It will simply
45 XCOMM query the 'name' of the new workspace, and
49 DtWsmGetCurrentWorkspace $(XtDisplay "-" $TOPLEVEL) \
50 $(XRootWindowOfScreen "-" $(XtScreen "-" $TOPLEVEL)) \
52 XmGetAtomName NAME $(XtDisplay "-" $TOPLEVEL) $NEW_ATOM
53 echo "Change to workspace complete " $NAME "("$NEW_ATOM")"
56 XCOMM ###################### Create the Main UI ###############################
58 XtInitialize TOPLEVEL dtWsTest DtWsTest "$0" "$@"
59 XtSetValues $TOPLEVEL allowShellResize:True
61 XtCreateManagedWidget DA da XmDrawingArea $TOPLEVEL
62 XtSetValues $DA height:200 width:200
64 XtRealizeWidget $TOPLEVEL
65 XSync $(XtDisplay "-" $TOPLEVEL) False
67 XtCreateApplicationShell TOPLEVEL2 DtWsTesta TopLevelShell
69 XtCreateManagedWidget RC rc XmRowColumn $TOPLEVEL2 \
70 orientation:HORIZONTAL \
73 XCOMM Get a list of all of the workspaces, and create a pushbutton for each one.
74 XCOMM When a pushbutton is activated, it will ask the workspace manager to
75 XCOMM change to the indicated workspace.
77 if DtWsmGetWorkspaceList $(XtDisplay "-" $TOPLEVEL) \
78 $(XRootWindowOfScreen "-" $(XtScreen "-" $TOPLEVEL)) \
85 XmGetAtomName NAME $(XtDisplay "-" $TOPLEVEL) $item
86 label="Set Current Workspace to "$NAME
87 XtCreateManagedWidget ITEM $item XmPushButton $RC \
89 XtAddCallback $ITEM activateCallback "SetWorkspace $item"
94 echo "Unable to get workspace list"
98 XtSetValues $RC numColumns:$wsCount
99 XtRealizeWidget $TOPLEVEL2
100 XSync $(XtDisplay "-" $TOPLEVEL) False
102 XCOMM The following block queries the initial set of workspaces occupied by
103 XCOMM this shell script; this list is printed out. Next, it will ask the
104 XCOMM workspace manager to move the shell script windows into all workspaces.
105 XCOMM Lastly, it will again ask the workspace manager for the list of
106 XCOMM workspaces occupied by the shell script windows, and will again print
108 if DtWsmGetWorkspacesOccupied $(XtDisplay "-" $TOPLEVEL) \
109 $(XtWindow "-" $TOPLEVEL) \
112 echo "Initial workspaces occupied:"
113 for item in $CURRENT_WS_LIST;
115 XmGetAtomName NAME $(XtDisplay "-" $TOPLEVEL) $item
119 DtWsmGetWorkspaceList $(XtDisplay "-" $TOPLEVEL) \
120 $(XRootWindowOfScreen "-" $(XtScreen "-" $TOPLEVEL)) \
123 DtWsmSetWorkspacesOccupied $(XtDisplay "-" $TOPLEVEL) \
124 $(XtWindow "-" $TOPLEVEL) \
127 DtWsmSetWorkspacesOccupied $(XtDisplay "-" $TOPLEVEL2) \
128 $(XtWindow "-" $TOPLEVEL2) \
131 echo "Unable to get current list of occupied workspaces"
135 XSync $(XtDisplay "-" $TOPLEVEL) False
137 XCOMM Print the new list of workspaces occupied
138 DtWsmGetWorkspacesOccupied $(XtDisplay "-" $TOPLEVEL) \
139 $(XtWindow "-" $TOPLEVEL) \
142 echo "After modification, workspaces occupied:"
144 for item in $CURRENT_WS_LIST;
146 XmGetAtomName NAME $(XtDisplay "-" $TOPLEVEL) $item
152 XCOMM Add a callback to be notified whenever the workspace changes.
153 DtWsmAddCurrentWorkspaceCallback HANDLE1 $TOPLEVEL WsCB