Mouse.c 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /************************************<+>*************************************
  24. ****************************************************************************
  25. **
  26. ** File: Mouse.c
  27. **
  28. ** Project: DT 3.0
  29. **
  30. ** Description: Controls the Dtstyle Mouse dialog
  31. **
  32. **
  33. ** (c) Copyright Hewlett-Packard Company, 1990.
  34. **
  35. **
  36. **
  37. ****************************************************************************
  38. ************************************<+>*************************************/
  39. /*$XConsortium: Mouse.c /main/5 1996/07/19 13:45:42 pascale $*/
  40. #include <X11/Xlib.h>
  41. #include <errno.h>
  42. #include <Xm/Xm.h>
  43. #include <Xm/Form.h>
  44. #include <Xm/Frame.h>
  45. #include <Xm/LabelG.h>
  46. #include <Xm/MwmUtil.h>
  47. #include <Xm/MessageB.h>
  48. #include <Xm/PushB.h>
  49. #include <Xm/PushBG.h>
  50. #include <Xm/RowColumn.h>
  51. #include <Xm/Scale.h>
  52. #include <Xm/ToggleBG.h>
  53. #include <Xm/VendorSEP.h>
  54. #include <Dt/DialogBox.h>
  55. #include <Dt/Message.h>
  56. #include <Dt/SessionM.h>
  57. #include <Dt/HourGlass.h>
  58. #include <Dt/UserMsg.h>
  59. #include "Help.h"
  60. #include "Main.h"
  61. #include "SaveRestore.h"
  62. /*+++++++++++++++++++++++++++++++++++++++*/
  63. /* include extern functions */
  64. /*+++++++++++++++++++++++++++++++++++++++*/
  65. #include "Mouse.h"
  66. /*+++++++++++++++++++++++++++++++++++++++*/
  67. /* Local #defines */
  68. /*+++++++++++++++++++++++++++++++++++++++*/
  69. #define ACCEL_MIN 0
  70. #define ACCEL_MAX 10
  71. #define THRESH_MIN 0
  72. #define THRESH_MAX 15
  73. #define THRESHDEFAULT 10
  74. #define DCLICK_MIN 0
  75. #define DCLICK_MAX 10
  76. #define POINTER2B 0
  77. #define POINTER3B 1
  78. #define DCLICKDEFAULT 500
  79. #define RIGHT_HANDED 0
  80. #define LEFT_HANDED 1
  81. #define TRANSFER 0
  82. #define ADJUST 1
  83. #define LEFTMSG ((char *)GETMESSAGE(9, 1, "Left"))
  84. #define RIGHTMSG ((char *)GETMESSAGE(9, 2, "Right"))
  85. #define HANDMSG ((char *)GETMESSAGE(9, 3, "Handedness:"))
  86. #define MIDDLEMSG ((char *)GETMESSAGE(9, 4, "Button 2:"))
  87. #define MSG3 ((char *)GETMESSAGE(9, 10, "ERROR: setting pointer mapping\n"))
  88. #define TRANSMSG ((char *)GETMESSAGE(9, 11, "Transfer"))
  89. #define ADJMSG ((char *)GETMESSAGE(9, 12, "Adjust"))
  90. #define WARN_MSG ((char *)GETMESSAGE(9, 13, "The right and left mouse buttons will swap\n\
  91. functions immediately after you click on OK.\n\
  92. The `Test Double-Click' graphic in the Mouse\n\
  93. window shows the current handedness by the \n\
  94. positions of Button 1 and Button 3."))
  95. #define MID_WARN_MSG_T ((char *)GETMESSAGE(9, 14, "If you click on OK, mouse button 2 will be set\n\
  96. to `transfer' (drag) at your next session."))
  97. #define IMMEDIATE_MSG ((char *)GETMESSAGE(9, 15, "The new double-click time will take effect\n\
  98. as applications are restarted."))
  99. #define LATER_MSG ((char *)GETMESSAGE(9, 16, "The new double-click time will take effect\n\
  100. at your next session."))
  101. #define MID_WARN_MSG_A ((char *)GETMESSAGE(9, 19, "If you click on OK, mouse button 2 will be set\n\
  102. to `adjust' at your next session. Button 2 may\n\
  103. be used to adjust text and list selections.\n\
  104. Transfer actions (drag) on text and lists will\n\
  105. require the use of Button 1."))
  106. #define MENUMSG ((char *)GETMESSAGE(9, 20, "Menu"))
  107. #define B2 "Dtms2B.bm"
  108. #define B2_REV "Dtms2BR.bm"
  109. #define B3 "Dtms3B.bm"
  110. #define B3_REV "Dtms3BR.bm"
  111. static char *multiClickTimeString = "*multiClickTime:%d\n";
  112. static char *enableBtn1TransferString = "*enableBtn1Transfer:%s\n";
  113. static char *mouseString = "Mouse";
  114. /*+++++++++++++++++++++++++++++++++++++++*/
  115. /* Internal Functions */
  116. /*+++++++++++++++++++++++++++++++++++++++*/
  117. static Widget build_mouseDialog(
  118. Widget shell) ;
  119. static void formLayoutCB(
  120. Widget w,
  121. XtPointer client_data,
  122. XtPointer call_data) ;
  123. static void _DtmapCB_mouseDialog(
  124. Widget w,
  125. XtPointer client_data,
  126. XtPointer call_data) ;
  127. static int getValue(
  128. Widget w) ;
  129. static void valueChangedCB(
  130. Widget w,
  131. XtPointer client_data,
  132. XtPointer call_data) ;
  133. static void dclickVCCB(
  134. Widget w,
  135. XtPointer client_data,
  136. XtPointer call_data) ;
  137. static void dclickTestCB(
  138. Widget w,
  139. XtPointer client_data,
  140. XtPointer call_data) ;
  141. static void reverseToggleCB(
  142. Widget w,
  143. XtPointer client_data,
  144. XtPointer call_data) ;
  145. static void midreverseToggleCB(
  146. Widget w,
  147. XtPointer client_data,
  148. XtPointer call_data) ;
  149. static void warnToggleCB(
  150. Widget w,
  151. XtPointer client_data,
  152. XtPointer call_data) ;
  153. static void midwarnToggleCB(
  154. Widget w,
  155. XtPointer client_data,
  156. XtPointer call_data) ;
  157. static void cancelWarnCB(
  158. Widget w,
  159. XtPointer client_data,
  160. XtPointer call_data) ;
  161. static void midcancelWarnCB(
  162. Widget w,
  163. XtPointer client_data,
  164. XtPointer call_data) ;
  165. static void systemDefaultCB(
  166. Widget w,
  167. XtPointer client_data,
  168. XtPointer call_data) ;
  169. static void ButtonCB(
  170. Widget w,
  171. XtPointer client_data,
  172. XtPointer call_data) ;
  173. /*+++++++++++++++++++++++++++++++++++++++*/
  174. /* Internal Variables */
  175. /*+++++++++++++++++++++++++++++++++++++++*/
  176. typedef struct {
  177. Widget pictFrame;
  178. Widget pictRC;
  179. Widget pictButton;
  180. Widget pictLabel;
  181. Widget handLabGad;
  182. Widget rightToggle;
  183. Widget leftToggle;
  184. Widget middleLabGad;
  185. Widget transferToggle;
  186. Widget adjustToggle;
  187. Widget systemDefault;
  188. Widget accelLabGad;
  189. Widget threshLabGad;
  190. Widget dclickLabGad;
  191. Widget accelScale;
  192. Widget threshScale;
  193. Widget dclickScale;
  194. Pixmap pixmap;
  195. Pixmap b3;
  196. Pixmap b3_rev;
  197. Pixmap b2;
  198. Pixmap b2_rev;
  199. Pixmap pixmapSel;
  200. Pixmap b3Sel;
  201. Pixmap b3_revSel;
  202. Pixmap b2Sel;
  203. Pixmap b2_revSel;
  204. int type;
  205. int numButtons;
  206. int accel_numerator;
  207. int accel_denominator;
  208. int threshold;
  209. Boolean dclickChanged;
  210. Boolean btn2Changed;
  211. XtIntervalId timeID;
  212. int mydclick;
  213. Boolean systemDefaultFlag;
  214. unsigned char map_return[256];
  215. unsigned char new_map_return[256];
  216. Boolean origHanded;
  217. Boolean handed;
  218. Boolean function;
  219. Boolean origFunction;
  220. } Mouse;
  221. static Widget warnDialog;
  222. static Widget midwarnDialog;
  223. static Mouse mouse;
  224. static saveRestore save = {FALSE, 0, };
  225. /*+++++++++++++++++++++++++++++++++++++++*/
  226. /* popup_mouseBB */
  227. /*+++++++++++++++++++++++++++++++++++++++*/
  228. void
  229. popup_mouseBB( Widget shell )
  230. {
  231. if (style.mouseDialog == NULL) {
  232. _DtTurnOnHourGlass(shell);
  233. build_mouseDialog(shell);
  234. mouse.systemDefaultFlag = True;
  235. mouse.dclickChanged = False;
  236. mouse.btn2Changed = False;
  237. XtManageChild(style.mouseDialog);
  238. _DtTurnOffHourGlass(shell);
  239. }
  240. else
  241. {
  242. XtManageChild(style.mouseDialog);
  243. raiseWindow(XtWindow(XtParent(style.mouseDialog)));
  244. }
  245. }
  246. /*+++++++++++++++++++++++++++++++++++++++*/
  247. /* build__mouseDialog */
  248. /*+++++++++++++++++++++++++++++++++++++++*/
  249. static Widget
  250. build_mouseDialog( Widget shell )
  251. {
  252. int i, n;
  253. Arg args[MAX_ARGS];
  254. int nmap;
  255. XmString button_string[NUM_LABELS];
  256. Widget form;
  257. int count = 0;
  258. Widget widget_list[15];
  259. XmString string;
  260. Dimension MaxLabelWidth1;
  261. Dimension HandLabelWidth;
  262. Dimension MiddleLabelWidth;
  263. Dimension MaxToggleWidth;
  264. Dimension RightToggleWidth;
  265. Dimension TransferToggleWidth;
  266. XrmDatabase database;
  267. char *str_name;
  268. char *str_class;
  269. char **str_type_return;
  270. XrmValue value_return;
  271. /* check hil device# for 2 or 3 button mouse */
  272. /* IMPORTANT NOTE: */
  273. /* X servers will return different values for */
  274. /* mouse.numButtons in the call below. */
  275. /* The HP X server will return 5 if a quarted */
  276. /* threebutton mouse is present and a 3 if a */
  277. /* quarted two-button mouse is present. The IBM */
  278. /* does not support a two-button mouse. */
  279. /* The cod ebelow always loads a three-button */
  280. /* for IBM/Sun/HP unless a non-quarted two-button */
  281. /* mouse is present on the HP server. */
  282. /* When porting this code to a non IBM/Sun/HP */
  283. /* platform that has or supports a two-button */
  284. /* mouse the code below may have to be changed to */
  285. /* take into account the behavior of the new */
  286. /* server. */
  287. nmap = 256;
  288. mouse.numButtons = XGetPointerMapping(style.display, mouse.map_return,
  289. nmap);
  290. if ( mouse.numButtons == 2 )
  291. mouse.type = POINTER2B;
  292. else if ( mouse.numButtons == 3 || mouse.numButtons == 5 )
  293. mouse.type = POINTER3B;
  294. else
  295. mouse.type = 99;
  296. /* choose a bitmap based on button mapping *
  297. * and number of buttons */
  298. if(mouse.type == POINTER3B)
  299. {
  300. mouse.b3 = XmGetPixmap(style.screen, B3,
  301. style.secBSCol, style.secTSCol);
  302. mouse.b3_rev = XmGetPixmap(style.screen, B3_REV,
  303. style.secBSCol, style.secTSCol);
  304. mouse.b3Sel = XmGetPixmap(style.screen, B3,
  305. style.secTSCol, style.secBSCol );
  306. mouse.b3_revSel = XmGetPixmap(style.screen, B3_REV,
  307. style.secTSCol, style.secBSCol);
  308. if(mouse.map_return[0] == 1)
  309. {
  310. mouse.pixmap = mouse.b3;
  311. mouse.pixmapSel = mouse.b3Sel;
  312. }
  313. else
  314. {
  315. mouse.pixmap = mouse.b3_rev;
  316. mouse.pixmapSel = mouse.b3_revSel;
  317. }
  318. }
  319. else /* 2 button mouse */
  320. {
  321. mouse.b2 = XmGetPixmap(style.screen, B2,
  322. style.secBSCol, style.secTSCol);
  323. mouse.b2_rev = XmGetPixmap(style.screen, B2_REV,
  324. style.secBSCol, style.secTSCol);
  325. mouse.b2Sel = XmGetPixmap(style.screen, B2,
  326. style.secTSCol, style.secBSCol);
  327. mouse.b2_revSel = XmGetPixmap(style.screen, B2_REV,
  328. style.secTSCol, style.secBSCol);
  329. if(mouse.map_return[0] == 1)
  330. {
  331. mouse.pixmap = mouse.b2;
  332. mouse.pixmapSel = mouse.b2Sel;
  333. }
  334. else
  335. {
  336. mouse.pixmap = mouse.b2_rev;
  337. mouse.pixmapSel = mouse.b2_revSel;
  338. }
  339. }
  340. /*Get the value of doubleclick*/
  341. mouse.mydclick = XtGetMultiClickTime(style.display);
  342. if (mouse.mydclick > 0)
  343. mouse.mydclick = mouse.mydclick/100;
  344. if (mouse.mydclick < 1)
  345. mouse.mydclick = 1;
  346. /*Get the value of the enableBtn1Transfer resource */
  347. /*from the data base. */
  348. str_name = "*enableBtn1Transfer";
  349. str_class = "*EnableBtn1Transfer";
  350. database = XrmGetDatabase(style.display);
  351. if (!XrmGetResource(database, str_name, str_class, (char **)&str_type_return, &value_return))
  352. {
  353. mouse.function = TRANSFER;
  354. mouse.origFunction = TRANSFER;
  355. }
  356. else
  357. if (strcmp(value_return.addr, "True") == 0)
  358. {
  359. mouse.function = ADJUST;
  360. mouse.origFunction = ADJUST;
  361. }
  362. else
  363. {
  364. mouse.function = TRANSFER;
  365. mouse.origFunction = TRANSFER;
  366. }
  367. /* Set up DialogBoxDialog button labels */
  368. button_string[0] = CMPSTR((String) _DtOkString);
  369. button_string[1] = CMPSTR((String) _DtCancelString);
  370. button_string[2] = CMPSTR((String) _DtHelpString);
  371. /* Create toplevel DialogBox */
  372. /* saveRestore
  373. * Note that save.poscnt has been initialized elsewhere.
  374. * save.posArgs may contain information from restoreMouse().*/
  375. XtSetArg(save.posArgs[save.poscnt], XmNbuttonCount, NUM_LABELS);
  376. save.poscnt++;
  377. XtSetArg(save.posArgs[save.poscnt], XmNbuttonLabelStrings, button_string);
  378. save.poscnt++;
  379. XtSetArg (save.posArgs[save.poscnt], XmNdefaultPosition, False);
  380. save.poscnt++;
  381. style.mouseDialog = __DtCreateDialogBoxDialog(shell, mouseString,
  382. save.posArgs, save.poscnt);
  383. XtAddCallback(style.mouseDialog, XmNcallback, ButtonCB, NULL);
  384. XtAddCallback(style.mouseDialog, XmNhelpCallback,
  385. (XtCallbackProc)HelpRequestCB, (XtPointer)HELP_MOUSE_DIALOG);
  386. XmStringFree(button_string[0]);
  387. XmStringFree(button_string[1]);
  388. XmStringFree(button_string[2]);
  389. widget_list[0] = _DtDialogBoxGetButton(style.mouseDialog,2);
  390. n=0;
  391. XtSetArg(args[n], XmNautoUnmanage, False); n++;
  392. XtSetArg(args[n], XmNcancelButton, widget_list[0]); n++;
  393. XtSetValues (style.mouseDialog, args, n);
  394. n=0;
  395. XtSetArg(args[n], XmNtitle, ((char *)GETMESSAGE(9, 18, "Style Manager - Mouse"))); n++;
  396. XtSetArg (args[n], XmNuseAsyncGeometry, True); n++;
  397. XtSetArg(args[n], XmNmwmFunctions, DIALOG_MWM_FUNC); n++;
  398. XtSetValues (XtParent(style.mouseDialog), args, n);
  399. n = 0;
  400. XtSetArg(args[n], XmNhorizontalSpacing, style.horizontalSpacing); n++;
  401. XtSetArg(args[n], XmNverticalSpacing, style.verticalSpacing); n++;
  402. XtSetArg(args[n], XmNallowOverlap, False); n++;
  403. XtSetArg(args[n], XmNchildType, XmWORK_AREA); n++;
  404. form = XmCreateForm(style.mouseDialog, "mouseForm", args, n);
  405. n = 0;
  406. XtSetArg(args[n], XmNmarginHeight, LB_MARGIN_HEIGHT); n++;
  407. XtSetArg(args[n], XmNmarginWidth, LB_MARGIN_WIDTH); n++;
  408. string = CMPSTR(((char *)GETMESSAGE(9, 5, "Default")));
  409. XtSetArg(args[n], XmNlabelString, string); n++;
  410. widget_list[count++] =
  411. mouse.systemDefault= XmCreatePushButtonGadget(form, "systemDefault", args, n);
  412. XmStringFree(string);
  413. n = 0;
  414. XtSetArg(args[n], XmNorientation, XmVERTICAL); n++;
  415. widget_list[count++] =
  416. mouse.pictFrame= XmCreateFrame(form, "pictFrame", args, n);
  417. n = 0;
  418. XtSetArg(args[n], XmNorientation, XmVERTICAL); n++;
  419. XtSetArg(args[n], XmNadjustMargin, False); n++;
  420. XtSetArg(args[n], XmNentryAlignment, XmALIGNMENT_BEGINNING); n++;
  421. mouse.pictRC = XmCreateRowColumn(mouse.pictFrame, "pictRC", args, n);
  422. n = 0;
  423. XtSetArg(args[n], XmNlabelType, XmPIXMAP); n++;
  424. XtSetArg(args[n], XmNlabelPixmap, mouse.pixmap); n++;
  425. XtSetArg(args[n], XmNrecomputeSize, False); n++;
  426. XtSetArg(args[n], XmNmarginWidth, 0); n++;
  427. XtSetArg(args[n], XmNmarginHeight, 0); n++;
  428. XtSetArg(args[n], XmNshadowThickness, 0); n++;
  429. XtSetArg(args[n], XmNmultiClick, XmMULTICLICK_KEEP); n++;
  430. mouse.pictButton= XmCreatePushButton(mouse.pictRC, "mousePict", args, n);
  431. n = 0;
  432. string = CMPSTR ((char *)GETMESSAGE(9, 17, "Test\nDouble-Click"));
  433. XtSetArg(args[n], XmNlabelString, string); n++;
  434. mouse.pictLabel= XmCreateLabelGadget(mouse.pictRC, "mouseLabel", args, n);
  435. XmStringFree(string);
  436. n = 0;
  437. XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
  438. XtSetArg(args[n], XmNmarginHeight, 0); n++;
  439. string = CMPSTR(HANDMSG);
  440. XtSetArg(args[n], XmNlabelString, string); n++;
  441. widget_list[count++] =
  442. mouse.handLabGad= XmCreateLabelGadget(form,"handLabGad", args, n);
  443. XmStringFree(string);
  444. n=0;
  445. string = CMPSTR(RIGHTMSG);
  446. XtSetArg(args[n], XmNlabelString, string); n++;
  447. XtSetArg(args[n], XmNnavigationType, XmTAB_GROUP); n++;
  448. XtSetArg(args[n], XmNindicatorType, XmONE_OF_MANY); n++;
  449. XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
  450. mouse.rightToggle= XmCreateToggleButtonGadget(form,
  451. "rightToggle", args, n);
  452. XmStringFree(string);
  453. n=0;
  454. string = CMPSTR(LEFTMSG);
  455. XtSetArg(args[n], XmNlabelString, string); n++;
  456. XtSetArg(args[n], XmNnavigationType, XmTAB_GROUP); n++;
  457. XtSetArg(args[n], XmNindicatorType, XmONE_OF_MANY); n++;
  458. XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
  459. mouse.leftToggle= XmCreateToggleButtonGadget(form,
  460. "leftToggle", args, n);
  461. XmStringFree(string);
  462. n = 0;
  463. XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
  464. XtSetArg(args[n], XmNmarginHeight, 0); n++;
  465. string = CMPSTR(MIDDLEMSG);
  466. XtSetArg(args[n], XmNlabelString, string); n++;
  467. widget_list[count++] =
  468. mouse.middleLabGad= XmCreateLabelGadget(form,"middleLabGad", args, n);
  469. XmStringFree(string);
  470. n=0;
  471. string = CMPSTR(TRANSMSG);
  472. XtSetArg(args[n], XmNlabelString, string); n++;
  473. XtSetArg(args[n], XmNindicatorType, XmONE_OF_MANY); n++;
  474. XtSetArg(args[n], XmNnavigationType, XmTAB_GROUP); n++;
  475. XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
  476. mouse.transferToggle= XmCreateToggleButtonGadget(form,
  477. "transToggle", args, n);
  478. XmStringFree(string);
  479. n=0;
  480. string = CMPSTR(ADJMSG);
  481. XtSetArg(args[n], XmNlabelString, string); n++;
  482. XtSetArg(args[n], XmNnavigationType, XmTAB_GROUP); n++;
  483. XtSetArg(args[n], XmNindicatorType, XmONE_OF_MANY); n++;
  484. XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
  485. mouse.adjustToggle= XmCreateToggleButtonGadget(form,
  486. "adjToggle", args, n);
  487. XmStringFree(string);
  488. n = 0;
  489. XtSetArg(args[n], XmNalignment, XmALIGNMENT_END); n++;
  490. XtSetArg(args[n], XmNmarginHeight, 0); n++;
  491. string = CMPSTR(((char *)GETMESSAGE(9, 6, "Double-Click")));
  492. XtSetArg(args[n], XmNlabelString, string); n++;
  493. widget_list[count++] =
  494. mouse.dclickLabGad= XmCreateLabelGadget(form,"dclickLabGad", args, n);
  495. XmStringFree(string);
  496. n = 0;
  497. XtSetArg(args[n], XmNmaximum, DCLICK_MAX); n++;
  498. XtSetArg(args[n], XmNminimum, DCLICK_MIN); n++;
  499. XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
  500. XtSetArg(args[n], XmNprocessingDirection, XmMAX_ON_RIGHT); n++;
  501. XtSetArg(args[n], XmNhighlightThickness, SCALE_HIGHLIGHT_THICKNESS); n++;
  502. XtSetArg(args[n], XmNshowValue, True); n++;
  503. XtSetArg(args[n], XmNvalue, mouse.mydclick); n++;
  504. XtSetArg(args[n], XmNdecimalPoints, (short)1); n++;
  505. widget_list[count++] =
  506. mouse.dclickScale= XmCreateScale(form,"dclickScale", args, n);
  507. n = 0;
  508. XtSetArg(args[n], XmNalignment, XmALIGNMENT_END); n++;
  509. XtSetArg(args[n], XmNmarginHeight, 0); n++;
  510. string = CMPSTR(((char *)GETMESSAGE(9, 8, "Acceleration")));
  511. XtSetArg(args[n], XmNlabelString, string); n++;
  512. widget_list[count++] =
  513. mouse.accelLabGad= XmCreateLabelGadget(form,"accelLabGad", args, n);
  514. XmStringFree(string);
  515. n = 0;
  516. XtSetArg(args[n], XmNminimum, ACCEL_MIN); n++;
  517. XtSetArg(args[n], XmNmaximum, ACCEL_MAX); n++;
  518. XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
  519. XtSetArg(args[n], XmNprocessingDirection, XmMAX_ON_RIGHT); n++;
  520. XtSetArg(args[n], XmNhighlightThickness, SCALE_HIGHLIGHT_THICKNESS); n++;
  521. XtSetArg(args[n], XmNshowValue, True); n++;
  522. widget_list[count++] =
  523. mouse.accelScale= XmCreateScale(form,"accelScale", args, n);
  524. n = 0;
  525. XtSetArg(args[n], XmNalignment, XmALIGNMENT_END); n++;
  526. XtSetArg(args[n], XmNmarginHeight, 0); n++;
  527. string = CMPSTR(((char *)GETMESSAGE(9, 9, "Threshold")));
  528. XtSetArg(args[n], XmNlabelString, string); n++;
  529. widget_list[count++] =
  530. mouse.threshLabGad= XmCreateLabelGadget(form,"threshLabGad", args, n);
  531. XmStringFree(string);
  532. n = 0;
  533. XtSetArg(args[n], XmNminimum, THRESH_MIN); n++;
  534. XtSetArg(args[n], XmNmaximum, THRESH_MAX); n++;
  535. XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
  536. XtSetArg(args[n], XmNprocessingDirection, XmMAX_ON_RIGHT); n++;
  537. XtSetArg(args[n], XmNhighlightThickness, SCALE_HIGHLIGHT_THICKNESS); n++;
  538. XtSetArg(args[n], XmNshowValue, True); n++;
  539. widget_list[count++] =
  540. mouse.threshScale= XmCreateScale(form,"threshScale", args, n);
  541. XtAddCallback(style.mouseDialog, XmNmapCallback, formLayoutCB, NULL);
  542. XtAddCallback(style.mouseDialog, XmNmapCallback, _DtmapCB_mouseDialog, shell);
  543. XtAddCallback(mouse.systemDefault, XmNactivateCallback,
  544. systemDefaultCB, NULL);
  545. /* calculate the max width for toggles for the overall alignment */
  546. /* Set labels to max label width */
  547. MaxLabelWidth1 = HandLabelWidth = XtWidth(mouse.handLabGad);
  548. MiddleLabelWidth = XtWidth(mouse.middleLabGad);
  549. if (MiddleLabelWidth > MaxLabelWidth1)
  550. {
  551. MaxLabelWidth1 = MiddleLabelWidth;
  552. }
  553. MaxToggleWidth = RightToggleWidth = XtWidth(mouse.rightToggle);
  554. TransferToggleWidth = XtWidth(mouse.transferToggle);
  555. if (TransferToggleWidth > MaxToggleWidth)
  556. {
  557. MaxToggleWidth = TransferToggleWidth;
  558. }
  559. if (mouse.function == TRANSFER)
  560. {
  561. XmToggleButtonGadgetSetState(mouse.transferToggle, True, True);
  562. XmToggleButtonGadgetSetState(mouse.adjustToggle, False, False);
  563. }
  564. else
  565. {
  566. XmToggleButtonGadgetSetState(mouse.adjustToggle, True, True);
  567. XmToggleButtonGadgetSetState(mouse.transferToggle, False, False);
  568. }
  569. XtVaSetValues(mouse.handLabGad, XmNwidth, MaxLabelWidth1, NULL);
  570. XtVaSetValues(mouse.middleLabGad, XmNwidth, MaxLabelWidth1, NULL);
  571. XtVaSetValues(mouse.rightToggle, XmNwidth, MaxToggleWidth, NULL);
  572. XtVaSetValues(mouse.transferToggle, XmNwidth, MaxToggleWidth, NULL);
  573. XtAddCallback(mouse.rightToggle, XmNvalueChangedCallback,
  574. warnToggleCB, (XtPointer)RIGHT_HANDED);
  575. XtAddCallback(mouse.leftToggle, XmNvalueChangedCallback,
  576. warnToggleCB, (XtPointer)LEFT_HANDED);
  577. XtAddCallback(mouse.transferToggle, XmNvalueChangedCallback,
  578. midwarnToggleCB, (XtPointer)TRANSFER);
  579. XtAddCallback(mouse.adjustToggle, XmNvalueChangedCallback,
  580. midwarnToggleCB, (XtPointer)ADJUST);
  581. XtAddCallback(mouse.accelScale, XmNvalueChangedCallback,
  582. valueChangedCB, NULL);
  583. XtAddCallback(mouse.threshScale, XmNvalueChangedCallback,
  584. valueChangedCB, NULL);
  585. XtAddCallback(mouse.dclickScale, XmNvalueChangedCallback,
  586. dclickVCCB, (caddr_t)mouse.pictButton);
  587. XtAddCallback(mouse.pictButton, XmNactivateCallback,
  588. dclickTestCB, NULL);
  589. XtManageChild(form);
  590. XtManageChildren(widget_list,count);
  591. XtManageChild(mouse.pictRC);
  592. XtManageChild(mouse.pictButton);
  593. XtManageChild(mouse.pictLabel);
  594. XtManageChild(mouse.rightToggle);
  595. XtManageChild(mouse.leftToggle);
  596. /*
  597. * If there are only two mouse buttons then switch the
  598. * label for the transferToggle to "Menu" and mark it
  599. * insensitive but checked.
  600. * Otherwise manage both the transfer and adjust toggles.
  601. */
  602. if (mouse.numButtons == 2) {
  603. n=0;
  604. string = CMPSTR(MENUMSG);
  605. XtSetArg(args[n], XmNlabelString, string); n++;
  606. XtSetValues(mouse.transferToggle, args, n);
  607. XmStringFree(string);
  608. XmToggleButtonGadgetSetState(mouse.transferToggle, True, False);
  609. XtManageChild(mouse.transferToggle);
  610. } else {
  611. XtManageChild(mouse.transferToggle);
  612. XtManageChild(mouse.adjustToggle);
  613. }
  614. return(style.mouseDialog);
  615. }
  616. /*+++++++++++++++++++++++++++++++++++++++*/
  617. /* formLayoutCB */
  618. /*+++++++++++++++++++++++++++++++++++++++*/
  619. static void
  620. formLayoutCB(
  621. Widget w,
  622. XtPointer client_data,
  623. XtPointer call_data )
  624. {
  625. int n;
  626. Arg args[MAX_ARGS];
  627. Dimension MaxLabelWidth;
  628. Dimension AccelLabelWidth;
  629. Dimension ThreshLabelWidth;
  630. Dimension DclickLabelWidth;
  631. Dimension ScaleHeight;
  632. Dimension LabelHeight;
  633. int TopOffset;
  634. int LeftOffset;
  635. /* Do the scale and label attachments */
  636. ScaleHeight = XtHeight(mouse.accelScale);
  637. MaxLabelWidth = AccelLabelWidth = XtWidth(mouse.accelLabGad);
  638. LabelHeight = XtHeight(mouse.accelLabGad);
  639. ThreshLabelWidth = XtWidth(mouse.threshLabGad);
  640. if (ThreshLabelWidth > MaxLabelWidth)
  641. {
  642. MaxLabelWidth = ThreshLabelWidth;
  643. }
  644. DclickLabelWidth = XtWidth(mouse.dclickLabGad);
  645. if (DclickLabelWidth > MaxLabelWidth)
  646. {
  647. MaxLabelWidth = DclickLabelWidth;
  648. }
  649. /* Mouse Picture PushButton */
  650. n=0;
  651. XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); 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, style.horizontalSpacing); n++;
  656. XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
  657. XtSetValues (mouse.pictFrame, args, n);
  658. /* System Default Button */
  659. n=0;
  660. XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  661. XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
  662. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
  663. XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
  664. XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  665. XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
  666. XtSetValues (mouse.systemDefault, args, n);
  667. /* Handedness Label */
  668. n=0;
  669. XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  670. XtSetArg(args[n], XmNtopWidget, mouse.systemDefault); n++;
  671. XtSetArg(args[n], XmNtopOffset, 4*style.verticalSpacing); n++;
  672. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
  673. XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  674. XtSetArg(args[n], XmNleftWidget, mouse.pictFrame); n++;
  675. XtSetArg(args[n], XmNleftOffset, 2*style.horizontalSpacing); n++;
  676. XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
  677. XtSetValues (mouse.handLabGad, args, n);
  678. /* right toggle */
  679. n=0;
  680. XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  681. XtSetArg(args[n], XmNtopWidget, mouse.handLabGad); n++;
  682. XtSetArg(args[n], XmNtopOffset, -5); n++;
  683. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
  684. XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  685. XtSetArg(args[n], XmNleftWidget, mouse.handLabGad); n++;
  686. XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
  687. XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
  688. XtSetValues (mouse.rightToggle, args, n);
  689. /* left toggle */
  690. n=0;
  691. XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  692. XtSetArg(args[n], XmNtopWidget, mouse.handLabGad); n++;
  693. XtSetArg(args[n], XmNtopOffset, -5); n++;
  694. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
  695. XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  696. XtSetArg(args[n], XmNleftWidget, mouse.rightToggle); n++;
  697. XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
  698. XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  699. XtSetValues (mouse.leftToggle, args, n);
  700. /* Middle button Label */
  701. n=0;
  702. XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  703. XtSetArg(args[n], XmNtopWidget, mouse.handLabGad); n++;
  704. XtSetArg(args[n], XmNtopOffset, 3*style.verticalSpacing); n++;
  705. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
  706. XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  707. XtSetArg(args[n], XmNleftWidget, mouse.pictFrame); n++;
  708. XtSetArg(args[n], XmNleftOffset, 2*style.horizontalSpacing); n++;
  709. XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
  710. XtSetValues (mouse.middleLabGad, args, n);
  711. /* transfer toggle */
  712. n=0;
  713. XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  714. XtSetArg(args[n], XmNtopWidget, mouse.middleLabGad); n++;
  715. XtSetArg(args[n], XmNtopOffset, -5); n++;
  716. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
  717. XtSetArg(args[n], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  718. XtSetArg(args[n], XmNleftWidget, mouse.rightToggle); n++;
  719. XtSetArg(args[n], XmNleftOffset, 0); n++;
  720. XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
  721. XtSetValues (mouse.transferToggle, args, n);
  722. /* adjust toggle */
  723. n=0;
  724. XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  725. XtSetArg(args[n], XmNtopWidget, mouse.middleLabGad); n++;
  726. XtSetArg(args[n], XmNtopOffset, -5); n++;
  727. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
  728. XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  729. XtSetArg(args[n], XmNleftWidget, mouse.transferToggle); n++;
  730. XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
  731. XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  732. XtSetValues (mouse.adjustToggle, args, n);
  733. TopOffset = ScaleHeight + style.verticalSpacing - LabelHeight;
  734. /* DoubleClick Label */
  735. n=0;
  736. XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  737. XtSetArg(args[n], XmNtopWidget, mouse.pictFrame) ; n++;
  738. XtSetArg(args[n], XmNtopOffset, TopOffset); n++;
  739. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
  740. XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  741. LeftOffset = MaxLabelWidth + style.horizontalSpacing - DclickLabelWidth;
  742. XtSetArg(args[n], XmNleftOffset, LeftOffset); n++;
  743. XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
  744. XtSetValues (mouse.dclickLabGad, args, n);
  745. /* DoubleClick Scale */
  746. n=0;
  747. XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++;
  748. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  749. XtSetArg(args[n], XmNbottomWidget, mouse.dclickLabGad); n++;
  750. XtSetArg(args[n], XmNbottomOffset, 0); n++;
  751. XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  752. XtSetArg(args[n], XmNleftWidget, mouse.dclickLabGad); n++;
  753. XtSetArg(args[n], XmNleftOffset, 2*style.horizontalSpacing); n++;
  754. XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  755. XtSetValues (mouse.dclickScale, args, n);
  756. /* Acceleration Label */
  757. n=0;
  758. XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  759. XtSetArg(args[n], XmNtopWidget, mouse.dclickLabGad); n++;
  760. XtSetArg(args[n], XmNtopOffset, TopOffset); n++;
  761. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
  762. XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  763. LeftOffset = MaxLabelWidth + style.horizontalSpacing - AccelLabelWidth;
  764. XtSetArg(args[n], XmNleftOffset, LeftOffset); n++;
  765. XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
  766. XtSetValues (mouse.accelLabGad, args, n);
  767. /* Acceleration Scale */
  768. n=0;
  769. XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++;
  770. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  771. XtSetArg(args[n], XmNbottomWidget, mouse.accelLabGad); n++;
  772. XtSetArg(args[n], XmNbottomOffset, 0); n++;
  773. XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  774. XtSetArg(args[n], XmNleftWidget, mouse.accelLabGad); n++;
  775. XtSetArg(args[n], XmNleftOffset, 2*style.horizontalSpacing); n++;
  776. XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  777. XtSetValues (mouse.accelScale, args, n);
  778. /* Threshold Label */
  779. n=0;
  780. XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
  781. XtSetArg(args[n], XmNtopWidget, mouse.accelScale); n++;
  782. XtSetArg(args[n], XmNtopOffset, TopOffset); n++;
  783. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  784. XtSetArg(args[n], XmNbottomOffset, style.verticalSpacing); n++;
  785. XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  786. LeftOffset = MaxLabelWidth + style.horizontalSpacing - ThreshLabelWidth;
  787. XtSetArg(args[n], XmNleftOffset, LeftOffset); n++;
  788. XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
  789. XtSetValues (mouse.threshLabGad, args, n);
  790. /* Threshold Scale */
  791. n=0;
  792. XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++;
  793. XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  794. XtSetArg(args[n], XmNbottomWidget, mouse.threshLabGad); n++;
  795. XtSetArg(args[n], XmNbottomOffset, 0); n++;
  796. XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  797. XtSetArg(args[n], XmNleftWidget, mouse.threshLabGad); n++;
  798. XtSetArg(args[n], XmNleftOffset, 2*style.horizontalSpacing); n++;
  799. XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  800. XtSetValues (mouse.threshScale, args, n);
  801. XtRemoveCallback(style.mouseDialog, XmNmapCallback, formLayoutCB, NULL);
  802. }
  803. /*+++++++++++++++++++++++++++++++++++++++*/
  804. /* _DtmapCB_mouseDialog */
  805. /*+++++++++++++++++++++++++++++++++++++++*/
  806. static void
  807. _DtmapCB_mouseDialog(
  808. Widget w,
  809. XtPointer client_data,
  810. XtPointer call_data )
  811. {
  812. int n;
  813. int i;
  814. int nmap;
  815. Arg args[MAX_ARGS];
  816. static int first_time = 1;
  817. if (first_time)
  818. {
  819. DtWsmRemoveWorkspaceFunctions(style.display, XtWindow(XtParent(w)));
  820. if (!save.restoreFlag)
  821. putDialog((Widget)client_data, w);
  822. first_time = 0;
  823. }
  824. else
  825. {
  826. /* Don't need to do XGetPointerMapping first time dialog
  827. * is mapped because it is done when dialog is created
  828. * The type of device will not change between remapping
  829. */
  830. nmap = 256;
  831. mouse.numButtons = XGetPointerMapping(style.display,
  832. mouse.map_return, nmap);
  833. }
  834. /* save mouse mapping values */
  835. for (i=0; i<mouse.numButtons; i++)
  836. mouse.new_map_return[i] = mouse.map_return[i];
  837. /* change Pointer Mapping */
  838. /* the ReverseToggleCB will set the correct Pixmap */
  839. if (mouse.map_return[0] == 1) /* right-handed */
  840. {
  841. mouse.handed = RIGHT_HANDED;
  842. mouse.origHanded = RIGHT_HANDED;
  843. XmToggleButtonGadgetSetState(mouse.rightToggle, True, True);
  844. XmToggleButtonGadgetSetState(mouse.leftToggle, False, False);
  845. }
  846. else /* left-handed */
  847. {
  848. mouse.handed = LEFT_HANDED;
  849. mouse.origHanded = LEFT_HANDED;
  850. XmToggleButtonGadgetSetState(mouse.leftToggle, True, True);
  851. XmToggleButtonGadgetSetState(mouse.rightToggle, False, False);
  852. }
  853. /* MultiClickTime will not change between remapping */
  854. XGetPointerControl(style.display, &mouse.accel_numerator,
  855. &mouse.accel_denominator, &mouse.threshold);
  856. n=0;
  857. XtSetArg(args[n], XmNvalue,mouse.accel_numerator); n++;
  858. XtSetValues(mouse.accelScale, args, n);
  859. n=0;
  860. XtSetArg(args[n], XmNvalue,mouse.threshold); n++;
  861. XtSetValues(mouse.threshScale, args, n);
  862. }
  863. static int
  864. getValue(
  865. Widget w )
  866. {
  867. int n, value;
  868. Arg args[1];
  869. n=0;
  870. XtSetArg(args[n], XmNvalue, &value); n++;
  871. XtGetValues(w, args, n);
  872. return(value);
  873. }
  874. /*+++++++++++++++++++++++++++++++++++++++*/
  875. /* valueChangedCB */
  876. /*+++++++++++++++++++++++++++++++++++++++*/
  877. static void
  878. valueChangedCB(
  879. Widget w,
  880. XtPointer client_data,
  881. XtPointer call_data )
  882. {
  883. int new_acceln, new_acceld, new_thresh;
  884. /* set mouse parameters to new scale values */
  885. new_acceld = 1;
  886. new_acceln = getValue(mouse.accelScale);
  887. new_thresh = getValue(mouse.threshScale);
  888. XChangePointerControl(style.display, True, True, new_acceln,
  889. new_acceld, new_thresh);
  890. mouse.systemDefaultFlag = False;
  891. }
  892. /*+++++++++++++++++++++++++++++++++++++++*/
  893. /* dclickVCCB */
  894. /*+++++++++++++++++++++++++++++++++++++++*/
  895. static void
  896. dclickVCCB(
  897. Widget w,
  898. XtPointer client_data,
  899. XtPointer call_data )
  900. {
  901. XmScaleCallbackStruct *cb = (XmScaleCallbackStruct *) call_data;
  902. mouse.dclickChanged = True;
  903. XtSetMultiClickTime (style.display, (cb->value)*100);
  904. }
  905. /*+++++++++++++++++++++++++++++++++++++++*/
  906. /* dclickTestCB */
  907. /*+++++++++++++++++++++++++++++++++++++++*/
  908. static void
  909. dclickTestCB(
  910. Widget w,
  911. XtPointer client_data,
  912. XtPointer call_data )
  913. {
  914. Arg color[3], args[10]; /* arg list */
  915. int n; /* arg count */
  916. XmPushButtonCallbackStruct *cb = (XmPushButtonCallbackStruct *)call_data;
  917. static int selectstate = False;
  918. if (cb->event->xbutton.button == 1)
  919. {
  920. if(cb->click_count == 2)
  921. {
  922. if (selectstate)
  923. {
  924. n=0;
  925. XtSetArg(color[n], XmNlabelPixmap, mouse.pixmap); n++;
  926. XtSetValues (w, color, n);
  927. if (style.useMultiColorIcons)
  928. {
  929. n=0;
  930. XtSetArg(color[n], XmNbackground, style.secBgCol); n++;
  931. XtSetValues (w, color, n);
  932. XtSetValues (mouse.pictRC, color, n);
  933. XtSetValues (mouse.pictLabel, color, n);
  934. }
  935. selectstate = False;
  936. }
  937. else
  938. {
  939. /* This will change the background color to select color,
  940. but it causes the pixmap to redraw if IT was changed.*/
  941. n=0;
  942. XtSetArg(color[n], XmNlabelPixmap, mouse.pixmapSel); n++;
  943. XtSetValues (w, color, n);
  944. if (style.useMultiColorIcons)
  945. {
  946. n=0;
  947. XtSetArg(color[n], XmNbackground, style.secSelectColor); n++;
  948. XtSetValues (w, color, n);
  949. XtSetValues (mouse.pictRC, color, n);
  950. XtSetValues (mouse.pictLabel, color, n);
  951. }
  952. selectstate = True;
  953. }
  954. }
  955. }
  956. }
  957. /*+++++++++++++++++++++++++++++++++++++++**/
  958. /* warnToggleCB - put up a warning dialog */
  959. /* about changing the handedness. */
  960. /*+++++++++++++++++++++++++++++++++++++++**/
  961. static void
  962. warnToggleCB(
  963. Widget w,
  964. XtPointer client_data,
  965. XtPointer call_data )
  966. {
  967. int n;
  968. Arg args[10];
  969. XmString string;
  970. Boolean set;
  971. if (w == mouse.leftToggle && mouse.handed == LEFT_HANDED)
  972. {
  973. XmToggleButtonGadgetSetState(mouse.leftToggle, True, False);
  974. return;
  975. }
  976. if (w == mouse.rightToggle && mouse.handed == RIGHT_HANDED)
  977. {
  978. XmToggleButtonGadgetSetState(mouse.rightToggle, True, False);
  979. return;
  980. }
  981. if (w == mouse.rightToggle)
  982. {
  983. XmToggleButtonGadgetSetState(mouse.leftToggle, False, False);
  984. }
  985. else
  986. {
  987. XmToggleButtonGadgetSetState(mouse.rightToggle, False, False);
  988. }
  989. n = 0;
  990. XtSetArg(args[n], XmNokLabelString, CMPSTR((String) _DtOkString)); n++;
  991. XtSetArg(args[n], XmNcancelLabelString, CMPSTR((String) _DtCancelString)); n++;
  992. string = CMPSTR(WARN_MSG);
  993. XtSetArg(args[n], XmNmessageString, string); n++;
  994. XtSetArg(args[n], XmNmwmFunctions, DIALOG_MWM_FUNC ); n++;
  995. XtSetArg(args[n], XmNborderWidth, 3); n++;
  996. XtSetArg(args[n], XmNdialogStyle, XmDIALOG_SYSTEM_MODAL); n++;
  997. XtSetArg(args[n], XmNdialogTitle, CMPSTR((char *)GETMESSAGE(2,2, "Notice"))); n++;
  998. warnDialog = XmCreateInformationDialog(style.shell, "WarnDialog", args, n);
  999. XmStringFree(string);
  1000. XtUnmanageChild (XmMessageBoxGetChild(warnDialog, XmDIALOG_HELP_BUTTON));
  1001. XtAddCallback(warnDialog, XmNokCallback, reverseToggleCB, client_data);
  1002. XtAddCallback(warnDialog, XmNcancelCallback, cancelWarnCB, client_data);
  1003. XtManageChild(warnDialog);
  1004. }
  1005. /*++++++++++++++++++++++++++++++++++++++++++**/
  1006. /* midwarnToggleCB - put up a warning dialog */
  1007. /* about changing the function of the middle */
  1008. /* button. */
  1009. /*++++++++++++++++++++++++++++++++++++++++++**/
  1010. static void
  1011. midwarnToggleCB(
  1012. Widget w,
  1013. XtPointer client_data,
  1014. XtPointer call_data )
  1015. {
  1016. int n;
  1017. Arg args[10];
  1018. XmString warnstring;
  1019. Boolean set;
  1020. if (w == mouse.adjustToggle && mouse.function == ADJUST)
  1021. {
  1022. XmToggleButtonGadgetSetState(mouse.adjustToggle, True, False);
  1023. return;
  1024. }
  1025. if (w == mouse.transferToggle && mouse.function == TRANSFER)
  1026. {
  1027. XmToggleButtonGadgetSetState(mouse.transferToggle, True, False);
  1028. return;
  1029. }
  1030. n = 0;
  1031. XtSetArg(args[n], XmNokLabelString, CMPSTR((String) _DtOkString)); n++;
  1032. XtSetArg(args[n], XmNcancelLabelString, CMPSTR((String) _DtCancelString)); n++;
  1033. XtSetArg(args[n], XmNborderWidth, 3); n++;
  1034. XtSetArg(args[n], XmNmwmFunctions, DIALOG_MWM_FUNC ); n++;
  1035. XtSetArg(args[n], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL); n++;
  1036. XtSetArg(args[n], XmNdialogTitle, CMPSTR((char *)GETMESSAGE(2,2, "Notice"))); n++;
  1037. midwarnDialog = XmCreateInformationDialog(style.shell, "MidWarnDialog", args, n);
  1038. XtUnmanageChild (XmMessageBoxGetChild(midwarnDialog, XmDIALOG_HELP_BUTTON));
  1039. if ((intptr_t)client_data == TRANSFER)
  1040. {
  1041. warnstring = CMPSTR(MID_WARN_MSG_T);
  1042. XtVaSetValues(midwarnDialog, XmNmessageString, warnstring, NULL); n++;
  1043. XmToggleButtonGadgetSetState(mouse.adjustToggle, False, False);
  1044. }
  1045. else
  1046. {
  1047. warnstring = CMPSTR(MID_WARN_MSG_A);
  1048. XtVaSetValues(midwarnDialog, XmNmessageString, warnstring, NULL); n++;
  1049. XmToggleButtonGadgetSetState(mouse.transferToggle, False, False);
  1050. }
  1051. XmStringFree(warnstring);
  1052. XtAddCallback(midwarnDialog, XmNokCallback, midreverseToggleCB,
  1053. client_data);
  1054. XtAddCallback(midwarnDialog, XmNcancelCallback, midcancelWarnCB,
  1055. client_data);
  1056. XtManageChild(midwarnDialog);
  1057. }
  1058. /*+++++++++++++++++++++++++++++++++++++++*/
  1059. /* cancelWarnCB - callback for the */
  1060. /* cancel button of the warnDialog */
  1061. /*+++++++++++++++++++++++++++++++++++++++*/
  1062. static void
  1063. cancelWarnCB(
  1064. Widget w,
  1065. XtPointer client_data,
  1066. XtPointer call_data )
  1067. {
  1068. int n;
  1069. Arg args[10];
  1070. XmString string;
  1071. if (mouse.handed == RIGHT_HANDED)
  1072. {
  1073. XmToggleButtonGadgetSetState(mouse.rightToggle, True, False);
  1074. XmToggleButtonGadgetSetState(mouse.leftToggle, False, False);
  1075. }
  1076. else
  1077. {
  1078. XmToggleButtonGadgetSetState(mouse.leftToggle, True, False);
  1079. XmToggleButtonGadgetSetState(mouse.rightToggle, False, False);
  1080. }
  1081. XtDestroyWidget(warnDialog);
  1082. }
  1083. /*+++++++++++++++++++++++++++++++++++++++*/
  1084. /* midcancelWarnCB - callback for the */
  1085. /* cancel button of the midwarnDialog */
  1086. /*+++++++++++++++++++++++++++++++++++++++*/
  1087. static void
  1088. midcancelWarnCB(
  1089. Widget w,
  1090. XtPointer client_data,
  1091. XtPointer call_data )
  1092. {
  1093. int n;
  1094. Arg args[10];
  1095. XmString string;
  1096. if (mouse.function == TRANSFER)
  1097. {
  1098. XmToggleButtonGadgetSetState(mouse.transferToggle, True, True);
  1099. XmToggleButtonGadgetSetState(mouse.adjustToggle, False, False);
  1100. }
  1101. else
  1102. {
  1103. XmToggleButtonGadgetSetState(mouse.adjustToggle, True, True);
  1104. XmToggleButtonGadgetSetState(mouse.transferToggle, False, False);
  1105. }
  1106. XtDestroyWidget(midwarnDialog);
  1107. }
  1108. /*+++++++++++++++++++++++++++++++++++++++*/
  1109. /* reverseToggleCB */
  1110. /*+++++++++++++++++++++++++++++++++++++++*/
  1111. static void
  1112. reverseToggleCB(
  1113. Widget w,
  1114. XtPointer client_data,
  1115. XtPointer call_data )
  1116. {
  1117. int n;
  1118. int i, j;
  1119. Arg args[MAX_ARGS];
  1120. Boolean set;
  1121. Boolean toggle;
  1122. toggle = (Boolean) (intptr_t) client_data;
  1123. if(mouse.type == POINTER3B)
  1124. {
  1125. if (toggle == LEFT_HANDED)
  1126. {
  1127. if (mouse.handed == LEFT_HANDED)
  1128. return;
  1129. mouse.handed = LEFT_HANDED;
  1130. mouse.pixmap = mouse.b3_rev;
  1131. mouse.pixmapSel = mouse.b3_revSel;
  1132. for(i = 0, j = 3; i < 3; i++, j--)
  1133. mouse.new_map_return[i] = j;
  1134. mouse.new_map_return[3] = 5;
  1135. mouse.new_map_return[4] = 4;
  1136. }
  1137. else
  1138. {
  1139. if (mouse.handed == RIGHT_HANDED)
  1140. return;
  1141. mouse.handed = RIGHT_HANDED;
  1142. mouse.pixmap = mouse.b3;
  1143. mouse.pixmapSel = mouse.b3Sel;
  1144. for(i = 0, j = 1; i < 3; i++, j++)
  1145. mouse.new_map_return[i] = j;
  1146. mouse.new_map_return[3] = 4;
  1147. mouse.new_map_return[4] = 5;
  1148. }
  1149. }
  1150. else /* 2B mouse */
  1151. {
  1152. if (toggle == LEFT_HANDED)
  1153. {
  1154. if (mouse.handed == LEFT_HANDED)
  1155. return;
  1156. mouse.handed = LEFT_HANDED;
  1157. mouse.pixmap = mouse.b2_rev;
  1158. mouse.pixmapSel = mouse.b2_revSel;
  1159. for(i = 0, j = 2; i < 2; i++, j--)
  1160. mouse.new_map_return[i] = j;
  1161. }
  1162. else
  1163. {
  1164. if (mouse.handed == RIGHT_HANDED)
  1165. return;
  1166. mouse.handed = RIGHT_HANDED;
  1167. mouse.pixmap = mouse.b2;
  1168. mouse.pixmapSel = mouse.b2Sel;
  1169. for(i = 0, j = 1; i < 2; i++, j++)
  1170. mouse.new_map_return[i] = j;
  1171. }
  1172. }
  1173. n=0;
  1174. XtSetArg(args[n], XmNlabelPixmap, mouse.pixmap); n++;
  1175. XtSetValues(mouse.pictButton, args, n);
  1176. /* change Pointer Mapping */
  1177. if (XSetPointerMapping(style.display, mouse.new_map_return, mouse.numButtons)
  1178. != MappingSuccess)
  1179. _DtSimpleError (progName, DtWarning, NULL, MSG3, NULL);
  1180. mouse.systemDefaultFlag = False;
  1181. XtDestroyWidget(warnDialog);
  1182. }
  1183. /*+++++++++++++++++++++++++++++++++++++++*/
  1184. /* midreverseToggleCB */
  1185. /*+++++++++++++++++++++++++++++++++++++++*/
  1186. static void
  1187. midreverseToggleCB(
  1188. Widget w,
  1189. XtPointer client_data,
  1190. XtPointer call_data )
  1191. {
  1192. int n;
  1193. int i, j;
  1194. Arg args[MAX_ARGS];
  1195. Boolean set;
  1196. Boolean toggle;
  1197. toggle = (Boolean) (intptr_t) client_data;
  1198. if (toggle == ADJUST)
  1199. {
  1200. if (mouse.function == ADJUST)
  1201. return;
  1202. mouse.function = ADJUST;
  1203. }
  1204. else
  1205. {
  1206. if (mouse.function == TRANSFER)
  1207. return;
  1208. mouse.function = TRANSFER;
  1209. }
  1210. mouse.btn2Changed = True;
  1211. mouse.systemDefaultFlag = False;
  1212. XtDestroyWidget(midwarnDialog);
  1213. }
  1214. /*+++++++++++++++++++++++++++++++++++++++*/
  1215. /* systemDefaultCB */
  1216. /*+++++++++++++++++++++++++++++++++++++++*/
  1217. static void
  1218. systemDefaultCB(
  1219. Widget w,
  1220. XtPointer client_data,
  1221. XtPointer call_data )
  1222. {
  1223. int n, i, j;
  1224. Arg args[MAX_ARGS];
  1225. Bool do_accel, do_thresh;
  1226. int new_acceln, new_acceld, new_thresh;
  1227. char dclickRes[40];
  1228. /* set default mouse values */
  1229. new_acceld = -1;
  1230. new_acceln = -1;
  1231. new_thresh = THRESHDEFAULT;
  1232. do_accel = 1;
  1233. do_thresh = 1;
  1234. XChangePointerControl(style.display, do_accel, do_thresh, new_acceln,
  1235. new_acceld, new_thresh);
  1236. /*get default mouse values for sliders*/
  1237. XGetPointerControl(style.display, &new_acceln, &new_acceld, &new_thresh);
  1238. n=0;
  1239. XtSetArg(args[n], XmNvalue,new_acceln); n++;
  1240. XtSetValues(mouse.accelScale, args, n);
  1241. n=0;
  1242. XtSetArg(args[n], XmNvalue,new_thresh); n++;
  1243. XtSetValues(mouse.threshScale, args, n);
  1244. n=0;
  1245. XtSetArg(args[n], XmNvalue,DCLICKDEFAULT/100); n++;
  1246. XtSetValues(mouse.dclickScale, args, n);
  1247. sprintf(dclickRes, multiClickTimeString, DCLICKDEFAULT);
  1248. _DtAddToResource(style.display,dclickRes);
  1249. /* change mouse mapping to default */
  1250. if(mouse.type == POINTER3B)
  1251. {
  1252. mouse.pixmap = mouse.b3;
  1253. mouse.pixmapSel = mouse.b3Sel;
  1254. for(i = 0, j = 1; i < 3; i++, j++)
  1255. mouse.new_map_return[i] = j;
  1256. mouse.new_map_return[3] = 4;
  1257. mouse.new_map_return[4] = 5;
  1258. }
  1259. else
  1260. {
  1261. mouse.pixmap = mouse.b2;
  1262. mouse.pixmapSel = mouse.b2Sel;
  1263. for(i = 0, j = 1; i < 2; i++, j++)
  1264. mouse.new_map_return[i] = j;
  1265. }
  1266. if (mouse.handed != RIGHT_HANDED)
  1267. {
  1268. /* change Pointer Mapping */
  1269. if(XSetPointerMapping(style.display, mouse.new_map_return,
  1270. mouse.numButtons) != MappingSuccess)
  1271. _DtSimpleError (progName, DtWarning, NULL, MSG3, NULL);
  1272. n=0;
  1273. XtSetArg(args[n], XmNlabelPixmap, mouse.pixmap); n++;
  1274. XtSetValues(mouse.pictButton, args, n);
  1275. mouse.handed = RIGHT_HANDED;
  1276. XmToggleButtonGadgetSetState(mouse.rightToggle, True, True);
  1277. XmToggleButtonGadgetSetState(mouse.leftToggle, False, False);
  1278. }
  1279. if (mouse.function != TRANSFER)
  1280. {
  1281. mouse.function = TRANSFER;
  1282. mouse.btn2Changed = True;
  1283. XmToggleButtonGadgetSetState(mouse.transferToggle, True, True);
  1284. XmToggleButtonGadgetSetState(mouse.adjustToggle, False, False);
  1285. }
  1286. mouse.systemDefaultFlag = True;
  1287. }
  1288. /*+++++++++++++++++++++++++++++++++++++++*/
  1289. /* ButtonCB */
  1290. /* callback for PushButtons in DialogBox */
  1291. /*+++++++++++++++++++++++++++++++++++++++*/
  1292. static void
  1293. ButtonCB(
  1294. Widget w,
  1295. XtPointer client_data,
  1296. XtPointer call_data )
  1297. {
  1298. int n, i, j;
  1299. Arg args[MAX_ARGS];
  1300. DtDialogBoxCallbackStruct *cb = (DtDialogBoxCallbackStruct *) call_data;
  1301. Bool do_accel, do_thresh;
  1302. Bool set;
  1303. char message1[6], message2[50], message3[6], message4[6];
  1304. char pointerStr[70];
  1305. static char dclickRes[40];
  1306. static char enableBtn1Res[40];
  1307. int dclick;
  1308. int new_acceln, new_acceld, new_thresh;
  1309. switch (cb->button_position)
  1310. {
  1311. case OK_BUTTON:
  1312. XtUnmanageChild(w);
  1313. /* if sendSettings is true send data to Session Manager */
  1314. if(style.smState.smSendSettings)
  1315. {
  1316. if (mouse.systemDefaultFlag && !mouse.dclickChanged)
  1317. {
  1318. SmDefaultPointerSettings();
  1319. }
  1320. else /* dclick or one of the sliders changed */
  1321. {
  1322. sprintf(message1,"%d", mouse.numButtons );
  1323. if(mouse.numButtons == 3 || mouse.numButtons == 5)
  1324. sprintf(message2,"%d_%d_%d", mouse.new_map_return[0],
  1325. mouse.new_map_return[1],
  1326. mouse.new_map_return[2]);
  1327. else
  1328. sprintf(message2,"%d_%d_%d_%d_%d", mouse.new_map_return[0],
  1329. mouse.new_map_return[1],
  1330. mouse.new_map_return[2],
  1331. mouse.new_map_return[3],
  1332. mouse.new_map_return[4]);
  1333. sprintf(message3,"%d", getValue(mouse.accelScale));
  1334. sprintf(message4,"%d", getValue(mouse.threshScale));
  1335. sprintf(dclickRes, multiClickTimeString,
  1336. getValue(mouse.dclickScale)*100);
  1337. if (mouse.dclickChanged)
  1338. {
  1339. if (style.xrdb.writeXrdbImmediate) {
  1340. InfoDialog(IMMEDIATE_MSG, style.shell, False);
  1341. _DtAddToResource(style.display,dclickRes);
  1342. }
  1343. else
  1344. InfoDialog(LATER_MSG, style.shell, False);
  1345. }
  1346. sprintf (pointerStr,"%s %s %s %s %s",
  1347. message1, message2, message3, message4,
  1348. dclickRes );
  1349. SmNewPointerSettings (pointerStr);
  1350. }
  1351. }
  1352. else
  1353. { /* sendSettings is False. If double click has changed update Xrdb */
  1354. if (mouse.dclickChanged)
  1355. {
  1356. InfoDialog(IMMEDIATE_MSG, style.shell, False);
  1357. sprintf(dclickRes, multiClickTimeString,
  1358. getValue(mouse.dclickScale)*100);
  1359. _DtAddToResource(style.display,dclickRes);
  1360. }
  1361. }
  1362. mouse.dclickChanged = False;
  1363. if (mouse.btn2Changed)
  1364. if(mouse.function == TRANSFER)
  1365. sprintf(enableBtn1Res, enableBtn1TransferString, "button2_transfer");
  1366. else
  1367. sprintf(enableBtn1Res, enableBtn1TransferString, "True");
  1368. _DtAddToResource(style.display,enableBtn1Res);
  1369. break;
  1370. case CANCEL_BUTTON:
  1371. XtUnmanageChild(w);
  1372. /* check if values and changePonterControl only if needed */
  1373. new_acceln = getValue(mouse.accelScale);
  1374. if (new_acceln != mouse.accel_numerator)
  1375. {
  1376. /* reset to incoming mouse values */
  1377. n=0;
  1378. XtSetArg(args[n], XmNvalue,mouse.accel_numerator); n++;
  1379. XtSetValues(mouse.accelScale, args, n);
  1380. }
  1381. new_thresh = getValue(mouse.threshScale);
  1382. if (new_thresh != mouse.threshold)
  1383. {
  1384. /* reset to incoming mouse values */
  1385. n=0;
  1386. XtSetArg(args[n], XmNvalue,mouse.threshold); n++;
  1387. XtSetValues(mouse.threshScale, args, n);
  1388. }
  1389. n=0;
  1390. XtSetArg(args[n], XmNvalue,mouse.mydclick); n++;
  1391. XtSetValues(mouse.dclickScale, args, n);
  1392. mouse.dclickChanged = False;
  1393. XtSetMultiClickTime(style.display, mouse.mydclick*100);
  1394. if ((new_thresh != mouse.threshold) ||
  1395. (new_acceln != mouse.accel_numerator))
  1396. {
  1397. do_accel = mouse.accel_numerator ? 1:0;
  1398. do_thresh = mouse.threshold ? 1:0;
  1399. XChangePointerControl(style.display, do_accel, do_thresh,
  1400. mouse.accel_numerator, mouse.accel_denominator,
  1401. mouse.threshold);
  1402. }
  1403. if (mouse.handed != mouse.origHanded)
  1404. {
  1405. if (XSetPointerMapping(style.display, mouse.map_return,
  1406. mouse.numButtons) != MappingSuccess)
  1407. _DtSimpleError (progName, DtWarning, NULL, MSG3, NULL);
  1408. /* load the correct mouse pixmaps */
  1409. if(mouse.type == POINTER3B)
  1410. {
  1411. if (mouse.origHanded == LEFT_HANDED)
  1412. {
  1413. mouse.pixmap = mouse.b3_rev;
  1414. mouse.pixmapSel = mouse.b3_revSel;
  1415. }
  1416. else
  1417. {
  1418. if (mouse.origHanded == RIGHT_HANDED)
  1419. {
  1420. mouse.pixmap = mouse.b3;
  1421. mouse.pixmapSel = mouse.b3Sel;
  1422. }
  1423. }
  1424. }
  1425. else /* 2B mouse */
  1426. {
  1427. if (mouse.origHanded == LEFT_HANDED)
  1428. {
  1429. mouse.pixmap = mouse.b2_rev;
  1430. mouse.pixmapSel = mouse.b2_revSel;
  1431. }
  1432. else
  1433. {
  1434. if (mouse.origHanded == RIGHT_HANDED)
  1435. {
  1436. mouse.pixmap = mouse.b2;
  1437. mouse.pixmapSel = mouse.b2Sel;
  1438. }
  1439. }
  1440. }
  1441. n=0;
  1442. XtSetArg(args[n], XmNlabelPixmap, mouse.pixmap); n++;
  1443. XtSetValues(mouse.pictButton, args, n);
  1444. }
  1445. if (mouse.function != mouse.origFunction)
  1446. {
  1447. mouse.function = mouse.origFunction;
  1448. if (mouse.origFunction == TRANSFER)
  1449. {
  1450. XmToggleButtonGadgetSetState(mouse.transferToggle, True, True);
  1451. XmToggleButtonGadgetSetState(mouse.adjustToggle, False, False);
  1452. }
  1453. else
  1454. {
  1455. XmToggleButtonGadgetSetState(mouse.transferToggle, False, False);
  1456. XmToggleButtonGadgetSetState(mouse.adjustToggle, True, True);
  1457. }
  1458. }
  1459. break;
  1460. case HELP_BUTTON:
  1461. XtCallCallbacks(style.mouseDialog, XmNhelpCallback, (XtPointer)NULL);
  1462. break;
  1463. default:
  1464. break;
  1465. }
  1466. }
  1467. /************************************************************************
  1468. * restoreMouse()
  1469. *
  1470. * restore any state information saved with saveMouse.
  1471. * This is called from restoreSession with the application
  1472. * shell and the special xrm database retrieved for restore.
  1473. ************************************************************************/
  1474. void
  1475. restoreMouse(
  1476. Widget shell,
  1477. XrmDatabase db )
  1478. {
  1479. XrmName xrm_name[5];
  1480. XrmRepresentation rep_type;
  1481. XrmValue value;
  1482. xrm_name [0] = XrmStringToQuark ("Mouse");
  1483. xrm_name [2] = 0;
  1484. /* get x position */
  1485. xrm_name [1] = XrmStringToQuark ("x");
  1486. if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)){
  1487. XtSetArg (save.posArgs[save.poscnt], XmNx, atoi((char *)value.addr)); save.poscnt++;
  1488. save.restoreFlag = True;
  1489. }
  1490. /* get y position */
  1491. xrm_name [1] = XrmStringToQuark ("y");
  1492. if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)){
  1493. XtSetArg (save.posArgs[save.poscnt], XmNy, atoi((char *)value.addr)); save.poscnt++;
  1494. }
  1495. xrm_name [1] = XrmStringToQuark ("ismapped");
  1496. XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value);
  1497. /* Are we supposed to be mapped? */
  1498. if (strcmp(value.addr, "True") == 0)
  1499. popup_mouseBB(shell);
  1500. }
  1501. /************************************************************************
  1502. * saveMouse()
  1503. *
  1504. * This routine will write out to the passed file descriptor any state
  1505. * information this dialog needs. It is called from saveSessionCB with the
  1506. * file already opened.
  1507. * All information is saved in xrm format. There is no restriction
  1508. * on what can be saved. It doesn't have to be defined or be part of any
  1509. * widget or Xt definition. Just name and save it here and recover it in
  1510. * restoreBackdrop. The suggested minimum is whether you are mapped, and your
  1511. * location.
  1512. ************************************************************************/
  1513. void
  1514. saveMouse(
  1515. int fd )
  1516. {
  1517. Position x,y;
  1518. char *bufr = style.tmpBigStr; /* size=[1024], make bigger if needed */
  1519. XmVendorShellExtObject vendorExt;
  1520. XmWidgetExtData extData;
  1521. if (style.mouseDialog != NULL)
  1522. {
  1523. if (XtIsManaged(style.mouseDialog))
  1524. sprintf(bufr, "*Mouse.ismapped: True\n");
  1525. else
  1526. sprintf(bufr, "*Mouse.ismapped: False\n");
  1527. /* Get and write out the geometry info for our Window */
  1528. x = XtX(XtParent(style.mouseDialog));
  1529. y = XtY(XtParent(style.mouseDialog));
  1530. /* Modify x & y to take into account window mgr frames
  1531. * This is pretty bogus, but I don't know a better way to do it.
  1532. */
  1533. extData = _XmGetWidgetExtData(style.shell, XmSHELL_EXTENSION);
  1534. vendorExt = (XmVendorShellExtObject)extData->widget;
  1535. x -= vendorExt->vendor.xOffset;
  1536. y -= vendorExt->vendor.yOffset;
  1537. sprintf(bufr, "%s*Mouse.x: %d\n", bufr, x);
  1538. sprintf(bufr, "%s*Mouse.y: %d\n", bufr, y);
  1539. if(-1 == write (fd, bufr, strlen(bufr))) {
  1540. perror(strerror(errno));
  1541. }
  1542. }
  1543. }