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