1 /**
2  *
3  * $Id: resources.c,v 1.1 2004/08/28 19:25:46 dannybackx Exp $
4  *
5  * Copyright (C) 1995 Free Software Foundation, Inc.
6  * Copyright (C) 1995-2002 LessTif Development Team
7  *
8  * This file is part of the GNU LessTif Library.
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Library General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Library General Public License for more details.
19  *
20  * You should have received a copy of the GNU Library General Public
21  * License along with this library; if not, write to the Free
22  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23  *
24  **/
25 
26 #include <LTconfig.h>
27 
28 #include <stdio.h>
29 #include <string.h>
30 
31 #include <Xm/XmP.h>
32 #include <Xm/MwmUtil.h>
33 #include <Xm/XmStrDefs.h>
34 
35 #include "mwm.h"
36 #include "mwmstrings.h"
37 
38 /*
39  * mwm strings
40  */
41 const char mwm_strings[] =
42 "autoKeyFocus\0"
43 "AutoKeyFocus\0"
44 "autoRaiseDelay\0"
45 "AutoRaiseDelay\0"
46 "bitmapDirectory\0"
47 "BitmapDirectory\0"
48 "buttonBindings\0"
49 "ButtonBindings\0"
50 "cleanText\0"
51 "CleanText\0"
52 "clientAutoPlace\0"
53 "ClientAutoPlace\0"
54 "colormapFocusPolicy\0"
55 "ColormapFocusPolicy\0"
56 "configFile\0"
57 "ConfigFile\0"
58 "deiconifyKeyFocus\0"
59 "DeiconifyKeyFocus\0"
60 "doubleClickTime\0"
61 "DoubleClickTime\0"
62 "enableWarp\0"
63 "EnableWarp\0"
64 "enforceKeyFocus\0"
65 "EnforceKeyFocus\0"
66 "fadeNormalIcon\0"
67 "FadeNormalIcon\0"
68 "feedbackGeometry\0"
69 "FeedbackGeometry\0"
70 "freezeOnConfig\0"
71 "FreezeOnConfig\0"
72 "frameBorderWidth\0"
73 "FrameBorderWidth\0"
74 "iconAutoPlace\0"
75 "IconAutoPlace\0"
76 "iconBoxGeometry\0"
77 "IconBoxGeometry\0"
78 "iconBoxName\0"
79 "IconBoxName\0"
80 "iconBoxSBDisplayPolicy\0"
81 "IconBoxSBDisplayPolicy\0"
82 "iconBoxScheme\0"
83 "IconBoxScheme\0"
84 "iconBoxTitle\0"
85 "IconBoxTitle\0"
86 "iconClick\0"
87 "IconClick\0"
88 "iconDecoration\0"
89 "IconDecoration\0"
90 "iconImageMaximum\0"
91 "IconImageMaximum\0"
92 "iconImageMinimum\0"
93 "IconImageMinimum\0"
94 "iconPlacement\0"
95 "IconPlacement\0"
96 "iconPlacementMargin\0"
97 "IconPlacementMargin\0"
98 "interactivePlacement\0"
99 "InteractivePlacement\0"
100 "keyBindings\0"
101 "KeyBindings\0"
102 "limitResize\0"
103 "LimitResize\0"
104 "lowerOnIconify\0"
105 "LowerOnIconify\0"
106 "maximumMaximumSize\0"
107 "MaximumMaximumSize\0"
108 "moveThreshold\0"
109 "MoveThreshold\0"
110 "multiScreen\0"
111 "MultiScreen\0"
112 "passButtons\0"
113 "PassButtons\0"
114 "passSelectButton\0"
115 "PassSelectButton\0"
116 "positionIsFrame\0"
117 "PositionIsFrame\0"
118 "positionOnScreen\0"
119 "PositionOnScreen\0"
120 "quitTimeout\0"
121 "QuitTimeout\0"
122 "raiseKeyFocus\0"
123 "RaiseKeyFocus\0"
124 "resizeBorderWidth\0"
125 "FrameBorderWidth\0"
126 "resizeCursors\0"
127 "ResizeCursors\0"
128 "screens\0"
129 "Screens\0"
130 "showFeedback\0"
131 "ShowFeedback\0"
132 "startupKeyFocus\0"
133 "StartupKeyFocus\0"
134 "transientDecoration\0"
135 "TransientDecoration\0"
136 "transientFunctions\0"
137 "TransientFunctions\0"
138 "useIconBox\0"
139 "UseIconBox\0"
140 "wMenuButtonClick\0"
141 "WMenuButtonClick\0"
142 "wMenuButtonClick2\0"
143 "WMenuButtonClick2\0"
144 "clientDecoration\0"
145 "ClientDecoration\0"
146 "clientFunctions\0"
147 "ClientFunctions\0"
148 "focusAutoRaise\0"
149 "FocusAutoRaise\0"
150 "iconImage\0"
151 "IconImage\0"
152 "iconImageBackground\0"
153 "IconImageBackground\0"
154 "iconImageBottomShadowColor\0"
155 "IconImageBottomShadowColor\0"
156 "iconImageBottomShadowPixmap\0"
157 "IconImageBottomShadowPixmap\0"
158 "iconImageForeground\0"
159 "IconImageForeground\0"
160 "iconImageTopShadowColor\0"
161 "IconImageTopShadowColor\0"
162 "iconImageTopShadowPixmap\0"
163 "IconImageTopShadowPixmap\0"
164 "matteBackground\0"
165 "MatteBackground\0"
166 "matteBottomShadowColor\0"
167 "MatteBottomShadowColor\0"
168 "matteBottomShadowPixmap\0"
169 "MatteBottomShadowPixmap\0"
170 "matteForeground\0"
171 "MatteForeground\0"
172 "matteTopShadowColor\0"
173 "MatteTopShadowColor\0"
174 "matteTopShadowPixmap\0"
175 "MatteTopShadowPixmap\0"
176 "matteWidth\0"
177 "MatteWidth\0"
178 "maximumClientSize\0"
179 "MaximumClientSize\0"
180 "useClientIcon\0"
181 "UseClientIcon\0"
182 "usePPosition\0"
183 "UsePPosition\0"
184 "windowMenu\0"
185 "WindowMenu\0"
186 "activeBackground\0"
187 "activeForeground\0"
188 "activeBottomShadowColor\0"
189 "activeBottomShadowPixmap\0"
190 "activeTopShadowColor\0"
191 "activeBackgroundPixmap\0"
192 "activeTopShadowPixmap\0"
193 "WmCFocus\0"
194 "WmCDecor\0"
195 "WmCFunc\0"
196 "WmIDecor\0"
197 "WmIPlace\0"
198 "WmKFocus\0"
199 "WmSize\0"
200 "WmShowFeedback\0"
201 "WmUsePPosition\0"
202 "clientFlags\0"
203 "ClientFlags\0"
204 "WmCFlags\0"
205 "usePager\0"
206 "UsePager\0"
207 "edgeScrollX\0"
208 "EdgeScrollX\0"
209 "edgeScrollY\0"
210 "EdgeScrollY\0"
211 "pagerX\0"
212 "PagerX\0"
213 "pagerY\0"
214 "PagerY\0"
215 "virtualX\0"
216 "VirtualX\0"
217 "virtualY\0"
218 "VirtualY\0"
219 "clickTime\0"
220 "ClickTime\0"
221 "smartPlacement\0"
222 "SmartPlacement\0"
223 "\0";
224 
225 /*
226  * Syntax:
227  * "Mwm*resource_name: resource_value"
228  */
229 #undef Offset
230 #define Offset(field)	XtOffsetOf(MwmInternalInfo, field)
231 static XtResource mwm_resources[] =
232 {
233     {
234 	XmNautoKeyFocus, XmCAutoKeyFocus, XmRBoolean,
235 	sizeof(Boolean), Offset(auto_key_focus),
236 	XmRImmediate, (XtPointer)True
237     },
238     {
239 	XmNautoRaiseDelay, XmCAutoRaiseDelay, XmRInt,
240 	sizeof(Time), Offset(auto_raise_delay),
241 	XmRImmediate, (XtPointer)500
242     },
243     {
244 	XmNbitmapDirectory, XmCBitmapDirectory, XmRString,
245 	sizeof(String), Offset(bitmap_directory),
246 	XmRString, (XtPointer)MWM_ICONDIR
247     },
248     {
249 	XmNclientAutoPlace, XmCClientAutoPlace, XmRBoolean,
250 	sizeof(Boolean), Offset(client_auto_place),
251 	XmRImmediate, (XtPointer)True
252     },
253     {
254 	XmNcolormapFocusPolicy, XmCColormapFocusPolicy, XmRWmCFocus,
255 	sizeof(unsigned char), Offset(colormap_focus_policy),
256 	XmRString, (XtPointer)"keyboard"
257     },
258     {
259 	XmNconfigFile, XmCConfigFile, XmRString,
260 	sizeof(String), Offset(config_file),
261 	XmRImmediate, (XtPointer)HOME_MWMRC
262     },
263     {
264 	XmNdeiconifyKeyFocus, XmCDeiconifyKeyFocus, XmRBoolean,
265 	sizeof(Boolean), Offset(deiconify_key_focus),
266 	XmRImmediate, (XtPointer)True
267     },
268     {
269 	XmNclickTime, XmCClickTime, XmRInt,
270 	sizeof(Time), Offset(click_time),
271 	XmRImmediate, (XtPointer)100
272     },
273     {
274 	XmNdoubleClickTime, XmCDoubleClickTime, XmRInt,
275 	sizeof(Time), Offset(double_click_time),
276 	XmRCallProc, (XtPointer)_WmMultiClickTimeDefault
277     },
278     {
279 	XmNenableWarp, XmCEnableWarp, XmRBoolean,
280 	sizeof(Boolean), Offset(enable_warp),
281 	XmRImmediate, (XtPointer)True
282     },
283     {
284 	XmNenforceKeyFocus, XmCEnforceKeyFocus, XmRBoolean,
285 	sizeof(Boolean), Offset(enforce_key_focus),
286 	XmRImmediate, (XtPointer)True
287     },
288 #if 0
289     {
290 	XmNfreezeOnConfig, XmCFreezeOnConfig, XmRBoolean,
291     },
292 #endif
293     {
294 	XmNiconAutoPlace, XmCIconAutoPlace, XmRBoolean,
295 	sizeof(Boolean), Offset(icon_auto_place),
296 	XmRImmediate, (XtPointer)True
297     },
298 #if 0
299     {
300 	XmNiconBoxScheme, XmCIconBoxScheme,
301     },
302 #endif
303     {
304 	XmNiconClick, XmCIconClick, XmRBoolean,
305 	sizeof(Boolean), Offset(icon_click),
306 	XmRImmediate, (XtPointer)True
307     },
308     {
309 	XmNinteractivePlacement, XmCInteractivePlacement, XmRBoolean,
310 	sizeof(Boolean), Offset(interactive_placement),
311 	XmRImmediate, (XtPointer)False
312     },
313     {
314 	XmNkeyboardFocusPolicy, XmCKeyboardFocusPolicy, XmRWmKFocus,
315 	sizeof(unsigned char), Offset(keyboard_focus_policy),
316 	XmRString, (XtPointer)"explicit"
317     },
318     {
319 	XmNlowerOnIconify, XmCLowerOnIconify, XmRBoolean,
320 	sizeof(Boolean), Offset(lower_on_iconify),
321 	XmRImmediate, (XtPointer)True
322     },
323     {
324 	XmNmoveThreshold, XmCMoveThreshold, XmRDimension,
325 	sizeof(Dimension), Offset(move_threshold),
326 	XmRImmediate, (XtPointer)4
327     },
328     {
329 	XmNmultiScreen, XmCMultiScreen, XmRBoolean,
330 	sizeof(Boolean), Offset(multi_screen),
331 	XmRImmediate, (XtPointer)False
332     },
333     {
334 	XmNpassButtons, XmCPassButtons, XmRBoolean,
335 	sizeof(Boolean), Offset(pass_buttons),
336 	XmRImmediate, (XtPointer)False
337     },
338     {
339 	XmNpassSelectButton, XmCPassSelectButton, XmRBoolean,
340 	sizeof(Boolean), Offset(pass_selection_buttons),
341 	XmRImmediate, (XtPointer)False
342     },
343     {
344 	XmNpositionIsFrame, XmCPositionIsFrame, XmRBoolean,
345 	sizeof(Boolean), Offset(position_is_frame),
346 	XmRImmediate, (XtPointer)True
347     },
348     {
349 	XmNpositionOnScreen, XmCPositionOnScreen, XmRBoolean,
350 	sizeof(Boolean), Offset(position_on_screen),
351 	XmRImmediate, (XtPointer)True
352     },
353     {
354 	XmNquitTimeout, XmCQuitTimeout, XmRInt,
355 	sizeof(Time), Offset(quit_timeout),
356 	XmRImmediate, (XtPointer)1000
357     },
358     {
359 	XmNraiseKeyFocus, XmCRaiseKeyFocus, XmRBoolean,
360 	sizeof(Boolean), Offset(raise_key_focus),
361 	XmRImmediate, (XtPointer)False
362     },
363     {
364 	XmNscreens, XmCScreens, XmRString,
365 	sizeof(String), Offset(screens),
366 	XmRImmediate, (XtPointer)":0.0"
367     },
368     {
369 	XmNshowFeedback, XmCShowFeedback, XmRWmShowFeedback,
370 	sizeof(long), Offset(show_feedback),
371 	XmRString, (XtPointer)"all"
372     },
373     {
374 	XmNstartupKeyFocus, XmCStartupKeyFocus, XmRBoolean,
375 	sizeof(Boolean), Offset(startup_key_focus),
376 	XmRImmediate, (XtPointer)True
377     },
378     {
379 	XmNusePager, XmCUsePager, XmRBoolean,
380 	sizeof(Boolean), Offset(use_pager),
381 	XmRImmediate, (XtPointer)True
382     },
383     {
384 	XmNsmartPlacement, XmCSmartPlacement, XmRBoolean,
385 	sizeof(Boolean), Offset(smart_placement),
386 	XmRImmediate, (XtPointer)False
387     },
388     {
389 	XmNedgeScrollX, XmCEdgeScrollX, XmRInt,
390 	sizeof(int), Offset(edge_scroll_x),
391 	XmRImmediate, (XtPointer)XmUNSPECIFIED
392     },
393     {
394 	XmNedgeScrollY, XmCEdgeScrollY, XmRInt,
395 	sizeof(int), Offset(edge_scroll_y),
396 	XmRImmediate, (XtPointer)XmUNSPECIFIED
397     },
398     {
399 	XmNpagerX, XmCPagerX, XmRInt,
400 	sizeof(int), Offset(pager_x),
401 	XmRImmediate, (XtPointer)XmUNSPECIFIED
402     },
403     {
404 	XmNpagerY, XmCPagerY, XmRInt,
405 	sizeof(int), Offset(pager_y),
406 	XmRImmediate, (XtPointer)XmUNSPECIFIED
407     },
408     {
409 	XmNvirtualX, XmCVirtualX, XmRInt,
410 	sizeof(int), Offset(virtual_x),
411 	XmRImmediate, (XtPointer)3
412     },
413     {
414 	XmNvirtualY, XmCVirtualY, XmRInt,
415 	sizeof(int), Offset(virtual_y),
416 	XmRImmediate, (XtPointer)3
417     },
418     {
419 	XmNwMenuButtonClick, XmCWMenuButtonClick, XmRBoolean,
420 	sizeof(Boolean), Offset(w_menu_button_click),
421 	XmRImmediate, (XtPointer)True
422     },
423     {
424 	XmNwMenuButtonClick2, XmCWMenuButtonClick2, XmRBoolean,
425 	sizeof(Boolean), Offset(w_menu_button_click_2),
426 	XmRImmediate, (XtPointer)True
427     }
428 };
429 
430 /*
431  * Syntax:
432  * "Mwm*screen_name*resource_name: resource_value"
433  */
434 #undef Offset
435 #define Offset(field)   XtOffsetOf(ScreenInfo, field)
436 static XtResource mwm_screen_resources[] =
437 {
438     {
439 	XmNbuttonBindings, XmCButtonBindings, XmRString,
440 	sizeof(String), Offset(button_bindings),
441 	XmRString, (XtPointer)DEFAULT_BUTTON_BINDING_NAME
442     },
443     {
444 	XmNcleanText, XmCCleanText, XmRBoolean,
445 	sizeof(Boolean), Offset(clean_text),
446 	XmRImmediate, (XtPointer)False
447     },
448     {
449 	XmNfadeNormalIcon, XmCFadeNormalIcon, XmRBoolean,
450 	sizeof(Boolean), Offset(fade_normal_icon),
451 	XmRImmediate, (XtPointer)False
452     },
453     {
454 	XmNfeedbackGeometry, XmCFeedbackGeometry, XmRGeometry,
455 	sizeof(Geometry), Offset(feedback_geometry),
456 	XmRCallProc, (XtPointer)NULL
457     },
458     {
459 	XmNframeBorderWidth, XmCFrameBorderWidth, XmRDimension,
460 	sizeof(Dimension), Offset(frame_border_width),
461 	XmRCallProc, (XtPointer)_WmDefaultBorderWidth
462     },
463     {
464 	XmNiconBoxGeometry, XmCIconBoxGeometry, XmRGeometry,
465 	sizeof(Geometry), Offset(icon_box_geometry),
466 	XmRCallProc, (XtPointer)NULL
467     },
468     {
469 	XmNiconBoxName, XmCIconBoxName, XmRString,
470 	sizeof(String), Offset(icon_box_name),
471 	XmRImmediate, (XtPointer)"iconbox"
472     },
473     {
474 	XmNiconBoxSBDisplayPolicy, XmCIconBoxSBDisplayPolicy, XmRString,
475 	sizeof(String), Offset(icon_box_sb_display_policy),
476 	XmRImmediate, (XtPointer)"all"
477     },
478     {
479 	XmNiconBoxTitle, XmCIconBoxTitle, XmRXmString,
480 	sizeof(XmString), Offset(icon_box_title),
481 	XmRString, (XtPointer)"Icons"
482     },
483     {
484 	XmNiconDecoration, XmCIconDecoration, XmRWmIDecor,
485 	sizeof(long), Offset(icon_decoration),
486 	XmRString, (XtPointer)"activelabel label image"
487     },
488     {
489 	XmNiconImageMaximum, XmCIconImageMaximum, XmRWmSize,
490 	sizeof(Size), Offset(icon_image_maximum),
491 	XmRString, (XtPointer)"50x50"
492     },
493     {
494 	XmNiconImageMinimum, XmCIconImageMinimum, XmRWmSize,
495 	sizeof(Size), Offset(icon_image_minimum),
496 	XmRString, (XtPointer)"16x16"
497     },
498     {
499 	XmNiconPlacement, XmCIconPlacement, XmRWmIPlace,
500 	sizeof(unsigned char), Offset(icon_placement),
501 	XmRString, (XtPointer)"left bottom"
502     },
503     {
504 	XmNiconPlacementMargin, XmCIconPlacementMargin, XmRDimension,
505 	sizeof(Dimension), Offset(icon_placement_margin),
506 	XmRImmediate, (XtPointer)1
507     },
508     {
509 	XmNkeyBindings, XmCKeyBindings, XmRString,
510 	sizeof(String), Offset(key_bindings),
511 	XmRImmediate, (XtPointer)DEFAULT_KEY_BINDING_NAME
512     },
513     {
514 	XmNlimitResize, XmCLimitResize, XmRBoolean,
515 	sizeof(Boolean), Offset(limit_resize),
516 	XmRImmediate, (XtPointer)True
517     },
518     {
519 	XmNmaximumMaximumSize, XmCMaximumMaximumSize, XmRWmSize,
520 	sizeof(String), Offset(maximum_maximum_size),
521 	XmRCallProc, (XtPointer)NULL
522     },
523     {
524 	XmNmoveOpaque, XmCMoveOpaque, XmRBoolean,
525 	sizeof(Boolean), Offset(move_opaque),
526 	XmRImmediate, (XtPointer)False
527     },
528     {
529 	XmNresizeBorderWidth, XmCFrameBorderWidth, XmRDimension,
530 	sizeof(Dimension), Offset(resize_border_width),
531 	XmRCallProc, (XtPointer)_WmDefaultResizeBorderWidth
532     },
533     {
534 	XmNresizeCursors, XmCResizeCursors, XmRBoolean,
535 	sizeof(Boolean), Offset(resize_cursors),
536 	XmRImmediate, (XtPointer)True
537     },
538     {
539 	XmNtransientDecoration, XmCTransientDecoration, XmRWmCDecor,
540 	sizeof(long), Offset(transient_decoration),
541 	XmRString, (XtPointer)"menu title"
542     },
543     {
544 	XmNtransientFunctions, XmCTransientFunctions, XmRWmCFunc,
545 	sizeof(long), Offset(transient_functions),
546 	XmRString, (XtPointer)"-minimize maximize"
547     },
548     {
549 	XmNuseIconBox, XmCUseIconBox, XmRBoolean,
550 	sizeof(Boolean), Offset(use_icon_box),
551 	XmRImmediate, (XtPointer)False
552     }
553 };
554 
555 /*
556  * Syntax:
557  * "Mwm*client_name*resource_name: resource_value"
558  */
559 #undef Offset
560 #define Offset(field)	XtOffsetOf(MwmWindow, field)
561 static XtResource mwm_client_resources[] =
562 {
563     {
564 	XmNclientDecoration, XmCClientDecoration, XmRWmCDecor,
565 	sizeof(long), Offset(client_decoration),
566 	XmRString, (XtPointer)"all"
567     },
568     {
569 	XmNclientFunctions, XmCClientFunctions, XmRWmCFunc,
570 	sizeof(long), Offset(client_functions),
571 	XmRString, (XtPointer)"all"
572     },
573     {
574 	XmNclientFlags, XmCClientFlags, XmRWmCFlags,
575 	sizeof(long), Offset(flags),
576 	XmRString, (XtPointer)"none"
577     },
578     {
579 	XmNfocusAutoRaise, XmCFocusAutoRaise, XmRBoolean,
580 	sizeof(Boolean), Offset(focus_auto_raise),
581 	XmRCallProc, (XtPointer)_WmFocusAutoRaiseDefault
582     },
583     {
584 	XmNiconImage, XmCIconImage, XmRString,
585 	sizeof(String), Offset(icon_image),
586 	XmRImmediate, (XtPointer)NULL
587     },
588     {
589 	XmNiconImageBackground, XmCIconImageBackground, XmRPixel,
590 	sizeof(Pixel), Offset(icon_image_background),
591 	XmRCallProc, (XtPointer)_WmIconImageBDefault
592     },
593     {
594 	XmNiconImageBottomShadowColor, XmCIconImageBottomShadowColor, XmRPixel,
595 	sizeof(Pixel), Offset(icon_image_bottom_shadow_color),
596 	XmRCallProc, (XtPointer)_WmIconImageBSCDefault
597     },
598     {
599      XmNiconImageBottomShadowPixmap, XmCIconImageBottomShadowPixmap, XmRPixmap,
600 	sizeof(Pixmap), Offset(icon_image_bottom_shadow_pixmap),
601 	XmRCallProc, (XtPointer)_WmIconImageBSPDefault
602     },
603     {
604 	XmNiconImageForeground, XmCIconImageForeground, XmRPixel,
605 	sizeof(Pixel), Offset(icon_image_foreground),
606 	XmRCallProc, (XtPointer)_WmIconImageFDefault
607     },
608     {
609 	XmNiconImageTopShadowColor, XmCIconImageTopShadowColor, XmRPixel,
610 	sizeof(Pixel), Offset(icon_image_top_shadow_color),
611 	XmRCallProc, (XtPointer)_WmIconImageTSCDefault
612     },
613     {
614 	XmNiconImageTopShadowPixmap, XmCIconImageTopShadowPixmap, XmRPixmap,
615 	sizeof(Pixmap), Offset(icon_image_top_shadow_pixmap),
616 	XmRCallProc, (XtPointer)_WmIconImageTSPDefault
617     },
618     {
619 	XmNmatteBackground, XmCMatteBackground, XmRPixel,
620 	sizeof(Pixel), Offset(matte_background),
621 	XmRCallProc, (XtPointer)_WmMatteBDefault
622     },
623     {
624 	XmNmatteBottomShadowColor, XmCMatteBottomShadowColor, XmRPixel,
625 	sizeof(Pixel), Offset(matte_bottom_shadow_color),
626 	XmRCallProc, (XtPointer)_WmMatteBSCDefault
627     },
628     {
629 	XmNmatteBottomShadowPixmap, XmCMatteBottomShadowPixmap, XmRPixmap,
630 	sizeof(Pixmap), Offset(matte_bottom_shadow_pixmap),
631 	XmRCallProc, (XtPointer)_WmMatteBSPDefault
632     },
633     {
634 	XmNmatteForeground, XmCMatteForeground, XmRPixel,
635 	sizeof(Pixel), Offset(matte_foreground),
636 	XmRCallProc, (XtPointer)_WmMatteFDefault
637     },
638     {
639 	XmNmatteTopShadowColor, XmCMatteTopShadowColor, XmRPixel,
640 	sizeof(Pixel), Offset(matte_top_shadow_color),
641 	XmRCallProc, (XtPointer)_WmMatteTSCDefault
642     },
643     {
644 	XmNmatteTopShadowPixmap, XmCMatteTopShadowPixmap, XmRPixmap,
645 	sizeof(Pixmap), Offset(matte_top_shadow_pixmap),
646 	XmRCallProc, (XtPointer)_WmMatteTSPDefault
647     },
648     {
649 	XmNmatteWidth, XmCMatteWidth, XmRDimension,
650 	sizeof(Dimension), Offset(matte_width),
651 	XmRImmediate, (XtPointer)0
652     },
653     {
654 	XmNmaximumClientSize, XmCMaximumClientSize, XmRWmSize,
655 	sizeof(Size), Offset(maximum_client_size),
656 	XmRCallProc, (XtPointer)NULL
657     },
658     {
659 	XmNuseClientIcon, XmCUseClientIcon, XmRBoolean,
660 	sizeof(Boolean), Offset(use_client_icon),
661 	XmRImmediate, (XtPointer)False
662     },
663     {
664 	XmNusePPosition, XmCUsePPosition, XmRWmUsePPosition,
665 	sizeof(unsigned char), Offset(use_p_position),
666 	XmRString, (XtPointer)"nonzero"
667     },
668     {
669 	XmNwindowMenu, XmCWindowMenu, XmRString,
670 	sizeof(String), Offset(window_menu),
671 	XmRImmediate, (XtPointer)DEFAULT_WIN_MENU_NAME
672     }
673 };
674 
675 /*
676  * Syntax:
677  * "Mwm*[component_name]*resource_name: resource_value"
678  *
679  * BTW, just in case some copyrighters come along:  I got the function names
680  * by runnings "strings" on mwm on Solaris...
681  */
682 #undef Offset
683 #define Offset(field)	XtOffsetOf(ComponentInfo, field)
684 static XtResource mwm_component_resources[] =
685 {
686     {
687 	XmNbackground, XmCBackground, XmRPixel,
688 	sizeof(Pixel), Offset(background),
689 	XmRCallProc, (XtPointer)_WmBackgroundDefault
690     },
691     {
692 	XmNforeground, XmCForeground, XmRPixel,
693 	sizeof(XFontStruct *), Offset(foreground),
694 	XmRCallProc, (XtPointer)_WmForegroundDefault
695     },
696     {
697 	XmNbackgroundPixmap, XmCBackgroundPixmap, XmRPixmap,
698 	sizeof(Pixmap), Offset(background_pixmap),
699 	XmRCallProc, (XtPointer)_WmBackgroundPixmapDefault
700     },
701     {
702 	XmNbottomShadowColor, XmCBottomShadowColor, XmRPixel,
703 	sizeof(Pixel), Offset(bottom_shadow_color),
704 	XmRCallProc, (XtPointer)_WmBottomShadowColorDefault
705     },
706     {
707 	XmNbottomShadowPixmap, XmCBottomShadowPixmap, XmRPixmap,
708 	sizeof(Pixmap), Offset(bottom_shadow_pixmap),
709 	XmRCallProc, (XtPointer)_WmBottomShadowPixmapDefault
710     },
711     {
712 	XmNfontList, XmCFontList, XmRFontList,
713 	sizeof(XmFontList), Offset(font_list),
714 	XmRString, (XtPointer)"fixed"
715     },
716     {
717 	XmNsaveUnder, XmCSaveUnder, XmRBoolean,
718 	sizeof(Boolean), Offset(save_under),
719 	XmRImmediate, (XtPointer)False
720     },
721     {
722 	XmNtopShadowColor, XmCTopShadowColor, XmRPixel,
723 	sizeof(Pixel), Offset(top_shadow_color),
724 	XmRCallProc, (XtPointer)_WmTopShadowColorDefault
725     },
726     {
727 	XmNtopShadowPixmap, XmCTopShadowPixmap, XmRPixmap,
728 	sizeof(Pixmap), Offset(top_shadow_pixmap),
729 	XmRCallProc, (XtPointer)_WmTopShadowPixmapDefault
730     }
731 };
732 
733 /*
734  * frame/icon resources
735  */
736 #undef Offset
737 #define Offset(field)	XtOffsetOf(ComponentInfo, field)
738 static XtResource mwm_component_fi_resources[] =
739 {
740     {
741 	XmNactiveBackground, XmCBackground, XmRPixel,
742 	sizeof(Pixel), Offset(active_background),
743 	XmRCallProc, (XtPointer)_WmABackgroundDefault
744     },
745     {
746 	XmNactiveForeground, XmCBackground, XmRPixel,
747 	sizeof(Pixel), Offset(active_foreground),
748 	XmRCallProc, (XtPointer)_WmAForegroundDefault
749     },
750     {
751 	XmNactiveBottomShadowColor, XmCBackground, XmRPixel,
752 	sizeof(Pixel), Offset(active_bottom_shadow_color),
753 	XmRCallProc, (XtPointer)_WmABottomShadowColorDefault
754     },
755     {
756 	XmNactiveBottomShadowPixmap, XmCBottomShadowPixmap, XmRPixmap,
757 	sizeof(Pixmap), Offset(active_bottom_shadow_pixmap),
758 	XmRImmediate, (XtPointer)XmUNSPECIFIED_PIXMAP
759     },
760     {
761 	XmNactiveTopShadowColor, XmCBackground, XmRPixel,
762 	sizeof(Pixel), Offset(active_top_shadow_color),
763 	XmRCallProc, (XtPointer)_WmATopShadowColorDefault
764     },
765     {
766 	XmNactiveBackgroundPixmap, XmCBackgroundPixmap, XmRPixmap,
767 	sizeof(Pixmap), Offset(active_background_pixmap),
768 	XmRCallProc, (XtPointer)_WmABackgroundPixmapDefault
769     },
770     {
771 	XmNactiveTopShadowPixmap, XmCTopShadowPixmap, XmRPixmap,
772 	sizeof(Pixmap), Offset(active_top_shadow_pixmap),
773 	XmRCallProc, (XtPointer)_WmATopShadowPixmapDefault
774     }
775 };
776 
777 static char *
778   colormap_focus_policies[] =
779 {
780     "explicit",
781     "pointer",
782     "keyboard",
783     NULL
784 };
785 
786 static char *
787   client_decorations[] =
788 {
789     "all",
790     "border",
791     "resize",
792     "title",
793     "menu",
794     "minimize",
795     "maximize",
796     NULL
797 };
798 
799 static char *
800   client_functions[] =
801 {
802     "all",
803     "resize",
804     "move",
805     "minimize",
806     "maximize",
807     "close",
808     NULL
809 };
810 
811 static char *
812   icon_decorations[] =
813 {
814     "activelabel",
815     "image",
816     "label",
817     NULL
818 };
819 
820 static char *
821   icon_placements[] =
822 {
823     "top",
824     "bottom",
825     "left",
826     "right",
827     "tight",
828     NULL
829 };
830 
831 static char *
832   keyboard_focus_policies[] =
833 {
834     "explicit",
835     "pointer",
836     NULL
837 };
838 
839 static char *
840   show_feedback[] =
841 {
842     "all",
843     "behavior",
844     "kill",
845     "move",
846     "placement",
847     "quit",
848     "resize",
849     "restart",
850     NULL
851 };
852 
853 static char *
854   use_p_positions[] =
855 {
856     "on",
857     "off",
858     "nonzero",
859     NULL
860 };
861 
862 static char *
863   client_flags[] =
864 {
865     "sticky",
866     "circulate_skip",
867     "start_iconic",
868     "list_skip",
869     NULL
870 };
871 
872 static Boolean
WmCvtStringToCDecor(Display * dpy,XrmValuePtr args,Cardinal * num_args,XrmValuePtr from,XrmValuePtr to,XtPointer * data)873 WmCvtStringToCDecor(Display *dpy, XrmValuePtr args, Cardinal *num_args,
874 		    XrmValuePtr from, XrmValuePtr to, XtPointer *data)
875 {
876     static long val;
877     char *ptr;
878     int i;
879     Boolean reverse = False;
880 
881     if (*num_args != 0)
882     {
883 	XtWarningMsg("wrongParameters", "cvtStringToCDecor",
884 		     "XmToolkitError", "String to Client Decorations"
885 		     " conversion needs no extra arguments",
886 		     (String *)NULL, (Cardinal *)NULL);
887     }
888 
889     ptr = ((char *)(from->addr));
890 
891     if (strcmp(ptr, "all") == 0)
892     {
893 	val = MWM_DECOR_BORDER | MWM_DECOR_RESIZEH | MWM_DECOR_TITLE |
894 	    MWM_DECOR_MENU | MWM_DECOR_MAXIMIZE | MWM_DECOR_MINIMIZE;
895 
896 	if (to->addr == NULL)
897 	{
898 	    to->addr = (XPointer)&val;
899 	    to->size = sizeof(long);
900 	    return True;
901 	}
902 	else if (to->size >= sizeof(long))
903 	{
904 	    *((long *)to->addr) = val;
905 	    to->size = sizeof(long);
906 	    return True;
907 	}
908 	else
909 	{
910 	    XtDisplayStringConversionWarning(dpy, (char *)from->addr,
911 					     XmRWmCDecor);
912 	    return False;
913 	}
914     }
915 
916     if (strcmp(ptr, "none") == 0)
917     {
918 	val = 0;
919 	if (to->addr == NULL)
920 	{
921 	    to->addr = (XPointer)&val;
922 	    to->size = sizeof(long);
923 	    return True;
924 	}
925 	else if (to->size >= sizeof(long))
926 	{
927 	    *((long *)to->addr) = val;
928 	    to->size = sizeof(long);
929 	    return True;
930 	}
931 	else
932 	{
933 	    XtDisplayStringConversionWarning(dpy, (char *)from->addr,
934 					     XmRWmCDecor);
935 	    return False;
936 	}
937     }
938 
939     if (*ptr == '-')
940     {
941 	val = MWM_DECOR_BORDER | MWM_DECOR_RESIZEH | MWM_DECOR_TITLE |
942 	    MWM_DECOR_MENU | MWM_DECOR_MAXIMIZE | MWM_DECOR_MINIMIZE;
943 	reverse = True;
944     }
945     else
946 	val = 0;
947 
948     for (i = 0; client_decorations[i] != NULL; i++)
949     {
950 	if (strstr(ptr, client_decorations[i]) != NULL)
951 	{
952 	    if (reverse)
953 		val &= ~(1L << i);
954 	    else
955 		val |= (1L << i);
956 	}
957     }
958     if (to->addr == NULL)
959     {
960 	to->addr = (XPointer)&val;
961 	to->size = sizeof(long);
962 	return True;
963     }
964     else if (to->size >= sizeof(long))
965     {
966 	*((long *)to->addr) = val;
967 	to->size = sizeof(long);
968 	return True;
969     }
970     else
971     {
972 	XtDisplayStringConversionWarning(dpy, (char *)from->addr,
973 					 XmRWmCDecor);
974 	return False;
975     }
976 }
977 
978 static Boolean
WmCvtStringToCFocus(Display * dpy,XrmValuePtr args,Cardinal * num_args,XrmValuePtr from,XrmValuePtr to,XtPointer * data)979 WmCvtStringToCFocus(Display *dpy, XrmValuePtr args, Cardinal *num_args,
980 		    XrmValuePtr from, XrmValuePtr to, XtPointer *data)
981 {
982     static unsigned char val;
983     char *ptr;
984     int i;
985 
986     if (*num_args != 0)
987     {
988 	XtWarningMsg("wrongParameters", "cvtStringToCFocus",
989 		     "XmToolkitError", "String to Colormap Focus Policy"
990 		     " conversion needs no extra arguments",
991 		     (String *)NULL, (Cardinal *)NULL);
992     }
993 
994     ptr = ((char *)(from->addr));
995 
996     for (i = 0; colormap_focus_policies[i] != NULL; i++)
997     {
998 	if (strcmp(ptr, colormap_focus_policies[i]) == 0)
999 	{
1000 	    val = i;
1001 	    if (to->addr == NULL)
1002 	    {
1003 		to->addr = (XPointer)&val;
1004 		to->size = sizeof(unsigned char);
1005 		return True;
1006 	    }
1007 	    else if (to->size >= sizeof(unsigned char))
1008 	    {
1009 		*((unsigned char *)to->addr) = val;
1010 		to->size = sizeof(unsigned char);
1011 		return True;
1012 	    }
1013 	    else
1014 	    {
1015 		XtDisplayStringConversionWarning(dpy, (char *)from->addr,
1016 						 XmRWmCFocus);
1017 		return False;
1018 	    }
1019 	}
1020     }
1021     XtDisplayStringConversionWarning(dpy, (char *)from->addr, XmRWmCFocus);
1022     return False;
1023 }
1024 
1025 static Boolean
WmCvtStringToCFunc(Display * dpy,XrmValuePtr args,Cardinal * num_args,XrmValuePtr from,XrmValuePtr to,XtPointer * data)1026 WmCvtStringToCFunc(Display *dpy, XrmValuePtr args, Cardinal *num_args,
1027 		   XrmValuePtr from, XrmValuePtr to, XtPointer *data)
1028 {
1029     static long val;
1030     char *ptr;
1031     int i;
1032     Boolean reverse = False;
1033 
1034     if (*num_args != 0)
1035     {
1036 	XtWarningMsg("wrongParameters", "cvtStringToCFunc",
1037 		     "XmToolkitError", "String to Client Functions"
1038 		     " conversion needs no extra arguments",
1039 		     (String *)NULL, (Cardinal *)NULL);
1040     }
1041 
1042     ptr = ((char *)(from->addr));
1043 
1044     if (strcmp(ptr, "all") == 0)
1045     {
1046 	val = MWM_FUNC_RESIZE | MWM_FUNC_MOVE | MWM_FUNC_MINIMIZE |
1047 	    MWM_FUNC_MAXIMIZE | MWM_FUNC_CLOSE;
1048 	if (to->addr == NULL)
1049 	{
1050 	    to->addr = (XPointer)&val;
1051 	    to->size = sizeof(long);
1052 	    return True;
1053 	}
1054 	else if (to->size >= sizeof(long))
1055 	{
1056 	    *((long *)to->addr) = val;
1057 	    to->size = sizeof(long);
1058 	    return True;
1059 	}
1060 	else
1061 	{
1062 	    XtDisplayStringConversionWarning(dpy, (char *)from->addr,
1063 					     XmRWmCFunc);
1064 	    return False;
1065 	}
1066     }
1067 
1068     if (strcmp(ptr, "none") == 0)
1069     {
1070 	val = 0;
1071 	if (to->addr == NULL)
1072 	{
1073 	    to->addr = (XPointer)&val;
1074 	    to->size = sizeof(long);
1075 	    return True;
1076 	}
1077 	else if (to->size >= sizeof(long))
1078 	{
1079 	    *((long *)to->addr) = val;
1080 	    to->size = sizeof(long);
1081 	    return True;
1082 	}
1083 	else
1084 	{
1085 	    XtDisplayStringConversionWarning(dpy, (char *)from->addr,
1086 					     XmRWmCFunc);
1087 	    return False;
1088 	}
1089     }
1090 
1091     if (*ptr == '-')
1092     {
1093 	val = MWM_FUNC_RESIZE | MWM_FUNC_MOVE | MWM_FUNC_MINIMIZE |
1094 	    MWM_FUNC_MAXIMIZE | MWM_FUNC_CLOSE;
1095 	reverse = True;
1096     }
1097     else
1098 	val = 0;
1099 
1100     for (i = 0; client_functions[i] != NULL; i++)
1101     {
1102 	if (strstr(ptr, client_functions[i]) != NULL)
1103 	{
1104 	    if (reverse)
1105 		val &= ~(1L << i);
1106 	    else
1107 		val |= (1L << i);
1108 	}
1109     }
1110     if (to->addr == NULL)
1111     {
1112 	to->addr = (XPointer)&val;
1113 	to->size = sizeof(long);
1114 	return True;
1115     }
1116     else if (to->size >= sizeof(long))
1117     {
1118 	*((long *)to->addr) = val;
1119 	to->size = sizeof(long);
1120 	return True;
1121     }
1122     else
1123     {
1124 	XtDisplayStringConversionWarning(dpy, (char *)from->addr,
1125 					 XmRWmCFunc);
1126 	return False;
1127     }
1128 }
1129 
1130 static Boolean
WmCvtStringToCFlags(Display * dpy,XrmValuePtr args,Cardinal * num_args,XrmValuePtr from,XrmValuePtr to,XtPointer * data)1131 WmCvtStringToCFlags(Display *dpy, XrmValuePtr args, Cardinal *num_args,
1132 		    XrmValuePtr from, XrmValuePtr to, XtPointer *data)
1133 {
1134     static long val;
1135     char *ptr;
1136     int i;
1137 
1138     if (*num_args != 0)
1139     {
1140 	XtWarningMsg("wrongParameters", "cvtStringToCFlags",
1141 		     "XmToolkitError", "String to Client Flags"
1142 		     " conversion needs no extra arguments",
1143 		     (String *)NULL, (Cardinal *)NULL);
1144     }
1145 
1146     ptr = ((char *)(from->addr));
1147 
1148     if (strcmp(ptr, "all") == 0)
1149     {
1150 	val = STICKY | CIRCULATESKIP | STARTICONIC | WINDOWLISTSKIP;
1151 	if (to->addr == NULL)
1152 	{
1153 	    to->addr = (XPointer)&val;
1154 	    to->size = sizeof(long);
1155 	    return True;
1156 	}
1157 	else if (to->size >= sizeof(long))
1158 	{
1159 	    *((long *)to->addr) = val;
1160 	    to->size = sizeof(long);
1161 	    return True;
1162 	}
1163 	else
1164 	{
1165 	    XtDisplayStringConversionWarning(dpy, (char *)from->addr,
1166 					     XmRWmCFlags);
1167 	    return False;
1168 	}
1169     }
1170 
1171     if (strcmp(ptr, "none") == 0)
1172     {
1173 	val = 0;
1174 	if (to->addr == NULL)
1175 	{
1176 	    to->addr = (XPointer)&val;
1177 	    to->size = sizeof(long);
1178 	    return True;
1179 	}
1180 	else if (to->size >= sizeof(long))
1181 	{
1182 	    *((long *)to->addr) = val;
1183 	    to->size = sizeof(long);
1184 	    return True;
1185 	}
1186 	else
1187 	{
1188 	    XtDisplayStringConversionWarning(dpy, (char *)from->addr,
1189 					     XmRWmCFlags);
1190 	    return False;
1191 	}
1192     }
1193 
1194     for (i = 0; client_flags[i] != NULL; i++)
1195     {
1196 	if (strstr(ptr, client_flags[i]) != NULL)
1197 	{
1198 	    val |= (1L << i);
1199 	}
1200     }
1201     if (to->addr == NULL)
1202     {
1203 	to->addr = (XPointer)&val;
1204 	to->size = sizeof(long);
1205 	return True;
1206     }
1207     else if (to->size >= sizeof(long))
1208     {
1209 	*((long *)to->addr) = val;
1210 	to->size = sizeof(long);
1211 	return True;
1212     }
1213     else
1214     {
1215 	XtDisplayStringConversionWarning(dpy, (char *)from->addr,
1216 					 XmRWmCFlags);
1217 	return False;
1218     }
1219 }
1220 
1221 static Boolean
WmCvtStringToIDecor(Display * dpy,XrmValuePtr args,Cardinal * num_args,XrmValuePtr from,XrmValuePtr to,XtPointer * data)1222 WmCvtStringToIDecor(Display *dpy, XrmValuePtr args, Cardinal *num_args,
1223 		    XrmValuePtr from, XrmValuePtr to, XtPointer *data)
1224 {
1225     static long val;
1226     char *ptr;
1227     int i;
1228 
1229     if (*num_args != 0)
1230     {
1231 	XtWarningMsg("wrongParameters", "cvtStringToIDecor",
1232 		     "XmToolkitError", "String to Icon Decorations"
1233 		     " conversion needs no extra arguments",
1234 		     (String *)NULL, (Cardinal *)NULL);
1235     }
1236 
1237     val = 0;
1238     ptr = ((char *)(from->addr));
1239     for (i = 0; icon_decorations[i] != NULL; i++)
1240     {
1241 	if (strstr(ptr, icon_decorations[i]) != 0)
1242 	{
1243 	    val |= (1L << i);
1244 	}
1245     }
1246     if (val == 0)
1247     {
1248 	XtDisplayStringConversionWarning(dpy, (char *)from->addr, XmRWmIPlace);
1249 	return False;
1250     }
1251     if (to->addr == NULL)
1252     {
1253 	to->addr = (XPointer)&val;
1254 	to->size = sizeof(long);
1255 	return True;
1256     }
1257     else if (to->size >= sizeof(long))
1258     {
1259 	*((long *)to->addr) = val;
1260 	to->size = sizeof(long);
1261 	return True;
1262     }
1263     else
1264     {
1265 	XtDisplayStringConversionWarning(dpy, (char *)from->addr,
1266 					 XmRWmCFlags);
1267 	return False;
1268     }
1269 }
1270 
1271 static Boolean
WmCvtStringToIPlace(Display * dpy,XrmValuePtr args,Cardinal * num_args,XrmValuePtr from,XrmValuePtr to,XtPointer * data)1272 WmCvtStringToIPlace(Display *dpy, XrmValuePtr args, Cardinal *num_args,
1273 		    XrmValuePtr from, XrmValuePtr to, XtPointer *data)
1274 {
1275     static unsigned char val;
1276     char *ptr;
1277     int i;
1278 
1279     if (*num_args != 0)
1280     {
1281 	XtWarningMsg("wrongParameters", "cvtStringToIPlace",
1282 		     "XmToolkitError", "String to Icon Placement"
1283 		     " conversion needs no extra arguments",
1284 		     (String *)NULL, (Cardinal *)NULL);
1285     }
1286 
1287     ptr = ((char *)(from->addr));
1288 
1289     val = 0;
1290     for (i = 0; icon_placements[i] != NULL; i++)
1291     {
1292 	if (strstr(ptr, icon_placements[i]) != NULL)
1293 	{
1294 	    val |= (1L << i);
1295 	}
1296     }
1297     if (val == 0)
1298     {
1299 	XtDisplayStringConversionWarning(dpy, (char *)from->addr, XmRWmIPlace);
1300 	return False;
1301     }
1302     if (to->addr == NULL)
1303     {
1304 	to->addr = (XPointer)&val;
1305 	to->size = sizeof(unsigned char);
1306 	return True;
1307     }
1308     else if (to->size >= sizeof(unsigned char))
1309     {
1310 	*((long *)to->addr) = val;
1311 	to->size = sizeof(unsigned char);
1312 	return True;
1313     }
1314     else
1315     {
1316 	XtDisplayStringConversionWarning(dpy, (char *)from->addr,
1317 					 XmRWmIPlace);
1318 	return False;
1319     }
1320 }
1321 
1322 static Boolean
WmCvtStringToKFocus(Display * dpy,XrmValuePtr args,Cardinal * num_args,XrmValuePtr from,XrmValuePtr to,XtPointer * data)1323 WmCvtStringToKFocus(Display *dpy, XrmValuePtr args, Cardinal *num_args,
1324 		    XrmValuePtr from, XrmValuePtr to, XtPointer *data)
1325 {
1326     static unsigned char val;
1327     char *ptr;
1328     int i;
1329 
1330     if (*num_args != 0)
1331     {
1332 	XtWarningMsg("wrongParameters", "cvtStringToKFocus",
1333 		     "XmToolkitError", "String to Keyboard Focus Policy"
1334 		     " conversion needs no extra arguments",
1335 		     (String *)NULL, (Cardinal *)NULL);
1336     }
1337 
1338     ptr = ((char *)(from->addr));
1339 
1340     for (i = 0; keyboard_focus_policies[i] != NULL; i++)
1341     {
1342 	if (strcmp(ptr, keyboard_focus_policies[i]) == 0)
1343 	{
1344 	    val = i;
1345 	    if (to->addr == NULL)
1346 	    {
1347 		to->addr = (XPointer)&val;
1348 		to->size = sizeof(unsigned char);
1349 		return True;
1350 	    }
1351 	    else if (to->size >= sizeof(unsigned char))
1352 	    {
1353 		*((unsigned char *)to->addr) = val;
1354 		to->size = sizeof(unsigned char);
1355 		return True;
1356 	    }
1357 	    else
1358 	    {
1359 		XtDisplayStringConversionWarning(dpy, (char *)from->addr,
1360 						 XmRWmKFocus);
1361 		return False;
1362 	    }
1363 	}
1364     }
1365     XtDisplayStringConversionWarning(dpy, (char *)from->addr, XmRWmKFocus);
1366     return False;
1367 }
1368 
1369 static Boolean
WmCvtStringToShowFeedback(Display * dpy,XrmValuePtr args,Cardinal * num_args,XrmValuePtr from,XrmValuePtr to,XtPointer * data)1370 WmCvtStringToShowFeedback(Display *dpy, XrmValuePtr args, Cardinal *num_args,
1371 			  XrmValuePtr from, XrmValuePtr to, XtPointer *data)
1372 {
1373     static long val;
1374     char *ptr;
1375     int i;
1376     Boolean reverse = False;
1377 
1378     if (*num_args != 0)
1379     {
1380 	XtWarningMsg("wrongParameters", "cvtStringToShowFeedback",
1381 		     "XmToolkitError", "String to Show Feedback"
1382 		     " conversion needs no extra arguments",
1383 		     (String *)NULL, (Cardinal *)NULL);
1384     }
1385 
1386     ptr = ((char *)(from->addr));
1387 
1388     if (strcmp(ptr, "all") == 0)
1389     {
1390 	val = MWM_FEEDBACK_BEHAVIOR | MWM_FEEDBACK_KILL | MWM_FEEDBACK_MOVE |
1391 	    MWM_FEEDBACK_PLACEMENT | MWM_FEEDBACK_QUIT | MWM_FEEDBACK_RESIZE |
1392 	    MWM_FEEDBACK_RESTART;
1393 	if (to->addr == NULL)
1394 	{
1395 	    to->addr = (XPointer)&val;
1396 	    to->size = sizeof(long);
1397 	    return True;
1398 	}
1399 	else if (to->size >= sizeof(long))
1400 	{
1401 	    *((long *)to->addr) = val;
1402 	    to->size = sizeof(long);
1403 	    return True;
1404 	}
1405 	else
1406 	{
1407 	    XtDisplayStringConversionWarning(dpy, (char *)from->addr,
1408 					     XmRWmShowFeedback);
1409 	    return False;
1410 	}
1411     }
1412 
1413     if (strcmp(ptr, "none") == 0)
1414     {
1415 	val = 0;
1416 	if (to->addr == NULL)
1417 	{
1418 	    to->addr = (XPointer)&val;
1419 	    to->size = sizeof(long);
1420 	    return True;
1421 	}
1422 	else if (to->size >= sizeof(long))
1423 	{
1424 	    *((long *)to->addr) = val;
1425 	    to->size = sizeof(long);
1426 	    return True;
1427 	}
1428 	else
1429 	{
1430 	    XtDisplayStringConversionWarning(dpy, (char *)from->addr,
1431 					     XmRWmShowFeedback);
1432 	    return False;
1433 	}
1434     }
1435 
1436     if (*ptr == '-')
1437     {
1438 	val = MWM_FEEDBACK_BEHAVIOR | MWM_FEEDBACK_KILL | MWM_FEEDBACK_MOVE |
1439 	    MWM_FEEDBACK_PLACEMENT | MWM_FEEDBACK_QUIT | MWM_FEEDBACK_RESIZE |
1440 	    MWM_FEEDBACK_RESTART;
1441 	reverse = True;
1442     }
1443     else
1444 	val = 0;
1445 
1446     for (i = 0; show_feedback[i] != NULL; i++)
1447     {
1448 	if (strstr(ptr, show_feedback[i]) != NULL)
1449 	{
1450 	    if (reverse)
1451 		val &= ~(1L << i);
1452 	    else
1453 		val |= (1L << i);
1454 	}
1455     }
1456     if (to->addr == NULL)
1457     {
1458 	to->addr = (XPointer)&val;
1459 	to->size = sizeof(long);
1460 	return True;
1461     }
1462     else if (to->size >= sizeof(long))
1463     {
1464 	*((long *)to->addr) = val;
1465 	to->size = sizeof(long);
1466 	return True;
1467     }
1468     else
1469     {
1470 	XtDisplayStringConversionWarning(dpy, (char *)from->addr,
1471 					 XmRWmShowFeedback);
1472 	return False;
1473     }
1474 }
1475 
1476 static Boolean
WmCvtStringToSize(Display * dpy,XrmValuePtr args,Cardinal * num_args,XrmValuePtr from,XrmValuePtr to,XtPointer * data)1477 WmCvtStringToSize(Display *dpy, XrmValuePtr args, Cardinal *num_args,
1478 		  XrmValuePtr from, XrmValuePtr to, XtPointer *data)
1479 {
1480     static Size val;
1481     char *ptr;
1482 
1483     if (*num_args != 0)
1484     {
1485 	XtWarningMsg("wrongParameters", "cvtStringToSize",
1486 		     "XmToolkitError", "String to Size"
1487 		     " conversion needs no extra arguments",
1488 		     (String *)NULL, (Cardinal *)NULL);
1489     }
1490 
1491     ptr = ((char *)(from->addr));
1492 
1493     memset((void *)&val, 0, sizeof(Size));
1494     if (sscanf(ptr, "%hdx%hd", &val.width, &val.height) == 2)
1495     {
1496 	if (to->addr == NULL)
1497 	{
1498 	    to->addr = (XPointer)&val;
1499 	    to->size = sizeof(Size);
1500 	    return True;
1501 	}
1502 	else if (to->size >= sizeof(Size))
1503 	{
1504 	    *((Size *)to->addr) = val;
1505 	    to->size = sizeof(Size);
1506 	    return True;
1507 	}
1508 	else
1509 	{
1510 	    XtDisplayStringConversionWarning(dpy, (char *)from->addr,
1511 					     XmRWmSize);
1512 	    return False;
1513 	}
1514     }
1515     XtDisplayStringConversionWarning(dpy, (char *)from->addr, XmRWmSize);
1516     return False;
1517 }
1518 
1519 static Boolean
WmCvtStringToUsePPosition(Display * dpy,XrmValuePtr args,Cardinal * num_args,XrmValuePtr from,XrmValuePtr to,XtPointer * data)1520 WmCvtStringToUsePPosition(Display *dpy, XrmValuePtr args, Cardinal *num_args,
1521 			  XrmValuePtr from, XrmValuePtr to, XtPointer *data)
1522 {
1523     static unsigned char val;
1524     char *ptr;
1525     int i;
1526 
1527     if (*num_args != 0)
1528     {
1529 	XtWarningMsg("wrongParameters", "cvtStringToUsePPosition",
1530 		     "XmToolkitError", "String to Use PPosition"
1531 		     " conversion needs no extra arguments",
1532 		     (String *)NULL, (Cardinal *)NULL);
1533     }
1534 
1535     ptr = ((char *)(from->addr));
1536 
1537     for (i = 0; use_p_positions[i] != NULL; i++)
1538     {
1539 	if (strcmp(ptr, use_p_positions[i]) == 0)
1540 	{
1541 	    val = i;
1542 	    if (to->addr == NULL)
1543 	    {
1544 		to->addr = (XPointer)&val;
1545 		to->size = sizeof(unsigned char);
1546 		return True;
1547 	    }
1548 	    else if (to->size >= sizeof(unsigned char))
1549 	    {
1550 		*((unsigned char *)to->addr) = val;
1551 		to->size = sizeof(unsigned char);
1552 		return True;
1553 	    }
1554 	    else
1555 	    {
1556 		XtDisplayStringConversionWarning(dpy, (char *)from->addr,
1557 						 XmRWmUsePPosition);
1558 		return False;
1559 	    }
1560 	}
1561     }
1562     XtDisplayStringConversionWarning(dpy, (char *)from->addr, XmRWmUsePPosition);
1563     return False;
1564 }
1565 
1566 /*
1567  * get resources for a client window
1568  */
1569 void
RES_GetClientDefaults(ScreenInfo * scr,MwmWindow * tmp_win,char * name_s,char * class_s)1570 RES_GetClientDefaults(ScreenInfo *scr, MwmWindow *tmp_win,
1571 		      char *name_s, char *class_s)
1572 {
1573     working_base = tmp_win;
1574     rscr = scr;
1575     XtGetSubresources(toplevel, (XtPointer)tmp_win,
1576 		      name_s, class_s,
1577 		      mwm_client_resources,
1578 		      XtNumber(mwm_client_resources), NULL, 0);
1579 }
1580 
1581 void
RES_Initialize(void)1582 RES_Initialize(void)
1583 {
1584     XmRegisterConverters();
1585 
1586     XtSetTypeConverter(XmRString,
1587 		       XmRWmCDecor,
1588 		       WmCvtStringToCDecor,
1589 		       (XtConvertArgList)NULL,
1590 		       0,
1591 		       XtCacheAll,
1592 		       NULL);
1593 
1594     XtSetTypeConverter(XmRString,
1595 		       XmRWmCFocus,
1596 		       WmCvtStringToCFocus,
1597 		       (XtConvertArgList)NULL,
1598 		       0,
1599 		       XtCacheAll,
1600 		       NULL);
1601 
1602     XtSetTypeConverter(XmRString,
1603 		       XmRWmCFunc,
1604 		       WmCvtStringToCFunc,
1605 		       (XtConvertArgList)NULL,
1606 		       0,
1607 		       XtCacheAll,
1608 		       NULL);
1609 
1610     XtSetTypeConverter(XmRString,
1611 		       XmRWmIDecor,
1612 		       WmCvtStringToIDecor,
1613 		       (XtConvertArgList)NULL,
1614 		       0,
1615 		       XtCacheAll,
1616 		       NULL);
1617 
1618     XtSetTypeConverter(XmRString,
1619 		       XmRWmIPlace,
1620 		       WmCvtStringToIPlace,
1621 		       (XtConvertArgList)NULL,
1622 		       0,
1623 		       XtCacheAll,
1624 		       NULL);
1625 
1626     XtSetTypeConverter(XmRString,
1627 		       XmRWmKFocus,
1628 		       WmCvtStringToKFocus,
1629 		       (XtConvertArgList)NULL,
1630 		       0,
1631 		       XtCacheAll,
1632 		       NULL);
1633 
1634     XtSetTypeConverter(XmRString,
1635 		       XmRWmShowFeedback,
1636 		       WmCvtStringToShowFeedback,
1637 		       (XtConvertArgList)NULL,
1638 		       0,
1639 		       XtCacheAll,
1640 		       NULL);
1641 
1642     XtSetTypeConverter(XmRString,
1643 		       XmRWmSize,
1644 		       WmCvtStringToSize,
1645 		       (XtConvertArgList)NULL,
1646 		       0,
1647 		       XtCacheAll,
1648 		       NULL);
1649 
1650     XtSetTypeConverter(XmRString,
1651 		       XmRWmUsePPosition,
1652 		       WmCvtStringToUsePPosition,
1653 		       (XtConvertArgList)NULL,
1654 		       0,
1655 		       XtCacheAll,
1656 		       NULL);
1657 
1658     XtSetTypeConverter(XmRString,
1659 		       XmRWmCFlags,
1660 		       WmCvtStringToCFlags,
1661 		       (XtConvertArgList)NULL,
1662 		       0,
1663 		       XtCacheAll,
1664 		       NULL);
1665 
1666     XtGetApplicationResources(toplevel, (XtPointer)&Mwm,
1667 			      mwm_resources, XtNumber(mwm_resources), NULL, 0);
1668 }
1669 
1670 /*
1671  * get the resources for each screen
1672  */
1673 void
RES_GetScreenDefaults(ScreenInfo * scr)1674 RES_GetScreenDefaults(ScreenInfo *scr)
1675 {
1676     rscr = scr;
1677 #if 0
1678     /*FIXME: do we need this here? A.R.*/
1679     working_base = scr;
1680 #endif
1681     XtGetSubresources(toplevel, (XtPointer)scr,
1682                       scr->screen_name, scr->screen_name,
1683                       mwm_screen_resources,
1684                       XtNumber(mwm_screen_resources), NULL, 0);
1685 }
1686 
1687 /*
1688  * get the resources for the components in each screen
1689  */
1690 void
RES_GetComponentDefaults(ScreenInfo * scr)1691 RES_GetComponentDefaults(ScreenInfo *scr)
1692 {
1693     Widget client;
1694 
1695     /*
1696      * MLM: OK, seems the resource manager won't pay attention to me if
1697      * I ask it to find recursive structures.  This is a hack, and I'd
1698      * appreciate it if someone would correct the name/class values so
1699      * I don't have to do this.
1700      */
1701     rscr = scr;
1702     working_base = &(scr->components[MWM_MENU]);
1703     scr->components[MWM_MENU].type = MWM_MENU;
1704     XtGetSubresources(toplevel, (XtPointer)&(scr->components[MWM_MENU]),
1705 		      "menu", "menu",
1706 		      mwm_component_resources,
1707 		      XtNumber(mwm_component_resources), NULL, 0);
1708 
1709     working_base = &(scr->components[MWM_FEEDBACK]);
1710     scr->components[MWM_FEEDBACK].type = MWM_FEEDBACK;
1711     XtGetSubresources(toplevel, (XtPointer)&(scr->components[MWM_FEEDBACK]),
1712 		      "feedback", "feedback",
1713 		      mwm_component_resources,
1714 		      XtNumber(mwm_component_resources), NULL, 0);
1715 
1716     working_base = &(scr->components[MWM_PAGER]);
1717     scr->components[MWM_PAGER].type = MWM_PAGER;
1718     XtGetSubresources(toplevel, (XtPointer)&(scr->components[MWM_PAGER]),
1719 		      "pager", "pager",
1720 		      mwm_component_resources,
1721 		      XtNumber(mwm_component_resources), NULL, 0);
1722 
1723     working_base = &(scr->components[MWM_ICON]);
1724     scr->components[MWM_ICON].type = MWM_ICON;
1725     XtGetSubresources(toplevel, (XtPointer)&(scr->components[MWM_ICON]),
1726 		      "icon", "icon",
1727 		      mwm_component_resources,
1728 		      XtNumber(mwm_component_resources), NULL, 0);
1729     XtGetSubresources(toplevel, (XtPointer)&(scr->components[MWM_ICON]),
1730 		      "icon", "icon",
1731 		      mwm_component_fi_resources,
1732 		      XtNumber(mwm_component_fi_resources), NULL, 0);
1733 
1734     client = XtVaCreateWidget("client", (WidgetClass)&objectClassRec,
1735 			      toplevel, NULL);
1736 
1737     working_base = &(scr->components[MWM_TITLE_A]);
1738     scr->components[MWM_TITLE_A].type = MWM_TITLE_A;
1739     XtGetSubresources(client, (XtPointer)working_base,
1740 		      "title", "title",
1741 		      mwm_component_resources,
1742 		      XtNumber(mwm_component_resources), NULL, 0);
1743     XtGetSubresources(client, (XtPointer)working_base,
1744 		      "title", "title",
1745 		      mwm_component_fi_resources,
1746 		      XtNumber(mwm_component_fi_resources), NULL, 0);
1747 
1748     working_base = &(scr->components[MWM_RESIZE_H]);
1749     scr->components[MWM_RESIZE_H].type = MWM_RESIZE_H;
1750     XtGetSubresources(client, (XtPointer)working_base,
1751 		      "resizeh", "resizeh",
1752 		      mwm_component_resources,
1753 		      XtNumber(mwm_component_resources), NULL, 0);
1754     XtGetSubresources(client, (XtPointer)working_base,
1755 		      "resizeh", "resizeh",
1756 		      mwm_component_fi_resources,
1757 		      XtNumber(mwm_component_fi_resources), NULL, 0);
1758 
1759     working_base = &(scr->components[MWM_BORDER]);
1760     scr->components[MWM_BORDER].type = MWM_BORDER;
1761     XtGetSubresources(client, (XtPointer)working_base,
1762 		      "border", "border",
1763 		      mwm_component_resources,
1764 		      XtNumber(mwm_component_resources), NULL, 0);
1765     XtGetSubresources(client, (XtPointer)working_base,
1766 		      "border", "border",
1767 		      mwm_component_fi_resources,
1768 		      XtNumber(mwm_component_fi_resources), NULL, 0);
1769 
1770     working_base = &(scr->components[MWM_MAXIMIZE_B]);
1771     scr->components[MWM_MAXIMIZE_B].type = MWM_MAXIMIZE_B;
1772     XtGetSubresources(client, (XtPointer)working_base,
1773 		      "maximizeb", "maximizeb",
1774 		      mwm_component_resources,
1775 		      XtNumber(mwm_component_resources), NULL, 0);
1776     XtGetSubresources(client, (XtPointer)working_base,
1777 		      "maximizeb", "maximizeb",
1778 		      mwm_component_fi_resources,
1779 		      XtNumber(mwm_component_fi_resources), NULL, 0);
1780 
1781     working_base = &(scr->components[MWM_MINIMIZE_B]);
1782     scr->components[MWM_MINIMIZE_B].type = MWM_MINIMIZE_B;
1783     XtGetSubresources(client, (XtPointer)working_base,
1784 		      "minimizeb", "minimizeb",
1785 		      mwm_component_resources,
1786 		      XtNumber(mwm_component_resources), NULL, 0);
1787     XtGetSubresources(client, (XtPointer)working_base,
1788 		      "minimizeb", "minimizeb",
1789 		      mwm_component_fi_resources,
1790 		      XtNumber(mwm_component_fi_resources), NULL, 0);
1791 
1792     working_base = &(scr->components[MWM_MENU_B]);
1793     scr->components[MWM_MENU_B].type = MWM_MENU_B;
1794     XtGetSubresources(client, (XtPointer)working_base,
1795 		      "menub", "menub",
1796 		      mwm_component_resources,
1797 		      XtNumber(mwm_component_resources), NULL, 0);
1798     XtGetSubresources(client, (XtPointer)working_base,
1799 		      "menub", "menub",
1800 		      mwm_component_fi_resources,
1801 		      XtNumber(mwm_component_fi_resources), NULL, 0);
1802 }
1803