5e6fc5577b372fcf5d4edbd4c335555b0dfbf94d
[oweals/cde.git] / cde / programs / dtwm / WmResource.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 /* 
24  * (c) Copyright 1989, 1990, 1991, 1992, 1993 OPEN SOFTWARE FOUNDATION, INC. 
25  * ALL RIGHTS RESERVED 
26 */ 
27 /* 
28  * Motif Release 1.2.3
29 */ 
30 /*
31  * (c) Copyright 1987, 1988, 1989, 1990, 1993, 1994 HEWLETT-PACKARD COMPANY 
32  * (c) Copyright 1993, 1994 International Business Machines Corp.
33  * (c) Copyright 1993, 1994 Sun Microsystems, Inc.
34  * (c) Copyright 1993, 1994 Novell, Inc.
35  */
36
37 /*
38  * Included Files:
39  */
40
41 #include "WmGlobal.h"
42 #include "WmResNames.h"
43
44 #define MWM_NEED_IIMAGE
45 #include "WmIBitmap.h"
46
47 #include <stdio.h>
48
49 #include <Xm/XmP.h>
50 #include <Xm/RowColumn.h>
51 #include <Xm/ScreenP.h>         /* for XmGetXmScreen and screen.moveOpaque */
52
53 /*
54  * include extern functions
55  */
56 #include "WmResource.h"
57 #include "WmError.h"
58 #include "WmGraphics.h"
59 #include "WmMenu.h"
60 #include "WmResParse.h"
61 #include "WmBackdrop.h"
62 #include "WmIconBox.h"
63 #include "WmWrkspace.h"
64 #include <Dt/GetDispRes.h>
65 #define cfileP  (wmGD.pWmPB->pFile) /* fopen'ed configuration file or NULL */
66 #include "WmXSMP.h"
67
68 /*
69  * Function Declarations:
70  */
71 XmColorData *_WmGetDefaultColors ();
72
73 void _WmTopShadowPixmapDefault (Widget widget, int offset, XrmValue *value);
74 void _WmIconImageFDefault (Widget widget, int offset, XrmValue *value);
75 void _WmIconImageBDefault (Widget widget, int offset, XrmValue *value);
76 void _WmIconImageBSCDefault (Widget widget, int offset, XrmValue *value);
77 void _WmIconImageBSPDefault (Widget widget, int offset, XrmValue *value);
78 void _WmIconImageTSCDefault (Widget widget, int offset, XrmValue *value);
79 void _WmIconImageTSPDefault (Widget widget, int offset, XrmValue *value);
80 void _WmMatteFDefault (Widget widget, int offset, XrmValue *value);
81 void _WmMatteBDefault (Widget widget, int offset, XrmValue *value);
82 void _WmMatteBSCDefault (Widget widget, int offset, XrmValue *value);
83 void _WmMatteBSPDefault (Widget widget, int offset, XrmValue *value);
84 void _WmMatteTSCDefault (Widget widget, int offset, XrmValue *value);
85 void _WmMatteTSPDefault (Widget widget, int offset, XrmValue *value);
86 void _WmBackgroundDefault (Widget widget, int offset, XrmValue *value);
87 void _WmForegroundDefault (Widget widget, int offset, XrmValue *value);
88 void _WmBackgroundPixmapDefault (Widget widget, int offset, XrmValue *value);
89 void _WmBottomShadowColorDefault (Widget widget, int offset, XrmValue *value);
90 void _WmTopShadowColorDefault (Widget widget, int offset, XrmValue *value);
91 void _WmABackgroundDefault (Widget widget, int offset, XrmValue *value);
92 void _WmAForegroundDefault (Widget widget, int offset, XrmValue *value);
93 void _WmABackgroundPixmapDefault (Widget widget, int offset, XrmValue *value);
94 void _WmABottomShadowColorDefault (Widget widget, int offset, XrmValue *value);
95 void _WmATopShadowColorDefault (Widget widget, int offset, XrmValue *value);
96 void _WmATopShadowPixmapDefault (Widget widget, int offset, XrmValue *value);
97 void _WmFocusAutoRaiseDefault (Widget widget, int offset, XrmValue *value);
98 void _WmMultiClickTimeDefault (Widget widget, int offset, XrmValue *value);
99 void ProcessWmResources (void);
100 void ProcessGlobalScreenResources (void);
101 void SetStdGlobalResourceValues (void);
102 void ProcessScreenListResource (void);
103 void ProcessAppearanceResources (WmScreenData *pSD);
104 void MakeAppearanceResources (WmScreenData *pSD, AppearanceData *pAData, Boolean makeActiveResources);
105 void GetAppearanceGCs (WmScreenData *pSD, Pixel fg, Pixel bg, XFontStruct *font, Pixmap bg_pixmap, Pixel ts_color, Pixmap ts_pixmap, Pixel bs_color, Pixmap bs_pixmap, GC *pGC, GC *ptsGC, GC *pbsGC);
106 void ProcessScreenResources (WmScreenData *pSD, unsigned char *screenName);
107 void ProcessWorkspaceResources (WmWorkspaceData *pWS);
108 void ProcessClientResources (ClientData *pCD);
109 void SetStdClientResourceValues (ClientData *pCD);
110 void SetStdScreenResourceValues (WmScreenData *pSD);
111 GC GetHighlightGC (WmScreenData *pSD, Pixel fg, Pixel bg, Pixmap pixmap);
112 static void WriteOutXrmColors (WmScreenData *pSD);
113 void ProcessPresenceResources (WmScreenData *pSD);
114 void ProcessDefaultBackdropImages (WmScreenData *pSD);
115 void _WmBackdropBgDefault (Widget widget, int offset, XrmValue *value);
116 void _WmBackdropFgDefault (Widget widget, int offset, XrmValue *value);
117 void _WmBackdropColorSetDefault (Widget widget, int offset, XrmValue *value);
118 void _WmIconImageMaximumDefault (Widget widget, int offset, XrmValue *value);
119 void _WmSecondariesOnTopDefault (Widget widget, int offset, XrmValue *value);
120 int DefaultWsColorSetId (WmWorkspaceData *pWS);
121 void _WmGetDynamicDefault (Widget widget, unsigned char type, String defaultColor, Pixel newBackground, XrmValue *value);
122 Boolean SimilarAppearanceData (AppearanceData *pAD1, AppearanceData *pAD2);
123
124
125
126 /*
127  * Global Variables:
128  */
129
130 /* builtin window menu specification */
131
132 #ifndef NO_MESSAGE_CATALOG
133 /*
134  * Use the same name as builtin to let the message catalog menu
135  * take precedence over any menus that might match in sys.mwmrc
136  */
137 char defaultSystemMenuName[] = "_MwmWindowMenu_";
138 #else
139 char defaultSystemMenuName[] = "DefaultWindowMenu";
140 #endif  /* NO_MESSAGE_CATALOG */
141 char builtinSystemMenuName[] = "_MwmWindowMenu_";
142 #ifndef MCCABE
143 #define BUILTINSYSTEMMENU "_MwmWindowMenu_\n\
144 {\n\
145         Restore         _R      Alt<Key>F5      f.restore\n\
146         Move            _M      Alt<Key>F7      f.move\n\
147         Size            _S      Alt<Key>F8      f.resize\n\
148         Minimize        _n      Alt<Key>F9      f.minimize\n\
149         Maximize        _x      Alt<Key>F10     f.maximize\n\
150         Lower           _L      Alt<Key>F3      f.lower\n\
151         no-label                                f.separator\n\
152         Close           _C      Alt<Key>F4      f.kill\n\
153 }"
154 #ifdef NO_MESSAGE_CATALOG
155 char builtinSystemMenu[] = BUILTINSYSTEMMENU;
156 #else /* !defined(NO_MESSAGE_CATALOG)*/
157 char *builtinSystemMenu = BUILTINSYSTEMMENU;
158
159 #define DEFAULT_DTWM_SYSTEMMENU "_MwmWindowMenu_\n\
160 {\n\
161         Restore         _R      f.restore\n\
162         Move            _M      f.move\n\
163         Size            _S      f.resize\n\
164         Minimize        _n      f.minimize\n\
165         Maximize        _x      f.maximize\n\
166         Lower           _L      f.lower\n\
167         no-label                f.separator\n\
168       \"Occupy Workspace...\"   _O      f.workspace_presence\n\
169       \"Occupy All Workspaces\" _A      f.occupy_all\n\
170       \"Unoccupy Workspace\"    _U      f.remove\n\
171         no-label                        f.separator\n\
172         Close   _C      Alt<Key>F4      f.kill\n\
173 }"
174
175 void InitBuiltinSystemMenu(void)
176 {
177     char * tmpString;
178     char *ResString = NULL;
179     char *MovString = NULL;
180     char *SizString = NULL;
181     char *MinString = NULL;
182     char *MaxString = NULL;
183     char *LowString = NULL;
184     char *OcpString = NULL;
185     char *OcaString = NULL;
186     char *RemString = NULL;
187     char *CloString = NULL;
188     char dsm[2048];
189     char dsmtemp[sizeof(dsm)];
190     Boolean gotItAll;
191     gotItAll = True;
192     if(gotItAll)
193     {
194 #ifdef sun
195         tmpString = ((char *)GETMESSAGE(62, 60, "Restore _R  Alt<Key>F5 f.restore"));
196 #else
197         tmpString = ((char *)GETMESSAGE(62, 49, "Restore _R  f.restore"));
198 #endif
199         if ((ResString =
200              (char *)XtMalloc ((unsigned int) (strlen(tmpString) + 1))) == NULL)
201         {
202             Warning (((char *)GETMESSAGE(62, 2, "Insufficient memory for local default menu.")));
203             gotItAll = False;
204         }
205         else
206         {
207             strcpy(ResString, tmpString);
208         }
209     }
210     if(gotItAll)
211     {
212 #ifdef sun
213         tmpString = ((char *)GETMESSAGE(62, 61, "Move _M  Alt<Key>F7 f.move"));
214 #else
215         tmpString = ((char *)GETMESSAGE(62, 50, "Move _M  f.move"));
216 #endif
217         if ((MovString =
218              (char *)XtMalloc ((unsigned int) (strlen(tmpString) + 1))) == NULL)
219         {
220             Warning (((char *)GETMESSAGE(62, 4, "Insufficient memory for local default menu.")));
221             gotItAll = False;
222         }
223         else
224         {
225             strcpy(MovString, tmpString);
226         }
227     }
228     if(gotItAll)
229     {
230 #ifdef sun
231         tmpString = ((char *)GETMESSAGE(62, 62, "Size _S  Alt<Key>F8 f.resize"));
232 #else
233         tmpString = ((char *)GETMESSAGE(62, 51, "Size _S  f.resize"));
234 #endif
235         if ((SizString =
236              (char *)XtMalloc ((unsigned int) (strlen(tmpString) + 1))) == NULL)
237         {
238             Warning (((char *)GETMESSAGE(62, 6, "Insufficient memory for local default menu.")));
239             gotItAll = False;
240         }
241         else
242         {
243             strcpy(SizString, tmpString);
244         }
245     }
246     if(gotItAll)
247     {
248 #ifdef sun
249         tmpString = ((char *)GETMESSAGE(62, 63, "Minimize _n  Alt<Key>F9 f.minimize"));
250 #else
251         tmpString = ((char *)GETMESSAGE(62, 52, "Minimize _n  f.minimize"));
252 #endif
253         if ((MinString =
254              (char *)XtMalloc ((unsigned int) (strlen(tmpString) + 1))) == NULL)
255         {
256             Warning (((char *)GETMESSAGE(62, 8, "Insufficient memory for local default menu.")));
257             gotItAll = False;
258         }
259         else
260         {
261             strcpy(MinString, tmpString);
262         }
263     }
264     if(gotItAll)
265     {
266 #ifdef sun
267         tmpString = ((char *)GETMESSAGE(62, 64, "Maximize _x  Alt<Key>F10 f.maximize"));
268 #else
269         tmpString = ((char *)GETMESSAGE(62, 53, "Maximize _x  f.maximize"));
270 #endif
271         if ((MaxString =
272              (char *)XtMalloc ((unsigned int) (strlen(tmpString) + 1))) == NULL)
273         {
274             Warning (((char *)GETMESSAGE(62, 10, "Insufficient memory for local default menu.")));
275             gotItAll = False;
276         }
277         else
278         {
279             strcpy(MaxString, tmpString);
280         }
281     }
282     if(gotItAll)
283     {
284 #ifdef sun
285         tmpString = ((char *)GETMESSAGE(62, 65, "Lower _L  Alt<Key>F3 f.lower"));
286 #else
287         tmpString = ((char *)GETMESSAGE(62, 54, "Lower _L  f.lower"));
288 #endif
289         if ((LowString =
290              (char *)XtMalloc ((unsigned int) (strlen(tmpString) + 1))) == NULL)
291         {
292             Warning (((char *)GETMESSAGE(62, 12, "Insufficient memory for local default menu.")));
293             gotItAll = False;
294         }
295         else
296         {
297             strcpy(LowString, tmpString);
298         }
299     }
300
301     if (DtwmBehavior)
302     {
303         if(gotItAll)
304         {
305             tmpString = ((char *)GETMESSAGE(62, 55, "Occupy\\ Workspace\\.\\.\\. _O  f.workspace_presence"));
306             if ((OcpString =
307                  (char *)XtMalloc ((unsigned int) 
308                                  (strlen(tmpString) + 1))) == NULL)
309             {
310                 Warning (((char *)GETMESSAGE(62, 14, "Insufficient memory for local default menu.")));
311                 gotItAll = False;
312             }
313             else
314             {
315                 strcpy(OcpString, tmpString);
316             }
317         }
318         if(gotItAll)
319         {
320             tmpString = ((char *)GETMESSAGE(62, 56, "Occupy\\ All\\ Workspaces _A  f.occupy_all"));
321             if ((OcaString =
322                  (char *)XtMalloc ((unsigned int) 
323                                  (strlen(tmpString) + 1))) == NULL)
324             {
325                 Warning (((char *)GETMESSAGE(62, 16, "Insufficient memory for local default menu.")));
326                 gotItAll = False;
327             }
328             else
329             {
330                 strcpy(OcaString, tmpString);
331             }
332         }
333         if(gotItAll)
334         {
335             tmpString = ((char *)GETMESSAGE(62, 57, "Unoccupy\\ Workspace _U  f.remove"));
336             if ((RemString =
337                  (char *)XtMalloc ((unsigned int) 
338                                  (strlen(tmpString) + 1))) == NULL)
339             {
340                 Warning (((char *)GETMESSAGE(62, 18, "Insufficient memory for local default menu.")));
341                 gotItAll = False;
342             }
343             else
344             {
345                 strcpy(RemString, tmpString);
346             }
347         }
348     } /* if DTWM */
349
350     if(gotItAll)
351     {
352         tmpString = ((char *)GETMESSAGE(62, 48, "Close _C Alt<Key>F4 f.kill"));
353         if ((CloString =
354              (char *)XtMalloc ((unsigned int) (strlen(tmpString) + 1))) == NULL)
355         {
356             Warning (((char *)GETMESSAGE(62, 20, "Insufficient memory for local default menu.")));
357             gotItAll = False;
358         }
359         else
360         {
361             strcpy(CloString, tmpString);
362         }
363     }
364
365     if (!gotItAll)
366     {
367         if (DtwmBehavior)
368         {
369             builtinSystemMenu = (char *) 
370                         XtNewString((String)DEFAULT_DTWM_SYSTEMMENU);
371         }
372         else
373         {
374             builtinSystemMenu = (char *) 
375                         XtNewString((String)BUILTINSYSTEMMENU);
376         }
377     }
378     else
379     {
380         /* put it together */
381         snprintf(dsm, sizeof(dsm), "%s\n{\n%s\n%s\n%s\n%s\n%s\n%s\n no-label  f.separator\n",
382                  defaultSystemMenuName, ResString, MovString,
383                  SizString, MinString, MaxString, LowString);
384         if (DtwmBehavior)
385         {
386             snprintf(dsmtemp, sizeof(dsmtemp), "%s%s\n%s\n%s\n no-label  f.separator\n",
387                      dsm, OcpString, OcaString, RemString);
388             strcpy(dsm, dsmtemp);
389         }
390         snprintf(dsmtemp, sizeof(dsmtemp), "%s%s\n}", dsm, CloString);
391         strcpy(dsm, dsmtemp);
392         
393         if ((builtinSystemMenu =
394              (char *)XtMalloc ((unsigned int) (strlen(dsm) + 1))) == NULL)
395         {
396            Warning (((char *)GETMESSAGE(62, 21, "Insufficient memory for localized default system menu")));
397             if (DtwmBehavior)
398             {
399                 builtinSystemMenu = (char *) 
400                         XtNewString((String)DEFAULT_DTWM_SYSTEMMENU);
401             }
402             else
403             {
404                 builtinSystemMenu = (char *) 
405                         XtNewString((String)BUILTINSYSTEMMENU);
406             }
407         }
408         else
409         {
410             strcpy(builtinSystemMenu, dsm);
411         }
412     }
413
414     if (ResString != NULL)
415        XtFree(ResString);
416     if (MovString != NULL)
417        XtFree(MovString);
418     if (SizString != NULL)
419        XtFree(SizString);
420     if (MinString != NULL)
421        XtFree(MinString);
422     if (MaxString != NULL)
423        XtFree(MaxString);
424     if (LowString != NULL)
425        XtFree(LowString);
426     if (OcpString != NULL)
427        XtFree(OcpString);
428     if (OcaString != NULL)
429        XtFree(OcaString);
430     if (RemString != NULL)
431        XtFree(RemString);
432     if (CloString != NULL)
433        XtFree(CloString);
434     
435 } /* END OF FUNCTION  InitBuiltinSystemMenu */
436 #endif /* NO_MESSAGE_CATALOG */
437 #else /* MCCABE */
438 char builtinSystemMenu[];
439 #endif /* MCCABE */
440
441 #define HARD_CODED_PRIMARY   3
442 char defaultRootMenuName[] = "DefaultRootMenu";
443 char builtinRootMenuName[] = "_MwmRootMenu_";
444 #ifndef MCCABE
445 #define BUILTINROOTMENU "DefaultRootMenu\n\
446 {\n\
447         \"Root Menu\"           f.title\n\
448         \"New Window\"          f.exec \"xterm &\"\n\
449         \"Shuffle Up\"          f.circle_up\n\
450         \"Shuffle Down\"        f.circle_down\n\
451         \"Refresh\"             f.refresh\n\
452         \"Pack Icons\"          f.pack_icons\n\
453          no-label               f.separator\n\
454         \"Restart...\"          f.restart\n\
455 }";
456 char builtinRootMenu[] = BUILTINROOTMENU
457 #else /* MCCABE */
458 char builtinRootMenu[];
459 #endif /* MCCABE */
460
461
462 /* builtin key bindings specification */
463
464 char defaultKeyBindingsName[] = "DefaultKeyBindings";
465 char builtinKeyBindingsName[] = "_MwmKeyBindings_";
466 #ifndef MCCABE
467 #define BUILTINKEYBINDINGS "_MwmKeyBindings_\n\
468 {\n\
469         Shift<Key>Escape        window|icon             f.post_wmenu\n\
470         Alt<Key>space           window|icon             f.post_wmenu\n\
471         Alt<Key>Tab             root|icon|window        f.next_key\n\
472         Alt Shift<Key>Tab       root|icon|window        f.prev_key\n\
473         Alt<Key>Escape          root|icon|window        f.circle_down\n\
474         Alt Shift<Key>Escape    root|icon|window        f.circle_up\n\
475         Alt Shift Ctrl<Key>exclam root|icon|window      f.set_behavior\n\
476         Alt Ctrl<Key>1            root|icon|window      f.set_behavior\n\
477         Alt<Key>F6              window                  f.next_key transient\n\
478         Alt Shift<Key>F6        window                  f.prev_key transient\n\
479         Shift<Key>F10           icon                    f.post_wmenu\n\
480 }";
481 char builtinKeyBindings[] = BUILTINKEYBINDINGS
482
483 #else
484 char builtinKeyBindings[];
485 #endif
486
487 /*
488  * NOTE: Default Toggle Behavior key bindings.  There are TWO key bindings as
489  * of 1.1.4 and 1.2.  Make sure you make any modify builtinKeyBindings (above)
490  * whenever modifying behaviorKeyBindings.
491  */
492
493 char behaviorKeyBindingName[] = "_MwmBehaviorKey_";
494 #ifndef MCCABE
495 #define BEHAVIORKEYBINDINGS "_MwmBehaviorKey_\n\
496 {\n\
497         Alt Shift Ctrl<Key>exclam root|icon|window      f.set_behavior\n\
498         Alt Ctrl<Key>1            root|icon|window      f.set_behavior\n\
499 }";
500 char behaviorKeyBindings[] = BEHAVIORKEYBINDINGS
501
502 #else
503 char behaviorKeyBindings[];
504 #endif
505
506
507 /* default button bindings specification */
508 /* note - the %s will be replaced by the real DefaultRootMenu */
509
510 char defaultButtonBindingsName[] = "DefaultButtonBindings";
511 char builtinButtonBindingsName[] = "_MwmButtonBindings_";
512 #ifndef MCCABE
513 # define BUILTINBUTTONBINDINGS "_MwmButtonBindings_\n\
514 {\n\
515         <Btn1Down>      icon|frame      f.raise\n\
516         <Btn3Down>      icon|frame      f.post_wmenu\n\
517         <Btn3Down>      root            f.menu DefaultRootMenu\n\
518 }";
519 char builtinButtonBindings[] = BUILTINBUTTONBINDINGS
520
521 #else
522 char builtinButtonBindings[];
523 #endif
524
525
526 static ClientData *_pCD;
527 static String _defaultBackground;
528 static String _defaultActiveBackground;
529 static AppearanceData *_pAppearanceData;
530 static WmWorkspaceData *pResWS;
531 static WmScreenData *pResSD;
532
533 static char _defaultColor1HEX[] = "#A8A8A8A8A8A8";
534 static char _defaultColor2HEX[] = "#5F5F92929E9E";
535
536 static char _defaultColor1[] = "LightGrey";
537 static char _defaultColor2[] = "CadetBlue";
538 #define DEFAULT_COLOR_NONE      NULL
539
540 Const char _foreground[]    = "foreground";
541 Const char _75_foreground[] = "75_foreground";
542 Const char _50_foreground[] = "50_foreground";
543 Const char _25_foreground[] = "25_foreground";
544 Const char *_Dither = XmCO_DITHER;
545 Const char *_NoDither = XmCO_NO_DITHER;
546 Const char CLIENT_FRAME_PART[] = "client";
547 Const char ICON_FRAME_PART[] = "icon";
548 Const char FEEDBACK_FRAME_PART[] = "feedback";
549 Const char MENU_ITEM_PART[] = "menu";
550
551 #define WmBGC          XmBACKGROUND
552 #define WmFGC          XmFOREGROUND
553 #define WmTSC          XmTOP_SHADOW
554 #define WmBSC          XmBOTTOM_SHADOW
555
556 #define MAX_SHORT       0xffff
557
558 #ifndef BITMAPDIR
559 #define BITMAPDIR "/usr/include/X11/bitmaps/"
560 #endif
561
562 \f
563 /*************************************<->*************************************
564  *
565  *  wmGlobalResources
566  *
567  *
568  *  Description:
569  *  -----------
570  *  This data structure is used in the processing of mwm general
571  *  appearance and behavior resources.  These resources are specified
572  *  with the following syntax:
573  *
574  *      "Mwm*<resource_identifier>".
575  *
576  *************************************<->***********************************/
577
578
579 XtResource wmGlobalResources[] =
580 {
581
582     {
583         WmNautoKeyFocus,
584         WmCAutoKeyFocus,
585         XtRBoolean,
586         sizeof (Boolean),
587         XtOffsetOf(WmGlobalData, autoKeyFocus),
588         XtRImmediate,
589         (XtPointer)True
590     },
591
592     {
593         WmNautoRaiseDelay,
594         WmCAutoRaiseDelay,
595         XtRInt,
596         sizeof (int),
597         XtOffsetOf(WmGlobalData, autoRaiseDelay),
598         XtRImmediate,
599         (XtPointer)500
600     },
601
602     {
603         WmNbitmapDirectory,
604         WmCBitmapDirectory,
605         XtRString,
606         sizeof (String),
607         XtOffsetOf(WmGlobalData, bitmapDirectory),
608         XtRString,
609         (XtPointer)BITMAPDIR
610     },
611     {
612         WmNblinkOnExec,
613         WmCBlinkOnExec,
614         XtRBoolean,
615         sizeof (Boolean),
616         XtOffsetOf(WmGlobalData, blinkOnExec),
617         XtRImmediate,
618         (XtPointer)False
619     },
620     {
621         WmNframeStyle,
622         WmCFrameStyle,
623         WmRFrameStyle,
624         sizeof (FrameStyle),
625         XtOffsetOf(WmGlobalData, frameStyle),
626         XtRImmediate,
627         (XtPointer)WmRECESSED
628     },
629
630     {
631         WmNclientAutoPlace,
632         WmCClientAutoPlace,
633         XtRBoolean,
634         sizeof (Boolean),
635         XtOffsetOf(WmGlobalData, clientAutoPlace),
636         XtRImmediate,
637         (XtPointer)True
638     },
639
640     {
641         WmNcolormapFocusPolicy,
642         WmCColormapFocusPolicy,
643         WmRCFocusPolicy,
644         sizeof (int),
645         XtOffsetOf(WmGlobalData, colormapFocusPolicy),
646         XtRImmediate,
647         (XtPointer)CMAP_FOCUS_KEYBOARD
648     },
649
650     {
651         WmNconfigFile,
652         WmCConfigFile,
653         XtRString,
654         sizeof (String),
655         XtOffsetOf(WmGlobalData, configFile),
656         XtRImmediate,
657         (XtPointer)NULL
658     },
659
660     {
661         WmNcppCommand,
662         WmCCppCommand,
663         XtRString,
664         sizeof (String),
665         XtOffsetOf(WmGlobalData, cppCommand),
666         XtRImmediate,
667         (XtPointer)NULL
668     },
669
670     {
671         WmNdeiconifyKeyFocus,
672         WmCDeiconifyKeyFocus,
673         XtRBoolean,
674         sizeof (Boolean),
675         XtOffsetOf(WmGlobalData, deiconifyKeyFocus),
676         XtRImmediate,
677         (XtPointer)True
678     },
679
680     {
681         WmNdoubleClickTime,
682         WmCDoubleClickTime,
683         XtRInt,
684         sizeof (int),
685         XtOffsetOf(WmGlobalData, doubleClickTime),
686         XtRCallProc,
687         (XtPointer)_WmMultiClickTimeDefault
688     },
689
690     {
691         WmNenableWarp,
692         WmCEnableWarp,
693         XtRBoolean,
694         sizeof (Boolean),
695         XtOffsetOf(WmGlobalData, enableWarp),
696         XtRImmediate,
697         (XtPointer)True
698     },
699
700     {
701         WmNenforceKeyFocus,
702         WmCEnforceKeyFocus,
703         XtRBoolean,
704         sizeof (Boolean),
705         XtOffsetOf(WmGlobalData, enforceKeyFocus),
706         XtRImmediate,
707         (XtPointer)True
708     },
709
710     {
711         WmNframeExternalShadowWidth,
712         WmCFrameExternalShadowWidth,
713         XtRDimension,
714         sizeof (Dimension),
715         XtOffsetOf(WmGlobalData, frameExternalShadowWidth),
716         XtRImmediate,
717         (XtPointer)2
718     },
719
720     {
721         WmNfreezeOnConfig,
722         WmCFreezeOnConfig,
723         XtRBoolean,
724         sizeof (Boolean),
725         XtOffsetOf(WmGlobalData, freezeOnConfig),
726         XtRImmediate,
727         (XtPointer)True
728     },
729
730     {
731         WmNuseWindowOutline,
732         WmCUseWindowOutline,
733         XtRBoolean,
734         sizeof (Boolean),
735         XtOffsetOf(WmGlobalData, useWindowOutline),
736         XtRImmediate,
737         (XtPointer)False
738     },
739
740     {
741         WmNiconAutoPlace,
742         WmCIconAutoPlace,
743         XtRBoolean,
744         sizeof (Boolean),
745         XtOffsetOf(WmGlobalData, iconAutoPlace),
746         XtRImmediate,
747         (XtPointer)True
748     },
749
750     {
751         WmNiconExternalShadowWidth,
752         WmCIconExternalShadowWidth,
753         XtRDimension,
754         sizeof (Dimension),
755         XtOffsetOf(WmGlobalData, iconExternalShadowWidth),
756         XtRImmediate,
757         (XtPointer)2
758     },
759
760     {
761         WmNiconClick,
762         WmCIconClick,
763         XtRBoolean,
764         sizeof (Boolean),
765         XtOffsetOf(WmGlobalData, iconClick),
766         XtRImmediate,
767         (XtPointer)True
768     },
769
770     {
771         WmNinteractivePlacement,
772         WmCInteractivePlacement,
773         XtRBoolean,
774         sizeof (Boolean),
775         XtOffsetOf(WmGlobalData, interactivePlacement),
776         XtRImmediate,
777         (XtPointer)False
778     },
779
780     {
781         WmNkeyboardFocusPolicy,
782         WmCKeyboardFocusPolicy,
783         WmRKFocusPolicy,
784         sizeof (int),
785         XtOffsetOf(WmGlobalData, keyboardFocusPolicy),
786         XtRImmediate,
787 #if defined(sun)
788         (XtPointer)KEYBOARD_FOCUS_POINTER
789 #else
790         (XtPointer)KEYBOARD_FOCUS_EXPLICIT
791 #endif
792     },
793
794     {
795         WmNlowerOnIconify,
796         WmCLowerOnIconify,
797         XtRBoolean,
798         sizeof (Boolean),
799         XtOffsetOf(WmGlobalData, lowerOnIconify),
800         XtRImmediate,
801         (XtPointer)True
802     },
803
804     {
805         WmNmarqueeSelectGranularity,
806         WmCMarqueeSelectGranularity,
807         XtRInt,
808         sizeof (int),
809         XtOffsetOf(WmGlobalData, marqueeSelectGranularity),
810         XtRImmediate,
811         (XtPointer)0
812     },
813
814     {
815         WmNmoveThreshold,
816         WmCMoveThreshold,
817         XtRInt,
818         sizeof (int),
819         XtOffsetOf(WmGlobalData, moveThreshold),
820         XtRImmediate,
821         (XtPointer)4
822     },
823
824     {
825         WmNpassButtons,
826         WmCPassButtons,
827         XtRBoolean,
828         sizeof (Boolean),
829         XtOffsetOf(WmGlobalData, passButtons),
830         XtRImmediate,
831         (XtPointer)False
832     },
833
834     {
835         WmNpassSelectButton,
836         WmCPassSelectButton,
837         XtRBoolean,
838         sizeof (Boolean),
839         XtOffsetOf(WmGlobalData, passSelectButton),
840         XtRImmediate,
841         (XtPointer)True
842     },
843
844     {
845         WmNpositionIsFrame,
846         WmCPositionIsFrame,
847         XtRBoolean,
848         sizeof (Boolean),
849         XtOffsetOf(WmGlobalData, positionIsFrame),
850         XtRImmediate,
851         (XtPointer)True
852     },
853
854     {
855         WmNpositionOnScreen,
856         WmCPositionOnScreen,
857         XtRBoolean,
858         sizeof (Boolean),
859         XtOffsetOf(WmGlobalData, positionOnScreen),
860         XtRImmediate,
861         (XtPointer)True
862     },
863
864     {
865         WmNquitTimeout,
866         WmCQuitTimeout,
867         XtRInt,
868         sizeof (int),
869         XtOffsetOf(WmGlobalData, quitTimeout),
870         XtRImmediate,
871         (XtPointer)1000
872     },
873
874     {
875         WmNraiseKeyFocus,
876         WmCRaiseKeyFocus,
877         XtRBoolean,
878         sizeof (Boolean),
879         XtOffsetOf(WmGlobalData, raiseKeyFocus),
880         XtRImmediate,
881         (XtPointer)False
882     },
883
884     {
885         WmNrefreshByClearing,
886         WmCRefreshByClearing,
887         XtRBoolean,
888         sizeof (Boolean),
889         XtOffsetOf(WmGlobalData, refreshByClearing),
890         XtRImmediate,
891         (XtPointer)True
892     },
893
894     {
895         WmNrootButtonClick,
896         WmCRootButtonClick,
897         XtRBoolean,
898         sizeof (Boolean),
899         XtOffsetOf(WmGlobalData, rootButtonClick),
900         XtRImmediate,
901         (XtPointer)True
902     },
903
904     {
905         WmNshowFeedback,
906         WmCShowFeedback,
907         WmRShowFeedback,
908         sizeof (int),
909         XtOffsetOf(WmGlobalData, showFeedback),
910         XtRImmediate,
911         (XtPointer)(WM_SHOW_FB_DEFAULT)
912     },
913
914     {
915         WmNstartupKeyFocus,
916         WmCStartupKeyFocus,
917         XtRBoolean,
918         sizeof (Boolean),
919         XtOffsetOf(WmGlobalData, startupKeyFocus),
920         XtRImmediate,
921         (XtPointer)True
922     },
923
924     {
925         WmNsystemButtonClick,
926         WmCSystemButtonClick,
927         XtRBoolean,
928         sizeof (Boolean),
929         XtOffsetOf(WmGlobalData, systemButtonClick),
930         XtRImmediate,
931         (XtPointer)True
932     },
933
934     {
935         WmNsystemButtonClick2,
936         WmCSystemButtonClick2,
937         XtRBoolean,
938         sizeof (Boolean),
939         XtOffsetOf(WmGlobalData, systemButtonClick2),
940         XtRImmediate,
941         (XtPointer)True
942     },
943     {
944         WmNuseFrontPanel,
945         WmCUseFrontPanel,
946         XtRBoolean,
947         sizeof (Boolean),
948         XtOffsetOf(WmGlobalData, useFrontPanel),
949         XtRImmediate,
950         (XtPointer)True
951     },
952
953     {
954         WmNhelpDirectory,
955         WmCHelpDirectory,
956         XtRString,
957         sizeof (String),
958         XtOffsetOf(WmGlobalData, helpDirectory),
959         XtRImmediate,
960         (XtPointer)"DT/Dtwm/"
961     },
962
963     {
964         WmNdtLite,
965         WmCDtLite,
966         XtRBoolean,
967         sizeof (Boolean),
968         XtOffsetOf(WmGlobalData, dtLite),
969         XtRImmediate,
970         (XtPointer)False
971     }
972 }; /* END OF wmGlobalResources[] */
973
974
975 /*
976  * These determine the screens to manage at startup.
977  * These are broken out to enhance startup performance.
978  */
979 XtResource wmGlobalScreenResources[] =
980 {
981     {
982         WmNmultiScreen,
983         WmCMultiScreen,
984         XtRBoolean,
985         sizeof (Boolean),
986         XtOffsetOf(WmGlobalData, multiScreen),
987         XtRImmediate,
988         (XtPointer)True
989     },
990
991     {
992         WmNscreens,
993         WmCScreens,
994         XtRString,
995         sizeof (String),
996         XtOffsetOf(WmGlobalData, screenList),
997         XtRImmediate,
998         (XtPointer)NULL
999     },
1000
1001     {   WmNbackdropDirectories, 
1002         WmCBackdropDirectories, 
1003         XmRString, 
1004         sizeof(char *),
1005         XtOffsetOf(WmGlobalData, backdropDirs), 
1006         XmRString,
1007         DEFAULT_BACKDROP_DIR
1008     },
1009 };
1010
1011
1012 \f
1013 /******************************<->*************************************
1014  *
1015  *  wmStdGlobalResources
1016  *
1017  *
1018  *  Description:
1019  *  -----------
1020  *  This data structure is used in the processing of mwm general appearance
1021  *  and behavior resources that are not automatically set for the standard
1022  *  (default) behavior.  These resources are specified with the following
1023  *  syntax:
1024  *
1025  *      "Mwm*<resource_identifier>".
1026  *
1027  ******************************<->***********************************/
1028
1029 XtResource wmStdGlobalResources[] =
1030 {
1031
1032     {
1033         WmNbitmapDirectory,
1034         WmCBitmapDirectory,
1035         XtRString,
1036         sizeof (String),
1037         XtOffsetOf(WmGlobalData, bitmapDirectory),
1038         XtRString,
1039         (XtPointer)BITMAPDIR
1040     },
1041
1042     {
1043         WmNconfigFile,
1044         WmCConfigFile,
1045         XtRString,
1046         sizeof (String),
1047         XtOffsetOf(WmGlobalData, configFile),
1048         XtRImmediate,
1049         (XtPointer)NULL
1050     },
1051
1052     {
1053         WmNframeStyle,
1054         WmCFrameStyle,
1055         WmRFrameStyle,
1056         sizeof (FrameStyle),
1057         XtOffsetOf(WmGlobalData, frameStyle),
1058         XtRImmediate,
1059         (XtPointer)WmRECESSED
1060     },
1061
1062     {
1063         WmNiconAutoPlace,
1064         WmCIconAutoPlace,
1065         XtRBoolean,
1066         sizeof (Boolean),
1067         XtOffsetOf(WmGlobalData, iconAutoPlace),
1068         XtRImmediate,
1069         (XtPointer)True
1070     },
1071
1072     {
1073         WmNmoveThreshold,
1074         WmCMoveThreshold,
1075         XtRInt,
1076         sizeof (int),
1077         XtOffsetOf(WmGlobalData, moveThreshold),
1078         XtRImmediate,
1079         (XtPointer)4
1080     },
1081
1082     {
1083         WmNpositionIsFrame,
1084         WmCPositionIsFrame,
1085         XtRBoolean,
1086         sizeof (Boolean),
1087         XtOffsetOf(WmGlobalData, positionIsFrame),
1088         XtRImmediate,
1089         (XtPointer)True
1090     },
1091
1092     {
1093         WmNpositionOnScreen,
1094         WmCPositionOnScreen,
1095         XtRBoolean,
1096         sizeof (Boolean),
1097         XtOffsetOf(WmGlobalData, positionOnScreen),
1098         XtRImmediate,
1099         (XtPointer)True
1100     },
1101
1102     {
1103         WmNquitTimeout,
1104         WmCQuitTimeout,
1105         XtRInt,
1106         sizeof (int),
1107         XtOffsetOf(WmGlobalData, quitTimeout),
1108         XtRImmediate,
1109         (XtPointer)1000
1110     },
1111
1112     {
1113         WmNshowFeedback,
1114         WmCShowFeedback,
1115         WmRShowFeedback,
1116         sizeof (int),
1117         XtOffsetOf(WmGlobalData, showFeedback),
1118         XtRImmediate,
1119         (XtPointer)(WM_SHOW_FB_DEFAULT)
1120     },
1121
1122 };
1123
1124 \f
1125 /******************************<->*************************************
1126  *
1127  *  wmScreenResources
1128  *
1129  *
1130  *  Description:
1131  *  -----------
1132  *  This data structure is used in the processing of mwm screen specific
1133  *  appearance and behavior resources.  These resources are specified
1134  *  with the following syntax:
1135  *
1136  *      "Mwm*screen<#>*<resource_identifier>".
1137  *
1138  ******************************<->***********************************/
1139
1140 XtResource wmScreenResources[] =
1141 {
1142     {
1143         WmNbuttonBindings,
1144         WmCButtonBindings,
1145         XtRString,
1146         sizeof (String),
1147         XtOffsetOf (WmScreenData, buttonBindings),
1148         XtRString,
1149         (XtPointer)defaultButtonBindingsName
1150     },
1151
1152     {
1153         WmNcleanText,
1154         WmCCleanText,
1155         XtRBoolean,
1156         sizeof (Boolean),
1157         XtOffsetOf (WmScreenData, cleanText),
1158         XtRImmediate,
1159         (XtPointer)True
1160     },
1161
1162     {
1163         WmNfeedbackGeometry,
1164         WmCFeedbackGeometry,
1165         XtRString,
1166         sizeof (String),
1167         XtOffsetOf (WmScreenData, feedbackGeometry),
1168         XtRString,
1169         (XtPointer)NULL
1170     },
1171
1172     {
1173         WmNfadeNormalIcon,
1174         WmCFadeNormalIcon,
1175         XtRBoolean,
1176         sizeof (Boolean),
1177         XtOffsetOf (WmScreenData, fadeNormalIcon),
1178         XtRImmediate,
1179         (XtPointer)False
1180     },
1181
1182     {
1183         WmNiconDecoration,
1184         WmCIconDecoration,
1185         WmRIconDecor,
1186         sizeof (int),
1187         XtOffsetOf (WmScreenData, iconDecoration),
1188         XtRImmediate,
1189         (XtPointer)USE_ICON_DEFAULT_APPEARANCE
1190     },
1191
1192     {
1193         WmNiconImageMaximum,
1194         WmCIconImageMaximum,
1195         WmRSize,
1196         sizeof (WHSize),
1197         XtOffsetOf (WmScreenData, iconImageMaximum),
1198         XtRCallProc,
1199         (XtPointer) _WmIconImageMaximumDefault
1200     },
1201
1202     {
1203         WmNiconImageMinimum,
1204         WmCIconImageMinimum,
1205         WmRSize,
1206         sizeof (WHSize),
1207         XtOffsetOf (WmScreenData, iconImageMinimum),
1208         XtRString,
1209         "16x16"
1210     },
1211
1212     {
1213         WmNiconPlacement,
1214         WmCIconPlacement,
1215         WmRIconPlacement,
1216         sizeof (int),
1217         XtOffsetOf (WmScreenData, iconPlacement),
1218         XtRImmediate,
1219         (XtPointer)(ICON_PLACE_LEFT_PRIMARY | ICON_PLACE_BOTTOM_SECONDARY)
1220     },
1221
1222     {
1223         WmNiconPlacementMargin,
1224         WmCIconPlacementMargin,
1225         XtRInt,
1226         sizeof (int),
1227         XtOffsetOf (WmScreenData, iconPlacementMargin),
1228         XtRImmediate,
1229         (XtPointer)-1
1230     },
1231
1232     {
1233         WmNkeyBindings,
1234         WmCKeyBindings,
1235         XtRString,
1236         sizeof (String),
1237         XtOffsetOf (WmScreenData, keyBindings),
1238         XtRString,
1239         (XtPointer)defaultKeyBindingsName
1240     },
1241
1242     {
1243         WmNframeBorderWidth,
1244         WmCFrameBorderWidth,
1245         XtRInt,
1246         sizeof (int),
1247         XtOffsetOf (WmScreenData, frameBorderWidth),
1248         XtRImmediate,
1249         (XtPointer) BIGSIZE
1250     },
1251
1252     {
1253         WmNiconBoxName,
1254         WmCIconBoxName,
1255         XtRString,
1256         sizeof (String),
1257         XtOffsetOf (WmScreenData, iconBoxName),
1258         XtRString,
1259         (XtPointer)"iconbox"
1260     },
1261
1262     {
1263         WmNiconBoxSBDisplayPolicy,
1264         WmCIconBoxSBDisplayPolicy,
1265         XtRString,
1266         sizeof (String),
1267         XtOffsetOf (WmScreenData, iconBoxSBDisplayPolicy),
1268         XtRString,
1269         (XtPointer)"all"
1270     },
1271
1272     {
1273         WmNiconBoxScheme,
1274         WmCIconBoxScheme,
1275         XtRInt,
1276         sizeof (int),
1277         XtOffsetOf (WmScreenData, iconBoxScheme),
1278         XtRImmediate,
1279         (XtPointer)0
1280     },
1281
1282     {
1283         WmNiconBoxTitle,
1284         WmCIconBoxTitle,
1285         XmRXmString,
1286         sizeof (XmString),
1287         XtOffsetOf (WmScreenData, iconBoxTitle),
1288         XmRXmString,
1289         (XtPointer)NULL
1290     },
1291
1292     {
1293         WmNlimitResize,
1294         WmCLimitResize,
1295         XtRBoolean,
1296         sizeof (Boolean),
1297         XtOffsetOf (WmScreenData, limitResize),
1298         XtRImmediate,
1299         (XtPointer)True
1300     },
1301
1302     {
1303         WmNmaximumMaximumSize,
1304         WmCMaximumMaximumSize,
1305         WmRSize,
1306         sizeof (WHSize),
1307         XtOffsetOf (WmScreenData, maximumMaximumSize),
1308         XtRString,
1309         "0x0"
1310     },
1311
1312     {
1313         WmNresizeBorderWidth,
1314         WmCFrameBorderWidth,
1315         XtRInt,
1316         sizeof (int),
1317         XtOffsetOf (WmScreenData, resizeBorderWidth),
1318         XtRImmediate,
1319         (XtPointer) BIGSIZE
1320     },
1321
1322     {
1323         WmNresizeCursors,
1324         WmCResizeCursors,
1325         XtRBoolean,
1326         sizeof (Boolean),
1327         XtOffsetOf (WmScreenData, resizeCursors),
1328         XtRImmediate,
1329         (XtPointer)True
1330     },
1331
1332     {
1333         WmNtransientDecoration,
1334         WmCTransientDecoration,
1335         WmRClientDecor,
1336         sizeof (int),
1337         XtOffsetOf (WmScreenData, transientDecoration),
1338         XtRImmediate,
1339         (XtPointer)(WM_DECOR_SYSTEM | WM_DECOR_RESIZEH)
1340     },
1341
1342     {
1343         WmNtransientFunctions,
1344         WmCTransientFunctions,
1345         WmRClientFunction,
1346         sizeof (int),
1347         XtOffsetOf (WmScreenData, transientFunctions),
1348         XtRImmediate,
1349         (XtPointer)(WM_FUNC_ALL & ~(MWM_FUNC_MAXIMIZE | MWM_FUNC_MINIMIZE))
1350     },
1351
1352     {
1353         WmNsubpanelDecoration,
1354         WmCSubpanelDecoration,
1355         WmRClientDecor,
1356         sizeof (int),
1357         XtOffsetOf (WmScreenData, subpanelDecoration),
1358         XtRImmediate,
1359         (XtPointer)(WM_DECOR_SYSTEM)
1360     },
1361
1362     {
1363         WmNsubpanelResources,
1364         WmCSubpanelResources,
1365         XtRString,
1366         sizeof (String),
1367         XtOffsetOf (WmScreenData, subpanelResources),
1368         XtRString,
1369         (XtPointer)NULL
1370     },
1371
1372     {
1373         WmNuseIconBox,
1374         WmCUseIconBox,
1375         XtRBoolean,
1376         sizeof (Boolean),
1377         XtOffsetOf (WmScreenData, useIconBox),
1378         XtRImmediate,
1379         (XtPointer)False
1380     },
1381
1382     {
1383         WmNmoveOpaque,
1384         WmCMoveOpaque,
1385         XtRBoolean,
1386         sizeof (Boolean),
1387         XtOffsetOf (WmScreenData, moveOpaque),
1388         XtRImmediate,
1389         (XtPointer)False
1390
1391     },
1392
1393     {
1394         WmNhelpResources,
1395         WmCHelpResources,
1396         XtRString,
1397         sizeof (String),
1398         XtOffsetOf (WmScreenData, helpResources),
1399         XtRString,
1400         (XtPointer)NULL
1401     },
1402
1403     {
1404         WmNinitialWorkspace,
1405         WmCInitialWorkspace,
1406         XtRString,
1407         sizeof (String),
1408         XtOffsetOf (WmScreenData, initialWorkspace),
1409         XtRString,
1410         (XtPointer)NULL
1411     },
1412
1413     {
1414         WmNworkspaceList,
1415         WmCWorkspaceList,
1416         XtRString,
1417         sizeof (String),
1418         XtOffsetOf (WmScreenData, workspaceList),
1419         XtRImmediate,
1420         (XtPointer)NULL
1421     },
1422
1423     {
1424         WmNworkspaceCount,
1425         WmCWorkspaceCount,
1426         XtRInt,
1427         sizeof (int),
1428         XtOffsetOf (WmScreenData, numWorkspaces),
1429         XtRImmediate,
1430         (XtPointer)0
1431     }
1432
1433 };
1434
1435 \f
1436 /******************************<->*************************************
1437  *
1438  *  wmStdScreenResources
1439  *
1440  *
1441  *  Description:
1442  *  -----------
1443  *  This data structure is used in the processing of mwm screen specific
1444  *  appearance and behavior resources that are not automatically set for 
1445  *  the standard (default) behavior.  These resources are specified with 
1446  *  the following syntax:
1447  *
1448  *      "Mwm*screen<#>*<resource_identifier>".
1449  *
1450  ******************************<->***********************************/
1451
1452 XtResource wmStdScreenResources[] =
1453 {
1454     {
1455         WmNframeBorderWidth,
1456         WmCFrameBorderWidth,
1457         XtRInt,
1458         sizeof (int),
1459         XtOffsetOf (WmScreenData, frameBorderWidth),
1460         XtRImmediate,
1461         (XtPointer) BIGSIZE
1462     },
1463
1464     {
1465         WmNiconImageMaximum,
1466         WmCIconImageMaximum,
1467         WmRSize,
1468         sizeof (WHSize),
1469         XtOffsetOf (WmScreenData, iconImageMaximum),
1470         XtRCallProc,
1471         (XtPointer) _WmIconImageMaximumDefault
1472     },
1473
1474     {
1475         WmNiconImageMinimum,
1476         WmCIconImageMinimum,
1477         WmRSize,
1478         sizeof (WHSize),
1479         XtOffsetOf (WmScreenData, iconImageMinimum),
1480         XtRString,
1481         "32x32"
1482     },
1483
1484     {
1485         WmNiconPlacementMargin,
1486         WmCIconPlacementMargin,
1487         XtRInt,
1488         sizeof (int),
1489         XtOffsetOf (WmScreenData, iconPlacementMargin),
1490         XtRImmediate,
1491         (XtPointer)-1
1492     },
1493
1494     {
1495         WmNmaximumMaximumSize,
1496         WmCMaximumMaximumSize,
1497         WmRSize,
1498         sizeof (WHSize),
1499         XtOffsetOf (WmScreenData, maximumMaximumSize),
1500         XtRString,
1501         "0x0"
1502     },
1503
1504     {
1505         WmNresizeBorderWidth,
1506         WmCFrameBorderWidth,
1507         XtRInt,
1508         sizeof (int),
1509         XtOffsetOf (WmScreenData, resizeBorderWidth),
1510         XtRImmediate,
1511         (XtPointer) BIGSIZE
1512     }
1513 };
1514
1515
1516 \f
1517 /******************************<->*************************************
1518  *
1519  *  wmWorkspaceResources
1520  *
1521  *
1522  *  Description:
1523  *  -----------
1524  *  This data structure is used in the processing of mwm workspace 
1525  *  specific appearance and behavior resources.  These resources are 
1526  *  specified with the following syntax:
1527  *
1528  *      "Mwm*[screen<#>*]<workspace>*<resource_identifier>".
1529  *
1530  ******************************<->***********************************/
1531 XtResource wmWorkspaceResources[] =
1532 {
1533     {
1534         WmNiconBoxGeometry,
1535         WmCIconBoxGeometry,
1536         XtRString,
1537         sizeof (String),
1538         XtOffsetOf (WmWorkspaceData, iconBoxGeometry),
1539         XtRString,
1540         (XtPointer)NULL
1541     },
1542
1543     {
1544         WmNtitle,
1545         WmCTitle,
1546         XmRXmString,
1547         sizeof (XmString),
1548         XtOffsetOf (WmWorkspaceData, title),
1549         XmRXmString,
1550         (XtPointer)NULL
1551     }
1552
1553 };
1554
1555
1556 \f
1557 /******************************<->*************************************
1558  *
1559  *  wmStdWorkspaceResources
1560  *
1561  *
1562  *  Description:
1563  *  -----------
1564  *  This data structure is used in the processing of mwm workspace specific 
1565  *  appearance and behavior resources that are not automatically set for 
1566  *  the standard (default) behavior.  These resources are specified with 
1567  *  the following syntax:
1568  *
1569  *      "Mwm*[screen<#>*]<workspace>*<resource_identifier>".
1570  *
1571  *************************************<->***********************************/
1572
1573 XtResource wmStdWorkspaceResources[] =
1574 {
1575     {
1576         WmNtitle,
1577         WmCTitle,
1578         XmRXmString,
1579         sizeof (XmString),
1580         XtOffsetOf (WmWorkspaceData, title),
1581         XmRXmString,
1582         (XtPointer)NULL
1583     }
1584 };
1585
1586
1587 /*************************************<->*************************************
1588  *
1589  *  wmBackdropResources
1590  *
1591  *
1592  *  Description:
1593  *  -----------
1594  *  This data structure is used in the processing of workspace specific
1595  *  resources that apply to the backdrop.
1596  *
1597  *  These resources are specified with the following syntax:
1598  *
1599  *      "Mwm*[screen*][workspace*]backdrop*<resource_id>:"
1600  *
1601  *  NOTE: The order of these resources is important for correct
1602  *        dynamic processing!!!!
1603  *
1604  *************************************<->***********************************/
1605
1606 XtResource wmBackdropResources[] =
1607 {
1608     {
1609         WmNcolorSetId,
1610         WmCColorSetId,
1611         XtRInt,
1612         sizeof (int),
1613         XtOffsetOf (BackdropData, colorSet),
1614         XtRCallProc,
1615         (XtPointer) _WmBackdropColorSetDefault
1616     },
1617
1618     {
1619         WmNimageBackground,
1620         WmCImageBackground,
1621         XtRPixel,
1622         sizeof (Pixel),
1623         XtOffsetOf (BackdropData, background),
1624         XtRCallProc,
1625         (XtPointer) _WmBackdropBgDefault
1626     },
1627
1628     {
1629         WmNimageForeground,
1630         WmCImageForeground,
1631         XtRPixel,
1632         sizeof (Pixel),
1633         XtOffsetOf (BackdropData, foreground),
1634         XtRCallProc,
1635         (XtPointer) _WmBackdropFgDefault
1636     },
1637
1638     {
1639         WmNimage,
1640         WmCImage,
1641         XtRString,
1642         sizeof (String),
1643         XtOffsetOf (BackdropData, image),
1644         XtRString,
1645         (XtPointer)NULL
1646     },
1647
1648 };
1649
1650 \f
1651 /*************************************<->*************************************
1652  *
1653  *  wmWsPresenceResources
1654  *
1655  *
1656  *  Description:
1657  *  -----------
1658  *  This data structure is used in the processing of specific
1659  *  resources that apply to the WorkspacePresence dialog.
1660  *
1661  *  These resources are specified with the following syntax:
1662  *
1663  *      "Mwm*[screen*][workspace*]workspacePresence*<resource_id>:"
1664  *
1665  *************************************<->***********************************/
1666
1667 XtResource wmWsPresenceResources[] =
1668 {
1669     {
1670         WmNtitle,
1671         WmCTitle,
1672         XmRXmString,
1673         sizeof (XmString),
1674         XtOffsetOf (WsPresenceData, title),
1675         XmRXmString,
1676         (XtPointer)NULL
1677     }
1678 };
1679
1680 /*************************************<->*************************************
1681  *
1682  *  wmClientResources
1683  *
1684  *
1685  *  Description:
1686  *  -----------
1687  *  This data structure is used in the processing of client specific 
1688  *  window manager resources.  These resources are specified with the
1689  *  following syntax:
1690  *
1691  *      "Mwm*<client_name_or_class>*<resource_identifier>"
1692  *
1693  *************************************<->***********************************/
1694
1695 XtResource wmClientResources[] =
1696 {
1697
1698     {
1699         WmNabsentMapBehavior,
1700         WmCAbsentMapBehavior,
1701         WmRAbsentMapBehavior,
1702         sizeof (int),
1703         XtOffsetOf (ClientData, absentMapBehavior),
1704         XtRImmediate,
1705         (XtPointer)(AMAP_BEHAVIOR_ADD)
1706     },
1707
1708     {
1709         WmNclientDecoration,
1710         WmCClientDecoration,
1711         WmRClientDecor,
1712         sizeof (int),
1713         XtOffsetOf (ClientData, clientDecoration),
1714         XtRImmediate,
1715         (XtPointer)(WM_DECOR_DEFAULT)
1716     },
1717
1718     {
1719         WmNclientFunctions,
1720         WmCClientFunctions,
1721         WmRClientFunction,
1722         sizeof (int),
1723         XtOffsetOf (ClientData, clientFunctions),
1724         XtRImmediate,
1725         (XtPointer)(WM_FUNC_DEFAULT)
1726     },
1727
1728     {
1729         WmNfocusAutoRaise,
1730         WmCFocusAutoRaise,
1731         XtRBoolean,
1732         sizeof (Boolean),
1733         XtOffsetOf (ClientData, focusAutoRaise),
1734         XtRCallProc,
1735         (XtPointer)_WmFocusAutoRaiseDefault
1736     },
1737
1738     {
1739         WmNiconImage,
1740         WmCIconImage,
1741         XtRString,
1742         sizeof (String),
1743         XtOffsetOf (ClientData, iconImage),
1744         XtRString,
1745         (XtPointer)NULL
1746     },
1747
1748     {
1749         WmNiconImageBackground,
1750         WmCIconImageBackground,
1751         XtRPixel,
1752         sizeof (Pixel),
1753         XtOffsetOf (ClientData, iconImageBackground),
1754         XtRCallProc,
1755         (XtPointer)_WmIconImageBDefault
1756     },
1757
1758     {
1759         WmNiconImageForeground,
1760         WmCIconImageForeground,
1761         XtRPixel,
1762         sizeof (Pixel),
1763         XtOffsetOf (ClientData, iconImageForeground),
1764         XtRCallProc,
1765         (XtPointer)_WmIconImageFDefault
1766     },
1767
1768     {
1769         WmNiconImageBottomShadowColor,
1770         WmCIconImageBottomShadowColor,
1771         XtRPixel,
1772         sizeof (Pixel),
1773         XtOffsetOf (ClientData, iconImageBottomShadowColor),
1774         XtRCallProc,
1775         (XtPointer)_WmIconImageBSCDefault
1776     },
1777
1778     {
1779         WmNiconImageBottomShadowPixmap,
1780         WmCIconImageBottomShadowPixmap,
1781         XtRString,
1782         sizeof (String),
1783         XtOffsetOf (ClientData, iconImageBottomShadowPStr),
1784         XtRCallProc,
1785         (XtPointer)_WmIconImageBSPDefault
1786     },
1787
1788     {
1789         WmNiconImageTopShadowColor,
1790         WmCIconImageTopShadowColor,
1791         XtRPixel,
1792         sizeof (Pixel),
1793         XtOffsetOf (ClientData, iconImageTopShadowColor),
1794         XtRCallProc,
1795         (XtPointer)_WmIconImageTSCDefault
1796     },
1797
1798     {
1799         WmNiconImageTopShadowPixmap,
1800         WmCIconImageTopShadowPixmap,
1801         XtRString,
1802         sizeof (String),
1803         XtOffsetOf (ClientData, iconImageTopShadowPStr),
1804         XtRCallProc,
1805         (XtPointer)_WmIconImageTSPDefault
1806     },
1807
1808     {
1809         WmNignoreWMSaveHints,
1810         WmCIgnoreWMSaveHints,
1811         XtRBoolean,
1812         sizeof (Boolean),
1813         XtOffsetOf (ClientData, ignoreWMSaveHints),
1814         XtRImmediate,
1815         (XtPointer)True
1816     },
1817
1818     {
1819         WmNmatteWidth,
1820         WmCMatteWidth,
1821         XtRInt,
1822         sizeof (int),
1823         XtOffsetOf (ClientData, matteWidth),
1824         XtRImmediate,
1825         (XtPointer)0
1826     },
1827
1828     {
1829         WmNmaximumClientSize,
1830         WmCMaximumClientSize,
1831         WmRSize,
1832         sizeof (WHSize),
1833         XtOffsetOf (ClientData, maximumClientSize),
1834         XtRString,
1835         "0x0"
1836     },
1837
1838     {
1839         WmNsecondariesOnTop,
1840         WmCSecondariesOnTop,
1841         XtRBoolean,
1842         sizeof (Boolean),
1843         XtOffsetOf (ClientData, secondariesOnTop),
1844         XtRCallProc,
1845         (XtPointer)_WmSecondariesOnTopDefault
1846     },
1847
1848     {
1849         WmNsystemMenu,
1850         WmCSystemMenu,
1851         XtRString,
1852         sizeof (String),
1853         XtOffsetOf (ClientData, systemMenu),
1854         XtRString,
1855         (XtPointer)defaultSystemMenuName
1856     },
1857
1858     {
1859         WmNuseClientIcon,
1860         WmCUseClientIcon,
1861         XtRBoolean,
1862         sizeof (Boolean),
1863         XtOffsetOf (ClientData, useClientIcon),
1864         XtRImmediate,
1865         (XtPointer)True
1866     },
1867
1868     {
1869         WmNusePPosition,
1870         WmCUsePPosition,
1871         WmRUsePPosition,
1872         sizeof (int),
1873         XtOffsetOf (ClientData, usePPosition),
1874         XtRImmediate,
1875         (XtPointer)(USE_PPOSITION_NONZERO)
1876     }
1877
1878 }; /* END OF STRUCTURE wmClientResources */
1879
1880
1881 \f
1882 /*************************************<->*************************************
1883  *
1884  *  wmStdClientResources
1885  *
1886  *
1887  *  Description:
1888  *  -----------
1889  *  This data structure is used in the processing of client specific 
1890  *  window manager resources that are not automatically set for the standard
1891  *  (default) behavior.  These resources are specified with the
1892  *  following syntax:
1893  *
1894  *      "Mwm*<client_name_or_class>*<resource_identifier>"
1895  *
1896  *************************************<->***********************************/
1897
1898 XtResource wmStdClientResources[] =
1899 {
1900
1901     {
1902         WmNiconImage,
1903         WmCIconImage,
1904         XtRString,
1905         sizeof (String),
1906         XtOffsetOf (ClientData, iconImage),
1907         XtRString,
1908         (XtPointer)NULL
1909     },
1910
1911     {
1912         WmNiconImageBackground,
1913         WmCIconImageBackground,
1914         XtRPixel,
1915         sizeof (Pixel),
1916         XtOffsetOf (ClientData, iconImageBackground),
1917         XtRCallProc,
1918         (XtPointer)_WmIconImageBDefault
1919     },
1920
1921     {
1922         WmNiconImageForeground,
1923         WmCIconImageForeground,
1924         XtRPixel,
1925         sizeof (Pixel),
1926         XtOffsetOf (ClientData, iconImageForeground),
1927         XtRCallProc,
1928         (XtPointer)_WmIconImageFDefault
1929     },
1930
1931     {
1932         WmNiconImageBottomShadowColor,
1933         WmCIconImageBottomShadowColor,
1934         XtRPixel,
1935         sizeof (Pixel),
1936         XtOffsetOf (ClientData, iconImageBottomShadowColor),
1937         XtRCallProc,
1938         (XtPointer)_WmIconImageBSCDefault
1939     },
1940
1941     {
1942         WmNiconImageBottomShadowPixmap,
1943         WmCIconImageBottomShadowPixmap,
1944         XtRString,
1945         sizeof (String),
1946         XtOffsetOf (ClientData, iconImageBottomShadowPStr),
1947         XtRCallProc,
1948         (XtPointer)_WmIconImageBSPDefault
1949     },
1950
1951     {
1952         WmNiconImageTopShadowColor,
1953         WmCIconImageTopShadowColor,
1954         XtRPixel,
1955         sizeof (Pixel),
1956         XtOffsetOf (ClientData, iconImageTopShadowColor),
1957         XtRCallProc,
1958         (XtPointer)_WmIconImageTSCDefault
1959     },
1960
1961     {
1962         WmNiconImageTopShadowPixmap,
1963         WmCIconImageTopShadowPixmap,
1964         XtRString,
1965         sizeof (String),
1966         XtOffsetOf (ClientData, iconImageTopShadowPStr),
1967         XtRCallProc,
1968         (XtPointer)_WmIconImageTSPDefault
1969     },
1970
1971     {
1972         WmNmatteWidth,
1973         WmCMatteWidth,
1974         XtRInt,
1975         sizeof (int),
1976         XtOffsetOf (ClientData, matteWidth),
1977         XtRImmediate,
1978         (XtPointer)0
1979     },
1980
1981     {
1982         WmNmaximumClientSize,
1983         WmCMaximumClientSize,
1984         WmRSize,
1985         sizeof (WHSize),
1986         XtOffsetOf (ClientData, maximumClientSize),
1987         XtRString,
1988         "0x0"
1989     },
1990
1991     {
1992         WmNsecondariesOnTop,
1993         WmCSecondariesOnTop,
1994         XtRBoolean,
1995         sizeof (Boolean),
1996         XtOffsetOf (ClientData, secondariesOnTop),
1997         XtRCallProc,
1998         (XtPointer)_WmSecondariesOnTopDefault
1999     },
2000
2001     {
2002         WmNuseClientIcon,
2003         WmCUseClientIcon,
2004         XtRBoolean,
2005         sizeof (Boolean),
2006         XtOffsetOf (ClientData, useClientIcon),
2007         XtRImmediate,
2008         (XtPointer)False
2009     }
2010 };
2011
2012
2013 \f
2014 /*************************************<->*************************************
2015  *
2016  *  wmClientResourcesM
2017  *
2018  *
2019  *  Description:
2020  *  -----------
2021  *  This data structure is used in the processing of client specific 
2022  *  window manager resources that affect the appearance of the client
2023  *  matte.  These resources are specified with the following syntax:
2024  *
2025  *      "Mwm*<client_name_or_class>*<resource_identifier>"
2026  *
2027  *************************************<->***********************************/
2028
2029 XtResource wmClientResourcesM[] =
2030 {
2031     {
2032         WmNmatteBackground,
2033         WmCMatteBackground,
2034         XtRPixel,
2035         sizeof (Pixel),
2036         XtOffsetOf (ClientData, matteBackground),
2037         XtRCallProc,
2038         (XtPointer)_WmMatteBDefault
2039     },
2040
2041     {
2042         WmNmatteForeground,
2043         WmCMatteForeground,
2044         XtRPixel,
2045         sizeof (Pixel),
2046         XtOffsetOf (ClientData, matteForeground),
2047         XtRCallProc,
2048         (XtPointer)_WmMatteFDefault
2049     },
2050
2051     {
2052         WmNmatteBottomShadowColor,
2053         WmCMatteBottomShadowColor,
2054         XtRPixel,
2055         sizeof (Pixel),
2056         XtOffsetOf (ClientData, matteBottomShadowColor),
2057         XtRCallProc,
2058         (XtPointer)_WmMatteBSCDefault
2059     },
2060
2061     {
2062         WmNmatteBottomShadowPixmap,
2063         WmCMatteBottomShadowPixmap,
2064         XtRString,
2065         sizeof (String),
2066         XtOffsetOf (ClientData, matteBottomShadowPStr),
2067         XtRCallProc,
2068         (XtPointer)_WmMatteBSPDefault
2069     },
2070
2071     {
2072         WmNmatteTopShadowColor,
2073         WmCMatteTopShadowColor,
2074         XtRPixel,
2075         sizeof (Pixel),
2076         XtOffsetOf (ClientData, matteTopShadowColor),
2077         XtRCallProc,
2078         (XtPointer)_WmMatteTSCDefault
2079     },
2080
2081     {
2082         WmNmatteTopShadowPixmap,
2083         WmCMatteTopShadowPixmap,
2084         XtRString,
2085         sizeof (String),
2086         XtOffsetOf (ClientData, matteTopShadowPStr),
2087         XtRCallProc,
2088         (XtPointer)_WmMatteTSPDefault
2089     }
2090 };
2091
2092
2093 \f
2094 /*************************************<->*************************************
2095  *
2096  *  wmAppearanceResources
2097  *
2098  *
2099  *  Description:
2100  *  -----------
2101  *  This data structure is used in the processing of component appearance
2102  *  resources.  These resources are specified with the following syntax:
2103  *
2104  *      "Mwm*<resource_identifier>"
2105  *      "Mwm*client*<resource_identifier>"
2106  *      "Mwm*icon*<resource_identifier>"
2107  *      "Mwm*feedback*<resource_identifier>"
2108  *
2109  *************************************<->***********************************/
2110
2111 XtResource wmAppearanceResources[] =
2112 {
2113
2114     {
2115         XmNfontList,
2116         XmCFontList,
2117         XmRFontList,
2118         sizeof (XmFontList),
2119         XtOffsetOf (AppearanceData, fontList),
2120         XtRString,
2121         "fixed"
2122     },
2123
2124     {
2125         WmNsaveUnder,
2126         WmCSaveUnder,
2127         XtRBoolean,
2128         sizeof (Boolean),
2129         XtOffsetOf (AppearanceData, saveUnder),
2130         XtRImmediate,
2131         (XtPointer)False
2132     },
2133
2134     {
2135         XtNbackground,
2136         XtCBackground,
2137         XtRPixel,
2138         sizeof (Pixel),
2139         XtOffsetOf (AppearanceData, background),
2140         XtRCallProc,
2141         (XtPointer)_WmBackgroundDefault
2142     },
2143
2144     {
2145         XtNforeground,
2146         XtCForeground,
2147         XtRPixel,
2148         sizeof (Pixel),
2149         XtOffsetOf (AppearanceData, foreground),
2150         XtRCallProc,
2151         (XtPointer)_WmForegroundDefault
2152     },
2153
2154     {
2155         XmNbottomShadowColor,
2156         XtCForeground,
2157         XtRPixel,
2158         sizeof (Pixel),
2159         XtOffsetOf (AppearanceData, bottomShadowColor),
2160         XtRCallProc,
2161         (XtPointer)_WmBottomShadowColorDefault
2162     },
2163
2164     {
2165         XmNbottomShadowPixmap,
2166         XmCBottomShadowPixmap,
2167         XtRString,
2168         sizeof (String),
2169         XtOffsetOf (AppearanceData, bottomShadowPStr),
2170         XtRString,
2171         (XtPointer)NULL
2172     },
2173
2174     {
2175         XmNtopShadowColor,
2176         XtCForeground,
2177         XtRPixel,
2178         sizeof (Pixel),
2179         XtOffsetOf (AppearanceData, topShadowColor),
2180         XtRCallProc,
2181         (XtPointer)_WmTopShadowColorDefault
2182     },
2183
2184     {
2185         XmNbackgroundPixmap,
2186         XmCBackgroundPixmap,
2187         XtRString,
2188         sizeof (String),
2189         XtOffsetOf (AppearanceData, backgroundPStr),
2190         XtRCallProc,
2191         (XtPointer)_WmBackgroundPixmapDefault
2192     },
2193
2194     {
2195         XmNtopShadowPixmap,
2196         XmCTopShadowPixmap,
2197         XtRString,
2198         sizeof (String),
2199         XtOffsetOf (AppearanceData, topShadowPStr),
2200         XtRCallProc,
2201         (XtPointer)_WmTopShadowPixmapDefault
2202     },
2203
2204     {
2205         WmNactiveBackground,
2206         XtCBackground,
2207         XtRPixel,
2208         sizeof (Pixel),
2209         XtOffsetOf (AppearanceData, activeBackground),
2210         XtRCallProc,
2211         (XtPointer)_WmABackgroundDefault
2212     },
2213
2214     {
2215         WmNactiveForeground,
2216         XtCForeground,
2217         XtRPixel,
2218         sizeof (Pixel),
2219         XtOffsetOf (AppearanceData, activeForeground),
2220         XtRCallProc,
2221         (XtPointer)_WmAForegroundDefault
2222     },
2223
2224     {
2225         WmNactiveBottomShadowColor,
2226         XtCForeground,
2227         XtRPixel,
2228         sizeof (Pixel),
2229         XtOffsetOf (AppearanceData, activeBottomShadowColor),
2230         XtRCallProc,
2231         (XtPointer)_WmABottomShadowColorDefault
2232     },
2233
2234     {
2235         WmNactiveBottomShadowPixmap,
2236         XmCBottomShadowPixmap,
2237         XtRString,
2238         sizeof (String),
2239         XtOffsetOf (AppearanceData, activeBottomShadowPStr),
2240         XtRString,
2241         (XtPointer)NULL
2242     },
2243
2244     {
2245         WmNactiveTopShadowColor,
2246         XtCForeground,
2247         XtRPixel,
2248         sizeof (Pixel),
2249         XtOffsetOf (AppearanceData, activeTopShadowColor),
2250         XtRCallProc,
2251         (XtPointer)_WmATopShadowColorDefault
2252     },
2253
2254     {
2255         WmNactiveBackgroundPixmap,
2256         XmCBackgroundPixmap,
2257         XtRString,
2258         sizeof (String),
2259         XtOffsetOf (AppearanceData, activeBackgroundPStr),
2260         XtRCallProc,
2261         (XtPointer)_WmABackgroundPixmapDefault
2262     },
2263
2264     {
2265         WmNactiveTopShadowPixmap,
2266         XmCTopShadowPixmap,
2267         XtRString,
2268         sizeof (String),
2269         XtOffsetOf (AppearanceData, activeTopShadowPStr),
2270         XtRCallProc,
2271         (XtPointer)_WmATopShadowPixmapDefault
2272     }
2273
2274 };
2275
2276
2277 \f
2278 /*************************************<->*************************************
2279  *
2280  *  _WmIconImageFDefault (widget, offset, value)
2281  *  _WmIconImageBDefault (widget, offset, value)
2282  *  _WmIconImageBSCDefault (widget, offset, value)
2283  *  _WmIconImageBSPDefault (widget, offset, value)
2284  *  _WmIconImageTSCDefault (widget, offset, value)
2285  *  _WmIconImageTSPDefault (widget, offset, value)
2286  *  _WmMatteFDefault (widget, offset, value)
2287  *  _WmMatteBDefault (widget, offset, value)
2288  *  _WmMatteBSCDefault (widget, offset, value)
2289  *  _WmMatteBSPDefault (widget, offset, value)
2290  *  _WmMatteTSCDefault (widget, offset, value)
2291  *  _WmMatteTSPDefault (widget, offset, value)
2292  *
2293  *
2294  *  Description:
2295  *  -----------
2296  *  These functions are used to generate dynamic defaults for various
2297  *  client-specific appearance related resources.
2298  *
2299  *
2300  *  Inputs:
2301  *  ------
2302  *  widget = this is the parent widget for the wm subpart
2303  *
2304  *  offset = this is the resource offset
2305  *
2306  *  value = this is a pointer to a XrmValue in which to store the result
2307  *
2308  *  _pCD = (static global) pointer to client data associated with resources
2309  *
2310  * 
2311  *  Outputs:
2312  *  -------
2313  *  value = default resource value and size
2314  * 
2315  *************************************<->***********************************/
2316
2317 void 
2318 _WmIconImageFDefault (Widget widget, int offset, XrmValue *value)
2319 {
2320     _WmGetDynamicDefault (widget, WmFGC, 0,
2321         _pCD->iconImageBackground, value);
2322
2323 } /* END OF FUNCTION _WmIconImageFDefault */
2324
2325 void 
2326 _WmIconImageBDefault (Widget widget, int offset, XrmValue *value)
2327 {
2328     value->addr = (char *)&(_pCD->pSD->iconAppearance.background);
2329     value->size = sizeof (Pixel);
2330
2331 } /* END OF FUNCTION _WmIconImageBDefault */
2332
2333
2334 void 
2335 _WmIconImageBSCDefault (Widget widget, int offset, XrmValue *value)
2336 {
2337     _WmGetDynamicDefault (widget, WmBSC, 0,
2338         _pCD->iconImageBackground, value);
2339
2340 } /* END OF FUNCTION _WmIconImageBSCDefault */
2341
2342
2343 void 
2344 _WmIconImageBSPDefault (Widget widget, int offset, XrmValue *value)
2345 {
2346
2347     value->addr = (char *)_pCD->pSD->iconAppearance.bottomShadowPStr;
2348     value->size = sizeof (String);
2349
2350 } /* END OF FUNCTION _WmIconImageBSCDefault */
2351
2352
2353 void 
2354 _WmIconImageTSCDefault (Widget widget, int offset, XrmValue *value)
2355 {
2356     _WmGetDynamicDefault (widget, WmTSC, 0,
2357         _pCD->iconImageBackground, value);
2358
2359 } /* END OF FUNCTION _WmIconImageTSCDefault */
2360
2361
2362 void 
2363 _WmIconImageTSPDefault (Widget widget, int offset, XrmValue *value)
2364 {
2365
2366     value->addr = (char *)_pCD->pSD->iconAppearance.topShadowPStr;
2367     value->size = sizeof (String);
2368
2369 } /* END OF FUNCTION _WmIconImageTSPDefault */
2370
2371
2372 void 
2373 _WmMatteFDefault (Widget widget, int offset, XrmValue *value)
2374 {
2375     _WmGetDynamicDefault (widget, WmFGC, 0,
2376         _pCD->matteBackground, value);
2377
2378 } /* END OF FUNCTION _WmMatteFDefault */
2379
2380
2381 void 
2382 _WmMatteBDefault (Widget widget, int offset, XrmValue *value)
2383 {
2384     value->addr = (char *)&(_pCD->pSD->clientAppearance.background);
2385     value->size = sizeof (Pixel);
2386
2387 } /* END OF FUNCTION _WmMatteBDefault */
2388
2389
2390 void 
2391 _WmMatteBSCDefault (Widget widget, int offset, XrmValue *value)
2392 {
2393     _WmGetDynamicDefault (widget, WmBSC, 0,
2394         _pCD->matteBackground, value);
2395
2396 } /* END OF FUNCTION _WmMatteBSCDefault */
2397
2398
2399 void 
2400 _WmMatteBSPDefault (Widget widget, int offset, XrmValue *value)
2401 {
2402
2403     value->addr = (char *)_pCD->pSD->clientAppearance.bottomShadowPStr;
2404     value->size = sizeof (String);
2405
2406 } /* END OF FUNCTION _WmMatteBSCDefault */
2407
2408
2409 void 
2410 _WmMatteTSCDefault (Widget widget, int offset, XrmValue *value)
2411 {
2412     _WmGetDynamicDefault (widget, WmTSC, 0,
2413         _pCD->matteBackground, value);
2414
2415 } /* END OF FUNCTION _WmMatteTSCDefault */
2416
2417
2418 void 
2419 _WmMatteTSPDefault (Widget widget, int offset, XrmValue *value)
2420 {
2421
2422     value->addr = (char *)_pCD->pSD->clientAppearance.topShadowPStr;
2423     value->size = sizeof (String);
2424
2425 } /* END OF FUNCTION _WmMatteTSCDefault */
2426
2427
2428 \f
2429 /*************************************<->*************************************
2430  *
2431  *  _WmBackgroundDefault (widget, offset, value)
2432  *  _WmForegroundDefault (widget, offset, value)
2433  *  _WmBackgroundPixmapDefault (widget, offset, value)
2434  *  _WmBottomShadowColorDefault (widget, offset, value)
2435  *  _WmTopShadowColorDefault (widget, offset, value)
2436  *  _WmTopShadowPixmapDefault (widget, offset, value)
2437  *  _WmABackgroundDefault (widget, offset, value)
2438  *  _WmAForegroundDefault (widget, offset, value)
2439  *  _WmABackgroundPixmapDefault (widget, offset, value)
2440  *  _WmABottomShadowColorDefault (widget, offset, value)
2441  *  _WmRFBackgroundDefault (widget, offset, value)
2442  *  _WmRFForegroundDefault (widget, offset, value)
2443  *  _WmATopShadowColorDefault (widget, offset, value)
2444  *  _WmATopShadowPixmapDefault (widget, offset, value)
2445  *
2446  *
2447  *  Description:
2448  *  -----------
2449  *  These functions are used to generate dynamic defaults for various
2450  *  component appearance related resources (not client-specific).
2451  *
2452  *
2453  *  Inputs:
2454  *  ------
2455  *  widget = this is the parent widget for the wm subpart
2456  *
2457  *  offset = this is the resource offset
2458  *
2459  *  value = this is a pointer to a XrmValue in which to store the result
2460  *
2461  *  _defaultBackground = (static global) default background color (inactive)
2462  *
2463  *  _defaultActiveBackground = (static global) default bg color (active)
2464  *
2465  *  _pAppearanceData = (static global) pointer to resouce set structure
2466  *
2467  * 
2468  *  Outputs:
2469  *  -------
2470  *  value = default resource value and size
2471  * 
2472  *************************************<->***********************************/
2473
2474 void 
2475 _WmBackgroundDefault (Widget widget, int offset, XrmValue *value)
2476 {
2477     _WmGetDynamicDefault (widget, WmBGC, _defaultBackground, 0, value);
2478
2479 } /* END OF FUNCTION _WmBackgroundDefault */
2480
2481
2482 void 
2483 _WmForegroundDefault (Widget widget, int offset, XrmValue *value)
2484 {
2485     _WmGetDynamicDefault (widget, WmFGC, 0, _pAppearanceData->background,
2486         value);
2487
2488 } /* END OF FUNCTION _WmForegroundDefault */
2489
2490
2491 void 
2492 _WmBackgroundPixmapDefault (Widget widget, int offset, XrmValue *value)
2493 {
2494     static String string;
2495
2496
2497     if ((Monochrome (XtScreen (widget))) ||
2498         (_pAppearanceData->topShadowColor == _pAppearanceData->background))
2499     {
2500         string = (String) _25_foreground;
2501     }
2502     else
2503     {
2504         string = NULL;
2505     }
2506
2507     value->addr = (char *)string;
2508     value->size = sizeof (String);
2509
2510 } /* END OF FUNCTION _WmBackgroundPixmapDefault */
2511
2512
2513 void 
2514 _WmBottomShadowColorDefault (Widget widget, int offset, XrmValue *value)
2515 {
2516     _WmGetDynamicDefault (widget, WmBSC, 0, _pAppearanceData->background,
2517         value);
2518
2519 } /* END OF FUNCTION _WmBottomShadowColorDefault */
2520
2521
2522 void 
2523 _WmTopShadowColorDefault (Widget widget, int offset, XrmValue *value)
2524 {
2525     _WmGetDynamicDefault (widget, WmTSC, 0, _pAppearanceData->background,
2526         value);
2527
2528 } /* END OF FUNCTION _WmTopShadowColorDefault */
2529
2530
2531 void 
2532 _WmTopShadowPixmapDefault (Widget widget, int offset, XrmValue *value)
2533 {
2534     static String string;
2535
2536
2537     if ((Monochrome (XtScreen (widget))) ||
2538         (_pAppearanceData->topShadowColor == _pAppearanceData->background))
2539     {
2540         /* Fix monochrome 3D appearance */
2541         string = (String) _50_foreground;
2542         if (_pAppearanceData->backgroundPStr != NULL)
2543             if (!strcmp(_pAppearanceData->backgroundPStr, _25_foreground) ||
2544                 !strcmp(_pAppearanceData->backgroundPStr, _50_foreground))
2545             {
2546                 string = (String) _foreground;
2547             }
2548     }
2549     else
2550     {
2551         string = NULL;
2552     }
2553
2554     value->addr = (char *)string;
2555     value->size = sizeof (String);
2556
2557 } /* END OF FUNCTION _WmTopShadowPixmapDefault */
2558
2559
2560 void 
2561 _WmABackgroundDefault (Widget widget, int offset, XrmValue *value)
2562 {
2563     _WmGetDynamicDefault (widget, WmBGC, _defaultActiveBackground, 0, value);
2564
2565 } /* END OF FUNCTION _WmABackgroundDefault */
2566
2567
2568 void 
2569 _WmAForegroundDefault (Widget widget, int offset, XrmValue *value)
2570 {
2571     _WmGetDynamicDefault (widget, WmFGC, 0, _pAppearanceData->activeBackground,
2572         value);
2573
2574 } /* END OF FUNCTION _WmAForegroundDefault */
2575
2576 void 
2577 _WmABackgroundPixmapDefault (Widget widget, int offset, XrmValue *value)
2578 {
2579     static String string;
2580
2581
2582     if ((Monochrome (XtScreen (widget))) ||
2583         (_pAppearanceData->activeTopShadowColor ==
2584                                         _pAppearanceData->activeBackground))
2585     {
2586         string = (String) _50_foreground;
2587     }
2588     else
2589     {
2590         string = NULL;
2591     }
2592
2593     value->addr = (char *)string;
2594     value->size = sizeof (String);
2595
2596 } /* END OF FUNCTION _WmABackgroundPixmapDefault */
2597
2598 void 
2599 _WmABottomShadowColorDefault (Widget widget, int offset, XrmValue *value)
2600 {
2601     _WmGetDynamicDefault (widget, WmBSC, 0, _pAppearanceData->activeBackground,
2602         value);
2603
2604 } /* END OF FUNCTION _WmABottomShadowColorDefault */
2605
2606
2607 void 
2608 _WmATopShadowColorDefault (Widget widget, int offset, XrmValue *value)
2609 {
2610     _WmGetDynamicDefault (widget, WmTSC, 0, _pAppearanceData->activeBackground,
2611         value);
2612
2613 } /* END OF FUNCTION _WmATopShadowColorDefault */
2614
2615
2616 void 
2617 _WmATopShadowPixmapDefault (Widget widget, int offset, XrmValue *value)
2618 {
2619     static String string;
2620
2621     if ((Monochrome (XtScreen (widget))) ||
2622         (_pAppearanceData->activeTopShadowColor ==
2623                                      _pAppearanceData->activeBackground))
2624     {
2625         /* Fix monochrome 3D appearance */
2626         string = (String) _50_foreground;
2627         if (_pAppearanceData->activeBackgroundPStr != NULL)
2628             if (!strcmp
2629                     (_pAppearanceData->activeBackgroundPStr, _25_foreground) ||
2630                 !strcmp
2631                     (_pAppearanceData->activeBackgroundPStr, _50_foreground))
2632             {
2633                 string = (String) _foreground;
2634             }
2635     }
2636     else
2637     {
2638         string = NULL;
2639     }
2640     
2641     value->addr = (char *)string;
2642     value->size = sizeof (String);
2643     
2644 } /* END OF FUNCTION _WmATopShadowPixmapDefault */
2645
2646
2647 void 
2648 _WmBackdropBgDefault (Widget widget, int offset, XrmValue *value)
2649 {
2650     static Pixel pixValue;
2651     unsigned int colorSetId = (unsigned int) pResWS->backdrop.colorSet;
2652
2653     if (wmGD.statusColorServer == CSERVE_NORMAL)
2654     {
2655         if ((colorSetId == 0) || (colorSetId > XmCO_MAX_NUM_COLORS))
2656         {
2657             colorSetId = (unsigned int) DefaultWsColorSetId (pResWS);
2658         }
2659
2660         switch (pResWS->pSD->colorUse)
2661         {
2662             case XmCO_BLACK_WHITE:
2663                 pixValue = pResWS->pSD->pPixelData[colorSetId-1].bg;
2664                 break;
2665
2666             default:
2667             case XmCO_LOW_COLOR:
2668             case XmCO_MEDIUM_COLOR:
2669             case XmCO_HIGH_COLOR:
2670                 pixValue = pResWS->pSD->pPixelData[colorSetId-1].bs;
2671                 break;
2672         }
2673     }
2674     else
2675     {
2676         /*
2677          *  Color server is unavailable.  Has user specified a colorset?
2678          *
2679          *  If not, go monochrome.
2680          *
2681          */
2682             pixValue = WhitePixel (DISPLAY, pResWS->pSD->screen);
2683     }
2684
2685     /* return the dynamic default */
2686
2687     value->addr = (char *) &pixValue;
2688     value->size = sizeof (Pixel);
2689
2690 } /* END OF FUNCTION _WmBackdropBgDefault */
2691
2692 void 
2693 _WmBackdropFgDefault (Widget widget, int offset, XrmValue *value)
2694 {
2695     static Pixel pixValue;
2696     unsigned int colorSetId = (unsigned int) pResWS->backdrop.colorSet;
2697
2698     if (wmGD.statusColorServer == CSERVE_NORMAL)
2699     {
2700         if ((colorSetId == 0) || (colorSetId > XmCO_MAX_NUM_COLORS))
2701         {
2702             colorSetId = (unsigned int) DefaultWsColorSetId (pResWS);
2703         }
2704
2705         switch (pResWS->pSD->colorUse)
2706         {
2707             case XmCO_BLACK_WHITE:
2708                 pixValue = pResWS->pSD->pPixelData[colorSetId-1].fg;
2709                 break;
2710
2711             default:
2712             case XmCO_LOW_COLOR:
2713             case XmCO_MEDIUM_COLOR:
2714             case XmCO_HIGH_COLOR:
2715                 pixValue = pResWS->pSD->pPixelData[colorSetId-1].bg;
2716                 break;
2717         }
2718     }
2719     else
2720     {
2721         /*
2722          *  Color server is unavailable.  Has user specified a colorset?
2723          *
2724          *  If not, go monochrome.
2725          *
2726          */
2727             pixValue = BlackPixel (DISPLAY, pResWS->pSD->screen);
2728     }
2729     value->addr = (char *) &pixValue;
2730     value->size = sizeof (Pixel);
2731
2732 } /* END OF FUNCTION _WmBackdropFgDefault */
2733
2734 void 
2735 _WmBackdropColorSetDefault (Widget widget, int offset, XrmValue *value)
2736 {
2737     static unsigned int colorSetId;
2738
2739     if (wmGD.statusColorServer == CSERVE_NORMAL)
2740     {
2741         colorSetId = (unsigned int) DefaultWsColorSetId (pResWS);
2742     }
2743     else
2744     {
2745         colorSetId = 0; /* invalid color set */
2746     }
2747
2748     value->addr = (char *) &colorSetId;
2749     value->size = sizeof (Pixel);
2750
2751 } /* END OF FUNCTION _WmBackdropColorSetIdDefault */
2752
2753 void 
2754 _WmIconImageMaximumDefault (Widget widget, int offset, XrmValue *value)
2755 {
2756     static WHSize cval;
2757
2758     if ((pResSD->displayResolutionType == LOW_RES_DISPLAY) ||
2759         (pResSD->displayResolutionType == VGA_RES_DISPLAY))
2760     {
2761         cval.width = 32;
2762         cval.height = 32;
2763     }
2764     else
2765     {
2766         cval.width = 48;
2767         cval.height = 48;
2768     }
2769
2770     value->addr = (char *)  &cval;
2771     value->size = sizeof (WHSize);
2772
2773 } /* END OF FUNCTION _WmIconImageMaximumDefault */
2774
2775 \f
2776 /*************************************<->*************************************
2777  *
2778  *  DefaultWsColorSetId (pWS)
2779  *
2780  *
2781  *  Description:
2782  *  -----------
2783  *  This function returns the default colorSetId for a given workspace
2784  *
2785  *
2786  *  Inputs:
2787  *  ------
2788  *  pWS = ptr to workspace data
2789  * 
2790  *  Outputs:
2791  *  -------
2792  *  return = default color set ID.
2793  *
2794  *  "active" and "inactive" color sets are not used.
2795  * 
2796  *************************************<->***********************************/
2797
2798 int 
2799 DefaultWsColorSetId (WmWorkspaceData *pWS)
2800 {
2801     static int _ws_high_color_map[] = { 3, 5, 6, 7 };
2802 #define        _WS_HIGH_COLOR_COUNT     4    
2803     int i;
2804     WmScreenData *pSD;
2805     int iIndex;
2806     int rval = 8;
2807
2808     if (pWS)
2809     {
2810         pSD = pWS->pSD;
2811
2812         iIndex = (int) ((unsigned long)(pWS) - 
2813                           (unsigned long)(pSD->pWS))/sizeof(WmWorkspaceData);
2814         if (iIndex < 0) 
2815             iIndex = 0; /* bad pWS or pSD, shouldn't get here */
2816
2817         switch (pSD->colorUse)
2818         {
2819             case XmCO_BLACK_WHITE:
2820             case XmCO_LOW_COLOR:
2821                 rval = 1 +
2822                   (pSD->pInactivePixelSet-pSD->pPixelData)/sizeof(XmPixelSet);
2823                 break;
2824
2825             case XmCO_MEDIUM_COLOR:
2826                 rval = HARD_CODED_PRIMARY;
2827                 break;
2828
2829             case XmCO_HIGH_COLOR:
2830                 i = iIndex % _WS_HIGH_COLOR_COUNT;
2831                 rval = _ws_high_color_map[i];
2832                 break;
2833         }
2834     }
2835
2836     return (rval);
2837
2838 } /* END OF FUNCTION DefaultWsColorSetId */
2839
2840
2841
2842 \f
2843 /*************************************<->*************************************
2844  *
2845  *  _WmFocusAutoRaiseDefault (widget, offset, value)
2846  *
2847  *
2848  *  Description:
2849  *  -----------
2850  *  This function generates a default value for the focusAutoRaise resource.
2851  *
2852  *
2853  *  Inputs:
2854  *  ------
2855  *  widget = this is the parent widget for the wm subpart
2856  *
2857  *  offset = this is the resource offset
2858  *
2859  *  value = this is a pointer to a XrmValue in which to store the result
2860  *
2861  * 
2862  *  Outputs:
2863  *  -------
2864  *  value = default resource value and size
2865  * 
2866  *************************************<->***********************************/
2867
2868 void 
2869 _WmFocusAutoRaiseDefault (Widget widget, int offset, XrmValue *value)
2870 {
2871     static Boolean focusAutoRaise;
2872
2873     if (wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_EXPLICIT)
2874     {
2875         focusAutoRaise = True;
2876     }
2877     else
2878     {
2879         focusAutoRaise = False;
2880     }
2881
2882     value->addr = (char *)&focusAutoRaise;
2883     value->size = sizeof (Boolean);
2884
2885 } /* END OF FUNCTION _WmFocusAutoRaiseDefault */
2886
2887 \f
2888 /*************************************<->*************************************
2889  *
2890  *  _WmMultiClickTimeDefault (widget, offset, value)
2891  *
2892  *
2893  *  Description:
2894  *  -----------
2895  *  This function generates a default value for the doubleClickTime resource.
2896  *  We dynamically default to the XtR4 multiClickTime value.
2897  *
2898  *  Inputs:
2899  *  ------
2900  *  widget = this is the parent widget for the wm subpart
2901  *
2902  *  offset = this is the resource offset
2903  *
2904  *  value = this is a pointer to a XrmValue in which to store the result
2905  *
2906  *  Outputs:
2907  *  -------
2908  *  value = default resource value and size
2909  * 
2910  *************************************<->***********************************/
2911
2912 void 
2913 _WmMultiClickTimeDefault (Widget widget, int offset, XrmValue *value)
2914 {
2915     static int multiClickTime;
2916
2917     multiClickTime = XtGetMultiClickTime(XtDisplay(widget));
2918
2919     value->addr = (char *)&multiClickTime;
2920     value->size = sizeof (int);
2921
2922 } /* END OF FUNCTION _WmMultiClickTimeDefault */
2923
2924
2925 /*************************************<->*************************************
2926  *
2927  *  _WmSecondariesOnTopDefault (widget, offset, value)
2928  *
2929  *
2930  *  Description:
2931  *  -----------
2932  *  This function generates a default value for the secondariesOnTop 
2933  *  resource.
2934  *
2935  *  Inputs:
2936  *  ------
2937  *  widget = this is the parent widget for the wm subpart
2938  *
2939  *  offset = this is the resource offset
2940  *
2941  *  value = this is a pointer to a XrmValue in which to store the result
2942  *
2943  *  Outputs:
2944  *  -------
2945  *  value = default resource value and size
2946  * 
2947  *************************************<->***********************************/
2948
2949 void 
2950 _WmSecondariesOnTopDefault (Widget widget, int offset, XrmValue *value)
2951 {
2952     static Boolean secondariesOnTop;
2953
2954     /*
2955      * Inherit setting from primary window if this window is 
2956      * secondary. 
2957      */
2958
2959     if (_pCD->transientLeader != NULL)
2960         secondariesOnTop = _pCD->transientLeader->secondariesOnTop;
2961     else
2962         secondariesOnTop = True;
2963
2964     value->addr = (char *)&secondariesOnTop;
2965     value->size = sizeof (Boolean);
2966
2967 } /* END OF FUNCTION _WmSecondariesOnTopDefault */
2968
2969
2970 \f
2971 /******************************<->*************************************
2972  *
2973  *  ProcessWmResources ()
2974  *
2975  *
2976  *  Description:
2977  *  -----------
2978  *  This function is used to retrieve and process window manager resources
2979  *  that are not client-specific.
2980  *
2981  *
2982  *  Inputs:
2983  *  ------
2984  *  wmGlobalResources = pointer to wm resource list
2985  *
2986  * 
2987  *  Outputs:
2988  *  -------
2989  *  wmGD = (global data filled out with resource values)
2990  * 
2991  *************************************<->***********************************/
2992
2993 void 
2994 ProcessWmResources (void)
2995 {
2996
2997     /*
2998      * Process the mwm general appearance and behavior resources.  Retrieve
2999      * a limited set of resource values if the window manager is starting
3000      * up with the standard behavior.
3001      */
3002
3003     if (wmGD.useStandardBehavior)
3004     {
3005         XtGetApplicationResources (wmGD.topLevelW, (XtPointer) &wmGD,
3006             wmStdGlobalResources, XtNumber (wmStdGlobalResources), NULL, 0);
3007
3008         /*
3009          * Fill in the standard resource values.
3010          */
3011
3012         SetStdGlobalResourceValues ();
3013     }
3014     else
3015     {
3016         XtGetApplicationResources (wmGD.topLevelW, (XtPointer) &wmGD,
3017             wmGlobalResources, XtNumber (wmGlobalResources), NULL, 0);
3018     }
3019
3020     if (wmGD.autoRaiseDelay < 0)
3021     {
3022        wmGD.autoRaiseDelay = 500;
3023        Warning (((char *)GETMESSAGE(62, 66, "Out of range autoRaiseDelay resource value. Must be non-negative")));
3024     }
3025
3026 } /* END OF FUNCTION ProcessWmResources */
3027
3028
3029 \f
3030 /******************************<->*************************************
3031  *
3032  *  ProcessGlobalScreenResources ()
3033  *
3034  *
3035  *  Description:
3036  *  -----------
3037  *  This function is used to retrieve window manager resources to 
3038  *  determine the screens to manage.
3039  *
3040  *
3041  *  Inputs:
3042  *  ------
3043  *  wmGlobalScreenResources = pointer to wm resource list
3044  *
3045  * 
3046  *  Outputs:
3047  *  -------
3048  *  wmGD = (global data filled out with resource values)
3049  * 
3050  *************************************<->***********************************/
3051
3052 void 
3053 ProcessGlobalScreenResources (void)
3054 {
3055     XtGetApplicationResources (wmGD.topLevelW, &wmGD,
3056         wmGlobalScreenResources, 
3057         XtNumber (wmGlobalScreenResources), NULL, 0);
3058
3059     if (wmGD.multiScreen)
3060     {
3061         wmGD.numScreens = ScreenCount(DISPLAY);
3062     }
3063     else
3064     {
3065         wmGD.numScreens = 1;
3066     }
3067
3068     if (wmGD.screenList != NULL)
3069     {
3070         ProcessScreenListResource();
3071     }
3072 }
3073
3074
3075 \f
3076 /*************************************<->*************************************
3077  *
3078  *  SetStdGlobalResourceValues ()
3079  *
3080  *
3081  *  Description:
3082  *  -----------
3083  *  This function sets resource data to standard values.  This setting
3084  *  is done in place of getting the values from the user settings in
3085  *  the resource database.
3086  *
3087  * 
3088  *  Outputs:
3089  *  -------
3090  *  wmGD = (global data filled out with resource values)
3091  * 
3092  *************************************<->***********************************/
3093
3094 void 
3095 SetStdGlobalResourceValues (void)
3096 {
3097     wmGD.autoKeyFocus = True;
3098     wmGD.clientAutoPlace = True;
3099     wmGD.colormapFocusPolicy = CMAP_FOCUS_KEYBOARD;
3100     wmGD.deiconifyKeyFocus = True;
3101     wmGD.doubleClickTime = 500;
3102     wmGD.freezeOnConfig = True;
3103     wmGD.iconAutoPlace = True;
3104     wmGD.iconClick = True;
3105     wmGD.interactivePlacement = False;
3106     wmGD.keyboardFocusPolicy = KEYBOARD_FOCUS_EXPLICIT;
3107     wmGD.lowerOnIconify = True;
3108     wmGD.passSelectButton = True;
3109     wmGD.startupKeyFocus = True;
3110     wmGD.systemButtonClick = True;
3111     wmGD.systemButtonClick2 = True;
3112     wmGD.useFrontPanel=False;
3113
3114 } /* END OF FUNCTION SetStdGlobalResourceValues */
3115
3116
3117 \f
3118 /*************************************<->*************************************
3119  *
3120  *  ProcessScreenListResource ()
3121  *
3122  *
3123  *  Description:
3124  *  -----------
3125  *  This processes the names in the screenList resource.
3126  *
3127  *
3128  *  Inputs:
3129  *  ------
3130  *  wmGlobalResources = pointer to wmGD.screenList 
3131  *
3132  * 
3133  *  Outputs:
3134  *  -------
3135  *  wmGD.screenNames
3136  * 
3137  *************************************<->***********************************/
3138
3139 void 
3140 ProcessScreenListResource (void)
3141 {
3142     unsigned char *lineP;
3143     unsigned char *string;
3144     int sNum = 0;
3145     int nameCount = 0;
3146
3147     lineP = (unsigned char *)wmGD.screenList;
3148
3149     /*
3150      *  Parse screenList. 
3151      */
3152     while (((string = GetString(&lineP)) != NULL) && 
3153            (sNum < ScreenCount(DISPLAY)))
3154     {
3155         if (!(wmGD.screenNames[sNum] = (unsigned char *) 
3156             WmRealloc ((char*)wmGD.screenNames[sNum], strlen((char*)string)+1)))
3157         {
3158             ExitWM(WM_ERROR_EXIT_VALUE);
3159         }
3160         else 
3161         {
3162             strcpy((char *)wmGD.screenNames[sNum], (char *)string);
3163             nameCount++;
3164             sNum++;
3165         }
3166     }
3167
3168     /*
3169      * If the number of listed screens (sNum) is < screen count, fill in the 
3170      * remaining screen names with the name of the first screen specified,
3171      * if such exists.
3172      */
3173     if (nameCount > 0)
3174     {
3175         string = wmGD.screenNames[0];    /* name of the first screen */
3176         while (sNum < ScreenCount(DISPLAY))
3177         {
3178             if (!(wmGD.screenNames[sNum] = (unsigned char *) 
3179                 WmRealloc ((char*)wmGD.screenNames[sNum], 
3180                                 strlen((char *)string)+1)))
3181             {
3182                 ExitWM(WM_ERROR_EXIT_VALUE);
3183             }
3184             else 
3185             {
3186                 strcpy((char *)wmGD.screenNames[sNum], (char *)string);
3187                 sNum++;
3188             }
3189         }
3190     }
3191
3192         
3193 } /* END OF FUNCTION ProcessScreenListResource */
3194
3195
3196 /******************************<->*************************************
3197  *
3198  *  ProcessWmColors ()
3199  *
3200  *
3201  *  Description:
3202  *  -----------
3203  *  Retrieve the color sets from the colorserver.
3204  *
3205  *  Inputs:
3206  *  ------
3207  *  none
3208  * 
3209  *  Outputs:
3210  *  -------
3211  *  modifies parts of global pixel sets
3212  *
3213  *  Comments:
3214  *  --------
3215  * 
3216  ******************************<->***********************************/
3217
3218 void 
3219 ProcessWmColors (WmScreenData *pSD)
3220 {
3221     short active, inactive, primary, secondary;
3222
3223     if ((pSD->pPixelData = (XmPixelSet *) 
3224             XtMalloc (XmCO_NUM_COLORS * sizeof(XmPixelSet)))) 
3225     {
3226         /*
3227          *
3228          *
3229          *  ASSUMPTION:  If XmeGetPixelData() returns true,
3230          *  we have a good color server at our disposal.
3231          *
3232          *
3233          */
3234         if (XmeGetPixelData (pSD->screen, &pSD->colorUse,
3235                                 pSD->pPixelData, &active, &inactive,
3236                                 &primary, &secondary))
3237         {
3238             pSD->pActivePixelSet = &(pSD->pPixelData[active]);
3239             pSD->pInactivePixelSet = &(pSD->pPixelData[inactive]);
3240             pSD->pPrimaryPixelSet = &(pSD->pPixelData[primary]);
3241             pSD->pSecondaryPixelSet = &(pSD->pPixelData[secondary]);
3242
3243             /*  Hack here.  The index "4" is the proper array reference.   */
3244             /*  This is used because XmGetPixelData has not been properly  */
3245             /*  updated.                                                   */
3246             
3247             pSD->pTextPixelSet = &(pSD->pPixelData[3]);
3248
3249             wmGD.statusColorServer = CSERVE_NORMAL;
3250
3251         }
3252         else
3253         {
3254             XtFree((char *)pSD->pPixelData);
3255             pSD->pPixelData = NULL;
3256             pSD->pActivePixelSet = NULL;
3257             pSD->pInactivePixelSet = NULL;
3258             pSD->pPrimaryPixelSet = NULL;
3259             pSD->pSecondaryPixelSet = NULL;
3260             pSD->pTextPixelSet = NULL;
3261         }
3262     }
3263     else 
3264     {
3265         Warning (((char *)GETMESSAGE(62, 22, "Insufficient memory for color data")));
3266         ExitWM (WM_ERROR_EXIT_VALUE);
3267     }
3268
3269 } /* END OF FUNCTION ProcessWmColors */
3270
3271 \f
3272 /******************************<->*************************************
3273  *
3274  *  WriteOutXrmColors ()
3275  *
3276  *
3277  *  Description:
3278  *  -----------
3279  *  Update the XRM database with pixel values from the color server.
3280  *
3281  *  Inputs:
3282  *  ------
3283  *  pSD    = contains pixel sets
3284  * 
3285  *  Outputs:
3286  *  -------
3287  *  updated resource database
3288  *  
3289  *  Comments:
3290  *  --------
3291  *  N.B.  Must change to write out data on a PER-SCREEN basis.
3292  *        e.g., "Dtwm*0*background"
3293  ******************************<->***********************************/
3294
3295 static void 
3296 WriteOutXrmColors (WmScreenData *pSD)
3297 {
3298     XrmDatabase     db;
3299     XrmValue        value;
3300     int             thisScreen = pSD->screen;
3301     XmPixelSet     *tpixset;
3302     XmPixelSet     *spixset;
3303
3304     char *res_class;
3305     String screen_name;
3306
3307     if (MwmBehavior)
3308     {
3309         res_class = WM_RESOURCE_CLASS;
3310     }
3311     else 
3312     {
3313         res_class = DT_WM_RESOURCE_CLASS;
3314     }
3315
3316     screen_name = (String) wmGD.screenNames[pSD->screen];
3317
3318     db = XtScreenDatabase(XScreenOfDisplay(DISPLAY, thisScreen));
3319
3320     /** update the clients database with new colors **/
3321     value.size = sizeof(Pixel);
3322
3323     /*
3324      *
3325      *    WM ACTIVE RESOURCES--e.g., for the active frame 
3326      *
3327      */
3328     if (pSD->pActivePixelSet)
3329     {
3330         tpixset = pSD->pActivePixelSet;
3331         spixset = pSD->pSecondaryPixelSet;
3332
3333         if (pSD->colorUse == XmCO_BLACK_WHITE)
3334         {
3335             /*
3336              *
3337              *  Limit ourselves here to the client (frame)
3338              *  visuals
3339              *
3340              */
3341
3342             /* activeForeground */
3343             value.addr = (XtPointer) &(BlackPixel(DISPLAY, pSD->screen));
3344
3345             XrmPutResource (&db, 
3346                 ResCat (res_class, screen_name, WmNactiveForeground, 
3347                         NULL), XtRPixel, &value);
3348
3349             /* activeBackground */
3350             value.addr = (XtPointer) &(WhitePixel(DISPLAY, pSD->screen));
3351
3352             XrmPutResource (&db, 
3353                 ResCat (res_class, screen_name, WmNactiveBackground,
3354                         NULL), XtRPixel, &value);
3355
3356             XrmPutStringResource (&db, ResCat (res_class, screen_name, 
3357                      WmNactiveBackgroundPixmap, NULL),
3358                     _foreground);
3359
3360             /* activeTopShadow */
3361             XrmPutStringResource (&db, ResCat (res_class, screen_name, 
3362                     WmNactiveTopShadowPixmap, NULL),
3363                 _Dither);
3364
3365             value.addr = (XtPointer) &(BlackPixel(DISPLAY, pSD->screen));
3366             XrmPutResource (&db,
3367                 ResCat (res_class, screen_name, WmNactiveTopShadowColor,
3368                         NULL), XtRPixel, &value);
3369
3370             /* activeBottomShadow */
3371             value.addr = (XtPointer) &(BlackPixel(DISPLAY, pSD->screen));
3372             XrmPutResource (&db,
3373                 ResCat (res_class, screen_name, 
3374                         WmNactiveBottomShadowColor, NULL), XtRPixel, &value);
3375
3376             XrmPutStringResource (&db, ResCat (res_class, screen_name, 
3377                     WmNactiveBottomShadowPixmap, NULL),
3378                     _foreground);
3379         }
3380
3381         else /* active colors for non-BW systems */
3382         {
3383             value.addr = (XtPointer) &(tpixset->bg);
3384             XrmPutResource (&db, 
3385                 ResCat (res_class, screen_name, WmNactiveBackground, NULL),
3386                 XtRPixel, &value);
3387
3388             value.addr = (XtPointer) &(tpixset->fg);
3389             XrmPutResource (&db, 
3390                 ResCat (res_class, screen_name, WmNactiveForeground, NULL),
3391                 XtRPixel, &value);
3392
3393                 value.addr = (XtPointer) &(tpixset->ts);
3394                 XrmPutResource (&db, 
3395                     ResCat (res_class, screen_name, WmNactiveTopShadowColor, NULL),
3396                     XtRPixel, &value);
3397
3398                 value.addr = (XtPointer) &(tpixset->bs);
3399                 XrmPutResource (&db,
3400                     ResCat (res_class, screen_name, WmNactiveBottomShadowColor, NULL),
3401                     XtRPixel, &value);
3402
3403                 if (XmCO_DitherTopShadow(DISPLAY, thisScreen, tpixset)) 
3404                 {
3405                     XrmPutStringResource (&db, 
3406                         ResCat (res_class, screen_name, WmNactiveTopShadowPixmap, NULL),
3407                         _Dither);
3408
3409                 }
3410
3411                 if (XmCO_DitherBottomShadow(DISPLAY, thisScreen, tpixset)) 
3412                 {
3413                     XrmPutStringResource (&db,
3414                         ResCat (res_class, screen_name, WmNactiveBottomShadowPixmap, 
3415                                 NULL),
3416                         _Dither);
3417
3418                 }
3419         }
3420     }
3421     /*
3422      *
3423      *    WM INACTIVE colors--e.g., for dialogues
3424      *
3425      */
3426     if (pSD->pInactivePixelSet)
3427     {
3428         tpixset = pSD->pInactivePixelSet;
3429         spixset = pSD->pSecondaryPixelSet;
3430
3431         if (pSD->colorUse == XmCO_BLACK_WHITE)
3432         {
3433
3434            /*
3435             *
3436             *  Set colors/pixmaps for the frames--leave the
3437             *  menus out of it so that their text won't look
3438             *  unsatisfactory against a dithered background.
3439             *
3440             */
3441
3442             /* foreground */
3443             value.addr = (XtPointer) &(BlackPixel(DISPLAY, pSD->screen));
3444
3445             XrmPutResource (&db, 
3446                 ResCat (res_class, screen_name, (char *)CLIENT_FRAME_PART,
3447                         WmNforeground), XtRPixel, &value);
3448
3449             XrmPutResource (&db, 
3450                 ResCat (res_class, screen_name, (char *)ICON_FRAME_PART,
3451                         WmNforeground), XtRPixel, &value);
3452
3453
3454             /* background */
3455             XrmPutStringResource (&db, 
3456                 ResCat (res_class, screen_name, (char *)CLIENT_FRAME_PART,
3457                         WmNbackgroundPixmap), _Dither);
3458
3459             XrmPutStringResource (&db, 
3460                 ResCat (res_class, screen_name, (char *)ICON_FRAME_PART,
3461                         WmNbackgroundPixmap), _Dither);
3462
3463             value.addr = (XtPointer) &(WhitePixel(DISPLAY, pSD->screen));
3464             XrmPutResource (&db,
3465                 ResCat (res_class, screen_name, (char *)CLIENT_FRAME_PART,
3466                         WmNbackground), XtRPixel, &value);
3467
3468             XrmPutResource (&db,
3469                 ResCat (res_class, screen_name, (char *)ICON_FRAME_PART,
3470                         WmNbackground), XtRPixel, &value);
3471
3472             /* topshadow */
3473             XrmPutStringResource (&db, 
3474                 ResCat (res_class, screen_name, (char *)CLIENT_FRAME_PART,
3475                         WmNtopShadowPixmap), _foreground);
3476
3477             XrmPutStringResource (&db, 
3478                 ResCat (res_class, screen_name, (char *)ICON_FRAME_PART,
3479                         WmNtopShadowPixmap), _foreground);
3480
3481             value.addr = (XtPointer) &(WhitePixel(DISPLAY, pSD->screen));
3482             XrmPutResource (&db,
3483                 ResCat (res_class, screen_name, (char *)CLIENT_FRAME_PART,
3484                         WmNtopShadowColor), XtRPixel, &value);
3485
3486             XrmPutResource (&db,
3487                 ResCat (res_class, screen_name, (char *)ICON_FRAME_PART,
3488                         WmNtopShadowColor), XtRPixel, &value);
3489
3490
3491             /* bottomshadow */
3492             XrmPutStringResource (&db, 
3493                 ResCat (res_class, screen_name, (char *)CLIENT_FRAME_PART,
3494                         WmNbottomShadowPixmap), _foreground);
3495
3496             XrmPutStringResource (&db, 
3497                 ResCat (res_class, screen_name, (char *)ICON_FRAME_PART,
3498                         WmNbottomShadowPixmap), _foreground);
3499
3500             value.addr = (XtPointer) &(BlackPixel(DISPLAY, pSD->screen));
3501
3502             XrmPutResource (&db, 
3503                 ResCat (res_class, screen_name, (char *)CLIENT_FRAME_PART,
3504                         WmNbottomShadowColor), XtRPixel, &value);
3505
3506             XrmPutResource (&db, 
3507                 ResCat (res_class, screen_name, (char *)ICON_FRAME_PART,
3508                         WmNbottomShadowColor), XtRPixel, &value);
3509
3510                 /*
3511                  *
3512                  *  Ensure that the icon images have a black foreground and
3513                  *  a white background.
3514                  *
3515                  */
3516                     value.addr = (XtPointer) &(BlackPixel(DISPLAY, pSD->screen));
3517
3518                     XrmPutResource (&db, 
3519                         ResCat (res_class, screen_name, WmNiconImageForeground,
3520                                 NULL), XtRPixel, &value);
3521
3522                     value.addr = (XtPointer) &(WhitePixel(DISPLAY, pSD->screen));
3523
3524                     XrmPutResource (&db, 
3525                         ResCat (res_class, screen_name, WmNiconImageBackground,
3526                                 NULL), XtRPixel, &value);
3527
3528             /* Now deal with XmCO_BLACK_WHITE Menus */
3529
3530             /* XmCO_BLACK_WHITE menu foreground */
3531             value.addr = (XtPointer) &(tpixset->fg);
3532
3533             XrmPutResource (&db, 
3534                 ResCat (res_class, screen_name, (char *)MENU_ITEM_PART,
3535                         WmNforeground), XtRPixel, &value);
3536
3537             /* XmCO_BLACK_WHITE menu background */
3538             value.addr = (XtPointer) &(tpixset->bg);
3539
3540             XrmPutResource (&db, 
3541                 ResCat (res_class, screen_name, (char *)MENU_ITEM_PART,
3542                         WmNbackground), XtRPixel, &value);
3543
3544             /* XmCO_BLACK_WHITE menu top shadow */
3545
3546             XrmPutStringResource (&db, 
3547                 ResCat (res_class, screen_name, (char *)MENU_ITEM_PART,
3548                         WmNtopShadowPixmap), _50_foreground);
3549
3550             /* use foreground color for this pixmap */
3551             value.addr = (XtPointer) &(tpixset->fg);
3552
3553             XrmPutResource (&db,
3554                 ResCat (res_class, screen_name, (char *)MENU_ITEM_PART,
3555                         WmNtopShadowColor), XtRPixel, &value);
3556
3557             /* XmCO_BLACK_WHITE menu bottom shadow */
3558
3559             XrmPutStringResource (&db, 
3560                 ResCat (res_class, screen_name, (char *)MENU_ITEM_PART,
3561                         WmNbottomShadowPixmap), _75_foreground);
3562
3563             /* use foreground color for this pixmap */
3564             value.addr = (XtPointer) &(tpixset->fg);
3565
3566             XrmPutResource (&db, 
3567                 ResCat (res_class, screen_name, (char *)MENU_ITEM_PART,
3568                         WmNbottomShadowColor), XtRPixel, &value);
3569
3570             /* Finally, deal with XmCO_BLACK_WHITE Confirm Boxes */
3571
3572             /* XmCO_BLACK_WHITE confirm box foreground */
3573             value.addr = (XtPointer) &(spixset->fg);
3574
3575             XrmPutResource (&db, 
3576                 ResCat (res_class, screen_name, (char *)FEEDBACK_FRAME_PART,
3577                         WmNforeground), XtRPixel, &value);
3578
3579             /* XmCO_BLACK_WHITE confirm box background */
3580             value.addr = (XtPointer) &(spixset->bg);
3581
3582             XrmPutResource (&db, 
3583                 ResCat (res_class, screen_name, (char *)FEEDBACK_FRAME_PART,
3584                         WmNbackground), XtRPixel, &value);
3585
3586             /* XmCO_BLACK_WHITE confirm box top shadow */
3587
3588             XrmPutStringResource (&db, 
3589                 ResCat (res_class, screen_name, (char *)FEEDBACK_FRAME_PART,
3590                         WmNtopShadowPixmap), _50_foreground);
3591
3592             /* use foreground color */
3593             value.addr = (XtPointer) &(spixset->fg);
3594
3595             XrmPutResource (&db,
3596                 ResCat (res_class, screen_name, (char *)FEEDBACK_FRAME_PART,
3597                         WmNtopShadowColor), XtRPixel, &value);
3598
3599             /* XmCO_BLACK_WHITE confirm box bottom shadow */
3600
3601             XrmPutStringResource (&db, 
3602                 ResCat (res_class, screen_name, (char *)FEEDBACK_FRAME_PART,
3603                         WmNbottomShadowPixmap), _75_foreground);
3604
3605             /* use foreground color */
3606             value.addr = (XtPointer) &(spixset->fg);
3607
3608             XrmPutResource (&db, 
3609                 ResCat (res_class, screen_name, (char *)FEEDBACK_FRAME_PART,
3610                         WmNbottomShadowColor), XtRPixel, &value);
3611
3612             /* use select color for icon box trough color */    
3613
3614             value.addr = (XtPointer) &(tpixset->sc);
3615
3616             XrmPutResource (&db,
3617                 ResCat (res_class, screen_name, (char *)CLIENT_FRAME_PART, 
3618                         XmNtroughColor), XtRPixel, &value);
3619
3620             /* use select color for arm and select colors in dialogs */ 
3621
3622             value.addr = (XtPointer) &(spixset->sc);
3623
3624             XrmPutResource (&db,
3625                 ResCat (res_class, screen_name, (char *)FEEDBACK_FRAME_PART, 
3626                         XmNarmColor), XtRPixel, &value);
3627
3628             XrmPutResource (&db,
3629                 ResCat (res_class, screen_name, (char *)FEEDBACK_FRAME_PART, 
3630                         XmNselectColor), XtRPixel, &value);
3631
3632             XrmPutResource (&db,
3633                 ResCat (res_class, screen_name, (char *)FEEDBACK_FRAME_PART, 
3634                         XmNtroughColor), XtRPixel, &value);
3635         }
3636         else /* inactive colors for non-BW systems */
3637         {
3638                 XmPixelSet     *fpixset;
3639
3640                 /*
3641                  * Set mwm component colors 
3642                  */
3643                 value.addr = (XtPointer) &(tpixset->bg);
3644                 XrmPutResource (&db,
3645                     ResCat (res_class, screen_name, (char *)CLIENT_FRAME_PART,
3646                             WmNbackground), XtRPixel, &value);
3647
3648                 XrmPutResource (&db,
3649                     ResCat (res_class, screen_name, (char *)ICON_FRAME_PART,
3650                             WmNbackground), XtRPixel, &value);
3651
3652                 XrmPutResource (&db, 
3653                     ResCat (res_class, screen_name, (char *)MENU_ITEM_PART,
3654                             WmNbackground), XtRPixel, &value);
3655
3656                 value.addr = (XtPointer) &(spixset->bg);
3657                 XrmPutResource (&db, 
3658                     ResCat (res_class, screen_name, (char *)FEEDBACK_FRAME_PART,
3659                             WmNbackground), XtRPixel, &value);
3660
3661                 value.addr = (XtPointer) &(tpixset->ts);
3662                 XrmPutResource (&db,
3663                     ResCat (res_class, screen_name, (char *)CLIENT_FRAME_PART,
3664                             WmNtopShadowColor), XtRPixel, &value);
3665
3666                 XrmPutResource (&db,
3667                     ResCat (res_class, screen_name, (char *)ICON_FRAME_PART,
3668                             WmNtopShadowColor), XtRPixel, &value);
3669
3670                 XrmPutResource (&db, 
3671                     ResCat (res_class, screen_name, (char *)MENU_ITEM_PART,
3672                             WmNtopShadowColor), XtRPixel, &value);
3673
3674                 value.addr = (XtPointer) &(spixset->ts);
3675                 XrmPutResource (&db, 
3676                     ResCat (res_class, screen_name, (char *)FEEDBACK_FRAME_PART,
3677                             WmNtopShadowColor), XtRPixel, &value);
3678
3679                 value.addr = (XtPointer) &(tpixset->bs);
3680                 XrmPutResource (&db,
3681                     ResCat (res_class, screen_name, (char *)CLIENT_FRAME_PART,
3682                             WmNbottomShadowColor), XtRPixel, &value);
3683
3684                 XrmPutResource (&db,
3685                     ResCat (res_class, screen_name, (char *)ICON_FRAME_PART,
3686                             WmNbottomShadowColor), XtRPixel, &value);
3687
3688                 XrmPutResource (&db, 
3689                     ResCat (res_class, screen_name, (char *)MENU_ITEM_PART,
3690                             WmNbottomShadowColor), XtRPixel, &value);
3691
3692                 value.addr = (XtPointer) &(spixset->bs);
3693                 XrmPutResource (&db, 
3694                     ResCat (res_class, screen_name, (char *)FEEDBACK_FRAME_PART,
3695                             WmNbottomShadowColor), XtRPixel, &value);
3696
3697                 value.addr = (XtPointer) &(tpixset->fg);
3698                 XrmPutResource (&db,
3699                     ResCat (res_class, screen_name, (char *)CLIENT_FRAME_PART,
3700                             WmNforeground), XtRPixel, &value);
3701
3702                 XrmPutResource (&db,
3703                     ResCat (res_class, screen_name, (char *)ICON_FRAME_PART,
3704                             WmNforeground), XtRPixel, &value);
3705
3706                 XrmPutResource (&db, 
3707                     ResCat (res_class, screen_name, (char *)MENU_ITEM_PART,
3708                             WmNforeground), XtRPixel, &value);
3709
3710                 value.addr = (XtPointer) &(spixset->fg);
3711                 XrmPutResource (&db, 
3712                     ResCat (res_class, screen_name, (char *)FEEDBACK_FRAME_PART,
3713                             WmNforeground), XtRPixel, &value);
3714
3715                 /*
3716                  * Set select color only for menus and feedback mwm
3717                  * parts. Client and Icon parts aren't real widgets.
3718                  * Set client trough color for icon box.
3719                  */
3720                 value.addr = (XtPointer) &(tpixset->sc);
3721                 XrmPutResource (&db,
3722                    ResCat (res_class, screen_name, (char *)MENU_ITEM_PART, 
3723                             XmNselectColor), XtRPixel, &value);
3724          
3725                 XrmPutResource (&db,
3726                    ResCat (res_class, screen_name, (char *)MENU_ITEM_PART, 
3727                             XmNarmColor), XtRPixel, &value);
3728
3729                 XrmPutResource (&db,
3730                    ResCat (res_class, screen_name, (char *)MENU_ITEM_PART, 
3731                             XmNtroughColor), XtRPixel, &value);
3732
3733                 XrmPutResource (&db,
3734                    ResCat (res_class, screen_name, (char *)CLIENT_FRAME_PART, 
3735                             XmNtroughColor), XtRPixel, &value);
3736
3737                 XrmPutResource (&db,
3738                    ResCat (res_class, screen_name, (char *)FEEDBACK_FRAME_PART, 
3739                             XmNselectColor), XtRPixel, &value);
3740          
3741                 value.addr = (XtPointer) &(spixset->sc);
3742                 XrmPutResource (&db,
3743                    ResCat (res_class, screen_name, (char *)FEEDBACK_FRAME_PART, 
3744                             XmNarmColor), XtRPixel, &value);
3745
3746                 XrmPutResource (&db,
3747                    ResCat (res_class, screen_name, (char *)FEEDBACK_FRAME_PART, 
3748                             XmNtroughColor), XtRPixel, &value);
3749
3750                 /*
3751                  * Set Dtwm dialog colors
3752                  */
3753                 fpixset = pSD->pSecondaryPixelSet;
3754
3755                 value.addr = (XtPointer) &(fpixset->bg);
3756                 XrmPutResource (&db, 
3757                     ResCat (res_class, screen_name, XmNbackground, NULL),
3758                     XtRPixel, &value);
3759
3760                 value.addr = (XtPointer) &(fpixset->fg);
3761                 XrmPutResource (&db,
3762                     ResCat (res_class, screen_name, XmNforeground, NULL),
3763                     XtRPixel, &value);
3764
3765                 value.addr = (XtPointer) &(fpixset->ts);
3766                 XrmPutResource (&db, 
3767                     ResCat (res_class, screen_name, XmNtopShadowColor, NULL),
3768                     XtRPixel, &value);
3769
3770                 value.addr = (XtPointer) &(fpixset->bs);
3771                 XrmPutResource (&db, 
3772                     ResCat (res_class, screen_name, XmNbottomShadowColor, NULL),
3773                     XtRPixel, &value);
3774
3775                 /*
3776                  *
3777                  *  Set up the select color, as for buttons in the dialogue
3778                  *  boxes.
3779                  *
3780                  */
3781                  value.addr = (XtPointer) &(fpixset->sc);
3782                  XrmPutResource (&db,
3783                     ResCat (res_class, screen_name, XmNselectColor, NULL),
3784                         XtRPixel, &value);
3785          
3786                  /* value.addr = (XtPointer) &(fpixset->sc); */
3787                  XrmPutResource (&db,
3788                     ResCat (res_class, screen_name, XmNarmColor, NULL),
3789                         XtRPixel, &value);
3790
3791                  /* value.addr = (XtPointer) &(fpixset->sc); */
3792                  XrmPutResource (&db,
3793                     ResCat (res_class, screen_name, XmNtroughColor, NULL),
3794                         XtRPixel, &value);
3795
3796                 if (XmCO_DitherTopShadow(DISPLAY, thisScreen, fpixset)) 
3797                 {
3798                     XrmPutStringResource (&db, 
3799                         ResCat (res_class, screen_name, WmNtopShadowPixmap, NULL),
3800                         _Dither);
3801
3802                     if (pSD->colorUse == XmCO_BLACK_WHITE)
3803                     {
3804                         XrmPutStringResource (&db, 
3805                             ResCat (res_class, screen_name, 
3806                                 WmNbottomShadowPixmap, NULL),
3807                             _NoDither);
3808
3809                     }
3810                 }
3811
3812                 if (XmCO_DitherBottomShadow(DISPLAY, thisScreen, fpixset)) 
3813                 {
3814                     XrmPutStringResource (&db, 
3815                         ResCat (res_class, screen_name, WmNbottomShadowPixmap, NULL),
3816                         _Dither);
3817
3818                     if (pSD->colorUse == XmCO_BLACK_WHITE)
3819                     {
3820                         XrmPutStringResource (&db, 
3821                             ResCat (res_class, screen_name, 
3822                                 WmNtopShadowPixmap, NULL),
3823                             _NoDither);
3824
3825                     }
3826                 }
3827
3828                 if (tpixset->bs != tpixset->ts)
3829                 /*
3830                  *
3831                  *   If the inactive bottomshadow and topshadow are
3832                  *   different (i.e., valid), then make the icon image
3833                  *   use those colors.
3834                  */
3835                 {
3836                     value.addr = (XtPointer) &(tpixset->bs);
3837
3838                     XrmPutResource (&db, 
3839                         ResCat (res_class, screen_name, WmNiconImageForeground,
3840                                 NULL), XtRPixel, &value);
3841
3842                     value.addr = (XtPointer) &(tpixset->ts);
3843
3844                     XrmPutResource (&db, 
3845                         ResCat (res_class, screen_name, WmNiconImageBackground,
3846                                 NULL), XtRPixel, &value);
3847
3848                     value.addr = (XtPointer) &(tpixset->bs);
3849
3850                     XrmPutResource (&db, 
3851                         ResCat (res_class, screen_name, 
3852                                 WmNiconImageBottomShadowColor,
3853                                 NULL), XtRPixel, &value);
3854
3855                     value.addr = (XtPointer) &(tpixset->ts);
3856
3857                     XrmPutResource (&db, 
3858                         ResCat (res_class, screen_name, 
3859                                 WmNiconImageTopShadowColor,
3860                                 NULL), XtRPixel, &value);
3861                 }
3862                 else
3863                 /*
3864                  *
3865                  *  Ensure that the icon images have a black foreground and
3866                  *  a white background.
3867                  *
3868                  */
3869                 {
3870                     value.addr = (XtPointer) &(BlackPixel(DISPLAY, pSD->screen));
3871
3872                     XrmPutResource (&db, 
3873                         ResCat (res_class, screen_name, WmNiconImageForeground,
3874                                 NULL), XtRPixel, &value);
3875
3876                     value.addr = (XtPointer) &(WhitePixel(DISPLAY, pSD->screen));
3877
3878                     XrmPutResource (&db, 
3879                         ResCat (res_class, screen_name, WmNiconImageBackground,
3880                                 NULL), XtRPixel, &value);
3881                 }
3882         }
3883     }
3884
3885
3886     if (pSD->pTextPixelSet)
3887     {
3888        value.addr = (XtPointer) &(pSD->pTextPixelSet->bg);
3889
3890        XrmPutResource (&db,
3891           ResCat (res_class, screen_name, "XmTextField",
3892                   WmNbackground), XtRPixel, &value);
3893
3894        XrmPutResource (&db,
3895           ResCat (res_class, screen_name, "XmText",
3896                   WmNbackground), XtRPixel, &value);
3897     }
3898 }
3899
3900 \f
3901 /******************************<->*************************************
3902  *
3903  *  ResCat (s1,s2,s3,s4)
3904  *
3905  *
3906  *  Description:
3907  *  -----------
3908  *  Cats up to four strings together with '*' in between.
3909  *
3910  *
3911  *  Inputs:
3912  *  ------
3913  *  s1...s4 = pointers to Strings or NULL pointers (no string)
3914  * 
3915  *  Outputs:
3916  *  -------
3917  *  Return = pointer to statically allocated string that has 
3918  *           the passed in string cat'ed together with '*'s 
3919  *           in between.
3920  *
3921  *  Comments:
3922  *  --------
3923  *  Does no limit checking on the static buffer 
3924  * 
3925  *************************************<->***********************************/
3926
3927 String
3928 ResCat (String s1, String s2, String s3, String s4)
3929 {
3930
3931
3932     int count;
3933
3934     Boolean useResourceClass = True;
3935
3936     wmGD.tmpBuffer[0] = '\0';
3937
3938     count = MAXBUF - 1;
3939
3940     if (s1)
3941     {
3942         if ((MwmBehavior) &&
3943             !strcmp (s1, WM_RESOURCE_CLASS))
3944         /*
3945          *
3946          *  if this routine is called with a class name
3947          *  ("Mwm" or "Dtwm"), then DON'T use it.
3948          *  We want our resources to be written out
3949          *  as:  *iconImageForeground:   <pixel_val>
3950          *
3951          *  as opposed to:  Dtwm*iconImageForeground:   <pixel_val>
3952          *
3953          */
3954         {
3955                 useResourceClass = False;
3956         }
3957         else if (!strcmp (s1, DT_WM_RESOURCE_CLASS))
3958         {
3959                 useResourceClass = False;
3960         }
3961         else
3962         {
3963             strncat((char *)wmGD.tmpBuffer, s1, count);
3964             count -= strlen(s1);
3965         }
3966
3967         if (s2 && (count > 0))
3968         {
3969             strncat ((char *)wmGD.tmpBuffer, "*", count);
3970             count -= 1;
3971             strncat ((char *)wmGD.tmpBuffer, s2, count);
3972             count -= strlen (s2);
3973
3974             if (s3 && (count > 0))
3975             {
3976                 strncat ((char *)wmGD.tmpBuffer, "*", count);
3977                 count -= 1;
3978                 strncat ((char *)wmGD.tmpBuffer, s3, count);
3979                 count -= strlen (s3);
3980
3981                 if (s4)
3982                 {
3983                     strncat ((char *)wmGD.tmpBuffer, "*", count);
3984                     count -= 1;
3985                     strncat ((char *)wmGD.tmpBuffer, s4, count);
3986                 }
3987             }
3988         }
3989     }
3990     return ((String) wmGD.tmpBuffer);
3991
3992 } /* END OF FUNCTION ResCat */
3993
3994
3995 \f
3996 /******************************<->*************************************
3997  *
3998  *  CheckForNoDither (pAD)
3999  *
4000  *
4001  *  Description:
4002  *  -----------
4003  *  Checks for reserved string as pixmap name of dither that indicates
4004  *  no dithering and replaces the string with a NULL.
4005  *
4006  *
4007  *  Inputs:
4008  *  ------
4009  *  pAD   = pointer to appearance data
4010  * 
4011  *  Outputs:
4012  *  -------
4013  *  pAD   = pointer to appearance data (may be modified)
4014  *
4015  *  Comments:
4016  *  ---------
4017  *  This check is done to avoid repeated calls to XmGetPixmap when
4018  *  managing windows. XmGetPixmap doesn't cache failures, and the
4019  *  NoDither string should fail every time. We want to prevent 
4020  *  XmGetPixmap from call XtResolvePathName to rummage through
4021  *  the file system.
4022  *
4023  *************************************<->***********************************/
4024
4025 void 
4026 CheckForNoDither (AppearanceData *pAD)
4027 {
4028     if (pAD->backgroundPStr && 
4029         !strcmp(pAD->backgroundPStr, _NoDither))
4030     {
4031         pAD->backgroundPStr = NULL;
4032     }
4033     if (pAD->bottomShadowPStr && 
4034         !strcmp(pAD->bottomShadowPStr, _NoDither))
4035     {
4036         pAD->bottomShadowPStr = NULL;
4037     }
4038     if (pAD->topShadowPStr && 
4039         !strcmp(pAD->topShadowPStr, _NoDither))
4040     {
4041         pAD->topShadowPStr = NULL;
4042     }
4043     if (pAD->activeBackgroundPStr && 
4044         !strcmp(pAD->activeBackgroundPStr, _NoDither))
4045     {
4046         pAD->activeBackgroundPStr = NULL;
4047     }
4048     if (pAD->activeBottomShadowPStr && 
4049         !strcmp(pAD->activeBottomShadowPStr, _NoDither))
4050     {
4051         pAD->activeBottomShadowPStr = NULL;
4052     }
4053     if (pAD->activeTopShadowPStr &&
4054         !strcmp(pAD->activeTopShadowPStr, _NoDither))
4055     {
4056         pAD->activeTopShadowPStr = NULL;
4057     }
4058
4059 } /* END OF FUNCTION CheckForNoDither */
4060
4061
4062
4063 \f
4064 /******************************<->*************************************
4065  *
4066  *  ProcessAppearanceResources (pSD)
4067  *
4068  *
4069  *  Description:
4070  *  -----------
4071  *  Retrieve and process the general appearance resources for the mwm
4072  *  subparts: "client", "icon", and "feedback"
4073  *
4074  *
4075  *  Inputs:
4076  *  ------
4077  *  pSD   = pointer to screen data
4078  * 
4079  *  Outputs:
4080  *  -------
4081  *  modifies parts of global data wmGD.
4082  *
4083  *  Comments:
4084  *  --------
4085  *  o Changeable GCs are created with XCreateGC. The base GCs used for
4086  *    text output will have clip_masks defined for them later.
4087  *  
4088  * 
4089  *************************************<->***********************************/
4090
4091 void 
4092 ProcessAppearanceResources (WmScreenData *pSD)
4093 {
4094     Widget clientW;             /* dummy widget for resource fetching */
4095     int i;
4096     Arg args[10];
4097
4098
4099     /*
4100      * Get the client subpart resources:
4101      */
4102
4103     /* save info in static globals for dynamic default processing */
4104     _defaultBackground = _defaultColor1;
4105     _defaultActiveBackground = _defaultColor2;
4106     _pAppearanceData = &(pSD->clientAppearance);
4107
4108     (void)XtGetSubresources (pSD->screenTopLevelW, 
4109               (XtPointer) &(pSD->clientAppearance),
4110               WmNclient, WmCClient, wmAppearanceResources, 
4111               XtNumber (wmAppearanceResources), NULL, 0);
4112     CheckForNoDither (&(pSD->clientAppearance));
4113
4114
4115     /*
4116      * Process the client resource values:
4117      */
4118
4119     /* make background, top and bottom shadow pixmaps */
4120
4121     MakeAppearanceResources (pSD, &(pSD->clientAppearance), True);
4122
4123
4124     /*
4125      * Get the client.title subpart resources:
4126      */
4127
4128         /* insert "client" widget in hierarchy */
4129
4130     i = 0;
4131     clientW = XtCreateWidget (WmNclient, xmRowColumnWidgetClass, 
4132                         pSD->screenTopLevelW, (ArgList) args, i);
4133
4134
4135         /* fetch "client.title" subpart appearance resources */
4136
4137     _pAppearanceData = &(pSD->clientTitleAppearance);
4138
4139     (void)XtGetSubresources (clientW, (XtPointer) &(pSD->clientTitleAppearance),
4140               WmNtitle, WmCTitle, wmAppearanceResources, 
4141               XtNumber (wmAppearanceResources), NULL, 0);
4142     CheckForNoDither (&(pSD->clientTitleAppearance));
4143
4144
4145     /*
4146      * Process the client.title resource values:
4147      */
4148
4149
4150     /* 
4151      * check if client title appearance is different from the rest of frame.
4152      */
4153     if (SimilarAppearanceData (&(pSD->clientAppearance), 
4154                                &(pSD->clientTitleAppearance)))
4155     {
4156         /* title bar doesn't need special graphic processing */
4157         pSD->decoupleTitleAppearance = False;
4158     }
4159     else 
4160     {
4161         /* make background, top and bottom shadow pixmaps */
4162         MakeAppearanceResources (pSD, &(pSD->clientTitleAppearance), True);
4163         pSD->decoupleTitleAppearance = True;
4164     }
4165
4166     XtDestroyWidget (clientW);  /* all done with dummy widget */
4167
4168
4169     /*
4170      * Get the icon subpart resources:
4171      */
4172
4173     _pAppearanceData = &(pSD->iconAppearance);
4174
4175     (void)XtGetSubresources (pSD->screenTopLevelW, 
4176               (XtPointer) &(pSD->iconAppearance),
4177               WmNicon, WmCIcon, wmAppearanceResources, 
4178               XtNumber (wmAppearanceResources), NULL, 0);
4179     CheckForNoDither (&(pSD->iconAppearance));
4180
4181
4182     /*
4183      * Process the icon resource values:
4184      */
4185
4186     /* make background, top and bottom shadow pixmaps */
4187
4188     MakeAppearanceResources (pSD, &(pSD->iconAppearance), True);
4189
4190
4191     /*
4192      * Get the feedback subpart resources:
4193      * !!! only get "inactive" resources !!!
4194      */
4195
4196     _defaultBackground = _defaultColor2;
4197     _defaultActiveBackground = _defaultColor2;
4198     _pAppearanceData = &(pSD->feedbackAppearance);
4199
4200     (void)XtGetSubresources (pSD->screenTopLevelW, 
4201               (XtPointer) &(pSD->feedbackAppearance),
4202               WmNfeedback, WmCFeedback, wmAppearanceResources, 
4203               XtNumber (wmAppearanceResources), NULL, 0);
4204     CheckForNoDither (&(pSD->feedbackAppearance));
4205
4206     /*
4207      * Process the feedback resource values:
4208      */
4209
4210     /* make background, top and bottom shadow pixmaps */
4211
4212     MakeAppearanceResources (pSD, &(pSD->feedbackAppearance), False);
4213
4214
4215 } /* END OF FUNCTION ProcessAppearanceResources */
4216
4217
4218 \f
4219 /*************************************<->*************************************
4220  *
4221  *  FallbackMakeTitleHeight (pAData)
4222  *
4223  *
4224  *  Description:
4225  *  -----------
4226  *  This function makes title hight for AppearanceData
4227  *  (using XExtentsOfFontSet on pAData->fontList)
4228  *
4229  *  Inputs:
4230  *  ------
4231  *
4232  *  pAData = pointer to appearance data structure containing resource info
4233  *
4234  *
4235  *  Outputs:
4236  *  -------
4237  *  *pAData - pAData->titleHeight is updated
4238  *  return = 1 on success, 0 on failure (pAData->titleHeight is intact)
4239  *
4240  *************************************<->***********************************/
4241
4242 int
4243 FallbackMakeTitleHeight (AppearanceData *pAData) {
4244   XmFontContext       fc;
4245   XmFontType          type;
4246   XmFontListEntry     entry;
4247   XtPointer           pFont;
4248   XFontSetExtents     *pExtents;
4249   int                 result = 0;
4250
4251   XmFontListInitFontContext ( &fc, pAData->fontList);
4252   pAData->titleHeight = 0;
4253   entry = XmFontListNextEntry (fc);
4254   while (entry)
4255   {
4256     pFont = XmFontListEntryGetFont (entry, &type);
4257     switch (type)
4258     {
4259     case XmFONT_IS_FONT:
4260       /* does not really happen since XmeRenderTableGetDefaultFont
4261          seems to fail only on fontsets */
4262       break;
4263     case XmFONT_IS_FONTSET:
4264       if (!(pExtents = XExtentsOfFontSet ((XFontSet) pFont))) {
4265         break;
4266       }
4267       if (WM_TITLE_BAR_PADDING + pExtents->max_logical_extent.height > pAData->titleHeight) {
4268         pAData->titleHeight = WM_TITLE_BAR_PADDING + pExtents->max_logical_extent.height;
4269         result = 1;
4270       }
4271       break;
4272     default:
4273       break;
4274     }
4275     entry = XmFontListNextEntry (fc);
4276   }
4277   XmFontListFreeFontContext (fc);
4278   return result;
4279 }
4280
4281 \f
4282 /*************************************<->*************************************
4283  *
4284  *  MakeAppearanceResources (pSD, pAData, makeActiveResources)
4285  *
4286  *
4287  *  Description:
4288  *  -----------
4289  *  This function makes top, bottom and background pixmaps for a window
4290  *  manager component.  Inactive and active (if specified) GC's are
4291  *  also made.
4292  *
4293  *
4294  *  Inputs:
4295  *  ------
4296  *  pSD = pointer to screen data
4297  *
4298  *  pAData = pointer to appearance data structure containing resource info
4299  *
4300  *  makeActiveResources = if True then make active resources
4301  * 
4302  *  Outputs:
4303  *  -------
4304  *  *pAData = pixmap and GC fields filled out
4305  *
4306  *************************************<->***********************************/
4307
4308 void 
4309 MakeAppearanceResources (WmScreenData *pSD, AppearanceData *pAData, Boolean makeActiveResources)
4310 {
4311     Pixel foreground;
4312
4313     /*
4314      * Extract a font from the font list.
4315      */
4316
4317     if (! XmeRenderTableGetDefaultFont(pAData->fontList, &(pAData->font)))
4318     {
4319 #if 0
4320         /* This always prints garbage on failure, which seems to
4321          * always happen at least 1-3 times on startup.
4322          */
4323         sprintf((char *)wmGD.tmpBuffer,
4324                 ((char *)GETMESSAGE(62, 23, "failed to load font: %.100s\0")), (char*) pAData->fontList);
4325 #endif
4326         Warning("XmeRenderTableGetDefaultFont() failed, trying a fixed font");
4327
4328 #if defined(CSRG_BASED) || defined(__linux__)
4329         /* HACK to try get _some_ font anyway (fontList seems to end
4330          * up as an empty list on some modern systems; investigate) */
4331         pAData->font = XLoadQueryFont(wmGD.display, "fixed");
4332         if (pAData->font == NULL)
4333         {
4334           ExitWM(WM_ERROR_EXIT_VALUE);
4335         }
4336         /* try to get right title hight using XExtentsOfFontSet: on UTF-8
4337          * locales XmeRenderTableGetDefaultFont does not return anything
4338          * when font is a compound fontset*/
4339         if (!FallbackMakeTitleHeight(pAData))
4340         {
4341           /* failed to get height from fontList - falling back to fixed */
4342           pAData->titleHeight = (pAData->font)->ascent + (pAData->font)->descent
4343             + WM_TITLE_BAR_PADDING;
4344         }
4345 #else
4346         ExitWM(WM_ERROR_EXIT_VALUE);
4347 #endif
4348     } else {
4349         /* got default font successfully, hack was not needed */
4350         /*
4351          *  Calculate title bar's height (using selected font) and store it in pAData.
4352          */
4353         pAData->titleHeight = (pAData->font)->ascent + (pAData->font)->descent
4354         + WM_TITLE_BAR_PADDING;
4355     }
4356
4357
4358
4359     /*
4360      * Make standard (inactive) appearance resources.
4361      */
4362
4363     /* background pixmap */
4364
4365     if (pAData->backgroundPStr)
4366     {
4367         pAData->backgroundPixmap = XmGetPixmap (
4368                                        ScreenOfDisplay (DISPLAY, 
4369                                            pSD->screen),
4370                                        pAData->backgroundPStr,
4371                                        pAData->foreground,
4372                                        pAData->background);
4373
4374         if (pAData->backgroundPixmap == XmUNSPECIFIED_PIXMAP)
4375         {
4376             pAData->backgroundPixmap = (Pixmap)NULL;
4377         }
4378     }
4379     else
4380     {
4381         pAData->backgroundPixmap = (Pixmap)NULL;
4382     }
4383
4384     /* top shadow pixmap */
4385
4386     if (pAData->topShadowPStr)
4387     {
4388         /*
4389          * Make sure top shadow color is not the same as background
4390          * otherwise the wrong pixmap will be generated.
4391          */
4392         if (pAData->topShadowColor != pAData->background)
4393             foreground = pAData->topShadowColor;
4394         else
4395             foreground = pAData->foreground;
4396         pAData->topShadowPixmap = XmGetPixmap (
4397                                        ScreenOfDisplay (DISPLAY,
4398                                            pSD->screen),
4399                                        pAData->topShadowPStr,
4400                                        foreground,
4401                                        pAData->background);
4402
4403         if (pAData->topShadowPixmap == XmUNSPECIFIED_PIXMAP)
4404         {
4405             pAData->topShadowPixmap = (Pixmap)NULL;
4406         }
4407     }
4408     else
4409     {
4410         pAData->topShadowPixmap = (Pixmap)NULL;
4411     }
4412
4413
4414     /* bottom shadow pixmap */
4415
4416     if (pAData->bottomShadowPStr)
4417     {
4418         /*
4419          * Make sure bottom shadow color is not the same as background
4420          * otherwise the wrong pixmap will be generated.
4421          */
4422         if (pAData->bottomShadowColor != pAData->background)
4423             foreground = pAData->bottomShadowColor;
4424         else
4425             foreground = pAData->foreground;
4426         pAData->bottomShadowPixmap = XmGetPixmap (
4427                                        ScreenOfDisplay (DISPLAY,
4428                                            pSD->screen),
4429                                        pAData->bottomShadowPStr,
4430                                        foreground,
4431                                        pAData->background);
4432
4433         if (pAData->bottomShadowPixmap == XmUNSPECIFIED_PIXMAP)
4434         {
4435             pAData->bottomShadowPixmap = (Pixmap)NULL;
4436         }
4437     }
4438     else
4439     {
4440         pAData->bottomShadowPixmap = (Pixmap)NULL;
4441     }
4442
4443     /* inactive appearance GC */
4444
4445     GetAppearanceGCs (pSD,
4446                       pAData->foreground,
4447                       pAData->background,
4448                       pAData->font,
4449                       pAData->backgroundPixmap,
4450                       pAData->topShadowColor,
4451                       pAData->topShadowPixmap,
4452                       pAData->bottomShadowColor,
4453                       pAData->bottomShadowPixmap,
4454                       &(pAData->inactiveGC),
4455                       &(pAData->inactiveTopShadowGC),
4456                       &(pAData->inactiveBottomShadowGC));
4457
4458
4459
4460     /*
4461      * Make active apppearance resources if specified.
4462      */
4463
4464     if (!makeActiveResources)
4465     {
4466         return;
4467     }
4468
4469     /* active background pixmap */
4470
4471     if (pAData->activeBackgroundPStr)
4472     {
4473         pAData->activeBackgroundPixmap = XmGetPixmap (
4474                                              ScreenOfDisplay (DISPLAY,
4475                                                  pSD->screen),
4476                                              pAData->activeBackgroundPStr,
4477                                              pAData->activeForeground,
4478                                              pAData->activeBackground);
4479
4480         if (pAData->activeBackgroundPixmap == XmUNSPECIFIED_PIXMAP)
4481         {
4482             pAData->activeBackgroundPixmap = (Pixmap)NULL;
4483         }
4484     }
4485     else
4486     {
4487         pAData->activeBackgroundPixmap = (Pixmap)NULL;
4488     }
4489
4490     /* active top shadow pixmap */
4491
4492     if (pAData->activeTopShadowPStr)
4493     {
4494         pAData->activeTopShadowPixmap = XmGetPixmap (
4495                                             ScreenOfDisplay (DISPLAY,
4496                                                 pSD->screen),
4497                                             pAData->activeTopShadowPStr,
4498                                             pAData->activeTopShadowColor,
4499                                             pAData->activeBackground);
4500
4501         if (pAData->activeTopShadowPixmap == XmUNSPECIFIED_PIXMAP)
4502         {
4503             pAData->activeTopShadowPixmap = (Pixmap)NULL;
4504         }
4505     }
4506     else
4507     {
4508         pAData->activeTopShadowPixmap = (Pixmap)NULL;
4509     }
4510
4511
4512     /* active bottom shadow pixmap */
4513
4514     if (pAData->activeBottomShadowPStr)
4515     {
4516         pAData->activeBottomShadowPixmap = XmGetPixmap (
4517                                                ScreenOfDisplay (DISPLAY,
4518                                                    pSD->screen),
4519                                                pAData->activeBottomShadowPStr,
4520                                                pAData->activeBottomShadowColor,
4521                                                pAData->activeBackground);
4522
4523         if (pAData->activeBottomShadowPixmap == XmUNSPECIFIED_PIXMAP)
4524         {
4525             pAData->activeBottomShadowPixmap = (Pixmap)NULL;
4526         }
4527     }
4528     else
4529     {
4530         pAData->activeBottomShadowPixmap = (Pixmap)NULL;
4531     }
4532
4533     /* inactive appearance GC */
4534
4535     GetAppearanceGCs (pSD,
4536                       pAData->activeForeground,
4537                       pAData->activeBackground,
4538                       pAData->font,
4539                       pAData->activeBackgroundPixmap,
4540                       pAData->activeTopShadowColor,
4541                       pAData->activeTopShadowPixmap,
4542                       pAData->activeBottomShadowColor,
4543                       pAData->activeBottomShadowPixmap,
4544                       &(pAData->activeGC),
4545                       &(pAData->activeTopShadowGC),
4546                       &(pAData->activeBottomShadowGC));
4547
4548
4549 } /* END OF FUNCTION MakeAppearanceResources */
4550
4551
4552 \f
4553 /*************************************<->*************************************
4554  *
4555  *  GetAppearanceGCs (pSD, fg, bg, font, bg_pixmap, ts_color, 
4556  *                    ts_pixmap, bs_color, bs_pixmap, pGC, ptsGC, pbsGC)
4557  *
4558  *
4559  *  Description:
4560  *  -----------
4561  *  Creates the appearance GCs for any of the icon, client, or feedback 
4562  *  resources.
4563  *
4564  *
4565  *  Inputs:
4566  *  ------
4567  *  pSD         - pointer to screen data
4568  *  fg          - base foreground color
4569  *  bg          - base background color
4570  *  font        - font
4571  *  bg_pixmap   - background pixmap
4572  *  ts_color    - top shadow color
4573  *  ts_pixmap   - top shadow pixmap
4574  *  bs_color    - bottom shadow color
4575  *  bs_pixmap   - bottom shadow pixmap
4576  *  pGC         - pointer to location to receive base GC
4577  *  ptsGC       - pointer to location to receive top shadow GC
4578  *  pbsGC       - pointer to location to receive bottom shadow GC
4579  * 
4580  *  Outputs:
4581  *  -------
4582  *  *pGC        - base GC
4583  *  *ptsGC      - top shadow GC
4584  *  *pbsGC      - bottom shadow GC
4585  *  
4586  *
4587  *  Comments:
4588  *  --------
4589  * 
4590  * 
4591  *************************************<->***********************************/
4592
4593 void 
4594 GetAppearanceGCs (WmScreenData *pSD, Pixel fg, Pixel bg, XFontStruct *font, Pixmap bg_pixmap, Pixel ts_color, Pixmap ts_pixmap, Pixel bs_color, Pixmap bs_pixmap, GC *pGC, GC *ptsGC, GC *pbsGC)
4595 {
4596     XGCValues gcv;
4597     XtGCMask  mask;
4598
4599
4600     /*
4601      * Get base GC
4602      */
4603
4604     mask = GCForeground | GCBackground | GCFont;
4605     gcv.foreground = fg;
4606     gcv.background = bg;
4607     gcv.font = font->fid;
4608
4609     if (bg_pixmap)
4610     {
4611         mask |= GCTile;
4612         gcv.tile = bg_pixmap;
4613     }
4614
4615     *pGC = XCreateGC (DISPLAY, pSD->rootWindow, mask, &gcv);
4616
4617     /*
4618      * !!! Need GC error detection !!!
4619      */
4620
4621     *ptsGC = GetHighlightGC (pSD, ts_color, bg, ts_pixmap);
4622
4623     *pbsGC = GetHighlightGC (pSD, bs_color, bg, bs_pixmap);
4624
4625 } /* END OF FUNCTION GetAppearanceGCs */
4626
4627
4628
4629 \f
4630 /*************************************<->*************************************
4631  *
4632  *  ProcessScreenResources (pSD, screenName)
4633  *
4634  *
4635  *  Description:
4636  *  -----------
4637  *  This function retrieves resources that are screen specific.  If the
4638  *  window manager is providing standard behavior then retrieve the limited
4639  *  set of resources that don't affect standard behavior and set the
4640  *  values of the other resources to the standard values.
4641  *
4642  *
4643  *  Inputs:
4644  *  ------
4645  *  pSD = pointer to screen data
4646  *  screenName = name of screen
4647  *
4648  * 
4649  *  Outputs:
4650  *  -------
4651  *  pSD = resource data for screen is set
4652  *
4653  *
4654  *  Comments:
4655  *  --------
4656  *  o Gets subresources based on workspace name
4657  * 
4658  *************************************<->***********************************/
4659
4660 void 
4661 ProcessScreenResources (WmScreenData *pSD, unsigned char *screenName)
4662 {
4663     pResSD = pSD;       /* save current screen data for default processing */
4664     /*
4665      * Use the screen name (e.g., "0") as the default resource name.
4666      */
4667
4668     if (wmGD.useStandardBehavior)
4669     {
4670         XtGetSubresources (wmGD.topLevelW, (XtPointer) pSD, 
4671             (String) screenName, 
4672             (String) screenName,
4673             wmStdScreenResources, 
4674             XtNumber (wmStdScreenResources), NULL, 0);
4675
4676         /*
4677          * Fill in the standard resource values.
4678          */
4679
4680         SetStdScreenResourceValues (pSD);
4681     }
4682     else
4683     {
4684         XtGetSubresources (wmGD.topLevelW, (XtPointer) pSD, 
4685             (String)screenName, (String) screenName,
4686             wmScreenResources, 
4687             XtNumber (wmScreenResources), NULL, 0);
4688
4689         pSD->moveOpaque = (((XmScreen) XmGetXmScreen(XtScreen(pSD->screenTopLevelW)))
4690                            -> screen.moveOpaque);
4691     }
4692
4693
4694     /*
4695      * Do some additional processing on the window manager resource values.
4696      */
4697
4698
4699     if (pSD->iconImageMinimum.width < ICON_IMAGE_MIN_WIDTH)
4700     {
4701         pSD->iconImageMinimum.width = ICON_IMAGE_MIN_WIDTH;
4702     }
4703     else if (pSD->iconImageMinimum.width > ICON_IMAGE_MAX_WIDTH)
4704     {
4705         pSD->iconImageMinimum.width = ICON_IMAGE_MAX_WIDTH;
4706     }
4707
4708     if (pSD->iconImageMinimum.height < ICON_IMAGE_MIN_HEIGHT)
4709     {
4710         pSD->iconImageMinimum.height = ICON_IMAGE_MIN_HEIGHT;
4711     }
4712     else if (pSD->iconImageMinimum.height > ICON_IMAGE_MAX_HEIGHT)
4713     {
4714         pSD->iconImageMinimum.height = ICON_IMAGE_MAX_HEIGHT;
4715     }
4716
4717     if (pSD->iconImageMaximum.width < pSD->iconImageMinimum.width)
4718     {
4719         pSD->iconImageMaximum.width = pSD->iconImageMinimum.width;
4720     }
4721     else if (pSD->iconImageMaximum.width > ICON_IMAGE_MAX_WIDTH)
4722     {
4723         pSD->iconImageMaximum.width = ICON_IMAGE_MAX_WIDTH;
4724     }
4725
4726     if (pSD->iconImageMaximum.height < pSD->iconImageMinimum.height)
4727     {
4728         pSD->iconImageMaximum.height = pSD->iconImageMinimum.height;
4729     }
4730     else if (pSD->iconImageMaximum.height > ICON_IMAGE_MAX_HEIGHT)
4731     {
4732         pSD->iconImageMaximum.height = ICON_IMAGE_MAX_HEIGHT;
4733     }
4734
4735     if (pSD->iconPlacementMargin > MAXIMUM_ICON_MARGIN)
4736     {
4737         pSD->iconPlacementMargin = MAXIMUM_ICON_MARGIN;
4738     }
4739
4740     if (pSD->maximumMaximumSize.width <= 0)
4741     {
4742         pSD->maximumMaximumSize.width =
4743                         2 * DisplayWidth (DISPLAY, pSD->screen);
4744     }
4745
4746     if (pSD->maximumMaximumSize.height <= 0)
4747     {
4748         pSD->maximumMaximumSize.height =
4749                         2 * DisplayHeight (DISPLAY, pSD->screen);
4750     }
4751
4752     /*
4753      * Set the icon appearance default based on whether or not the icon box
4754      * is being used.
4755      */
4756
4757     if (pSD->iconDecoration & USE_ICON_DEFAULT_APPEARANCE)
4758     {
4759         if (pSD->useIconBox)
4760         {
4761             pSD->iconDecoration = ICON_APPEARANCE_ICONBOX;
4762         }
4763         else
4764         {
4765             pSD->iconDecoration = ICON_APPEARANCE_STANDALONE;
4766         }
4767     }
4768
4769     /*
4770      * If resizeBorderWidth or frameBorderWidth is unset then initialize
4771      * to dynamic defaults.
4772      */
4773
4774     if ((pSD->resizeBorderWidth == (Dimension)BIGSIZE) ||
4775         (pSD->frameBorderWidth == (Dimension)BIGSIZE))
4776     {
4777         double xres, yres, avg_res;
4778
4779         xres = (((double) DisplayWidth(DISPLAY, pSD->screen)) / 
4780                 ((double) DisplayWidthMM(DISPLAY, pSD->screen)));
4781         yres = (((double) DisplayHeight(DISPLAY, pSD->screen)) / 
4782                 ((double) DisplayHeightMM(DISPLAY, pSD->screen)));
4783
4784         avg_res = (xres + yres) / 2.0;
4785
4786         /* Multiply times width in mm (avg. 7-8 pixels) */
4787         if (pSD->resizeBorderWidth == (Dimension)BIGSIZE)
4788         {
4789             pSD->resizeBorderWidth = (int) (avg_res * 2.2);
4790
4791             /* limit size because big borders look ugly */
4792                 if (pSD->resizeBorderWidth > 6) pSD->resizeBorderWidth = 6;
4793         }
4794
4795         /* Multiply times width in mm (avg. 5-6 pixels) */
4796         if (pSD->frameBorderWidth == (Dimension)BIGSIZE)
4797         {
4798             pSD->frameBorderWidth = (int) (avg_res * 1.7);
4799
4800             /* limit size because big borders look ugly */
4801             if (wmGD.frameStyle == WmSLAB)
4802             {
4803                 if (pSD->frameBorderWidth > 4) pSD->frameBorderWidth = 4;
4804             }
4805             else
4806             {
4807                 if (pSD->frameBorderWidth > 5) pSD->frameBorderWidth = 5;
4808             }
4809         }
4810     }
4811
4812
4813     pSD->externalBevel = FRAME_EXTERNAL_SHADOW_WIDTH;
4814     pSD->joinBevel = FRAME_INTERNAL_SHADOW_WIDTH;
4815     if (pSD->frameBorderWidth < 
4816            (pSD->externalBevel + MIN_INTERNAL_BEVEL))
4817     {
4818         pSD->frameBorderWidth = 
4819             pSD->externalBevel + MIN_INTERNAL_BEVEL;
4820     }
4821     else if (pSD->frameBorderWidth > MAXIMUM_FRAME_BORDER_WIDTH)
4822     {
4823         pSD->frameBorderWidth = MAXIMUM_FRAME_BORDER_WIDTH;
4824     }
4825
4826     if (pSD->resizeBorderWidth < 
4827            (pSD->externalBevel + MIN_INTERNAL_BEVEL))
4828     {
4829         pSD->resizeBorderWidth = 
4830             (pSD->externalBevel + MIN_INTERNAL_BEVEL);
4831     }
4832     else if (pSD->resizeBorderWidth > MAXIMUM_FRAME_BORDER_WIDTH)
4833     {
4834         pSD->resizeBorderWidth = MAXIMUM_FRAME_BORDER_WIDTH;
4835     }
4836
4837     /*
4838      * Update the resource database.
4839      */
4840     WriteOutXrmColors (pSD);
4841
4842     /*
4843      * Process the component appearance resources for client, 
4844      * icon and feedback parts of mwm.
4845      */
4846
4847      ProcessAppearanceResources (pSD);
4848
4849     /* 
4850      * Process the workspace list and name the initial
4851      * workspaces
4852      */
4853
4854      ProcessWorkspaceList (pSD);
4855
4856      /*
4857       * Process default backdrop images to be used in low-color
4858       * situations
4859       */
4860      ProcessDefaultBackdropImages (pSD);
4861     
4862     /*
4863      * Save the default icon pixmap in global data. We'll use it only
4864      * as a last resort.
4865      */
4866
4867     pSD->builtinIconPixmap = 
4868         XCreateBitmapFromData (DISPLAY, pSD->rootWindow, (char *)iImage_bits, 
4869                                        iImage_width, iImage_height);
4870
4871 } /* END OF FUNCTION ProcessScreenResources */
4872
4873 /*************************************<->*************************************
4874  *
4875  *  ProcessDefaultBackdropImages (pSD)
4876  *
4877  *
4878  *  Description:
4879  *  -----------
4880  *  This function processes the default backdrop images to be used
4881  *  in low color or black and white workspaces.
4882  *
4883  *
4884  *  Inputs:
4885  *  ------
4886  *  pSD = pointer to screen data
4887  *
4888  * 
4889  *  Outputs:
4890  *  -------
4891  *  pSD = resource data for screen is set
4892  *
4893  *
4894  *  Comments:
4895  *  --------
4896  * 
4897  *************************************<->***********************************/
4898
4899 void 
4900 ProcessDefaultBackdropImages (WmScreenData *pSD)
4901 {
4902 } /* END OF FUNCTION ProcessDefaultBackdropImages */
4903
4904
4905 \f
4906 /*************************************<->*************************************
4907  *
4908  *  ProcessWorkspaceList (pSD)
4909  *
4910  *
4911  *  Description:
4912  *  -----------
4913  *  This function processes the workspaceCount and workspaceList 
4914  *  resources for a particular screen. It creates space for the initial 
4915  *  workspace data structures and adds in names for workspaces.
4916  *
4917  *
4918  *  Inputs:
4919  *  ------
4920  *  pSD = pointer to screen data
4921  *
4922  * 
4923  *  Outputs:
4924  *  -------
4925  *  pSD = resource data for screen is set
4926  *
4927  *
4928  *  Comments:
4929  *  --------
4930  *  NOTE: The workspaceCount resource has precedence over the
4931  *  workspaceList resource. workspaceCount determines the number of
4932  *  workspaces to create for the screen. Once the number is determined,
4933  *  workspaceList is used to fill in the "names." If workspaceList is
4934  *  not present or doesn't have enough names, then missing names are
4935  *  generated automatically. If workspaceList is present and
4936  *  workspaceCount is not present, then the workspaceCount is determined
4937  *  by the number of names in workspaceList.
4938  * 
4939  *************************************<->***********************************/
4940
4941 void 
4942 ProcessWorkspaceList (WmScreenData *pSD)
4943 {
4944     int i, wsNameCount, wsNamesAlloced;
4945     WmWorkspaceData *pwsI;
4946     unsigned char *lineP = NULL;
4947     unsigned char *string;
4948     Boolean bHaveWorkspaceList;
4949     Boolean bHaveWorkspaceCount;
4950     char **ppchWsNames = NULL;
4951
4952     /*
4953      * Validate initial resource settings
4954      */
4955     bHaveWorkspaceCount = (pSD->numWorkspaces >= 1);
4956     bHaveWorkspaceList = (pSD->workspaceList != NULL);
4957
4958     if (bHaveWorkspaceList)
4959     {
4960         /*
4961          * Parse out array of workspace names
4962          */
4963         wsNamesAlloced = WS_ALLOC_AMOUNT;
4964         ppchWsNames = (char **) XtMalloc (wsNamesAlloced * sizeof (char *));
4965         if (pSD->workspaceList)
4966         {
4967             lineP = (unsigned char *) pSD->workspaceList;
4968         }
4969         else
4970         {
4971             lineP = (unsigned char *)NULL;
4972         }
4973         wsNameCount = 0;
4974
4975         while (((string = GetString(&lineP)) != NULL))
4976         {
4977             ppchWsNames[wsNameCount] = (char *) string;
4978
4979             if (++wsNameCount >= wsNamesAlloced)
4980             {
4981                /*
4982                 *  Need to add more workspaces
4983                 */
4984                 wsNamesAlloced += WS_ALLOC_AMOUNT;
4985                 if (!(ppchWsNames = (char **) XtRealloc 
4986                           ((char *)ppchWsNames,
4987                             wsNamesAlloced * sizeof(char *))))
4988                 {
4989                     ExitWM (WM_ERROR_EXIT_VALUE);
4990                 }
4991             }
4992         }
4993
4994         if (!bHaveWorkspaceCount)
4995         {
4996             pSD->numWorkspaces = wsNameCount;
4997         }
4998     }
4999     else if (!bHaveWorkspaceCount)
5000     {
5001         /*
5002          * Neither workspaceCount nor workspaceList specified!!
5003          * Assume one workspace.
5004          */
5005         pSD->numWorkspaces = 1;
5006     }
5007
5008     if (pSD->numWorkspaces > MAX_WORKSPACE_COUNT)
5009             pSD->numWorkspaces = MAX_WORKSPACE_COUNT;
5010
5011     /*
5012      *  Allocate the array of workspace data
5013      */
5014     pSD->numWsDataAllocated = (pSD->numWorkspaces + WS_ALLOC_AMOUNT);
5015     pSD->numWsDataAllocated -= pSD->numWsDataAllocated % WS_ALLOC_AMOUNT;
5016     if (!(pSD->pWS = (WmWorkspaceData *) 
5017             XtMalloc (pSD->numWsDataAllocated * sizeof(WmWorkspaceData))))
5018     {
5019         ExitWM (WM_ERROR_EXIT_VALUE);
5020     }
5021
5022     pwsI = pSD->pWS;
5023
5024     for (i = 0; i < pSD->numWorkspaces; i++, pwsI++)
5025     {
5026         if (bHaveWorkspaceList && i < wsNameCount)
5027         {
5028             string = (unsigned char *) ppchWsNames[i];
5029         }
5030         else
5031         {
5032             string = GenerateWorkspaceName (pSD, i);
5033         }
5034         if (!(pwsI->name = (String) XtMalloc (1+strlen((char *)string))))
5035         {
5036             Warning (((char *)GETMESSAGE(62, 27, "Insufficient memory for workspace data")));
5037             ExitWM(WM_ERROR_EXIT_VALUE);
5038         }
5039         else 
5040         {
5041             strcpy(pwsI->name, (char *)string);
5042         }
5043     }
5044
5045     if (ppchWsNames) XtFree ((char *) ppchWsNames);
5046
5047 } /* END OF FUNCTION ProcessWorkspaceList */
5048
5049
5050 \f
5051 /******************************<->*************************************
5052  *
5053  *  ProcessWorkspaceResources (pWS)
5054  *
5055  *
5056  *  Description:
5057  *  -----------
5058  *  This function retrieves resources that are workspace specific.  If the
5059  *  window manager is providing standard behavior then retrieve the limited
5060  *  set of resources that don't affect standard behavior and set the
5061  *  values of the other resources to the standard values.
5062  *
5063  *
5064  *  Inputs:
5065  *  ------
5066  *  pWS = pointer to workspace data
5067  *
5068  * 
5069  *  Outputs:
5070  *  -------
5071  *  pWS = resource data for workspace is set
5072  *
5073  *
5074  *  Comments:
5075  *  --------
5076  *  o Gets subresources based on workspace name
5077  * 
5078  ******************************<->***********************************/
5079
5080 void 
5081 ProcessWorkspaceResources (WmWorkspaceData *pWS)
5082 {
5083
5084     /*
5085      * Retrieve workspace specific resources.
5086      */
5087     pResWS = pWS;       /* save current ws for default processing */
5088
5089     if (wmGD.useStandardBehavior)
5090     {
5091         XtGetSubresources (pWS->pSD->screenTopLevelW, (XtPointer) pWS, 
5092             pWS->name, pWS->name, wmStdWorkspaceResources, 
5093             XtNumber (wmStdWorkspaceResources), NULL, 0);
5094
5095         /*
5096          * Fill in the standard resource values.
5097          *
5098          * (no code for this right now)
5099          */
5100         pWS->iconBoxGeometry = NULL;
5101     }
5102     else
5103     {
5104         XtGetSubresources (pWS->pSD->screenTopLevelW, (XtPointer) pWS, 
5105             pWS->name, pWS->name, wmWorkspaceResources, 
5106             XtNumber (wmWorkspaceResources), NULL, 0);
5107
5108         /*  Dup iconbox geometry, it may be free'd later on.  */
5109
5110         if (pWS->iconBoxGeometry)
5111         {
5112             pWS->iconBoxGeometry = XtNewString (pWS->iconBoxGeometry);
5113         }
5114     }
5115
5116     if (pWS->title == NULL)
5117     {
5118         /*
5119          * Setup default workspace title 
5120          */
5121         pWS->title = XmStringCreateLocalized(pWS->name);
5122     }
5123     else
5124     {
5125        /*
5126         * Copy resource just in case there's a duplicate
5127         * Duplicates point to the same data, freeing on 
5128         * rename can cause a crash.
5129         */
5130         pWS->title = XmStringCopy(pWS->title);
5131
5132     }
5133
5134     /*
5135      * Dup iconbox geometry, it may be free'd later on.
5136      */
5137     if (pWS->iconBoxGeometry)
5138     {
5139         pWS->iconBoxGeometry = XtNewString (pWS->iconBoxGeometry);
5140     }
5141
5142     /*
5143      * Get backdrop resources
5144      */
5145     XtGetSubresources (pWS->workspaceTopLevelW, 
5146         (XtPointer) &(pWS->backdrop), 
5147         WmNbackdrop, WmCBackdrop, wmBackdropResources, 
5148         XtNumber (wmBackdropResources), NULL, 0);
5149
5150     ProcessBackdropResources (pWS, 0);
5151
5152 } /* END OF FUNCTION ProcessWorkspaceResources */
5153
5154 /******************************<->*************************************
5155  *
5156  *  ProcessPresenceResources (pSD)
5157  *
5158  *
5159  *  Description:
5160  *  -----------
5161  *  This function retrieves resources for the workspace presence
5162  *  dialog.
5163  *
5164  *  Inputs:
5165  *  ------
5166  *  pSD = pointer to screen data
5167  *
5168  * 
5169  *  Outputs:
5170  *  -------
5171  *  pSD = resource data for workspace presence dialog are set
5172  *
5173  *
5174  *  Comments:
5175  *  --------
5176  *  o Gets subresources 
5177  * 
5178  ******************************<->***********************************/
5179
5180 void 
5181 ProcessPresenceResources (WmScreenData *pSD)
5182 {
5183 #ifndef NO_MESSAGE_CATALOG
5184     static char *default_ws_pres_title = NULL;
5185 #else
5186     static char *default_ws_pres_title = "Workspace Presence";
5187 #endif
5188     Arg args[5];
5189     int n;
5190     unsigned char *pch1, *pch2;
5191
5192 #ifndef NO_MESSAGE_CATALOG
5193     /* 
5194      * Set up localized default title string on initial time through
5195      */
5196     if (default_ws_pres_title == NULL)
5197     {
5198         char * tmpString; 
5199         /*
5200          * catgets returns a pointer to an area that is over written 
5201          * on each call to catgets.  
5202          */
5203
5204         tmpString = ((char *)GETMESSAGE(62, 59, "Occupy Workspace"));
5205         if ((default_ws_pres_title =
5206              (char *)XtMalloc ((unsigned int) (strlen(tmpString) + 1))) == NULL)
5207         {
5208             Warning (((char *)GETMESSAGE(62, 31, "Insufficient memory for local message string")));
5209             default_ws_pres_title = "Occupy Workspace";
5210         }
5211         else
5212         {
5213             strcpy(default_ws_pres_title, tmpString);
5214         }
5215     }
5216 #endif
5217
5218     if (pSD->presence.shellW)
5219     {
5220         XtGetSubresources (pSD->presence.shellW, (XtPointer) &pSD->presence, 
5221                 WmNworkspacePresence, WmCWorkspacePresence, 
5222                 wmWsPresenceResources, 
5223                 XtNumber (wmWsPresenceResources), NULL, 0);
5224
5225         pch2 = NULL;
5226
5227         if (pSD->presence.title)
5228         {
5229             pch1 = (unsigned char *) 
5230                     WmXmStringToString (pSD->presence.title);
5231
5232             if (pch1 && (pch2 = (unsigned char *) 
5233                                 XtMalloc (1+strlen((char *)pch1))))
5234             {
5235                 strcpy ((char *)pch2, (char *)pch1);
5236             }
5237         }
5238
5239         if (!pch2)
5240         {
5241             pch2 = (unsigned char *) default_ws_pres_title;
5242         }
5243
5244         n = 0;
5245         XtSetArg (args[n], XmNtitle, pch2);             n++;
5246         XtSetValues (pSD->presence.shellW, args, n);
5247     }
5248
5249 } /* END OF FUNCTION ProcessPresenceResources */
5250
5251 \f
5252 /*************************************<->*************************************
5253  *
5254  *  ProcessClientResources (pCD)
5255  *
5256  *
5257  *  Description:
5258  *  -----------
5259  *  This function retrieves resources that are client specific.  If the
5260  *  window manager is providing standard behavior then retrieve the limited
5261  *  set of resources that don't affect standard behavior and set the
5262  *  values of the other resources to the standard values.
5263  *
5264  *
5265  *  Inputs:
5266  *  ------
5267  *  pCD = pointer to client data
5268  *
5269  * 
5270  *  Outputs:
5271  *  -------
5272  *  pCD = resource data for client is set
5273  *
5274  *
5275  *  Comments:
5276  *  --------
5277  *  o Gets subresources based on client name and class.
5278  *  o Creates GC for the client Matte, if there is one.
5279  * 
5280  *************************************<->***********************************/
5281
5282 void 
5283 ProcessClientResources (ClientData *pCD)
5284 {
5285     String clientName;
5286     String clientClass;
5287     WmScreenData *pSD = pCD->pSD;
5288
5289     /*
5290      * Retrieve basic client specific resources.
5291      */
5292
5293     _pCD = pCD; /* save in static global for dynamic default processing */
5294     clientName = (pCD->clientName) ? pCD->clientName : WmNdefaults;
5295     clientClass = (pCD->clientClass) ? pCD->clientClass : WmNdefaults;
5296
5297     if (wmGD.useStandardBehavior)
5298     {
5299         XtGetSubresources (pSD->screenTopLevelW, (XtPointer) pCD, clientName,
5300             clientClass, wmStdClientResources, XtNumber (wmStdClientResources),
5301             NULL, 0);
5302
5303         /*
5304          * Fill in the standard resource values.
5305          */
5306
5307         SetStdClientResourceValues (pCD);
5308     }
5309     else
5310     {
5311         XtGetSubresources (pSD->screenTopLevelW, (XtPointer) pCD, clientName,
5312             clientClass, wmClientResources, XtNumber (wmClientResources), NULL,
5313             0);
5314     }
5315
5316 #ifdef NO_MESSAGE_CATALOG
5317     /*
5318      * If (window menu spec is not found) then use the builtin
5319      * system menu.
5320      */
5321
5322     if ((pCD->systemMenu == defaultSystemMenuName) &&
5323         (pSD->defaultSystemMenuUseBuiltin == TRUE))
5324     {
5325         pCD->systemMenu = builtinSystemMenuName;
5326     }
5327 #endif
5328
5329     /*
5330      * If the client decorations or client functions have been defaulted
5331      * fix up the fields in the ProcessMwmHints function.
5332      */
5333
5334
5335     /* make top and bottom shadow pixmaps */
5336
5337     if (pCD->iconImageBottomShadowPStr)
5338     {
5339         if ((pCD->iconImageBottomShadowPStr ==
5340                     pSD->iconAppearance.bottomShadowPStr) &&
5341             (pCD->iconImageBottomShadowColor ==
5342                     pSD->iconAppearance.bottomShadowColor) &&
5343             (pCD->iconImageBackground == 
5344                     pSD->iconAppearance.background))
5345         {
5346             pCD->iconImageBottomShadowPixmap =
5347                     pSD->iconAppearance.bottomShadowPixmap;
5348         }
5349         else
5350         {
5351             pCD->iconImageBottomShadowPixmap =
5352                             XmGetPixmap ( ScreenOfDisplay (DISPLAY,
5353                                               pSD->screen),
5354                                           pCD->iconImageBottomShadowPStr,
5355                                           pCD->iconImageBottomShadowColor,
5356                                           pCD->iconImageBackground);
5357
5358             if (pCD->iconImageBottomShadowPixmap == XmUNSPECIFIED_PIXMAP)
5359             {
5360                 pCD->iconImageBottomShadowPixmap = (Pixmap)NULL;
5361             }
5362         }
5363     }
5364     else
5365     {
5366         pCD->iconImageBottomShadowPixmap = (Pixmap)NULL;
5367     }
5368
5369     if (pCD->iconImageTopShadowPStr)
5370     {
5371         if ((pCD->iconImageTopShadowPStr ==
5372                                 pSD->iconAppearance.topShadowPStr) &&
5373             (pCD->iconImageTopShadowColor ==
5374                                 pSD->iconAppearance.topShadowColor) &&
5375             (pCD->iconImageBackground == pSD->iconAppearance.background))
5376         {
5377             pCD->iconImageTopShadowPixmap =
5378                                         pSD->iconAppearance.topShadowPixmap;
5379         }
5380         else
5381         {
5382             pCD->iconImageTopShadowPixmap =
5383                             XmGetPixmap ( ScreenOfDisplay (DISPLAY,
5384                                               pSD->screen),
5385                                           pCD->iconImageTopShadowPStr,
5386                                           pCD->iconImageTopShadowColor,
5387                                           pCD->iconImageBackground);
5388
5389             if (pCD->iconImageTopShadowPixmap == XmUNSPECIFIED_PIXMAP)
5390             {
5391                 pCD->iconImageTopShadowPixmap = (Pixmap)NULL;
5392             }
5393         }
5394     }
5395     else
5396     {
5397         pCD->iconImageTopShadowPixmap = (Pixmap)NULL;
5398     }
5399
5400     if ((pCD->internalBevel < MIN_INTERNAL_BEVEL)  || 
5401         (pCD->internalBevel > MAX_INTERNAL_BEVEL))
5402     {
5403         pCD->internalBevel = MAX_INTERNAL_BEVEL;
5404     }
5405
5406
5407     /*
5408      * Retrieve matte resources and make internal matte resources.
5409      */
5410
5411     if (pCD->matteWidth > 0)
5412     {
5413         XtGetSubresources (pSD->screenTopLevelW, (XtPointer) pCD, clientName,
5414             clientClass, wmClientResourcesM, XtNumber (wmClientResourcesM),
5415             NULL, 0);
5416
5417         /* make top and bottom shadow pixmaps */
5418
5419         if (pCD->matteBottomShadowPStr &&
5420             (!strcmp(pCD->matteBottomShadowPStr, _NoDither)))
5421         {
5422             pCD->matteBottomShadowPStr = NULL;
5423         }
5424
5425         if (pCD->matteBottomShadowPStr)
5426         {
5427             if ((pCD->matteBottomShadowPStr ==
5428                                     pSD->clientAppearance.bottomShadowPStr) &&
5429                 (pCD->matteBottomShadowColor ==
5430                                     pSD->clientAppearance.bottomShadowColor) &&
5431                 (pCD->matteBackground == pSD->clientAppearance.background))
5432             {
5433                 pCD->matteBottomShadowPixmap =
5434                                 pSD->clientAppearance.bottomShadowPixmap;
5435             }
5436             else
5437             {
5438                 pCD->matteBottomShadowPixmap =
5439                                 XmGetPixmap (ScreenOfDisplay (DISPLAY,
5440                                                  pSD->screen),
5441                                              pCD->matteBottomShadowPStr,
5442                                              pCD->matteBottomShadowColor,
5443                                              pCD->matteBackground);
5444
5445                 if (pCD->matteBottomShadowPixmap == XmUNSPECIFIED_PIXMAP)
5446                 {
5447                     pCD->matteBottomShadowPixmap = (Pixmap)NULL;
5448                 }
5449             }
5450         }
5451         else
5452         {
5453             pCD->matteBottomShadowPixmap = (Pixmap)NULL;
5454         }
5455
5456         if (pCD->matteTopShadowPStr &&
5457             (!strcmp(pCD->matteTopShadowPStr, _NoDither)))
5458         {
5459             pCD->matteTopShadowPStr = NULL;
5460         }
5461
5462         if (pCD->matteTopShadowPStr)
5463         {
5464             if ((pCD->matteTopShadowPStr ==
5465                                     pSD->clientAppearance.topShadowPStr) &&
5466                 (pCD->matteTopShadowColor ==
5467                                     pSD->clientAppearance.topShadowColor) &&
5468                 (pCD->matteBackground == pSD->clientAppearance.background))
5469             {
5470                 pCD->matteTopShadowPixmap =
5471                                         pSD->clientAppearance.topShadowPixmap;
5472             }
5473             else
5474             {
5475                 pCD->matteTopShadowPixmap =
5476                                 XmGetPixmap (ScreenOfDisplay (DISPLAY,
5477                                                  pSD->screen),
5478                                              pCD->matteTopShadowPStr,
5479                                              pCD->matteTopShadowColor,
5480                                              pCD->matteBackground);
5481
5482                 if (pCD->matteTopShadowPixmap == XmUNSPECIFIED_PIXMAP)
5483                 {
5484                     pCD->matteTopShadowPixmap = (Pixmap)NULL;
5485                 }
5486             }
5487         }
5488         else
5489         {
5490             pCD->matteTopShadowPixmap = (Pixmap)NULL;
5491         }
5492
5493
5494         /* make top and bottom shadow GC's */
5495
5496         pCD->clientMatteTopShadowGC = GetHighlightGC (pCD->pSD,
5497                                           pCD->matteTopShadowColor,
5498                                           pCD->matteBackground,
5499                                           pCD->matteTopShadowPixmap);
5500
5501         pCD->clientMatteBottomShadowGC = GetHighlightGC (pCD->pSD,
5502                                           pCD->matteBottomShadowColor,
5503                                           pCD->matteBackground,
5504                                           pCD->matteBottomShadowPixmap);
5505     }
5506
5507 } /* END OF FUNCTION ProcessClientResources */
5508
5509
5510 \f
5511 /*************************************<->*************************************
5512  *
5513  *  SetStdClientResourceValues (pCD)
5514  *
5515  *
5516  *  Description:
5517  *  -----------
5518  *  This function sets client resource data to standard values.  This setting
5519  *  is done in place of getting the values from the user settings in
5520  *  the resource database.
5521  *
5522  *  Input:
5523  *  -----
5524  *  pCD = pointer to the client data
5525  *
5526  * 
5527  *  Output:
5528  *  ------
5529  *  pCD = (client data filled out with resource values)
5530  * 
5531  *************************************<->***********************************/
5532
5533 void 
5534 SetStdClientResourceValues (ClientData *pCD)
5535 {
5536     pCD->clientDecoration = WM_DECOR_DEFAULT;
5537     pCD->clientFunctions = WM_FUNC_DEFAULT;
5538     pCD->focusAutoRaise = True;
5539     pCD->systemMenu = builtinSystemMenuName;
5540     pCD->usePPosition = USE_PPOSITION_NONZERO;
5541     pCD->ignoreWMSaveHints = True;
5542
5543 } /* END OF FUNCTION SetStdClientResourceValues */
5544
5545
5546 \f
5547 /******************************<->*************************************
5548  *
5549  *  SetStdScreenResourceValues (pSD)
5550  *
5551  *
5552  *  Description:
5553  *  -----------
5554  *  This function sets screen resource data to standard values.  This setting
5555  *  is done in place of getting the values from the user settings in
5556  *  the resource database.
5557  *
5558  *  Input:
5559  *  -----
5560  *  pSD = pointer to the screen data
5561  *
5562  * 
5563  *  Output:
5564  *  ------
5565  *  pSD = (screen data filled out with resource values)
5566  * 
5567  ******************************<->***********************************/
5568
5569 void 
5570 SetStdScreenResourceValues (WmScreenData *pSD)
5571 {
5572     pSD->buttonBindings = builtinButtonBindingsName;
5573     pSD->cleanText = True;
5574     pSD->iconDecoration =
5575                 (ICON_LABEL_PART | ICON_IMAGE_PART | ICON_ACTIVE_LABEL_PART);
5576     pSD->iconPlacement =
5577                 (ICON_PLACE_LEFT_PRIMARY | ICON_PLACE_BOTTOM_SECONDARY);
5578     pSD->keyBindings = builtinKeyBindingsName;
5579     pSD->limitResize = True;
5580     pSD->resizeCursors = True;
5581     pSD->transientDecoration = (WM_DECOR_SYSTEM | WM_DECOR_RESIZEH);
5582     pSD->transientFunctions =
5583                 (WM_FUNC_ALL & ~(MWM_FUNC_MAXIMIZE | MWM_FUNC_MINIMIZE |
5584                                  MWM_FUNC_RESIZE));
5585     pSD->useIconBox = False;
5586
5587     pSD->feedbackGeometry = NULL;
5588     pSD->moveOpaque = False;
5589
5590 } /* END OF FUNCTION SetStdScreenResourceValues */
5591
5592 \f
5593 /*************************************<->*************************************
5594  *
5595  *  GetHighlightGC (pSD, fg, bg, pixmap)
5596  *
5597  *
5598  *  Description:
5599  *  -----------
5600  *  Get a graphic context for either drawing top- or bottom-shadow 
5601  *  highlights.
5602  *
5603  *
5604  *  Inputs:
5605  *  ------
5606  *  pSD = pointer to screen data
5607  *  fg = foreground color
5608  *  bg = background color
5609  *  pixmap = pixmap for highlight
5610  * 
5611  *  Outputs:
5612  *  -------
5613  *  RETRUN = GC with the input parameters incorporated.
5614  *
5615  *************************************<->***********************************/
5616
5617 GC GetHighlightGC (WmScreenData *pSD, Pixel fg, Pixel bg, Pixmap pixmap)
5618 {
5619     XGCValues gcv;
5620     XtGCMask  mask;
5621
5622
5623     mask = GCForeground | GCBackground | GCLineWidth | GCFillStyle;
5624     gcv.background = bg;
5625     gcv.foreground = fg;
5626     gcv.line_width = 1;
5627
5628     if (pixmap)
5629     {
5630         mask |= GCFillStyle | GCTile;
5631         gcv.fill_style = FillTiled;
5632         gcv.tile = pixmap;
5633     }
5634     else
5635     {
5636         gcv.fill_style = FillSolid;
5637     }
5638
5639 #ifdef OLD_CODE
5640     /*
5641      * NOTE: If additional mask bits are added, modify WmGetGC()
5642      * in WmGraphics.c to check those values for matches.
5643      */
5644
5645     return (WmGetGC (pSD, mask, &gcv));
5646 #endif /* OLD_CODE */
5647
5648     return (XtGetGC (pSD->screenTopLevelW, mask, &gcv));
5649
5650 } /* END OF FUNCTION GetHighlightGC */
5651
5652
5653 \f
5654 /*************************************<->*************************************
5655  *
5656  *  _WmGetDynamicDefault (widget, type, defaultColor, newBackground, value)
5657  *
5658  *
5659  *  Description:
5660  *  -----------
5661  *  This function is used to generate a default color of the requested 
5662  *  type.  Default colors are generated for a 3-D appearance.
5663  *
5664  *
5665  *  Inputs:
5666  *  ------
5667  *  widget = this is the widget that is associated with the resource or
5668  *           that is the reference widget for the wm subpart.
5669  *
5670  *  type = this is the type of color resource (e.g., top shadow color).
5671  *
5672  *  defaultColor = pointer to default color name/specification.
5673  *
5674  *  newBackground = background pixel for generating 3-D colors.
5675  *
5676  * 
5677  *  Outputs:
5678  *  -------
5679  *  value = pointer to the XrmValue in which to store the color
5680  * 
5681  *************************************<->***********************************/
5682
5683 void 
5684 _WmGetDynamicDefault (Widget widget, unsigned char type, String defaultColor, Pixel newBackground, XrmValue *value)
5685 {
5686     static Screen *oldScreen = NULL;
5687     static Screen *newScreen;
5688     static Colormap oldColormap;
5689     static Colormap newColormap;
5690     static Pixel newValue;
5691     static Pixel background;
5692     static String oldDefaultColor = DEFAULT_COLOR_NONE;
5693     static XmColorData colorData;
5694
5695     /* initialize the return value */
5696
5697     value->size = sizeof (newValue);
5698     value->addr = (char *)&newValue;
5699
5700
5701     /*
5702      * Process monochrome defaults first.
5703      */
5704
5705     newScreen = XtScreen (widget);
5706
5707     if (Monochrome (newScreen))
5708     {
5709     Boolean ok = False;
5710     /*
5711      * Check color server sets for this screen.
5712      */
5713     if (wmGD.statusColorServer == CSERVE_NORMAL)
5714     {
5715         WmScreenData *pSD;
5716         int i;
5717
5718         for (i = 0; i < wmGD.numScreens; i++)
5719         {
5720             if (XScreenNumberOfScreen(newScreen) == wmGD.Screens[i].screen)
5721             {
5722                 pSD = &wmGD.Screens[i];
5723                 ok = True;
5724                 break;
5725             }
5726         }
5727
5728         if (ok)
5729         {
5730             ok = False;
5731             for (i = 0; i < XmCO_MAX_NUM_COLORS; i++)
5732             {
5733                 if (pSD->pPixelData[i].bg == newBackground)
5734                 {
5735                     switch (type)
5736                       {
5737                       case WmFGC: newValue = pSD->pPixelData[i].fg; break;
5738                       case WmBGC: newValue = pSD->pPixelData[i].bg; break;
5739                       case WmTSC: newValue = pSD->pPixelData[i].ts; break;
5740                       case WmBSC: newValue = pSD->pPixelData[i].bs; break;
5741                       }
5742
5743                     ok = True;
5744                 }
5745             }
5746         }
5747
5748     }
5749     if (!ok)
5750     {
5751         switch (type)
5752           {
5753           case WmFGC: newValue = BlackPixelOfScreen (newScreen); break;
5754           case WmBGC: newValue = WhitePixelOfScreen (newScreen); break;
5755           case WmTSC: newValue = WhitePixelOfScreen (newScreen); break;
5756           case WmBSC: newValue = BlackPixelOfScreen (newScreen); break;
5757           }
5758     }
5759         return;
5760     }
5761
5762
5763     /*
5764      * Check to see if appropriate colors are available from the
5765      * previous request; if the color is a background color then get
5766      * default colors.  Generate 3-D colors if necessary.  Maintain
5767      * new colors in static variables for later reuse.
5768      */
5769
5770     newColormap = widget->core.colormap;
5771
5772     if ((oldScreen != NULL) && (oldScreen == newScreen) &&
5773         (oldColormap == newColormap) && (type != WmBGC) &&
5774         (background == newBackground))
5775     {
5776     }
5777     else if ((oldScreen == newScreen) && (oldColormap == newColormap) &&
5778              (type == WmBGC) && (oldDefaultColor == defaultColor))
5779     {
5780     }
5781     else if (type == WmBGC)
5782     {
5783         /*
5784          * Find or generate a background color and associated 3-D colors.
5785          */
5786
5787         oldDefaultColor = defaultColor;
5788 /*
5789  * Fix for CR 5152 - Due to the use of Realloc in the color caches,
5790  *                   a static pointer is not acceptable.  Change it
5791  *                   to a static structure to maintain the data
5792  */
5793         colorData = *_WmGetDefaultColors (newScreen, newColormap, defaultColor);
5794     }
5795     else
5796     {
5797         /*
5798          * Find or generate a color based on the associated background color.
5799          */
5800
5801         oldDefaultColor = DEFAULT_COLOR_NONE;
5802         background = newBackground;
5803
5804         XmGetColors(newScreen, newColormap, background,
5805                     &colorData.foreground.pixel,
5806                     &colorData.top_shadow.pixel,
5807                     &colorData.bottom_shadow.pixel,
5808                     &colorData.select.pixel);
5809     }
5810
5811     oldScreen = newScreen;
5812     oldColormap = newColormap;
5813
5814
5815     /*
5816      * Set up the return value.
5817      */
5818
5819     colorData.allocated |= type;
5820     switch (type)
5821       {
5822       case XmBACKGROUND:    newValue = colorData.background.pixel;    break;
5823       case XmFOREGROUND:    newValue = colorData.foreground.pixel;    break;
5824       case XmTOP_SHADOW:    newValue = colorData.top_shadow.pixel;    break;
5825       case XmBOTTOM_SHADOW: newValue = colorData.bottom_shadow.pixel; break;
5826       case XmSELECT:        newValue = colorData.select.pixel;        break;
5827       default:              newValue = colorData.background.pixel;    break;
5828       }
5829
5830 } /* END OF FUNCTION _WmGetDynamicDefault */
5831
5832
5833 \f
5834 /*************************************<->*************************************
5835  *
5836  *  _WmGetDefaultColors (screen, colormap, defaultColor)
5837  *
5838  *
5839  *  Description:
5840  *  -----------
5841  *  This function is used to find or generate default 3-D colors based on a
5842  *  default background color.
5843  *
5844  *
5845  *  Inputs:
5846  *  ------
5847  *  screen = screen for which colors are to be generated.
5848  *
5849  *  colormap = colormap that is to be used to make colors.
5850  *
5851  *  defaultColor = pointer to a default color name/specification.
5852  *
5853  * 
5854  *  Outputs:
5855  *  -------
5856  *  RETURN = pointer to WmColorData structure containing 3-D colors.
5857  * 
5858  *************************************<->***********************************/
5859
5860 XmColorData * _WmGetDefaultColors (Screen *screen, Colormap colormap,
5861                                    String defaultColor)
5862 {
5863     static XmColorData *defaultSet[2] = {NULL, NULL};
5864     static int defaultCount[2] = {0, 0};
5865     static int defaultSize[2] = {0, 0};
5866     int setId;
5867     XmColorData *set;
5868     int count;
5869     int size;
5870     int i;
5871     Display *display = DisplayOfScreen (screen);
5872     XColor colorDef;
5873
5874 /*
5875  * Fix for CR 5152 - Due to the use of Realloc with _XmGetColors, it is
5876  *                   necessary to maintain a separate cache of color
5877  *                   data.  The Realloc may cause the data to be moved,
5878  *                   and the cache would contain pointers into the heap.
5879  */
5880
5881     /*
5882      * Look through the cache to see if the defaults are already in the
5883      * cache.  There is a list of cached defaults for each default color.
5884      */
5885
5886     if (defaultColor == _defaultColor2)
5887     {
5888         setId = 1;
5889     }
5890     else
5891     {
5892         setId = 0;
5893     }
5894
5895     set = defaultSet[setId];
5896     count = defaultCount[setId];
5897     size = defaultSize[setId];
5898     
5899     for (i = 0; i < count; i++)
5900     {
5901         if (((set + i)->screen == screen) && ((set + i)->color_map == colormap))
5902         {
5903             return (set + i);
5904         }
5905     }
5906
5907     /* 
5908      * No match in the cache, make a new entry and generate the colors.
5909      */
5910
5911     if (count == size)
5912     {
5913         size = (defaultSize[setId] += 10);
5914         set = defaultSet[setId] =
5915                 (XmColorData *)WmRealloc ((char *) defaultSet[setId],
5916                                     sizeof (XmColorData) * size);
5917     }
5918
5919     /*
5920      * Make the default background color for the resource set.
5921      */
5922
5923     if(!XParseColor (display, colormap, defaultColor, &colorDef))
5924     {
5925         if(!(strcmp(defaultColor, _defaultColor1)))
5926         {
5927             XParseColor (display, colormap, _defaultColor1HEX, &colorDef);
5928         }
5929         else
5930         {
5931             XParseColor (display, colormap, _defaultColor2HEX, &colorDef);
5932         }
5933     }
5934
5935     XAllocColor (display, colormap, &colorDef);
5936
5937
5938     /*
5939      * Generate the 3-D colors and save them in the defaults cache.
5940      */
5941
5942     XmGetColors(screen, colormap, colorDef.pixel,
5943                 &set[count].foreground.pixel,
5944                 &set[count].top_shadow.pixel,
5945                 &set[count].bottom_shadow.pixel,
5946                 &set[count].select.pixel);
5947     
5948     set[count].background.pixel = colorDef.pixel;
5949     
5950     set[count].screen    = screen;
5951     set[count].color_map = colormap;
5952     set[count].allocated = True;
5953     
5954     XQueryColor(DISPLAY, colormap, &(set[count].background));
5955     XQueryColor(DISPLAY, colormap, &(set[count].foreground));
5956     XQueryColor(DISPLAY, colormap, &(set[count].top_shadow));
5957     XQueryColor(DISPLAY, colormap, &(set[count].bottom_shadow));
5958     XQueryColor(DISPLAY, colormap, &(set[count].select));
5959
5960     (defaultCount[setId])++;
5961
5962     return (set + count);
5963
5964
5965 } /* END OF FUNCTION _WmGetDefaultColors */
5966
5967
5968 \f
5969 /*************************************<->*************************************
5970  *
5971  *  WmRealloc (ptr, size)
5972  *
5973  *
5974  *  Description:
5975  *  -----------
5976  *  This function is used reallocate a block of storage that has been
5977  *  malloc'ed.
5978  *
5979  *
5980  *  Inputs:
5981  *  ------
5982  *  ptr = pointer to storage that is to be realloc'ed; if NULL malloc an
5983  *        initial block of storage.
5984  *
5985  *  size = size of new storage
5986  * 
5987  *  Outputs:
5988  *  -------
5989  *  RETURN = pointer to realloc'ed block of storage
5990  * 
5991  *************************************<->***********************************/
5992
5993 char * WmRealloc (char *ptr, unsigned size)
5994 {
5995     if (ptr)
5996     {
5997         ptr = (char *)XtRealloc (ptr, size);
5998     }
5999     else
6000     {
6001         ptr = (char *)XtMalloc (size);
6002     }
6003
6004     if (ptr == NULL)
6005     {
6006         Warning (((char *)GETMESSAGE(62, 37, "Insufficient memory for window manager data")));
6007     }
6008
6009     return (ptr);
6010
6011 } /* END OF FUNCTION WmRealloc */
6012
6013
6014 \f
6015 /*************************************<->*************************************
6016  *
6017  *  WmMalloc (ptr, size)
6018  *
6019  *
6020  *  Description:
6021  *  -----------
6022  *  This function is used malloc a block of storage.  If a previous block
6023  *  of storage is being replace the old block is free'd.
6024  *
6025  *
6026  *  Inputs:
6027  *  ------
6028  *  ptr = pointer to storage that is to be replaced (free'd).
6029  *
6030  *  size = size of new storage
6031  * 
6032  *  Outputs:
6033  *  -------
6034  *  RETURN = pointer to malloc'ed block of storage
6035  * 
6036  *************************************<->***********************************/
6037
6038 char * WmMalloc (char *ptr, unsigned size)
6039 {
6040     if (ptr)
6041     {
6042         XtFree (ptr);
6043     }
6044
6045     ptr = (char *)XtMalloc (size);
6046
6047     if (ptr == NULL)
6048     {
6049         Warning (((char *)GETMESSAGE(62, 38, "Insufficient memory for window manager data")));
6050     }
6051
6052     return (ptr);
6053
6054 } /* END OF FUNCTION WmMalloc */
6055
6056
6057 \f
6058 /*************************************<->*************************************
6059  *
6060  *  SetupDefaultResources (pSD)
6061  *
6062  *
6063  *  Description:
6064  *  -----------
6065  *  This function is used to setup default (builtin) resources for the
6066  *  key bindings.
6067  *
6068  *
6069  *  Inputs:
6070  *  ------
6071  *  pSD = pointer to screen data
6072  *  wmGD = (defaultKeyBindingsString, ...)
6073  *
6074  *  builtinKeyBindingsName = name of default key bindings set
6075  *
6076  * 
6077  *  Outputs:
6078  *  -------
6079  *   None 
6080  *
6081  *************************************<->***********************************/
6082
6083 void
6084 SetupDefaultResources (WmScreenData *pSD)
6085 {
6086     KeySpec *nextKeySpec;
6087     String keyBindings;
6088     MenuSpec *menuSpec;
6089
6090
6091 /*
6092  * If (using DefaultBindings mechanism and bindings are not found in .mwmrc)
6093  *      then use the builtin bindings.
6094  */
6095     if (!pSD->keySpecs && !wmGD.useStandardBehavior)
6096     {
6097         /*
6098          * Print warning if user is NOT using "DefaultKeyBindings".
6099          */
6100         if (strcmp (pSD->keyBindings, defaultKeyBindingsName))
6101         {
6102            MWarning (((char *)GETMESSAGE(62, 67, "Key bindings %s not found, using builtin key bindings\n")),
6103            pSD->keyBindings);
6104         }
6105         pSD->keyBindings = builtinKeyBindingsName;
6106     }
6107
6108     if (!pSD->buttonSpecs && !wmGD.useStandardBehavior)
6109     {
6110         /*
6111          * Print warning if user is NOT using "DefaultButtonBindings".
6112          */
6113         if (strcmp (pSD->buttonBindings, defaultButtonBindingsName))
6114         {
6115            MWarning (((char *)GETMESSAGE(62, 68, "Button bindings %s not found, using builtin button bindings\n")),
6116                      pSD->buttonBindings);
6117         }
6118         pSD->buttonBindings = builtinButtonBindingsName;
6119     }
6120
6121     if (pSD->keyBindings == builtinKeyBindingsName)
6122     {
6123         /*
6124          * Default key specifications are to be used and no default
6125          * set has been provided by the user.  Make the built-in default
6126          * set.
6127          */
6128
6129         ParseKeyStr (pSD, (unsigned char *)builtinKeyBindings);
6130     }
6131     else
6132     {
6133         /*
6134          * Add the switch behavior key binding to the front of the list
6135          * of user specified key bindings that have been parsed.
6136          */
6137
6138         nextKeySpec = pSD->keySpecs;
6139         keyBindings = pSD->keyBindings;
6140         pSD->keyBindings = behaviorKeyBindingName;
6141         pSD->keySpecs = NULL;
6142
6143         ParseKeyStr (pSD, (unsigned char *)behaviorKeyBindings);
6144
6145         if (pSD->keySpecs)
6146         {
6147             /* Skip past the TWO key definitions (1.2 & 1.1.4) */
6148             pSD->keySpecs->nextKeySpec->nextKeySpec = nextKeySpec;
6149         }
6150         else
6151         {
6152             pSD->keySpecs = nextKeySpec;
6153         }
6154         pSD->keyBindings = keyBindings;
6155     }
6156
6157     if (pSD->buttonBindings == builtinButtonBindingsName)
6158     {
6159         /*
6160          * Default button specifications are to be used and no default
6161          * set has been provided by the user.  Make the built-in default
6162          * set.
6163          */
6164
6165         ParseButtonStr (pSD, (unsigned char *)builtinButtonBindings);
6166     }
6167
6168 #ifdef NO_MESSAGE_CATALOG
6169     /*
6170      * Set defaultSystemMenuUseBuiltin to FALSE if DefaultWindowMenu spec
6171      * is found.
6172      */
6173
6174     menuSpec = pSD->menuSpecs;
6175     while ( menuSpec )
6176     {
6177         if (!strcmp(menuSpec->name, defaultSystemMenuName))
6178         {
6179                 pSD->defaultSystemMenuUseBuiltin = FALSE;
6180                 break;
6181         }
6182         menuSpec = menuSpec->nextMenuSpec;
6183     }
6184 #endif
6185
6186 } /* END OF FUNCTION SetupDefaultResources */
6187
6188
6189 \f
6190 /*************************************<->*************************************
6191  *
6192  *  SimilarAppearanceData (pAD1, pAD2)
6193  *
6194  *
6195  *  Description:
6196  *  -----------
6197  *  This function returns True if the two passed sets of AppearanceData
6198  *  are similar. This is designed to compare appearance data before
6199  *  creation of the GCs.
6200  *
6201  *
6202  *  Inputs:
6203  *  ------
6204  *  pAD1        pointer to AppearanceData 1
6205  *  pAD2        pointer to AppearanceData 2
6206  *
6207  * 
6208  *  Outputs:
6209  *  -------
6210  *  Function returns True if similar, False otherwise.
6211  * 
6212  *  Comments:
6213  *  ---------
6214  *  This function is only used to compare the client
6215  *  and client*title appearance data.
6216  *************************************<->***********************************/
6217
6218 Boolean SimilarAppearanceData (AppearanceData *pAD1, AppearanceData *pAD2)
6219 {
6220     Boolean rval;
6221
6222     /*
6223      * !!! Should find out why all the Pixmap resources are unset !!!
6224      */
6225
6226     if ((pAD1->fontList == pAD2->fontList) &&
6227         (pAD1->background == pAD2->background) &&
6228         (pAD1->foreground == pAD2->foreground) &&
6229         (pAD1->backgroundPStr == pAD2->backgroundPStr) &&
6230         (pAD1->bottomShadowColor == pAD2->bottomShadowColor) &&
6231         (pAD1->bottomShadowPStr == pAD2->bottomShadowPStr) &&
6232         (pAD1->topShadowColor == pAD2->topShadowColor) &&
6233         (pAD1->topShadowPStr == pAD2->topShadowPStr) &&
6234         (pAD1->activeBackground == pAD2->activeBackground) &&
6235         (pAD1->activeForeground == pAD2->activeForeground) &&
6236         (pAD1->activeBackgroundPStr == pAD2->activeBackgroundPStr) &&
6237         (pAD1->activeBottomShadowColor == pAD2->activeBottomShadowColor) &&
6238         (pAD1->activeBottomShadowPStr == pAD2->activeBottomShadowPStr) &&
6239         (pAD1->activeTopShadowColor == pAD2->activeTopShadowColor) &&
6240         (pAD1->activeTopShadowPStr == pAD2->activeTopShadowPStr) )
6241     {
6242         rval = True;
6243     }
6244     else 
6245     {
6246         rval = False;
6247     }
6248
6249     return (rval);
6250
6251 } /* END OF FUNCTION SimilarAppearanceData */
6252
6253 /*************************************<->*************************************
6254  *
6255  *  Monochrome (screen)
6256  *
6257  *
6258  *  Description:
6259  *  -----------
6260  *  This function returns True if the screen passed it to be treated
6261  *  as monochrome for the purpose of assigning default resources.
6262  *
6263  *
6264  *  Inputs:
6265  *  ------
6266  *  screen      pointer to Screen
6267  *
6268  * 
6269  *  Outputs:
6270  *  -------
6271  *  Function returns True if monochrome (or Static Gray), False otherwise.
6272  * 
6273  *************************************<->***********************************/
6274
6275 Boolean 
6276 Monochrome (Screen *screen)
6277 {
6278     WmScreenData *pSD;
6279
6280     int scr;
6281     
6282     if (wmGD.statusColorServer == CSERVE_NORMAL)
6283     {
6284         for (scr = 0; scr < wmGD.numScreens; scr++)
6285         {
6286             pSD = &(wmGD.Screens[scr]);
6287
6288             if (pSD->managed)
6289             {
6290                 if (XScreenOfDisplay (DISPLAY, pSD->screen) == screen)
6291                 {
6292                     if (pSD->colorUse == XmCO_BLACK_WHITE)
6293                     {
6294                         return(True);
6295                     }
6296                     else
6297                     {
6298                         return(False);
6299                     }
6300                 }
6301             }
6302         }
6303     }
6304     /*
6305      *   If we don't know the answer to our question by now,
6306      *   fall back to the old mwm way of determining monochromicity.
6307      *
6308      */
6309
6310     return ((DefaultDepthOfScreen(screen) == 1));
6311 } /* END OF FUNCTION Monochrome */
6312
6313 /****************************   eof    ***************************/