WmCDecor.c 72 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933
  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 OPEN SOFTWARE FOUNDATION, INC.
  25. * ALL RIGHTS RESERVED
  26. */
  27. /*
  28. * Motif Release 1.2.1
  29. */
  30. /*
  31. * (c) Copyright 1987,1988,1989,1990,1991,1993 HEWLETT-PACKARD COMPANY */
  32. /*
  33. * Included Files:
  34. */
  35. #include "WmGlobal.h"
  36. #include "WmXSMP.h"
  37. #include <X11/cursorfont.h>
  38. #include <Xm/Xm.h>
  39. /*
  40. * Definitions
  41. */
  42. /*
  43. * include extern functions
  44. */
  45. #include "WmCDecor.h"
  46. #include "WmCDInfo.h"
  47. #include "WmError.h"
  48. #include "WmGraphics.h"
  49. #include "WmIconBox.h"
  50. #include "WmMenu.h"
  51. #include "WmWinInfo.h"
  52. /*
  53. * Global Variables:
  54. */
  55. typedef struct {
  56. int external; /* bevel from frame to root */
  57. int join; /* bevel between frame components */
  58. int internal; /* bevel from frame to client */
  59. } Single_Bevel_Count;
  60. typedef struct {
  61. Single_Bevel_Count top;
  62. Single_Bevel_Count bottom;
  63. } Bevel_Count;
  64. /*
  65. * "Worst case" bevel counts for frame pieces: this structure is
  66. * indexed by definitions in WmGlobal.h. Edit if they change!
  67. *
  68. * These counts are multiplied by the internal, external,
  69. * and join bevel resources to determine the sizes of dynamic
  70. * data structures to allocate.
  71. *
  72. */
  73. static Bevel_Count Bevels[] =
  74. {
  75. { {0, 0, 0}, {0, 0, 0} }, /* FRAME_NONE */
  76. { {0, 0, 0}, {0, 0, 0} }, /* FRAME_CLIENT */
  77. { {0, 4, 0}, {0, 3, 1} }, /* FRAME_SYSTEM */
  78. { {0, 2, 0}, {0, 1, 1} }, /* FRAME_TITLE */
  79. { {0, 4, 0}, {0, 3, 1} }, /* FRAME_MINIMIZE */
  80. { {0, 4, 0}, {0, 3, 1} }, /* FRAME_MAXIMIZE */
  81. { {2, 0, 0}, {0, 2, 2} }, /* FRAME_RESIZE_NW */
  82. { {1, 1, 0}, {0, 1, 1} }, /* FRAME_RESIZE_N */
  83. { {1, 1, 1}, {1, 1, 1} }, /* FRAME_RESIZE_NE */
  84. { {0, 1, 1}, {1, 1, 0} }, /* FRAME_RESIZE_E */
  85. { {0, 2, 2}, {2, 0, 0} }, /* FRAME_RESIZE_SE */
  86. { {0, 1, 1}, {1, 1, 0} }, /* FRAME_RESIZE_S */
  87. { {1, 1, 1}, {1, 1, 1} }, /* FRAME_RESIZE_SW */
  88. { {1, 1, 0}, {0, 1, 1} } /* FRAME_RESIZE_W */
  89. };
  90. /*************************************<->*************************************
  91. *
  92. * CreateTitleBarWindow (pcd)
  93. *
  94. *
  95. * Description:
  96. * -----------
  97. * Create title bar window.
  98. *
  99. *
  100. * Inputs:
  101. * ------
  102. * pcd - pointer to client data record
  103. *
  104. * Outputs:
  105. * -------
  106. * pcd - modified
  107. *
  108. *
  109. * Comments:
  110. * --------
  111. *
  112. *************************************<->***********************************/
  113. static void CreateTitleBarWindow (ClientData *pcd)
  114. {
  115. unsigned int wclass; /* window class */
  116. unsigned long attr_mask;
  117. XSetWindowAttributes window_attribs;
  118. /*
  119. * Create title bar window. If the title bar has its own appearance,
  120. * or if there is no border around the client area,
  121. * then we need to create an input/output window to draw in. Otherwise
  122. * we can use an input-only window (to clip the corner resize windows).
  123. */
  124. attr_mask = CWCursor;
  125. window_attribs.cursor = wmGD.workspaceCursor;
  126. if (DECOUPLE_TITLE_APPEARANCE(pcd))
  127. {
  128. /* title bar has a different appearance than rest of frame */
  129. wclass = InputOutput;
  130. /* need to handle exposure events */
  131. attr_mask |= CWEventMask;
  132. window_attribs.event_mask = ExposureMask;
  133. /*
  134. * Use background pixmap if one is specified, otherwise set the
  135. * appropriate background color.
  136. */
  137. if (CLIENT_TITLE_APPEARANCE(pcd).backgroundPixmap)
  138. {
  139. attr_mask |= CWBackPixmap;
  140. window_attribs.background_pixmap =
  141. CLIENT_TITLE_APPEARANCE(pcd).backgroundPixmap;
  142. }
  143. else
  144. {
  145. attr_mask |= CWBackPixel;
  146. window_attribs.background_pixel =
  147. CLIENT_TITLE_APPEARANCE(pcd).background;
  148. }
  149. }
  150. else
  151. {
  152. /* title bar has same appearance as rest of frame */
  153. wclass = InputOnly;
  154. }
  155. pcd->clientTitleWin = XCreateWindow(DISPLAY, pcd->clientFrameWin,
  156. (int) pcd->frameInfo.upperBorderWidth,
  157. (int) pcd->frameInfo.upperBorderWidth,
  158. pcd->frameInfo.width -
  159. 2*pcd->frameInfo.upperBorderWidth,
  160. pcd->frameInfo.titleBarHeight,
  161. 0,
  162. CopyFromParent,wclass,CopyFromParent,
  163. attr_mask, &window_attribs);
  164. }
  165. /*************************************<->*************************************
  166. *
  167. * FrameWindow (pcd)
  168. *
  169. *
  170. * Description:
  171. * -----------
  172. * Build a decorated frame for a client window and reparent the client
  173. * window to the frame.
  174. *
  175. *
  176. * Inputs:
  177. * ------
  178. * pcd - pointer to client data structure for window
  179. *
  180. * << Need the following member data >>
  181. *
  182. * client
  183. * fields from WM_HINTS property
  184. * fields from WM_CLASS property
  185. * fields from WM_NORMAL_HINTS property
  186. * clientX
  187. * clientY
  188. * clientWidth
  189. * clientHeight
  190. * fields from WM_NAME property
  191. *
  192. *
  193. * Outputs:
  194. * -------
  195. *
  196. *
  197. * Comments:
  198. * --------
  199. * This will create a top level shell (frame), fill in the appropriate
  200. * decoration, and reparent the window (in *pcd) to the frame.
  201. *
  202. *************************************<->***********************************/
  203. Boolean FrameWindow (ClientData *pcd)
  204. {
  205. if (!ConstructFrame (pcd)) /* window hierarchy for frame */
  206. {
  207. return(FALSE);
  208. }
  209. GenerateFrameDisplayLists (pcd); /* graphics for frame decoration */
  210. AdoptClient(pcd); /* reparent the window */
  211. /* shape the frame */
  212. if (wmGD.hasShape && pcd->wShaped)
  213. {
  214. SetFrameShape (pcd);
  215. }
  216. return(TRUE);
  217. } /* END OF FUNCTION FrameWindow */
  218. /*************************************<->*************************************
  219. *
  220. * FrameExposureProc (pcd)
  221. *
  222. *
  223. * Description:
  224. * -----------
  225. * Repaint the frame graphics
  226. *
  227. *
  228. * Inputs:
  229. * ------
  230. * pcd - pointer to client data
  231. *
  232. *
  233. * Outputs:
  234. * -------
  235. * none
  236. *
  237. * Comments:
  238. * --------
  239. * Assumes that the display lists for the frame graphics are already
  240. * set up.
  241. *
  242. *************************************<->***********************************/
  243. void FrameExposureProc (ClientData *pcd)
  244. {
  245. GC topGC, botGC;
  246. Window win = pcd->clientFrameWin;
  247. /* use "active" GCs if we have keyboard focus */
  248. if (pcd == wmGD.keyboardFocus) {
  249. topGC = CLIENT_APPEARANCE(pcd).activeTopShadowGC;
  250. botGC = CLIENT_APPEARANCE(pcd).activeBottomShadowGC;
  251. }
  252. else {
  253. topGC = CLIENT_APPEARANCE(pcd).inactiveTopShadowGC;
  254. botGC = CLIENT_APPEARANCE(pcd).inactiveBottomShadowGC;
  255. }
  256. /* draw the frame decoration */
  257. if (pcd->pclientTopShadows) {
  258. XFillRectangles (DISPLAY,
  259. win,
  260. topGC,
  261. pcd->pclientTopShadows->prect,
  262. pcd->pclientTopShadows->used);
  263. }
  264. if (pcd->pclientBottomShadows) {
  265. XFillRectangles (DISPLAY,
  266. win,
  267. botGC,
  268. pcd->pclientBottomShadows->prect,
  269. pcd->pclientBottomShadows->used);
  270. }
  271. if (DECOUPLE_TITLE_APPEARANCE(pcd) &&
  272. (pcd->decor & MWM_DECOR_TITLE))
  273. {
  274. if (pcd == wmGD.keyboardFocus) {
  275. topGC = CLIENT_TITLE_APPEARANCE(pcd).activeTopShadowGC;
  276. botGC = CLIENT_TITLE_APPEARANCE(pcd).activeBottomShadowGC;
  277. }
  278. else {
  279. topGC = CLIENT_TITLE_APPEARANCE(pcd).inactiveTopShadowGC;
  280. botGC = CLIENT_TITLE_APPEARANCE(pcd).inactiveBottomShadowGC;
  281. }
  282. if (pcd->pclientTitleTopShadows) {
  283. XFillRectangles (DISPLAY,
  284. pcd->clientTitleWin,
  285. topGC,
  286. pcd->pclientTitleTopShadows->prect,
  287. pcd->pclientTitleTopShadows->used);
  288. }
  289. if (pcd->pclientTitleBottomShadows) {
  290. XFillRectangles (DISPLAY,
  291. pcd->clientTitleWin,
  292. botGC,
  293. pcd->pclientTitleBottomShadows->prect,
  294. pcd->pclientTitleBottomShadows->used);
  295. }
  296. }
  297. /* draw the title bar text */
  298. DrawWindowTitle(pcd, False);
  299. }
  300. /*************************************<->*************************************
  301. *
  302. * BaseWinExposureProc (pcd)
  303. *
  304. *
  305. * Description:
  306. * -----------
  307. * Repaint the beveled matte graphics if any.
  308. *
  309. *
  310. * Inputs:
  311. * ------
  312. * pcd - pointer to client data
  313. *
  314. *
  315. * Outputs:
  316. * -------
  317. * none
  318. *
  319. * Comments:
  320. * --------
  321. * Assumes that the display lists for the matte graphics are already
  322. * set up.
  323. *
  324. *************************************<->***********************************/
  325. void BaseWinExposureProc (ClientData *pcd)
  326. {
  327. /* bevel the matte (if there is one) */
  328. if (pcd->matteWidth > 0) {
  329. if (pcd->pclientMatteTopShadows) {
  330. XFillRectangles (DISPLAY,
  331. pcd->clientBaseWin,
  332. pcd->clientMatteTopShadowGC,
  333. pcd->pclientMatteTopShadows->prect,
  334. pcd->pclientMatteTopShadows->used);
  335. }
  336. if (pcd->pclientMatteBottomShadows) {
  337. XFillRectangles (DISPLAY,
  338. pcd->clientBaseWin,
  339. pcd->clientMatteBottomShadowGC,
  340. pcd->pclientMatteBottomShadows->prect,
  341. pcd->pclientMatteBottomShadows->used);
  342. }
  343. }
  344. }
  345. /*************************************<->*************************************
  346. *
  347. * ConstructFrame (pcd)
  348. *
  349. *
  350. * Description:
  351. * -----------
  352. * Construct the window hierarchy for the frame
  353. *
  354. *
  355. * Inputs:
  356. * ------
  357. * pcd - pointer to client data record
  358. *
  359. * Outputs:
  360. * -------
  361. * pcd - modified
  362. *
  363. *
  364. * Comments:
  365. * --------
  366. *
  367. *************************************<->***********************************/
  368. Boolean ConstructFrame (ClientData *pcd)
  369. {
  370. unsigned long decoration = pcd->decor;
  371. unsigned long attr_mask;
  372. XSetWindowAttributes window_attribs;
  373. int frmX, frmY;
  374. /* set frame information */
  375. SetFrameInfo (pcd);
  376. /* allocate space */
  377. if (!AllocateFrameDisplayLists(pcd)) {
  378. return(FALSE);
  379. }
  380. /* create frame window */
  381. attr_mask = CWEventMask;
  382. window_attribs.event_mask = (ButtonPressMask | ButtonReleaseMask |
  383. SELECT_BUTTON_MOTION_MASK |
  384. DMANIP_BUTTON_MOTION_MASK |
  385. ExposureMask);
  386. if ((wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_POINTER) ||
  387. (wmGD.colormapFocusPolicy == CMAP_FOCUS_POINTER))
  388. {
  389. window_attribs.event_mask |= EnterWindowMask | LeaveWindowMask;
  390. }
  391. /*
  392. * Use background pixmap if one is specified, otherwise set the
  393. * appropriate background color.
  394. */
  395. if (CLIENT_APPEARANCE(pcd).backgroundPixmap)
  396. {
  397. attr_mask |= CWBackPixmap;
  398. window_attribs.background_pixmap =
  399. CLIENT_APPEARANCE(pcd).backgroundPixmap;
  400. }
  401. else
  402. {
  403. attr_mask |= CWBackPixel;
  404. window_attribs.background_pixel = CLIENT_APPEARANCE(pcd).background;
  405. }
  406. attr_mask |= CWCursor;
  407. window_attribs.cursor = wmGD.workspaceCursor;
  408. frmY = pcd->frameInfo.y;
  409. frmX = pcd->frameInfo.x;
  410. if (CLIENT_APPEARANCE(pcd).saveUnder &&
  411. WmGetWindowAttributes (pcd->client) &&
  412. wmGD.windowAttributes.save_under)
  413. {
  414. attr_mask |= CWSaveUnder;
  415. window_attribs.save_under = True;
  416. }
  417. pcd->clientFrameWin = XCreateWindow(DISPLAY,
  418. RootWindow (DISPLAY,
  419. SCREEN_FOR_CLIENT(pcd)),
  420. frmX,
  421. frmY,
  422. pcd->frameInfo.width,
  423. pcd->frameInfo.height, 0,
  424. CopyFromParent,InputOutput,CopyFromParent,
  425. attr_mask, &window_attribs);
  426. /* create resizing windows with cursors*/
  427. if (SHOW_RESIZE_CURSORS(pcd) && (decoration & MWM_DECOR_RESIZEH)) {
  428. CreateStretcherWindows (pcd);
  429. }
  430. if (decoration & MWM_DECOR_TITLE) CreateTitleBarWindow (pcd);
  431. /* generate gadget position search structure */
  432. if (!AllocateGadgetRectangles (pcd))
  433. return(FALSE);
  434. ComputeGadgetRectangles (pcd);
  435. /*
  436. * Create base window for reparenting. Save rectangle data for use
  437. * in event dispatching.
  438. */
  439. window_attribs.event_mask = (SubstructureRedirectMask |
  440. SubstructureNotifyMask |
  441. FocusChangeMask);
  442. if (pcd->matteWidth > 0)
  443. {
  444. window_attribs.event_mask |= ExposureMask;
  445. window_attribs.background_pixel = pcd->matteBackground;
  446. }
  447. else
  448. {
  449. window_attribs.background_pixel =
  450. CLIENT_TITLE_APPEARANCE(pcd).background;
  451. }
  452. attr_mask = CWBackPixel | CWEventMask;
  453. pcd->clientBaseWin = XCreateWindow(DISPLAY, pcd->clientFrameWin,
  454. BaseWindowX (pcd),
  455. BaseWindowY (pcd),
  456. BaseWindowWidth (pcd),
  457. BaseWindowHeight (pcd),
  458. 0,
  459. CopyFromParent,InputOutput,CopyFromParent,
  460. attr_mask, &window_attribs);
  461. /* map all subwindows of client frame */
  462. XMapSubwindows(DISPLAY, pcd->clientFrameWin);
  463. return(TRUE);
  464. }
  465. /*************************************<->*************************************
  466. *
  467. * GenerateFrameDisplayLists (pcd)
  468. *
  469. *
  470. * Description:
  471. * -----------
  472. * Set up the graphic decorations for the frame
  473. *
  474. *
  475. * Inputs:
  476. * ------
  477. * pcd - pointer to client data record
  478. *
  479. *
  480. * Outputs:
  481. * -------
  482. * pcd - modified
  483. *
  484. *
  485. * Comments:
  486. * --------
  487. * o This must be called after ConstructFrame to insure that the memory
  488. * for the rectangles has been allocated.
  489. * o If cnum values for StretcherCorner change, also change
  490. * StretcherCorner() in WmGraphics.c
  491. * o The variable internalBevel sets the depth of shadowing from the
  492. * frame to the client area.
  493. * o The variable insideBevel is used to decide how deep the bevel is
  494. * immediately inside the frame. This may not be internalBevel if
  495. * there's a matte, for example.
  496. * o The variable diffBevel stores the difference between insideBevel
  497. * and what's needed so the bottom of the title bar is correctly
  498. * beveled down to the client.
  499. *
  500. *************************************<->***********************************/
  501. void GenerateFrameDisplayLists (ClientData *pcd)
  502. {
  503. unsigned long decoration = pcd->decor;
  504. int matte_width = pcd->matteWidth;
  505. int insideBevel, inset, diffBevel;
  506. unsigned int nTitleBevel, sTitleBevel, eTitleBevel, wTitleBevel;
  507. unsigned int meTitleBevel, inWidth;
  508. int x, y, xAdj = 0, yAdj = 0;
  509. unsigned int width, height;
  510. RList *prlTop = NULL, *prlBot = NULL;
  511. int jX, jY;
  512. unsigned int jW, jH;
  513. /* zero out part counts */
  514. if (pcd->pclientTopShadows)
  515. pcd->pclientTopShadows->used = 0;
  516. if (pcd->pclientBottomShadows)
  517. pcd->pclientBottomShadows->used = 0;
  518. if (pcd->pclientTitleTopShadows)
  519. pcd->pclientTitleTopShadows->used = 0;
  520. if (pcd->pclientTitleBottomShadows)
  521. pcd->pclientTitleBottomShadows->used = 0;
  522. if (pcd->pclientMatteTopShadows)
  523. pcd->pclientMatteTopShadows->used = 0;
  524. if (pcd->pclientMatteBottomShadows)
  525. pcd->pclientMatteBottomShadows->used = 0;
  526. /* adjust inside bevel of gadgetry if there's a matte */
  527. if ((wmGD.frameStyle == WmRECESSED) && (matte_width > 0))
  528. insideBevel = JOIN_BEVEL(pcd);
  529. else
  530. insideBevel = pcd->internalBevel;
  531. diffBevel = insideBevel - 1;
  532. if (decoration & MWM_DECOR_RESIZEH)
  533. {
  534. /* adjust part width/heights if no title bar */
  535. if ((pcd->internalBevel > 1) && !(decoration & MWM_DECOR_TITLE))
  536. {
  537. inset = 1;
  538. }
  539. else
  540. {
  541. inset = 0;
  542. }
  543. /*
  544. * Draw the stretchers. If the horizontal or vertical pieces
  545. * get "too small", then don't draw them at all.
  546. */
  547. GetFramePartInfo (pcd, FRAME_RESIZE_NW, &x, &y, &width, &height);
  548. StretcherCorner (pcd->pclientTopShadows, /* NW */
  549. pcd->pclientBottomShadows,
  550. x, y,
  551. STRETCH_NORTH_WEST,
  552. pcd->frameInfo.upperBorderWidth - inset,
  553. width, height);
  554. GetFramePartInfo (pcd, FRAME_RESIZE_N, &x, &y, &width, &height);
  555. if ((int)width > 0)
  556. BevelRectangle (pcd->pclientTopShadows, /* N */
  557. pcd->pclientBottomShadows,
  558. x, y,
  559. width, height - inset,
  560. 2, 1, ((wmGD.frameStyle == WmSLAB) ? 0 : 1), 1);
  561. GetFramePartInfo (pcd, FRAME_RESIZE_NE, &x, &y, &width, &height);
  562. StretcherCorner (pcd->pclientTopShadows,
  563. pcd->pclientBottomShadows,
  564. x, y,
  565. STRETCH_NORTH_EAST,
  566. pcd->frameInfo.upperBorderWidth - inset, width, height);
  567. GetFramePartInfo (pcd, FRAME_RESIZE_E, &x, &y, &width, &height);
  568. if ((int)height > 0)
  569. BevelRectangle (pcd->pclientTopShadows, /* E */
  570. pcd->pclientBottomShadows,
  571. x+diffBevel, y,
  572. width-diffBevel, height,
  573. 1, 2, 1, ((wmGD.frameStyle == WmSLAB) ? 0 : 1));
  574. GetFramePartInfo (pcd, FRAME_RESIZE_SE, &x, &y, &width, &height);
  575. StretcherCorner (pcd->pclientTopShadows, /* SE */
  576. pcd->pclientBottomShadows,
  577. x, y,
  578. STRETCH_SOUTH_EAST,
  579. pcd->frameInfo.upperBorderWidth-inset, width, height);
  580. GetFramePartInfo (pcd, FRAME_RESIZE_S, &x, &y, &width, &height);
  581. if ((int) width > 0)
  582. BevelRectangle (pcd->pclientTopShadows, /* S */
  583. pcd->pclientBottomShadows,
  584. x, y+diffBevel,
  585. width, height-diffBevel,
  586. ((wmGD.frameStyle == WmSLAB) ? 0 : 1), 1, 2, 1);
  587. GetFramePartInfo (pcd, FRAME_RESIZE_SW, &x, &y, &width, &height);
  588. StretcherCorner (pcd->pclientTopShadows, /* SW */
  589. pcd->pclientBottomShadows,
  590. x, y,
  591. STRETCH_SOUTH_WEST,
  592. pcd->frameInfo.upperBorderWidth-inset, width, height);
  593. GetFramePartInfo (pcd, FRAME_RESIZE_W, &x, &y, &width, &height);
  594. if ((int) height > 0)
  595. BevelRectangle (pcd->pclientTopShadows, /* W */
  596. pcd->pclientBottomShadows,
  597. x, y,
  598. width-diffBevel, height,
  599. 1, ((wmGD.frameStyle == WmSLAB) ? 0 : 1), 1, 2);
  600. if (diffBevel)
  601. {
  602. /*
  603. * Draw second inside bevel level. This goes just around the
  604. * client area under the title bar.
  605. */
  606. BevelRectangle (pcd->pclientBottomShadows, /* inside */
  607. pcd->pclientTopShadows,
  608. (int) (pcd->frameInfo.lowerBorderWidth-diffBevel),
  609. (int) (pcd->clientOffset.y - diffBevel),
  610. pcd->frameInfo.width -
  611. 2*pcd->frameInfo.lowerBorderWidth +
  612. 2*diffBevel,
  613. pcd->frameInfo.height - pcd->clientOffset.y -
  614. pcd->frameInfo.lowerBorderWidth +
  615. 2*diffBevel,
  616. (unsigned int) diffBevel, (unsigned int) diffBevel,
  617. (unsigned int) diffBevel, (unsigned int) diffBevel);
  618. }
  619. }
  620. else if (decoration & MWM_DECOR_BORDER)
  621. {
  622. /* produce default border with no resizing functions */
  623. BevelRectangle (pcd->pclientTopShadows, /* outside */
  624. pcd->pclientBottomShadows,
  625. 0, 0,
  626. pcd->frameInfo.width, pcd->frameInfo.height,
  627. FRAME_EXTERNAL_SHADOW_WIDTH,
  628. FRAME_EXTERNAL_SHADOW_WIDTH,
  629. FRAME_EXTERNAL_SHADOW_WIDTH,
  630. FRAME_EXTERNAL_SHADOW_WIDTH);
  631. if ((pcd->internalBevel > 1) &&
  632. !matte_width &&
  633. (decoration & MWM_DECOR_TITLE)) {
  634. /*
  635. * Need to do special beveling around the inside of the
  636. * client area separately from around title area.
  637. */
  638. GetFramePartInfo (pcd, FRAME_TITLE, &x, &y, &width, &height);
  639. inset = 1 + (pcd->frameInfo.lowerBorderWidth -
  640. pcd->frameInfo.upperBorderWidth);
  641. BevelRectangle (pcd->pclientBottomShadows,
  642. pcd->pclientTopShadows,
  643. (int) (pcd->frameInfo.lowerBorderWidth-inset),
  644. (int) (pcd->frameInfo.lowerBorderWidth-inset),
  645. pcd->frameInfo.width -
  646. 2*pcd->frameInfo.lowerBorderWidth + 2*inset,
  647. pcd->frameInfo.height -
  648. 2*pcd->frameInfo.lowerBorderWidth + 2*inset,
  649. 1, 1, 1, 1);
  650. BevelRectangle (pcd->pclientBottomShadows, /* inside */
  651. pcd->pclientTopShadows,
  652. (int) (pcd->frameInfo.lowerBorderWidth-diffBevel),
  653. pcd->clientOffset.y - diffBevel,
  654. pcd->frameInfo.width -
  655. 2*pcd->frameInfo.lowerBorderWidth +
  656. 2*diffBevel,
  657. pcd->frameInfo.height - pcd->clientOffset.y -
  658. pcd->frameInfo.lowerBorderWidth + 2*diffBevel,
  659. (unsigned int)diffBevel, (unsigned int)diffBevel,
  660. (unsigned int)diffBevel, (unsigned int)diffBevel);
  661. }
  662. else
  663. {
  664. if((pcd->dtwmBehaviors & DtWM_BEHAVIOR_PANEL) &&
  665. (pcd->clientDecoration == WM_DECOR_BORDER))
  666. {
  667. insideBevel = 0;
  668. }
  669. BevelRectangle (pcd->pclientBottomShadows, /* inside */
  670. pcd->pclientTopShadows,
  671. (int)(pcd->frameInfo.lowerBorderWidth-insideBevel),
  672. (int)(pcd->frameInfo.lowerBorderWidth-insideBevel),
  673. pcd->frameInfo.width -
  674. 2*pcd->frameInfo.lowerBorderWidth +
  675. 2*insideBevel,
  676. pcd->frameInfo.height -
  677. 2*pcd->frameInfo.lowerBorderWidth +
  678. 2*insideBevel,
  679. (unsigned int)insideBevel,
  680. (unsigned int)insideBevel,
  681. (unsigned int)insideBevel,
  682. (unsigned int)insideBevel);
  683. }
  684. }
  685. /* draw title bar */
  686. /*
  687. * set bevels for title bar and parts
  688. */
  689. if (decoration & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
  690. {
  691. nTitleBevel = JOIN_BEVEL(pcd); /* north side of title */
  692. if (wmGD.frameStyle == WmSLAB)
  693. {
  694. sTitleBevel = JOIN_BEVEL(pcd); /* south side of title */
  695. }
  696. else
  697. {
  698. sTitleBevel = insideBevel; /* south side of title */
  699. }
  700. eTitleBevel = JOIN_BEVEL(pcd); /* east side of title */
  701. wTitleBevel = JOIN_BEVEL(pcd); /* west side of title */
  702. meTitleBevel = JOIN_BEVEL(pcd); /* btw Minimize, Maximize */
  703. }
  704. else
  705. {
  706. /* borderless window */
  707. nTitleBevel = EXTERNAL_BEVEL(pcd);
  708. if (wmGD.frameStyle == WmSLAB)
  709. {
  710. sTitleBevel = (matte_width > 0) ? JOIN_BEVEL(pcd) :
  711. EXTERNAL_BEVEL(pcd);
  712. }
  713. else
  714. {
  715. sTitleBevel = (matte_width > 0) ? insideBevel : EXTERNAL_BEVEL(pcd);
  716. }
  717. eTitleBevel = (decoration & (MWM_DECOR_MINIMIZE | MWM_DECOR_MAXIMIZE))?
  718. JOIN_BEVEL(pcd) : EXTERNAL_BEVEL(pcd);
  719. wTitleBevel = (decoration & MWM_DECOR_MENU) ?
  720. JOIN_BEVEL(pcd) : EXTERNAL_BEVEL(pcd);
  721. /* beveling east of minimize */
  722. meTitleBevel = (decoration & (MWM_DECOR_MAXIMIZE)) ?
  723. JOIN_BEVEL(pcd) : EXTERNAL_BEVEL(pcd);
  724. }
  725. if (decoration & MWM_DECOR_TITLE)
  726. {
  727. /*
  728. * Use a different set of rectangles if title appearance
  729. * is different from the rest of the frame.
  730. */
  731. if (DECOUPLE_TITLE_APPEARANCE(pcd))
  732. {
  733. prlTop = pcd->pclientTitleTopShadows;
  734. prlBot = pcd->pclientTitleBottomShadows;
  735. xAdj = yAdj = pcd->frameInfo.upperBorderWidth;
  736. }
  737. else
  738. {
  739. prlTop = pcd->pclientTopShadows;
  740. prlBot = pcd->pclientBottomShadows;
  741. xAdj = yAdj = 0;
  742. }
  743. GetFramePartInfo (pcd, FRAME_TITLE, &x, &y, &width, &height);
  744. if (pcd->decorFlags & TITLE_DEPRESSED) {
  745. /* show depressed title gadget */
  746. GetDepressInfo (pcd, FRAME_TITLE, &jX, &jY, &jW, &jH,
  747. &inWidth);
  748. BevelDepressedRectangle (prlTop, prlBot,
  749. x-xAdj, y-yAdj, width, height,
  750. nTitleBevel, eTitleBevel,
  751. sTitleBevel, wTitleBevel, inWidth);
  752. }
  753. else {
  754. /* show normal title gadget */
  755. BevelRectangle (prlTop, prlBot,
  756. x-xAdj, y-yAdj, width, height,
  757. nTitleBevel, eTitleBevel,
  758. sTitleBevel, wTitleBevel);
  759. }
  760. }
  761. if (decoration & MWM_DECOR_MENU) {
  762. GetFramePartInfo (pcd, FRAME_SYSTEM, &x, &y, &width, &height);
  763. if (pcd->decorFlags & SYSTEM_DEPRESSED) {
  764. /* show depressed system gadget */
  765. GetDepressInfo (pcd, FRAME_SYSTEM, &jX, &jY, &jW, &jH,
  766. &inWidth);
  767. BevelDepressedRectangle (prlTop, prlBot,
  768. x-xAdj, y-yAdj, width, height,
  769. nTitleBevel, wTitleBevel,
  770. sTitleBevel, nTitleBevel, inWidth);
  771. }
  772. else
  773. {
  774. /* show normal system gadget */
  775. BevelRectangle (prlTop, prlBot,
  776. x-xAdj, y-yAdj, width, height,
  777. nTitleBevel, wTitleBevel,
  778. sTitleBevel, nTitleBevel);
  779. }
  780. /* system icon */
  781. BevelSystemButton (prlTop, prlBot,
  782. x-xAdj, y-yAdj, width, height);
  783. }
  784. if (decoration & MWM_DECOR_MINIMIZE) {
  785. GetFramePartInfo (pcd, FRAME_MINIMIZE, &x, &y, &width, &height);
  786. if (pcd->decorFlags & MINIMIZE_DEPRESSED) {
  787. /* show depressed minimize gadget */
  788. GetDepressInfo (pcd, FRAME_MINIMIZE, &jX, &jY, &jW, &jH,
  789. &inWidth);
  790. BevelDepressedRectangle (prlTop, prlBot,
  791. x-xAdj, y-yAdj, width, height,
  792. nTitleBevel, meTitleBevel,
  793. sTitleBevel, eTitleBevel, inWidth);
  794. }
  795. else {
  796. /* show normal minimize gadget */
  797. BevelRectangle (prlTop, prlBot,
  798. x-xAdj, y-yAdj, width, height,
  799. nTitleBevel, meTitleBevel,
  800. sTitleBevel, eTitleBevel);
  801. }
  802. BevelMinimizeButton(prlTop, /* minimize icon */
  803. prlBot,
  804. x-xAdj, y-yAdj, height);
  805. }
  806. if (decoration & MWM_DECOR_MAXIMIZE) {
  807. GetFramePartInfo (pcd, FRAME_MAXIMIZE, &x, &y, &width, &height);
  808. if (pcd->decorFlags & MAXIMIZE_DEPRESSED) {
  809. /* show depressed maximize gadget */
  810. GetDepressInfo (pcd, FRAME_MAXIMIZE, &jX, &jY, &jW, &jH,
  811. &inWidth);
  812. BevelDepressedRectangle (prlTop, prlBot,
  813. x-xAdj, y-yAdj, width, height,
  814. nTitleBevel, nTitleBevel,
  815. sTitleBevel, eTitleBevel, inWidth);
  816. }
  817. else {
  818. /* show normal maximize gadget */
  819. BevelRectangle (prlTop, prlBot,
  820. x-xAdj, y-yAdj, width, height,
  821. nTitleBevel, nTitleBevel,
  822. sTitleBevel, eTitleBevel);
  823. }
  824. /* maximize icon - in or out depending on client state */
  825. if (pcd->maxConfig) {
  826. BevelMaximizeButton(prlBot,
  827. prlTop,
  828. x-xAdj, y-yAdj, height);
  829. }
  830. else {
  831. BevelMaximizeButton(prlTop,
  832. prlBot,
  833. x-xAdj, y-yAdj, height);
  834. }
  835. }
  836. /* draw the client matte (this is in the base window!!!) */
  837. if (matte_width > 0) {
  838. unsigned int mWidth, mHeight, exMatteBevel, tMatteBevel;
  839. mWidth = BaseWindowWidth (pcd);
  840. mHeight = BaseWindowHeight (pcd);
  841. if (decoration & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
  842. {
  843. exMatteBevel = JOIN_BEVEL(pcd);
  844. tMatteBevel = JOIN_BEVEL(pcd);
  845. }
  846. else
  847. {
  848. exMatteBevel = EXTERNAL_BEVEL(pcd);
  849. tMatteBevel = (decoration & MWM_DECOR_TITLE) ?
  850. JOIN_BEVEL(pcd) : EXTERNAL_BEVEL(pcd);
  851. }
  852. /* set up beveling around the edges */
  853. BevelRectangle (pcd->pclientMatteTopShadows,
  854. pcd->pclientMatteBottomShadows,
  855. 0,
  856. 0,
  857. mWidth,
  858. mHeight,
  859. tMatteBevel, exMatteBevel,
  860. exMatteBevel, exMatteBevel);
  861. /* reversed beveling on inside rectange ! */
  862. BevelRectangle ( pcd->pclientMatteBottomShadows,
  863. pcd->pclientMatteTopShadows,
  864. matte_width - pcd->internalBevel,
  865. matte_width - pcd->internalBevel,
  866. mWidth - 2*matte_width + 2*pcd->internalBevel,
  867. mHeight - 2*matte_width + 2*pcd->internalBevel,
  868. (unsigned int) pcd->internalBevel,
  869. (unsigned int) pcd->internalBevel,
  870. (unsigned int) pcd->internalBevel,
  871. (unsigned int) pcd->internalBevel);
  872. }
  873. }
  874. /*************************************<->*************************************
  875. *
  876. * AdoptClient (pcd)
  877. *
  878. *
  879. * Description:
  880. * -----------
  881. * Reparent the client window to the window frame
  882. *
  883. *
  884. * Inputs:
  885. * ------
  886. * pcd - pointer to client data record
  887. *
  888. *
  889. * Outputs:
  890. * -------
  891. * None
  892. *
  893. *
  894. * Comments:
  895. * --------
  896. *
  897. *************************************<->***********************************/
  898. void AdoptClient (ClientData *pcd)
  899. {
  900. XWindowChanges windowChanges;
  901. unsigned int mask;
  902. /* Put the window in the window manager's save set */
  903. if (!(pcd->clientFlags & CLIENT_WM_CLIENTS))
  904. {
  905. XChangeSaveSet (DISPLAY, pcd->client, SetModeInsert);
  906. pcd->clientFlags |= CLIENT_IN_SAVE_SET;
  907. }
  908. /*
  909. * set window geometry to be consistent with what we believe
  910. */
  911. mask = CWWidth | CWHeight;
  912. windowChanges.width = pcd->clientWidth;
  913. windowChanges.height = pcd->clientHeight;
  914. /*
  915. * strip off previous window border if we're adding our own border
  916. * or matte
  917. */
  918. if ( (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER)) ||
  919. (pcd->matteWidth > 0) )
  920. {
  921. mask |= CWBorderWidth;
  922. windowChanges.border_width = 0;
  923. }
  924. XConfigureWindow (DISPLAY, pcd->client, mask, &windowChanges);
  925. /* shape our frame to match that of the client's window */
  926. if (wmGD.hasShape)
  927. {
  928. int xws, yws, xbs, ybs;
  929. unsigned wws, hws, wbs, hbs;
  930. int boundingShaped, clipShaped;
  931. XShapeSelectInput (DISPLAY, pcd->client, ShapeNotifyMask);
  932. XShapeQueryExtents (DISPLAY, pcd->client,
  933. &boundingShaped, &xws, &yws, &wws, &hws,
  934. &clipShaped, &xbs, &ybs, &wbs, &hbs);
  935. pcd->wShaped = boundingShaped;
  936. }
  937. /* reparent the window to the base window */
  938. XReparentWindow (DISPLAY, pcd->client, pcd->clientBaseWin,
  939. pcd->matteWidth,
  940. pcd->matteWidth);
  941. pcd->clientFlags |= CLIENT_REPARENTED;
  942. } /* END OF FUNCTION AdoptClient */
  943. /*************************************<->*************************************
  944. *
  945. * GetTextBox (pcd, pBox)
  946. *
  947. *
  948. * Description:
  949. * -----------
  950. * Gets the rectangle that the text should fit into in the title bar
  951. *
  952. *
  953. * Inputs:
  954. * ------
  955. * pcd - pointer to client data
  956. * pBox - pointer to an XRectangle structure that gets return data
  957. *
  958. * Outputs:
  959. * -------
  960. * pBox - data is returned here
  961. *
  962. * Comments:
  963. * --------
  964. *
  965. *************************************<->***********************************/
  966. void GetTextBox (ClientData *pcd, XRectangle *pBox)
  967. {
  968. int x,y;
  969. unsigned int width,height;
  970. #if defined(DT_LEFT_JUSTIFIED_TITLE)
  971. Dimension textWidth;
  972. Dimension offset;
  973. XmFontList fontList;
  974. #endif
  975. /* get size of title area */
  976. if (!GetFramePartInfo (pcd, FRAME_TITLE, &x, &y, &width, &height))
  977. {
  978. /* no title area !!! */
  979. pBox->x = 0;
  980. pBox->y = 0;
  981. pBox->width = 0;
  982. pBox->height = 0;
  983. return;
  984. }
  985. /* adjust for shadowing and allow for some padding around the edges */
  986. x += WM_TOP_TITLE_SHADOW + WM_TOP_TITLE_PADDING;
  987. y += WM_TOP_TITLE_SHADOW + WM_TOP_TITLE_PADDING;
  988. width -= WM_TOP_TITLE_SHADOW + WM_BOTTOM_TITLE_SHADOW +
  989. WM_TOP_TITLE_PADDING + WM_BOTTOM_TITLE_PADDING;
  990. height -= WM_TOP_TITLE_SHADOW + WM_BOTTOM_TITLE_SHADOW +
  991. WM_TOP_TITLE_PADDING + WM_BOTTOM_TITLE_PADDING;
  992. #ifdef DT_LEFT_JUSTIFIED_TITLE
  993. if (wmGD.frameStyle == WmSLAB)
  994. {
  995. /*
  996. * We left justify the title in this style.
  997. * To keep it a little neat, we offset the title from
  998. * the left edge just a little (half the title height).
  999. * See if we have room to do this.
  1000. */
  1001. if (DECOUPLE_TITLE_APPEARANCE(pcd))
  1002. fontList = CLIENT_TITLE_APPEARANCE(pcd).fontList;
  1003. else
  1004. fontList = CLIENT_APPEARANCE(pcd).fontList;
  1005. textWidth = XmStringWidth(fontList, CLIENT_DISPLAY_TITLE(pcd));
  1006. offset = TitleBarHeight(pcd)/2;
  1007. if ((textWidth + offset) <= width)
  1008. {
  1009. /* We have plenty of room, do the offset */
  1010. x += offset;
  1011. width -= offset;
  1012. }
  1013. else if ((short) (width - textWidth) > 0)
  1014. {
  1015. /* We don't have enough room to do our usual offset,
  1016. * but if we reduce the offset, the text won't get
  1017. * clipped.
  1018. */
  1019. offset = (width - textWidth) / 2;
  1020. x += offset;
  1021. width -= offset;
  1022. }
  1023. }
  1024. #endif /* DT_LEFT_JUSTIFIED_TITLE */
  1025. /* return position and size */
  1026. pBox->x = x;
  1027. pBox->y = y;
  1028. pBox->width = width;
  1029. pBox->height = height;
  1030. }
  1031. /*************************************<->*************************************
  1032. *
  1033. * DrawWindowTitle (pcd, eraseFirst)
  1034. *
  1035. *
  1036. * Description:
  1037. * -----------
  1038. * Overwrites or replaces the client's title text in the
  1039. * title bar of the frame.
  1040. *
  1041. *
  1042. * Inputs:
  1043. * ------
  1044. * pcd - pointer to client data
  1045. * eraseFirst - if true, then the old title is erased first
  1046. *
  1047. * Outputs:
  1048. * -------
  1049. * none
  1050. *
  1051. * Comments:
  1052. * --------
  1053. * o Assumes 8-bit text for now.
  1054. *
  1055. *
  1056. *************************************<->***********************************/
  1057. void DrawWindowTitle (ClientData *pcd, Boolean eraseFirst)
  1058. {
  1059. GC clientGC;
  1060. unsigned long decoration = pcd->decor;
  1061. XRectangle textBox;
  1062. Window win;
  1063. XmFontList fontList;
  1064. XmString title = CLIENT_DISPLAY_TITLE(pcd);
  1065. /* make sure there is a title bar first */
  1066. if (!(decoration & MWM_DECOR_TITLE))
  1067. return;
  1068. if (DECOUPLE_TITLE_APPEARANCE(pcd))
  1069. {
  1070. /* use "active" GC if we have keyboard focus */
  1071. if (pcd == wmGD.keyboardFocus) {
  1072. clientGC = CLIENT_TITLE_APPEARANCE(pcd).activeGC;
  1073. }
  1074. else {
  1075. clientGC = CLIENT_TITLE_APPEARANCE(pcd).inactiveGC;
  1076. }
  1077. /* get the area that the text must fit in */
  1078. GetTextBox (pcd, &textBox);
  1079. /* adjust position to be relative to titlebar window, not frame */
  1080. textBox.x -= (short) pcd->frameInfo.upperBorderWidth;
  1081. textBox.y -= (short) pcd->frameInfo.upperBorderWidth;
  1082. win = pcd->clientTitleWin;
  1083. fontList = CLIENT_TITLE_APPEARANCE(pcd).fontList;
  1084. }
  1085. else
  1086. {
  1087. /* use "active" GC if we have keyboard focus */
  1088. if (pcd == wmGD.keyboardFocus) {
  1089. clientGC = CLIENT_APPEARANCE(pcd).activeGC;
  1090. }
  1091. else {
  1092. clientGC = CLIENT_APPEARANCE(pcd).inactiveGC;
  1093. }
  1094. /* get the area that the text must fit in */
  1095. GetTextBox (pcd, &textBox);
  1096. win = pcd->clientFrameWin;
  1097. fontList = CLIENT_APPEARANCE(pcd).fontList;
  1098. }
  1099. if (eraseFirst)
  1100. {
  1101. XClearArea (DISPLAY, win, textBox.x, textBox.y,
  1102. (unsigned int) textBox.width, (unsigned int) textBox.height,
  1103. FALSE);
  1104. }
  1105. #ifdef DT_LEFT_JUSTIFIED_TITLE
  1106. WmDrawXmString(DISPLAY, win, fontList, title, clientGC,
  1107. textBox.x, textBox.y, textBox.width, &textBox,
  1108. ((wmGD.frameStyle == WmSLAB) ? False : True));
  1109. #else /* DT_LEFT_JUSTIFIED_TITLE */
  1110. WmDrawXmString(DISPLAY, win, fontList, title, clientGC,
  1111. textBox.x, textBox.y, textBox.width, &textBox,
  1112. True);
  1113. #endif /* DT_LEFT_JUSTIFIED_TITLE */
  1114. } /* END OF FUNCTION DrawWindowTitle */
  1115. /*************************************<->*************************************
  1116. *
  1117. * CreateStretcherWindows (pcd)
  1118. *
  1119. *
  1120. * Description:
  1121. * -----------
  1122. * Create the input-only windows that overlay the resize gadgets.
  1123. *
  1124. *
  1125. * Inputs:
  1126. * ------
  1127. * pcd - pointer to client data.
  1128. *
  1129. *
  1130. * Outputs:
  1131. * -------
  1132. * pcd - modified
  1133. *
  1134. * Return - none
  1135. *
  1136. *
  1137. * Comments:
  1138. * --------
  1139. * o The windows are sized based upon resizeBorderWidth
  1140. * o This should be called before creating the title bar,
  1141. * and reparenting window. Later windows should obscure parts of the
  1142. * stretchers.
  1143. * o The stretchers are given special cursors.
  1144. *
  1145. *************************************<->***********************************/
  1146. void CreateStretcherWindows (ClientData *pcd)
  1147. {
  1148. int iWin;
  1149. int x, y;
  1150. unsigned int width, height;
  1151. XSetWindowAttributes win_attribs;
  1152. unsigned long attr_mask;
  1153. for (iWin = 0; iWin < STRETCH_COUNT; iWin++) {
  1154. if (pcd->clientStretchWin[iWin]) continue;
  1155. switch (iWin) {
  1156. case STRETCH_NORTH_WEST:
  1157. GetFramePartInfo (pcd, FRAME_RESIZE_NW,
  1158. &x, &y, &width, &height);
  1159. break;
  1160. case STRETCH_NORTH:
  1161. GetFramePartInfo (pcd, FRAME_RESIZE_N,
  1162. &x, &y, &width, &height);
  1163. break;
  1164. case STRETCH_NORTH_EAST:
  1165. GetFramePartInfo (pcd, FRAME_RESIZE_NE,
  1166. &x, &y, &width, &height);
  1167. break;
  1168. case STRETCH_EAST:
  1169. GetFramePartInfo (pcd, FRAME_RESIZE_E,
  1170. &x, &y, &width, &height);
  1171. break;
  1172. case STRETCH_SOUTH_EAST:
  1173. GetFramePartInfo (pcd, FRAME_RESIZE_SE,
  1174. &x, &y, &width, &height);
  1175. break;
  1176. case STRETCH_SOUTH:
  1177. GetFramePartInfo (pcd, FRAME_RESIZE_S,
  1178. &x, &y, &width, &height);
  1179. break;
  1180. case STRETCH_SOUTH_WEST:
  1181. GetFramePartInfo (pcd, FRAME_RESIZE_SW,
  1182. &x, &y, &width, &height);
  1183. break;
  1184. case STRETCH_WEST:
  1185. GetFramePartInfo (pcd, FRAME_RESIZE_W,
  1186. &x, &y, &width, &height);
  1187. break;
  1188. }
  1189. attr_mask = CWCursor;
  1190. win_attribs.cursor = wmGD.stretchCursors[iWin];
  1191. pcd->clientStretchWin[iWin] =
  1192. XCreateWindow(DISPLAY, pcd->clientFrameWin,
  1193. x, y, width, height, 0, CopyFromParent,
  1194. InputOnly, CopyFromParent, attr_mask, &win_attribs);
  1195. }
  1196. } /* END OF FUNCTION CreateStretcherWindows */
  1197. /*************************************<->*************************************
  1198. *
  1199. * CountFrameRectangles (pSD)
  1200. *
  1201. *
  1202. * Description:
  1203. * -----------
  1204. * Computes the number of top and bottom shadow rectangles to allocate
  1205. * per frame.
  1206. *
  1207. * Inputs:
  1208. * ------
  1209. * pWS - pointer to workspace data
  1210. *
  1211. * Outputs:
  1212. * -------
  1213. *
  1214. * Comments:
  1215. * --------
  1216. *
  1217. *
  1218. *************************************<->***********************************/
  1219. void CountFrameRectangles (WmScreenData *pSD)
  1220. {
  1221. int i;
  1222. pSD->Num_Title_Ts_Elements = pSD->Num_Title_Bs_Elements = 0;
  1223. /* count up rectangles for title bar */
  1224. for (i = FRAME_SYSTEM; i <= FRAME_MAXIMIZE; i++)
  1225. {
  1226. pSD->Num_Title_Ts_Elements += ((Bevels[i].top.external *
  1227. pSD->externalBevel) +
  1228. (Bevels[i].top.internal * MAX_INTERNAL_BEVEL) +
  1229. (Bevels[i].top.join * pSD->joinBevel));
  1230. pSD->Num_Title_Bs_Elements += ((Bevels[i].bottom.external*
  1231. pSD->externalBevel)+
  1232. (Bevels[i].bottom.internal * MAX_INTERNAL_BEVEL) +
  1233. (Bevels[i].bottom.join * pSD->joinBevel));
  1234. }
  1235. pSD->Num_Resize_Ts_Elements = pSD->Num_Resize_Bs_Elements = 0;
  1236. /* count up rectangles for resize handles*/
  1237. for (i = FRAME_RESIZE_NW; i <= FRAME_RESIZE_W; i++)
  1238. {
  1239. pSD->Num_Resize_Ts_Elements += ((Bevels[i].top.external *
  1240. pSD->externalBevel) +
  1241. (Bevels[i].top.internal * MAX_INTERNAL_BEVEL) +
  1242. (Bevels[i].top.join * pSD->joinBevel));
  1243. pSD->Num_Resize_Bs_Elements += ((Bevels[i].bottom.external*
  1244. pSD->externalBevel)+
  1245. (Bevels[i].bottom.internal * MAX_INTERNAL_BEVEL) +
  1246. (Bevels[i].bottom.join * pSD->joinBevel));
  1247. }
  1248. } /* END OF FUNCTION CountFrameRectangles */
  1249. /*************************************<->*************************************
  1250. *
  1251. * AllocateFrameDisplayLists (pcd)
  1252. *
  1253. *
  1254. * Description:
  1255. * -----------
  1256. * Allocates memory for the graphic display lists for the frame.
  1257. *
  1258. *
  1259. * Inputs:
  1260. * ------
  1261. * pcd - pointer to the client data
  1262. *
  1263. *
  1264. * Outputs:
  1265. * -------
  1266. * pcd - fields modified
  1267. *
  1268. * Return - TRUE if successful, FALSE otherwise.
  1269. *
  1270. *
  1271. * Comments:
  1272. * --------
  1273. *
  1274. *
  1275. *************************************<->***********************************/
  1276. Boolean AllocateFrameDisplayLists (ClientData *pcd)
  1277. {
  1278. int frame_top_count, frame_bottom_count;
  1279. /*
  1280. * If the title bar has it's own appearance, then allocate
  1281. * separate display lists for it.
  1282. */
  1283. if (DECOUPLE_TITLE_APPEARANCE(pcd) &&
  1284. (pcd->decor & MWM_DECOR_TITLE))
  1285. {
  1286. if (((pcd->pclientTitleTopShadows =
  1287. AllocateRList ((unsigned)NUM_TITLE_TS_ELEMENTS(pcd))) == NULL) ||
  1288. ((pcd->pclientTitleBottomShadows =
  1289. AllocateRList ((unsigned)NUM_TITLE_BS_ELEMENTS(pcd))) == NULL))
  1290. {
  1291. /* out of memory! */
  1292. Warning (((char *)GETMESSAGE(8, 1, "Insufficient memory for client window framing")));
  1293. return(FALSE);
  1294. }
  1295. frame_top_count = NUM_RESIZE_TS_ELEMENTS(pcd);
  1296. frame_bottom_count = NUM_RESIZE_BS_ELEMENTS(pcd);
  1297. }
  1298. else
  1299. {
  1300. frame_top_count = NUM_RESIZE_TS_ELEMENTS(pcd) +
  1301. NUM_TITLE_TS_ELEMENTS(pcd);
  1302. frame_bottom_count = NUM_RESIZE_BS_ELEMENTS(pcd) +
  1303. NUM_RESIZE_BS_ELEMENTS(pcd);
  1304. }
  1305. /*
  1306. * Allocate the primary lists for the frame
  1307. */
  1308. if ( (pcd->pclientTopShadows == NULL) &&
  1309. ((pcd->pclientTopShadows =
  1310. AllocateRList ((unsigned)frame_top_count)) == NULL) )
  1311. {
  1312. /* out of memory! */
  1313. Warning (((char *)GETMESSAGE(8, 2, "Insufficient memory for client window framing")));
  1314. return(FALSE);
  1315. }
  1316. if ( (pcd->pclientBottomShadows == NULL) &&
  1317. ((pcd->pclientBottomShadows =
  1318. AllocateRList ((unsigned)frame_bottom_count)) == NULL) )
  1319. {
  1320. /* out of memory! */
  1321. Warning (((char *)GETMESSAGE(8, 3, "Insufficient memory for client window framing")));
  1322. return(FALSE);
  1323. }
  1324. /*
  1325. * Only allocate matte lists if there is a matte.
  1326. */
  1327. if ( (pcd->matteWidth) &&
  1328. (pcd->pclientMatteTopShadows == NULL) &&
  1329. ((pcd->pclientMatteTopShadows =
  1330. AllocateRList ((unsigned)NUM_MATTE_TS_RECTS)) == NULL))
  1331. {
  1332. /* out of memory! */
  1333. Warning (((char *)GETMESSAGE(8, 4, "Insufficient memory for client window framing")));
  1334. return(FALSE);
  1335. }
  1336. if ( (pcd->matteWidth) &&
  1337. (pcd->pclientMatteBottomShadows == NULL) &&
  1338. ((pcd->pclientMatteBottomShadows =
  1339. AllocateRList ((unsigned)NUM_MATTE_BS_RECTS)) == NULL))
  1340. {
  1341. /* out of memory! */
  1342. Warning (((char *)GETMESSAGE(8, 5, "Insufficient memory for client window framing")));
  1343. return(FALSE);
  1344. }
  1345. return(TRUE);
  1346. } /* END OF FUNCTION AllocateFrameDisplayLists */
  1347. /*************************************<->*************************************
  1348. *
  1349. * InitClientDecoration (pSD)
  1350. *
  1351. *
  1352. * Description:
  1353. * -----------
  1354. * Initializes client decoration routines
  1355. *
  1356. *
  1357. * Inputs:
  1358. * ------
  1359. * pSD - pointer to screen data
  1360. *
  1361. * Outputs:
  1362. * -------
  1363. *
  1364. *
  1365. * Comments:
  1366. * --------
  1367. * This must be called once before decorating any client frames.
  1368. *************************************<->***********************************/
  1369. void InitClientDecoration (WmScreenData *pSD)
  1370. {
  1371. CountFrameRectangles(pSD);
  1372. } /* END OF FUNCTION InitClientDecoration */
  1373. /*************************************<->*************************************
  1374. *
  1375. * AllocateGadgetRectangles (pcd)
  1376. *
  1377. *
  1378. * Description:
  1379. * -----------
  1380. * Allocate the memory for event rectangles structures.
  1381. *
  1382. *
  1383. * Inputs:
  1384. * ------
  1385. * pcd - pointer to client data structure
  1386. *
  1387. * Outputs:
  1388. * -------
  1389. * pcd - modified
  1390. *
  1391. *
  1392. * Comments:
  1393. * --------
  1394. *
  1395. *************************************<->***********************************/
  1396. Boolean AllocateGadgetRectangles (ClientData *pcd)
  1397. {
  1398. int num_rects;
  1399. unsigned long decor = pcd->decor;
  1400. GadgetRectangle *pgr;
  1401. if (decor & MWM_DECOR_TITLE) {
  1402. /* count how many rectangles to allocate for titlebar */
  1403. num_rects = 1;
  1404. if (decor & MWM_DECOR_MENU) num_rects += 1;
  1405. if (decor & MWM_DECOR_MINIMIZE) num_rects += 1;
  1406. if (decor & MWM_DECOR_MAXIMIZE) num_rects += 1;
  1407. /* allocate memory if no memory is allocated */
  1408. if ( pcd->pTitleGadgets == NULL) {
  1409. /* allocate memory for these guys */
  1410. pgr = (GadgetRectangle *)
  1411. XtMalloc (num_rects * sizeof(GadgetRectangle));
  1412. if (pgr == NULL)
  1413. {
  1414. /* out of memory! */
  1415. Warning (((char *)GETMESSAGE(8, 6, "Insufficient memory for client window framing")));
  1416. return (FALSE);
  1417. }
  1418. /* update client data */
  1419. pcd->pTitleGadgets = pgr;
  1420. pcd->cTitleGadgets = 0;
  1421. }
  1422. }
  1423. if (decor & MWM_DECOR_RESIZEH) {
  1424. /* allocate memory if no memory is allocated */
  1425. if ( pcd->pResizeGadgets == NULL) {
  1426. /* allocate memory for these guys */
  1427. pgr = (GadgetRectangle *)
  1428. XtMalloc (STRETCH_COUNT * sizeof(GadgetRectangle));
  1429. if (pgr == NULL)
  1430. {
  1431. /* out of memory! */
  1432. Warning (((char *)GETMESSAGE(8, 7, "Insufficient memory for client window framing")));
  1433. return (FALSE);
  1434. }
  1435. /* update client data */
  1436. pcd->pResizeGadgets = pgr;
  1437. }
  1438. }
  1439. return(TRUE);
  1440. } /* END OF FUNCTION AllocateGadgetRectangles */
  1441. /*************************************<->*************************************
  1442. *
  1443. * ComputeGadgetRectangles (pcd)
  1444. *
  1445. *
  1446. * Description:
  1447. * -----------
  1448. * Creates the event rectangles structures to aid in identifying
  1449. * frame parts when events come in
  1450. *
  1451. *
  1452. * Inputs:
  1453. * ------
  1454. * pcd - pointer to client data structure
  1455. *
  1456. * Outputs:
  1457. * -------
  1458. * pcd - modified
  1459. *
  1460. *
  1461. * Comments:
  1462. * --------
  1463. * o assumes gadget rectangles are already allocated.
  1464. *
  1465. *************************************<->***********************************/
  1466. void ComputeGadgetRectangles (ClientData *pcd)
  1467. {
  1468. unsigned long decor = pcd->decor;
  1469. GadgetRectangle *pgr;
  1470. int fpX, fpY;
  1471. unsigned int fpWidth, fpHeight;
  1472. int igr;
  1473. int clientWidth = (pcd->maxConfig) ? pcd->maxWidth : pcd->clientWidth;
  1474. /* title bar */
  1475. if (decor & MWM_DECOR_TITLE) {
  1476. if ( (pgr = pcd->pTitleGadgets) == NULL) {
  1477. return; /* nothing there !!! */
  1478. }
  1479. /* do title rectangle */
  1480. pcd->titleRectangle.x = pcd->frameInfo.upperBorderWidth;
  1481. pcd->titleRectangle.y = pcd->frameInfo.upperBorderWidth;
  1482. /*
  1483. * Fixed bug where last button in title bar did not activate when
  1484. * the client's X border was showing.
  1485. */
  1486. pcd->titleRectangle.width = clientWidth +
  1487. (XBorderIsShowing(pcd) ? 2*pcd->xBorderWidth : 2*pcd->matteWidth);
  1488. pcd->titleRectangle.height = pcd->frameInfo.titleBarHeight;
  1489. /* fill in title bar rectangles */
  1490. igr = 0;
  1491. pgr[igr].id = FRAME_TITLE;
  1492. GetFramePartInfo (pcd, FRAME_TITLE, &fpX, &fpY, &fpWidth, &fpHeight);
  1493. /* copy in and convert to shorts */
  1494. pgr[igr].rect.x = fpX;
  1495. pgr[igr].rect.y = fpY;
  1496. pgr[igr].rect.width = fpWidth;
  1497. pgr[igr].rect.height = fpHeight;
  1498. igr += 1;
  1499. if (decor & MWM_DECOR_MENU) {
  1500. pgr[igr].id = FRAME_SYSTEM;
  1501. GetFramePartInfo (pcd, FRAME_SYSTEM, &fpX, &fpY, &fpWidth,
  1502. &fpHeight);
  1503. /* copy in and convert to shorts */
  1504. pgr[igr].rect.x = fpX;
  1505. pgr[igr].rect.y = fpY;
  1506. pgr[igr].rect.width = fpWidth;
  1507. pgr[igr].rect.height = fpHeight;
  1508. igr += 1;
  1509. }
  1510. if (decor & MWM_DECOR_MINIMIZE) {
  1511. pgr[igr].id = FRAME_MINIMIZE;
  1512. GetFramePartInfo (pcd, FRAME_MINIMIZE,
  1513. &fpX, &fpY, &fpWidth, &fpHeight);
  1514. /* copy in and convert to shorts */
  1515. pgr[igr].rect.x = fpX;
  1516. pgr[igr].rect.y = fpY;
  1517. pgr[igr].rect.width = fpWidth;
  1518. pgr[igr].rect.height = fpHeight;
  1519. igr += 1;
  1520. }
  1521. if (decor & MWM_DECOR_MAXIMIZE) {
  1522. pgr[igr].id = FRAME_MAXIMIZE;
  1523. GetFramePartInfo (pcd, FRAME_MAXIMIZE,
  1524. &fpX, &fpY, &fpWidth, &fpHeight);
  1525. /* copy in and convert to shorts */
  1526. pgr[igr].rect.x = fpX;
  1527. pgr[igr].rect.y = fpY;
  1528. pgr[igr].rect.width = fpWidth;
  1529. pgr[igr].rect.height = fpHeight;
  1530. igr += 1;
  1531. }
  1532. /* update client data */
  1533. pcd->pTitleGadgets = pgr;
  1534. pcd->cTitleGadgets = igr;
  1535. }
  1536. /* client matte area (actually base window area) */
  1537. if (decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
  1538. {
  1539. pcd->matteRectangle.x = pcd->frameInfo.lowerBorderWidth;
  1540. pcd->matteRectangle.y = pcd->frameInfo.upperBorderWidth +
  1541. pcd->frameInfo.titleBarHeight;
  1542. pcd->matteRectangle.width = pcd->frameInfo.width -
  1543. (2 * pcd->frameInfo.lowerBorderWidth);
  1544. pcd->matteRectangle.height = pcd->frameInfo.height -
  1545. pcd->frameInfo.upperBorderWidth -
  1546. pcd->frameInfo.lowerBorderWidth -
  1547. pcd->frameInfo.titleBarHeight;
  1548. }
  1549. else
  1550. {
  1551. pcd->matteRectangle.x = 0;
  1552. pcd->matteRectangle.y = pcd->frameInfo.titleBarHeight;
  1553. pcd->matteRectangle.width = pcd->frameInfo.width;
  1554. pcd->matteRectangle.height = pcd->frameInfo.height -
  1555. pcd->frameInfo.titleBarHeight;
  1556. }
  1557. if (decor & MWM_DECOR_RESIZEH) {
  1558. if ( (pgr = pcd->pResizeGadgets) == NULL) {
  1559. return; /* nothing there !!! */
  1560. }
  1561. /* fill in resize rectangles */
  1562. igr = 0;
  1563. if (decor & MWM_DECOR_RESIZEH) {
  1564. pgr[igr].id = FRAME_RESIZE_NW;
  1565. GetFramePartInfo (pcd, FRAME_RESIZE_NW,
  1566. &fpX, &fpY, &fpWidth, &fpHeight);
  1567. /* copy in and convert to shorts */
  1568. pgr[igr].rect.x = fpX;
  1569. pgr[igr].rect.y = fpY;
  1570. pgr[igr].rect.width = fpWidth;
  1571. pgr[igr].rect.height = fpHeight;
  1572. igr += 1;
  1573. pgr[igr].id = FRAME_RESIZE_N;
  1574. GetFramePartInfo (pcd, FRAME_RESIZE_N,
  1575. &fpX, &fpY, &fpWidth, &fpHeight);
  1576. if ((int) fpWidth > 0) {
  1577. /* copy in and convert to shorts */
  1578. pgr[igr].rect.x = fpX;
  1579. pgr[igr].rect.y = fpY;
  1580. pgr[igr].rect.width = fpWidth;
  1581. pgr[igr].rect.height = fpHeight;
  1582. igr += 1;
  1583. }
  1584. pgr[igr].id = FRAME_RESIZE_NE;
  1585. GetFramePartInfo (pcd, FRAME_RESIZE_NE,
  1586. &fpX, &fpY, &fpWidth, &fpHeight);
  1587. /* copy in and convert to shorts */
  1588. pgr[igr].rect.x = fpX;
  1589. pgr[igr].rect.y = fpY;
  1590. pgr[igr].rect.width = fpWidth;
  1591. pgr[igr].rect.height = fpHeight;
  1592. igr += 1;
  1593. pgr[igr].id = FRAME_RESIZE_W;
  1594. GetFramePartInfo (pcd, FRAME_RESIZE_W,
  1595. &fpX, &fpY, &fpWidth, &fpHeight);
  1596. if ((int)fpHeight > 0) {
  1597. /* copy in and convert to shorts */
  1598. pgr[igr].rect.x = fpX;
  1599. pgr[igr].rect.y = fpY;
  1600. pgr[igr].rect.width = fpWidth;
  1601. pgr[igr].rect.height = fpHeight;
  1602. igr += 1;
  1603. }
  1604. pgr[igr].id = FRAME_RESIZE_E;
  1605. GetFramePartInfo (pcd, FRAME_RESIZE_E,
  1606. &fpX, &fpY, &fpWidth, &fpHeight);
  1607. if ((int) fpHeight > 0) {
  1608. /* copy in and convert to shorts */
  1609. pgr[igr].rect.x = fpX;
  1610. pgr[igr].rect.y = fpY;
  1611. pgr[igr].rect.width = fpWidth;
  1612. pgr[igr].rect.height = fpHeight;
  1613. igr += 1;
  1614. }
  1615. pgr[igr].id = FRAME_RESIZE_SW;
  1616. GetFramePartInfo (pcd, FRAME_RESIZE_SW,
  1617. &fpX, &fpY, &fpWidth, &fpHeight);
  1618. /* copy in and convert to shorts */
  1619. pgr[igr].rect.x = fpX;
  1620. pgr[igr].rect.y = fpY;
  1621. pgr[igr].rect.width = fpWidth;
  1622. pgr[igr].rect.height = fpHeight;
  1623. igr += 1;
  1624. pgr[igr].id = FRAME_RESIZE_S;
  1625. GetFramePartInfo (pcd, FRAME_RESIZE_S,
  1626. &fpX, &fpY, &fpWidth, &fpHeight);
  1627. if ((int) fpWidth > 0) {
  1628. /* copy in and convert to shorts */
  1629. pgr[igr].rect.x = fpX;
  1630. pgr[igr].rect.y = fpY;
  1631. pgr[igr].rect.width = fpWidth;
  1632. pgr[igr].rect.height = fpHeight;
  1633. igr += 1;
  1634. }
  1635. pgr[igr].id = FRAME_RESIZE_SE;
  1636. GetFramePartInfo (pcd, FRAME_RESIZE_SE,
  1637. &fpX, &fpY, &fpWidth, &fpHeight);
  1638. /* copy in and convert to shorts */
  1639. pgr[igr].rect.x = fpX;
  1640. pgr[igr].rect.y = fpY;
  1641. pgr[igr].rect.width = fpWidth;
  1642. pgr[igr].rect.height = fpHeight;
  1643. }
  1644. /* update client data */
  1645. pcd->pResizeGadgets = pgr;
  1646. }
  1647. } /* END OF FUNCTION ComputeGadgetRectangles */
  1648. /*************************************<->*************************************
  1649. *
  1650. * GetSystemMenuPosition (pcd, px, py, height, context)
  1651. *
  1652. *
  1653. * Description:
  1654. * -----------
  1655. * Returns the position of where the system menu should be popped up.
  1656. * The hotspotRectangle in global is also set up to match the icon or
  1657. * system menu button area.
  1658. *
  1659. *
  1660. * Inputs:
  1661. * ------
  1662. * pcd = pointer to client data
  1663. *
  1664. * px = pointer to x location
  1665. *
  1666. * py = pointer to y location
  1667. *
  1668. * height = height of the system menu
  1669. *
  1670. * context = context that the menu is to be posted under.
  1671. *
  1672. *
  1673. * Outputs:
  1674. * -------
  1675. * *px = x location
  1676. *
  1677. * *py = y location
  1678. *
  1679. * wmGD.hotspotRectangle = system menu button or icon area (root relative)
  1680. *
  1681. *************************************<->***********************************/
  1682. void GetSystemMenuPosition (ClientData *pcd, int *px, int *py,
  1683. unsigned int height, Context context)
  1684. {
  1685. if ((pcd->clientState == MINIMIZED_STATE) ||
  1686. ((pcd->clientState != MINIMIZED_STATE) &&
  1687. (context == F_SUBCONTEXT_IB_WICON)))
  1688. {
  1689. /*
  1690. * Try to put the menu directly above the icon.
  1691. * If it would hit the top of the screen then try to put it below
  1692. * the icon and label.
  1693. * If it would then hit the bottom of the screen turn of the hotspot
  1694. * processing.
  1695. */
  1696. if (pcd->pSD->useIconBox && P_ICON_BOX(pcd))
  1697. {
  1698. GetIconBoxIconRootXY (pcd, px, py);
  1699. wmGD.hotspotRectangle.x = *px;
  1700. wmGD.hotspotRectangle.y = *py;
  1701. *py -= height;
  1702. if (*py < 0)
  1703. {
  1704. *py += height + ICON_HEIGHT(pcd);
  1705. if (*py + height >= DisplayHeight (DISPLAY,
  1706. SCREEN_FOR_CLIENT(pcd)))
  1707. {
  1708. wmGD.checkHotspot = FALSE;
  1709. }
  1710. }
  1711. }
  1712. else
  1713. {
  1714. *px = ICON_X(pcd);
  1715. *py = ICON_Y(pcd) - height;
  1716. if (*py < 0)
  1717. {
  1718. *py = ICON_Y(pcd) + ICON_HEIGHT(pcd);
  1719. if (*py + height >= DisplayHeight (DISPLAY,
  1720. SCREEN_FOR_CLIENT(pcd)))
  1721. {
  1722. wmGD.checkHotspot = FALSE;
  1723. }
  1724. }
  1725. wmGD.hotspotRectangle.x = ICON_X(pcd);
  1726. wmGD.hotspotRectangle.y = ICON_Y(pcd);
  1727. }
  1728. /* setup the hotspot rectangle data */
  1729. wmGD.hotspotRectangle.width = ICON_WIDTH(pcd);
  1730. wmGD.hotspotRectangle.height = ICON_HEIGHT(pcd);
  1731. }
  1732. else
  1733. {
  1734. /*
  1735. * Try to put the menu directly below the SW corner of the
  1736. * titlebar/border.
  1737. * If it would hit the bottom of the screen then try to put it directly
  1738. * above the NW corner of the titlebar/border.
  1739. * If it would then hit the top of the screen turn of the hotspot
  1740. * processing.
  1741. */
  1742. if ((pcd->decor & MWM_DECOR_TITLE) &&
  1743. !(pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER)))
  1744. {
  1745. *px = pcd->frameInfo.x;
  1746. *py = pcd->frameInfo.y + pcd->frameInfo.titleBarHeight;
  1747. }
  1748. else
  1749. {
  1750. *px = pcd->frameInfo.x + pcd->frameInfo.lowerBorderWidth;
  1751. *py = pcd->frameInfo.y + pcd->frameInfo.upperBorderWidth +
  1752. pcd->frameInfo.titleBarHeight;
  1753. }
  1754. if (*py + height >= DisplayHeight (DISPLAY,
  1755. SCREEN_FOR_CLIENT(pcd)))
  1756. {
  1757. if ((pcd->decor & MWM_DECOR_TITLE) &&
  1758. !(pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER)))
  1759. {
  1760. *py = pcd->frameInfo.y - height;
  1761. }
  1762. else
  1763. {
  1764. *py = pcd->frameInfo.y + pcd->frameInfo.upperBorderWidth -
  1765. height;
  1766. }
  1767. if (*py < 0)
  1768. {
  1769. wmGD.checkHotspot = FALSE;
  1770. }
  1771. }
  1772. /* setup the hotspot rectangle data */
  1773. wmGD.hotspotRectangle.x = pcd->frameInfo.x +
  1774. pcd->frameInfo.lowerBorderWidth;
  1775. wmGD.hotspotRectangle.y = pcd->frameInfo.y +
  1776. pcd->frameInfo.upperBorderWidth;
  1777. /* assume square button */
  1778. wmGD.hotspotRectangle.width = pcd->frameInfo.titleBarHeight;
  1779. wmGD.hotspotRectangle.height = pcd->frameInfo.titleBarHeight;
  1780. }
  1781. } /* END OF FUNCTION GetSystemMenuPosition */
  1782. /*************************************<->*************************************
  1783. *
  1784. * ShowActiveClientFrame (pcd)
  1785. *
  1786. *
  1787. * Description:
  1788. * -----------
  1789. * Paint the frame to indicate an "active" window
  1790. *
  1791. *
  1792. * Inputs:
  1793. * ------
  1794. * pcd - pointer to client data
  1795. *
  1796. *
  1797. * Outputs:
  1798. * -------
  1799. *
  1800. *
  1801. * Comments:
  1802. * --------
  1803. * o This calls the frame exposure procedure, which gets some GCs based
  1804. * on the current keyboard focus. Thus, wmGD.keyboardFocus == pcd
  1805. * must be TRUE when this is called for the correct highlighting to
  1806. * occur.
  1807. *
  1808. *************************************<->***********************************/
  1809. void
  1810. ShowActiveClientFrame (ClientData *pcd)
  1811. {
  1812. unsigned long attr_mask = 0;
  1813. XSetWindowAttributes window_attribs;
  1814. if (DECOUPLE_TITLE_APPEARANCE(pcd) &&
  1815. (pcd->decor & MWM_DECOR_TITLE))
  1816. {
  1817. /*
  1818. * Use background pixmap if one is specified, otherwise set the
  1819. * appropriate background color.
  1820. */
  1821. if (CLIENT_TITLE_APPEARANCE(pcd).activeBackgroundPixmap)
  1822. {
  1823. attr_mask |= CWBackPixmap;
  1824. window_attribs.background_pixmap =
  1825. CLIENT_TITLE_APPEARANCE(pcd).activeBackgroundPixmap;
  1826. }
  1827. else
  1828. {
  1829. attr_mask |= CWBackPixel;
  1830. window_attribs.background_pixel =
  1831. CLIENT_TITLE_APPEARANCE(pcd).activeBackground;
  1832. }
  1833. XChangeWindowAttributes (DISPLAY, pcd->clientTitleWin, attr_mask,
  1834. &window_attribs);
  1835. /* clear the frame to the right background */
  1836. XClearWindow (DISPLAY, pcd->clientTitleWin);
  1837. }
  1838. /*
  1839. * Use background pixmap if one is specified, otherwise set the
  1840. * appropriate background color.
  1841. */
  1842. if (CLIENT_APPEARANCE(pcd).activeBackgroundPixmap)
  1843. {
  1844. attr_mask |= CWBackPixmap;
  1845. window_attribs.background_pixmap =
  1846. CLIENT_APPEARANCE(pcd).activeBackgroundPixmap;
  1847. }
  1848. else
  1849. {
  1850. attr_mask |= CWBackPixel;
  1851. window_attribs.background_pixel =
  1852. CLIENT_APPEARANCE(pcd).activeBackground;
  1853. }
  1854. XChangeWindowAttributes (DISPLAY, pcd->clientFrameWin, attr_mask,
  1855. &window_attribs);
  1856. /* clear the frame to the right background */
  1857. XClearWindow (DISPLAY, pcd->clientFrameWin);
  1858. /* simulate exposure of window */
  1859. FrameExposureProc (pcd);
  1860. } /* END OF FUNCTION ShowActiveClient */
  1861. /*************************************<->*************************************
  1862. *
  1863. * ShowInactiveClientFrame (pcd)
  1864. *
  1865. *
  1866. * Description:
  1867. * -----------
  1868. * Paint the frame to indicate an "inactive" window
  1869. *
  1870. *
  1871. * Inputs:
  1872. * ------
  1873. * pcd - pointer to client data
  1874. *
  1875. *
  1876. * Outputs:
  1877. * -------
  1878. *
  1879. *
  1880. * Comments:
  1881. * --------
  1882. * o This calls the frame exposure procedure, which gets some GCs based
  1883. * on the current keyboard focus. Thus, wmGD.keyboardFocus == pcd
  1884. * must be FALSE when this is called for the correct highlighting to
  1885. * occur.
  1886. *
  1887. *
  1888. ******************************<->***********************************/
  1889. void
  1890. ShowInactiveClientFrame (ClientData *pcd)
  1891. {
  1892. unsigned long attr_mask = 0;
  1893. XSetWindowAttributes window_attribs;
  1894. if (DECOUPLE_TITLE_APPEARANCE(pcd) &&
  1895. (pcd->decor & MWM_DECOR_TITLE))
  1896. {
  1897. /*
  1898. * Use background pixmap if one is specified, otherwise set the
  1899. * appropriate background color.
  1900. */
  1901. if (CLIENT_TITLE_APPEARANCE(pcd).backgroundPixmap)
  1902. {
  1903. attr_mask |= CWBackPixmap;
  1904. window_attribs.background_pixmap =
  1905. CLIENT_TITLE_APPEARANCE(pcd).backgroundPixmap;
  1906. }
  1907. else
  1908. {
  1909. attr_mask |= CWBackPixel;
  1910. window_attribs.background_pixel =
  1911. CLIENT_TITLE_APPEARANCE(pcd).background;
  1912. }
  1913. XChangeWindowAttributes (DISPLAY, pcd->clientTitleWin, attr_mask,
  1914. &window_attribs);
  1915. /* clear the frame to the right background */
  1916. XClearWindow (DISPLAY, pcd->clientTitleWin);
  1917. /*
  1918. * attr_mask must be cleared because it is set if
  1919. * DECOUPLE_TITLE_APPEARANCE(pcd) is true.
  1920. */
  1921. attr_mask = 0;
  1922. }
  1923. /*
  1924. * Use background pixmap if one is specified, otherwise set the
  1925. * appropriate background color.
  1926. */
  1927. if (CLIENT_APPEARANCE(pcd).backgroundPixmap)
  1928. {
  1929. attr_mask |= CWBackPixmap;
  1930. window_attribs.background_pixmap =
  1931. CLIENT_APPEARANCE(pcd).backgroundPixmap;
  1932. }
  1933. else
  1934. {
  1935. attr_mask |= CWBackPixel;
  1936. window_attribs.background_pixel =
  1937. CLIENT_APPEARANCE(pcd).background;
  1938. }
  1939. /* change window attribs so clear does the right thing */
  1940. XChangeWindowAttributes (DISPLAY, pcd->clientFrameWin, attr_mask,
  1941. &window_attribs);
  1942. /* clear the frame to the right background */
  1943. XClearWindow (DISPLAY, pcd->clientFrameWin);
  1944. /* simulate exposure of window */
  1945. FrameExposureProc (pcd);
  1946. } /* END OF FUNCTION ShowInactiveClientFrame */
  1947. /*************************************<->*************************************
  1948. *
  1949. * RegenerateClientFrame (pcd)
  1950. *
  1951. *
  1952. * Description:
  1953. * -----------
  1954. * Reconfigure the sizes of all the components of the client frame
  1955. *
  1956. *
  1957. * Inputs:
  1958. * ------
  1959. * pcd - pointer to client data
  1960. *
  1961. *
  1962. * Outputs:
  1963. * -------
  1964. *
  1965. * Comments:
  1966. * --------
  1967. *
  1968. *
  1969. *************************************<->***********************************/
  1970. void RegenerateClientFrame (ClientData *pcd)
  1971. {
  1972. unsigned long decor = pcd->decor;
  1973. /*
  1974. * If an embedded client, there is no frame.
  1975. */
  1976. if (pcd->pECD)
  1977. {
  1978. if (!pcd->clientFrameWin)
  1979. {
  1980. return;
  1981. }
  1982. }
  1983. /* recompute frame information */
  1984. SetFrameInfo (pcd);
  1985. /* move & resize frame window */
  1986. XMoveResizeWindow (DISPLAY, pcd->clientFrameWin, pcd->frameInfo.x,
  1987. pcd->frameInfo.y, pcd->frameInfo.width, pcd->frameInfo.height);
  1988. /* resize base window */
  1989. XMoveResizeWindow (DISPLAY, pcd->clientBaseWin,
  1990. BaseWindowX (pcd), BaseWindowY (pcd),
  1991. BaseWindowWidth (pcd), BaseWindowHeight (pcd));
  1992. /* resize the stretcher windows */
  1993. if (SHOW_RESIZE_CURSORS(pcd) && (decor & MWM_DECOR_RESIZEH)) {
  1994. CreateStretcherWindows (pcd);
  1995. XMoveResizeWindow (DISPLAY,
  1996. pcd->clientStretchWin[STRETCH_NORTH_WEST],
  1997. 0, 0, pcd->frameInfo.cornerWidth,
  1998. pcd->frameInfo.cornerHeight);
  1999. XMoveResizeWindow (DISPLAY,
  2000. pcd->clientStretchWin[STRETCH_NORTH],
  2001. (int) pcd->frameInfo.cornerWidth, 0,
  2002. pcd->frameInfo.width - 2*pcd->frameInfo.cornerWidth,
  2003. pcd->frameInfo.upperBorderWidth);
  2004. XMoveResizeWindow (DISPLAY,
  2005. pcd->clientStretchWin[STRETCH_NORTH_EAST],
  2006. (int) (pcd->frameInfo.width - pcd->frameInfo.cornerWidth), 0,
  2007. pcd->frameInfo.cornerWidth, pcd->frameInfo.cornerHeight);
  2008. XMoveResizeWindow (DISPLAY,
  2009. pcd->clientStretchWin[STRETCH_EAST],
  2010. (int) (pcd->frameInfo.width - pcd->frameInfo.lowerBorderWidth),
  2011. (int) (pcd->frameInfo.cornerHeight),
  2012. pcd->frameInfo.lowerBorderWidth,
  2013. pcd->frameInfo.height - 2*pcd->frameInfo.cornerHeight);
  2014. XMoveResizeWindow (DISPLAY,
  2015. pcd->clientStretchWin[STRETCH_SOUTH_EAST],
  2016. (int) (pcd->frameInfo.width - pcd->frameInfo.cornerWidth),
  2017. (int) (pcd->frameInfo.height - pcd->frameInfo.cornerHeight),
  2018. pcd->frameInfo.cornerWidth, pcd->frameInfo.cornerHeight);
  2019. XMoveResizeWindow (DISPLAY,
  2020. pcd->clientStretchWin[STRETCH_SOUTH],
  2021. (int) pcd->frameInfo.cornerWidth,
  2022. (int) (pcd->frameInfo.height - pcd->frameInfo.lowerBorderWidth),
  2023. pcd->frameInfo.width - 2*pcd->frameInfo.cornerWidth,
  2024. pcd->frameInfo.lowerBorderWidth);
  2025. XMoveResizeWindow (DISPLAY,
  2026. pcd->clientStretchWin[STRETCH_SOUTH_WEST],
  2027. 0, (int) (pcd->frameInfo.height - pcd->frameInfo.cornerHeight),
  2028. pcd->frameInfo.cornerWidth, pcd->frameInfo.cornerHeight);
  2029. XMoveResizeWindow (DISPLAY,
  2030. pcd->clientStretchWin[STRETCH_WEST],
  2031. 0, (int) pcd->frameInfo.cornerHeight,
  2032. pcd->frameInfo.lowerBorderWidth,
  2033. pcd->frameInfo.height - 2*pcd->frameInfo.cornerHeight);
  2034. }
  2035. /* resize title bar window */
  2036. if (decor & MWM_DECOR_TITLE)
  2037. {
  2038. if (!pcd->clientTitleWin) CreateTitleBarWindow (pcd);
  2039. XResizeWindow (DISPLAY, pcd->clientTitleWin,
  2040. pcd->frameInfo.width - 2*pcd->frameInfo.upperBorderWidth,
  2041. pcd->frameInfo.titleBarHeight);
  2042. }
  2043. /* recreate gadget rectangles */
  2044. AllocateGadgetRectangles (pcd);
  2045. ComputeGadgetRectangles (pcd);
  2046. /* regenerate the graphics */
  2047. GenerateFrameDisplayLists (pcd);
  2048. if (wmGD.hasShape && pcd->wShaped)
  2049. {
  2050. SetFrameShape (pcd);
  2051. }
  2052. /* map all subwindows of client frame */
  2053. XMapSubwindows(DISPLAY, pcd->clientFrameWin);
  2054. } /* END OF FUNCTION RegenerateClientFrame */
  2055. /*************************************<->*************************************
  2056. *
  2057. * BevelSystemButton (prTop, prBot, x, y, width, height)
  2058. *
  2059. *
  2060. * Description:
  2061. * -----------
  2062. * Bevels a rectangle for the system button (drawer handle?)
  2063. *
  2064. *
  2065. * Inputs:
  2066. * ------
  2067. * prTop - ptr to top shadow rectangles
  2068. * prBot - ptr to bottom shadow rectangles
  2069. * x - x coord of maximize gadget
  2070. * y - y coord of maximize gadget
  2071. * width - width of maximize gadget
  2072. * height - height of maximize gadget
  2073. *
  2074. *
  2075. * Outputs:
  2076. * -------
  2077. *
  2078. *
  2079. * Comments:
  2080. * --------
  2081. * o This draws a horizontal "drawer handle" for the system gadget.
  2082. * Assumptions: the enclosing box is square (width == height)
  2083. *************************************<->***********************************/
  2084. void BevelSystemButton (RList *prTop, RList *prBot, int x, int y,
  2085. unsigned int width, unsigned int height)
  2086. {
  2087. int offset1, offset2;
  2088. unsigned int dim1, dim2;
  2089. switch (height) {
  2090. case 5:
  2091. case 6:
  2092. offset1 = offset2 = 2;
  2093. dim1 = dim2 = height-4;
  2094. break;
  2095. case 7:
  2096. offset1 = offset2 = 2;
  2097. dim1 = 3;
  2098. dim2 = 2;
  2099. break;
  2100. case 8:
  2101. case 9:
  2102. offset1 = 2;
  2103. offset2 = 3;
  2104. dim1 = width - 4;
  2105. dim2 = height - 6;
  2106. break;
  2107. case 10:
  2108. case 11:
  2109. offset1 = 3;
  2110. offset2 = 4;
  2111. dim1 = width - 6;
  2112. dim2 = height - 8;
  2113. break;
  2114. case 12:
  2115. case 13:
  2116. offset1 = 3;
  2117. offset2 = (height-3)/2;
  2118. dim1 = width - 6;
  2119. dim2 = 3;
  2120. break;
  2121. default:
  2122. offset1 = 4;
  2123. offset2 = (height - 4)/2;
  2124. dim1 = width - 8;
  2125. dim2 = 4;
  2126. break;
  2127. }
  2128. if (height >= 5) {
  2129. /* system icon */
  2130. BevelRectangle (prTop, prBot, /* system icon */
  2131. (x+offset1), (y+offset2),
  2132. dim1, dim2,
  2133. 1, 1, 1, 1);
  2134. }
  2135. } /* END OF FUNCTION BevelSystemButton */
  2136. /*************************************<->*************************************
  2137. *
  2138. * BevelMinimizeButton (prTop, prBot, x, y, height)
  2139. *
  2140. *
  2141. * Description:
  2142. * -----------
  2143. * Bevels a rectangle for the minimize button
  2144. *
  2145. *
  2146. * Inputs:
  2147. * ------
  2148. * prTop - ptr to top shadow rectangles
  2149. * prBot - ptr to bottom shadow rectangles
  2150. * x - x coord of maximize gadget
  2151. * y - y coord of maximize gadget
  2152. * height - height of maximize gadget
  2153. *
  2154. *
  2155. * Outputs:
  2156. * -------
  2157. *
  2158. *
  2159. * Comments:
  2160. * --------
  2161. *
  2162. *************************************<->***********************************/
  2163. void BevelMinimizeButton (RList *prTop, RList *prBot, int x, int y,
  2164. unsigned int height)
  2165. {
  2166. int offset1, offset2;
  2167. unsigned int dim1, dim2;
  2168. switch (height) {
  2169. case 7:
  2170. case 8:
  2171. case 9:
  2172. offset1 = offset2 = 3;
  2173. dim1 = dim2 = height-6;
  2174. break;
  2175. case 10:
  2176. case 11:
  2177. case 12:
  2178. offset1 = offset2 = (height-3)/2;
  2179. dim1 = dim2 = 3;
  2180. break;
  2181. default:
  2182. offset1 = offset2 = (height-4)/2;
  2183. dim1 = dim2 = 4;
  2184. break;
  2185. }
  2186. if (height >= 7) {
  2187. /* minimize icon */
  2188. BevelRectangle (prTop, prBot,
  2189. (x+offset1), (y+offset2),
  2190. dim1, dim2,
  2191. 1, 1, 1, 1);
  2192. }
  2193. } /* END OF FUNCTION BevelMinimizeButton */
  2194. /*************************************<->*************************************
  2195. *
  2196. * BevelMaximizeButton (prTop, prBot, x, y, height)
  2197. *
  2198. *
  2199. * Description:
  2200. * -----------
  2201. * Bevels a rectangle for the maximize button
  2202. *
  2203. *
  2204. * Inputs:
  2205. * ------
  2206. * prTop - ptr to top shadow rectangles
  2207. * prBot - ptr to bottom shadow rectangles
  2208. * x - x coord of maximize gadget
  2209. * y - y coord of maximize gadget
  2210. * height - height of maximize gadget
  2211. *
  2212. *
  2213. * Outputs:
  2214. * -------
  2215. *
  2216. *
  2217. * Comments:
  2218. * --------
  2219. *
  2220. *************************************<->***********************************/
  2221. void BevelMaximizeButton (RList *prTop, RList *prBot, int x, int y,
  2222. unsigned int height)
  2223. {
  2224. int offset1, offset2;
  2225. unsigned int dim1, dim2;
  2226. switch (height) {
  2227. case 5:
  2228. case 6:
  2229. case 7:
  2230. case 8:
  2231. case 9:
  2232. case 10:
  2233. case 11:
  2234. offset1 = offset2 = 2;
  2235. dim1 = dim2 = height-4;
  2236. break;
  2237. case 12:
  2238. case 13:
  2239. case 14:
  2240. case 15:
  2241. offset1 = offset2 = 3;
  2242. dim1 = dim2 = height-6;
  2243. break;
  2244. default:
  2245. offset1 = offset2 = 4;
  2246. dim1 = dim2 = height-8;
  2247. break;
  2248. }
  2249. /* maximize icon */
  2250. BevelRectangle (prTop, prBot,
  2251. (x+offset1), (y+offset2),
  2252. dim1, dim2,
  2253. 1, 1, 1, 1);
  2254. } /* END OF FUNCTION BevelMaximizeButton */
  2255. /*************************************<->*************************************
  2256. *
  2257. * DepressGadget (pcd, gadget, depressed)
  2258. *
  2259. *
  2260. * Description:
  2261. * -----------
  2262. * Show the gadget in a "depressed" state
  2263. *
  2264. *
  2265. * Inputs:
  2266. * ------
  2267. * pcd - pointer to client data
  2268. * gadget - gadget id
  2269. * depressed - if True, then gadget is shown depressed, if False it is
  2270. * shown not depressed
  2271. *
  2272. *
  2273. * Outputs:
  2274. * -------
  2275. * return - true if sucessful
  2276. *
  2277. *
  2278. * Comments:
  2279. * --------
  2280. * o This assumes there is a one-pixel bevel around the gadget.
  2281. * o This only works on title bar gadgets.
  2282. *
  2283. *************************************<->***********************************/
  2284. Boolean DepressGadget (ClientData *pcd, int gadget, Boolean depressed)
  2285. {
  2286. int x, y;
  2287. unsigned int width, height, invertWidth;
  2288. static RList *pTopRect = NULL;
  2289. static RList *pBotRect = NULL;
  2290. GC topGC, botGC;
  2291. Window win;
  2292. /* get outside dimensions of box we want */
  2293. switch (gadget) {
  2294. case FRAME_TITLE:
  2295. case FRAME_SYSTEM:
  2296. case FRAME_MINIMIZE:
  2297. case FRAME_MAXIMIZE:
  2298. if (!GetDepressInfo (pcd, gadget, &x, &y, &width,
  2299. &height, &invertWidth))
  2300. return(FALSE);
  2301. break;
  2302. default:
  2303. return(FALSE); /* do nothing on non-title bar gagdets */
  2304. }
  2305. if (DECOUPLE_TITLE_APPEARANCE(pcd) &&
  2306. (pcd->decor & MWM_DECOR_TITLE))
  2307. {
  2308. /* adjust position to be relative to titlebar window, not frame */
  2309. x -= (short) pcd->frameInfo.upperBorderWidth;
  2310. y -= (short) pcd->frameInfo.upperBorderWidth;
  2311. /* use "active" GCs if we have keyboard focus */
  2312. if (pcd == wmGD.keyboardFocus) {
  2313. topGC = CLIENT_TITLE_APPEARANCE(pcd).activeTopShadowGC;
  2314. botGC = CLIENT_TITLE_APPEARANCE(pcd).activeBottomShadowGC;
  2315. }
  2316. else {
  2317. topGC = CLIENT_TITLE_APPEARANCE(pcd).inactiveTopShadowGC;
  2318. botGC =
  2319. CLIENT_TITLE_APPEARANCE(pcd).inactiveBottomShadowGC;
  2320. }
  2321. /* draw into title bar window */
  2322. win = pcd->clientTitleWin;
  2323. }
  2324. else
  2325. {
  2326. /* use "active" GCs if we have keyboard focus */
  2327. if (pcd == wmGD.keyboardFocus) {
  2328. topGC = CLIENT_APPEARANCE(pcd).activeTopShadowGC;
  2329. botGC = CLIENT_APPEARANCE(pcd).activeBottomShadowGC;
  2330. }
  2331. else {
  2332. topGC = CLIENT_APPEARANCE(pcd).inactiveTopShadowGC;
  2333. botGC = CLIENT_APPEARANCE(pcd).inactiveBottomShadowGC;
  2334. }
  2335. /* draw into client frame window */
  2336. win = pcd->clientFrameWin;
  2337. }
  2338. /*
  2339. * Bevel a rectangle for the desired button effect
  2340. * Allocate the rectangles if necessary.
  2341. */
  2342. if ( (pTopRect && pBotRect) ||
  2343. ((pTopRect = AllocateRList(2)) &&
  2344. (pBotRect = AllocateRList(2))))
  2345. {
  2346. pTopRect->used = 0;
  2347. pBotRect->used = 0;
  2348. BevelRectangle (pTopRect, pBotRect,
  2349. x, y, width, height,
  2350. invertWidth, invertWidth,
  2351. invertWidth, invertWidth);
  2352. }
  2353. /* draw the gadget border to make it look depressed or normal */
  2354. if (depressed) {
  2355. XFillRectangles (DISPLAY, win, botGC, pTopRect->prect, pTopRect->used);
  2356. XFillRectangles (DISPLAY, win, topGC, pBotRect->prect, pBotRect->used);
  2357. }
  2358. else {
  2359. XFillRectangles (DISPLAY, win, topGC, pTopRect->prect, pTopRect->used);
  2360. XFillRectangles (DISPLAY, win, botGC, pBotRect->prect, pBotRect->used);
  2361. }
  2362. return(TRUE);
  2363. } /* END OF FUNCTION DepressGadget */
  2364. /*************************************<->*************************************
  2365. *
  2366. * PushGadgetIn (pcd, gadget)
  2367. *
  2368. *
  2369. * Description:
  2370. * -----------
  2371. * Shows a title bar gadget in a depressed state
  2372. *
  2373. *
  2374. * Inputs:
  2375. * ------
  2376. * pcd - pointer to client data
  2377. * gadget - gadget id
  2378. *
  2379. * Outputs:
  2380. * -------
  2381. *
  2382. * Comments:
  2383. * --------
  2384. *
  2385. *************************************<->***********************************/
  2386. void PushGadgetIn (ClientData *pcd, int gadget)
  2387. {
  2388. switch (gadget) {
  2389. case FRAME_SYSTEM:
  2390. pcd->decorFlags |= SYSTEM_DEPRESSED;
  2391. break;
  2392. case FRAME_TITLE:
  2393. pcd->decorFlags |= TITLE_DEPRESSED;
  2394. break;
  2395. case FRAME_MINIMIZE:
  2396. pcd->decorFlags |= MINIMIZE_DEPRESSED;
  2397. break;
  2398. case FRAME_MAXIMIZE:
  2399. pcd->decorFlags |= MAXIMIZE_DEPRESSED;
  2400. break;
  2401. default:
  2402. return;
  2403. }
  2404. GenerateFrameDisplayLists(pcd);
  2405. (void) DepressGadget (pcd, gadget, TRUE);
  2406. wmGD.gadgetClient = pcd;
  2407. wmGD.gadgetDepressed = gadget;
  2408. } /* END OF FUNCTION PushGadgetIn */
  2409. /*************************************<->*************************************
  2410. *
  2411. * PopGadgetOut (pcd, gadget)
  2412. *
  2413. *
  2414. * Description:
  2415. * -----------
  2416. * Shows a title bar gadget in a depressed state
  2417. *
  2418. *
  2419. * Inputs:
  2420. * ------
  2421. * pcd - pointer to client data
  2422. * gadget - gadget id
  2423. *
  2424. * Outputs:
  2425. * -------
  2426. *
  2427. * Comments:
  2428. * --------
  2429. *
  2430. *************************************<->***********************************/
  2431. void PopGadgetOut (ClientData *pcd, int gadget)
  2432. {
  2433. switch (gadget) {
  2434. case FRAME_SYSTEM:
  2435. pcd->decorFlags &= ~SYSTEM_DEPRESSED;
  2436. break;
  2437. case FRAME_TITLE:
  2438. pcd->decorFlags &= ~TITLE_DEPRESSED;
  2439. break;
  2440. case FRAME_MINIMIZE:
  2441. pcd->decorFlags &= ~MINIMIZE_DEPRESSED;
  2442. break;
  2443. case FRAME_MAXIMIZE:
  2444. pcd->decorFlags &= ~MAXIMIZE_DEPRESSED;
  2445. break;
  2446. default:
  2447. return;
  2448. }
  2449. GenerateFrameDisplayLists(pcd);
  2450. (void) DepressGadget (pcd, gadget, FALSE);
  2451. wmGD.gadgetClient = NULL;
  2452. wmGD.gadgetDepressed = 0;
  2453. } /* END OF FUNCTION PopGadgetOut */
  2454. /*************************************<->*************************************
  2455. *
  2456. * SetFrameShape (pcd)
  2457. *
  2458. *
  2459. * Description:
  2460. * -----------
  2461. * Shapes the frame and base window to the shape of the client
  2462. * window. Also ors the title window into the shaped frame
  2463. * window if present.
  2464. *
  2465. * Inputs:
  2466. * ------
  2467. * pcd - pointer to client data
  2468. *
  2469. * Outputs:
  2470. * -------
  2471. *
  2472. * Comments:
  2473. * --------
  2474. * o currently punt on resize handle around the frame.
  2475. *
  2476. *************************************<->***********************************/
  2477. void SetFrameShape (ClientData *pcd)
  2478. {
  2479. /*
  2480. * The frame consists of the shape of the contents window offset by
  2481. * title_height or'ed with the shape of title window (which is always
  2482. * rectangular).
  2483. */
  2484. int xOffset = 0;
  2485. int yOffset = 0;
  2486. if (XBorderIsShowing(pcd))
  2487. {
  2488. xOffset = pcd->xBorderWidth;
  2489. yOffset = pcd->xBorderWidth;
  2490. }
  2491. else if(pcd->matteWidth > 0)
  2492. {
  2493. xOffset = pcd->matteWidth;
  2494. yOffset = pcd->matteWidth;
  2495. }
  2496. if (pcd->wShaped)
  2497. {
  2498. /*
  2499. * need to do general case
  2500. */
  2501. XShapeCombineShape (DISPLAY, pcd->clientBaseWin, ShapeBounding,
  2502. xOffset,
  2503. yOffset,
  2504. pcd->client, ShapeBounding,
  2505. ShapeSet);
  2506. XShapeCombineShape (DISPLAY, pcd->clientFrameWin, ShapeBounding,
  2507. BaseWindowX (pcd),
  2508. BaseWindowY (pcd),
  2509. pcd->clientBaseWin, ShapeBounding,
  2510. ShapeSet);
  2511. if (pcd->decor & MWM_DECOR_TITLE)
  2512. {
  2513. XShapeCombineShape (DISPLAY, pcd->clientFrameWin, ShapeBounding,
  2514. pcd->frameInfo.upperBorderWidth,
  2515. pcd->frameInfo.upperBorderWidth,
  2516. pcd->clientTitleWin, ShapeBounding,
  2517. ShapeUnion);
  2518. }
  2519. }
  2520. else
  2521. {
  2522. (void) XShapeCombineMask (DISPLAY, pcd->clientFrameWin,
  2523. ShapeBounding, 0, 0,
  2524. None, ShapeSet);
  2525. (void) XShapeCombineMask (DISPLAY, pcd->clientFrameWin,
  2526. ShapeClip, 0, 0,
  2527. None, ShapeSet);
  2528. (void) XShapeCombineMask (DISPLAY, pcd->clientBaseWin,
  2529. ShapeBounding, 0, 0,
  2530. None, ShapeSet);
  2531. (void) XShapeCombineMask (DISPLAY, pcd->clientBaseWin,
  2532. ShapeClip, 0, 0,
  2533. None, ShapeSet);
  2534. }
  2535. } /* END OF FUNCTION SetFrameShape */