Mouse.c 58 KB

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