2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
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
24 * (c) Copyright 1989, 1990, 1991, 1992, 1993 OPEN SOFTWARE FOUNDATION, INC.
31 * (c) Copyright 1987, 1988, 1989, 1990 HEWLETT-PACKARD COMPANY */
42 /*************************************<->*************************************
44 * unsigned int TitleTextHeight (pcd)
49 * Returns the height of the title text plus padding
53 * pcd - pointer to client data record
57 * TitleTextHeight - Height of title text plus padding
62 *************************************<->***********************************/
63 unsigned int TitleTextHeight (ClientData *pcd)
65 unsigned int ttextheight;
67 if (DECOUPLE_TITLE_APPEARANCE(pcd))
69 ttextheight = CLIENT_TITLE_APPEARANCE(pcd).titleHeight;
73 ttextheight = CLIENT_APPEARANCE(pcd).titleHeight;
79 /*************************************<->*************************************
81 * unsigned int InitTitleBarHeight (pcd)
86 * Used to initialize pCD->frameInfo.titleBarHeight which is used by the new
87 * macro TitleBarHeight(). Returns the height of the title bar.
91 * pcd - pointer to client data record
95 * InitTitleBarHeight - height of title bar, 0 if no title bar.
100 *************************************<->***********************************/
101 unsigned int InitTitleBarHeight (ClientData *pcd)
103 unsigned int tbarheight;
105 if (pcd->decor & MWM_DECOR_TITLE)
107 tbarheight = TitleTextHeight(pcd);
118 /*************************************<->*************************************
120 * unsigned int UpperBorderWidth (pcd)
125 * Returns the width of the upper frame border
129 * pcd - pointer to client data record
133 * UpperBorderWidth - width of the upper frame border
137 * The upper border width is thinner if there is a title bar. The
138 * title bar appears to sit across some of the inside beveling to
139 * make the frame look more integrated.
141 *************************************<->***********************************/
142 unsigned int UpperBorderWidth (ClientData *pcd)
144 unsigned int uswidth;
145 unsigned int decoration = pcd->decor;
147 if (decoration & MWM_DECOR_RESIZEH)
149 uswidth = RESIZE_BORDER_WIDTH(pcd);
151 else if (decoration & MWM_DECOR_BORDER)
153 uswidth = FRAME_BORDER_WIDTH(pcd);
154 if((pcd->clientFlags & FRONT_PANEL_BOX) &&
160 else if ((decoration & MWM_DECOR_TITLE) ||
161 (pcd->matteWidth > 0))
167 uswidth = pcd->xBorderWidth;
174 /*************************************<->*************************************
176 * unsigned int LowerBorderWidth (pcd)
181 * Returns the width of the lower frame border
185 * pcd - pointer to client data record
189 * LowerBorderWidth - width of the lower frame border
193 * The upper border width is thinner than the lower border if there
194 * is a title bar. The title bar appears to sit across some of the
195 * inside beveling to make the frame look more integrated.
197 *************************************<->***********************************/
198 unsigned int LowerBorderWidth (ClientData *pcd)
200 unsigned int lswidth;
201 unsigned int decoration = pcd->decor;
203 if (decoration & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
205 if ((pcd->matteWidth == 0) && (decoration & MWM_DECOR_TITLE) &&
206 (wmGD.frameStyle == WmRECESSED))
207 lswidth = UpperBorderWidth (pcd) +
208 (pcd->internalBevel - JOIN_BEVEL(pcd));
210 lswidth = UpperBorderWidth (pcd);
212 else if (pcd->matteWidth > 0)
218 lswidth = pcd->xBorderWidth;
225 /*************************************<->*************************************
227 * unsigned int FrameWidth (pcd)
232 * Returns the width of the frame
236 * pcd - pointer to client data record
240 * FrameWidth - width of frame
245 *************************************<->***********************************/
246 unsigned int FrameWidth (ClientData *pcd)
248 unsigned int frameWidth;
250 frameWidth = ((pcd->maxConfig) ? pcd->maxWidth : pcd->clientWidth) +
251 2*pcd->matteWidth + 2*LowerBorderWidth (pcd);
257 /*************************************<->*************************************
259 * unsigned int CornerWidth (pcd)
264 * Returns the width of the corner frame resize handle
268 * pcd - pointer to client data record
272 * CornerWidth - width of the corner resize handle
277 *************************************<->***********************************/
278 unsigned int CornerWidth (ClientData *pcd)
281 unsigned int frameWidth = FrameWidth (pcd);
283 /* adjust for resize border (default border if no resize wanted) */
284 if (pcd->decor & MWM_DECOR_RESIZEH)
286 /* corner size is driven by title bar height */
287 cwidth = TitleTextHeight(pcd) + UpperBorderWidth (pcd);
289 /* scale down corners to make resize pieces proportional */
290 if (3*cwidth > frameWidth) cwidth = frameWidth / 3;
293 /* no resizing functions */
301 /*************************************<->*************************************
303 * unsigned int FrameHeight (pcd)
308 * Returns the height of the frame
312 * pcd - pointer to client data record
316 * FrameHeight - position of frame
321 *************************************<->***********************************/
322 unsigned int FrameHeight (ClientData *pcd)
324 unsigned int frameHeight;
326 if (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
328 frameHeight = ((pcd->maxConfig) ?
329 pcd->maxHeight : pcd->clientHeight) +
330 2*pcd->matteWidth + LowerBorderWidth (pcd) +
331 UpperBorderWidth (pcd) + TitleBarHeight(pcd);
335 frameHeight = ((pcd->maxConfig) ?
336 pcd->maxHeight : pcd->clientHeight) +
337 2*pcd->matteWidth + 2*LowerBorderWidth (pcd) +
341 return (frameHeight);
345 /*************************************<->*************************************
347 * unsigned int CornerHeight (pcd)
352 * Returns the height of the corner frame resize handle
356 * pcd - pointer to client data record
360 * CornerHeight - Height of the corner resize handle
365 *************************************<->***********************************/
366 unsigned int CornerHeight (ClientData *pcd)
368 unsigned int cheight;
369 unsigned int frameHeight = FrameHeight (pcd);
371 /* adjust for resize border (default border if no resize wanted) */
372 if (pcd->decor & MWM_DECOR_RESIZEH)
374 /* corner size is driven by title bar height */
375 cheight = TitleTextHeight(pcd) + UpperBorderWidth (pcd);
377 /* scale down corners to make resize pieces proportional */
378 if (3*cheight > frameHeight) cheight = frameHeight / 3;
381 /* produce default border with no resizing functions */
389 /*************************************<->*************************************
391 * int BaseWindowX (pcd)
396 * Returns the X coord of the base window in the frame
400 * pcd - pointer to client data record
409 *************************************<->***********************************/
410 int BaseWindowX (ClientData *pcd)
414 if (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
415 rval = LowerBorderWidth(pcd);
423 /*************************************<->*************************************
425 * int BaseWindowY (pcd)
430 * Returns the Y coord of the base window in the frame
434 * pcd - pointer to client data record
443 *************************************<->***********************************/
444 int BaseWindowY (ClientData *pcd)
448 if (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
449 rval = UpperBorderWidth (pcd) + TitleBarHeight(pcd);
451 rval = TitleBarHeight(pcd);
458 /*************************************<->*************************************
465 * Returns the X-coordinate of the frame for the window
469 * pcd - pointer to client data record
473 * FrameX - X position of frame
478 *************************************<->***********************************/
479 int FrameX (ClientData *pcd)
483 frameX = ((pcd->maxConfig) ? pcd->maxX : pcd->clientX)
484 - LowerBorderWidth (pcd) - pcd->matteWidth;
490 /*************************************<->*************************************
497 * Returns the Y-coordinate of the frame for the window
501 * pcd - pointer to client data record
505 * FrameY - Y position of frame
510 *************************************<->***********************************/
511 int FrameY (ClientData *pcd)
515 frameY = ((pcd->maxConfig) ? pcd->maxY : pcd->clientY)
516 - UpperBorderWidth (pcd)
517 - TitleBarHeight (pcd) - pcd->matteWidth;
519 if ((pcd->decor & MWM_DECOR_TITLE) &&
520 !(pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER)) &&
523 frameY -= pcd->xBorderWidth;
530 /*************************************<->*************************************
532 * unsigned int BaseWindowWidth (pcd)
537 * Returns the width of the base window
541 * pcd - pointer to client data record
549 * o Based on code taken out of FrameWidth to make it a little
552 *************************************<->***********************************/
553 unsigned int BaseWindowWidth (ClientData *pcd)
557 if (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
560 * rval = FrameWidth(pcd) - 2*LowerBorderWidth(pcd);
563 rval = ((pcd->maxConfig) ? pcd->maxWidth : pcd->clientWidth) +
569 * rval = FrameWidth(pcd);
571 rval = ((pcd->maxConfig) ? pcd->maxWidth : pcd->clientWidth) +
572 2*pcd->matteWidth + 2*LowerBorderWidth (pcd);
580 /*************************************<->*************************************
582 * unsigned int BaseWindowHeight (pcd)
587 * Returns the height of the base window
591 * pcd - pointer to client data record
599 * o Based on code taken out of FrameHeight to make it a little
602 *************************************<->***********************************/
603 unsigned int BaseWindowHeight (ClientData *pcd)
607 if (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
611 * rval = FrameHeight(pcd) - LowerBorderWidth(pcd) -
612 * UpperBorderWidth(pcd) - TitleBarHeight(pcd);
615 rval = ((pcd->maxConfig) ? pcd->maxHeight : pcd->clientHeight) +
621 * rval = FrameHeight(pcd) - TitleBarHeight(pcd);
624 rval = ((pcd->maxConfig) ? pcd->maxHeight : pcd->clientHeight) +
625 2*pcd->matteWidth + 2*LowerBorderWidth (pcd);
633 /*************************************<->*************************************
635 * Boolean GetFramePartInfo (pcd, part, pX, pY, pWidth, pHeight)
640 * Gets frame relative position and size of the specified frame part
645 * pcd - pointer to client data
646 * part - part id (e.g. FRAME_TITLE, FRAME_SYSTEM, etc.)
647 * pX - pointer to x-coord return value
648 * pY - pointer to y-coord return value
649 * pWidth - pointer to width return value
650 * pHeight - pointer to width return value
655 * Return - True if values returned, false if no such part for this
656 * frame (values undefined).
662 *************************************<->***********************************/
663 Boolean GetFramePartInfo (ClientData *pcd, int part, int *pX, int *pY, unsigned int *pWidth, unsigned int *pHeight)
665 unsigned int boxdim = TitleBarHeight (pcd);
666 unsigned long decor = pcd->decor;
668 Boolean rval = FALSE;
673 if (decor & MWM_DECOR_MENU) {
674 *pX = pcd->frameInfo.upperBorderWidth;
675 *pY = pcd->frameInfo.upperBorderWidth;
683 if (decor & MWM_DECOR_TITLE) {
684 *pX = pcd->frameInfo.upperBorderWidth +
685 ((decor & MWM_DECOR_MENU) ? boxdim : 0);
686 *pY = pcd->frameInfo.upperBorderWidth;
687 *pWidth = pcd->frameInfo.width -
688 2*pcd->frameInfo.upperBorderWidth -
689 ((decor & MWM_DECOR_MENU) ? boxdim : 0) -
690 ((decor & MWM_DECOR_MINIMIZE) ? boxdim : 0) -
691 ((decor & MWM_DECOR_MAXIMIZE) ? boxdim : 0);
698 if (decor & MWM_DECOR_TITLE) {
699 *pX = pcd->frameInfo.upperBorderWidth;
700 *pY = pcd->frameInfo.upperBorderWidth;
701 *pWidth = pcd->frameInfo.width -
702 2*pcd->frameInfo.upperBorderWidth;
709 if (decor & MWM_DECOR_MINIMIZE) {
710 *pX = pcd->frameInfo.width -
711 pcd->frameInfo.upperBorderWidth - boxdim -
712 ((decor & MWM_DECOR_MAXIMIZE) ? boxdim : 0);
713 *pY = pcd->frameInfo.upperBorderWidth;
721 if (decor & MWM_DECOR_MAXIMIZE) {
722 *pX = pcd->frameInfo.width -
723 pcd->frameInfo.upperBorderWidth - boxdim;
724 *pY = pcd->frameInfo.upperBorderWidth;
732 * For very small windows, the resize pieces will shrink
733 * equally until the corner pieces get within two pixels
734 * of the resize border width. At this point the "side" section
735 * is killed off (by giving it a zero length) and the corner
736 * pieces claim the additional space
738 case FRAME_RESIZE_NW:
739 if (decor & MWM_DECOR_RESIZEH) {
743 if ((int)pcd->frameInfo.cornerWidth >
744 (int)pcd->frameInfo.lowerBorderWidth+2) {
745 *pWidth = pcd->frameInfo.cornerWidth;
748 horiz = pcd->frameInfo.width -
749 2*pcd->frameInfo.cornerWidth;
750 *pWidth = pcd->frameInfo.cornerWidth +
754 if ((int)pcd->frameInfo.cornerHeight >
755 (int)pcd->frameInfo.lowerBorderWidth+2) {
756 *pHeight = pcd->frameInfo.cornerHeight;
759 vert = pcd->frameInfo.height -
760 2*pcd->frameInfo.cornerHeight;
761 *pHeight = pcd->frameInfo.cornerHeight +
769 if (decor & MWM_DECOR_RESIZEH) {
770 *pX = pcd->frameInfo.cornerWidth;
772 *pHeight = pcd->frameInfo.upperBorderWidth;
773 if ((int)pcd->frameInfo.cornerWidth >
774 (int)pcd->frameInfo.lowerBorderWidth+2) {
775 *pWidth = pcd->frameInfo.width -
776 2*pcd->frameInfo.cornerWidth;
785 case FRAME_RESIZE_NE:
786 if (decor & MWM_DECOR_RESIZEH) {
787 if ((int)pcd->frameInfo.cornerWidth >
788 (int)pcd->frameInfo.lowerBorderWidth+2) {
789 *pWidth = pcd->frameInfo.cornerWidth;
792 horiz = pcd->frameInfo.width -
793 2*pcd->frameInfo.cornerWidth;
794 *pWidth = pcd->frameInfo.cornerWidth + horiz/2;
796 *pX = pcd->frameInfo.width - *pWidth;
798 if ((int)pcd->frameInfo.cornerHeight >
799 (int)pcd->frameInfo.lowerBorderWidth+2) {
800 *pHeight = pcd->frameInfo.cornerHeight;
803 vert = pcd->frameInfo.height -
804 2*pcd->frameInfo.cornerHeight;
805 *pHeight = pcd->frameInfo.cornerHeight +
814 if (decor & MWM_DECOR_RESIZEH) {
815 *pX = pcd->frameInfo.width -
816 pcd->frameInfo.lowerBorderWidth;
817 *pY = pcd->frameInfo.cornerHeight;
818 *pWidth = pcd->frameInfo.lowerBorderWidth;
819 if ((int)pcd->frameInfo.cornerHeight >
820 (int)pcd->frameInfo.lowerBorderWidth+2) {
821 *pHeight = pcd->frameInfo.height -
822 2*pcd->frameInfo.cornerHeight;
831 case FRAME_RESIZE_SE:
832 if (decor & MWM_DECOR_RESIZEH) {
833 if ((int)pcd->frameInfo.cornerWidth >
834 (int)pcd->frameInfo.lowerBorderWidth+2) {
835 *pWidth = pcd->frameInfo.cornerWidth;
838 horiz = pcd->frameInfo.width -
839 2*pcd->frameInfo.cornerWidth;
840 *pWidth = pcd->frameInfo.cornerWidth + horiz/2;
842 *pX = pcd->frameInfo.width - *pWidth;
844 if ((int)pcd->frameInfo.cornerHeight >
845 (int)pcd->frameInfo.lowerBorderWidth+2) {
846 *pHeight = pcd->frameInfo.cornerHeight;
849 vert = pcd->frameInfo.height -
850 2*pcd->frameInfo.cornerHeight;
851 *pHeight = pcd->frameInfo.cornerHeight + vert/2;
853 *pY = pcd->frameInfo.height - *pHeight;
859 if (decor & MWM_DECOR_RESIZEH) {
860 *pX = pcd->frameInfo.cornerWidth;
861 *pY = pcd->frameInfo.height -
862 pcd->frameInfo.lowerBorderWidth;
863 if ((int)pcd->frameInfo.cornerWidth >
864 (int)pcd->frameInfo.lowerBorderWidth+2) {
865 *pWidth = pcd->frameInfo.width -
866 2*pcd->frameInfo.cornerWidth;
871 *pHeight = pcd->frameInfo.lowerBorderWidth;
876 case FRAME_RESIZE_SW:
877 if (decor & MWM_DECOR_RESIZEH) {
878 if ((int)pcd->frameInfo.cornerWidth >
879 (int)pcd->frameInfo.lowerBorderWidth+2) {
880 *pWidth = pcd->frameInfo.cornerWidth;
883 horiz = pcd->frameInfo.width -
884 2*pcd->frameInfo.cornerWidth;
885 *pWidth = pcd->frameInfo.cornerWidth +
890 if ((int)pcd->frameInfo.cornerHeight >
891 (int)pcd->frameInfo.lowerBorderWidth+2) {
892 *pHeight = pcd->frameInfo.cornerHeight;
895 vert = pcd->frameInfo.height -
896 2*pcd->frameInfo.cornerHeight;
897 *pHeight = pcd->frameInfo.cornerHeight + vert/2;
899 *pY = pcd->frameInfo.height - *pHeight;
905 if (decor & MWM_DECOR_RESIZEH) {
907 *pY = pcd->frameInfo.cornerHeight;
908 *pWidth = pcd->frameInfo.lowerBorderWidth;
909 if ((int)pcd->frameInfo.cornerHeight >
910 (int)pcd->frameInfo.lowerBorderWidth+2) {
911 *pHeight = pcd->frameInfo.height -
912 2*pcd->frameInfo.cornerHeight;
929 /*************************************<->*************************************
931 * IdentifyFramePart (pCD, x, y)
936 * Returns an ID representing which part of the frame received the event
941 * pCD - pointer to client data
943 * x, y - client coordinates of event
948 * Return - ID of frame part where the button event occurred.
953 *************************************<->***********************************/
955 int IdentifyFramePart (ClientData *pCD, int x, int y)
957 unsigned long decor = pCD->decor;
958 int clientWidth = (pCD->maxConfig) ? pCD->maxWidth : pCD->clientWidth;
959 int clientHeight= (pCD->maxConfig) ? pCD->maxHeight : pCD->clientHeight;
963 /* check for client window */
965 if ( (x >= pCD->clientOffset.x) &&
966 (x < pCD->clientOffset.x + clientWidth) &&
967 (y >= pCD->clientOffset.y) &&
968 (y < pCD->clientOffset.y + clientHeight) )
970 return (FRAME_CLIENT);
974 /* check for client matte */
978 if ( (x >= pCD->matteRectangle.x) &&
979 (x < (int)pCD->matteRectangle.x + (int)pCD->matteRectangle.width) &&
980 (y >= pCD->matteRectangle.y) &&
981 (y < (int)pCD->matteRectangle.y + (int)pCD->matteRectangle.height) )
983 return (FRAME_MATTE);
988 /* check title bar */
990 if (decor & MWM_DECOR_TITLE)
992 if ( (x >= pCD->titleRectangle.x) &&
993 (x < (int)pCD->titleRectangle.x + (int)pCD->titleRectangle.width) &&
994 (y >= pCD->titleRectangle.y) &&
995 (y < (int)pCD->titleRectangle.y + (int)pCD->titleRectangle.height) )
997 return(GadgetID(x, y, pCD->pTitleGadgets,
998 (unsigned int)pCD->cTitleGadgets));
1003 /* try resize border */
1005 if (decor & MWM_DECOR_RESIZEH)
1007 rval = GadgetID(x, y, pCD->pResizeGadgets, STRETCH_COUNT);
1015 /* if not a resize border, but still in bounds return FRAME_NBORDER */
1017 if (rval == FRAME_NONE)
1019 if ((x >= 0) && (y >= 0) &&
1020 (x < FrameWidth (pCD)) && (y < FrameHeight (pCD)))
1022 rval = FRAME_NBORDER;
1028 } /* END OF FUNCTION IdentifyFramePart */
1033 /*************************************<->*************************************
1035 * GadgetID (x, y, pgadget, count)
1040 * returns the id of the gadget in the list that the event occurred in
1045 * x - x coordinate of event
1046 * y - y coordinate of event
1047 * pgadget - pointer to a list of GadgetRectangles
1048 * count - number of elements in the pgadget list
1052 * Return - ID of gadget if found, FRAME_NONE if not found
1059 *************************************<->***********************************/
1060 int GadgetID (int x, int y, GadgetRectangle *pgadget, unsigned int count)
1064 for (ix = 0; ix < count; ix++, pgadget++) {
1065 if ( (x >= pgadget->rect.x) &&
1066 (x < (int)pgadget->rect.x + (int)pgadget->rect.width) &&
1067 (y >= pgadget->rect.y) &&
1068 (y < (int)pgadget->rect.y + (int)pgadget->rect.height) ) {
1069 return ((unsigned long) pgadget->id);
1078 /*************************************<->*************************************
1080 * FrameToClient (pcd, pX, pY, pWidth, pHeight)
1085 * Converts frame position and size to client position and size
1090 * pcd - pointer to client data
1091 * pX - pointer to frame x-coord
1092 * pY - pointer to frame y-coord
1093 * pWidth - pointer to frame width in pixels
1094 * pHeight - pointer to frame height in pixels
1098 * *pX - client x-coord
1099 * *pY - client y-coord
1100 * *pWidth - client width in pixels
1101 * *pHeight - client height in pixels
1107 *************************************<->***********************************/
1108 void FrameToClient (ClientData *pcd, int *pX, int *pY, unsigned int *pWidth, unsigned int *pHeight)
1110 /* compute client window coordinates from frame coordinates */
1112 *pWidth = *pWidth - 2*pcd->clientOffset.x;
1113 *pHeight = *pHeight - pcd->clientOffset.x - pcd->clientOffset.y;
1114 *pX = *pX + pcd->clientOffset.x;
1115 *pY = *pY + pcd->clientOffset.y;
1119 /*************************************<->*************************************
1121 * ClientToFrame (pcd, pX, pY, pWidth, pHeight)
1126 * Converts frame position and size to client position and size
1131 * pcd - pointer to client data
1132 * pX - client x-coord
1133 * pY - client y-coord
1134 * pWidth - client width in pixels
1135 * pHeight - client height in pixels
1139 * *pX - frame x-coord
1140 * *pY - frame y-coord
1141 * *pWidth - frame width in pixels
1142 * *pHeight - frame height in pixels
1148 *************************************<->***********************************/
1149 void ClientToFrame (ClientData *pcd, int *pX, int *pY, unsigned int *pWidth, unsigned int *pHeight)
1151 /* compute client window coordinates from frame coordinates */
1152 *pWidth = *pWidth + 2*pcd->clientOffset.x;
1153 *pHeight = *pHeight + pcd->clientOffset.x + pcd->clientOffset.y;
1154 *pX = *pX - pcd->clientOffset.x;
1155 *pY = *pY - pcd->clientOffset.y;
1160 /*************************************<->*************************************
1162 * Boolean GetDepressInfo (pcd, part, pX, pY, pWidth, pHeight)
1167 * Gets frame relative position, size, and width of the beveling
1168 * to show the gadget in its depressed state.
1173 * pcd - pointer to client data
1174 * part - part id (e.g. FRAME_TITLE, FRAME_SYSTEM, etc.)
1175 * pX - pointer to x-coord return value
1176 * pY - pointer to y-coord return value
1177 * pWidth - pointer to width return value
1178 * pHeight - pointer to width return value
1179 * pInverWidth - pointer to inversion width return value
1184 * Return - True if values returned, false if no such part for this
1185 * frame (values undefined).
1190 * o The "part" must be a title bar gadget.
1192 *************************************<->***********************************/
1193 Boolean GetDepressInfo (ClientData *pcd, int part, int *pX, int *pY, unsigned int *pWidth, unsigned int *pHeight, unsigned int *pInvertWidth)
1196 unsigned int exBevel, eBevel;
1197 unsigned int wBevel, sBevel;
1198 unsigned int insideBevel, meBevel;
1199 unsigned int decoration = pcd->decor;
1206 case FRAME_MINIMIZE:
1207 case FRAME_MAXIMIZE:
1208 if ((rval = GetFramePartInfo (pcd, part, pX, pY, pWidth, pHeight)))
1211 * set bevel width based on join bevel
1213 *pInvertWidth = 1 + (JOIN_BEVEL(pcd) / 2);
1215 /* bevel between title and client (or matte) */
1216 insideBevel = (pcd->matteWidth > 0) ? JOIN_BEVEL(pcd) :
1221 * Compute beveling around the title area of the
1224 if (decoration & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
1226 exBevel = JOIN_BEVEL(pcd); /* north side */
1227 sBevel = insideBevel; /* south side */
1228 eBevel = JOIN_BEVEL(pcd); /* east side */
1229 wBevel = JOIN_BEVEL(pcd); /* west side */
1230 meBevel = JOIN_BEVEL(pcd); /* east of Min */
1234 /* borderless window */
1236 exBevel = EXTERNAL_BEVEL(pcd);
1238 sBevel = (pcd->matteWidth > 0) ? insideBevel :
1239 EXTERNAL_BEVEL(pcd);
1241 eBevel = (decoration & (MWM_DECOR_MINIMIZE |
1242 MWM_DECOR_MAXIMIZE))?
1243 JOIN_BEVEL(pcd) : EXTERNAL_BEVEL(pcd);
1245 wBevel = (decoration & MWM_DECOR_MENU) ?
1246 JOIN_BEVEL(pcd) : EXTERNAL_BEVEL(pcd);
1248 meBevel = (decoration & (MWM_DECOR_MAXIMIZE)) ?
1249 JOIN_BEVEL(pcd) : EXTERNAL_BEVEL(pcd);
1253 * Adjust height of all title bar gadgets if necessary.
1254 * (The bottom bevel is the same for all the pieces.)
1257 if (sBevel > *pInvertWidth)
1259 *pHeight -= (sBevel - *pInvertWidth);
1263 * Adjust the beveling on the other sides of the
1269 /* west and north sides */
1270 if (exBevel > *pInvertWidth)
1272 tmp = exBevel - *pInvertWidth;
1280 if (wBevel > *pInvertWidth)
1282 *pWidth -= (wBevel - *pInvertWidth);
1288 if (wBevel > *pInvertWidth)
1290 tmp = wBevel - *pInvertWidth;
1296 if (exBevel > *pInvertWidth)
1298 tmp = exBevel - *pInvertWidth;
1304 if (eBevel > *pInvertWidth)
1306 *pWidth -= eBevel - *pInvertWidth;
1310 case FRAME_MINIMIZE:
1312 if (exBevel > *pInvertWidth)
1314 tmp = exBevel - *pInvertWidth;
1320 if (eBevel > *pInvertWidth)
1322 tmp = eBevel - *pInvertWidth;
1328 if (meBevel > *pInvertWidth)
1330 *pWidth -= meBevel - *pInvertWidth;
1334 case FRAME_MAXIMIZE:
1335 /* north and east sides */
1336 if (exBevel > *pInvertWidth)
1338 tmp = exBevel - *pInvertWidth;
1345 if (eBevel > *pInvertWidth)
1347 tmp = eBevel - *pInvertWidth;
1353 } /* end case "title bar part" */
1368 /*************************************<->*************************************
1370 * SetFrameInfo (pcd)
1375 * Sets frame information into client data structure for easy access.
1380 * pcd - pointer to client data
1387 * o Sets values into the FrameInfo component of the client data structure
1389 *************************************<->***********************************/
1390 void SetFrameInfo (ClientData *pcd)
1394 * The title bar height value stored in pcd->frameInfo is used by the
1395 * macro TitleBarHeight(pcd).
1398 pcd->frameInfo.titleBarHeight = InitTitleBarHeight (pcd);
1400 pcd->frameInfo.x = FrameX (pcd);
1401 pcd->frameInfo.y = FrameY (pcd);
1402 pcd->frameInfo.width = FrameWidth (pcd);
1403 pcd->frameInfo.height = FrameHeight (pcd);
1404 pcd->frameInfo.upperBorderWidth = UpperBorderWidth (pcd);
1405 pcd->frameInfo.lowerBorderWidth = LowerBorderWidth (pcd);
1406 pcd->frameInfo.cornerWidth = CornerWidth (pcd);
1407 pcd->frameInfo.cornerHeight = CornerHeight (pcd);
1409 /* set client offset */
1411 if ( (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER)) ||
1412 (pcd->matteWidth > 0) )
1415 * The window has a window manager border.
1417 pcd->clientOffset.x = pcd->frameInfo.lowerBorderWidth +
1419 pcd->clientOffset.y = pcd->frameInfo.upperBorderWidth +
1420 pcd->frameInfo.titleBarHeight +
1426 * No window manager border, the original X border is showing
1429 pcd->clientOffset.x = pcd->xBorderWidth + pcd->matteWidth;
1430 pcd->clientOffset.y = pcd->xBorderWidth +
1431 pcd->frameInfo.titleBarHeight +
1439 /*************************************<->*************************************
1441 * SetClientOffset (pcd)
1446 * Sets the client offset into client data structure
1451 * pcd - pointer to client data
1458 * This can be called before SetFrameInfo to set up the client offset
1459 * without the danger of using uninitialized variables during
1460 * extraneous computation.
1462 *************************************<->***********************************/
1463 void SetClientOffset (ClientData *pcd)
1466 * The title bar height value stored in pcd->frameInfo is used by the
1467 * macro TitleBarHeight(pcd).
1470 pcd->frameInfo.titleBarHeight = InitTitleBarHeight (pcd);
1472 pcd->frameInfo.upperBorderWidth = UpperBorderWidth (pcd);
1473 pcd->frameInfo.lowerBorderWidth = LowerBorderWidth (pcd);
1475 /* set client offset */
1477 if ( (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER)) ||
1478 (pcd->matteWidth > 0) )
1481 * The window has a window manager border.
1483 pcd->clientOffset.x = pcd->frameInfo.lowerBorderWidth +
1485 pcd->clientOffset.y = pcd->frameInfo.upperBorderWidth +
1486 pcd->frameInfo.titleBarHeight +
1492 * No window manager border, the original X border is showing
1495 pcd->clientOffset.x = pcd->xBorderWidth + pcd->matteWidth;
1496 pcd->clientOffset.y = pcd->xBorderWidth +
1497 pcd->frameInfo.titleBarHeight +
1504 /*************************************<->*************************************
1506 * XBorderIsShowing (pcd)
1511 * Returns true if the X border is showing.
1516 * pcd - pointer to client data
1520 * XBorderIsShowing - True if no window manager border & x border is
1521 * visible, False otherwise
1526 *************************************<->***********************************/
1527 Boolean XBorderIsShowing (ClientData *pcd)
1531 if ( (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER)) ||
1532 (pcd->matteWidth > 0) )
1534 rval = False; /* hidden by window manager */
1538 rval = True; /* it's showing */