WmFeedback.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968
  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. * (c) Copyright 1989, 1990, 1991, 1992, 1993 OPEN SOFTWARE FOUNDATION, INC.
  25. * ALL RIGHTS RESERVED
  26. */
  27. /*
  28. * Motif Release 1.2.3
  29. */
  30. /*
  31. * (c) Copyright 1987, 1988, 1989, 1990 HEWLETT-PACKARD COMPANY */
  32. /*
  33. * Included Files:
  34. */
  35. #include "WmGlobal.h"
  36. #include "WmResNames.h"
  37. #include "WmError.h"
  38. #include <Xm/Xm.h>
  39. #include <X11/Shell.h>
  40. #include <Xm/Label.h>
  41. #include <Xm/DialogS.h>
  42. #include <Xm/BulletinB.h>
  43. #include <Xm/MessageB.h>
  44. #include <Dt/HourGlass.h>
  45. #define MOVE_OUTLINE_WIDTH 2
  46. #define FEEDBACK_BEVEL 2
  47. #define DEFAULT_POSITION_STRING "(0000x0000)"
  48. #define CB_HIGHLIGHT_THICKNESS 3
  49. /*
  50. * include extern functions
  51. */
  52. #include "WmFeedback.h"
  53. #include "WmFunction.h"
  54. #include "WmGraphics.h"
  55. #include "WmPanelP.h" /* for typedef in WmManage.h */
  56. #include "WmManage.h"
  57. #include "WmColormap.h"
  58. #include "stdio.h"
  59. /*
  60. * Global Variables:
  61. */
  62. static Cursor waitCursor = (Cursor)0L;
  63. /* see WmGlobal.h for index defines: */
  64. #ifndef NO_MESSAGE_CATALOG
  65. static char *confirm_mesg[4] = {"Switch to Default Behavior?",
  66. "Switch to Custom Behavior?",
  67. "Restart Mwm?",
  68. "QUIT Mwm?"};
  69. void
  70. initMesg(void)
  71. {
  72. char * tmpString;
  73. /*
  74. * catgets returns a pointer to an area that is over written
  75. * on each call to catgets.
  76. */
  77. tmpString = ((char *)GETMESSAGE(22, 12, "Switch to Default Behavior?"));
  78. if ((confirm_mesg[0] =
  79. (char *)XtMalloc ((unsigned int) (strlen(tmpString) + 1))) == NULL)
  80. {
  81. Warning (((char *)GETMESSAGE(22, 2, "Insufficient memory for local message string")));
  82. confirm_mesg[0] = "Switch to Default Behavior?";
  83. }
  84. else
  85. {
  86. strcpy(confirm_mesg[0], tmpString);
  87. }
  88. tmpString = ((char *)GETMESSAGE(22, 13, "Switch to Custom Behavior?"));
  89. if ((confirm_mesg[1] =
  90. (char *)XtMalloc ((unsigned int) (strlen(tmpString) + 1))) == NULL)
  91. {
  92. Warning (((char *)GETMESSAGE(22, 2, "Insufficient memory for local message string")));
  93. confirm_mesg[1] = "Switch to Custom Behavior?";
  94. }
  95. else
  96. {
  97. strcpy(confirm_mesg[1], tmpString);
  98. }
  99. if (MwmBehavior)
  100. {
  101. tmpString = ((char *)GETMESSAGE(22, 3, "Restart Mwm?"));
  102. }
  103. else
  104. {
  105. tmpString = ((char *)GETMESSAGE(22, 10, "Restart Workspace Manager?"));
  106. }
  107. if ((confirm_mesg[2] =
  108. (char *)XtMalloc ((unsigned int) (strlen(tmpString) + 1))) == NULL)
  109. {
  110. Warning (((char *)GETMESSAGE(22, 5, "Insufficient memory for local message string")));
  111. if (MwmBehavior)
  112. {
  113. confirm_mesg[2] = "Restart Mwm?";
  114. }
  115. else
  116. {
  117. confirm_mesg[2] = "Restart Workspace Manager?";
  118. }
  119. }
  120. else
  121. {
  122. strcpy(confirm_mesg[2], tmpString);
  123. }
  124. if (MwmBehavior)
  125. {
  126. tmpString = ((char *)GETMESSAGE(22, 6, "QUIT Mwm?"));
  127. }
  128. else
  129. {
  130. if (wmGD.dtLite)
  131. {
  132. tmpString = ((char *)GETMESSAGE(22, 9, "Log out?"));
  133. }
  134. else
  135. {
  136. tmpString = ((char *)GETMESSAGE(22, 11, "QUIT Workspace Manager?"));
  137. }
  138. }
  139. if ((confirm_mesg[3] =
  140. (char *)XtMalloc ((unsigned int) (strlen(tmpString) + 1))) == NULL)
  141. {
  142. Warning (((char *)GETMESSAGE(22, 8, "Insufficient memory for local message string")));
  143. if (MwmBehavior)
  144. {
  145. confirm_mesg[3] = "QUIT Mwm?";
  146. }
  147. else
  148. if (wmGD.dtLite)
  149. {
  150. confirm_mesg[3] = "Log out?";
  151. }
  152. else
  153. {
  154. confirm_mesg[3] = "QUIT Workspace Manager?";
  155. }
  156. }
  157. else
  158. {
  159. strcpy(confirm_mesg[3], tmpString);
  160. }
  161. }
  162. #else
  163. static char *confirm_mesg[4] = {"Toggle to Default Behavior?",
  164. "Toggle to Custom Behavior?",
  165. "Restart Mwm?",
  166. "QUIT Mwm?"};
  167. #endif
  168. static char *confirm_widget[4] = {"confirmDefaultBehavior",
  169. "confirmCustomBehavior",
  170. "confirmRestart",
  171. "confirmQuit"};
  172. typedef void (*ConfirmFunc)(Boolean);
  173. static ConfirmFunc confirm_func[4] = {Do_Set_Behavior,
  174. Do_Set_Behavior,
  175. Do_Restart,
  176. Do_Quit_Mwm};
  177. /*************************************<->*************************************
  178. *
  179. * ShowFeedbackWindow(pSD, x, y, width, height, style)
  180. *
  181. *
  182. * Description:
  183. * -----------
  184. * Pop up the window for moving and sizing feedback
  185. *
  186. *
  187. * Inputs:
  188. * ------
  189. * pSD - pointer to screen data
  190. * x - initial x-value
  191. * y - initial y-value
  192. * width - initial width value
  193. * height - initial height value
  194. * style - show size, position, or both
  195. *
  196. *
  197. * Outputs:
  198. * -------
  199. *
  200. *
  201. * Comments:
  202. * --------
  203. *************************************<->***********************************/
  204. void ShowFeedbackWindow (WmScreenData *pSD, int x, int y, unsigned int width, unsigned int height, unsigned long style)
  205. {
  206. unsigned long mask = 0;
  207. XSetWindowAttributes win_attribs;
  208. XWindowChanges win_changes;
  209. int direction, ascent, descent;
  210. XCharStruct xcsLocation;
  211. int winX, winY;
  212. int tmpX, tmpY;
  213. if ( (pSD->fbStyle = style) == FB_OFF)
  214. return;
  215. pSD->fbLastX = x;
  216. pSD->fbLastY = y;
  217. pSD->fbLastWidth = width;
  218. pSD->fbLastHeight = height;
  219. /*
  220. * Derive the size and position of the window from the text extents
  221. * Set starting position of each string
  222. */
  223. XTextExtents(pSD->feedbackAppearance.font, DEFAULT_POSITION_STRING,
  224. strlen(DEFAULT_POSITION_STRING), &direction, &ascent,
  225. &descent, &xcsLocation);
  226. pSD->fbWinWidth = xcsLocation.width + 4*FEEDBACK_BEVEL;
  227. switch (pSD->fbStyle)
  228. {
  229. case FB_SIZE:
  230. pSD->fbSizeY = 2*FEEDBACK_BEVEL + ascent;
  231. pSD->fbWinHeight = (ascent + descent) + 4*FEEDBACK_BEVEL;
  232. break;
  233. case FB_POSITION:
  234. pSD->fbLocY = 2*FEEDBACK_BEVEL + ascent;
  235. pSD->fbWinHeight = (ascent + descent) + 4*FEEDBACK_BEVEL;
  236. break;
  237. default:
  238. case (FB_SIZE | FB_POSITION):
  239. pSD->fbLocY = 2*FEEDBACK_BEVEL + ascent;
  240. pSD->fbSizeY = pSD->fbLocY + ascent + descent;
  241. pSD->fbWinHeight = 2*(ascent + descent) + 4*FEEDBACK_BEVEL;
  242. break;
  243. }
  244. if (pSD->feedbackGeometry) /* set by user */
  245. {
  246. unsigned int junkWidth, junkHeight;
  247. mask = XParseGeometry(pSD->feedbackGeometry, &tmpX, &tmpY,
  248. &junkWidth, &junkHeight);
  249. }
  250. if (mask & (XValue|YValue))
  251. {
  252. winX = (mask & XNegative) ?
  253. DisplayWidth(DISPLAY, pSD->screen) + tmpX - pSD->fbWinWidth : tmpX;
  254. winY = (mask & YNegative) ?
  255. DisplayHeight(DISPLAY, pSD->screen) + tmpY -pSD->fbWinHeight : tmpY;
  256. }
  257. else
  258. {
  259. winX = (DisplayWidth(DISPLAY, pSD->screen) - pSD->fbWinWidth)/2;
  260. winY = (DisplayHeight(DISPLAY, pSD->screen) -pSD->fbWinHeight)/2;
  261. }
  262. /*
  263. * Put new text into the feedback strings
  264. */
  265. UpdateFeedbackText (pSD, x, y, width, height);
  266. /*
  267. * bevel the window border for a 3-D look
  268. */
  269. if ( (pSD->fbTop && pSD->fbBottom) ||
  270. ((pSD->fbTop = AllocateRList((unsigned)2*FEEDBACK_BEVEL)) &&
  271. (pSD->fbBottom = AllocateRList((unsigned)2*FEEDBACK_BEVEL))) )
  272. {
  273. pSD->fbTop->used = 0;
  274. pSD->fbBottom->used = 0;
  275. BevelRectangle (pSD->fbTop,
  276. pSD->fbBottom,
  277. 0, 0,
  278. pSD->fbWinWidth, pSD->fbWinHeight,
  279. FEEDBACK_BEVEL, FEEDBACK_BEVEL,
  280. FEEDBACK_BEVEL, FEEDBACK_BEVEL);
  281. }
  282. /*
  283. * Create window if not yet created, otherwise fix size and position
  284. */
  285. if (!pSD->feedbackWin)
  286. {
  287. /*
  288. * Create the window
  289. */
  290. mask = CWEventMask | CWOverrideRedirect | CWSaveUnder;
  291. win_attribs.event_mask = ExposureMask;
  292. win_attribs.override_redirect = TRUE;
  293. win_attribs.save_under = TRUE;
  294. /*
  295. * Use background pixmap if one is specified, otherwise set the
  296. * appropriate background color.
  297. */
  298. if (pSD->feedbackAppearance.backgroundPixmap)
  299. {
  300. mask |= CWBackPixmap;
  301. win_attribs.background_pixmap =
  302. pSD->feedbackAppearance.backgroundPixmap;
  303. }
  304. else
  305. {
  306. mask |= CWBackPixel;
  307. win_attribs.background_pixel =
  308. pSD->feedbackAppearance.background;
  309. }
  310. pSD->feedbackWin = XCreateWindow (DISPLAY, pSD->rootWindow,
  311. winX, winY,
  312. pSD->fbWinWidth,
  313. pSD->fbWinHeight,
  314. 0, CopyFromParent,
  315. InputOutput, CopyFromParent,
  316. mask, &win_attribs);
  317. }
  318. else
  319. {
  320. win_changes.x = winX;
  321. win_changes.y = winY;
  322. win_changes.width = pSD->fbWinWidth;
  323. win_changes.height = pSD->fbWinHeight;
  324. win_changes.stack_mode = Above;
  325. mask = CWX | CWY | CWWidth | CWHeight | CWStackMode;
  326. XConfigureWindow(DISPLAY, pSD->feedbackWin, (unsigned int) mask,
  327. &win_changes);
  328. }
  329. /*
  330. * Make the feedback window visible (map it)
  331. */
  332. if (pSD && pSD->feedbackWin)
  333. {
  334. /* Make sure the feedback window doesn't get buried */
  335. XRaiseWindow(DISPLAY, pSD->feedbackWin);
  336. XMapWindow (DISPLAY, pSD->feedbackWin);
  337. PaintFeedbackWindow(pSD);
  338. }
  339. } /* END OF FUNCTION ShowFeedbackWindow */
  340. /*************************************<->*************************************
  341. *
  342. * PaintFeedbackWindow(pSD)
  343. *
  344. *
  345. * Description:
  346. * -----------
  347. * Repaints the feedback window in response to exposure events
  348. *
  349. *
  350. * Inputs:
  351. * ------
  352. * pSD - pointer to screen data
  353. *
  354. * Outputs:
  355. * -------
  356. *
  357. *
  358. * Comments:
  359. * --------
  360. *************************************<->***********************************/
  361. void PaintFeedbackWindow (WmScreenData *pSD)
  362. {
  363. if (pSD->feedbackWin)
  364. {
  365. /*
  366. * draw beveling
  367. */
  368. if (pSD->fbTop && pSD->fbTop->used > 0)
  369. {
  370. XFillRectangles (DISPLAY, pSD->feedbackWin,
  371. pSD->feedbackAppearance.inactiveTopShadowGC,
  372. pSD->fbTop->prect, pSD->fbTop->used);
  373. }
  374. if (pSD->fbBottom && pSD->fbBottom->used > 0)
  375. {
  376. XFillRectangles (DISPLAY, pSD->feedbackWin,
  377. pSD->feedbackAppearance.inactiveBottomShadowGC,
  378. pSD->fbBottom->prect,
  379. pSD->fbBottom->used);
  380. }
  381. /*
  382. * clear old text
  383. */
  384. XClearArea (DISPLAY, pSD->feedbackWin,
  385. FEEDBACK_BEVEL, FEEDBACK_BEVEL,
  386. pSD->fbWinWidth-2*FEEDBACK_BEVEL,
  387. pSD->fbWinHeight-2*FEEDBACK_BEVEL,
  388. FALSE);
  389. /*
  390. * put up new text
  391. */
  392. if (pSD->fbStyle & FB_POSITION)
  393. {
  394. WmDrawString (DISPLAY, pSD->feedbackWin,
  395. pSD->feedbackAppearance.inactiveGC,
  396. pSD->fbLocX, pSD->fbLocY,
  397. pSD->fbLocation, strlen(pSD->fbLocation));
  398. }
  399. if (pSD->fbStyle & FB_SIZE)
  400. {
  401. WmDrawString (DISPLAY, pSD->feedbackWin,
  402. pSD->feedbackAppearance.inactiveGC,
  403. pSD->fbSizeX, pSD->fbSizeY,
  404. pSD->fbSize, strlen(pSD->fbSize));
  405. }
  406. }
  407. }
  408. /*************************************<->*************************************
  409. *
  410. * HideFeedbackWindow (pSD)
  411. *
  412. *
  413. * Description:
  414. * -----------
  415. * Hide the feedback window
  416. *
  417. *
  418. * Inputs:
  419. * ------
  420. * pDS - pointer to screen data
  421. *
  422. * Outputs:
  423. * -------
  424. *
  425. *
  426. * Comments:
  427. * --------
  428. *
  429. *************************************<->***********************************/
  430. void HideFeedbackWindow (WmScreenData *pSD)
  431. {
  432. if (pSD->feedbackWin)
  433. {
  434. XUnmapWindow (DISPLAY, pSD->feedbackWin);
  435. ForceColormapFocus (ACTIVE_PSD, ACTIVE_PSD->colormapFocus);
  436. }
  437. pSD->fbStyle = FB_OFF;
  438. }
  439. /*************************************<->*************************************
  440. *
  441. * UpdateFeedbackInfo (pSD, x, y, width, height)
  442. *
  443. *
  444. * Description:
  445. * -----------
  446. * Update the information in the feedback window
  447. *
  448. *
  449. * Inputs:
  450. * ------
  451. * pSD - pointer to screen info
  452. * x - x-value
  453. * y - y-value
  454. * width - width value
  455. * height - height value
  456. *
  457. *
  458. * Outputs:
  459. * -------
  460. *
  461. *
  462. * Comments:
  463. * --------
  464. *
  465. *************************************<->***********************************/
  466. void UpdateFeedbackInfo (WmScreenData *pSD, int x, int y, unsigned int width, unsigned int height)
  467. {
  468. /*
  469. * Currently the feedback window must always be redrawn to (potentially)
  470. * repair damage done by moving the configuration outline. The feedback
  471. * repainting generally only needs to be done when the information
  472. * changes or the feedback window is actually overwritten by the
  473. * configuration outline.
  474. */
  475. pSD->fbLastX = x;
  476. pSD->fbLastY = y;
  477. pSD->fbLastWidth = width;
  478. pSD->fbLastHeight = height;
  479. UpdateFeedbackText (pSD, x, y, width, height);
  480. PaintFeedbackWindow(pSD);
  481. }
  482. /*************************************<->*************************************
  483. *
  484. * UpdateFeedbackText (pSD, x, y, width, height)
  485. *
  486. *
  487. * Description:
  488. * -----------
  489. * Update the information in the feedback strings
  490. *
  491. *
  492. * Inputs:
  493. * ------
  494. * pSD - pointer to screen data
  495. * x - x-value
  496. * y - y-value
  497. * width - width value
  498. * height - height value
  499. *
  500. *
  501. * Outputs:
  502. * -------
  503. *
  504. *
  505. * Comments:
  506. * --------
  507. *
  508. *************************************<->***********************************/
  509. void UpdateFeedbackText (WmScreenData *pSD, int x, int y, unsigned int width, unsigned int height)
  510. {
  511. int direction, ascent, descent;
  512. XCharStruct xcs;
  513. if (pSD->fbStyle & FB_POSITION)
  514. {
  515. sprintf (pSD->fbLocation, "(%4d,%-4d)", x, y);
  516. XTextExtents(pSD->feedbackAppearance.font, pSD->fbLocation,
  517. strlen(pSD->fbLocation), &direction, &ascent,
  518. &descent, &xcs);
  519. pSD->fbLocX = (pSD->fbWinWidth - xcs.width)/2;
  520. }
  521. if (pSD->fbStyle & FB_SIZE)
  522. {
  523. sprintf (pSD->fbSize, "%4dx%-4d", width, height);
  524. XTextExtents(pSD->feedbackAppearance.font, pSD->fbSize,
  525. strlen(pSD->fbSize), &direction, &ascent,
  526. &descent, &xcs);
  527. pSD->fbSizeX = (pSD->fbWinWidth - xcs.width)/2;
  528. }
  529. }
  530. /*************************************<->*************************************
  531. *
  532. * static void
  533. * OkCB (w, client_data, call_data)
  534. *
  535. *
  536. * Description:
  537. * -----------
  538. * QuestionBox Ok callback.
  539. *
  540. *
  541. * Inputs:
  542. * ------
  543. * None.
  544. *
  545. *
  546. * Outputs:
  547. * -------
  548. * None.
  549. *
  550. *
  551. * Comments:
  552. * --------
  553. * None.
  554. *
  555. *************************************<->***********************************/
  556. static void OkCB (Widget w, caddr_t client_data, caddr_t call_data)
  557. {
  558. WithdrawDialog (w);
  559. confirm_func[((WmScreenData *)client_data)->actionNbr] (False);
  560. wmGD.confirmDialogMapped = False;
  561. } /* END OF FUNCTION OkCB */
  562. /*************************************<->*************************************
  563. *
  564. * static void
  565. * CancelCB (w, client_data, call_data)
  566. *
  567. *
  568. * Description:
  569. * -----------
  570. * QuestionBox Cancel callback.
  571. *
  572. *
  573. * Inputs:
  574. * ------
  575. * None.
  576. *
  577. *
  578. * Outputs:
  579. * -------
  580. * None.
  581. *
  582. *
  583. * Comments:
  584. * --------
  585. * None.
  586. *
  587. *************************************<->***********************************/
  588. static void CancelCB (Widget w, caddr_t client_data, caddr_t call_data)
  589. {
  590. WithdrawDialog (w);
  591. wmGD.confirmDialogMapped = False;
  592. } /* END OF FUNCTION CancelCB */
  593. /*************************************<->*************************************
  594. *
  595. * void
  596. * ConfirmAction (pSD,nbr)
  597. *
  598. *
  599. * Description:
  600. * -----------
  601. * Post a QuestionBox and ask for confirmation. If so, executes the
  602. * appropriate action.
  603. *
  604. *
  605. * Inputs:
  606. * ------
  607. * nbr = action number
  608. * pSD->screen
  609. * pSD->screenTopLevel
  610. *
  611. *
  612. * Outputs:
  613. * -------
  614. * actionNbr = current QuestionBox widget index.
  615. * confirmW[actionNbr] = QuestionBox widget.
  616. *
  617. *
  618. * Comments:
  619. * --------
  620. *
  621. *************************************<->***********************************/
  622. void ConfirmAction (WmScreenData *pSD, int nbr)
  623. {
  624. Arg args[8];
  625. int n;
  626. int x, y;
  627. Dimension width, height;
  628. Widget dialogShellW = NULL;
  629. XmString messageString;
  630. static XmString defaultMessageString = NULL;
  631. /*
  632. * If there is a system modal window, don't post another
  633. * one. We need to think about a way to let a new system
  634. * modal window be posted, and when unposted, restore the
  635. * modal state of the current system modal window.
  636. */
  637. if(wmGD.systemModalActive)
  638. {
  639. return ;
  640. }
  641. if (pSD->confirmboxW[nbr] == NULL)
  642. /* First time for this one */
  643. {
  644. #ifndef NO_MESSAGE_CATALOG
  645. /*
  646. * Initialize messages
  647. */
  648. initMesg();
  649. #endif
  650. /*
  651. * Create a dialog popup shell with explicit keyboard policy.
  652. */
  653. n = 0;
  654. XtSetArg(args[n], XmNx, (XtArgVal)
  655. (DisplayWidth (DISPLAY, pSD->screen)/2)); n++;
  656. XtSetArg(args[n], XmNy, (XtArgVal)
  657. (DisplayHeight (DISPLAY, pSD->screen)/2)); n++;
  658. XtSetArg(args[n], XtNallowShellResize, (XtArgVal) TRUE); n++;
  659. XtSetArg(args[n], XtNkeyboardFocusPolicy, (XtArgVal) XmEXPLICIT); n++;
  660. XtSetArg(args[n], XtNdepth,
  661. (XtArgVal) DefaultDepth(DISPLAY, pSD->screen)); n++;
  662. XtSetArg(args[n], XtNscreen,
  663. (XtArgVal) ScreenOfDisplay(DISPLAY, pSD->screen)); n++;
  664. dialogShellW =
  665. XtCreatePopupShell ((String) WmNfeedback,
  666. transientShellWidgetClass,
  667. pSD->screenTopLevelW, args, n);
  668. /*
  669. * Create a QuestionBox as a child of the popup shell.
  670. * Set traversalOn and add callbacks for the OK and CANCEL buttons.
  671. * Unmanage the HELP button.
  672. */
  673. n = 0;
  674. XtSetArg(args[n], XmNdialogType, (XtArgVal) XmDIALOG_QUESTION); n++;
  675. XtSetArg(args[n], XmNmessageAlignment, (XtArgVal) XmALIGNMENT_CENTER);
  676. n++;
  677. XtSetArg(args[n], XmNtraversalOn, (XtArgVal) TRUE); n++;
  678. /*
  679. * In 1.2 confirmbox's widget name changed from the generic
  680. * WmNconfirmbox (ie. 'confirmbox') to a more descriptive name
  681. * so that each confirm dialog can be customized separately (e.g.
  682. * "Mwm*confirmRestart*messageString: restart it?").
  683. */
  684. pSD->confirmboxW[nbr] =
  685. XtCreateManagedWidget (confirm_widget[nbr], xmMessageBoxWidgetClass,
  686. dialogShellW, args, n);
  687. n = 0;
  688. XtSetArg(args[n], XmNmessageString, &messageString); n++;
  689. XtGetValues(pSD->confirmboxW[nbr], (ArgList) args, n);
  690. if (defaultMessageString == NULL)
  691. {
  692. defaultMessageString = XmStringCreateLocalized ("");
  693. }
  694. n = 0;
  695. /*
  696. * If the message string is the default, then put something
  697. * 'reasonable' in instead.
  698. */
  699. if (XmStringCompare( messageString, defaultMessageString ))
  700. {
  701. messageString = XmStringCreateLocalized(confirm_mesg[nbr]);
  702. XtSetArg(args[n], XmNmessageString, (XtArgVal) messageString); n++;
  703. XtSetValues(pSD->confirmboxW[nbr], (ArgList) args, n);
  704. XmStringFree(messageString);
  705. }
  706. n = 0;
  707. XtSetArg (args[n], XmNtraversalOn, (XtArgVal) TRUE); n++;
  708. XtSetArg (args[n], XmNhighlightThickness,
  709. (XtArgVal) CB_HIGHLIGHT_THICKNESS); n++;
  710. #ifndef NO_MESSAGE_CATALOG
  711. XtSetArg(args[n], XmNlabelString, wmGD.okLabel); n++;
  712. #endif
  713. XtSetValues ( XmMessageBoxGetChild (pSD->confirmboxW[nbr],
  714. XmDIALOG_OK_BUTTON), args, n);
  715. #ifndef NO_MESSAGE_CATALOG
  716. n--;
  717. XtSetArg(args[n], XmNlabelString, wmGD.cancelLabel); n++;
  718. #endif
  719. XtSetValues ( XmMessageBoxGetChild (pSD->confirmboxW[nbr],
  720. XmDIALOG_CANCEL_BUTTON), args, n);
  721. XtAddCallback (pSD->confirmboxW[nbr], XmNokCallback,
  722. (XtCallbackProc)OkCB, (XtPointer)pSD);
  723. XtAddCallback (pSD->confirmboxW[nbr], XmNcancelCallback,
  724. (XtCallbackProc)CancelCB, (XtPointer)NULL);
  725. XtUnmanageChild
  726. (XmMessageBoxGetChild (pSD->confirmboxW[nbr],
  727. XmDIALOG_HELP_BUTTON));
  728. XtRealizeWidget (dialogShellW);
  729. /*
  730. * Center the DialogShell in the display.
  731. */
  732. n = 0;
  733. XtSetArg(args[n], XmNheight, &height); n++;
  734. XtSetArg(args[n], XmNwidth, &width); n++;
  735. XtGetValues (dialogShellW, (ArgList) args, n);
  736. x = (DisplayWidth (DISPLAY, pSD->screen) - ((int) width))/2;
  737. y = (DisplayHeight (DISPLAY, pSD->screen) - ((int) height))/2;
  738. n = 0;
  739. XtSetArg(args[n], XmNx, (XtArgVal) x); n++;
  740. XtSetArg(args[n], XmNy, (XtArgVal) y); n++;
  741. XtSetValues (dialogShellW, (ArgList) args, n);
  742. ManageWindow (pSD, XtWindow(dialogShellW), MANAGEW_CONFIRM_BOX);
  743. }
  744. else
  745. {
  746. ReManageDialog (pSD, pSD->confirmboxW[nbr]);
  747. }
  748. pSD->actionNbr = nbr;
  749. XFlush(DISPLAY);
  750. wmGD.confirmDialogMapped = True;
  751. } /* END OF FUNCTION ConfirmAction */
  752. /*************************************<->*************************************
  753. *
  754. * ShowWaitState (flag)
  755. *
  756. *
  757. * Description:
  758. * -----------
  759. * Enter/Leave the wait state.
  760. *
  761. *
  762. * Inputs:
  763. * ------
  764. * flag = TRUE for Enter, FALSE for Leave.
  765. *
  766. *
  767. * Outputs:
  768. * -------
  769. * None.
  770. *
  771. *
  772. * Comments:
  773. * --------
  774. * None.
  775. *
  776. *************************************<->***********************************/
  777. void ShowWaitState (Boolean flag)
  778. {
  779. unsigned int width;
  780. unsigned int height;
  781. unsigned int xHotspot;
  782. unsigned int yHotspot;
  783. Pixmap pixmap;
  784. Pixmap maskPixmap;
  785. XColor xcolors[2];
  786. _DtGetHourGlassCursor(DISPLAY);
  787. if (flag)
  788. {
  789. XGrabPointer (DISPLAY, DefaultRootWindow(DISPLAY), FALSE,
  790. 0, GrabModeAsync, GrabModeAsync, None,
  791. waitCursor, CurrentTime);
  792. XGrabKeyboard (DISPLAY, DefaultRootWindow(DISPLAY), FALSE,
  793. GrabModeAsync, GrabModeAsync, CurrentTime);
  794. }
  795. else
  796. {
  797. XUngrabPointer (DISPLAY, CurrentTime);
  798. XUngrabKeyboard (DISPLAY, CurrentTime);
  799. }
  800. } /* END OF FUNCTION ShowWaitState */
  801. /*************************************<->*************************************
  802. *
  803. * InitCursorInfo ()
  804. *
  805. *
  806. * Description:
  807. * -----------
  808. * This function determines whether a server supports large cursors. It it
  809. * does large feedback cursors are used in some cases (wait state and
  810. * system modal state); otherwise smaller (16x16) standard cursors are used.
  811. *
  812. * Outputs:
  813. * -------
  814. * wmGD.useLargeCusors = set to True if larger cursors are supported.
  815. *
  816. *************************************<->***********************************/
  817. void InitCursorInfo (void)
  818. {
  819. unsigned int cWidth;
  820. unsigned int cHeight;
  821. wmGD.useLargeCursors = False;
  822. if (XQueryBestCursor (DISPLAY, DefaultRootWindow(DISPLAY),
  823. 32, 32, &cWidth, &cHeight))
  824. {
  825. if ((cWidth >= 32) && (cHeight >= 32))
  826. {
  827. wmGD.useLargeCursors = True;
  828. }
  829. }
  830. } /* END OF FUNCTION InitCursorInfo */