dtwm: Resolve coverity warnings related to uninitialised variables and missing return...
[oweals/cde.git] / cde / programs / dtwm / WmHelp.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $TOG: WmHelp.c /main/8 1997/06/18 17:30:51 samborn $ */
24 #ifdef WSM
25 /* 
26  * (c) Copyright 1987, 1988, 1989, 1990, 1992, 1993 HEWLETT-PACKARD COMPANY 
27  * (c) Copyright 1989, 1990, 1991, 1992 OPEN SOFTWARE FOUNDATION, INC. 
28  * ALL RIGHTS RESERVED 
29 */ 
30 #ifdef REV_INFO
31 #ifndef lint
32 static char rcsid[] = ""
33 #endif
34 #endif
35
36 /*
37  * Included Files:
38  */
39 #if defined(sun)
40 #ifndef XK_MISCELLANY
41 #define XK_MISCELLANY
42 #endif
43 #endif
44  
45 #include "WmGlobal.h"
46 #include "WmError.h"
47 #include "WmFunction.h"
48 #include "WmHelp.h"
49 #include "WmCDecor.h"
50 #include "WmResParse.h"
51 #ifdef PANELIST
52 #include "WmPanelP.h"
53 #endif /* PANELIST */
54 #include "WmResNames.h"
55 #include "WmWrkspace.h"
56 #include "DataBaseLoad.h"
57 #include <stdio.h>
58 #include <Xm/Xm.h>
59 #include <Xm/XmP.h>
60 #include <Xm/MessageB.h>
61 #include <X11/keysymdef.h>
62 #include <X11/keysym.h>
63 #include <X11/Shell.h>
64 #include <Xm/MwmUtil.h>
65
66 #include <Dt/HelpDialog.h>
67 #include <Dt/HelpQuickD.h>
68
69 #include <Dt/DtNlUtils.h>
70
71 #include <X11/cursorfont.h>
72
73
74 /****************************************************************
75  *
76  *  Cache List Info Structure Definition.
77  *
78  ****************************************************************/
79 typedef struct _CacheListStruct {
80     Widget                    helpDialog;
81     Boolean                   inUseFlag;
82     Boolean                   hLink;
83     Boolean                   restored;
84     char                      *workspaces;
85     Position                  xPos;
86     Position                  yPos;
87     struct _CacheListStruct   *pNext;
88     struct _CacheListStruct   *pPrevious;
89 } CacheListStruct;
90
91 typedef struct _DisplayTopicInfo {
92     char                      *workspaces;
93     Position                  xPos;
94     Position                  yPos;
95 } DisplayTopicInfo;
96
97 /*
98  * Function Declarations:
99  */
100
101 /********    Static Function Declarations    ********/
102 static int LocateTheControl( 
103                         Display *dpy,
104                         int screen,
105                         Widget *pWidget);
106 static WmScreenData *WmScreenDataFromWidget (
107                                              Widget theWidget) ;
108
109 static int WmDtReturnSelectedWidget (
110                          Widget theWidget,
111                          Cursor cursor,
112                          Widget *pWidget);
113 static void WmDtDisplayTopic (
114                                Widget  parent,
115                                char    *accessPath,
116                                char    *idString,
117                                int     helpType,
118                                Widget  wmClient,
119                                Boolean wmHelp,
120                                ArgList argList,
121                                int     argCount,
122                                ClientData *pCData,
123                                Boolean hyperLink,
124                                DisplayTopicInfo *displayTopicInfo);
125 static void WmDtCloseHelpCB (
126                               Widget w,
127                               XtPointer clientData,
128                               XtPointer callData);
129 static void WmDtWmCloseHelpCB (
130                               Widget w,
131                               XtPointer clientData,
132                               XtPointer callData);
133 static void WmDtVersionCloseCB (
134                                  Widget w,
135                                  XtPointer clientData,
136                                  XtPointer callData);
137 static void WmDtVersionPopupCB (
138                                  Widget w,
139                                  XtPointer clientData,
140                                  XtPointer callData);
141
142 static void WmDtProcessLinkCB (
143                                 Widget w,
144                                 XtPointer clientData,
145                                 XtPointer callData);
146 static Boolean WmDtGetFromCache(
147                                  CacheListStruct **pCurrentNode,
148                                  WmScreenData *pSD);
149 static void ShowHelpDialog(
150                       ClientData *pClient);
151
152 static void HideHelpDialog(
153                       WmScreenData *pSD,
154                       Boolean userDismissed );
155 static void wmDtHelpSetPosition(
156                                  PtrWsDtHelpData pHelp,
157                                  WmScreenData *pSD,
158                                  Boolean restorePos);
159 static void wmDtHelpMapEventHandler (
160                                  Widget, 
161                                  XtPointer, 
162                                  XEvent *,
163                                  Boolean *);
164 static void wmDtErrorDialog(
165                 WmScreenData *pSD,
166                 String sMessage,
167                 String sTitle);
168 static void wmDtErrorDialogOkCB(
169                 Widget w,
170                 XtPointer client_data,
171                 XtPointer call_data );
172 static void wmDtErrorDialogPopupCB(
173                 Widget w,
174                 XtPointer client_data,
175                 XtPointer call_data );
176 static void wmDtErrorDialogHide( 
177                 WmScreenData *pSD );
178
179 /********    End Static Function Declarations    ********/
180
181
182 /*
183  * Global Variables:
184  */
185
186
187 static  DisplayTopicInfo displayTopicInfo;
188 static  Widget      versionWidget = (Widget)NULL;
189
190 #define  PT_IN_CHILD(X, Y, CHILD) \
191          (((X) >=  (CHILD)->core.x) && \
192           ((X) <= ((CHILD)->core.x + (Position) (CHILD)->core.width)) && \
193           ((Y) >=  (CHILD)->core.y) && \
194           ((Y) <= ((CHILD)->core.y + (Position) (CHILD)->core.height)))
195
196 #define MAX_WIDGET_PATH 100
197
198
199 /**********************************************************************
200  * Function: LocateTheControl()
201  *
202  *   
203  *
204  **********************************************************************/
205 static int
206 LocateTheControl(
207         Display *dpy,
208         int screen,
209         Widget *pWidget )
210 {
211
212     Widget           child;
213     CompositeWidget  comp_widget;
214     int              status;
215     Cursor           cursor;
216     XEvent           event;
217     Window           target_win = None;
218     int              buttons = 0;
219     int              x,y;
220     int              i;
221     Window           parent;
222     Window           sub;
223     int              new_x, new_y;
224     int              offset;
225     KeySym           keySym;
226     Widget           widget = NULL;
227
228     Boolean          foundOne = False;
229     int  clientNum, scr;
230     WmFpEmbeddedClientData *pECD;
231     WmScreenData     *pSD = NULL;
232
233
234
235     /* Make the target cursor */
236     cursor = XCreateFontCursor (wmGD.display, XC_question_arrow);
237     
238     /* Grab the pointer using target cursor, letting it roam all over */
239     status = XGrabPointer (wmGD.display, RootWindow(wmGD.display, screen), 
240                            False,
241                            ButtonPressMask|ButtonReleaseMask, GrabModeAsync,
242                            GrabModeAsync, None, cursor, CurrentTime);
243     if (status != GrabSuccess)
244     {
245         Warning (((char *)GETMESSAGE(29, 1, 
246         "Help on Item failed. Another program may have grabbed the mouse.")));
247         return(DtHELP_SELECT_ERROR);
248     }
249     
250     
251     /* Grab the Keyboard so we can catch the ESC button press */
252     status = XGrabKeyboard(wmGD.display, RootWindow(wmGD.display, screen), 
253                            False,
254                            GrabModeAsync, GrabModeAsync, CurrentTime);
255     if (status != GrabSuccess)
256     {
257         XUngrabPointer (wmGD.display, CurrentTime);
258         Warning (((char *)GETMESSAGE(29, 2, 
259         "Help on Item failed. Another program may have grabbed the mouse.")));
260         return(DtHELP_SELECT_ERROR);
261     }
262     
263     /* Let the user select a window... */
264     while ((target_win == None) || (buttons != 0)) 
265     {
266         XtAppNextEvent(wmGD.mwmAppContext, &event);
267         
268         switch (event.type) 
269         {
270           case ButtonPress:
271             if (target_win == None) 
272             {
273                 target_win = event.xbutton.subwindow; /* window selected */
274                 if (target_win == None)
275                     target_win = RootWindow (wmGD.display, screen);
276             }
277             buttons++;
278             break;
279           case ButtonRelease:
280             /* there may have been some down before we started */
281             if (buttons > 0)
282                 buttons--;
283             break;
284           case KeyPress:
285             /* Look for ESC key press and stop if we get one */
286             if (event.xkey.state & ShiftMask)
287                 offset = 1;
288             else
289                 offset = 0;
290             
291             keySym = XLookupKeysym((XKeyEvent *)&event, offset);
292             if (keySym == XK_Escape)
293             {
294                 XUngrabKeyboard (wmGD.display, CurrentTime);
295                 XUngrabPointer (wmGD.display, CurrentTime);
296                 return(DtHELP_SELECT_ABORT);
297             }
298         }
299         
300         XtDispatchEvent(&event);
301     } 
302     
303     XUngrabKeyboard (wmGD.display, CurrentTime);      /* Done with keyboard */
304     XUngrabPointer (wmGD.display, CurrentTime);      /* Done with pointer */
305     
306 #ifdef  DEBUGGER
307     printf("RootWindow (wmGD.display, screen) = %ld\n", RootWindow (wmGD.display, screen));
308     printf("event.xbutton.root       = %ld\n", event.xbutton.root);
309     printf("event.xbutton.window     = %ld\n", event.xbutton.window);
310     printf("event.xbutton.subwindow  = %ld\n", event.xbutton.subwindow);
311     printf("event.xbutton.x          = %d\n",  event.xbutton.x);
312     printf("event.xbutton.y          = %d\n",  event.xbutton.y);
313     printf("event.xbutton.x_root     = %d\n",  event.xbutton.x_root);
314     printf("event.xbutton.y_root     = %d\n",  event.xbutton.y_root);
315 #endif  /*  DEBUGGER  */
316     
317     if (target_win == RootWindow (wmGD.display, screen))
318         return (DtHELP_SELECT_INVALID);
319     
320     for (scr = 0; scr < wmGD.numScreens; scr++)
321     {
322         if (wmGD.Screens[scr].managed &&
323             wmGD.Screens[scr].screen == screen)
324         {
325             pSD = (&(wmGD.Screens[scr]));
326             break;
327         }
328     }
329     if (!pSD)
330     {
331         pSD=wmGD.pActiveSD;
332     }
333
334     /* check for subwindows */
335     parent = RootWindow (wmGD.display, screen);
336     x      = event.xbutton.x_root;
337     y      = event.xbutton.y_root;
338     
339     while (!foundOne) 
340     {
341         XTranslateCoordinates(wmGD.display, parent, target_win, x, y,
342                               &new_x, &new_y, &sub);
343         if (!sub) 
344         {
345             x = new_x;
346             y = new_y;
347             break;
348         }
349         else 
350         {
351             pECD = (WmFpEmbeddedClientData *) pSD->pECD;
352             for (clientNum = 0; clientNum < pSD->numEmbeddedClients;
353                  clientNum++, pECD++)
354             {
355                 if ((pECD->pCD) &&
356                     (target_win == pECD->pCD->client))
357                 {
358                     widget = pECD->wControl;
359                     foundOne = True;
360                     break;
361                 }
362             }
363             parent = target_win;
364             target_win = sub;
365             x = new_x;
366             y = new_y;
367         }
368     }
369     
370     
371     if (widget == NULL)
372     {
373         widget = XtWindowToWidget (wmGD.display, target_win);
374     }
375     
376     if (widget == NULL)
377     {
378         widget = XtWindowToWidget (wmGD.display1, target_win);
379         
380         if (widget == NULL)
381         {
382             return (DtHELP_SELECT_INVALID);
383         }
384     }
385     
386     if (!XtIsComposite (widget))
387     {
388         *pWidget = widget;
389         return (DtHELP_SELECT_VALID);
390     }
391     comp_widget = (CompositeWidget)widget;
392     
393     /*  look for gadgets at this point  */
394     for (i = 0; i < comp_widget->composite.num_children; i++) 
395     {
396         child = comp_widget->composite.children[i];
397
398         if (PT_IN_CHILD (x, y, child) && XtIsManaged(child))
399         {
400             *pWidget = child;
401             return (DtHELP_SELECT_VALID);
402         }
403     }
404
405     if (widget != NULL)
406     {
407        *pWidget = widget;
408         return (DtHELP_SELECT_VALID);
409     }
410     
411     return (DtHELP_SELECT_INVALID);
412     
413 } /* END OF FUNCTION LocateTheControl */
414
415
416 /**********************************************************************
417  *
418  * Cache Creek related help functions
419  *
420  **********************************************************************/
421
422 /*************************************<->*************************************
423  *
424  *  WmDtStringHelpCB
425  *
426  *
427  *  Description:
428  *  -----------
429  *
430  *
431  *************************************<->***********************************/
432
433 void WmDtStringHelpCB (Widget theWidget, 
434                         XtPointer client_data, 
435                         XtPointer call_data)
436 {
437     WmScreenData *pSD;
438     char * theHelpString = (char *)client_data;
439     Widget theRealWidget = theWidget;
440     if( XmIsGadget(theWidget))
441     {
442         theRealWidget = XtParent(theWidget);
443     }
444     pSD = WmScreenDataFromWidget(theWidget);
445
446 /*    WmDtDisplayTopic(theRealWidget, NULL, theHelpString, */
447     WmDtDisplayTopic(pSD->screenTopLevelW1, NULL, theHelpString, 
448                       DtHELP_TYPE_DYNAMIC_STRING, (Widget) NULL, True,
449                       NULL, 0, NULL, False, NULL);
450
451
452
453 } /* END OF FUNCTION WmDtStringHelpCB */
454
455
456 /*************************************<->*************************************
457  *
458  *  WmDtWmStringHelpCB
459  *
460  *
461  *  Description:
462  *  -----------
463  *
464  *
465  *************************************<->***********************************/
466
467 void WmDtWmStringHelpCB (Widget theWidget, 
468                         XtPointer client_data, 
469                         XtPointer call_data)
470 {
471     WmScreenData *pSD;
472     char * theHelpString = (char *)client_data;
473     pSD = WmScreenDataFromWidget(theWidget);
474
475 #ifdef OLD
476     if (XtDisplay(theWidget) == DISPLAY)
477     {
478         WmDtDisplayTopic(pSD->screenTopLevelW1, 
479                           NULL, theHelpString, 
480                           DtHELP_TYPE_STRING, theWidget, True,
481                           NULL, 0, NULL, False, NULL);
482     }
483     else
484     {
485         WmDtDisplayTopic(theWidget, NULL, theHelpString, 
486                           DtHELP_TYPE_STRING, theWidget, True,
487                           NULL, 0, NULL, False, NULL);
488
489     }
490 #endif /* OLD */
491         WmDtDisplayTopic(pSD->screenTopLevelW1, 
492                           NULL, theHelpString, 
493                           DtHELP_TYPE_DYNAMIC_STRING, theWidget, True,
494                           NULL, 0, NULL, False, NULL);
495
496
497 } /* END OF FUNCTION WmDtWmStringHelpCB */
498
499
500
501 /*************************************<->*************************************
502  *
503  *  WmDtDisplayTopicHelp
504  *
505  *  Description:
506  *  -----------
507  *  External entry procedure used to display help topics.
508  *
509  *************************************<->***********************************/
510
511 void WmDtDisplayTopicHelp (Widget widget, 
512                         char * helpVolume,
513                         char * locationID)
514 {
515     WmScreenData *pSD = WmScreenDataFromWidget(widget);
516
517     WmDtDisplayTopic(pSD->screenTopLevelW1, 
518                       helpVolume, locationID,
519                       DtHELP_TYPE_TOPIC, (Widget) NULL, True,
520                       NULL, 0, NULL, False, NULL);
521 }
522
523 /*************************************<->*************************************
524  *
525  *  WmDtDisplayStringHelp
526  *
527  *  Description:
528  *  -----------
529  *  External entry procedure used to display help topics.
530  *
531  *************************************<->***********************************/
532
533 void WmDtDisplayStringHelp (Widget widget, 
534                         char * helpString)
535 {
536     WmScreenData *pSD = WmScreenDataFromWidget(widget);
537
538     WmDtDisplayTopic(pSD->screenTopLevelW1, 
539                           NULL, helpString, 
540                           DtHELP_TYPE_DYNAMIC_STRING, widget, True,
541                           NULL, 0, NULL, False, NULL);
542 }
543
544 /*************************************<->*************************************
545  *
546  *  WmDtWmTopicHelpCB
547  *
548  *
549  *  Description:
550  *  -----------
551  *  for each icon in the icon box
552  *
553  *************************************<->***********************************/
554
555 void WmDtWmTopicHelpCB (Widget theWidget, 
556                         XtPointer client_data, 
557                         XtPointer call_data)
558 {
559     Widget shellWidget;
560     WmScreenData *pSD;
561     char *helpVolume =  WM_DT_HELP_VOLUME;
562     char *locationID = (char *)client_data;
563     pSD = WmScreenDataFromWidget(theWidget);
564
565     shellWidget = theWidget;
566     while (!(XtIsSubclass(XtParent(shellWidget), shellWidgetClass)))
567     {
568         shellWidget = XtParent(shellWidget);
569     }
570
571     WmDtDisplayTopic(pSD->screenTopLevelW1, helpVolume, 
572                       locationID, 
573                       DtHELP_TYPE_TOPIC, shellWidget, True,
574                       NULL, 0, NULL, False, NULL);
575
576 } /* END OF FUNCTION WmDtWmTopicHelpCB */
577
578 /****************************************************************************
579  * Function:         WmScreenDataFromWidget(
580  *                              Widget theWidget)
581  *
582  * Parameters:      
583  *
584  * Return Value:    pSD
585  *
586  * Purpose:        
587  *
588  ***************************************************************************/
589 static WmScreenData *
590 WmScreenDataFromWidget (Widget theWidget) 
591 {
592
593     WmScreenData *pSD = NULL;
594     int scr;
595     
596     CacheListStruct *pTemp; 
597
598     if (theWidget)
599     {
600         for (scr = 0; scr < wmGD.numScreens; scr++)
601         {
602             if (wmGD.Screens[scr].managed &&
603                 wmGD.Screens[scr].screen == 
604                 XScreenNumberOfScreen(XtScreen(theWidget)))
605             {
606                 pSD = (&(wmGD.Screens[scr]));
607                 break;
608             }
609         } 
610         if (!pSD)
611         {
612             pSD=wmGD.pActiveSD;
613         }
614     }
615     else
616     {
617         pSD=wmGD.pActiveSD;
618     }
619     return(pSD);
620
621 } /* END OF FUNCTION WmScreenDataFromWidget */
622
623 /****************************************************************************
624  * Function:         WmDtCloseHelpCB(
625  *                              Widget w,
626  *                              caddr_t clientData, 
627  *                              caddr_t callData
628  *
629  * Parameters:      
630  *
631  * Return Value:    Void.
632  *
633  * Purpose:         Process close requests on all Help Dialog widgets 
634  *                  created and managed by this application.
635  *
636  ***************************************************************************/
637 static void WmDtCloseHelpCB (
638     Widget w,
639     XtPointer clientData,
640     XtPointer callData)
641 {
642     WmScreenData *pSD = NULL;
643     int scr;
644     Widget helpDialog = (Widget) clientData;
645     
646     CacheListStruct *pTemp; 
647     
648     pSD = WmScreenDataFromWidget(w);
649     pTemp = pSD->cachedHelp;
650
651     /* Search our Cache List for the closed help dialog */
652     while ((pTemp->helpDialog != helpDialog) && (pTemp != NULL))
653     {
654         pTemp = pTemp->pNext;
655     }
656     
657     if (pTemp == NULL)
658     {
659         /* ERROR */
660      /* printf("Didn't find our help dialog widget in the cache list??? /n");*/
661     }
662
663     XtPopdown (XtParent(helpDialog));
664
665     pTemp->inUseFlag  = FALSE;
666     pSD->cachedHelp->hLink  = False;    
667
668     /* Re-Assign our pTemp to point to our head so we can see 
669      * if we have any in-use help dialog in our list.
670      */
671     pTemp = pSD->cachedHelp;
672     
673 } /* END OF FUNCTION WmDtCloseHelpCB */
674
675
676 /****************************************************************************
677  * Function:         WmDtWmCloseHelpCB(
678  *                              Widget w,
679  *                              caddr_t clientData, 
680  *                              caddr_t callData
681  *
682  * Parameters:      
683  *
684  * Return Value:    Void.
685  *
686  * Purpose:         Process close requests on all Help Dialog widgets 
687  *                  created and managed by this application.
688  *
689  ***************************************************************************/
690 static void WmDtWmCloseHelpCB (
691     Widget w,
692     XtPointer clientData,
693     XtPointer callData)
694 {
695     WmScreenData *pSD;
696     Widget helpDialog = (Widget) clientData;
697     pSD = WmScreenDataFromWidget(w);
698     HideHelpDialog (pSD, True); 
699
700 } /* END OF FUNCTION WmDtWmCloseHelpCB */
701
702
703
704 /****************************************************************************
705  * Function:         WmDtWmPopupHelpCB(
706  *                              Widget w,
707  *                              caddr_t clientData, 
708  *                              caddr_t callData
709  *
710  * Parameters:      
711  *
712  * Return Value:    Void.
713  *
714  * Purpose:         Process 
715  *
716  *
717  ***************************************************************************/
718 static void WmDtWmPopupHelpCB (
719     Widget w,
720     XtPointer clientData,
721     XtPointer callData)
722 {
723     PtrWsDtHelpData  pHelp;
724     WmScreenData *pSD;
725
726     pSD = WmScreenDataFromWidget(w);
727
728     pHelp = &pSD->dtHelp;  
729
730     if (pSD->dtHelp.restored)
731     {
732         /*  set position of dialog to restored position  */
733         wmDtHelpSetPosition (pHelp, pSD, True);
734         pSD->dtHelp.restored = False;
735     }
736     else
737     {
738         /*  set position of dialog relative to client window  */
739         wmDtHelpSetPosition (pHelp, pSD, False); 
740     }
741
742 } /* END OF FUNCTION WmDtWmPopupHelpCB */
743
744
745 /****************************************************************************
746  * Function:         WmDtVersionPopupCB(
747  *                              Widget w,
748  *                              caddr_t clientData, 
749  *                              caddr_t callData
750  *
751  * Parameters:      
752  *
753  * Return Value:    Void.
754  *
755  * Purpose:         Process 
756  *
757  *
758  ***************************************************************************/
759 static void WmDtVersionPopupCB (
760     Widget w,
761     XtPointer clientData,
762     XtPointer callData)
763 {
764     Arg         setArgs[10];    
765     Arg         getArgs[10];    
766     Dimension   width, height;
767     int         x, y;
768     int         n;
769
770     if (w)
771     {
772 #ifdef OLD
773         n = 0;
774         XtSetArg (setArgs[n], XmNx, 0);  n++;
775         XtSetArg (setArgs[n], XmNy, 0);  n++;
776 #endif /* OLD */
777
778         /*
779          * Center the Version Dialog on the screen
780          */
781
782         n = 0;
783         XtSetArg(getArgs[n], XmNheight, &height); n++;
784         XtSetArg(getArgs[n], XmNwidth, &width); n++;
785         XtGetValues (w, (ArgList) getArgs, n);
786
787         x = (DisplayWidth 
788              (DISPLAY, XScreenNumberOfScreen(XtScreen(w))) - ((int) width))/2;
789         y = (DisplayHeight 
790              (DISPLAY, XScreenNumberOfScreen(XtScreen(w))) - ((int) height))/2;
791         n = 0;
792         XtSetArg(setArgs[n], XmNx, (XtArgVal) x); n++;
793         XtSetArg(setArgs[n], XmNy, (XtArgVal) y); n++;
794         XtSetValues (w, setArgs, n);
795     }
796
797 } /* END OF FUNCTION WmDtVersionPopupCB */
798
799
800
801 /****************************************************************************
802  * Function:         WmDtPopupHelpCB(
803  *                              Widget helpShellW,
804  *                              caddr_t clientData, 
805  *                              caddr_t callData
806  *
807  * Parameters:      
808  *
809  * Return Value:    Void.
810  *
811  * Purpose:         Process 
812  *
813  *
814  ***************************************************************************/
815 static void WmDtPopupHelpCB (
816     Widget helpShellW,
817     XtPointer clientData,
818     XtPointer callData)
819 {
820     char * ptr;
821     Atom * workspace_atoms = NULL;
822     int num_workspaces=0;
823
824     CacheListStruct *pTemp = (CacheListStruct *)clientData;
825     Arg args[10];
826     int n;
827     
828     n = 0;
829     XtSetArg (args[n], XmNgeometry, NULL);   n++;
830     XtSetArg (args[n], XmNwaitForWm, False); n++;
831
832     if (pTemp)
833     {
834         if (pTemp->workspaces) 
835         {
836             char **atom_names = NULL;
837             do
838             {
839                 ptr = DtStrchr (pTemp->workspaces, '*');
840                 if (ptr != NULL) *ptr = '\0';
841                 
842                 atom_names = 
843                     (char **) XtRealloc ((char *)atom_names,
844                                          sizeof(char*) * (num_workspaces + 1));
845                 atom_names[num_workspaces] = XtNewString(pTemp->workspaces);
846                 num_workspaces++;
847                 
848                 if (ptr != NULL)
849                 {
850                     *ptr = '*';
851                     pTemp->workspaces = ptr + 1;
852                 }
853             } while (ptr != NULL);
854
855             workspace_atoms = (Atom *) XtMalloc(sizeof(Atom) * num_workspaces);
856             XInternAtoms(wmGD.display, atom_names, num_workspaces,
857                          True, workspace_atoms); 
858             
859             DtWsmSetWorkspacesOccupied (XtDisplay(helpShellW), 
860                                         XtWindow (helpShellW), 
861                                         workspace_atoms,
862                                         num_workspaces);
863             
864             while (num_workspaces-- > 0)
865               XtFree(atom_names[num_workspaces]);
866             XtFree ((char *) atom_names);
867             XtFree ((char *) workspace_atoms);
868         }
869         
870         XtSetArg (args[n], XmNx, pTemp->xPos);       n++;
871         XtSetArg (args[n], XmNy, pTemp->yPos);       n++;
872         pTemp->restored = False;
873         XtRemoveCallback(helpShellW, XmNpopupCallback, 
874                          WmDtPopupHelpCB, clientData);
875         XtAddCallback(helpShellW, XmNpopupCallback, WmDtPopupHelpCB, NULL);
876     }
877     else
878     {
879         XtSetArg (args[n], XmNx, 0);         n++;
880         XtSetArg (args[n], XmNy, 0);         n++;
881     }
882
883     XtSetValues (helpShellW, args, n);
884
885
886 } /* END OF FUNCTION WmDtPopupHelpCB */
887
888
889
890 /****************************************************************************
891  * Function:         WmDtVersionCloseCB(
892  *                              Widget w,
893  *                              caddr_t clientData, 
894  *                              caddr_t callData
895  *
896  * Parameters:      
897  *
898  * Return Value:    Void.
899  *
900  * Purpose:         Process close requests on all Help Dialog widgets 
901  *                  created and managed by this application.
902  *
903  ***************************************************************************/
904 static void WmDtVersionCloseCB (
905     Widget w,
906     XtPointer clientData,
907     XtPointer callData)
908 {
909     XtUnmanageChild (w);
910
911 } /* END OF FUNCTION WmDtWmVersionCloseHelpCB */
912
913
914
915
916 /****************************************************************************
917  * Function:        void WmDtProcessLinkCB(
918  *                              Widget w,
919  *                              caddr_t  clientData, 
920  *                              caddr_t callData
921  *
922  * Parameters:      
923  *
924  * Return Value:    Void.
925  *
926  * Purpose:         Process JUMP-NEW and APP-LINK hypertext requests in a 
927  *                  given Help Dialog Window.
928  *                 
929  *                  This is the callback used for the DtNhyperLinkCallback
930  *                  on each of the help dialog widges created.
931  *
932  ****************************************************************************/
933 static void WmDtProcessLinkCB (
934     Widget w,
935     XtPointer clientData,
936     XtPointer callData)
937
938 {
939     DtHelpDialogCallbackStruct * hyperData = 
940         (DtHelpDialogCallbackStruct *) callData;
941     
942     switch (hyperData->hyperType)
943     {
944       case DtHELP_LINK_JUMP_NEW:
945         WmDtDisplayTopic (XtParent(w), hyperData->helpVolume,
946                            hyperData->locationId,
947                            /* DtHELP_LINK_JUMP_NEW */ DtHELP_TYPE_TOPIC,
948                            (Widget)NULL, False,
949                            NULL, 0, NULL, True, NULL);
950         break;
951         
952       default:  /* This catches the application definded link types */
953         if (hyperData->hyperType >= 100)
954         {  
955             /* The application would put any code here to handle their
956              * Applicaiton-defined-links.  
957              */
958         }
959         else
960         {
961             /* ERROR */
962             /* printf("We some how got a bogus hyptertext link type/n");*/
963         }           
964     }  /* End Switch Statement */
965     
966 } /* END OF FUNCTION WmDtProcessLinkCB */
967
968
969 /****************************************************************************
970  * Function:        void WmDtHelpOnVersion(
971  *                              Widget parent)
972  *
973  * Parameters:      
974  *
975  * Return Value:    Void.
976  *
977  * Purpose:         Displays a new Cache Creek help topic in a new/cached
978  *                  help dialog widget.
979  *
980  ****************************************************************************/
981 void WmDtHelpOnVersion (
982                          Widget  parent)
983
984 {
985 #ifndef NO_DT
986
987     Arg         setArgs[10];    
988     Arg         setArgs2[5];    
989     int         n, n2;
990     Widget printButton = NULL;
991     Widget helpButton = NULL;
992     Widget backButton = NULL;
993     Widget closeButton = NULL;
994 #ifdef NO_MESSAGE_CATALOG
995     XmString    label = NULL;
996 #endif
997
998    if((versionWidget != NULL) &&
999        (XtIsManaged(versionWidget)))
1000     {
1001         return ;
1002     }
1003
1004     n = 0;
1005     if (!(versionWidget))
1006     {
1007 #ifndef NO_MESSAGE_CATALOG
1008         XtSetArg (setArgs[n], XmNtitle, wmNLS.defaultVersionTitle);     n++;
1009 #else
1010         XtSetArg (setArgs[n], XmNtitle, "About Workspace Manager");     n++;
1011 #endif
1012
1013
1014         XtSetArg (setArgs[n], DtNhelpType, DtHELP_TYPE_TOPIC);    n++;
1015         XtSetArg (setArgs[n], DtNlocationId, "_COPYRIGHT");  n++;
1016         XtSetArg (setArgs[n], DtNhelpVolume, WM_DT_HELP_VOLUME);     n++; 
1017
1018         versionWidget = DtCreateHelpQuickDialog (parent, "VersionDialog",
1019                                                   setArgs, n);
1020
1021         XtAddCallback(versionWidget, DtNcloseCallback,
1022                       WmDtVersionCloseCB, 
1023                       (XtPointer) versionWidget);
1024
1025         XtAddCallback(XtParent(versionWidget), XmNpopupCallback,
1026                       WmDtVersionPopupCB, NULL);
1027
1028         closeButton = DtHelpQuickDialogGetChild( versionWidget, 
1029                                              DtHELP_QUICK_CLOSE_BUTTON );
1030         n2=0;
1031
1032 #ifndef NO_MESSAGE_CATALOG
1033         XtSetArg (setArgs2[n2], DtNcloseLabelString, wmGD.okLabel);    n2++;
1034 #else
1035         XtSetArg (setArgs2[n2], DtNcloseLabelString, 
1036               label=XmStringCreateLocalized ("OK")); n2++;
1037 #endif
1038
1039         XtSetValues(closeButton, setArgs2, n2);
1040 #ifdef NO_MESSAGE_CATALOG
1041         if(label)XmStringFree(label);
1042 #endif
1043
1044         printButton = DtHelpQuickDialogGetChild( versionWidget, 
1045                                              DtHELP_QUICK_PRINT_BUTTON );
1046         helpButton = DtHelpQuickDialogGetChild( versionWidget, 
1047                                              DtHELP_QUICK_HELP_BUTTON );
1048         backButton = DtHelpQuickDialogGetChild( versionWidget, 
1049                                              DtHELP_QUICK_BACK_BUTTON );
1050
1051         XtUnmanageChild(printButton);
1052         XtUnmanageChild(helpButton);
1053         XtUnmanageChild(backButton);
1054     }
1055     else
1056     {
1057         XtSetArg (setArgs[n], DtNlocationId, "_COPYRIGHT");  n++;
1058         XtSetArg (setArgs[n], DtNhelpVolume, WM_DT_HELP_VOLUME);     n++; 
1059         XtSetValues(versionWidget, setArgs, n);
1060     }
1061     XtManageChild(versionWidget);
1062
1063 #endif /* NO_DT */
1064
1065 } /* END OF FUNCTION WmDtHelpOnVersion  */
1066
1067
1068
1069 /******************************<->*************************************
1070  *
1071  *  Boolean WmDtHelp (String args)
1072  *
1073  *  Description:
1074  *  -----------
1075  *  Invoke item help 
1076  *
1077  *  Inputs:
1078  *  ------
1079  *  args - 
1080  * 
1081  *  Outputs:
1082  *  -------
1083  *  Return - True if the find a help callback; false otherwise.
1084  *
1085  *  Comments:
1086  *  --------
1087  *
1088  ******************************<->***********************************/
1089
1090 Boolean
1091 WmDtHelp (String args)
1092 {
1093     WmScreenData *pSD;
1094     Widget theWidget;
1095     WmPanelistObject  pPanelist;
1096     char *theHelpVolume = WM_DT_HELP_VOLUME;
1097     char *theHelpTopic  = WM_DT_HELP_TOPIC;
1098     unsigned char volume[MAXWMPATH + 1];
1099     unsigned char topic[MAXWMPATH + 1];
1100     int  argCount = 0;
1101
1102
1103     /* get right screen data */
1104 /*    pSD = WmScreenDataFromWidget(w);*/
1105     pSD = wmGD.pActiveSD;
1106
1107
1108     pPanelist = (WmPanelistObject) pSD->wPanelist;
1109     
1110     if ((theWidget = O_Panel(pPanelist)))
1111     {
1112         if (args )
1113         {
1114             /*
1115              * parse args for volume and topic 
1116              */
1117             WmDtGetHelpArgs(args, volume, topic, &argCount);
1118             if (argCount == 1)
1119             {
1120                 WmDtDisplayTopic(pSD->screenTopLevelW1, 
1121                                   theHelpVolume, 
1122                                   (char *)topic, 
1123                                   DtHELP_TYPE_TOPIC, theWidget, True,
1124                                   NULL, 0, NULL, False, NULL);
1125             }
1126             else
1127             {
1128                 WmDtDisplayTopic(pSD->screenTopLevelW1, 
1129                                   (char *)volume, 
1130                                   (char *)topic, 
1131                                   DtHELP_TYPE_TOPIC, theWidget, False,
1132                                   NULL, 0, NULL, False, NULL);
1133             }
1134             
1135         }
1136         else
1137         {
1138             WmDtDisplayTopic(pSD->screenTopLevelW1, 
1139                               theHelpVolume, 
1140                               theHelpTopic, 
1141                               DtHELP_TYPE_TOPIC, theWidget, True,
1142                               NULL, 0, NULL, False, NULL);
1143         }
1144         return(True);
1145     }
1146     else
1147     {
1148         return (False);
1149     }
1150 }  /* END OF FUNCTION WmDtHelp */
1151
1152
1153 /******************************<->*************************************
1154  *
1155  *  Boolean WmDtHelpMode (void)
1156  *
1157  *  Description:
1158  *  -----------
1159  *  Invoke item help mode
1160  *
1161  *  Inputs:
1162  *  ------
1163  *  args - 
1164  * 
1165  *  Outputs:
1166  *  -------
1167  *  Return - True if the find a help callback; false otherwise.
1168  *
1169  *  Comments:
1170  *  --------
1171  *
1172  ******************************<->***********************************/
1173
1174 Boolean
1175 WmDtHelpMode (void)
1176 {
1177     Widget selectedWidget = NULL;
1178     int iStatus;
1179     String sTmp, sMessage, sTitle;
1180
1181     iStatus = WmDtReturnSelectedWidget(wmGD.topLevelW, None, 
1182                         &selectedWidget);
1183
1184     switch (iStatus)
1185     {
1186         case DtHELP_SELECT_VALID:
1187             if (selectedWidget != (Widget) NULL)
1188             {
1189                 do
1190                 {
1191                     if ((XtHasCallbacks(selectedWidget, 
1192                             XmNhelpCallback) == XtCallbackHasSome))
1193                     {
1194                         XtCallCallbacks(selectedWidget, XmNhelpCallback, 
1195                             (XtPointer)NULL);
1196                         return(True);
1197                     }
1198                     else
1199                     {
1200                         selectedWidget = XtParent(selectedWidget);
1201                     }
1202                 }
1203                 while (selectedWidget != NULL);
1204             }
1205             break;
1206
1207         case DtHELP_SELECT_INVALID:
1208             /* invalid selection error (window not of this process) */
1209 #ifndef NO_MESSAGE_CATALOG
1210             sTmp = (char *)GETMESSAGE(29, 3, 
1211                  "You must select a Workspace Manager\n\
1212 dialog, an item in the Front Panel,\n\
1213 or an item in a subpanel.");
1214             sMessage = XtNewString (sTmp);
1215             sTmp = (char *)GETMESSAGE(29, 4, 
1216                 "Workspace Manager - Help On Item Error");
1217             sTitle = XtNewString (sTmp);
1218 #else
1219             sMessage = "You must select a Workspace Manager\n\
1220 dialog, an item in the Front Panel,\n\
1221 or an item in a subpanel.";
1222             sTitle = "Workspace Manager - Help On Item Error";
1223 #endif
1224             wmDtErrorDialog (ACTIVE_PSD, sMessage, sTitle);
1225 #ifndef NO_MESSAGE_CATALOG
1226             if (sMessage) XtFree (sMessage);
1227             if (sTitle) XtFree (sTitle);
1228 #endif
1229             break;
1230
1231         case DtHELP_SELECT_ERROR:
1232             /* error (like grab failed) */
1233             break;
1234
1235         case DtHELP_SELECT_ABORT:
1236             /* user aborted this selection */
1237             break;
1238     } /* end switch */
1239
1240     return (False);
1241 }  /* END OF FUNCTION WmDtHelpMode */
1242
1243
1244
1245 /*****************************************************************************
1246  * Function:     WmDtReturnSelectedWidget (Widget, Cursor, Widget *) 
1247  *
1248  * Parameters:   Widget      Specifies a valid widget within the app's
1249  *                           widget hierarchy.
1250  *               Cursor      Cursor to grab pointer with (use NULL!!)
1251  *               Widget *    ptr to loc to receive returned widget
1252  *
1253  * Return Value:  DtHELP_SELECT_ERROR  - error in getting the widget
1254  *                DtHELP_SELECT_ABORT  - user aborted
1255  *                DtHELP_SELECT_INVALID - user selected invalid window
1256  *                DtHELP_SELECT_VALID  - valid widget returned
1257  *
1258  * Purpose: Allows developers to get the widget ID for any widget in their UI
1259  *          that the user has selected vai the pointer.  This function will
1260  *          cause the cursor to change and allow a user to select an item in 
1261  *          the UI.
1262  *
1263  *****************************************************************************/
1264 static int
1265 WmDtReturnSelectedWidget(
1266         Widget theWidget, 
1267         Cursor cursor, 
1268         Widget *pWidget )
1269
1270 {
1271     Display   *dpy;
1272     int       screen;  
1273     int       iStatus;
1274  
1275     /* Setup some needed variables */
1276     dpy = XtDisplay(theWidget);
1277     screen = ACTIVE_SCREEN;
1278  
1279     /* refresh the display */
1280     XmUpdateDisplay(theWidget);
1281
1282     /* Change the curser to let the user select the desired widget */
1283     iStatus = LocateTheControl(dpy, screen, pWidget);
1284     
1285     return (iStatus);
1286     
1287 } /* END OF FUNCTION WmDtReturnSelectedWidget */
1288
1289
1290 /****************************************************************************
1291  * Function:        void WmDtDisplayTopic(
1292  *                              Widget parent,
1293  *                              char *helpVolume,
1294  *                              char *locationId,
1295  *                              Widget wmClient,
1296  *                              Boolean wmHelp,
1297  *                              ArgList argList,
1298  *                              int argCount,
1299  *                              ClientData *pCData,
1300  *                              Boolean  hyperlink,
1301  *                              DisplayTopicInfo   *displayTopicInfo)
1302  *
1303  * Parameters:      
1304  *
1305  * Return Value:    Void.
1306  *
1307  * Purpose:         Displays a new Cache Creek help topic in a new/cached
1308  *                  help dialog widget.
1309  *
1310  ****************************************************************************/
1311 static void
1312 WmDtDisplayTopic (
1313     Widget  parent,
1314     char    *helpVolume,
1315     char    *locationId,
1316     int      helpType,
1317     Widget  wmClient,
1318     Boolean wmHelp ,
1319     ArgList argList,
1320     int argCount,
1321     ClientData *pCData,
1322     Boolean hyperLink,
1323     DisplayTopicInfo *displayTopicInfo)
1324
1325 {
1326 #ifndef NO_DT
1327     Arg         setArgs[10]; 
1328     Arg         smallArgs[2];   
1329     ArgList  argsNew;
1330     int         n;
1331     int         ac;
1332     Widget      helpWidget;
1333     Widget      shellWidget;
1334     char *      helpTitle;
1335     WmPanelistObject  pPanelist;
1336     char *      defaultTitle="Help";
1337     ClientData *pCD = NULL;
1338     WmScreenData *pSD = NULL;
1339     CacheListStruct *pCurrentNode = NULL;
1340     Boolean       cachedNode = FALSE;
1341
1342
1343     pSD = WmScreenDataFromWidget (parent);
1344
1345
1346     pPanelist = (WmPanelistObject) pSD->wPanelist;
1347     
1348     if (argCount)
1349     {
1350         /*argsNew = (ArgList) XtMalloc( sizeof( Arg) * (argCount + 1)) ;*/
1351         argsNew = (ArgList) XtMalloc( sizeof( Arg) * (argCount)) ;
1352         memcpy( argsNew, argList, (sizeof( Arg) * argCount)) ;
1353     }
1354
1355     shellWidget = parent;
1356     while (!(XtIsSubclass(shellWidget, shellWidgetClass)))
1357     {
1358         shellWidget = XtParent(shellWidget);
1359     }
1360
1361     n = 0;
1362     switch (helpType)
1363     {
1364       case  DtHELP_TYPE_TOPIC:
1365         if (helpVolume != NULL)
1366         {
1367             XtSetArg (setArgs[n],DtNhelpVolume,helpVolume);     n++; 
1368         }
1369         XtSetArg (setArgs[n], DtNlocationId,locationId);        n++;
1370         helpTitle=locationId;
1371         break;
1372         
1373       case DtHELP_TYPE_DYNAMIC_STRING:
1374         XtSetArg (setArgs[n], DtNstringData, locationId);        n++;
1375 /*      helpTitle=locationId;*/
1376         helpTitle=defaultTitle;
1377         break;
1378         
1379       case DtHELP_TYPE_MAN_PAGE:
1380         break;
1381         
1382       case DtHELP_TYPE_FILE:
1383         
1384         break;
1385         
1386       default:
1387         /* error condition, don't try to display help */
1388         break;
1389     }
1390
1391     if (n)
1392     {
1393         XtSetArg (setArgs[n], DtNhelpType, helpType);        n++;    
1394
1395         if (wmHelp)
1396         {
1397             if (pSD->dtHelp.shell)
1398             {
1399                 helpWidget = pSD->dtHelp.dialog;
1400                 XtSetValues(helpWidget, setArgs, n);
1401             }
1402             else
1403             {
1404 #ifndef NO_MESSAGE_CATALOG
1405                 XtSetArg (setArgs[n], XmNtitle, 
1406                           wmNLS.defaultDtwmHelpTitle);     n++;
1407 #else
1408                 XtSetArg (setArgs[n], XmNtitle, 
1409                                 "Workspace Manager - Help");     n++;
1410 #endif
1411
1412                 pSD->dtHelp.dialog =  
1413                     DtCreateHelpDialog(shellWidget, "helpWidget", setArgs, n);
1414                 helpWidget = pSD->dtHelp.dialog;
1415                 pSD->dtHelp.shell = XtParent(helpWidget);
1416                 pSD->dtHelp.bMapped = False;
1417
1418                 n = 0;
1419                 XtSetArg (setArgs[n], XmNname, "wmHelp");     n++;
1420                 if (argCount)
1421                 {
1422                     XtSetValues(pSD->dtHelp.shell, 
1423                                 argList, argCount);
1424                 }
1425
1426                 XtAddCallback(helpWidget, 
1427                               DtNhyperLinkCallback,
1428                               WmDtProcessLinkCB, NULL);
1429                 
1430                 XtAddCallback(helpWidget, DtNcloseCallback,
1431                               WmDtWmCloseHelpCB,
1432                               (XtPointer) helpWidget);
1433
1434                 XtAddCallback(pSD->dtHelp.shell, XmNpopupCallback,
1435                               WmDtWmPopupHelpCB, NULL);
1436
1437                 XtAddEventHandler(pSD->dtHelp.shell, 
1438                         StructureNotifyMask, 
1439                         False, 
1440                         wmDtHelpMapEventHandler, 
1441                         (XtPointer) pSD);
1442
1443             }
1444             if(pCData)
1445             {
1446                 ShowHelpDialog(pCData);
1447             }
1448             else
1449             {
1450                 if (wmClient)
1451                 {
1452                     XFindContext (DISPLAY, XtWindow(XtParent(wmClient)),
1453                                   wmGD.windowContextType, (caddr_t *)&pCD);
1454                 }
1455                 else
1456                 {
1457                     XFindContext (DISPLAY, XtWindow(O_Shell(pPanelist)),
1458                                   wmGD.windowContextType, (caddr_t *)&pCD);
1459                 }
1460                 ShowHelpDialog(pCD);
1461             }           
1462         }     /* if (wmHelp) */
1463         else
1464         {
1465             /* Get a used or new node form our cache if we have one */
1466             cachedNode = WmDtGetFromCache(&pCurrentNode, pSD);
1467
1468             /* If we got a free one from the Cache, use it */
1469             /* Set Values on current free one, then map it */
1470             if (cachedNode)
1471             {
1472                 XtSetValues(pCurrentNode->helpDialog, setArgs, n);
1473             }
1474             else
1475             {
1476 #ifndef NO_MESSAGE_CATALOG
1477                 XtSetArg (setArgs[n], XmNtitle, 
1478                           wmNLS.defaultHelpTitle);     n++;
1479 #else
1480                 XtSetArg (setArgs[n], XmNtitle, 
1481                                 "Workspace Manager - Help");     n++;
1482 #endif
1483
1484                 XtSetArg (setArgs[n], XmNgeometry, NULL); n++;
1485                 XtSetArg (setArgs[n], XmNx, 0); n++;
1486                 XtSetArg (setArgs[n], XmNy, 0); n++;
1487
1488                 pCurrentNode->helpDialog =  
1489                     DtCreateHelpDialog(shellWidget, "helpWidget", setArgs, n);
1490                 n = 0;
1491                 XtSetArg (setArgs[n], XmNname, "cachedHelp");     n++;
1492                 if (argCount)
1493                 {
1494                     XtSetValues(shellWidget, argList, argCount);
1495                 }
1496
1497                 XtAddCallback(pCurrentNode->helpDialog, 
1498                               DtNhyperLinkCallback,
1499                               WmDtProcessLinkCB, NULL);
1500                 
1501                 XtAddCallback(pCurrentNode->helpDialog, DtNcloseCallback,
1502                               WmDtCloseHelpCB, 
1503                               (XtPointer) pCurrentNode->helpDialog);
1504
1505                 if (hyperLink)
1506                 {
1507                     pCurrentNode->hLink = True;             
1508                 }
1509                 else
1510                 {
1511                     if (displayTopicInfo)
1512                     {
1513                         pCurrentNode->workspaces = 
1514                             displayTopicInfo->workspaces;
1515                         pCurrentNode->xPos = displayTopicInfo->xPos;
1516                         pCurrentNode->yPos = displayTopicInfo->yPos;
1517                         pCurrentNode->restored = True;
1518                         XtAddCallback(XtParent(pCurrentNode->helpDialog), 
1519                                       XmNpopupCallback,
1520                                       WmDtPopupHelpCB, 
1521                                       (XtPointer)pCurrentNode);
1522                     }
1523                     else
1524                     {
1525                         XtAddCallback(XtParent(pCurrentNode->helpDialog), 
1526                                       XmNpopupCallback,
1527                                       WmDtPopupHelpCB, NULL);
1528                     }
1529                 }
1530
1531             }
1532             helpWidget = pCurrentNode->helpDialog;
1533             XtManageChild(helpWidget);    
1534             XtPopup(XtParent(helpWidget), XtGrabNone);
1535         }
1536
1537     } /* if n is still 0, we did not find a useful help type */
1538 #endif /* NO_DT */
1539 } /* END OF FUNCTION WmDtDisplayTopic  */
1540
1541
1542 /****************************************************************************
1543  * Function:        static Boolean WmDtGetFromCache(
1544  *                                       CacheListStruct **pCurrentNode)
1545  *
1546  *
1547  * Parameters:      
1548  *
1549  * Return Value:    Void.
1550  *
1551  * Purpose:         Gets a free help node form our cache list.  If none are
1552  *                  free, it will return fallse and the calling routine will
1553  *                  create a new help dialog widget.
1554  *
1555  ****************************************************************************/
1556 static Boolean WmDtGetFromCache(
1557                                  CacheListStruct **pCurrentNode,
1558                                  WmScreenData       *pSD)
1559 {
1560     CacheListStruct *pTemp; 
1561     
1562     if (pSD->cachedHelp == NULL)
1563     {
1564         /* We have a new list so lets create one and pass it back */
1565         pSD->cachedHelp = 
1566             (CacheListStruct *) XtMalloc((sizeof(CacheListStruct)));
1567         
1568         /* Assign the default values to our node */
1569         pSD->cachedHelp->helpDialog = NULL;
1570         pSD->cachedHelp->inUseFlag  = TRUE;
1571         pSD->cachedHelp->restored  = False;
1572         pSD->cachedHelp->hLink  = False;
1573         pSD->cachedHelp->pNext      = NULL;
1574         pSD->cachedHelp->pPrevious = NULL;
1575         
1576         /* Return our head pointer because it's our first and only node */
1577         *pCurrentNode = pSD->cachedHelp;
1578         return (FALSE);
1579     }
1580     else
1581     { 
1582         /* We have some nodes so search for a free one first */
1583         pTemp = pSD->cachedHelp;
1584         
1585         while (pTemp != NULL)
1586         {
1587             if (pTemp->inUseFlag == FALSE)
1588             {
1589                 pTemp->inUseFlag = TRUE;
1590                 pTemp->hLink  = False;  
1591                 pTemp->restored  = False;
1592                 *pCurrentNode = pTemp;
1593                 return (TRUE);
1594             }
1595             else
1596                 pTemp = pTemp->pNext;
1597         }
1598         
1599         
1600         /* 
1601          * If we did not find a free node then we must add a new one to the
1602          * top of the list, and return it.
1603          */
1604         
1605         pTemp =  (CacheListStruct *) XtMalloc((sizeof(CacheListStruct)));
1606         
1607         /* Assign the default values to our node */
1608         pTemp->helpDialog = NULL;
1609         pTemp->inUseFlag  = TRUE;
1610         pTemp->restored  = False;
1611         pTemp->hLink  = False;  
1612         pTemp->pNext      = pSD->cachedHelp;
1613         pTemp->pPrevious  = NULL;
1614         
1615         pSD->cachedHelp->pPrevious = pTemp;
1616
1617         /* Re-Assign our head pointer to point to the new head of the list */
1618         pSD->cachedHelp = pTemp;
1619         
1620         /* Return our head pointer because it's our new node */
1621         *pCurrentNode = pSD->cachedHelp;
1622         return (FALSE);
1623     }
1624     
1625 } /* END OF FUNCTION WmDtGetFromCache */
1626
1627 /* End of Dt utils */
1628
1629
1630 /*************************************<->*************************************
1631  *
1632  *  void
1633  *  RestoreHelpDialogs (pSD)
1634  *
1635  *
1636  *  Description:
1637  *  -----------
1638  *  Saves the state of the help system
1639  *
1640  *  Inputs:
1641  *  ------
1642  *
1643  * 
1644  *  Outputs:
1645  *  -------
1646  *  Return = none
1647  *
1648  *
1649  *  Comments:
1650  *  --------
1651  * 
1652  ******************************<->***********************************/
1653
1654 Boolean
1655 RestoreHelpDialogs(
1656         WmScreenData *pSD)
1657 {
1658 #ifndef NO_DT
1659     XrmDatabase db;
1660     XrmName xrm_name[5];
1661     XrmRepresentation rep_type;
1662     XrmValue value;
1663
1664     Position xLoc, yLoc;
1665     short columns, rows;
1666     int helpType;
1667     char geometry[40];
1668     int wsCnt;    
1669     int cCount;
1670     int cachedCount=0;          
1671     char dialogName[18];
1672
1673     ClientData *pCD = NULL;
1674     char *tTitle = NULL;
1675     char *wsName = NULL;
1676     char *wmClientName = NULL;
1677     char *helpVolume = NULL;
1678     char *locationId = NULL;
1679     char *stringData = NULL;
1680     char *workspaces = NULL;
1681
1682     Arg setArgs[20];
1683     int ac;
1684
1685     WmPanelistObject  pPanelist = (WmPanelistObject) pSD->wPanelist;
1686
1687     xLoc = 0;
1688     yLoc = 0;
1689     columns = 40;
1690     rows = 15;
1691
1692     if (pSD->helpResources)
1693     {
1694         if ((db = XrmGetStringDatabase (pSD->helpResources)) == NULL) 
1695         {
1696             return(False);
1697         }
1698         xrm_name [0] = XrmStringToQuark ("wsHelp");
1699         xrm_name [1] = XrmStringToQuark ("onScreen");
1700         xrm_name [2] = NULLQUARK;
1701         
1702         
1703         if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)) 
1704         {
1705             /* Are we supposed to be mapped? */
1706             if (strcmp(value.addr, "True") == 0)
1707             {
1708                 ac = 0;
1709                 /* get x position */
1710                 xrm_name [1] = XrmStringToQuark ("x");
1711                 if (XrmQGetResource (db, xrm_name, xrm_name, 
1712                                      &rep_type, &value)) 
1713                 {
1714                     pSD->dtHelp.xPos = (Position)atoi((char *)value.addr);
1715                     pSD->dtHelp.restored = True;
1716                 }
1717                 
1718                 /* get y position */
1719                 xrm_name [1] = XrmStringToQuark ("y");
1720                 if (XrmQGetResource (db, xrm_name, xrm_name, 
1721                                      &rep_type, &value)) 
1722                 {
1723                     pSD->dtHelp.yPos = (Position)atoi((char *)value.addr);
1724                     pSD->dtHelp.restored = True;
1725                 }
1726
1727                 /* get columns */
1728                 xrm_name [1] = XrmStringToQuark ("columns");
1729                 if (XrmQGetResource (db, xrm_name, xrm_name, 
1730                                      &rep_type, &value)) 
1731                 {
1732                     XtSetArg (setArgs[ac], XmNcolumns, 
1733                               (short)atoi((char *)value.addr)); ac++;
1734                     columns = (short)atoi((char *)value.addr);
1735                 }
1736
1737                 /* get rows */
1738                 xrm_name [1] = XrmStringToQuark ("rows");
1739                 if (XrmQGetResource (db, xrm_name, xrm_name, 
1740                                      &rep_type, &value)) 
1741                 {
1742                     XtSetArg (setArgs[ac], XmNrows, 
1743                               (short)atoi((char *)value.addr)); ac++;
1744                     rows = (short)atoi((char *)value.addr);
1745                 }
1746                 sprintf (geometry, "=+%d+%d", xLoc, yLoc);
1747                 
1748                 XtSetArg (setArgs[ac], XmNgeometry, 
1749                           XtNewString(geometry)); ac++;
1750
1751                 /* get visiblePathCount */
1752                 xrm_name [1] = XrmStringToQuark ("vPCount");
1753                 if (XrmQGetResource (db, xrm_name, xrm_name, 
1754                                      &rep_type, &value)) 
1755                 {
1756                     XtSetArg (setArgs[ac], DtNvisiblePathCount, 
1757                               (int)atoi((char *)value.addr)); ac++;
1758                 }
1759
1760                 /* get topicTitle */
1761                 xrm_name [1] = XrmStringToQuark ("tTitle");
1762                 if (XrmQGetResource (db, xrm_name, xrm_name, 
1763                                      &rep_type, &value)) 
1764                 {
1765                     tTitle = XtNewString ((char *)value.addr);
1766                     XtSetArg (setArgs[ac], DtNtopicTitle, tTitle); ac++;
1767                 }
1768
1769                 /* get help type */
1770                 xrm_name [1] = XrmStringToQuark ("helpType");
1771                 if (XrmQGetResource (db, xrm_name, xrm_name, 
1772                                      &rep_type, &value)) 
1773                 {
1774                     XtSetArg (setArgs[ac], DtNhelpType, 
1775                               (int)atoi((char *)value.addr)); ac++;
1776                     helpType = (int)atoi((char *)value.addr);
1777                 }
1778                 
1779                 
1780                 switch (helpType)
1781                 {
1782                   case  DtHELP_TYPE_TOPIC:
1783                     /* get helpVolume */
1784                     xrm_name [1] = XrmStringToQuark ("helpVolume");
1785                     if (XrmQGetResource (db, xrm_name, xrm_name, 
1786                                          &rep_type, &value)) 
1787                     {
1788                         helpVolume = XtNewString ((char *)value.addr);
1789 /*                      XtSetArg (setArgs[ac], DtNhelpVolume, 
1790                                   helpVolume); ac++;*/
1791                     }
1792                     /* get locationId */
1793                     xrm_name [1] = XrmStringToQuark ("locationId");
1794                     if (XrmQGetResource (db, xrm_name, xrm_name, 
1795                                          &rep_type, &value)) 
1796                     {
1797                         locationId = XtNewString ((char *)value.addr);
1798 /*                      XtSetArg (setArgs[ac], DtNlocationId, 
1799                                   locationId); ac++;*/
1800                     }
1801
1802                     break;
1803                     
1804                   case DtHELP_TYPE_DYNAMIC_STRING:
1805                     
1806                     /* get stringData */
1807                     xrm_name [1] = XrmStringToQuark ("stringData");
1808                     if (XrmQGetResource (db, xrm_name, xrm_name, 
1809                                          &rep_type, &value)) 
1810                     {
1811                         stringData = XtNewString ((char *)value.addr);
1812 /*                      XtSetArg (setArgs[ac], DtNstringData, 
1813                                   stringData); ac++;*/
1814                         locationId = stringData;
1815                     }
1816                     
1817                     break;
1818                     
1819                   case DtHELP_TYPE_MAN_PAGE:
1820                     
1821                     break;
1822                     
1823                   case DtHELP_TYPE_FILE:
1824                     
1825                     break;
1826                     
1827                   default:
1828                     /* error condition, don't try to display help */
1829                     break;
1830                 }
1831
1832                 /* get name of wm client for which wmHelp is transient */
1833
1834                 xrm_name [1] = XrmStringToQuark ("windowGroup");
1835                 if (XrmQGetResource (db, xrm_name, xrm_name, 
1836                                      &rep_type, &value)) 
1837                 {
1838                     wmClientName =  ((char *)value.addr);
1839                     if ((!strcmp(wmClientName, pSD->iconBoxName)) &&
1840                         (pSD->useIconBox))
1841                     {
1842                         xrm_name [1] = XrmStringToQuark ("wsName");
1843                         if (XrmQGetResource (db, xrm_name, xrm_name, 
1844                                              &rep_type, &value)) 
1845                         {
1846                             wsName = (char *)value.addr;
1847                             for (wsCnt = 0; wsCnt < pSD->numWorkspaces; 
1848                                  wsCnt++)
1849                             {
1850                                 if (!strcmp(pSD->pWS[wsCnt].name, wsName))
1851                                 {
1852                                     pCD=pSD->pWS[wsCnt].pIconBox->pCD_iconBox;
1853                                     break;
1854                                 }
1855                             }
1856                         }
1857
1858                     }
1859 /*
1860                     else if(!strcmp(wmClientName, O_PanelName(pPanelist)))
1861                     {
1862                         pCD=O_ClientData(pPanelist);
1863                     }
1864 */
1865                 }
1866
1867                 /* 
1868                  *  Map the help dialog
1869                  */
1870
1871                 WmDtDisplayTopic(pSD->screenTopLevelW1, helpVolume, 
1872                                   locationId, 
1873                                   helpType, NULL, True,
1874                                   setArgs, ac, pCD, False, NULL); 
1875             }
1876         }/* if (XrmQGetResource for wsHelp) */
1877
1878         xrm_name [0] = XrmStringToQuark ("cachedHelp");
1879         xrm_name [1] = XrmStringToQuark ("cachedCount");
1880         xrm_name [2] = NULLQUARK;
1881         
1882         
1883         if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)) 
1884         {
1885             /* restore cachedCount number of help dialogs */
1886             cachedCount = (int)atoi((char *)value.addr);
1887             for (cCount=1; cCount < (cachedCount + 1); cCount++)
1888             {
1889                 sprintf (dialogName,  "oWsHelp%d", cCount);
1890                 xrm_name [0] = XrmStringToQuark (dialogName);
1891                 xrm_name [1] = NULLQUARK;
1892                 xrm_name [2] = NULLQUARK;
1893
1894                 displayTopicInfo.xPos = 0;
1895                 displayTopicInfo.xPos = 0;
1896                 displayTopicInfo.workspaces = NULL;
1897
1898                 ac = 0;
1899                 /* get x position */
1900                 xrm_name [1] = XrmStringToQuark ("x");
1901                 if (XrmQGetResource (db, xrm_name, xrm_name, 
1902                                      &rep_type, &value)) 
1903                 {
1904                     /*              XtSetArg (setArgs[ac], XmNx, 
1905                                     atoi((char *)value.addr)); ac++;*/
1906                     xLoc = (Position)atoi((char *)value.addr);
1907                     displayTopicInfo.xPos = xLoc;
1908                 }
1909                 
1910                 /* get y position */
1911                 xrm_name [1] = XrmStringToQuark ("y");
1912                 if (XrmQGetResource (db, xrm_name, xrm_name, 
1913                                      &rep_type, &value)) 
1914                 {
1915                     /*              XtSetArg (setArgs[ac], XmNy, 
1916                                     atoi((char *)value.addr)); ac++;*/
1917                     yLoc = (Position)atoi((char *)value.addr);
1918                     displayTopicInfo.yPos = yLoc;
1919                 }
1920                 
1921                 /* get columns */
1922                 xrm_name [1] = XrmStringToQuark ("columns");
1923                 if (XrmQGetResource (db, xrm_name, xrm_name, 
1924                                      &rep_type, &value)) 
1925                 {
1926                     XtSetArg (setArgs[ac], XmNcolumns, 
1927                               (short)atoi((char *)value.addr)); ac++;
1928                     columns = (short)atoi((char *)value.addr);
1929                 }
1930                 
1931                 /* get rows */
1932                 xrm_name [1] = XrmStringToQuark ("rows");
1933                 if (XrmQGetResource (db, xrm_name, xrm_name, 
1934                                      &rep_type, &value)) 
1935                 {
1936                     XtSetArg (setArgs[ac], XmNrows, 
1937                               (short)atoi((char *)value.addr)); ac++;
1938                     rows = (short)atoi((char *)value.addr);
1939                 }
1940                 sprintf (geometry, "=+%d+%d", xLoc, yLoc);
1941                 
1942                 XtSetArg (setArgs[ac], XmNgeometry, 
1943                           XtNewString(geometry)); ac++;
1944                 
1945                 /* get visiblePathCount */
1946                 xrm_name [1] = XrmStringToQuark ("vPCount");
1947                 if (XrmQGetResource (db, xrm_name, xrm_name, 
1948                                      &rep_type, &value)) 
1949                 {
1950                     XtSetArg (setArgs[ac], DtNvisiblePathCount, 
1951                               (int)atoi((char *)value.addr)); ac++;
1952                 }
1953
1954                 /* get topicTitle */
1955                 xrm_name [1] = XrmStringToQuark ("tTitle");
1956                 if (XrmQGetResource (db, xrm_name, xrm_name, 
1957                                      &rep_type, &value)) 
1958                 {
1959                     tTitle = XtNewString ((char *)value.addr);
1960                     XtSetArg (setArgs[ac], DtNtopicTitle, tTitle); ac++;
1961                 }
1962
1963                 /* get workspaces list */
1964                 xrm_name [1] = XrmStringToQuark ("workspaces");
1965                 if (XrmQGetResource (db, xrm_name, xrm_name, 
1966                                      &rep_type, &value)) 
1967                 {
1968                     workspaces = XtNewString ((char *)value.addr);
1969                     displayTopicInfo.workspaces = workspaces;
1970                 }
1971
1972
1973                 /* get help type */
1974                 xrm_name [1] = XrmStringToQuark ("helpType");
1975                 if (XrmQGetResource (db, xrm_name, xrm_name, 
1976                                      &rep_type, &value)) 
1977                 {
1978                     XtSetArg (setArgs[ac], DtNhelpType, 
1979                               (int)atoi((char *)value.addr)); ac++;
1980                     helpType = (int)atoi((char *)value.addr);
1981                 }
1982                 
1983
1984                 switch (helpType)
1985                 {
1986                   case  DtHELP_TYPE_TOPIC:
1987                     /* get helpVolume */
1988                     xrm_name [1] = XrmStringToQuark ("helpVolume");
1989                     if (XrmQGetResource (db, xrm_name, xrm_name, 
1990                                          &rep_type, &value)) 
1991                     {
1992                         helpVolume = XtNewString ((char *)value.addr);
1993                     }
1994                     /* get locationId */
1995                     xrm_name [1] = XrmStringToQuark ("locationId");
1996                     if (XrmQGetResource (db, xrm_name, xrm_name, 
1997                                          &rep_type, &value)) 
1998                     {
1999                         locationId = XtNewString ((char *)value.addr);
2000                     }
2001                     
2002                     break;
2003                     
2004                   case DtHELP_TYPE_DYNAMIC_STRING:
2005                     
2006                     /* get stringData */
2007                     xrm_name [1] = XrmStringToQuark ("stringData");
2008                     if (XrmQGetResource (db, xrm_name, xrm_name, 
2009                                          &rep_type, &value)) 
2010                     {
2011                         stringData = XtNewString ((char *)value.addr);
2012                         /* XtSetArg (setArgs[ac], DtNstringData, 
2013                                                 stringData); ac++;*/
2014                         locationId = stringData;
2015                     }
2016                     
2017                     break;
2018                     
2019                   case DtHELP_TYPE_MAN_PAGE:
2020                     
2021                     break;
2022                     
2023                   case DtHELP_TYPE_FILE:
2024                     
2025                     break;
2026                     
2027                   default:
2028                     /* error condition, don't try to display help */
2029                     break;
2030                     
2031                 } /* switch */          
2032
2033                 WmDtDisplayTopic(pSD->screenTopLevelW1, helpVolume, 
2034                                   locationId, 
2035                                   helpType, NULL, False,
2036                                   setArgs, ac, NULL, False, 
2037                                   &displayTopicInfo); 
2038                 
2039             } /* for all cached help dialogs */
2040
2041
2042         } /* if (XrmQGetResource ) cachedHelp/cachedCount */ 
2043
2044         XrmDestroyDatabase(db);
2045     }
2046 #endif /* NO_DT */
2047
2048     return True;
2049 } /* END OF FUNCTION  RestoreHelpDialogs */
2050
2051 /*************************************<->*************************************
2052  *
2053  *  void
2054  *  SaveHelpResources (pSD)
2055  *
2056  *
2057  *  Description:
2058  *  -----------
2059  *  Saves the state of the help system
2060  *
2061  *  Inputs:
2062  *  ------
2063  *
2064  * 
2065  *  Outputs:
2066  *  -------
2067  *  Return = none
2068  *
2069  *
2070  *  Comments:
2071  *  --------
2072  * 
2073  ******************************<->***********************************/
2074
2075 void 
2076 SaveHelpResources(
2077         WmScreenData *pSD)
2078 {
2079 #ifndef NO_DT
2080     PtrWsDtHelpData  pHelp;
2081     CacheListStruct *pTemp; 
2082     Arg getArgs[20];
2083     int ac;
2084
2085     Window wmGroupWindow;
2086     ClientData *pCD;
2087     ClientData *pCDforHelp;
2088     int wsCnt;
2089     int thisCnt;
2090     WorkspaceID wsID;
2091     WmWorkspaceData *pWS;
2092
2093     Position xLoc, yLoc;
2094     short columns, rows;
2095     unsigned char helpType;
2096     int vPCount;
2097     char *helpVolume;
2098     char *locationId;
2099     char *stringData;
2100     char *topicTitle;
2101     char *wsName;
2102     char workspaces[MAXWMPATH+1];
2103
2104     char buffer[MAXWMPATH+1];
2105     char *res_class;
2106     char *data;
2107     int cum_len;
2108
2109     char screenName[10];
2110     char dialogName[128];
2111     char resString[MAXWMPATH+1];
2112  
2113     int  cachedCount=0;
2114
2115
2116     pHelp = &pSD->dtHelp;  
2117
2118     /* allocate initial data space */
2119     if ((data = (char *) XtMalloc (MAXWMPATH+1)) == NULL)
2120     {
2121         Warning (((char *)
2122                   GETMESSAGE(76,12,"Insufficient memory to save resources")));
2123         Do_Quit_Mwm (False);
2124     }
2125     cum_len = 1;
2126     *data = '\0';
2127
2128     /* Get our current resource class */
2129
2130     if (MwmBehavior)
2131     {
2132         res_class = WM_RESOURCE_CLASS;
2133     }
2134     else
2135     {
2136         res_class = DT_WM_RESOURCE_CLASS;
2137     }
2138
2139     sprintf (screenName, "%d", pSD->screen);
2140
2141     sprintf (buffer, "%s*%s*%s:  \\n ", res_class,  screenName, 
2142              WmNhelpResources);
2143     AddStringToResourceData (buffer, &data, &cum_len);
2144
2145     if (pHelp->onScreen)
2146     {
2147         sprintf (dialogName, "wsHelp");
2148         sprintf (buffer, "%s*onScreen: True\\n ", dialogName);
2149         AddStringToResourceData (buffer, &data, &cum_len);
2150
2151         ac = 0; 
2152         XtSetArg(getArgs[ac], XmNx, &xLoc);   ac++;
2153         XtSetArg(getArgs[ac], XmNy, &yLoc);   ac++;
2154         XtGetValues(pSD->dtHelp.shell, getArgs, ac);
2155         if (!XFindContext (DISPLAY, XtWindow(pSD->dtHelp.shell),
2156                            wmGD.windowContextType, (caddr_t *)&pCDforHelp))
2157         {
2158             if (wmGD.positionIsFrame)
2159             {
2160                 xLoc = xLoc - pCDforHelp->clientOffset.x;
2161                 yLoc = yLoc - pCDforHelp->clientOffset.y;
2162             }
2163         }
2164
2165         ac = 0;
2166         XtSetArg(getArgs[ac], XmNcolumns, &columns); ac++;
2167         XtSetArg(getArgs[ac], XmNrows, &rows);   ac++;
2168         XtSetArg(getArgs[ac], DtNhelpType, &helpType);   ac++;
2169         XtSetArg(getArgs[ac], DtNvisiblePathCount, &vPCount);   ac++;
2170         XtSetArg(getArgs[ac], DtNtopicTitle, &topicTitle);   ac++;
2171         XtGetValues(pSD->dtHelp.dialog, getArgs, ac);
2172
2173         sprintf (buffer, "%s*x: %d \\n ", dialogName, xLoc);
2174         AddStringToResourceData (buffer, &data, &cum_len);
2175         sprintf (buffer, "%s*y: %d \\n ", dialogName, yLoc);
2176         AddStringToResourceData (buffer, &data, &cum_len);
2177         sprintf (buffer, "%s*columns: %d \\n ", dialogName, columns);
2178         AddStringToResourceData (buffer, &data, &cum_len);
2179         sprintf (buffer, "%s*rows: %d \\n ", dialogName, rows);
2180         AddStringToResourceData (buffer, &data, &cum_len);
2181         sprintf (buffer, "%s*helpType: %d \\n ", dialogName, helpType);
2182         AddStringToResourceData (buffer, &data, &cum_len);
2183         sprintf (buffer, "%s*vPCount: %d \\n ", dialogName, vPCount);
2184         AddStringToResourceData (buffer, &data, &cum_len);
2185         sprintf (buffer, "%s*tTitle: %s\\n ", dialogName, topicTitle);
2186         AddStringToResourceData (buffer, &data, &cum_len);
2187
2188         ac = 0;
2189         switch (helpType)
2190         {
2191           case  DtHELP_TYPE_TOPIC:
2192             XtSetArg (getArgs[ac],DtNhelpVolume, &helpVolume); ac++; 
2193             XtSetArg (getArgs[ac], DtNlocationId, &locationId); ac++;
2194             XtGetValues(pSD->dtHelp.dialog, getArgs, ac);
2195             sprintf (buffer, "%s*helpVolume: %s\\n ", dialogName, helpVolume);
2196             AddStringToResourceData (buffer, &data, &cum_len);
2197             sprintf (buffer, "%s*locationId: %s\\n ", dialogName, locationId);
2198             AddStringToResourceData (buffer, &data, &cum_len);
2199
2200             break;
2201             
2202           case DtHELP_TYPE_DYNAMIC_STRING:
2203             XtSetArg (getArgs[ac], DtNstringData, &stringData); ac++;
2204             XtGetValues(pSD->dtHelp.dialog, getArgs, ac);
2205             sprintf (buffer, "%s*stringData: %s\\n ", dialogName, stringData);
2206             AddStringToResourceData (buffer, &data, &cum_len);
2207
2208             break;
2209             
2210           case DtHELP_TYPE_MAN_PAGE:
2211             
2212             break;
2213             
2214           case DtHELP_TYPE_FILE:
2215             
2216             break;
2217             
2218           default:
2219             /* error condition, don't try to display help */
2220             break;
2221         }
2222
2223         ac = 0;
2224         XtSetArg(getArgs[ac], XmNwindowGroup, &wmGroupWindow);   ac++;
2225         XtGetValues(pSD->dtHelp.shell, getArgs, ac);
2226
2227         if (!XFindContext (DISPLAY, wmGroupWindow,
2228                            wmGD.windowContextType, (caddr_t *)&pCD))
2229         {
2230             sprintf (buffer, "%s*windowGroup: %s\\n ", dialogName, 
2231                      pCD->clientName);
2232             AddStringToResourceData (buffer, &data, &cum_len);
2233
2234             if ((!strcmp(pCD->clientName, pSD->iconBoxName)) &&
2235                 (pSD->useIconBox))
2236             {
2237                 wsName = XGetAtomName(DISPLAY,
2238                                       pCD->pWsList[pCD->currentWsc].wsID);
2239                 sprintf (buffer, "%s*wsName: %s\\n ", dialogName, 
2240                          wsName);
2241                 AddStringToResourceData (buffer, &data, &cum_len);
2242                 XFree(wsName);
2243             }
2244         }
2245
2246     }
2247     
2248     if (pSD->cachedHelp != NULL)
2249     {
2250         /* 
2251          * We have some nodes so search for 
2252          * managed dialogs and save their state
2253          */
2254         
2255         pTemp = pSD->cachedHelp;
2256         
2257         while (pTemp != NULL)
2258         {
2259             if (pTemp->inUseFlag == FALSE)
2260             {
2261                 pTemp = pTemp->pNext;
2262             }
2263             else
2264             {
2265                 cachedCount++;          
2266                 sprintf (dialogName,  "oWsHelp%d",cachedCount);
2267
2268                 ac = 0; 
2269                 XtSetArg(getArgs[ac], XmNx, &xLoc);   ac++;
2270                 XtSetArg(getArgs[ac], XmNy, &yLoc);   ac++;
2271                 XtGetValues(XtParent(pTemp->helpDialog), getArgs, ac);
2272                 if (!XFindContext (DISPLAY, 
2273                                    XtWindow(XtParent(pTemp->helpDialog)),
2274                                    wmGD.windowContextType, 
2275                                    (caddr_t *)&pCDforHelp))
2276                 {
2277                     if (wmGD.positionIsFrame)
2278                     {
2279                         xLoc = xLoc - pCDforHelp->clientOffset.x;
2280                         yLoc = yLoc - pCDforHelp->clientOffset.y;
2281                     }
2282                 }
2283                 else
2284                 {
2285                     pCDforHelp = NULL;
2286                 }
2287
2288
2289                 ac = 0; 
2290                 XtSetArg(getArgs[ac], XmNcolumns, &columns); ac++;
2291                 XtSetArg(getArgs[ac], XmNrows, &rows);   ac++;
2292                 XtSetArg(getArgs[ac], DtNhelpType, &helpType);   ac++;
2293                 XtSetArg(getArgs[ac], DtNvisiblePathCount, &vPCount);   ac++;
2294                 XtSetArg(getArgs[ac], DtNtopicTitle, &topicTitle);   ac++;
2295                 XtGetValues(pTemp->helpDialog, getArgs, ac);
2296
2297                 sprintf (buffer, "%s*x: %d \\n ", dialogName, xLoc);
2298                 AddStringToResourceData (buffer, &data, &cum_len);
2299                 sprintf (buffer, "%s*y: %d \\n ", dialogName, yLoc);
2300                 AddStringToResourceData (buffer, &data, &cum_len);
2301                 sprintf (buffer, "%s*columns: %d \\n ", dialogName, columns);
2302                 AddStringToResourceData (buffer, &data, &cum_len);
2303                 sprintf (buffer, "%s*rows: %d \\n ", dialogName, rows);
2304                 AddStringToResourceData (buffer, &data, &cum_len);
2305                 sprintf (buffer, "%s*helpType: %d \\n ", dialogName, helpType);
2306                 AddStringToResourceData (buffer, &data, &cum_len);
2307                 sprintf (buffer, "%s*vPCount: %d \\n ", dialogName, vPCount);
2308                 AddStringToResourceData (buffer, &data, &cum_len);
2309                 sprintf (buffer, "%s*tTitle: %s\\n ", dialogName, topicTitle);
2310                 AddStringToResourceData (buffer, &data, &cum_len);
2311
2312                 ac = 0;
2313                 switch (helpType)
2314                 {
2315                   case  DtHELP_TYPE_TOPIC:
2316                     XtSetArg (getArgs[ac],DtNhelpVolume, &helpVolume); ac++; 
2317                     XtSetArg (getArgs[ac], DtNlocationId, &locationId); ac++;
2318                     XtGetValues(pTemp->helpDialog, getArgs, ac);
2319                     sprintf (buffer, "%s*helpVolume: %s\\n ", 
2320                              dialogName, helpVolume);
2321                     AddStringToResourceData (buffer, &data, &cum_len);
2322                     sprintf (buffer, "%s*locationId: %s\\n ", 
2323                              dialogName, locationId);
2324                     AddStringToResourceData (buffer, &data, &cum_len);
2325
2326                     break;
2327                     
2328                   case DtHELP_TYPE_DYNAMIC_STRING:
2329                     XtSetArg (getArgs[ac], DtNstringData, &stringData); ac++;
2330                     XtGetValues(pTemp->helpDialog, getArgs, ac);
2331                     sprintf (buffer, "%s*stringData: %s\\n ", 
2332                              dialogName, stringData);
2333                     AddStringToResourceData (buffer, &data, &cum_len);
2334
2335                     break;
2336                     
2337                   case DtHELP_TYPE_MAN_PAGE:
2338                     
2339                     break;
2340                     
2341                   case DtHELP_TYPE_FILE:
2342         
2343                     break;
2344                     
2345                   default:
2346                     /* error condition, don't try to display help */
2347                     break;
2348                 }
2349
2350                 if (pCDforHelp)
2351                 {
2352                     thisCnt = 0;
2353                     sprintf(workspaces, "%s", "");
2354                     for (wsCnt = 0; wsCnt < pSD->numWorkspaces;
2355                          wsCnt++)
2356                     {
2357                         wsID = XInternAtom (DISPLAY, pSD->pWS[wsCnt].name, 
2358                                             False);
2359                         pWS = GetWorkspaceData (pSD, wsID);
2360
2361                         if (ClientInWorkspace (pWS, pCDforHelp))
2362                         {
2363                             if (thisCnt == 0)
2364                             {
2365                                 strcpy(workspaces, pSD->pWS[wsCnt].name); 
2366
2367                             }
2368                             else
2369                             {
2370                                 strcat(workspaces, "*");
2371                                 strcat(workspaces, pSD->pWS[wsCnt].name);
2372                             }
2373                             thisCnt++;
2374                         }
2375                     }
2376                     sprintf (buffer, "%s*workspaces: %s\\n ", dialogName, 
2377                              workspaces);
2378                     AddStringToResourceData (buffer, &data, &cum_len);
2379                 }
2380                 pTemp = pTemp->pNext;
2381             }
2382         } /* While */
2383         if (cachedCount)
2384         {
2385             sprintf (buffer, "cachedHelp*cachedCount: %d\\n ",  cachedCount);
2386             AddStringToResourceData (buffer, &data, &cum_len);
2387         }
2388     }
2389
2390     if (data)
2391     {
2392         /*
2393          * Save help resources as a string 
2394          */
2395         sprintf (buffer, " \n");
2396         AddStringToResourceData (buffer, &data, &cum_len);
2397         
2398         _DtAddToResource (DISPLAY, data);
2399         XtFree(data);
2400     }
2401 #endif /*  NO_DT */
2402 } /* END OF FUNCTION  SaveHelpResources */
2403
2404
2405  
2406 /* Code stolen from WmPresence.c */
2407
2408 /*************************************<->*************************************
2409  *
2410  *  void
2411  *  ShowHelpDialog (pClient)
2412  *
2413  *
2414  *  Description:
2415  *  -----------
2416  *  Pops up (shows) the help dialog
2417  *
2418  *  Inputs:
2419  *  ------
2420  *
2421  * 
2422  *  Outputs:
2423  *  -------
2424  *  Return = none
2425  *
2426  *
2427  *  Comments:
2428  *  --------
2429  * 
2430  ******************************<->***********************************/
2431
2432 static void 
2433 ShowHelpDialog(
2434         ClientData *pClient)
2435 {
2436     PtrWsDtHelpData  pHelp;
2437     WmScreenData *pSD;
2438     ClientData *pOldCD;
2439
2440     if (!(pClient))
2441     {
2442         pSD=wmGD.pActiveSD;
2443     }
2444     else
2445     {
2446         pSD = pClient->pSD;
2447     }
2448     pHelp = &pSD->dtHelp;  
2449
2450     pOldCD = pHelp->pCDforClient;
2451     pHelp->pCDforClient = pClient;
2452 /*    pHelp->contextForClient = wsContext;*/
2453
2454     if (pSD->dtHelp.onScreen)
2455     {
2456         ClientData *pCD = NULL;
2457
2458         XFindContext (DISPLAY, XtWindow (pSD->dtHelp.shell),
2459                         wmGD.windowContextType, (XtPointer) &pCD);
2460
2461         if ((!pSD->dtHelp.bMapped) ||
2462             (pCD &&
2463              (!ClientInWorkspace (ACTIVE_WS, pCD) ||
2464              (pCD->clientState == MINIMIZED_STATE) ||
2465              (pOldCD && pOldCD != pHelp->pCDforClient))))
2466         {
2467             HideHelpDialog (pSD, True);
2468         }
2469     }
2470     
2471     /* 
2472      * pop it up 
2473      */
2474
2475     XtManageChild(pSD->dtHelp.dialog);
2476     XtPopup (pSD->dtHelp.shell, XtGrabNone);
2477
2478     pSD->dtHelp.onScreen = True;
2479
2480 } /* END OF FUNCTION  ShowHelpDialog */
2481
2482
2483 /*************************************<->*************************************
2484  *
2485  *  void
2486  *  HideHelpDialog (pSD, userDismissed)
2487  *
2488  *
2489  *  Description:
2490  *  -----------
2491  *  Pops down (hides) the workspace presence dialog
2492  *
2493  *  Inputs:
2494  *  ------
2495  *  pSD = pointer to screen data
2496  *  userDismissed = did the user dismiss or did workspace switching 
2497  *                  unpost the workspace presence box ?
2498  * 
2499  *  Outputs:
2500  *  -------
2501  *  Return = none
2502  *
2503  *
2504  *  Comments:
2505  *  --------
2506  * 
2507  ******************************<->***********************************/
2508
2509 static void 
2510 HideHelpDialog(
2511         WmScreenData *pSD,
2512         Boolean userDismissed )
2513
2514 {
2515     if (pSD->dtHelp.onScreen)
2516     {
2517         /* Pop down the shell */
2518         XtPopdown (pSD->dtHelp.shell);
2519
2520         /* 
2521          * Do a withdraw to make sure window gets unmanaged
2522          * (popdown does nothing if its unmapped)
2523          */
2524         XWithdrawWindow (DISPLAY, XtWindow (pSD->dtHelp.shell),
2525                          pSD->screen);
2526         /* must sync to insure event order */
2527         XSync (DISPLAY, False);
2528         
2529         
2530         pSD->dtHelp.onScreen = False;
2531         pSD->dtHelp.userDismissed = userDismissed;
2532     }
2533
2534 } /* END OF FUNCTION HideHelpDialog  */
2535
2536
2537 /*************************************<->*************************************
2538  *
2539  *  wmDtHelpSetPosition (pHelp, pSD, restorePos)
2540  *
2541  *
2542  *  Description:
2543  *  -----------
2544  *  Sets the position of the workspace presence dialog
2545  *
2546  *  Inputs:
2547  *  ------
2548  *  pPres = pointer to workspace presence data
2549  *
2550  *  Outputs:
2551  *  --------
2552  * 
2553  ******************************<->***********************************/
2554 static void 
2555 wmDtHelpSetPosition(
2556                      PtrWsDtHelpData pHelp,
2557                      WmScreenData *pSD,
2558                      Boolean restorePos)
2559 {
2560     Arg args[10];
2561     int n;
2562     XFontStruct *font;
2563     Dimension height;
2564     Window wGroup = None;
2565     int x, y;
2566     ClientData *pCDforHelp;
2567
2568     if (!restorePos)
2569     {
2570         /*
2571          * Get size of this dialog
2572          */
2573         n = 0;
2574         XtSetArg (args[n], XmNheight, &height); n++;
2575         XtGetValues (pHelp->shell, args, n);
2576         
2577         if (wmGD.positionIsFrame)
2578         {
2579             if (pSD->decoupleTitleAppearance)
2580             {
2581                 font = pSD->clientTitleAppearance.font;
2582             }
2583             else
2584             {
2585                 font = pSD->clientAppearance.font;
2586             }
2587             
2588 /*          height += TEXT_HEIGHT(font) + (2 * pSD->frameBorderWidth);*/
2589             height += TEXT_HEIGHT(font) + (2 * pSD->resizeBorderWidth);
2590         }
2591
2592         
2593         /* 
2594          * set position of dialog relative to client window 
2595          * (use system menu position)
2596          * set this dialog to be transient for the client
2597          * for which it is posted.
2598      */
2599         if (pHelp->pCDforClient)
2600         {
2601             GetSystemMenuPosition (pHelp->pCDforClient, 
2602                                    &x, &y, height,
2603                                    (Context)0);
2604 #ifdef NO
2605             if(y < pHelp->pCDforClient->frameInfo.y)
2606             {
2607                 if (!XFindContext (DISPLAY, XtWindow(pHelp->shell),
2608                                    wmGD.windowContextType, 
2609                                    (caddr_t *)&pCDforHelp))
2610                 {
2611                     if (wmGD.positionIsFrame)
2612                     {
2613 /*                      x = x - pCDforHelp->clientOffset.x;*/
2614                         y = y - pCDforHelp->clientOffset.x;
2615                     }
2616                 }
2617                 else
2618                 {
2619                     y = y - (2 * pSD->frameBorderWidth);
2620                 }
2621             }
2622 #endif
2623         }
2624         else
2625         {
2626             /*
2627              * Don't have a client so map at 0,0
2628          */
2629             x = 0;
2630             y = 0;
2631         }
2632     }
2633     else
2634     {
2635         x = pHelp->xPos;
2636         y = pHelp->yPos;
2637     }
2638
2639     n = 0;
2640     XtSetArg (args[n], XmNgeometry, NULL); n++;
2641     XtSetArg (args[n], XmNx, x);                                n++;
2642     XtSetArg (args[n], XmNy, y);                                n++;
2643     XtSetArg (args[n], XmNtransientFor, NULL);                  n++;
2644
2645     if (pHelp->pCDforClient)
2646     {
2647         int ac;
2648         Arg al[5];
2649
2650         ac = 0;
2651         XtSetArg (al[ac], XmNwindowGroup, &wGroup); ac++;
2652         XtGetValues (pHelp->shell, al, ac);
2653
2654 #ifdef FUTURE
2655         if (pHelp->contextForClient != F_CONTEXT_ICON)
2656         {
2657             XtSetArg (args[n], XmNwindowGroup, 
2658                       pHelp->pCDforClient->client); 
2659             n++;
2660         }
2661         else if (pSD->useIconBox && P_ICON_BOX(pHelp->pCDforClient))
2662         {
2663             XtSetArg (args[n], XmNwindowGroup, 
2664                       P_ICON_BOX(pHelp->pCDforClient)->pCD_iconBox->client); 
2665             n++;
2666         }
2667         else
2668         {
2669             XtSetArg (args[n], XmNwindowGroup, 0); n++;
2670         }
2671 #else /* FUTURE */
2672         if (wGroup != pHelp->pCDforClient->client)
2673         {
2674             /*
2675              * Changing who this is transient for, need to 
2676              * make sure the window is unmapped so that the
2677              * window manager moves it to the right place.
2678              */
2679             HideHelpDialog (pSD, True);
2680         }
2681
2682         XtSetArg (args[n], XmNwindowGroup, pHelp->pCDforClient->client); n++;
2683 #endif /* FUTURE */
2684     }
2685     else
2686     {
2687         if (wGroup != None)
2688         {
2689             HideHelpDialog (pSD, True);
2690         }
2691         XtSetArg (args[n], XmNwindowGroup, 0); n++;
2692     }
2693
2694     XtSetArg (args[n], XmNwaitForWm, False);                    n++;
2695
2696     XtSetValues (pHelp->shell, args, n);
2697
2698     
2699 } /* END OF FUNCTION wmDtHelpSetPosition */
2700
2701 /* End of Code stolen from WmPresence.c */
2702
2703 /*************************************<->*************************************
2704  *
2705  *  wmDtHelpMapEventHandler (wHelp, pSD, pEvent)
2706  *
2707  *
2708  *  Description:
2709  *  -----------
2710  *  An XtEventHandler called on structure notify events on the screen's 
2711  *  help window.  (Only handles map and unmap events)
2712  *
2713  *  Inputs:
2714  *  ------
2715  *  wHelp = help widget
2716  *  pSD = ptr to screen data
2717  *  pEvent = event triggering this call
2718  *
2719  *  Outputs:
2720  *  --------
2721  * 
2722  ******************************<->***********************************/
2723 static void
2724 wmDtHelpMapEventHandler(
2725         Widget wHelp, 
2726         XtPointer ptr,
2727         XEvent  *pEvent,
2728         Boolean *pBoolean)      /* unused */
2729 {
2730     WmScreenData *pSD = (WmScreenData *) ptr;
2731
2732     switch (pEvent->type)
2733     {
2734         case MapNotify:
2735             pSD->dtHelp.bMapped = True;
2736             break;
2737
2738         case UnmapNotify:
2739             pSD->dtHelp.bMapped = False;
2740             break;
2741     }
2742 }
2743 /* END OF FUNCTION wmDtHelpMapHandler */
2744
2745
2746
2747 /*************************************<->*************************************
2748  *
2749  *  wmDtErrorDialog (pSD, message, title)
2750  *
2751  *
2752  *  Description:
2753  *  -----------
2754  *  Called to show an error message
2755  *
2756  *  Inputs:
2757  *  ------
2758  *  pSD = ptr to screen data
2759  *  message = error message to display
2760  *  title = title for the error dialog
2761  *
2762  *  Outputs:
2763  *  --------
2764  * 
2765  ******************************<->***********************************/
2766 static void
2767 wmDtErrorDialog(
2768         WmScreenData *pSD,
2769         String sMessage,
2770         String sTitle
2771                 )
2772 {
2773     int ac;
2774     Arg al[20];
2775     XmString xmsMessage;
2776     XmString xmsTitle;
2777     Widget wTemp;
2778     Widget wParent;
2779     Widget wShell;
2780     Window wRoot, wChild; 
2781     int rootX, rootY, winX, winY;
2782     unsigned int mask;
2783     Dimension dWidth, dHeight;
2784     Position x, y;
2785 #ifdef PANELIST
2786     WmPanelistObject  pPanelist;
2787 #endif /* PANELIST */
2788
2789     xmsMessage = 
2790             XmStringCreateLocalized (sMessage);
2791     xmsTitle = 
2792             XmStringCreateLocalized (sTitle);
2793
2794     if (pSD->dtHelp.errorDialog == NULL)
2795     {
2796 #ifdef NO_MESSAGE_CATALOG
2797         XmString tmpXmString = (XmString)NULL;
2798 #endif
2799
2800         ac = 0;
2801         XtSetArg (al[ac], XmNmessageString, xmsMessage);        ac++;
2802         XtSetArg (al[ac], XmNdialogTitle, xmsTitle);            ac++;
2803 #ifndef NO_MESSAGE_CATALOG
2804         XtSetArg (al[ac], XmNokLabelString, wmGD.okLabel);      ac++;
2805 #else
2806         tmpXmString = XmStringCreateLocalized ("OK");
2807         XtSetArg (al[ac], XmNokLabelString, tmpXmString); ac++;
2808 #endif
2809
2810 #if 0
2811         if ((wmGD.dtSD == pSD) && pSD->wPanelist)
2812         {
2813             pPanelist = (WmPanelistObject) pSD->wPanelist;
2814             wParent = O_Shell (pPanelist);
2815         }
2816         else
2817         {
2818             wParent = pSD->screenTopLevelW1;
2819         }
2820 #else
2821         wParent = pSD->screenTopLevelW1;
2822 #endif
2823         pSD->dtHelp.errorDialog =
2824             XmCreateErrorDialog (wParent, "Error Dialog", al, ac);
2825
2826 #ifdef NO_MESSAGE_CATALOG
2827         if (tmpXmString)
2828             XmStringFree(tmpXmString);
2829 #endif
2830
2831         wTemp = XmMessageBoxGetChild (pSD->dtHelp.errorDialog, 
2832                         XmDIALOG_HELP_BUTTON);
2833         XtUnmanageChild (wTemp);
2834
2835         wTemp = XmMessageBoxGetChild (pSD->dtHelp.errorDialog, 
2836                         XmDIALOG_CANCEL_BUTTON);
2837         XtUnmanageChild (wTemp);
2838
2839         XtAddCallback (pSD->dtHelp.errorDialog, XmNokCallback, 
2840                         wmDtErrorDialogOkCB, (XtPointer)pSD); 
2841
2842         wShell = pSD->dtHelp.errorDialog;
2843         while (!(XtIsSubclass(wShell, shellWidgetClass)))
2844         {
2845             wShell = XtParent(wShell);
2846         }
2847         XtAddCallback(wShell, XmNpopupCallback, wmDtErrorDialogPopupCB, 
2848                         (XtPointer)pSD);
2849
2850         XtRealizeWidget (pSD->dtHelp.errorDialog);
2851
2852         /* remove some WM functions */
2853         ac = 0;
2854         XtSetArg (al[ac], XmNmwmFunctions, (MWM_FUNC_ALL|
2855             MWM_FUNC_RESIZE|MWM_FUNC_MINIMIZE|MWM_FUNC_MAXIMIZE));
2856             ac++;
2857         XtSetValues (wShell, al, ac);
2858
2859         DtWsmRemoveWorkspaceFunctions (DISPLAY, XtWindow(wShell));
2860     }
2861     else
2862     {
2863         /* make sure it's unmanaged */
2864         wmDtErrorDialogHide (pSD);
2865
2866         /* set new message and title */
2867         ac = 0;
2868         XtSetArg (al[ac], XmNmessageString, xmsMessage);        ac++;
2869         XtSetArg (al[ac], XmNdialogTitle, xmsTitle);            ac++;
2870         XtSetValues (pSD->dtHelp.errorDialog, al, ac);
2871     }
2872
2873     if (pSD->dtHelp.errorDialog)
2874     {
2875         XtManageChild (pSD->dtHelp.errorDialog);
2876         XtPopup (XtParent(pSD->dtHelp.errorDialog), XtGrabNone);
2877     }
2878
2879     XmStringFree (xmsMessage);
2880     XmStringFree (xmsTitle);
2881 }
2882 /* END OF FUNCTION wmDtErrorDialog */
2883
2884 \f
2885 /*************************************<->*************************************
2886  *
2887  *  void
2888  *  wmDtErrorDialogHide (pSD)
2889  *
2890  *
2891  *  Description:
2892  *  -----------
2893  *
2894  *
2895  *  Inputs:
2896  *  ------
2897  *  pSD = ptr to screen data
2898  *
2899  * 
2900  *  Outputs:
2901  *  -------
2902  *  Return = ...
2903  *
2904  *
2905  *  Comments:
2906  *  --------
2907  * 
2908  *************************************<->***********************************/
2909
2910 static void 
2911 wmDtErrorDialogHide( WmScreenData *pSD )
2912 {
2913     Widget wShell;
2914
2915     XtPopdown (XtParent(pSD->dtHelp.errorDialog));
2916     XtUnmanageChild (pSD->dtHelp.errorDialog);
2917     /* 
2918      * Do a withdraw to make sure window gets unmanaged
2919      * (popdown does nothing if its unmapped)
2920      */
2921     wShell = pSD->dtHelp.errorDialog;
2922     while (!(XtIsSubclass(wShell, shellWidgetClass)))
2923     {
2924         wShell = XtParent(wShell);
2925     }
2926     if (wShell)
2927         XWithdrawWindow (DISPLAY, XtWindow (wShell), pSD->screen);
2928
2929     /* must sync to insure event order */
2930     XSync (DISPLAY, False);
2931
2932 } /* END OF FUNCTION wmDtErrorDialogHide */
2933
2934 \f
2935 /*************************************<->*************************************
2936  *
2937  *  void
2938  *  wmDtErrorDialogOkCB (w, client_data, call_data)
2939  *
2940  *
2941  *  Description:
2942  *  -----------
2943  *
2944  *
2945  *  Inputs:
2946  *  ------
2947  *  w = ...
2948  *  client_data = ...
2949  *  call_data = ...
2950  *
2951  * 
2952  *  Outputs:
2953  *  -------
2954  *  Return = ...
2955  *
2956  *
2957  *  Comments:
2958  *  --------
2959  * 
2960  *************************************<->***********************************/
2961
2962 static void 
2963 wmDtErrorDialogOkCB(
2964         Widget w,
2965         XtPointer client_data,
2966         XtPointer call_data )
2967 {
2968     WmScreenData *pSD = (WmScreenData *) client_data;
2969
2970     wmDtErrorDialogHide (pSD);
2971
2972 } /* END OF FUNCTION wmDtErrorDialogOkCB */
2973
2974 \f
2975 /*************************************<->*************************************
2976  *
2977  *  void
2978  *  wmDtErrorDialogPopupCB (w, client_data, call_data)
2979  *
2980  *
2981  *  Description:
2982  *  -----------
2983  *
2984  *
2985  *  Inputs:
2986  *  ------
2987  *  w = ...
2988  *  client_data = ...
2989  *  call_data = ...
2990  *
2991  * 
2992  *  Outputs:
2993  *  -------
2994  *  Return = ...
2995  *
2996  *
2997  *  Comments:
2998  *  --------
2999  * 
3000  *************************************<->***********************************/
3001
3002 static void 
3003 wmDtErrorDialogPopupCB(
3004         Widget w,
3005         XtPointer client_data,
3006         XtPointer call_data )
3007 {
3008     WmScreenData *pSD = (WmScreenData *) client_data;
3009     Window wRoot, wChild; 
3010     int rootX, rootY, winX, winY;
3011     unsigned int mask;
3012     Dimension dWidth, dHeight;
3013     Position x, y;
3014     Arg al[10];
3015     int ac;
3016
3017     /* set new position near cursor position */
3018     XQueryPointer (DISPLAY, XtWindow(pSD->screenTopLevelW1),
3019         &wRoot, &wChild, &rootX, &rootY, &winX, &winY, &mask);
3020
3021     ac = 0;
3022     XtSetArg (al[ac], XmNwidth, &dWidth);                       ac++;
3023     XtSetArg (al[ac], XmNheight, &dHeight);                     ac++;
3024     XtGetValues (w, al, ac);
3025
3026     x = (Position) rootX - (dWidth / 2);
3027     y = (Position) rootY - (dHeight / 2);
3028
3029     if ((x + ((Position) dWidth / 2)) > DisplayWidth (DISPLAY, pSD->screen))
3030         x = DisplayWidth (DISPLAY,pSD->screen) - (dWidth/2) - 1;
3031     if (x < 0) 
3032         x = 0;
3033
3034     if ((y + ((Position) dHeight / 2)) > DisplayHeight (DISPLAY, pSD->screen))
3035         y = DisplayHeight (DISPLAY,pSD->screen) - (dHeight/2) - 1;
3036     if (y < 0) 
3037         y = 0;
3038
3039     ac = 0;
3040     XtSetArg (al[ac], XmNx, x);                 ac++; 
3041     XtSetArg (al[ac], XmNy, y);                 ac++;
3042     XtSetArg (al[ac], XmNwindowGroup, 
3043                         XtUnspecifiedWindowGroup);      ac++; 
3044     XtSetArg (al[ac], XmNwaitForWm, False);             ac++;
3045     XtSetValues (w, al, ac);
3046
3047
3048 } /* END OF FUNCTION wmDtErrorDialogPopupCB */
3049
3050 /****************************   eof    ***************************/
3051 #endif /* WSM */
3052
3053
3054
3055