2
0

WmCDInfo.c 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541
  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 ( (x >= pCD->titleRectangle.x) &&
  891. (x < (int)pCD->titleRectangle.x + (int)pCD->titleRectangle.width) &&
  892. (y >= pCD->titleRectangle.y) &&
  893. (y < (int)pCD->titleRectangle.y + (int)pCD->titleRectangle.height) )
  894. {
  895. return(GadgetID(x, y, pCD->pTitleGadgets,
  896. (unsigned int)pCD->cTitleGadgets));
  897. }
  898. }
  899. /* try resize border */
  900. if (decor & MWM_DECOR_RESIZEH)
  901. {
  902. rval = GadgetID(x, y, pCD->pResizeGadgets, STRETCH_COUNT);
  903. }
  904. else
  905. {
  906. rval = FRAME_NONE;
  907. }
  908. /* if not a resize border, but still in bounds return FRAME_NBORDER */
  909. if (rval == FRAME_NONE)
  910. {
  911. if ((x >= 0) && (y >= 0) &&
  912. (x < FrameWidth (pCD)) && (y < FrameHeight (pCD)))
  913. {
  914. rval = FRAME_NBORDER;
  915. }
  916. }
  917. return (rval);
  918. } /* END OF FUNCTION IdentifyFramePart */
  919. /*************************************<->*************************************
  920. *
  921. * GadgetID (x, y, pgadget, count)
  922. *
  923. *
  924. * Description:
  925. * -----------
  926. * returns the id of the gadget in the list that the event occurred in
  927. *
  928. *
  929. * Inputs:
  930. * ------
  931. * x - x coordinate of event
  932. * y - y coordinate of event
  933. * pgadget - pointer to a list of GadgetRectangles
  934. * count - number of elements in the pgadget list
  935. *
  936. * Outputs:
  937. * -------
  938. * Return - ID of gadget if found, FRAME_NONE if not found
  939. *
  940. *
  941. * Comments:
  942. * --------
  943. *
  944. *
  945. *************************************<->***********************************/
  946. int GadgetID (int x, int y, GadgetRectangle *pgadget, unsigned int count)
  947. {
  948. int ix;
  949. for (ix = 0; ix < count; ix++, pgadget++) {
  950. if ( (x >= pgadget->rect.x) &&
  951. (x < (int)pgadget->rect.x + (int)pgadget->rect.width) &&
  952. (y >= pgadget->rect.y) &&
  953. (y < (int)pgadget->rect.y + (int)pgadget->rect.height) ) {
  954. return ((unsigned long) pgadget->id);
  955. }
  956. }
  957. return(FRAME_NONE);
  958. }
  959. /*************************************<->*************************************
  960. *
  961. * FrameToClient (pcd, pX, pY, pWidth, pHeight)
  962. *
  963. *
  964. * Description:
  965. * -----------
  966. * Converts frame position and size to client position and size
  967. *
  968. *
  969. * Inputs:
  970. * ------
  971. * pcd - pointer to client data
  972. * pX - pointer to frame x-coord
  973. * pY - pointer to frame y-coord
  974. * pWidth - pointer to frame width in pixels
  975. * pHeight - pointer to frame height in pixels
  976. *
  977. * Outputs:
  978. * -------
  979. * *pX - client x-coord
  980. * *pY - client y-coord
  981. * *pWidth - client width in pixels
  982. * *pHeight - client height in pixels
  983. *
  984. *
  985. * Comments:
  986. * --------
  987. *
  988. *************************************<->***********************************/
  989. void FrameToClient (ClientData *pcd, int *pX, int *pY, unsigned int *pWidth, unsigned int *pHeight)
  990. {
  991. /* compute client window coordinates from frame coordinates */
  992. *pWidth = *pWidth - 2*pcd->clientOffset.x;
  993. *pHeight = *pHeight - pcd->clientOffset.x - pcd->clientOffset.y;
  994. *pX = *pX + pcd->clientOffset.x;
  995. *pY = *pY + pcd->clientOffset.y;
  996. }
  997. /*************************************<->*************************************
  998. *
  999. * ClientToFrame (pcd, pX, pY, pWidth, pHeight)
  1000. *
  1001. *
  1002. * Description:
  1003. * -----------
  1004. * Converts frame position and size to client position and size
  1005. *
  1006. *
  1007. * Inputs:
  1008. * ------
  1009. * pcd - pointer to client data
  1010. * pX - client x-coord
  1011. * pY - client y-coord
  1012. * pWidth - client width in pixels
  1013. * pHeight - client height in pixels
  1014. *
  1015. * Outputs:
  1016. * -------
  1017. * *pX - frame x-coord
  1018. * *pY - frame y-coord
  1019. * *pWidth - frame width in pixels
  1020. * *pHeight - frame height in pixels
  1021. *
  1022. *
  1023. * Comments:
  1024. * --------
  1025. *
  1026. *************************************<->***********************************/
  1027. void ClientToFrame (ClientData *pcd, int *pX, int *pY, unsigned int *pWidth, unsigned int *pHeight)
  1028. {
  1029. /* compute client window coordinates from frame coordinates */
  1030. *pWidth = *pWidth + 2*pcd->clientOffset.x;
  1031. *pHeight = *pHeight + pcd->clientOffset.x + pcd->clientOffset.y;
  1032. *pX = *pX - pcd->clientOffset.x;
  1033. *pY = *pY - pcd->clientOffset.y;
  1034. }
  1035. /*************************************<->*************************************
  1036. *
  1037. * Boolean GetDepressInfo (pcd, part, pX, pY, pWidth, pHeight)
  1038. *
  1039. *
  1040. * Description:
  1041. * -----------
  1042. * Gets frame relative position, size, and width of the beveling
  1043. * to show the gadget in its depressed state.
  1044. *
  1045. *
  1046. * Inputs:
  1047. * ------
  1048. * pcd - pointer to client data
  1049. * part - part id (e.g. FRAME_TITLE, FRAME_SYSTEM, etc.)
  1050. * pX - pointer to x-coord return value
  1051. * pY - pointer to y-coord return value
  1052. * pWidth - pointer to width return value
  1053. * pHeight - pointer to width return value
  1054. * pInverWidth - pointer to inversion width return value
  1055. *
  1056. *
  1057. * Outputs:
  1058. * -------
  1059. * Return - True if values returned, false if no such part for this
  1060. * frame (values undefined).
  1061. *
  1062. *
  1063. * Comments:
  1064. * --------
  1065. * o The "part" must be a title bar gadget.
  1066. *
  1067. *************************************<->***********************************/
  1068. Boolean GetDepressInfo (ClientData *pcd, int part, int *pX, int *pY, unsigned int *pWidth, unsigned int *pHeight, unsigned int *pInvertWidth)
  1069. {
  1070. Boolean rval;
  1071. unsigned int exBevel, eBevel;
  1072. unsigned int wBevel, sBevel;
  1073. unsigned int insideBevel, meBevel;
  1074. unsigned int decoration = pcd->decor;
  1075. unsigned int tmp;
  1076. switch (part)
  1077. {
  1078. case FRAME_SYSTEM:
  1079. case FRAME_TITLE:
  1080. case FRAME_MINIMIZE:
  1081. case FRAME_MAXIMIZE:
  1082. if ((rval = GetFramePartInfo (pcd, part, pX, pY, pWidth, pHeight)))
  1083. {
  1084. /*
  1085. * set bevel width based on join bevel
  1086. */
  1087. *pInvertWidth = 1 + (JOIN_BEVEL(pcd) / 2);
  1088. /* bevel between title and client (or matte) */
  1089. insideBevel = (pcd->matteWidth > 0) ? JOIN_BEVEL(pcd) :
  1090. pcd->internalBevel;
  1091. /*
  1092. * Compute beveling around the title area of the
  1093. * title bar.
  1094. */
  1095. if (decoration & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
  1096. {
  1097. exBevel = JOIN_BEVEL(pcd); /* north side */
  1098. sBevel = insideBevel; /* south side */
  1099. eBevel = JOIN_BEVEL(pcd); /* east side */
  1100. wBevel = JOIN_BEVEL(pcd); /* west side */
  1101. meBevel = JOIN_BEVEL(pcd); /* east of Min */
  1102. }
  1103. else
  1104. {
  1105. /* borderless window */
  1106. exBevel = EXTERNAL_BEVEL(pcd);
  1107. sBevel = (pcd->matteWidth > 0) ? insideBevel :
  1108. EXTERNAL_BEVEL(pcd);
  1109. eBevel = (decoration & (MWM_DECOR_MINIMIZE |
  1110. MWM_DECOR_MAXIMIZE))?
  1111. JOIN_BEVEL(pcd) : EXTERNAL_BEVEL(pcd);
  1112. wBevel = (decoration & MWM_DECOR_MENU) ?
  1113. JOIN_BEVEL(pcd) : EXTERNAL_BEVEL(pcd);
  1114. meBevel = (decoration & (MWM_DECOR_MAXIMIZE)) ?
  1115. JOIN_BEVEL(pcd) : EXTERNAL_BEVEL(pcd);
  1116. }
  1117. /*
  1118. * Adjust height of all title bar gadgets if necessary.
  1119. * (The bottom bevel is the same for all the pieces.)
  1120. */
  1121. if (sBevel > *pInvertWidth)
  1122. {
  1123. *pHeight -= (sBevel - *pInvertWidth);
  1124. }
  1125. /*
  1126. * Adjust the beveling on the other sides of the
  1127. * gadgets.
  1128. */
  1129. switch (part)
  1130. {
  1131. case FRAME_SYSTEM:
  1132. /* west and north sides */
  1133. if (exBevel > *pInvertWidth)
  1134. {
  1135. tmp = exBevel - *pInvertWidth;
  1136. *pX += tmp;
  1137. *pWidth -= tmp;
  1138. *pY += tmp;
  1139. *pHeight -= tmp;
  1140. }
  1141. /* east side */
  1142. if (wBevel > *pInvertWidth)
  1143. {
  1144. *pWidth -= (wBevel - *pInvertWidth);
  1145. }
  1146. break;
  1147. case FRAME_TITLE:
  1148. /* west side */
  1149. if (wBevel > *pInvertWidth)
  1150. {
  1151. tmp = wBevel - *pInvertWidth;
  1152. *pX += tmp;
  1153. *pWidth -= tmp;
  1154. }
  1155. /* north side */
  1156. if (exBevel > *pInvertWidth)
  1157. {
  1158. tmp = exBevel - *pInvertWidth;
  1159. *pY += tmp;
  1160. *pHeight -= tmp;
  1161. }
  1162. /* east side */
  1163. if (eBevel > *pInvertWidth)
  1164. {
  1165. *pWidth -= eBevel - *pInvertWidth;
  1166. }
  1167. break;
  1168. case FRAME_MINIMIZE:
  1169. /* north side */
  1170. if (exBevel > *pInvertWidth)
  1171. {
  1172. tmp = exBevel - *pInvertWidth;
  1173. *pY += tmp;
  1174. *pHeight -= tmp;
  1175. }
  1176. /* west side */
  1177. if (eBevel > *pInvertWidth)
  1178. {
  1179. tmp = eBevel - *pInvertWidth;
  1180. *pX += tmp;
  1181. *pWidth -= tmp;
  1182. }
  1183. /* east side */
  1184. if (meBevel > *pInvertWidth)
  1185. {
  1186. *pWidth -= meBevel - *pInvertWidth;
  1187. }
  1188. break;
  1189. case FRAME_MAXIMIZE:
  1190. /* north and east sides */
  1191. if (exBevel > *pInvertWidth)
  1192. {
  1193. tmp = exBevel - *pInvertWidth;
  1194. *pY += tmp;
  1195. *pHeight -= tmp;
  1196. *pWidth -= tmp;
  1197. }
  1198. /* west side */
  1199. if (eBevel > *pInvertWidth)
  1200. {
  1201. tmp = eBevel - *pInvertWidth;
  1202. *pX += tmp;
  1203. *pWidth -= tmp;
  1204. }
  1205. break;
  1206. } /* end switch */
  1207. } /* end case "title bar part" */
  1208. break;
  1209. default:
  1210. rval = False;
  1211. break;
  1212. } /* end switch */
  1213. return (rval);
  1214. }
  1215. /*************************************<->*************************************
  1216. *
  1217. * SetFrameInfo (pcd)
  1218. *
  1219. *
  1220. * Description:
  1221. * -----------
  1222. * Sets frame information into client data structure for easy access.
  1223. *
  1224. *
  1225. * Inputs:
  1226. * ------
  1227. * pcd - pointer to client data
  1228. *
  1229. * Outputs:
  1230. * -------
  1231. *
  1232. * Comments:
  1233. * --------
  1234. * o Sets values into the FrameInfo component of the client data structure
  1235. *
  1236. *************************************<->***********************************/
  1237. void SetFrameInfo (ClientData *pcd)
  1238. {
  1239. /*
  1240. * The title bar height value stored in pcd->frameInfo is used by the
  1241. * macro TitleBarHeight(pcd).
  1242. */
  1243. pcd->frameInfo.titleBarHeight = InitTitleBarHeight (pcd);
  1244. pcd->frameInfo.x = FrameX (pcd);
  1245. pcd->frameInfo.y = FrameY (pcd);
  1246. pcd->frameInfo.width = FrameWidth (pcd);
  1247. pcd->frameInfo.height = FrameHeight (pcd);
  1248. pcd->frameInfo.upperBorderWidth = UpperBorderWidth (pcd);
  1249. pcd->frameInfo.lowerBorderWidth = LowerBorderWidth (pcd);
  1250. pcd->frameInfo.cornerWidth = CornerWidth (pcd);
  1251. pcd->frameInfo.cornerHeight = CornerHeight (pcd);
  1252. /* set client offset */
  1253. if ( (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER)) ||
  1254. (pcd->matteWidth > 0) )
  1255. {
  1256. /*
  1257. * The window has a window manager border.
  1258. */
  1259. pcd->clientOffset.x = pcd->frameInfo.lowerBorderWidth +
  1260. pcd->matteWidth;
  1261. pcd->clientOffset.y = pcd->frameInfo.upperBorderWidth +
  1262. pcd->frameInfo.titleBarHeight +
  1263. pcd->matteWidth;
  1264. }
  1265. else
  1266. {
  1267. /*
  1268. * No window manager border, the original X border is showing
  1269. * through.
  1270. */
  1271. pcd->clientOffset.x = pcd->xBorderWidth + pcd->matteWidth;
  1272. pcd->clientOffset.y = pcd->xBorderWidth +
  1273. pcd->frameInfo.titleBarHeight +
  1274. pcd->matteWidth;
  1275. }
  1276. }
  1277. /*************************************<->*************************************
  1278. *
  1279. * SetClientOffset (pcd)
  1280. *
  1281. *
  1282. * Description:
  1283. * -----------
  1284. * Sets the client offset into client data structure
  1285. *
  1286. *
  1287. * Inputs:
  1288. * ------
  1289. * pcd - pointer to client data
  1290. *
  1291. * Outputs:
  1292. * -------
  1293. *
  1294. * Comments:
  1295. * --------
  1296. * This can be called before SetFrameInfo to set up the client offset
  1297. * without the danger of using uninitialized variables during
  1298. * extraneous computation.
  1299. *
  1300. *************************************<->***********************************/
  1301. void SetClientOffset (ClientData *pcd)
  1302. {
  1303. /*
  1304. * The title bar height value stored in pcd->frameInfo is used by the
  1305. * macro TitleBarHeight(pcd).
  1306. */
  1307. pcd->frameInfo.titleBarHeight = InitTitleBarHeight (pcd);
  1308. pcd->frameInfo.upperBorderWidth = UpperBorderWidth (pcd);
  1309. pcd->frameInfo.lowerBorderWidth = LowerBorderWidth (pcd);
  1310. /* set client offset */
  1311. if ( (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER)) ||
  1312. (pcd->matteWidth > 0) )
  1313. {
  1314. /*
  1315. * The window has a window manager border.
  1316. */
  1317. pcd->clientOffset.x = pcd->frameInfo.lowerBorderWidth +
  1318. pcd->matteWidth;
  1319. pcd->clientOffset.y = pcd->frameInfo.upperBorderWidth +
  1320. pcd->frameInfo.titleBarHeight +
  1321. pcd->matteWidth;
  1322. }
  1323. else
  1324. {
  1325. /*
  1326. * No window manager border, the original X border is showing
  1327. * through.
  1328. */
  1329. pcd->clientOffset.x = pcd->xBorderWidth + pcd->matteWidth;
  1330. pcd->clientOffset.y = pcd->xBorderWidth +
  1331. pcd->frameInfo.titleBarHeight +
  1332. pcd->matteWidth;
  1333. }
  1334. }
  1335. /*************************************<->*************************************
  1336. *
  1337. * XBorderIsShowing (pcd)
  1338. *
  1339. *
  1340. * Description:
  1341. * -----------
  1342. * Returns true if the X border is showing.
  1343. *
  1344. *
  1345. * Inputs:
  1346. * ------
  1347. * pcd - pointer to client data
  1348. *
  1349. * Outputs:
  1350. * -------
  1351. * XBorderIsShowing - True if no window manager border & x border is
  1352. * visible, False otherwise
  1353. *
  1354. * Comments:
  1355. * --------
  1356. *
  1357. *************************************<->***********************************/
  1358. Boolean XBorderIsShowing (ClientData *pcd)
  1359. {
  1360. Boolean rval;
  1361. if ( (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER)) ||
  1362. (pcd->matteWidth > 0) )
  1363. {
  1364. rval = False; /* hidden by window manager */
  1365. }
  1366. else
  1367. {
  1368. rval = True; /* it's showing */
  1369. }
  1370. return(rval);
  1371. }