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 Mouse dialog
33 ** (c) Copyright Hewlett-Packard Company, 1990.
37 ****************************************************************************
38 ************************************<+>*************************************/
39 /*$XConsortium: Mouse.c /main/5 1996/07/19 13:45:42 pascale $*/
47 #include <Xm/LabelG.h>
48 #include <Xm/MwmUtil.h>
49 #include <Xm/MessageB.h>
51 #include <Xm/PushBG.h>
52 #include <Xm/RowColumn.h>
54 #include <Xm/ToggleBG.h>
55 #include <Xm/VendorSEP.h>
57 #include <Dt/DialogBox.h>
58 #include <Dt/Message.h>
59 #include <Dt/SessionM.h>
60 #include <Dt/HourGlass.h>
61 #include <Dt/UserMsg.h>
65 #include "SaveRestore.h"
67 /*+++++++++++++++++++++++++++++++++++++++*/
68 /* include extern functions */
69 /*+++++++++++++++++++++++++++++++++++++++*/
72 /*+++++++++++++++++++++++++++++++++++++++*/
74 /*+++++++++++++++++++++++++++++++++++++++*/
79 #define THRESHDEFAULT 10
84 #define DCLICKDEFAULT 500
85 #define RIGHT_HANDED 0
91 #define LEFTMSG ((char *)GETMESSAGE(9, 1, "Left"))
92 #define RIGHTMSG ((char *)GETMESSAGE(9, 2, "Right"))
93 #define HANDMSG ((char *)GETMESSAGE(9, 3, "Handedness:"))
94 #define MIDDLEMSG ((char *)GETMESSAGE(9, 4, "Button 2:"))
95 #define MSG3 ((char *)GETMESSAGE(9, 10, "ERROR: setting pointer mapping\n"))
96 #define TRANSMSG ((char *)GETMESSAGE(9, 11, "Transfer"))
97 #define ADJMSG ((char *)GETMESSAGE(9, 12, "Adjust"))
98 #define WARN_MSG ((char *)GETMESSAGE(9, 13, "The right and left mouse buttons will swap\n\
99 functions immediately after you click on OK.\n\
100 The `Test Double-Click' graphic in the Mouse\n\
101 window shows the current handedness by the \n\
102 positions of Button 1 and Button 3."))
103 #define MID_WARN_MSG_T ((char *)GETMESSAGE(9, 14, "If you click on OK, mouse button 2 will be set\n\
104 to `transfer' (drag) at your next session."))
105 #define IMMEDIATE_MSG ((char *)GETMESSAGE(9, 15, "The new double-click time will take effect\n\
106 as applications are restarted."))
107 #define LATER_MSG ((char *)GETMESSAGE(9, 16, "The new double-click time will take effect\n\
108 at your next session."))
109 #define MID_WARN_MSG_A ((char *)GETMESSAGE(9, 19, "If you click on OK, mouse button 2 will be set\n\
110 to `adjust' at your next session. Button 2 may\n\
111 be used to adjust text and list selections.\n\
112 Transfer actions (drag) on text and lists will\n\
113 require the use of Button 1."))
114 #define MENUMSG ((char *)GETMESSAGE(9, 20, "Menu"))
116 #define B2 "Dtms2B.bm"
117 #define B2_REV "Dtms2BR.bm"
118 #define B3 "Dtms3B.bm"
119 #define B3_REV "Dtms3BR.bm"
121 static char *multiClickTimeString = "*multiClickTime:%d\n";
122 static char *enableBtn1TransferString = "*enableBtn1Transfer:%s\n";
123 static char *mouseString = "Mouse";
125 /*+++++++++++++++++++++++++++++++++++++++*/
126 /* Internal Functions */
127 /*+++++++++++++++++++++++++++++++++++++++*/
129 static Widget build_mouseDialog(
131 static void formLayoutCB(
133 XtPointer client_data,
134 XtPointer call_data) ;
135 static void _DtmapCB_mouseDialog(
137 XtPointer client_data,
138 XtPointer call_data) ;
141 static void valueChangedCB(
143 XtPointer client_data,
144 XtPointer call_data) ;
145 static void dclickVCCB(
147 XtPointer client_data,
148 XtPointer call_data) ;
149 static void dclickTestCB(
151 XtPointer client_data,
152 XtPointer call_data) ;
153 static void reverseToggleCB(
155 XtPointer client_data,
156 XtPointer call_data) ;
157 static void midreverseToggleCB(
159 XtPointer client_data,
160 XtPointer call_data) ;
161 static void warnToggleCB(
163 XtPointer client_data,
164 XtPointer call_data) ;
165 static void midwarnToggleCB(
167 XtPointer client_data,
168 XtPointer call_data) ;
169 static void cancelWarnCB(
171 XtPointer client_data,
172 XtPointer call_data) ;
173 static void midcancelWarnCB(
175 XtPointer client_data,
176 XtPointer call_data) ;
177 static void systemDefaultCB(
179 XtPointer client_data,
180 XtPointer call_data) ;
181 static void ButtonCB(
183 XtPointer client_data,
184 XtPointer call_data) ;
187 /*+++++++++++++++++++++++++++++++++++++++*/
188 /* Internal Variables */
189 /*+++++++++++++++++++++++++++++++++++++++*/
200 Widget transferToggle;
202 Widget systemDefault;
222 int accel_denominator;
224 Boolean dclickChanged;
228 Boolean systemDefaultFlag;
229 unsigned char map_return[256];
230 unsigned char new_map_return[256];
234 Boolean origFunction;
237 static Widget warnDialog;
238 static Widget midwarnDialog;
241 static saveRestore save = {FALSE, 0, };
244 /*+++++++++++++++++++++++++++++++++++++++*/
246 /*+++++++++++++++++++++++++++++++++++++++*/
249 popup_mouseBB( Widget shell )
251 if (style.mouseDialog == NULL) {
252 _DtTurnOnHourGlass(shell);
253 build_mouseDialog(shell);
254 mouse.systemDefaultFlag = True;
255 mouse.dclickChanged = False;
256 mouse.btn2Changed = False;
257 XtManageChild(style.mouseDialog);
258 _DtTurnOffHourGlass(shell);
262 XtManageChild(style.mouseDialog);
263 raiseWindow(XtWindow(XtParent(style.mouseDialog)));
267 /*+++++++++++++++++++++++++++++++++++++++*/
268 /* build__mouseDialog */
269 /*+++++++++++++++++++++++++++++++++++++++*/
271 build_mouseDialog( Widget shell )
276 XmString button_string[NUM_LABELS];
279 Widget widget_list[15];
282 Dimension MaxLabelWidth1;
283 Dimension HandLabelWidth;
284 Dimension MiddleLabelWidth;
285 Dimension MaxToggleWidth;
286 Dimension RightToggleWidth;
287 Dimension TransferToggleWidth;
289 XrmDatabase database;
292 char **str_type_return;
293 XrmValue value_return;
295 /* check hil device# for 2 or 3 button mouse */
296 /* IMPORTANT NOTE: */
297 /* X servers will return different values for */
298 /* mouse.numButtons in the call below. */
299 /* The HP X server will return 5 if a quarted */
300 /* threebutton mouse is present and a 3 if a */
301 /* quarted two-button mouse is present. The IBM */
302 /* does not support a two-button mouse. */
303 /* The cod ebelow always loads a three-button */
304 /* for IBM/Sun/HP unless a non-quarted two-button */
305 /* mouse is present on the HP server. */
306 /* When porting this code to a non IBM/Sun/HP */
307 /* platform that has or supports a two-button */
308 /* mouse the code below may have to be changed to */
309 /* take into account the behavior of the new */
313 mouse.numButtons = XGetPointerMapping(style.display, mouse.map_return,
315 if ( mouse.numButtons == 2 )
316 mouse.type = POINTER2B;
317 else if ( mouse.numButtons == 3 || mouse.numButtons == 5 )
318 mouse.type = POINTER3B;
321 /* choose a bitmap based on button mapping *
322 * and number of buttons */
324 if(mouse.type == POINTER3B)
326 mouse.b3 = XmGetPixmap(style.screen, B3,
327 style.secBSCol, style.secTSCol);
328 mouse.b3_rev = XmGetPixmap(style.screen, B3_REV,
329 style.secBSCol, style.secTSCol);
330 mouse.b3Sel = XmGetPixmap(style.screen, B3,
331 style.secTSCol, style.secBSCol );
332 mouse.b3_revSel = XmGetPixmap(style.screen, B3_REV,
333 style.secTSCol, style.secBSCol);
335 if(mouse.map_return[0] == 1)
337 mouse.pixmap = mouse.b3;
338 mouse.pixmapSel = mouse.b3Sel;
342 mouse.pixmap = mouse.b3_rev;
343 mouse.pixmapSel = mouse.b3_revSel;
346 else /* 2 button mouse */
348 mouse.b2 = XmGetPixmap(style.screen, B2,
349 style.secBSCol, style.secTSCol);
350 mouse.b2_rev = XmGetPixmap(style.screen, B2_REV,
351 style.secBSCol, style.secTSCol);
352 mouse.b2Sel = XmGetPixmap(style.screen, B2,
353 style.secTSCol, style.secBSCol);
354 mouse.b2_revSel = XmGetPixmap(style.screen, B2_REV,
355 style.secTSCol, style.secBSCol);
357 if(mouse.map_return[0] == 1)
359 mouse.pixmap = mouse.b2;
360 mouse.pixmapSel = mouse.b2Sel;
364 mouse.pixmap = mouse.b2_rev;
365 mouse.pixmapSel = mouse.b2_revSel;
369 /*Get the value of doubleclick*/
370 mouse.mydclick = XtGetMultiClickTime(style.display);
371 if (mouse.mydclick > 0)
372 mouse.mydclick = mouse.mydclick/100;
373 if (mouse.mydclick < 1)
376 /*Get the value of the enableBtn1Transfer resource */
377 /*from the data base. */
379 str_name = "*enableBtn1Transfer";
380 str_class = "*EnableBtn1Transfer";
382 database = XrmGetDatabase(style.display);
383 if (!XrmGetResource(database, str_name, str_class, (char **)&str_type_return, &value_return))
385 mouse.function = TRANSFER;
386 mouse.origFunction = TRANSFER;
389 if (strcmp(value_return.addr, "True") == 0)
391 mouse.function = ADJUST;
392 mouse.origFunction = ADJUST;
396 mouse.function = TRANSFER;
397 mouse.origFunction = TRANSFER;
400 /* Set up DialogBoxDialog button labels */
401 button_string[0] = CMPSTR((String) _DtOkString);
402 button_string[1] = CMPSTR((String) _DtCancelString);
403 button_string[2] = CMPSTR((String) _DtHelpString);
405 /* Create toplevel DialogBox */
407 * Note that save.poscnt has been initialized elsewhere.
408 * save.posArgs may contain information from restoreMouse().*/
410 XtSetArg(save.posArgs[save.poscnt], XmNbuttonCount, NUM_LABELS);
412 XtSetArg(save.posArgs[save.poscnt], XmNbuttonLabelStrings, button_string);
414 XtSetArg (save.posArgs[save.poscnt], XmNdefaultPosition, False);
416 style.mouseDialog = __DtCreateDialogBoxDialog(shell, mouseString,
417 save.posArgs, save.poscnt);
418 XtAddCallback(style.mouseDialog, XmNcallback, ButtonCB, NULL);
419 XtAddCallback(style.mouseDialog, XmNhelpCallback,
420 (XtCallbackProc)HelpRequestCB, (XtPointer)HELP_MOUSE_DIALOG);
423 XmStringFree(button_string[0]);
424 XmStringFree(button_string[1]);
425 XmStringFree(button_string[2]);
427 widget_list[0] = _DtDialogBoxGetButton(style.mouseDialog,2);
429 XtSetArg(args[n], XmNautoUnmanage, False); n++;
430 XtSetArg(args[n], XmNcancelButton, widget_list[0]); n++;
431 XtSetValues (style.mouseDialog, args, n);
434 XtSetArg(args[n], XmNtitle, ((char *)GETMESSAGE(9, 18, "Style Manager - Mouse"))); n++;
435 XtSetArg (args[n], XmNuseAsyncGeometry, True); n++;
436 XtSetArg(args[n], XmNmwmFunctions, DIALOG_MWM_FUNC); n++;
437 XtSetValues (XtParent(style.mouseDialog), args, n);
440 XtSetArg(args[n], XmNhorizontalSpacing, style.horizontalSpacing); n++;
441 XtSetArg(args[n], XmNverticalSpacing, style.verticalSpacing); n++;
442 XtSetArg(args[n], XmNallowOverlap, False); n++;
443 XtSetArg(args[n], XmNchildType, XmWORK_AREA); n++;
444 form = XmCreateForm(style.mouseDialog, "mouseForm", args, n);
447 XtSetArg(args[n], XmNmarginHeight, LB_MARGIN_HEIGHT); n++;
448 XtSetArg(args[n], XmNmarginWidth, LB_MARGIN_WIDTH); n++;
449 string = CMPSTR(((char *)GETMESSAGE(9, 5, "Default")));
450 XtSetArg(args[n], XmNlabelString, string); n++;
451 widget_list[count++] =
452 mouse.systemDefault= XmCreatePushButtonGadget(form, "systemDefault", args, n);
453 XmStringFree(string);
456 XtSetArg(args[n], XmNorientation, XmVERTICAL); n++;
457 widget_list[count++] =
458 mouse.pictFrame= XmCreateFrame(form, "pictFrame", args, n);
461 XtSetArg(args[n], XmNorientation, XmVERTICAL); n++;
462 XtSetArg(args[n], XmNadjustMargin, False); n++;
463 XtSetArg(args[n], XmNentryAlignment, XmALIGNMENT_BEGINNING); n++;
464 mouse.pictRC = XmCreateRowColumn(mouse.pictFrame, "pictRC", args, n);
467 XtSetArg(args[n], XmNlabelType, XmPIXMAP); n++;
468 XtSetArg(args[n], XmNlabelPixmap, mouse.pixmap); n++;
469 XtSetArg(args[n], XmNrecomputeSize, False); n++;
470 XtSetArg(args[n], XmNmarginWidth, 0); n++;
471 XtSetArg(args[n], XmNmarginHeight, 0); n++;
472 XtSetArg(args[n], XmNshadowThickness, 0); n++;
473 XtSetArg(args[n], XmNmultiClick, XmMULTICLICK_KEEP); n++;
474 mouse.pictButton= XmCreatePushButton(mouse.pictRC, "mousePict", args, n);
477 string = CMPSTR ((char *)GETMESSAGE(9, 17, "Test\nDouble-Click"));
478 XtSetArg(args[n], XmNlabelString, string); n++;
479 mouse.pictLabel= XmCreateLabelGadget(mouse.pictRC, "mouseLabel", args, n);
480 XmStringFree(string);
483 XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
484 XtSetArg(args[n], XmNmarginHeight, 0); n++;
485 string = CMPSTR(HANDMSG);
486 XtSetArg(args[n], XmNlabelString, string); n++;
487 widget_list[count++] =
488 mouse.handLabGad= XmCreateLabelGadget(form,"handLabGad", args, n);
489 XmStringFree(string);
492 string = CMPSTR(RIGHTMSG);
493 XtSetArg(args[n], XmNlabelString, string); n++;
494 XtSetArg(args[n], XmNnavigationType, XmTAB_GROUP); n++;
495 XtSetArg(args[n], XmNindicatorType, XmONE_OF_MANY); n++;
496 XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
497 mouse.rightToggle= XmCreateToggleButtonGadget(form,
498 "rightToggle", args, n);
499 XmStringFree(string);
502 string = CMPSTR(LEFTMSG);
503 XtSetArg(args[n], XmNlabelString, string); n++;
504 XtSetArg(args[n], XmNnavigationType, XmTAB_GROUP); n++;
505 XtSetArg(args[n], XmNindicatorType, XmONE_OF_MANY); n++;
506 XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
507 mouse.leftToggle= XmCreateToggleButtonGadget(form,
508 "leftToggle", args, n);
509 XmStringFree(string);
513 XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
514 XtSetArg(args[n], XmNmarginHeight, 0); n++;
515 string = CMPSTR(MIDDLEMSG);
516 XtSetArg(args[n], XmNlabelString, string); n++;
517 widget_list[count++] =
518 mouse.middleLabGad= XmCreateLabelGadget(form,"middleLabGad", args, n);
519 XmStringFree(string);
522 string = CMPSTR(TRANSMSG);
523 XtSetArg(args[n], XmNlabelString, string); n++;
524 XtSetArg(args[n], XmNindicatorType, XmONE_OF_MANY); n++;
525 XtSetArg(args[n], XmNnavigationType, XmTAB_GROUP); n++;
526 XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
527 mouse.transferToggle= XmCreateToggleButtonGadget(form,
528 "transToggle", args, n);
529 XmStringFree(string);
532 string = CMPSTR(ADJMSG);
533 XtSetArg(args[n], XmNlabelString, string); n++;
534 XtSetArg(args[n], XmNnavigationType, XmTAB_GROUP); n++;
535 XtSetArg(args[n], XmNindicatorType, XmONE_OF_MANY); n++;
536 XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
537 mouse.adjustToggle= XmCreateToggleButtonGadget(form,
538 "adjToggle", args, n);
539 XmStringFree(string);
542 XtSetArg(args[n], XmNalignment, XmALIGNMENT_END); n++;
543 XtSetArg(args[n], XmNmarginHeight, 0); n++;
544 string = CMPSTR(((char *)GETMESSAGE(9, 6, "Double-Click")));
545 XtSetArg(args[n], XmNlabelString, string); n++;
546 widget_list[count++] =
547 mouse.dclickLabGad= XmCreateLabelGadget(form,"dclickLabGad", args, n);
548 XmStringFree(string);
551 XtSetArg(args[n], XmNmaximum, DCLICK_MAX); n++;
552 XtSetArg(args[n], XmNminimum, DCLICK_MIN); n++;
553 XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
554 XtSetArg(args[n], XmNprocessingDirection, XmMAX_ON_RIGHT); n++;
555 XtSetArg(args[n], XmNhighlightThickness, SCALE_HIGHLIGHT_THICKNESS); n++;
556 XtSetArg(args[n], XmNshowValue, True); n++;
557 XtSetArg(args[n], XmNvalue, mouse.mydclick); n++;
558 XtSetArg(args[n], XmNdecimalPoints, (short)1); n++;
559 widget_list[count++] =
560 mouse.dclickScale= XmCreateScale(form,"dclickScale", args, n);
563 XtSetArg(args[n], XmNalignment, XmALIGNMENT_END); n++;
564 XtSetArg(args[n], XmNmarginHeight, 0); n++;
565 string = CMPSTR(((char *)GETMESSAGE(9, 8, "Acceleration")));
566 XtSetArg(args[n], XmNlabelString, string); n++;
567 widget_list[count++] =
568 mouse.accelLabGad= XmCreateLabelGadget(form,"accelLabGad", args, n);
569 XmStringFree(string);
572 XtSetArg(args[n], XmNminimum, ACCEL_MIN); n++;
573 XtSetArg(args[n], XmNmaximum, ACCEL_MAX); n++;
574 XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
575 XtSetArg(args[n], XmNprocessingDirection, XmMAX_ON_RIGHT); n++;
576 XtSetArg(args[n], XmNhighlightThickness, SCALE_HIGHLIGHT_THICKNESS); n++;
577 XtSetArg(args[n], XmNshowValue, True); n++;
578 widget_list[count++] =
579 mouse.accelScale= XmCreateScale(form,"accelScale", args, n);
582 XtSetArg(args[n], XmNalignment, XmALIGNMENT_END); n++;
583 XtSetArg(args[n], XmNmarginHeight, 0); n++;
584 string = CMPSTR(((char *)GETMESSAGE(9, 9, "Threshold")));
585 XtSetArg(args[n], XmNlabelString, string); n++;
586 widget_list[count++] =
587 mouse.threshLabGad= XmCreateLabelGadget(form,"threshLabGad", args, n);
588 XmStringFree(string);
591 XtSetArg(args[n], XmNminimum, THRESH_MIN); n++;
592 XtSetArg(args[n], XmNmaximum, THRESH_MAX); n++;
593 XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
594 XtSetArg(args[n], XmNprocessingDirection, XmMAX_ON_RIGHT); n++;
595 XtSetArg(args[n], XmNhighlightThickness, SCALE_HIGHLIGHT_THICKNESS); n++;
596 XtSetArg(args[n], XmNshowValue, True); n++;
597 widget_list[count++] =
598 mouse.threshScale= XmCreateScale(form,"threshScale", args, n);
600 XtAddCallback(style.mouseDialog, XmNmapCallback, formLayoutCB, NULL);
601 XtAddCallback(style.mouseDialog, XmNmapCallback, _DtmapCB_mouseDialog, shell);
602 XtAddCallback(mouse.systemDefault, XmNactivateCallback,
603 systemDefaultCB, NULL);
605 /* calculate the max width for toggles for the overall alignment */
606 /* Set labels to max label width */
608 MaxLabelWidth1 = HandLabelWidth = XtWidth(mouse.handLabGad);
609 MiddleLabelWidth = XtWidth(mouse.middleLabGad);
610 if (MiddleLabelWidth > MaxLabelWidth1)
612 MaxLabelWidth1 = MiddleLabelWidth;
615 MaxToggleWidth = RightToggleWidth = XtWidth(mouse.rightToggle);
616 TransferToggleWidth = XtWidth(mouse.transferToggle);
617 if (TransferToggleWidth > MaxToggleWidth)
619 MaxToggleWidth = TransferToggleWidth;
623 if (mouse.function == TRANSFER)
625 XmToggleButtonGadgetSetState(mouse.transferToggle, True, True);
626 XmToggleButtonGadgetSetState(mouse.adjustToggle, False, False);
630 XmToggleButtonGadgetSetState(mouse.adjustToggle, True, True);
631 XmToggleButtonGadgetSetState(mouse.transferToggle, False, False);
634 XtVaSetValues(mouse.handLabGad, XmNwidth, MaxLabelWidth1, NULL);
635 XtVaSetValues(mouse.middleLabGad, XmNwidth, MaxLabelWidth1, NULL);
637 XtVaSetValues(mouse.rightToggle, XmNwidth, MaxToggleWidth, NULL);
638 XtVaSetValues(mouse.transferToggle, XmNwidth, MaxToggleWidth, NULL);
640 XtAddCallback(mouse.rightToggle, XmNvalueChangedCallback,
641 warnToggleCB, (XtPointer)RIGHT_HANDED);
643 XtAddCallback(mouse.leftToggle, XmNvalueChangedCallback,
644 warnToggleCB, (XtPointer)LEFT_HANDED);
646 XtAddCallback(mouse.transferToggle, XmNvalueChangedCallback,
647 midwarnToggleCB, (XtPointer)TRANSFER);
649 XtAddCallback(mouse.adjustToggle, XmNvalueChangedCallback,
650 midwarnToggleCB, (XtPointer)ADJUST);
652 XtAddCallback(mouse.accelScale, XmNvalueChangedCallback,
653 valueChangedCB, NULL);
655 XtAddCallback(mouse.threshScale, XmNvalueChangedCallback,
656 valueChangedCB, NULL);
657 XtAddCallback(mouse.dclickScale, XmNvalueChangedCallback,
658 dclickVCCB, (caddr_t)mouse.pictButton);
659 XtAddCallback(mouse.pictButton, XmNactivateCallback,
663 XtManageChildren(widget_list,count);
664 XtManageChild(mouse.pictRC);
665 XtManageChild(mouse.pictButton);
666 XtManageChild(mouse.pictLabel);
667 XtManageChild(mouse.rightToggle);
668 XtManageChild(mouse.leftToggle);
671 * If there are only two mouse buttons then switch the
672 * label for the transferToggle to "Menu" and mark it
673 * insensitive but checked.
674 * Otherwise manage both the transfer and adjust toggles.
676 if (mouse.numButtons == 2) {
678 string = CMPSTR(MENUMSG);
679 XtSetArg(args[n], XmNlabelString, string); n++;
680 XtSetValues(mouse.transferToggle, args, n);
681 XmStringFree(string);
682 XmToggleButtonGadgetSetState(mouse.transferToggle, True, False);
683 XtManageChild(mouse.transferToggle);
685 XtManageChild(mouse.transferToggle);
686 XtManageChild(mouse.adjustToggle);
689 return(style.mouseDialog);
693 /*+++++++++++++++++++++++++++++++++++++++*/
695 /*+++++++++++++++++++++++++++++++++++++++*/
699 XtPointer client_data,
700 XtPointer call_data )
704 Dimension MaxLabelWidth;
705 Dimension AccelLabelWidth;
706 Dimension ThreshLabelWidth;
707 Dimension DclickLabelWidth;
708 Dimension ScaleHeight;
709 Dimension LabelHeight;
713 /* Do the scale and label attachments */
715 ScaleHeight = XtHeight(mouse.accelScale);
717 MaxLabelWidth = AccelLabelWidth = XtWidth(mouse.accelLabGad);
718 LabelHeight = XtHeight(mouse.accelLabGad);
720 ThreshLabelWidth = XtWidth(mouse.threshLabGad);
721 if (ThreshLabelWidth > MaxLabelWidth)
723 MaxLabelWidth = ThreshLabelWidth;
726 DclickLabelWidth = XtWidth(mouse.dclickLabGad);
727 if (DclickLabelWidth > MaxLabelWidth)
729 MaxLabelWidth = DclickLabelWidth;
732 /* Mouse Picture PushButton */
734 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
735 XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
736 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
737 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
738 XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
739 XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
740 XtSetValues (mouse.pictFrame, args, n);
743 /* System Default Button */
745 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
746 XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
747 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
748 XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
749 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
750 XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
751 XtSetValues (mouse.systemDefault, args, n);
754 /* Handedness Label */
756 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
757 XtSetArg(args[n], XmNtopWidget, mouse.systemDefault); n++;
758 XtSetArg(args[n], XmNtopOffset, 4*style.verticalSpacing); n++;
759 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
760 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
761 XtSetArg(args[n], XmNleftWidget, mouse.pictFrame); n++;
762 XtSetArg(args[n], XmNleftOffset, 2*style.horizontalSpacing); n++;
763 XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
764 XtSetValues (mouse.handLabGad, args, n);
768 XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
769 XtSetArg(args[n], XmNtopWidget, mouse.handLabGad); n++;
770 XtSetArg(args[n], XmNtopOffset, -5); n++;
771 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
772 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
773 XtSetArg(args[n], XmNleftWidget, mouse.handLabGad); n++;
774 XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
775 XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
776 XtSetValues (mouse.rightToggle, args, n);
780 XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
781 XtSetArg(args[n], XmNtopWidget, mouse.handLabGad); n++;
782 XtSetArg(args[n], XmNtopOffset, -5); n++;
783 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
784 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
785 XtSetArg(args[n], XmNleftWidget, mouse.rightToggle); n++;
786 XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
787 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
788 XtSetValues (mouse.leftToggle, args, n);
791 /* Middle button Label */
793 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
794 XtSetArg(args[n], XmNtopWidget, mouse.handLabGad); n++;
795 XtSetArg(args[n], XmNtopOffset, 3*style.verticalSpacing); n++;
796 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
797 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
798 XtSetArg(args[n], XmNleftWidget, mouse.pictFrame); n++;
799 XtSetArg(args[n], XmNleftOffset, 2*style.horizontalSpacing); n++;
800 XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
801 XtSetValues (mouse.middleLabGad, args, n);
804 /* transfer toggle */
806 XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
807 XtSetArg(args[n], XmNtopWidget, mouse.middleLabGad); n++;
808 XtSetArg(args[n], XmNtopOffset, -5); n++;
809 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
810 XtSetArg(args[n], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
811 XtSetArg(args[n], XmNleftWidget, mouse.rightToggle); n++;
812 XtSetArg(args[n], XmNleftOffset, 0); n++;
813 XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
814 XtSetValues (mouse.transferToggle, args, n);
818 XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
819 XtSetArg(args[n], XmNtopWidget, mouse.middleLabGad); n++;
820 XtSetArg(args[n], XmNtopOffset, -5); n++;
821 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
822 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
823 XtSetArg(args[n], XmNleftWidget, mouse.transferToggle); n++;
824 XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
825 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
826 XtSetValues (mouse.adjustToggle, args, n);
830 TopOffset = ScaleHeight + style.verticalSpacing - LabelHeight;
832 /* DoubleClick Label */
834 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
835 XtSetArg(args[n], XmNtopWidget, mouse.pictFrame) ; n++;
836 XtSetArg(args[n], XmNtopOffset, TopOffset); n++;
837 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
838 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
839 LeftOffset = MaxLabelWidth + style.horizontalSpacing - DclickLabelWidth;
840 XtSetArg(args[n], XmNleftOffset, LeftOffset); n++;
841 XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
842 XtSetValues (mouse.dclickLabGad, args, n);
844 /* DoubleClick Scale */
846 XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++;
847 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
848 XtSetArg(args[n], XmNbottomWidget, mouse.dclickLabGad); n++;
849 XtSetArg(args[n], XmNbottomOffset, 0); n++;
850 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
851 XtSetArg(args[n], XmNleftWidget, mouse.dclickLabGad); n++;
852 XtSetArg(args[n], XmNleftOffset, 2*style.horizontalSpacing); n++;
853 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
854 XtSetValues (mouse.dclickScale, args, n);
856 /* Acceleration Label */
858 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
859 XtSetArg(args[n], XmNtopWidget, mouse.dclickLabGad); n++;
860 XtSetArg(args[n], XmNtopOffset, TopOffset); n++;
861 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
862 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
863 LeftOffset = MaxLabelWidth + style.horizontalSpacing - AccelLabelWidth;
864 XtSetArg(args[n], XmNleftOffset, LeftOffset); n++;
865 XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
866 XtSetValues (mouse.accelLabGad, args, n);
868 /* Acceleration Scale */
870 XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++;
871 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
872 XtSetArg(args[n], XmNbottomWidget, mouse.accelLabGad); n++;
873 XtSetArg(args[n], XmNbottomOffset, 0); n++;
874 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
875 XtSetArg(args[n], XmNleftWidget, mouse.accelLabGad); n++;
876 XtSetArg(args[n], XmNleftOffset, 2*style.horizontalSpacing); n++;
877 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
878 XtSetValues (mouse.accelScale, args, n);
880 /* Threshold Label */
882 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
883 XtSetArg(args[n], XmNtopWidget, mouse.accelScale); n++;
884 XtSetArg(args[n], XmNtopOffset, TopOffset); n++;
885 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
886 XtSetArg(args[n], XmNbottomOffset, style.verticalSpacing); n++;
887 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
888 LeftOffset = MaxLabelWidth + style.horizontalSpacing - ThreshLabelWidth;
889 XtSetArg(args[n], XmNleftOffset, LeftOffset); n++;
890 XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
891 XtSetValues (mouse.threshLabGad, args, n);
893 /* Threshold Scale */
895 XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++;
896 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
897 XtSetArg(args[n], XmNbottomWidget, mouse.threshLabGad); n++;
898 XtSetArg(args[n], XmNbottomOffset, 0); n++;
899 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
900 XtSetArg(args[n], XmNleftWidget, mouse.threshLabGad); n++;
901 XtSetArg(args[n], XmNleftOffset, 2*style.horizontalSpacing); n++;
902 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
903 XtSetValues (mouse.threshScale, args, n);
905 XtRemoveCallback(style.mouseDialog, XmNmapCallback, formLayoutCB, NULL);
909 /*+++++++++++++++++++++++++++++++++++++++*/
910 /* _DtmapCB_mouseDialog */
911 /*+++++++++++++++++++++++++++++++++++++++*/
913 _DtmapCB_mouseDialog(
915 XtPointer client_data,
916 XtPointer call_data )
922 static int first_time = 1;
926 DtWsmRemoveWorkspaceFunctions(style.display, XtWindow(XtParent(w)));
928 if (!save.restoreFlag)
929 putDialog((Widget)client_data, w);
935 /* Don't need to do XGetPointerMapping first time dialog
936 * is mapped because it is done when dialog is created
937 * The type of device will not change between remapping
940 mouse.numButtons = XGetPointerMapping(style.display,
941 mouse.map_return, nmap);
944 /* save mouse mapping values */
945 for (i=0; i<mouse.numButtons; i++)
946 mouse.new_map_return[i] = mouse.map_return[i];
948 /* change Pointer Mapping */
949 /* the ReverseToggleCB will set the correct Pixmap */
950 if (mouse.map_return[0] == 1) /* right-handed */
952 mouse.handed = RIGHT_HANDED;
953 mouse.origHanded = RIGHT_HANDED;
954 XmToggleButtonGadgetSetState(mouse.rightToggle, True, True);
955 XmToggleButtonGadgetSetState(mouse.leftToggle, False, False);
957 else /* left-handed */
959 mouse.handed = LEFT_HANDED;
960 mouse.origHanded = LEFT_HANDED;
961 XmToggleButtonGadgetSetState(mouse.leftToggle, True, True);
962 XmToggleButtonGadgetSetState(mouse.rightToggle, False, False);
965 /* MultiClickTime will not change between remapping */
967 XGetPointerControl(style.display, &mouse.accel_numerator,
968 &mouse.accel_denominator, &mouse.threshold);
970 XtSetArg(args[n], XmNvalue,mouse.accel_numerator); n++;
971 XtSetValues(mouse.accelScale, args, n);
974 XtSetArg(args[n], XmNvalue,mouse.threshold); n++;
975 XtSetValues(mouse.threshScale, args, n);
988 XtSetArg(args[n], XmNvalue, &value); n++;
989 XtGetValues(w, args, n);
994 /*+++++++++++++++++++++++++++++++++++++++*/
996 /*+++++++++++++++++++++++++++++++++++++++*/
1000 XtPointer client_data,
1001 XtPointer call_data )
1004 int new_acceln, new_acceld, new_thresh;
1006 /* set mouse parameters to new scale values */
1008 new_acceln = getValue(mouse.accelScale);
1009 new_thresh = getValue(mouse.threshScale);
1011 XChangePointerControl(style.display, True, True, new_acceln,
1012 new_acceld, new_thresh);
1014 mouse.systemDefaultFlag = False;
1018 /*+++++++++++++++++++++++++++++++++++++++*/
1020 /*+++++++++++++++++++++++++++++++++++++++*/
1024 XtPointer client_data,
1025 XtPointer call_data )
1027 XmScaleCallbackStruct *cb = (XmScaleCallbackStruct *) call_data;
1029 mouse.dclickChanged = True;
1030 XtSetMultiClickTime (style.display, (cb->value)*100);
1033 /*+++++++++++++++++++++++++++++++++++++++*/
1035 /*+++++++++++++++++++++++++++++++++++++++*/
1039 XtPointer client_data,
1040 XtPointer call_data )
1042 Arg color[3], args[10]; /* arg list */
1043 register int n; /* arg count */
1044 XmPushButtonCallbackStruct *cb = (XmPushButtonCallbackStruct *)call_data;
1045 static int selectstate = False;
1047 if (cb->event->xbutton.button == 1)
1049 if(cb->click_count == 2)
1054 XtSetArg(color[n], XmNlabelPixmap, mouse.pixmap); n++;
1055 XtSetValues (w, color, n);
1057 if (style.useMultiColorIcons)
1060 XtSetArg(color[n], XmNbackground, style.secBgCol); n++;
1061 XtSetValues (w, color, n);
1062 XtSetValues (mouse.pictRC, color, n);
1063 XtSetValues (mouse.pictLabel, color, n);
1066 selectstate = False;
1070 /* This will change the background color to select color,
1071 but it causes the pixmap to redraw if IT was changed.*/
1074 XtSetArg(color[n], XmNlabelPixmap, mouse.pixmapSel); n++;
1075 XtSetValues (w, color, n);
1077 if (style.useMultiColorIcons)
1080 XtSetArg(color[n], XmNbackground, style.secSelectColor); n++;
1081 XtSetValues (w, color, n);
1082 XtSetValues (mouse.pictRC, color, n);
1083 XtSetValues (mouse.pictLabel, color, n);
1096 /*+++++++++++++++++++++++++++++++++++++++**/
1097 /* warnToggleCB - put up a warning dialog */
1098 /* about changing the handedness. */
1099 /*+++++++++++++++++++++++++++++++++++++++**/
1104 XtPointer client_data,
1105 XtPointer call_data )
1114 if (w == mouse.leftToggle && mouse.handed == LEFT_HANDED)
1116 XmToggleButtonGadgetSetState(mouse.leftToggle, True, False);
1119 if (w == mouse.rightToggle && mouse.handed == RIGHT_HANDED)
1121 XmToggleButtonGadgetSetState(mouse.rightToggle, True, False);
1124 if (w == mouse.rightToggle)
1126 XmToggleButtonGadgetSetState(mouse.leftToggle, False, False);
1130 XmToggleButtonGadgetSetState(mouse.rightToggle, False, False);
1134 XtSetArg(args[n], XmNokLabelString, CMPSTR((String) _DtOkString)); n++;
1135 XtSetArg(args[n], XmNcancelLabelString, CMPSTR((String) _DtCancelString)); n++;
1136 string = CMPSTR(WARN_MSG);
1137 XtSetArg(args[n], XmNmessageString, string); n++;
1138 XtSetArg(args[n], XmNmwmFunctions, DIALOG_MWM_FUNC ); n++;
1139 XtSetArg(args[n], XmNborderWidth, 3); n++;
1140 XtSetArg(args[n], XmNdialogStyle, XmDIALOG_SYSTEM_MODAL); n++;
1141 XtSetArg(args[n], XmNdialogTitle, CMPSTR((char *)GETMESSAGE(2,2, "Notice"))); n++;
1142 warnDialog = XmCreateInformationDialog(style.shell, "WarnDialog", args, n);
1143 XmStringFree(string);
1144 XtUnmanageChild (XmMessageBoxGetChild(warnDialog, XmDIALOG_HELP_BUTTON));
1145 XtAddCallback(warnDialog, XmNokCallback, reverseToggleCB, client_data);
1146 XtAddCallback(warnDialog, XmNcancelCallback, cancelWarnCB, client_data);
1147 XtManageChild(warnDialog);
1151 /*++++++++++++++++++++++++++++++++++++++++++**/
1152 /* midwarnToggleCB - put up a warning dialog */
1153 /* about changing the function of the middle */
1155 /*++++++++++++++++++++++++++++++++++++++++++**/
1160 XtPointer client_data,
1161 XtPointer call_data )
1166 XmString warnstring;
1169 if (w == mouse.adjustToggle && mouse.function == ADJUST)
1171 XmToggleButtonGadgetSetState(mouse.adjustToggle, True, False);
1174 if (w == mouse.transferToggle && mouse.function == TRANSFER)
1176 XmToggleButtonGadgetSetState(mouse.transferToggle, True, False);
1181 XtSetArg(args[n], XmNokLabelString, CMPSTR((String) _DtOkString)); n++;
1182 XtSetArg(args[n], XmNcancelLabelString, CMPSTR((String) _DtCancelString)); n++;
1183 XtSetArg(args[n], XmNborderWidth, 3); n++;
1184 XtSetArg(args[n], XmNmwmFunctions, DIALOG_MWM_FUNC ); n++;
1185 XtSetArg(args[n], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL); n++;
1186 XtSetArg(args[n], XmNdialogTitle, CMPSTR((char *)GETMESSAGE(2,2, "Notice"))); n++;
1187 midwarnDialog = XmCreateInformationDialog(style.shell, "MidWarnDialog", args, n);
1189 XtUnmanageChild (XmMessageBoxGetChild(midwarnDialog, XmDIALOG_HELP_BUTTON));
1192 if ((intptr_t)client_data == TRANSFER)
1194 warnstring = CMPSTR(MID_WARN_MSG_T);
1195 XtVaSetValues(midwarnDialog, XmNmessageString, warnstring, NULL); n++;
1197 XmToggleButtonGadgetSetState(mouse.adjustToggle, False, False);
1201 warnstring = CMPSTR(MID_WARN_MSG_A);
1202 XtVaSetValues(midwarnDialog, XmNmessageString, warnstring, NULL); n++;
1204 XmToggleButtonGadgetSetState(mouse.transferToggle, False, False);
1206 XmStringFree(warnstring);
1209 XtAddCallback(midwarnDialog, XmNokCallback, midreverseToggleCB,
1211 XtAddCallback(midwarnDialog, XmNcancelCallback, midcancelWarnCB,
1213 XtManageChild(midwarnDialog);
1216 /*+++++++++++++++++++++++++++++++++++++++*/
1217 /* cancelWarnCB - callback for the */
1218 /* cancel button of the warnDialog */
1219 /*+++++++++++++++++++++++++++++++++++++++*/
1224 XtPointer client_data,
1225 XtPointer call_data )
1232 if (mouse.handed == RIGHT_HANDED)
1234 XmToggleButtonGadgetSetState(mouse.rightToggle, True, False);
1235 XmToggleButtonGadgetSetState(mouse.leftToggle, False, False);
1239 XmToggleButtonGadgetSetState(mouse.leftToggle, True, False);
1240 XmToggleButtonGadgetSetState(mouse.rightToggle, False, False);
1242 XtDestroyWidget(warnDialog);
1245 /*+++++++++++++++++++++++++++++++++++++++*/
1246 /* midcancelWarnCB - callback for the */
1247 /* cancel button of the midwarnDialog */
1248 /*+++++++++++++++++++++++++++++++++++++++*/
1253 XtPointer client_data,
1254 XtPointer call_data )
1261 if (mouse.function == TRANSFER)
1263 XmToggleButtonGadgetSetState(mouse.transferToggle, True, True);
1264 XmToggleButtonGadgetSetState(mouse.adjustToggle, False, False);
1268 XmToggleButtonGadgetSetState(mouse.adjustToggle, True, True);
1269 XmToggleButtonGadgetSetState(mouse.transferToggle, False, False);
1271 XtDestroyWidget(midwarnDialog);
1274 /*+++++++++++++++++++++++++++++++++++++++*/
1275 /* reverseToggleCB */
1276 /*+++++++++++++++++++++++++++++++++++++++*/
1281 XtPointer client_data,
1282 XtPointer call_data )
1290 toggle = (Boolean) (intptr_t) client_data;
1292 if(mouse.type == POINTER3B)
1294 if (toggle == LEFT_HANDED)
1296 if (mouse.handed == LEFT_HANDED)
1298 mouse.handed = LEFT_HANDED;
1299 mouse.pixmap = mouse.b3_rev;
1300 mouse.pixmapSel = mouse.b3_revSel;
1301 for(i = 0, j = 3; i < 3; i++, j--)
1302 mouse.new_map_return[i] = j;
1303 mouse.new_map_return[3] = 5;
1304 mouse.new_map_return[4] = 4;
1308 if (mouse.handed == RIGHT_HANDED)
1310 mouse.handed = RIGHT_HANDED;
1311 mouse.pixmap = mouse.b3;
1312 mouse.pixmapSel = mouse.b3Sel;
1313 for(i = 0, j = 1; i < 3; i++, j++)
1314 mouse.new_map_return[i] = j;
1315 mouse.new_map_return[3] = 4;
1316 mouse.new_map_return[4] = 5;
1321 if (toggle == LEFT_HANDED)
1323 if (mouse.handed == LEFT_HANDED)
1325 mouse.handed = LEFT_HANDED;
1326 mouse.pixmap = mouse.b2_rev;
1327 mouse.pixmapSel = mouse.b2_revSel;
1328 for(i = 0, j = 2; i < 2; i++, j--)
1329 mouse.new_map_return[i] = j;
1333 if (mouse.handed == RIGHT_HANDED)
1335 mouse.handed = RIGHT_HANDED;
1336 mouse.pixmap = mouse.b2;
1337 mouse.pixmapSel = mouse.b2Sel;
1338 for(i = 0, j = 1; i < 2; i++, j++)
1339 mouse.new_map_return[i] = j;
1344 XtSetArg(args[n], XmNlabelPixmap, mouse.pixmap); n++;
1345 XtSetValues(mouse.pictButton, args, n);
1347 /* change Pointer Mapping */
1348 if (XSetPointerMapping(style.display, mouse.new_map_return, mouse.numButtons)
1350 _DtSimpleError (progName, DtWarning, NULL, MSG3, NULL);
1352 mouse.systemDefaultFlag = False;
1353 XtDestroyWidget(warnDialog);
1358 /*+++++++++++++++++++++++++++++++++++++++*/
1359 /* midreverseToggleCB */
1360 /*+++++++++++++++++++++++++++++++++++++++*/
1365 XtPointer client_data,
1366 XtPointer call_data )
1374 toggle = (Boolean) (intptr_t) client_data;
1376 if (toggle == ADJUST)
1378 if (mouse.function == ADJUST)
1380 mouse.function = ADJUST;
1384 if (mouse.function == TRANSFER)
1386 mouse.function = TRANSFER;
1388 mouse.btn2Changed = True;
1389 mouse.systemDefaultFlag = False;
1391 XtDestroyWidget(midwarnDialog);
1395 /*+++++++++++++++++++++++++++++++++++++++*/
1396 /* systemDefaultCB */
1397 /*+++++++++++++++++++++++++++++++++++++++*/
1401 XtPointer client_data,
1402 XtPointer call_data )
1406 Bool do_accel, do_thresh;
1407 int new_acceln, new_acceld, new_thresh;
1410 /* set default mouse values */
1413 new_thresh = THRESHDEFAULT;
1416 XChangePointerControl(style.display, do_accel, do_thresh, new_acceln,
1417 new_acceld, new_thresh);
1419 /*get default mouse values for sliders*/
1420 XGetPointerControl(style.display, &new_acceln, &new_acceld, &new_thresh);
1423 XtSetArg(args[n], XmNvalue,new_acceln); n++;
1424 XtSetValues(mouse.accelScale, args, n);
1427 XtSetArg(args[n], XmNvalue,new_thresh); n++;
1428 XtSetValues(mouse.threshScale, args, n);
1431 XtSetArg(args[n], XmNvalue,DCLICKDEFAULT/100); n++;
1432 XtSetValues(mouse.dclickScale, args, n);
1434 sprintf(dclickRes, multiClickTimeString, DCLICKDEFAULT);
1435 _DtAddToResource(style.display,dclickRes);
1437 /* change mouse mapping to default */
1438 if(mouse.type == POINTER3B)
1440 mouse.pixmap = mouse.b3;
1441 mouse.pixmapSel = mouse.b3Sel;
1442 for(i = 0, j = 1; i < 3; i++, j++)
1443 mouse.new_map_return[i] = j;
1444 mouse.new_map_return[3] = 4;
1445 mouse.new_map_return[4] = 5;
1449 mouse.pixmap = mouse.b2;
1450 mouse.pixmapSel = mouse.b2Sel;
1451 for(i = 0, j = 1; i < 2; i++, j++)
1452 mouse.new_map_return[i] = j;
1455 if (mouse.handed != RIGHT_HANDED)
1457 /* change Pointer Mapping */
1458 if(XSetPointerMapping(style.display, mouse.new_map_return,
1459 mouse.numButtons) != MappingSuccess)
1460 _DtSimpleError (progName, DtWarning, NULL, MSG3, NULL);
1463 XtSetArg(args[n], XmNlabelPixmap, mouse.pixmap); n++;
1464 XtSetValues(mouse.pictButton, args, n);
1467 mouse.handed = RIGHT_HANDED;
1468 XmToggleButtonGadgetSetState(mouse.rightToggle, True, True);
1469 XmToggleButtonGadgetSetState(mouse.leftToggle, False, False);
1473 if (mouse.function != TRANSFER)
1475 mouse.function = TRANSFER;
1476 mouse.btn2Changed = True;
1477 XmToggleButtonGadgetSetState(mouse.transferToggle, True, True);
1478 XmToggleButtonGadgetSetState(mouse.adjustToggle, False, False);
1481 mouse.systemDefaultFlag = True;
1485 /*+++++++++++++++++++++++++++++++++++++++*/
1487 /* callback for PushButtons in DialogBox */
1488 /*+++++++++++++++++++++++++++++++++++++++*/
1492 XtPointer client_data,
1493 XtPointer call_data )
1497 DtDialogBoxCallbackStruct *cb = (DtDialogBoxCallbackStruct *) call_data;
1498 Bool do_accel, do_thresh;
1500 char message1[6], message2[50], message3[6], message4[6];
1501 char pointerStr[70];
1502 static char dclickRes[40];
1503 static char enableBtn1Res[40];
1505 int new_acceln, new_acceld, new_thresh;
1507 switch (cb->button_position)
1513 /* if sendSettings is true send data to Session Manager */
1515 if(style.smState.smSendSettings)
1517 if (mouse.systemDefaultFlag && !mouse.dclickChanged)
1519 SmDefaultPointerSettings();
1521 else /* dclick or one of the sliders changed */
1523 sprintf(message1,"%d", mouse.numButtons );
1524 if(mouse.numButtons == 3 || mouse.numButtons == 5)
1525 sprintf(message2,"%d_%d_%d", mouse.new_map_return[0],
1526 mouse.new_map_return[1],
1527 mouse.new_map_return[2]);
1529 sprintf(message2,"%d_%d_%d_%d_%d", mouse.new_map_return[0],
1530 mouse.new_map_return[1],
1531 mouse.new_map_return[2],
1532 mouse.new_map_return[3],
1533 mouse.new_map_return[4]);
1534 sprintf(message3,"%d", getValue(mouse.accelScale));
1535 sprintf(message4,"%d", getValue(mouse.threshScale));
1537 sprintf(dclickRes, multiClickTimeString,
1538 getValue(mouse.dclickScale)*100);
1540 if (mouse.dclickChanged)
1542 if (style.xrdb.writeXrdbImmediate) {
1543 InfoDialog(IMMEDIATE_MSG, style.shell, False);
1544 _DtAddToResource(style.display,dclickRes);
1547 InfoDialog(LATER_MSG, style.shell, False);
1550 sprintf (pointerStr,"%s %s %s %s %s",
1551 message1, message2, message3, message4,
1554 SmNewPointerSettings (pointerStr);
1559 { /* sendSettings is False. If double click has changed update Xrdb */
1561 if (mouse.dclickChanged)
1563 InfoDialog(IMMEDIATE_MSG, style.shell, False);
1564 sprintf(dclickRes, multiClickTimeString,
1565 getValue(mouse.dclickScale)*100);
1566 _DtAddToResource(style.display,dclickRes);
1569 mouse.dclickChanged = False;
1571 if (mouse.btn2Changed)
1572 if(mouse.function == TRANSFER)
1573 sprintf(enableBtn1Res, enableBtn1TransferString, "button2_transfer");
1575 sprintf(enableBtn1Res, enableBtn1TransferString, "True");
1576 _DtAddToResource(style.display,enableBtn1Res);
1584 /* check if values and changePonterControl only if needed */
1586 new_acceln = getValue(mouse.accelScale);
1587 if (new_acceln != mouse.accel_numerator)
1589 /* reset to incoming mouse values */
1591 XtSetArg(args[n], XmNvalue,mouse.accel_numerator); n++;
1592 XtSetValues(mouse.accelScale, args, n);
1595 new_thresh = getValue(mouse.threshScale);
1596 if (new_thresh != mouse.threshold)
1598 /* reset to incoming mouse values */
1600 XtSetArg(args[n], XmNvalue,mouse.threshold); n++;
1601 XtSetValues(mouse.threshScale, args, n);
1605 XtSetArg(args[n], XmNvalue,mouse.mydclick); n++;
1606 XtSetValues(mouse.dclickScale, args, n);
1607 mouse.dclickChanged = False;
1608 XtSetMultiClickTime(style.display, mouse.mydclick*100);
1610 if ((new_thresh != mouse.threshold) ||
1611 (new_acceln != mouse.accel_numerator))
1613 do_accel = mouse.accel_numerator ? 1:0;
1614 do_thresh = mouse.threshold ? 1:0;
1615 XChangePointerControl(style.display, do_accel, do_thresh,
1616 mouse.accel_numerator, mouse.accel_denominator,
1621 if (mouse.handed != mouse.origHanded)
1623 if (XSetPointerMapping(style.display, mouse.map_return,
1624 mouse.numButtons) != MappingSuccess)
1625 _DtSimpleError (progName, DtWarning, NULL, MSG3, NULL);
1627 /* load the correct mouse pixmaps */
1629 if(mouse.type == POINTER3B)
1631 if (mouse.origHanded == LEFT_HANDED)
1633 mouse.pixmap = mouse.b3_rev;
1634 mouse.pixmapSel = mouse.b3_revSel;
1638 if (mouse.origHanded == RIGHT_HANDED)
1640 mouse.pixmap = mouse.b3;
1641 mouse.pixmapSel = mouse.b3Sel;
1647 if (mouse.origHanded == LEFT_HANDED)
1649 mouse.pixmap = mouse.b2_rev;
1650 mouse.pixmapSel = mouse.b2_revSel;
1654 if (mouse.origHanded == RIGHT_HANDED)
1656 mouse.pixmap = mouse.b2;
1657 mouse.pixmapSel = mouse.b2Sel;
1663 XtSetArg(args[n], XmNlabelPixmap, mouse.pixmap); n++;
1664 XtSetValues(mouse.pictButton, args, n);
1667 if (mouse.function != mouse.origFunction)
1669 mouse.function = mouse.origFunction;
1670 if (mouse.origFunction == TRANSFER)
1672 XmToggleButtonGadgetSetState(mouse.transferToggle, True, True);
1673 XmToggleButtonGadgetSetState(mouse.adjustToggle, False, False);
1677 XmToggleButtonGadgetSetState(mouse.transferToggle, False, False);
1678 XmToggleButtonGadgetSetState(mouse.adjustToggle, True, True);
1684 XtCallCallbacks(style.mouseDialog, XmNhelpCallback, (XtPointer)NULL);
1693 /************************************************************************
1696 * restore any state information saved with saveMouse.
1697 * This is called from restoreSession with the application
1698 * shell and the special xrm database retrieved for restore.
1699 ************************************************************************/
1705 XrmName xrm_name[5];
1706 XrmRepresentation rep_type;
1709 xrm_name [0] = XrmStringToQuark ("Mouse");
1712 /* get x position */
1713 xrm_name [1] = XrmStringToQuark ("x");
1714 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)){
1715 XtSetArg (save.posArgs[save.poscnt], XmNx, atoi((char *)value.addr)); save.poscnt++;
1716 save.restoreFlag = True;
1719 /* get y position */
1720 xrm_name [1] = XrmStringToQuark ("y");
1721 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)){
1722 XtSetArg (save.posArgs[save.poscnt], XmNy, atoi((char *)value.addr)); save.poscnt++;
1725 xrm_name [1] = XrmStringToQuark ("ismapped");
1726 XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value);
1727 /* Are we supposed to be mapped? */
1728 if (strcmp(value.addr, "True") == 0)
1729 popup_mouseBB(shell);
1732 /************************************************************************
1735 * This routine will write out to the passed file descriptor any state
1736 * information this dialog needs. It is called from saveSessionCB with the
1737 * file already opened.
1738 * All information is saved in xrm format. There is no restriction
1739 * on what can be saved. It doesn't have to be defined or be part of any
1740 * widget or Xt definition. Just name and save it here and recover it in
1741 * restoreBackdrop. The suggested minimum is whether you are mapped, and your
1743 ************************************************************************/
1749 char *bufr = style.tmpBigStr; /* size=[1024], make bigger if needed */
1750 XmVendorShellExtObject vendorExt;
1751 XmWidgetExtData extData;
1753 if (style.mouseDialog != NULL)
1755 if (XtIsManaged(style.mouseDialog))
1756 sprintf(bufr, "*Mouse.ismapped: True\n");
1758 sprintf(bufr, "*Mouse.ismapped: False\n");
1760 /* Get and write out the geometry info for our Window */
1761 x = XtX(XtParent(style.mouseDialog));
1762 y = XtY(XtParent(style.mouseDialog));
1764 /* Modify x & y to take into account window mgr frames
1765 * This is pretty bogus, but I don't know a better way to do it.
1767 extData = _XmGetWidgetExtData(style.shell, XmSHELL_EXTENSION);
1768 vendorExt = (XmVendorShellExtObject)extData->widget;
1769 x -= vendorExt->vendor.xOffset;
1770 y -= vendorExt->vendor.yOffset;
1772 sprintf(bufr, "%s*Mouse.x: %d\n", bufr, x);
1773 sprintf(bufr, "%s*Mouse.y: %d\n", bufr, y);
1775 if(-1 == write (fd, bufr, strlen(bufr))) {
1776 perror(strerror(errno));