WmCDInfo.c 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542
  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 "WmCDInfo.h"
  37. /*************************************<->*************************************
  38. *
  39. * unsigned int TitleTextHeight (pcd)
  40. *
  41. *
  42. * Description:
  43. * -----------
  44. * Returns the height of the title text plus padding
  45. *
  46. * Inputs:
  47. * ------
  48. * pcd - pointer to client data record
  49. *
  50. * Outputs:
  51. * -------
  52. * TitleTextHeight - Height of title text plus padding
  53. *
  54. * Comments:
  55. * --------
  56. *
  57. *************************************<->***********************************/
  58. unsigned int TitleTextHeight (ClientData *pcd)
  59. {
  60. unsigned int ttextheight;
  61. if (DECOUPLE_TITLE_APPEARANCE(pcd))
  62. {
  63. ttextheight = CLIENT_TITLE_APPEARANCE(pcd).titleHeight;
  64. }
  65. else
  66. {
  67. ttextheight = CLIENT_APPEARANCE(pcd).titleHeight;
  68. }
  69. return (ttextheight);
  70. }
  71. /*************************************<->*************************************
  72. *
  73. * unsigned int InitTitleBarHeight (pcd)
  74. *
  75. *
  76. * Description:
  77. * -----------
  78. * Used to initialize pCD->frameInfo.titleBarHeight which is used by the new
  79. * macro TitleBarHeight(). Returns the height of the title bar.
  80. *
  81. * Inputs:
  82. * ------
  83. * pcd - pointer to client data record
  84. *
  85. * Outputs:
  86. * -------
  87. * InitTitleBarHeight - height of title bar, 0 if no title bar.
  88. *
  89. * Comments:
  90. * --------
  91. *
  92. *************************************<->***********************************/
  93. unsigned int InitTitleBarHeight (ClientData *pcd)
  94. {
  95. unsigned int tbarheight;
  96. if (pcd->decor & MWM_DECOR_TITLE)
  97. {
  98. tbarheight = TitleTextHeight(pcd);
  99. }
  100. else
  101. {
  102. tbarheight = 0;
  103. }
  104. return (tbarheight);
  105. }
  106. /*************************************<->*************************************
  107. *
  108. * unsigned int UpperBorderWidth (pcd)
  109. *
  110. *
  111. * Description:
  112. * -----------
  113. * Returns the width of the upper frame border
  114. *
  115. * Inputs:
  116. * ------
  117. * pcd - pointer to client data record
  118. *
  119. * Outputs:
  120. * -------
  121. * UpperBorderWidth - width of the upper frame border
  122. *
  123. * Comments:
  124. * --------
  125. * The upper border width is thinner if there is a title bar. The
  126. * title bar appears to sit across some of the inside beveling to
  127. * make the frame look more integrated.
  128. *
  129. *************************************<->***********************************/
  130. unsigned int UpperBorderWidth (ClientData *pcd)
  131. {
  132. unsigned int uswidth;
  133. unsigned int decoration = pcd->decor;
  134. if (decoration & MWM_DECOR_RESIZEH)
  135. {
  136. uswidth = RESIZE_BORDER_WIDTH(pcd);
  137. }
  138. else if (decoration & MWM_DECOR_BORDER)
  139. {
  140. uswidth = FRAME_BORDER_WIDTH(pcd);
  141. if((pcd->clientFlags & FRONT_PANEL_BOX) &&
  142. (uswidth > 0))
  143. {
  144. uswidth -= 1;
  145. }
  146. }
  147. else if ((decoration & MWM_DECOR_TITLE) ||
  148. (pcd->matteWidth > 0))
  149. {
  150. uswidth = 0;
  151. }
  152. else
  153. {
  154. uswidth = pcd->xBorderWidth;
  155. }
  156. return (uswidth);
  157. }
  158. /*************************************<->*************************************
  159. *
  160. * unsigned int LowerBorderWidth (pcd)
  161. *
  162. *
  163. * Description:
  164. * -----------
  165. * Returns the width of the lower frame border
  166. *
  167. * Inputs:
  168. * ------
  169. * pcd - pointer to client data record
  170. *
  171. * Outputs:
  172. * -------
  173. * LowerBorderWidth - width of the lower frame border
  174. *
  175. * Comments:
  176. * --------
  177. * The upper border width is thinner than the lower border if there
  178. * is a title bar. The title bar appears to sit across some of the
  179. * inside beveling to make the frame look more integrated.
  180. *
  181. *************************************<->***********************************/
  182. unsigned int LowerBorderWidth (ClientData *pcd)
  183. {
  184. unsigned int lswidth;
  185. unsigned int decoration = pcd->decor;
  186. if (decoration & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
  187. {
  188. if ((pcd->matteWidth == 0) && (decoration & MWM_DECOR_TITLE) &&
  189. (wmGD.frameStyle == WmRECESSED))
  190. lswidth = UpperBorderWidth (pcd) +
  191. (pcd->internalBevel - JOIN_BEVEL(pcd));
  192. else
  193. lswidth = UpperBorderWidth (pcd);
  194. }
  195. else if (pcd->matteWidth > 0)
  196. {
  197. lswidth = 0;
  198. }
  199. else
  200. {
  201. lswidth = pcd->xBorderWidth;
  202. }
  203. return (lswidth);
  204. }
  205. /*************************************<->*************************************
  206. *
  207. * unsigned int FrameWidth (pcd)
  208. *
  209. *
  210. * Description:
  211. * -----------
  212. * Returns the width of the frame
  213. *
  214. * Inputs:
  215. * ------
  216. * pcd - pointer to client data record
  217. *
  218. * Outputs:
  219. * -------
  220. * FrameWidth - width of frame
  221. *
  222. * Comments:
  223. * --------
  224. *
  225. *************************************<->***********************************/
  226. unsigned int FrameWidth (ClientData *pcd)
  227. {
  228. unsigned int frameWidth;
  229. frameWidth = ((pcd->maxConfig) ? pcd->maxWidth : pcd->clientWidth) +
  230. 2*pcd->matteWidth + 2*LowerBorderWidth (pcd);
  231. return (frameWidth);
  232. }
  233. /*************************************<->*************************************
  234. *
  235. * unsigned int CornerWidth (pcd)
  236. *
  237. *
  238. * Description:
  239. * -----------
  240. * Returns the width of the corner frame resize handle
  241. *
  242. * Inputs:
  243. * ------
  244. * pcd - pointer to client data record
  245. *
  246. * Outputs:
  247. * -------
  248. * CornerWidth - width of the corner resize handle
  249. *
  250. * Comments:
  251. * --------
  252. *
  253. *************************************<->***********************************/
  254. unsigned int CornerWidth (ClientData *pcd)
  255. {
  256. unsigned int cwidth;
  257. unsigned int frameWidth = FrameWidth (pcd);
  258. /* adjust for resize border (default border if no resize wanted) */
  259. if (pcd->decor & MWM_DECOR_RESIZEH)
  260. {
  261. /* corner size is driven by title bar height */
  262. cwidth = TitleTextHeight(pcd) + UpperBorderWidth (pcd);
  263. /* scale down corners to make resize pieces proportional */
  264. if (3*cwidth > frameWidth) cwidth = frameWidth / 3;
  265. }
  266. else {
  267. /* no resizing functions */
  268. cwidth = 0;
  269. }
  270. return (cwidth);
  271. }
  272. /*************************************<->*************************************
  273. *
  274. * unsigned int FrameHeight (pcd)
  275. *
  276. *
  277. * Description:
  278. * -----------
  279. * Returns the height of the frame
  280. *
  281. * Inputs:
  282. * ------
  283. * pcd - pointer to client data record
  284. *
  285. * Outputs:
  286. * -------
  287. * FrameHeight - position of frame
  288. *
  289. * Comments:
  290. * --------
  291. *
  292. *************************************<->***********************************/
  293. unsigned int FrameHeight (ClientData *pcd)
  294. {
  295. unsigned int frameHeight;
  296. if (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
  297. {
  298. frameHeight = ((pcd->maxConfig) ?
  299. pcd->maxHeight : pcd->clientHeight) +
  300. 2*pcd->matteWidth + LowerBorderWidth (pcd) +
  301. UpperBorderWidth (pcd) + TitleBarHeight(pcd);
  302. }
  303. else
  304. {
  305. frameHeight = ((pcd->maxConfig) ?
  306. pcd->maxHeight : pcd->clientHeight) +
  307. 2*pcd->matteWidth + 2*LowerBorderWidth (pcd) +
  308. TitleBarHeight(pcd);
  309. }
  310. return (frameHeight);
  311. }
  312. /*************************************<->*************************************
  313. *
  314. * unsigned int CornerHeight (pcd)
  315. *
  316. *
  317. * Description:
  318. * -----------
  319. * Returns the height of the corner frame resize handle
  320. *
  321. * Inputs:
  322. * ------
  323. * pcd - pointer to client data record
  324. *
  325. * Outputs:
  326. * -------
  327. * CornerHeight - Height of the corner resize handle
  328. *
  329. * Comments:
  330. * --------
  331. *
  332. *************************************<->***********************************/
  333. unsigned int CornerHeight (ClientData *pcd)
  334. {
  335. unsigned int cheight;
  336. unsigned int frameHeight = FrameHeight (pcd);
  337. /* adjust for resize border (default border if no resize wanted) */
  338. if (pcd->decor & MWM_DECOR_RESIZEH)
  339. {
  340. /* corner size is driven by title bar height */
  341. cheight = TitleTextHeight(pcd) + UpperBorderWidth (pcd);
  342. /* scale down corners to make resize pieces proportional */
  343. if (3*cheight > frameHeight) cheight = frameHeight / 3;
  344. }
  345. else {
  346. /* produce default border with no resizing functions */
  347. cheight = 0;
  348. }
  349. return (cheight);
  350. }
  351. /*************************************<->*************************************
  352. *
  353. * int BaseWindowX (pcd)
  354. *
  355. *
  356. * Description:
  357. * -----------
  358. * Returns the X coord of the base window in the frame
  359. *
  360. * Inputs:
  361. * ------
  362. * pcd - pointer to client data record
  363. *
  364. * Outputs:
  365. * -------
  366. * BaseWindowX
  367. *
  368. * Comments:
  369. * --------
  370. *
  371. *************************************<->***********************************/
  372. int BaseWindowX (ClientData *pcd)
  373. {
  374. int rval;
  375. if (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
  376. rval = LowerBorderWidth(pcd);
  377. else
  378. rval = 0;
  379. return (rval);
  380. }
  381. /*************************************<->*************************************
  382. *
  383. * int BaseWindowY (pcd)
  384. *
  385. *
  386. * Description:
  387. * -----------
  388. * Returns the Y coord of the base window in the frame
  389. *
  390. * Inputs:
  391. * ------
  392. * pcd - pointer to client data record
  393. *
  394. * Outputs:
  395. * -------
  396. * BaseWindowY
  397. *
  398. * Comments:
  399. * --------
  400. *
  401. *************************************<->***********************************/
  402. int BaseWindowY (ClientData *pcd)
  403. {
  404. int rval;
  405. if (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
  406. rval = UpperBorderWidth (pcd) + TitleBarHeight(pcd);
  407. else
  408. rval = TitleBarHeight(pcd);
  409. return (rval);
  410. }
  411. /*************************************<->*************************************
  412. *
  413. * int FrameX (pcd)
  414. *
  415. *
  416. * Description:
  417. * -----------
  418. * Returns the X-coordinate of the frame for the window
  419. *
  420. * Inputs:
  421. * ------
  422. * pcd - pointer to client data record
  423. *
  424. * Outputs:
  425. * -------
  426. * FrameX - X position of frame
  427. *
  428. * Comments:
  429. * --------
  430. *
  431. *************************************<->***********************************/
  432. int FrameX (ClientData *pcd)
  433. {
  434. int frameX;
  435. frameX = ((pcd->maxConfig) ? pcd->maxX : pcd->clientX)
  436. - LowerBorderWidth (pcd) - pcd->matteWidth;
  437. return (frameX);
  438. }
  439. /*************************************<->*************************************
  440. *
  441. * int FrameY (pcd)
  442. *
  443. *
  444. * Description:
  445. * -----------
  446. * Returns the Y-coordinate of the frame for the window
  447. *
  448. * Inputs:
  449. * ------
  450. * pcd - pointer to client data record
  451. *
  452. * Outputs:
  453. * -------
  454. * FrameY - Y position of frame
  455. *
  456. * Comments:
  457. * --------
  458. *
  459. *************************************<->***********************************/
  460. int FrameY (ClientData *pcd)
  461. {
  462. int frameY;
  463. frameY = ((pcd->maxConfig) ? pcd->maxY : pcd->clientY)
  464. - UpperBorderWidth (pcd)
  465. - TitleBarHeight (pcd) - pcd->matteWidth;
  466. if ((pcd->decor & MWM_DECOR_TITLE) &&
  467. !(pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER)) &&
  468. !(pcd->matteWidth))
  469. {
  470. frameY -= pcd->xBorderWidth;
  471. }
  472. return (frameY);
  473. }
  474. /*************************************<->*************************************
  475. *
  476. * unsigned int BaseWindowWidth (pcd)
  477. *
  478. *
  479. * Description:
  480. * -----------
  481. * Returns the width of the base window
  482. *
  483. * Inputs:
  484. * ------
  485. * pcd - pointer to client data record
  486. *
  487. * Outputs:
  488. * -------
  489. * BaseWindowWidth
  490. *
  491. * Comments:
  492. * --------
  493. * o Based on code taken out of FrameWidth to make it a little
  494. * more efficient.
  495. *
  496. *************************************<->***********************************/
  497. unsigned int BaseWindowWidth (ClientData *pcd)
  498. {
  499. unsigned int rval;
  500. if (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
  501. {
  502. /*
  503. * rval = FrameWidth(pcd) - 2*LowerBorderWidth(pcd);
  504. */
  505. rval = ((pcd->maxConfig) ? pcd->maxWidth : pcd->clientWidth) +
  506. 2*pcd->matteWidth;
  507. }
  508. else
  509. {
  510. /*
  511. * rval = FrameWidth(pcd);
  512. */
  513. rval = ((pcd->maxConfig) ? pcd->maxWidth : pcd->clientWidth) +
  514. 2*pcd->matteWidth + 2*LowerBorderWidth (pcd);
  515. }
  516. return (rval);
  517. }
  518. /*************************************<->*************************************
  519. *
  520. * unsigned int BaseWindowHeight (pcd)
  521. *
  522. *
  523. * Description:
  524. * -----------
  525. * Returns the height of the base window
  526. *
  527. * Inputs:
  528. * ------
  529. * pcd - pointer to client data record
  530. *
  531. * Outputs:
  532. * -------
  533. * BaseWindowHeight
  534. *
  535. * Comments:
  536. * --------
  537. * o Based on code taken out of FrameHeight to make it a little
  538. * more efficient.
  539. *
  540. *************************************<->***********************************/
  541. unsigned int BaseWindowHeight (ClientData *pcd)
  542. {
  543. unsigned int rval;
  544. if (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
  545. {
  546. /*
  547. * rval = FrameHeight(pcd) - LowerBorderWidth(pcd) -
  548. * UpperBorderWidth(pcd) - TitleBarHeight(pcd);
  549. */
  550. rval = ((pcd->maxConfig) ? pcd->maxHeight : pcd->clientHeight) +
  551. 2*pcd->matteWidth;
  552. }
  553. else
  554. {
  555. /*
  556. * rval = FrameHeight(pcd) - TitleBarHeight(pcd);
  557. */
  558. rval = ((pcd->maxConfig) ? pcd->maxHeight : pcd->clientHeight) +
  559. 2*pcd->matteWidth + 2*LowerBorderWidth (pcd);
  560. }
  561. return (rval);
  562. }
  563. /*************************************<->*************************************
  564. *
  565. * Boolean GetFramePartInfo (pcd, part, pX, pY, pWidth, pHeight)
  566. *
  567. *
  568. * Description:
  569. * -----------
  570. * Gets frame relative position and size of the specified frame part
  571. *
  572. *
  573. * Inputs:
  574. * ------
  575. * pcd - pointer to client data
  576. * part - part id (e.g. FRAME_TITLE, FRAME_SYSTEM, etc.)
  577. * pX - pointer to x-coord return value
  578. * pY - pointer to y-coord return value
  579. * pWidth - pointer to width return value
  580. * pHeight - pointer to width return value
  581. *
  582. *
  583. * Outputs:
  584. * -------
  585. * Return - True if values returned, false if no such part for this
  586. * frame (values undefined).
  587. *
  588. *
  589. * Comments:
  590. * --------
  591. *
  592. *************************************<->***********************************/
  593. Boolean GetFramePartInfo (ClientData *pcd, int part, int *pX, int *pY, unsigned int *pWidth, unsigned int *pHeight)
  594. {
  595. unsigned int boxdim = TitleBarHeight (pcd);
  596. unsigned long decor = pcd->decor;
  597. int vert, horiz;
  598. Boolean rval = FALSE;
  599. switch (part)
  600. {
  601. case FRAME_SYSTEM:
  602. if (decor & MWM_DECOR_MENU) {
  603. *pX = pcd->frameInfo.upperBorderWidth;
  604. *pY = pcd->frameInfo.upperBorderWidth;
  605. *pWidth = boxdim;
  606. *pHeight = boxdim;
  607. rval = TRUE;
  608. }
  609. break;
  610. case FRAME_TITLE:
  611. if (decor & MWM_DECOR_TITLE) {
  612. *pX = pcd->frameInfo.upperBorderWidth +
  613. ((decor & MWM_DECOR_MENU) ? boxdim : 0);
  614. *pY = pcd->frameInfo.upperBorderWidth;
  615. *pWidth = pcd->frameInfo.width -
  616. 2*pcd->frameInfo.upperBorderWidth -
  617. ((decor & MWM_DECOR_MENU) ? boxdim : 0) -
  618. ((decor & MWM_DECOR_MINIMIZE) ? boxdim : 0) -
  619. ((decor & MWM_DECOR_MAXIMIZE) ? boxdim : 0);
  620. *pHeight = boxdim;
  621. rval = TRUE;
  622. }
  623. break;
  624. case FRAME_TITLEBAR:
  625. if (decor & MWM_DECOR_TITLE) {
  626. *pX = pcd->frameInfo.upperBorderWidth;
  627. *pY = pcd->frameInfo.upperBorderWidth;
  628. *pWidth = pcd->frameInfo.width -
  629. 2*pcd->frameInfo.upperBorderWidth;
  630. *pHeight = boxdim;
  631. rval = TRUE;
  632. }
  633. break;
  634. case FRAME_MINIMIZE:
  635. if (decor & MWM_DECOR_MINIMIZE) {
  636. *pX = pcd->frameInfo.width -
  637. pcd->frameInfo.upperBorderWidth - boxdim -
  638. ((decor & MWM_DECOR_MAXIMIZE) ? boxdim : 0);
  639. *pY = pcd->frameInfo.upperBorderWidth;
  640. *pWidth= boxdim;
  641. *pHeight = boxdim;
  642. rval = TRUE;
  643. }
  644. break;
  645. case FRAME_MAXIMIZE:
  646. if (decor & MWM_DECOR_MAXIMIZE) {
  647. *pX = pcd->frameInfo.width -
  648. pcd->frameInfo.upperBorderWidth - boxdim;
  649. *pY = pcd->frameInfo.upperBorderWidth;
  650. *pWidth = boxdim;
  651. *pHeight = boxdim;
  652. rval = TRUE;
  653. }
  654. break;
  655. /*
  656. * For very small windows, the resize pieces will shrink
  657. * equally until the corner pieces get within two pixels
  658. * of the resize border width. At this point the "side" section
  659. * is killed off (by giving it a zero length) and the corner
  660. * pieces claim the additional space
  661. */
  662. case FRAME_RESIZE_NW:
  663. if (decor & MWM_DECOR_RESIZEH) {
  664. *pX = 0;
  665. *pY = 0;
  666. if ((int)pcd->frameInfo.cornerWidth >
  667. (int)pcd->frameInfo.lowerBorderWidth+2) {
  668. *pWidth = pcd->frameInfo.cornerWidth;
  669. }
  670. else {
  671. horiz = pcd->frameInfo.width -
  672. 2*pcd->frameInfo.cornerWidth;
  673. *pWidth = pcd->frameInfo.cornerWidth +
  674. horiz/2 + horiz%2;
  675. }
  676. if ((int)pcd->frameInfo.cornerHeight >
  677. (int)pcd->frameInfo.lowerBorderWidth+2) {
  678. *pHeight = pcd->frameInfo.cornerHeight;
  679. }
  680. else {
  681. vert = pcd->frameInfo.height -
  682. 2*pcd->frameInfo.cornerHeight;
  683. *pHeight = pcd->frameInfo.cornerHeight +
  684. vert/2 + vert%2;
  685. }
  686. rval = TRUE;
  687. }
  688. break;
  689. case FRAME_RESIZE_N:
  690. if (decor & MWM_DECOR_RESIZEH) {
  691. *pX = pcd->frameInfo.cornerWidth;
  692. *pY = 0;
  693. *pHeight = pcd->frameInfo.upperBorderWidth;
  694. if ((int)pcd->frameInfo.cornerWidth >
  695. (int)pcd->frameInfo.lowerBorderWidth+2) {
  696. *pWidth = pcd->frameInfo.width -
  697. 2*pcd->frameInfo.cornerWidth;
  698. }
  699. else {
  700. *pWidth = 0;
  701. }
  702. rval = TRUE;
  703. }
  704. break;
  705. case FRAME_RESIZE_NE:
  706. if (decor & MWM_DECOR_RESIZEH) {
  707. if ((int)pcd->frameInfo.cornerWidth >
  708. (int)pcd->frameInfo.lowerBorderWidth+2) {
  709. *pWidth = pcd->frameInfo.cornerWidth;
  710. }
  711. else {
  712. horiz = pcd->frameInfo.width -
  713. 2*pcd->frameInfo.cornerWidth;
  714. *pWidth = pcd->frameInfo.cornerWidth + horiz/2;
  715. }
  716. *pX = pcd->frameInfo.width - *pWidth;
  717. if ((int)pcd->frameInfo.cornerHeight >
  718. (int)pcd->frameInfo.lowerBorderWidth+2) {
  719. *pHeight = pcd->frameInfo.cornerHeight;
  720. }
  721. else {
  722. vert = pcd->frameInfo.height -
  723. 2*pcd->frameInfo.cornerHeight;
  724. *pHeight = pcd->frameInfo.cornerHeight +
  725. vert/2 + vert%2;
  726. }
  727. *pY = 0;
  728. rval = TRUE;
  729. }
  730. break;
  731. case FRAME_RESIZE_E:
  732. if (decor & MWM_DECOR_RESIZEH) {
  733. *pX = pcd->frameInfo.width -
  734. pcd->frameInfo.lowerBorderWidth;
  735. *pY = pcd->frameInfo.cornerHeight;
  736. *pWidth = pcd->frameInfo.lowerBorderWidth;
  737. if ((int)pcd->frameInfo.cornerHeight >
  738. (int)pcd->frameInfo.lowerBorderWidth+2) {
  739. *pHeight = pcd->frameInfo.height -
  740. 2*pcd->frameInfo.cornerHeight;
  741. }
  742. else {
  743. *pHeight = 0;
  744. }
  745. rval = TRUE;
  746. }
  747. break;
  748. case FRAME_RESIZE_SE:
  749. if (decor & MWM_DECOR_RESIZEH) {
  750. if ((int)pcd->frameInfo.cornerWidth >
  751. (int)pcd->frameInfo.lowerBorderWidth+2) {
  752. *pWidth = pcd->frameInfo.cornerWidth;
  753. }
  754. else {
  755. horiz = pcd->frameInfo.width -
  756. 2*pcd->frameInfo.cornerWidth;
  757. *pWidth = pcd->frameInfo.cornerWidth + horiz/2;
  758. }
  759. *pX = pcd->frameInfo.width - *pWidth;
  760. if ((int)pcd->frameInfo.cornerHeight >
  761. (int)pcd->frameInfo.lowerBorderWidth+2) {
  762. *pHeight = pcd->frameInfo.cornerHeight;
  763. }
  764. else {
  765. vert = pcd->frameInfo.height -
  766. 2*pcd->frameInfo.cornerHeight;
  767. *pHeight = pcd->frameInfo.cornerHeight + vert/2;
  768. }
  769. *pY = pcd->frameInfo.height - *pHeight;
  770. rval = TRUE;
  771. }
  772. break;
  773. case FRAME_RESIZE_S:
  774. if (decor & MWM_DECOR_RESIZEH) {
  775. *pX = pcd->frameInfo.cornerWidth;
  776. *pY = pcd->frameInfo.height -
  777. pcd->frameInfo.lowerBorderWidth;
  778. if ((int)pcd->frameInfo.cornerWidth >
  779. (int)pcd->frameInfo.lowerBorderWidth+2) {
  780. *pWidth = pcd->frameInfo.width -
  781. 2*pcd->frameInfo.cornerWidth;
  782. }
  783. else {
  784. *pWidth = 0;
  785. }
  786. *pHeight = pcd->frameInfo.lowerBorderWidth;
  787. rval = TRUE;
  788. }
  789. break;
  790. case FRAME_RESIZE_SW:
  791. if (decor & MWM_DECOR_RESIZEH) {
  792. if ((int)pcd->frameInfo.cornerWidth >
  793. (int)pcd->frameInfo.lowerBorderWidth+2) {
  794. *pWidth = pcd->frameInfo.cornerWidth;
  795. }
  796. else {
  797. horiz = pcd->frameInfo.width -
  798. 2*pcd->frameInfo.cornerWidth;
  799. *pWidth = pcd->frameInfo.cornerWidth +
  800. horiz/2 + horiz%2;
  801. }
  802. *pX = 0;
  803. if ((int)pcd->frameInfo.cornerHeight >
  804. (int)pcd->frameInfo.lowerBorderWidth+2) {
  805. *pHeight = pcd->frameInfo.cornerHeight;
  806. }
  807. else {
  808. vert = pcd->frameInfo.height -
  809. 2*pcd->frameInfo.cornerHeight;
  810. *pHeight = pcd->frameInfo.cornerHeight + vert/2;
  811. }
  812. *pY = pcd->frameInfo.height - *pHeight;
  813. rval = TRUE;
  814. }
  815. break;
  816. case FRAME_RESIZE_W:
  817. if (decor & MWM_DECOR_RESIZEH) {
  818. *pX = 0;
  819. *pY = pcd->frameInfo.cornerHeight;
  820. *pWidth = pcd->frameInfo.lowerBorderWidth;
  821. if ((int)pcd->frameInfo.cornerHeight >
  822. (int)pcd->frameInfo.lowerBorderWidth+2) {
  823. *pHeight = pcd->frameInfo.height -
  824. 2*pcd->frameInfo.cornerHeight;
  825. }
  826. else {
  827. *pHeight = 0;
  828. }
  829. rval = TRUE;
  830. }
  831. break;
  832. default:
  833. break;
  834. }
  835. return(rval);
  836. }
  837. /*************************************<->*************************************
  838. *
  839. * IdentifyFramePart (pCD, x, y)
  840. *
  841. *
  842. * Description:
  843. * -----------
  844. * Returns an ID representing which part of the frame received the event
  845. *
  846. *
  847. * Inputs:
  848. * ------
  849. * pCD - pointer to client data
  850. *
  851. * x, y - client coordinates of event
  852. *
  853. *
  854. * Outputs:
  855. * -------
  856. * Return - ID of frame part where the button event occurred.
  857. *
  858. *
  859. * Comments:
  860. * --------
  861. *************************************<->***********************************/
  862. int IdentifyFramePart (ClientData *pCD, int x, int y)
  863. {
  864. unsigned long decor = pCD->decor;
  865. int clientWidth = (pCD->maxConfig) ? pCD->maxWidth : pCD->clientWidth;
  866. int clientHeight= (pCD->maxConfig) ? pCD->maxHeight : pCD->clientHeight;
  867. int rval;
  868. /* check for client window */
  869. if ( (x >= pCD->clientOffset.x) &&
  870. (x < pCD->clientOffset.x + clientWidth) &&
  871. (y >= pCD->clientOffset.y) &&
  872. (y < pCD->clientOffset.y + clientHeight) )
  873. {
  874. return (FRAME_CLIENT);
  875. }
  876. /* check for client matte */
  877. if (pCD->matteWidth)
  878. {
  879. if ( (x >= pCD->matteRectangle.x) &&
  880. (x < (int)pCD->matteRectangle.x + (int)pCD->matteRectangle.width) &&
  881. (y >= pCD->matteRectangle.y) &&
  882. (y < (int)pCD->matteRectangle.y + (int)pCD->matteRectangle.height) )
  883. {
  884. return (FRAME_MATTE);
  885. }
  886. }
  887. /* check title bar */
  888. if (decor & MWM_DECOR_TITLE)
  889. {
  890. if ( pCD->pTitleGadgets &&
  891. (x >= pCD->titleRectangle.x) &&
  892. (x < (int)pCD->titleRectangle.x + (int)pCD->titleRectangle.width) &&
  893. (y >= pCD->titleRectangle.y) &&
  894. (y < (int)pCD->titleRectangle.y + (int)pCD->titleRectangle.height) )
  895. {
  896. return(GadgetID(x, y, pCD->pTitleGadgets,
  897. (unsigned int)pCD->cTitleGadgets));
  898. }
  899. }
  900. /* try resize border */
  901. if (decor & MWM_DECOR_RESIZEH && pCD->pTitleGadgets)
  902. {
  903. rval = GadgetID(x, y, pCD->pResizeGadgets, STRETCH_COUNT);
  904. }
  905. else
  906. {
  907. rval = FRAME_NONE;
  908. }
  909. /* if not a resize border, but still in bounds return FRAME_NBORDER */
  910. if (rval == FRAME_NONE)
  911. {
  912. if ((x >= 0) && (y >= 0) &&
  913. (x < FrameWidth (pCD)) && (y < FrameHeight (pCD)))
  914. {
  915. rval = FRAME_NBORDER;
  916. }
  917. }
  918. return (rval);
  919. } /* END OF FUNCTION IdentifyFramePart */
  920. /*************************************<->*************************************
  921. *
  922. * GadgetID (x, y, pgadget, count)
  923. *
  924. *
  925. * Description:
  926. * -----------
  927. * returns the id of the gadget in the list that the event occurred in
  928. *
  929. *
  930. * Inputs:
  931. * ------
  932. * x - x coordinate of event
  933. * y - y coordinate of event
  934. * pgadget - pointer to a list of GadgetRectangles
  935. * count - number of elements in the pgadget list
  936. *
  937. * Outputs:
  938. * -------
  939. * Return - ID of gadget if found, FRAME_NONE if not found
  940. *
  941. *
  942. * Comments:
  943. * --------
  944. *
  945. *
  946. *************************************<->***********************************/
  947. int GadgetID (int x, int y, GadgetRectangle *pgadget, unsigned int count)
  948. {
  949. int ix;
  950. for (ix = 0; ix < count; ix++, pgadget++) {
  951. if ( (x >= pgadget->rect.x) &&
  952. (x < (int)pgadget->rect.x + (int)pgadget->rect.width) &&
  953. (y >= pgadget->rect.y) &&
  954. (y < (int)pgadget->rect.y + (int)pgadget->rect.height) ) {
  955. return ((unsigned long) pgadget->id);
  956. }
  957. }
  958. return(FRAME_NONE);
  959. }
  960. /*************************************<->*************************************
  961. *
  962. * FrameToClient (pcd, pX, pY, pWidth, pHeight)
  963. *
  964. *
  965. * Description:
  966. * -----------
  967. * Converts frame position and size to client position and size
  968. *
  969. *
  970. * Inputs:
  971. * ------
  972. * pcd - pointer to client data
  973. * pX - pointer to frame x-coord
  974. * pY - pointer to frame y-coord
  975. * pWidth - pointer to frame width in pixels
  976. * pHeight - pointer to frame height in pixels
  977. *
  978. * Outputs:
  979. * -------
  980. * *pX - client x-coord
  981. * *pY - client y-coord
  982. * *pWidth - client width in pixels
  983. * *pHeight - client height in pixels
  984. *
  985. *
  986. * Comments:
  987. * --------
  988. *
  989. *************************************<->***********************************/
  990. void FrameToClient (ClientData *pcd, int *pX, int *pY, unsigned int *pWidth, unsigned int *pHeight)
  991. {
  992. /* compute client window coordinates from frame coordinates */
  993. *pWidth = *pWidth - 2*pcd->clientOffset.x;
  994. *pHeight = *pHeight - pcd->clientOffset.x - pcd->clientOffset.y;
  995. *pX = *pX + pcd->clientOffset.x;
  996. *pY = *pY + pcd->clientOffset.y;
  997. }
  998. /*************************************<->*************************************
  999. *
  1000. * ClientToFrame (pcd, pX, pY, pWidth, pHeight)
  1001. *
  1002. *
  1003. * Description:
  1004. * -----------
  1005. * Converts frame position and size to client position and size
  1006. *
  1007. *
  1008. * Inputs:
  1009. * ------
  1010. * pcd - pointer to client data
  1011. * pX - client x-coord
  1012. * pY - client y-coord
  1013. * pWidth - client width in pixels
  1014. * pHeight - client height in pixels
  1015. *
  1016. * Outputs:
  1017. * -------
  1018. * *pX - frame x-coord
  1019. * *pY - frame y-coord
  1020. * *pWidth - frame width in pixels
  1021. * *pHeight - frame height in pixels
  1022. *
  1023. *
  1024. * Comments:
  1025. * --------
  1026. *
  1027. *************************************<->***********************************/
  1028. void ClientToFrame (ClientData *pcd, int *pX, int *pY, unsigned int *pWidth, unsigned int *pHeight)
  1029. {
  1030. /* compute client window coordinates from frame coordinates */
  1031. *pWidth = *pWidth + 2*pcd->clientOffset.x;
  1032. *pHeight = *pHeight + pcd->clientOffset.x + pcd->clientOffset.y;
  1033. *pX = *pX - pcd->clientOffset.x;
  1034. *pY = *pY - pcd->clientOffset.y;
  1035. }
  1036. /*************************************<->*************************************
  1037. *
  1038. * Boolean GetDepressInfo (pcd, part, pX, pY, pWidth, pHeight)
  1039. *
  1040. *
  1041. * Description:
  1042. * -----------
  1043. * Gets frame relative position, size, and width of the beveling
  1044. * to show the gadget in its depressed state.
  1045. *
  1046. *
  1047. * Inputs:
  1048. * ------
  1049. * pcd - pointer to client data
  1050. * part - part id (e.g. FRAME_TITLE, FRAME_SYSTEM, etc.)
  1051. * pX - pointer to x-coord return value
  1052. * pY - pointer to y-coord return value
  1053. * pWidth - pointer to width return value
  1054. * pHeight - pointer to width return value
  1055. * pInverWidth - pointer to inversion width return value
  1056. *
  1057. *
  1058. * Outputs:
  1059. * -------
  1060. * Return - True if values returned, false if no such part for this
  1061. * frame (values undefined).
  1062. *
  1063. *
  1064. * Comments:
  1065. * --------
  1066. * o The "part" must be a title bar gadget.
  1067. *
  1068. *************************************<->***********************************/
  1069. Boolean GetDepressInfo (ClientData *pcd, int part, int *pX, int *pY, unsigned int *pWidth, unsigned int *pHeight, unsigned int *pInvertWidth)
  1070. {
  1071. Boolean rval;
  1072. unsigned int exBevel, eBevel;
  1073. unsigned int wBevel, sBevel;
  1074. unsigned int insideBevel, meBevel;
  1075. unsigned int decoration = pcd->decor;
  1076. unsigned int tmp;
  1077. switch (part)
  1078. {
  1079. case FRAME_SYSTEM:
  1080. case FRAME_TITLE:
  1081. case FRAME_MINIMIZE:
  1082. case FRAME_MAXIMIZE:
  1083. if ((rval = GetFramePartInfo (pcd, part, pX, pY, pWidth, pHeight)))
  1084. {
  1085. /*
  1086. * set bevel width based on join bevel
  1087. */
  1088. *pInvertWidth = 1 + (JOIN_BEVEL(pcd) / 2);
  1089. /* bevel between title and client (or matte) */
  1090. insideBevel = (pcd->matteWidth > 0) ? JOIN_BEVEL(pcd) :
  1091. pcd->internalBevel;
  1092. /*
  1093. * Compute beveling around the title area of the
  1094. * title bar.
  1095. */
  1096. if (decoration & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
  1097. {
  1098. exBevel = JOIN_BEVEL(pcd); /* north side */
  1099. sBevel = insideBevel; /* south side */
  1100. eBevel = JOIN_BEVEL(pcd); /* east side */
  1101. wBevel = JOIN_BEVEL(pcd); /* west side */
  1102. meBevel = JOIN_BEVEL(pcd); /* east of Min */
  1103. }
  1104. else
  1105. {
  1106. /* borderless window */
  1107. exBevel = EXTERNAL_BEVEL(pcd);
  1108. sBevel = (pcd->matteWidth > 0) ? insideBevel :
  1109. EXTERNAL_BEVEL(pcd);
  1110. eBevel = (decoration & (MWM_DECOR_MINIMIZE |
  1111. MWM_DECOR_MAXIMIZE))?
  1112. JOIN_BEVEL(pcd) : EXTERNAL_BEVEL(pcd);
  1113. wBevel = (decoration & MWM_DECOR_MENU) ?
  1114. JOIN_BEVEL(pcd) : EXTERNAL_BEVEL(pcd);
  1115. meBevel = (decoration & (MWM_DECOR_MAXIMIZE)) ?
  1116. JOIN_BEVEL(pcd) : EXTERNAL_BEVEL(pcd);
  1117. }
  1118. /*
  1119. * Adjust height of all title bar gadgets if necessary.
  1120. * (The bottom bevel is the same for all the pieces.)
  1121. */
  1122. if (sBevel > *pInvertWidth)
  1123. {
  1124. *pHeight -= (sBevel - *pInvertWidth);
  1125. }
  1126. /*
  1127. * Adjust the beveling on the other sides of the
  1128. * gadgets.
  1129. */
  1130. switch (part)
  1131. {
  1132. case FRAME_SYSTEM:
  1133. /* west and north sides */
  1134. if (exBevel > *pInvertWidth)
  1135. {
  1136. tmp = exBevel - *pInvertWidth;
  1137. *pX += tmp;
  1138. *pWidth -= tmp;
  1139. *pY += tmp;
  1140. *pHeight -= tmp;
  1141. }
  1142. /* east side */
  1143. if (wBevel > *pInvertWidth)
  1144. {
  1145. *pWidth -= (wBevel - *pInvertWidth);
  1146. }
  1147. break;
  1148. case FRAME_TITLE:
  1149. /* west side */
  1150. if (wBevel > *pInvertWidth)
  1151. {
  1152. tmp = wBevel - *pInvertWidth;
  1153. *pX += tmp;
  1154. *pWidth -= tmp;
  1155. }
  1156. /* north side */
  1157. if (exBevel > *pInvertWidth)
  1158. {
  1159. tmp = exBevel - *pInvertWidth;
  1160. *pY += tmp;
  1161. *pHeight -= tmp;
  1162. }
  1163. /* east side */
  1164. if (eBevel > *pInvertWidth)
  1165. {
  1166. *pWidth -= eBevel - *pInvertWidth;
  1167. }
  1168. break;
  1169. case FRAME_MINIMIZE:
  1170. /* north side */
  1171. if (exBevel > *pInvertWidth)
  1172. {
  1173. tmp = exBevel - *pInvertWidth;
  1174. *pY += tmp;
  1175. *pHeight -= tmp;
  1176. }
  1177. /* west side */
  1178. if (eBevel > *pInvertWidth)
  1179. {
  1180. tmp = eBevel - *pInvertWidth;
  1181. *pX += tmp;
  1182. *pWidth -= tmp;
  1183. }
  1184. /* east side */
  1185. if (meBevel > *pInvertWidth)
  1186. {
  1187. *pWidth -= meBevel - *pInvertWidth;
  1188. }
  1189. break;
  1190. case FRAME_MAXIMIZE:
  1191. /* north and east sides */
  1192. if (exBevel > *pInvertWidth)
  1193. {
  1194. tmp = exBevel - *pInvertWidth;
  1195. *pY += tmp;
  1196. *pHeight -= tmp;
  1197. *pWidth -= tmp;
  1198. }
  1199. /* west side */
  1200. if (eBevel > *pInvertWidth)
  1201. {
  1202. tmp = eBevel - *pInvertWidth;
  1203. *pX += tmp;
  1204. *pWidth -= tmp;
  1205. }
  1206. break;
  1207. } /* end switch */
  1208. } /* end case "title bar part" */
  1209. break;
  1210. default:
  1211. rval = False;
  1212. break;
  1213. } /* end switch */
  1214. return (rval);
  1215. }
  1216. /*************************************<->*************************************
  1217. *
  1218. * SetFrameInfo (pcd)
  1219. *
  1220. *
  1221. * Description:
  1222. * -----------
  1223. * Sets frame information into client data structure for easy access.
  1224. *
  1225. *
  1226. * Inputs:
  1227. * ------
  1228. * pcd - pointer to client data
  1229. *
  1230. * Outputs:
  1231. * -------
  1232. *
  1233. * Comments:
  1234. * --------
  1235. * o Sets values into the FrameInfo component of the client data structure
  1236. *
  1237. *************************************<->***********************************/
  1238. void SetFrameInfo (ClientData *pcd)
  1239. {
  1240. /*
  1241. * The title bar height value stored in pcd->frameInfo is used by the
  1242. * macro TitleBarHeight(pcd).
  1243. */
  1244. pcd->frameInfo.titleBarHeight = InitTitleBarHeight (pcd);
  1245. pcd->frameInfo.x = FrameX (pcd);
  1246. pcd->frameInfo.y = FrameY (pcd);
  1247. pcd->frameInfo.width = FrameWidth (pcd);
  1248. pcd->frameInfo.height = FrameHeight (pcd);
  1249. pcd->frameInfo.upperBorderWidth = UpperBorderWidth (pcd);
  1250. pcd->frameInfo.lowerBorderWidth = LowerBorderWidth (pcd);
  1251. pcd->frameInfo.cornerWidth = CornerWidth (pcd);
  1252. pcd->frameInfo.cornerHeight = CornerHeight (pcd);
  1253. /* set client offset */
  1254. if ( (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER)) ||
  1255. (pcd->matteWidth > 0) )
  1256. {
  1257. /*
  1258. * The window has a window manager border.
  1259. */
  1260. pcd->clientOffset.x = pcd->frameInfo.lowerBorderWidth +
  1261. pcd->matteWidth;
  1262. pcd->clientOffset.y = pcd->frameInfo.upperBorderWidth +
  1263. pcd->frameInfo.titleBarHeight +
  1264. pcd->matteWidth;
  1265. }
  1266. else
  1267. {
  1268. /*
  1269. * No window manager border, the original X border is showing
  1270. * through.
  1271. */
  1272. pcd->clientOffset.x = pcd->xBorderWidth + pcd->matteWidth;
  1273. pcd->clientOffset.y = pcd->xBorderWidth +
  1274. pcd->frameInfo.titleBarHeight +
  1275. pcd->matteWidth;
  1276. }
  1277. }
  1278. /*************************************<->*************************************
  1279. *
  1280. * SetClientOffset (pcd)
  1281. *
  1282. *
  1283. * Description:
  1284. * -----------
  1285. * Sets the client offset into client data structure
  1286. *
  1287. *
  1288. * Inputs:
  1289. * ------
  1290. * pcd - pointer to client data
  1291. *
  1292. * Outputs:
  1293. * -------
  1294. *
  1295. * Comments:
  1296. * --------
  1297. * This can be called before SetFrameInfo to set up the client offset
  1298. * without the danger of using uninitialized variables during
  1299. * extraneous computation.
  1300. *
  1301. *************************************<->***********************************/
  1302. void SetClientOffset (ClientData *pcd)
  1303. {
  1304. /*
  1305. * The title bar height value stored in pcd->frameInfo is used by the
  1306. * macro TitleBarHeight(pcd).
  1307. */
  1308. pcd->frameInfo.titleBarHeight = InitTitleBarHeight (pcd);
  1309. pcd->frameInfo.upperBorderWidth = UpperBorderWidth (pcd);
  1310. pcd->frameInfo.lowerBorderWidth = LowerBorderWidth (pcd);
  1311. /* set client offset */
  1312. if ( (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER)) ||
  1313. (pcd->matteWidth > 0) )
  1314. {
  1315. /*
  1316. * The window has a window manager border.
  1317. */
  1318. pcd->clientOffset.x = pcd->frameInfo.lowerBorderWidth +
  1319. pcd->matteWidth;
  1320. pcd->clientOffset.y = pcd->frameInfo.upperBorderWidth +
  1321. pcd->frameInfo.titleBarHeight +
  1322. pcd->matteWidth;
  1323. }
  1324. else
  1325. {
  1326. /*
  1327. * No window manager border, the original X border is showing
  1328. * through.
  1329. */
  1330. pcd->clientOffset.x = pcd->xBorderWidth + pcd->matteWidth;
  1331. pcd->clientOffset.y = pcd->xBorderWidth +
  1332. pcd->frameInfo.titleBarHeight +
  1333. pcd->matteWidth;
  1334. }
  1335. }
  1336. /*************************************<->*************************************
  1337. *
  1338. * XBorderIsShowing (pcd)
  1339. *
  1340. *
  1341. * Description:
  1342. * -----------
  1343. * Returns true if the X border is showing.
  1344. *
  1345. *
  1346. * Inputs:
  1347. * ------
  1348. * pcd - pointer to client data
  1349. *
  1350. * Outputs:
  1351. * -------
  1352. * XBorderIsShowing - True if no window manager border & x border is
  1353. * visible, False otherwise
  1354. *
  1355. * Comments:
  1356. * --------
  1357. *
  1358. *************************************<->***********************************/
  1359. Boolean XBorderIsShowing (ClientData *pcd)
  1360. {
  1361. Boolean rval;
  1362. if ( (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER)) ||
  1363. (pcd->matteWidth > 0) )
  1364. {
  1365. rval = False; /* hidden by window manager */
  1366. }
  1367. else
  1368. {
  1369. rval = True; /* it's showing */
  1370. }
  1371. return(rval);
  1372. }