2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
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
23 /************************************<+>*************************************
24 ****************************************************************************
30 ** Description: Controls the Dtstyle Window Manager customization dialog
33 ** (c) Copyright Hewlett-Packard Company, 1990, 1993.
37 ****************************************************************************
38 ************************************<+>*************************************/
39 /* $XConsortium: Dtwm.c /main/4 1995/10/30 13:09:13 rswiston $ */
40 /*+++++++++++++++++++++++++++++++++++++++*/
42 /*+++++++++++++++++++++++++++++++++++++++*/
46 #include <Xm/MwmUtil.h>
51 #include <Xm/LabelG.h>
52 #include <Xm/PushBG.h>
53 #include <Xm/RowColumn.h>
54 #include <Xm/ToggleBG.h>
55 #include <Xm/SeparatoG.h>
56 #include <Xm/VendorSEP.h>
57 #include <Xm/MessageB.h>
59 #include <Dt/DialogBox.h>
61 #include <Dt/TitleBox.h>
63 #include <Dt/Message.h>
64 #include <Dt/HourGlass.h>
69 #include "SaveRestore.h"
74 /*+++++++++++++++++++++++++++++++++++++++*/
75 /* include extern functions */
76 /*+++++++++++++++++++++++++++++++++++++++*/
79 /*+++++++++++++++++++++++++++++++++++++++*/
81 /*+++++++++++++++++++++++++++++++++++++++*/
85 #define POINTER_STR "pointer"
86 #define EXPLICIT_STR "explicit"
88 #define NUM_PLACEMENT_ICONS 8
92 #define BOTTOM_RIGHT 3
96 #define RIGHT_BOTTOM 7
97 #define WARN_MSG ((char *)GETMESSAGE(18, 12, "The workspace manager must be restarted in\n\
98 order for your changes to take effect.\n\
99 Press OK to restart the workspace manager\n\
100 or Cancel to reset the changes."))
102 /*+++++++++++++++++++++++++++++++++++++++*/
103 /* Internal Functions */
104 /*+++++++++++++++++++++++++++++++++++++++*/
106 static Widget build_dtwmDlg ( Widget shell ) ;
107 static void formLayoutCB ( Widget, XtPointer, XtPointer ) ;
108 static void _DtmapCB_dtwmDlg ( Widget, XtPointer, XtPointer ) ;
109 static void systemDefaultCB ( Widget, XtPointer, XtPointer ) ;
110 static void ButtonCB ( Widget, XtPointer, XtPointer ) ;
111 static void getDtwmValues ( ) ;
112 static void _DtWmParseToLower (unsigned char *string) ;
113 static void okWarnCB ( Widget, XtPointer, XtPointer ) ;
114 static void cancelWarnCB ( Widget, XtPointer, XtPointer ) ;
116 /*+++++++++++++++++++++++++++++++++++++++*/
117 /* Internal Variables */
118 /*+++++++++++++++++++++++++++++++++++++++*/
122 Widget systemDefault;
123 Widget windowFocusTB;
124 Widget focusPolicyRC;
125 Widget focusSeparator;
129 Widget iconPlacementTB;
135 Boolean systemDefaultFlag;
136 int origKeyboardFocusPolicy;
137 int origFocusAutoRaise;
145 static saveRestore save = {FALSE, 0, };
147 static char dtwmRes[150]="";
149 static char *icon[] = {
160 static char *placementStr[] = {
171 /*+++++++++++++++++++++++++++++++++++++++*/
173 /*+++++++++++++++++++++++++++++++++++++++*/
179 if (style.dtwmDialog == NULL) {
180 _DtTurnOnHourGlass(shell);
181 build_dtwmDlg(shell);
183 XtManageChild(style.dtwmDialog);
184 _DtTurnOffHourGlass(shell);
188 XtManageChild(style.dtwmDialog);
189 raiseWindow(XtWindow(XtParent(style.dtwmDialog)));
191 dtwm.systemDefaultFlag = False;
194 /*+++++++++++++++++++++++++++++++++++++++*/
196 /*+++++++++++++++++++++++++++++++++++++++*/
201 char *str_type_return;
202 XrmValue value_return;
208 db = XtDatabase(style.display);
210 /* Get KeyboardFocusPolicy value */
211 if (status = XrmGetResource (db, "dtwm.keyboardFocusPolicy",
212 "Dtwm.KeyboardFocusPolicy",
213 &str_type_return, &value_return))
215 /* make local copy of string */
216 string = (char *) XtMalloc( value_return.size );
217 strcpy (string, value_return.addr);
219 /* convert to lower case */
220 _DtWmParseToLower((unsigned char *)string);
222 if (strcmp(string, "pointer") == 0)
224 XmToggleButtonGadgetSetState (dtwm.pointerTG, True, True);
225 dtwm.origKeyboardFocusPolicy = POINTER;
227 if (strcmp(string, "explicit") == 0)
229 XmToggleButtonGadgetSetState (dtwm.explicitTG, True, True);
230 dtwm.origKeyboardFocusPolicy = EXPLICIT;
234 else /* KeyboardFocusPolicy not specified */
236 /* set the Dtwm default value - explicit */
237 XmToggleButtonGadgetSetState (dtwm.explicitTG, True, True);
238 dtwm.origKeyboardFocusPolicy = EXPLICIT;
241 /* Get FocusAutoRaise value */
242 if (status = XrmGetResource (db, "dtwm.focusAutoRaise",
243 "Dtwm.FocusAutoRaise",
244 &str_type_return, &value_return))
246 /* make local copy of string */
247 string = (char *) XtMalloc( value_return.size );
248 strcpy (string, value_return.addr);
250 /* convert to lower case */
251 _DtWmParseToLower((unsigned char *)string);
253 dtwm.origFocusAutoRaise =
254 (strcmp(string, "true") ? False : True);
255 XmToggleButtonGadgetSetState (dtwm.autoRaiseTG,
256 dtwm.origFocusAutoRaise, True);
260 else /* FocusAutoRaise not specified */
262 /* set the Dtwm default value:
263 * True when keyboardFocusPolicy is explicit
264 * False when keyboardFocusPolicy is pointer
266 dtwm.origFocusAutoRaise =
267 ((dtwm.origKeyboardFocusPolicy == EXPLICIT) ? True : False);
268 XmToggleButtonGadgetSetState (dtwm.autoRaiseTG,
269 dtwm.origFocusAutoRaise, True);
272 /* Get SecStack value from secondaries OnTop resource*/
273 if (status = XrmGetResource (db, "dtwm.secondariesOnTop",
274 "Dtwm.secondariesOnTop",
275 &str_type_return, &value_return))
277 /* make local copy of string */
278 string = (char *) XtMalloc( value_return.size );
279 strcpy (string, value_return.addr);
281 /* convert to lower case */
282 _DtWmParseToLower((unsigned char *)string);
285 (strcmp(string, "true") ? False : True);
286 XmToggleButtonGadgetSetState (dtwm.secStackTG,
287 !dtwm.origSecStack, True);
291 else /* SecStack resource not specified */
294 dtwm.origSecStack = False;
295 XmToggleButtonGadgetSetState (dtwm.secStackTG,
296 !dtwm.origSecStack, False);
298 dtwm.origSecStack = True;
299 XmToggleButtonGadgetSetState (dtwm.secStackTG,
300 !dtwm.origSecStack, True);
303 /* Get UseIconBox value */
304 if (status = XrmGetResource (db, "dtwm.useIconBox",
306 &str_type_return, &value_return))
308 /* make local copy of string */
309 string = (char *) XtMalloc( value_return.size );
310 strcpy (string, value_return.addr);
312 /* convert to lower case */
313 _DtWmParseToLower((unsigned char *)string);
315 dtwm.origUseIconBox =
316 (strcmp(string, "true") ? False : True);
317 if (dtwm.origUseIconBox)
318 XmToggleButtonGadgetSetState (dtwm.iconBoxTG, True, True);
320 XmToggleButtonGadgetSetState (dtwm.desktopTG, True, True);
324 else /* UseIconBox not specified */
326 /* set the Dtwm default value - False, desktop - True*/
327 dtwm.origUseIconBox = False;
328 XmToggleButtonGadgetSetState (dtwm.desktopTG, True, True);
331 /* Get MoveOpaque value */
332 if (status = XrmGetResource (db, "dtwm.moveOpaque",
334 &str_type_return, &value_return))
336 /* make local copy of string */
337 string = (char *) XtMalloc( value_return.size );
338 strcpy (string, value_return.addr);
340 /* convert to lower case */
341 _DtWmParseToLower((unsigned char *)string);
343 dtwm.origMoveOpaque =
344 (strcmp(string, "true") ? False : True);
345 XmToggleButtonGadgetSetState (dtwm.moveOpaqueTG,
346 dtwm.origMoveOpaque, True);
350 else /* MoveOpaque not specified */
352 /* set the Dtwm default value: False */
354 dtwm.origMoveOpaque = False;
355 XmToggleButtonGadgetSetState (dtwm.moveOpaqueTG,
356 dtwm.origMoveOpaque, True);
361 /*+++++++++++++++++++++++++++++++++++++++*/
363 /*+++++++++++++++++++++++++++++++++++++++*/
370 XmString button_string[NUM_LABELS];
373 Widget windowFocusForm;
374 Widget iconPlacementForm;
376 Widget widgetList1[6];
378 /* get dtwm resource values */
380 /* Set up DialogBoxDialog button labels */
381 button_string[0] = CMPSTR((String) _DtOkString);
382 button_string[1] = CMPSTR((String) _DtCancelString);
383 button_string[2] = CMPSTR((String) _DtHelpString);
385 /* Create toplevel DialogBox */
387 * Note that save.poscnt has been initialized elsewhere.
388 * save.posArgs may contain information from restoreBeep().*/
390 XtSetArg(save.posArgs[save.poscnt], XmNbuttonCount, NUM_LABELS); save.poscnt++;
391 XtSetArg(save.posArgs[save.poscnt], XmNbuttonLabelStrings, button_string); save.poscnt++;
392 XtSetArg(save.posArgs[save.poscnt], XmNdefaultPosition, False);
395 __DtCreateDialogBoxDialog(shell, "dtwmDialog", save.posArgs, save.poscnt);
396 XtAddCallback(style.dtwmDialog, XmNhelpCallback,
397 (XtCallbackProc)HelpRequestCB, (XtPointer)HELP_DTWM_DIALOG);
399 XmStringFree(button_string[0]);
400 XmStringFree(button_string[1]);
401 XmStringFree(button_string[2]);
403 widgetList1[0] = _DtDialogBoxGetButton(style.dtwmDialog,2);
405 XtSetArg(args[n], XmNautoUnmanage, False); n++;
406 XtSetArg(args[n], XmNcancelButton, widgetList1[0]); n++;
407 XtSetValues (style.dtwmDialog, args, n);
410 XtSetArg(args[n], XmNtitle, ((char *)GETMESSAGE(18, 1, "Style Manager - Window"))); n++;
411 XtSetArg (args[n], XmNuseAsyncGeometry, True); n++;
412 XtSetArg(args[n], XmNmwmFunctions, DIALOG_MWM_FUNC); n++;
413 XtSetValues (XtParent(style.dtwmDialog), args, n);
416 XtSetArg(args[n], XmNallowOverlap, False); n++;
417 XtSetArg(args[n], XmNchildType, XmWORK_AREA); n++;
418 form = XmCreateForm(style.dtwmDialog, "dtwmForm", args, n);
421 XtSetArg(args[n], XmNfillMode, XmFILL_SELF); n++;
422 XtSetArg(args[n], XmNbehavior, XmICON_LABEL); n++;
423 XtSetArg(args[n], XmNpixmapForeground, style.secBSCol); n++;
424 XtSetArg(args[n], XmNpixmapBackground, style.secTSCol); n++;
425 XtSetArg(args[n], XmNstring, NULL); n++;
426 XtSetArg(args[n], XmNshadowThickness, 0); n++;
427 XtSetArg(args[n], XmNimageName, DTWM_ICON); n++;
428 XtSetArg(args[n], XmNtraversalOn, False); n++;
429 widgetList1[count++] =
430 dtwm.pictLabel = _DtCreateIcon(form, "dtwmpictLabel", args, n);
433 XtSetArg(args[n], XmNmarginHeight, LB_MARGIN_HEIGHT); n++;
434 XtSetArg(args[n], XmNmarginWidth, LB_MARGIN_WIDTH); n++;
435 string = CMPSTR(((char *)GETMESSAGE(18, 2, "Default")));
436 XtSetArg(args[n], XmNlabelString, string); n++;
437 widgetList1[count++] = dtwm.systemDefault =
438 XmCreatePushButtonGadget(form, "systemDefault", args, n);
439 XmStringFree(string);
442 string = CMPSTR((char *)GETMESSAGE(18, 3, "Window Behavior"));
443 XtSetArg(args[n], XmNtitleString, string); n++;
444 widgetList1[count++] = dtwm.windowFocusTB
445 = _DtCreateTitleBox(form, "windowFocusTB", args, n);
446 XmStringFree(string);
449 XtSetArg(args[n], XmNallowOverlap, False); n++;
450 XtSetArg(args[n], XmNchildType, XmWORK_AREA); n++;
452 XmCreateForm(dtwm.windowFocusTB, "windowFocusForm", args, n);
455 string = CMPSTR((char *)GETMESSAGE(18, 4, "Window Icons"));
456 XtSetArg(args[n], XmNtitleString, string); n++;
457 widgetList1[count++] = dtwm.iconPlacementTB
458 = _DtCreateTitleBox(form, "iconPlacementTB", args, n);
459 XmStringFree(string);
462 XtSetArg(args[n], XmNallowOverlap, False); n++;
463 XtSetArg(args[n], XmNchildType, XmWORK_AREA); n++;
465 XmCreateForm(dtwm.iconPlacementTB, "iconPlacementForm", args, n);
468 XtSetArg(args[n], XmNmarginWidth, 0); n++;
469 XtSetArg(args[n], XmNmarginHeight, 0); n++;
471 XmCreateRadioBox(windowFocusForm, "focusPolicyRC", args, n);
474 string = CMPSTR((char *)GETMESSAGE(18, 13, "Point In Window To Make Active"));
475 XtSetArg(args[n], XmNlabelString, string); n++;
477 XmCreateToggleButtonGadget(dtwm.focusPolicyRC, "pointerTG", args, n);
478 XmStringFree(string);
481 string = CMPSTR((char *)GETMESSAGE(18, 14, "Click In Window To Make Active"));
482 XtSetArg(args[n], XmNlabelString, string); n++;
484 XmCreateToggleButtonGadget(dtwm.focusPolicyRC, "explicitTG", args, n);
485 XmStringFree(string);
488 XtSetArg(args[n], XmNmargin, 0); n++;
489 dtwm.focusSeparator =
490 XmCreateSeparatorGadget(windowFocusForm, "focusSeparator", args, n);
493 string = CMPSTR((char *)GETMESSAGE(18, 15, "Raise Window When Made Active"));
494 XtSetArg(args[n], XmNnavigationType, XmTAB_GROUP); n++;
495 XtSetArg(args[n], XmNlabelString, string); n++;
496 XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
498 XmCreateToggleButtonGadget(windowFocusForm, "autoRaiseTG", args, n);
499 XmStringFree(string);
503 string = CMPSTR((char *)GETMESSAGE(18, 11, "Allow Primary Windows On Top"));
504 XtSetArg(args[n], XmNnavigationType, XmTAB_GROUP); n++;
505 XtSetArg(args[n], XmNlabelString, string); n++;
506 XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
508 XmCreateToggleButtonGadget(windowFocusForm, "secStackTG", args, n);
509 XmStringFree(string);
512 string = CMPSTR((char *)GETMESSAGE(18, 16, "Show Contents During Move"));
513 XtSetArg(args[n], XmNnavigationType, XmTAB_GROUP); n++;
514 XtSetArg(args[n], XmNlabelString, string); n++;
515 XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
517 XmCreateToggleButtonGadget(windowFocusForm, "moveOpaqueTG", args, n);
518 XmStringFree(string);
521 XtSetArg(args[n], XmNmarginWidth, 0); n++;
522 XtSetArg(args[n], XmNmarginHeight, 0); n++;
524 XmCreateRadioBox(iconPlacementForm, "useIconBoxRC", args, n);
527 string = CMPSTR((char *)GETMESSAGE(18, 9, "Use Icon Box"));
528 XtSetArg(args[n], XmNlabelString, string); n++;
530 XmCreateToggleButtonGadget(dtwm.useIconBoxRC, "iconBoxTG", args, n);
531 XmStringFree(string);
534 string = CMPSTR((char *)GETMESSAGE(18, 10, "Place On Workspace"));
535 XtSetArg(args[n], XmNlabelString, string); n++;
537 XmCreateToggleButtonGadget(dtwm.useIconBoxRC, "desktopTG", args, n);
538 XmStringFree(string);
540 XtAddCallback(style.dtwmDialog, XmNmapCallback, formLayoutCB, NULL);
541 XtAddCallback(style.dtwmDialog, XmNmapCallback, _DtmapCB_dtwmDlg, shell);
542 XtAddCallback(style.dtwmDialog, XmNcallback, ButtonCB, NULL);
543 XtAddCallback(dtwm.systemDefault, XmNactivateCallback, systemDefaultCB, NULL);
546 XtManageChildren(widgetList1,count);
548 XtManageChild(windowFocusForm);
549 XtManageChild(iconPlacementForm);
551 XtManageChild(dtwm.focusPolicyRC);
552 XtManageChild(dtwm.pointerTG);
553 XtManageChild(dtwm.explicitTG);
555 XtManageChild(dtwm.focusSeparator);
556 XtManageChild(dtwm.autoRaiseTG);
557 XtManageChild(dtwm.secStackTG);
558 XtManageChild(dtwm.moveOpaqueTG);
560 XtManageChild(dtwm.useIconBoxRC);
561 XtManageChild(dtwm.iconBoxTG);
562 XtManageChild(dtwm.desktopTG);
564 return(style.dtwmDialog);
568 /*+++++++++++++++++++++++++++++++++++++++*/
570 /*+++++++++++++++++++++++++++++++++++++++*/
574 XtPointer client_data,
575 XtPointer call_data )
582 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
583 XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
584 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
585 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
586 XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
587 XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
588 XtSetValues (dtwm.pictLabel, args, n);
592 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
593 XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
594 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
595 XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
596 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
597 XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
598 XtSetValues (dtwm.systemDefault, args, n);
600 /* Window Focus TitleBox */
602 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
603 XtSetArg(args[n], XmNtopWidget, dtwm.pictLabel); n++;
604 XtSetArg(args[n], XmNtopOffset, style.horizontalSpacing); n++;
605 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
606 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
607 XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
608 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
609 XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
610 XtSetValues (dtwm.windowFocusTB, args, n);
612 /* Icon Placement TitleBox */
614 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
615 XtSetArg(args[n], XmNtopWidget, dtwm.windowFocusTB); n++;
616 XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
617 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
618 XtSetArg(args[n], XmNbottomOffset, style.verticalSpacing); n++;
619 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
620 XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
621 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
622 XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
623 XtSetValues (dtwm.iconPlacementTB, args, n);
627 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
628 XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
629 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
630 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
631 XtSetArg(args[n], XmNleftOffset, 0); n++;
632 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
633 XtSetArg(args[n], XmNrightOffset, 0); n++;
634 XtSetValues (dtwm.focusPolicyRC, args, n);
638 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
639 XtSetArg(args[n], XmNtopWidget, dtwm.focusPolicyRC); n++;
640 XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
641 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
642 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
643 XtSetArg(args[n], XmNleftOffset, 0); n++;
644 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
645 XtSetArg(args[n], XmNrightOffset, 0); n++;
646 XtSetValues (dtwm.focusSeparator, args, n);
650 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
651 XtSetArg(args[n], XmNtopWidget, dtwm.focusSeparator); n++;
652 XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
653 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
654 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
655 XtSetArg(args[n], XmNleftOffset, 0); n++;
656 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
657 XtSetArg(args[n], XmNrightOffset, 0); n++;
658 XtSetValues (dtwm.autoRaiseTG, args, n);
662 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
663 XtSetArg(args[n], XmNtopWidget, dtwm.autoRaiseTG); n++;
664 XtSetArg(args[n], XmNtopOffset, style.verticalSpacing-3); n++;
665 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
666 XtSetArg(args[n], XmNbottomOffset, style.verticalSpacing); n++;
667 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
668 XtSetArg(args[n], XmNleftOffset, 0); n++;
669 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
670 XtSetArg(args[n], XmNrightOffset, 0); n++;
671 XtSetValues (dtwm.secStackTG, args, n);
676 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
677 XtSetArg(args[n], XmNtopWidget, dtwm.secStackTG); n++;
678 XtSetArg(args[n], XmNtopOffset, style.verticalSpacing-3); n++;
679 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
680 XtSetArg(args[n], XmNbottomOffset, style.verticalSpacing); n++;
681 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
682 XtSetArg(args[n], XmNleftOffset, 0); n++;
683 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
684 XtSetArg(args[n], XmNrightOffset, 0); n++;
685 XtSetValues (dtwm.moveOpaqueTG, args, n);
687 /* Use Icon Box RC */
689 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
690 XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
691 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
692 XtSetArg(args[n], XmNbottomOffset, 0); n++;
693 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
694 XtSetArg(args[n], XmNleftOffset, 0); n++;
695 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
696 XtSetArg(args[n], XmNrightOffset, 0); n++;
697 XtSetValues (dtwm.useIconBoxRC, args, n);
699 XtRemoveCallback(style.dtwmDialog, XmNmapCallback, formLayoutCB, NULL);
702 /*+++++++++++++++++++++++++++++++++++++++*/
703 /* _DtmapCB_dtwmDlg */
704 /*+++++++++++++++++++++++++++++++++++++++*/
708 XtPointer client_data,
709 XtPointer call_data )
712 static int first_time = 1;
717 DtWsmRemoveWorkspaceFunctions(style.display, XtWindow(XtParent(w)));
719 if (!save.restoreFlag)
720 putDialog ((Widget)client_data, w);
722 XtRemoveCallback(style.dtwmDialog, XmNmapCallback, _DtmapCB_dtwmDlg, NULL);
727 /*+++++++++++++++++++++++++++++++++++++++*/
728 /* systemDefaultCB */
729 /*+++++++++++++++++++++++++++++++++++++++*/
733 XtPointer client_data,
734 XtPointer call_data )
737 /* KeyboardFocusPolicy: explicit */
738 XmToggleButtonGadgetSetState (dtwm.explicitTG, True, True);
740 /* FocusAutoRaise: True */
741 XmToggleButtonGadgetSetState (dtwm.autoRaiseTG, True, True);
744 /* Sun default is secStack: False */
745 XmToggleButtonGadgetSetState (dtwm.secStackTG, True, True);
748 XmToggleButtonGadgetSetState (dtwm.secStackTG, False, True);
751 /* OpaqueMove: False */
752 XmToggleButtonGadgetSetState (dtwm.moveOpaqueTG, False, True);
754 /* PlaceOnDesktop: True */
755 XmToggleButtonGadgetSetState (dtwm.desktopTG, True, True);
759 /*+++++++++++++++++++++++++++++++++++++++*/
761 /* callback for PushButtons in DialogBox */
762 /*+++++++++++++++++++++++++++++++++++++++*/
766 XtPointer client_data,
767 XtPointer call_data )
773 Boolean changeFlag = 0;
774 DtDialogBoxCallbackStruct *cb = (DtDialogBoxCallbackStruct *) call_data;
776 switch (cb->button_position)
782 /* create the Dtwm resource specs for xrdb */
784 state = XmToggleButtonGadgetGetState (dtwm.explicitTG);
785 if ( state != dtwm.origKeyboardFocusPolicy)
787 sprintf(dtwmRes, "Dtwm.keyboardFocusPolicy: %s\n",
788 XmToggleButtonGadgetGetState (dtwm.pointerTG)
789 ? POINTER_STR : EXPLICIT_STR);
793 /* write out FocusAutoRaise if toggle has changed or if
794 * KeyboardFocusPolicy has changed. FAR default value is
795 * based off of KFP so must set explicitly or visible toggle
796 * will be inacurate */
797 state = XmToggleButtonGadgetGetState (dtwm.autoRaiseTG);
798 if (state != dtwm.origFocusAutoRaise || changeFlag)
800 sprintf(dtwmRes+strlen(dtwmRes), "Dtwm*focusAutoRaise: %s\n",
801 XmToggleButtonGadgetGetState (dtwm.autoRaiseTG)
806 state = !XmToggleButtonGadgetGetState (dtwm.secStackTG);
807 if ( state != dtwm.origSecStack)
809 sprintf(dtwmRes+strlen(dtwmRes), "Dtwm*secondariesOnTop: %s\n",
810 XmToggleButtonGadgetGetState (dtwm.secStackTG)
815 state = XmToggleButtonGadgetGetState (dtwm.moveOpaqueTG);
816 if ( state != dtwm.origMoveOpaque)
818 sprintf(dtwmRes+strlen(dtwmRes), "Dtwm*moveOpaque: %s\n",
819 XmToggleButtonGadgetGetState (dtwm.moveOpaqueTG)
824 state = XmToggleButtonGadgetGetState (dtwm.iconBoxTG);
825 if (state != dtwm.origUseIconBox)
827 sprintf(dtwmRes+strlen(dtwmRes), "Dtwm*useIconBox: %s\n",
828 XmToggleButtonGadgetGetState (dtwm.iconBoxTG)
835 if (dtwm.warnDialog == NULL)
838 XtSetArg(args[n], XmNokLabelString, CMPSTR((String) _DtOkString)); n++;
839 XtSetArg(args[n], XmNcancelLabelString, CMPSTR((String) _DtCancelString)); n++;
840 XtSetArg(args[n], XmNborderWidth, 3); n++;
841 XtSetArg(args[n], XmNmwmFunctions, DIALOG_MWM_FUNC ); n++;
842 XtSetArg(args[n], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL); n++;
843 XtSetArg(args[n], XmNdialogTitle, CMPSTR((char *)GETMESSAGE(2,2, "Notice"))); n++;
844 XtSetArg(args[n], XmNmessageString, CMPSTR(WARN_MSG)); n++;
845 dtwm.warnDialog = XmCreateInformationDialog(style.shell, "warnDialog", args, n);
847 XtUnmanageChild (XmMessageBoxGetChild(dtwm.warnDialog, XmDIALOG_HELP_BUTTON));
849 XtAddCallback(dtwm.warnDialog, XmNokCallback, okWarnCB,
851 XtAddCallback(dtwm.warnDialog, XmNcancelCallback, cancelWarnCB,
854 XtManageChild(dtwm.warnDialog);
862 /* reset to dtwm values from when dialog is mapped */
865 XmToggleButtonGadgetSetState (dtwm.pointerTG,
866 dtwm.origKeyboardFocusPolicy ? POINTER : EXPLICIT , True);
868 XmToggleButtonGadgetSetState (dtwm.explicitTG,
869 dtwm.origKeyboardFocusPolicy ? EXPLICIT : POINTER , True);
871 XmToggleButtonGadgetSetState (dtwm.autoRaiseTG,
872 dtwm.origFocusAutoRaise ? True : False , True);
874 XmToggleButtonGadgetSetState (dtwm.secStackTG,
875 dtwm.origSecStack ? False : True , True);
877 XmToggleButtonGadgetSetState (dtwm.moveOpaqueTG,
878 dtwm.origMoveOpaque ? True : False , True);
880 XmToggleButtonGadgetSetState (dtwm.iconBoxTG,
881 dtwm.origUseIconBox ? True : False , True);
883 XmToggleButtonGadgetSetState (dtwm.desktopTG,
884 dtwm.origUseIconBox ? False : True , True);
889 XtCallCallbacks(style.dtwmDialog, XmNhelpCallback, (XtPointer)NULL);
898 /************************************************************************
901 * restore any state information saved with savedtwm.
902 * This is called from restoreSession with the application
903 * shell and the special xrm database retrieved for restore.
904 ************************************************************************/
911 XrmRepresentation rep_type;
914 xrm_name [0] = XrmStringToQuark ("dtwmDlg");
918 xrm_name [1] = XrmStringToQuark ("x");
919 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)){
920 XtSetArg (save.posArgs[save.poscnt], XmNx, atoi((char *)value.addr)); save.poscnt++;
921 save.restoreFlag = True;
925 xrm_name [1] = XrmStringToQuark ("y");
926 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)){
927 XtSetArg (save.posArgs[save.poscnt], XmNy, atoi((char *)value.addr)); save.poscnt++;
930 xrm_name [1] = XrmStringToQuark ("ismapped");
931 XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value);
932 /* Are we supposed to be mapped? */
933 if (strcmp(value.addr, "True") == 0)
937 /************************************************************************
940 * This routine will write out to the passed file descriptor any state
941 * information this dialog needs. It is called from saveSessionCB with the
942 * file already opened.
943 * All information is saved in xrm format. There is no restriction
944 * on what can be saved. It doesn't have to be defined or be part of any
945 * widget or Xt definition. Just name and save it here and recover it in
946 * restoreBackdrop. The suggested minimum is whether you are mapped, and your
948 ************************************************************************/
954 Dimension width, height;
955 char *bufr = style.tmpBigStr; /* size=[1024], make bigger if needed */
956 XmVendorShellExtObject vendorExt;
957 XmWidgetExtData extData;
959 if (style.dtwmDialog != NULL)
961 if (XtIsManaged(style.dtwmDialog))
962 sprintf(bufr, "*dtwmDlg.ismapped: True\n");
964 sprintf(bufr, "*dtwmDlg.ismapped: False\n");
966 /* Get and write out the geometry info for our Window */
967 x = XtX(XtParent(style.dtwmDialog));
968 y = XtY(XtParent(style.dtwmDialog));
970 /* Modify x & y to take into account window mgr frames
971 * This is pretty bogus, but I don't know a better way to do it.
973 extData = _XmGetWidgetExtData(style.shell, XmSHELL_EXTENSION);
974 vendorExt = (XmVendorShellExtObject)extData->widget;
975 x -= vendorExt->vendor.xOffset;
976 y -= vendorExt->vendor.yOffset;
978 width = XtWidth(style.dtwmDialog);
979 height = XtHeight(style.dtwmDialog);
981 sprintf(bufr, "%s*dtwmDlg.x: %d\n", bufr, x);
982 sprintf(bufr, "%s*dtwmDlg.y: %d\n", bufr, y);
983 sprintf(bufr, "%s*dtwmDlg.width: %d\n", bufr, width);
984 sprintf(bufr, "%s*dtwmDlg.height: %d\n", bufr, height);
985 if(-1 == write (fd, bufr, strlen(bufr))) {
986 perror(strerror(errno));
992 /*************************************<->*************************************
994 * _DtWmParseToLower (string)
999 * Lower all characters in a string.
1004 * string = NULL-terminated character string or NULL
1009 * string = NULL-terminated lower case character string or NULL
1014 * Can handle multi-byte characters
1016 *************************************<->***********************************/
1019 void _DtWmParseToLower (unsigned char *string)
1021 unsigned char *pch = string;
1025 while ((chlen = mblen ((char *)pch, MB_CUR_MAX)) > 0)
1027 if ((chlen == 1) && (isupper (*pch)))
1029 *pch = tolower(*pch);
1034 while (*pch != NULL)
1038 *pch = tolower(*pch);
1044 } /* END OF FUNCTION _DtWmParseToLower */
1049 /*+++++++++++++++++++++++++++++++++++++++*/
1050 /* cancelWarnCB - callback for the */
1051 /* cancel button of the warnDialog */
1052 /*+++++++++++++++++++++++++++++++++++++++*/
1057 XtPointer client_data,
1058 XtPointer call_data )
1060 XmToggleButtonGadgetSetState (dtwm.pointerTG,
1061 dtwm.origKeyboardFocusPolicy ? POINTER : EXPLICIT , True);
1063 XmToggleButtonGadgetSetState (dtwm.explicitTG,
1064 dtwm.origKeyboardFocusPolicy ? EXPLICIT : POINTER , True);
1066 XmToggleButtonGadgetSetState (dtwm.autoRaiseTG,
1067 dtwm.origFocusAutoRaise ? True : False , True);
1069 XmToggleButtonGadgetSetState (dtwm.secStackTG,
1070 dtwm.origSecStack ? False : True , True);
1072 XmToggleButtonGadgetSetState (dtwm.moveOpaqueTG,
1073 dtwm.origMoveOpaque ? True : False , True);
1075 XmToggleButtonGadgetSetState (dtwm.iconBoxTG,
1076 dtwm.origUseIconBox ? True : False , True);
1078 XmToggleButtonGadgetSetState (dtwm.desktopTG,
1079 dtwm.origUseIconBox ? False : True , True);
1085 /*+++++++++++++++++++++++++++++++++++++++*/
1086 /* okWarnCB - callback for the */
1087 /* OK button of the warnDialog */
1088 /*+++++++++++++++++++++++++++++++++++++++*/
1093 XtPointer client_data,
1094 XtPointer call_data )
1096 dtwm.origKeyboardFocusPolicy = XmToggleButtonGadgetGetState (dtwm.explicitTG);
1097 dtwm.origFocusAutoRaise = XmToggleButtonGadgetGetState (dtwm.autoRaiseTG);
1098 dtwm.origSecStack = !XmToggleButtonGadgetGetState (dtwm.secStackTG);
1099 dtwm.origMoveOpaque = XmToggleButtonGadgetGetState (dtwm.moveOpaqueTG);
1100 dtwm.origUseIconBox = XmToggleButtonGadgetGetState (dtwm.iconBoxTG);
1103 /* write out resources to xrdb */
1104 _DtAddToResource(style.display, dtwmRes);
1106 /* force the workspace manager to restart */
1107 _DtWmRestartNoConfirm(style.display, style.root);