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 librararies 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.
32 static char rcsid[] = "$XConsortium: WmCDInfo.c /main/4 1995/11/01 11:32:15 rswiston $"
36 * (c) Copyright 1987, 1988, 1989, 1990 HEWLETT-PACKARD COMPANY */
47 /*************************************<->*************************************
49 * unsigned int TitleTextHeight (pcd)
54 * Returns the height of the title text plus padding
58 * pcd - pointer to client data record
62 * TitleTextHeight - Height of title text plus padding
67 *************************************<->***********************************/
68 unsigned int TitleTextHeight (ClientData *pcd)
70 unsigned int ttextheight;
73 if (DECOUPLE_TITLE_APPEARANCE(pcd))
75 ttextheight = CLIENT_TITLE_APPEARANCE(pcd).titleHeight;
79 ttextheight = CLIENT_APPEARANCE(pcd).titleHeight;
85 if (DECOUPLE_TITLE_APPEARANCE(pcd))
87 font = CLIENT_TITLE_APPEARANCE(pcd).font;
91 font = CLIENT_APPEARANCE(pcd).font;
96 ttextheight = TEXT_HEIGHT(font) + WM_TITLE_BAR_PADDING;
101 * Failed to load any font! (probably due to error in
102 * font path, toolkit, or resource converter. Set to
103 * arbitrary value for robustness.
109 return (ttextheight);
113 /*************************************<->*************************************
115 * unsigned int InitTitleBarHeight (pcd)
120 * Used to initialize pCD->frameInfo.titleBarHeight which is used by the new
121 * macro TitleBarHeight(). Returns the height of the title bar.
125 * pcd - pointer to client data record
129 * InitTitleBarHeight - height of title bar, 0 if no title bar.
134 *************************************<->***********************************/
135 unsigned int InitTitleBarHeight (ClientData *pcd)
137 unsigned int tbarheight;
139 if (pcd->decor & MWM_DECOR_TITLE)
141 tbarheight = TitleTextHeight(pcd);
152 /*************************************<->*************************************
154 * unsigned int UpperBorderWidth (pcd)
159 * Returns the width of the upper frame border
163 * pcd - pointer to client data record
167 * UpperBorderWidth - width of the upper frame border
171 * The upper border width is thinner if there is a title bar. The
172 * title bar appears to sit across some of the inside beveling to
173 * make the frame look more integrated.
175 *************************************<->***********************************/
176 unsigned int UpperBorderWidth (ClientData *pcd)
178 unsigned int uswidth;
179 unsigned int decoration = pcd->decor;
181 if (decoration & MWM_DECOR_RESIZEH)
183 uswidth = RESIZE_BORDER_WIDTH(pcd);
185 else if (decoration & MWM_DECOR_BORDER)
187 uswidth = FRAME_BORDER_WIDTH(pcd);
189 if((pcd->clientFlags & FRONT_PANEL_BOX) &&
194 #endif /* PANELIST */
196 else if ((decoration & MWM_DECOR_TITLE) ||
197 (pcd->matteWidth > 0))
203 uswidth = pcd->xBorderWidth;
210 /*************************************<->*************************************
212 * unsigned int LowerBorderWidth (pcd)
217 * Returns the width of the lower frame border
221 * pcd - pointer to client data record
225 * LowerBorderWidth - width of the lower frame border
229 * The upper border width is thinner than the lower border if there
230 * is a title bar. The title bar appears to sit across some of the
231 * inside beveling to make the frame look more integrated.
233 *************************************<->***********************************/
234 unsigned int LowerBorderWidth (ClientData *pcd)
236 unsigned int lswidth;
237 unsigned int decoration = pcd->decor;
239 if (decoration & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
241 if ((pcd->matteWidth == 0) && (decoration & MWM_DECOR_TITLE) &&
242 (wmGD.frameStyle == WmRECESSED))
243 lswidth = UpperBorderWidth (pcd) +
244 (pcd->internalBevel - JOIN_BEVEL(pcd));
246 lswidth = UpperBorderWidth (pcd);
248 else if (pcd->matteWidth > 0)
254 lswidth = pcd->xBorderWidth;
261 /*************************************<->*************************************
263 * unsigned int FrameWidth (pcd)
268 * Returns the width of the frame
272 * pcd - pointer to client data record
276 * FrameWidth - width of frame
281 *************************************<->***********************************/
282 unsigned int FrameWidth (ClientData *pcd)
284 unsigned int frameWidth;
286 frameWidth = ((pcd->maxConfig) ? pcd->maxWidth : pcd->clientWidth) +
287 2*pcd->matteWidth + 2*LowerBorderWidth (pcd);
293 /*************************************<->*************************************
295 * unsigned int CornerWidth (pcd)
300 * Returns the width of the corner frame resize handle
304 * pcd - pointer to client data record
308 * CornerWidth - width of the corner resize handle
313 *************************************<->***********************************/
314 unsigned int CornerWidth (ClientData *pcd)
317 unsigned int frameWidth = FrameWidth (pcd);
319 /* adjust for resize border (default border if no resize wanted) */
320 if (pcd->decor & MWM_DECOR_RESIZEH)
322 /* corner size is driven by title bar height */
323 cwidth = TitleTextHeight(pcd) + UpperBorderWidth (pcd);
325 /* scale down corners to make resize pieces proportional */
326 if (3*cwidth > frameWidth) cwidth = frameWidth / 3;
329 /* no resizing functions */
337 /*************************************<->*************************************
339 * unsigned int FrameHeight (pcd)
344 * Returns the height of the frame
348 * pcd - pointer to client data record
352 * FrameHeight - position of frame
357 *************************************<->***********************************/
358 unsigned int FrameHeight (ClientData *pcd)
360 unsigned int frameHeight;
362 if (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
364 frameHeight = ((pcd->maxConfig) ?
365 pcd->maxHeight : pcd->clientHeight) +
366 2*pcd->matteWidth + LowerBorderWidth (pcd) +
367 UpperBorderWidth (pcd) + TitleBarHeight(pcd);
371 frameHeight = ((pcd->maxConfig) ?
372 pcd->maxHeight : pcd->clientHeight) +
373 2*pcd->matteWidth + 2*LowerBorderWidth (pcd) +
377 return (frameHeight);
381 /*************************************<->*************************************
383 * unsigned int CornerHeight (pcd)
388 * Returns the height of the corner frame resize handle
392 * pcd - pointer to client data record
396 * CornerHeight - Height of the corner resize handle
401 *************************************<->***********************************/
402 unsigned int CornerHeight (ClientData *pcd)
404 unsigned int cheight;
405 unsigned int frameHeight = FrameHeight (pcd);
407 /* adjust for resize border (default border if no resize wanted) */
408 if (pcd->decor & MWM_DECOR_RESIZEH)
410 /* corner size is driven by title bar height */
411 cheight = TitleTextHeight(pcd) + UpperBorderWidth (pcd);
413 /* scale down corners to make resize pieces proportional */
414 if (3*cheight > frameHeight) cheight = frameHeight / 3;
417 /* produce default border with no resizing functions */
425 /*************************************<->*************************************
427 * int BaseWindowX (pcd)
432 * Returns the X coord of the base window in the frame
436 * pcd - pointer to client data record
445 *************************************<->***********************************/
446 int BaseWindowX (ClientData *pcd)
450 if (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
451 rval = LowerBorderWidth(pcd);
459 /*************************************<->*************************************
461 * int BaseWindowY (pcd)
466 * Returns the Y coord of the base window in the frame
470 * pcd - pointer to client data record
479 *************************************<->***********************************/
480 int BaseWindowY (ClientData *pcd)
484 if (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
485 rval = UpperBorderWidth (pcd) + TitleBarHeight(pcd);
487 rval = TitleBarHeight(pcd);
494 /*************************************<->*************************************
501 * Returns the X-coordinate of the frame for the window
505 * pcd - pointer to client data record
509 * FrameX - X position of frame
514 *************************************<->***********************************/
515 int FrameX (ClientData *pcd)
519 frameX = ((pcd->maxConfig) ? pcd->maxX : pcd->clientX)
520 - LowerBorderWidth (pcd) - pcd->matteWidth;
526 /*************************************<->*************************************
533 * Returns the Y-coordinate of the frame for the window
537 * pcd - pointer to client data record
541 * FrameY - Y position of frame
546 *************************************<->***********************************/
547 int FrameY (ClientData *pcd)
551 frameY = ((pcd->maxConfig) ? pcd->maxY : pcd->clientY)
552 - UpperBorderWidth (pcd)
553 - TitleBarHeight (pcd) - pcd->matteWidth;
555 if ((pcd->decor & MWM_DECOR_TITLE) &&
556 !(pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER)) &&
559 frameY -= pcd->xBorderWidth;
566 /*************************************<->*************************************
568 * unsigned int BaseWindowWidth (pcd)
573 * Returns the width of the base window
577 * pcd - pointer to client data record
585 * o Based on code taken out of FrameWidth to make it a little
588 *************************************<->***********************************/
589 unsigned int BaseWindowWidth (ClientData *pcd)
593 if (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
596 * rval = FrameWidth(pcd) - 2*LowerBorderWidth(pcd);
599 rval = ((pcd->maxConfig) ? pcd->maxWidth : pcd->clientWidth) +
605 * rval = FrameWidth(pcd);
607 rval = ((pcd->maxConfig) ? pcd->maxWidth : pcd->clientWidth) +
608 2*pcd->matteWidth + 2*LowerBorderWidth (pcd);
616 /*************************************<->*************************************
618 * unsigned int BaseWindowHeight (pcd)
623 * Returns the height of the base window
627 * pcd - pointer to client data record
635 * o Based on code taken out of FrameHeight to make it a little
638 *************************************<->***********************************/
639 unsigned int BaseWindowHeight (ClientData *pcd)
643 if (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
647 * rval = FrameHeight(pcd) - LowerBorderWidth(pcd) -
648 * UpperBorderWidth(pcd) - TitleBarHeight(pcd);
651 rval = ((pcd->maxConfig) ? pcd->maxHeight : pcd->clientHeight) +
657 * rval = FrameHeight(pcd) - TitleBarHeight(pcd);
660 rval = ((pcd->maxConfig) ? pcd->maxHeight : pcd->clientHeight) +
661 2*pcd->matteWidth + 2*LowerBorderWidth (pcd);
669 /*************************************<->*************************************
671 * Boolean GetFramePartInfo (pcd, part, pX, pY, pWidth, pHeight)
676 * Gets frame relative position and size of the specified frame part
681 * pcd - pointer to client data
682 * part - part id (e.g. FRAME_TITLE, FRAME_SYSTEM, etc.)
683 * pX - pointer to x-coord return value
684 * pY - pointer to y-coord return value
685 * pWidth - pointer to width return value
686 * pHeight - pointer to width return value
691 * Return - True if values returned, false if no such part for this
692 * frame (values undefined).
698 *************************************<->***********************************/
699 Boolean GetFramePartInfo (ClientData *pcd, int part, int *pX, int *pY, unsigned int *pWidth, unsigned int *pHeight)
701 unsigned int boxdim = TitleBarHeight (pcd);
702 unsigned long decor = pcd->decor;
704 Boolean rval = FALSE;
709 if (decor & MWM_DECOR_MENU) {
710 *pX = pcd->frameInfo.upperBorderWidth;
711 *pY = pcd->frameInfo.upperBorderWidth;
719 if (decor & MWM_DECOR_TITLE) {
720 *pX = pcd->frameInfo.upperBorderWidth +
721 ((decor & MWM_DECOR_MENU) ? boxdim : 0);
722 *pY = pcd->frameInfo.upperBorderWidth;
723 *pWidth = pcd->frameInfo.width -
724 2*pcd->frameInfo.upperBorderWidth -
725 ((decor & MWM_DECOR_MENU) ? boxdim : 0) -
726 ((decor & MWM_DECOR_MINIMIZE) ? boxdim : 0) -
727 ((decor & MWM_DECOR_MAXIMIZE) ? boxdim : 0);
735 if (decor & MWM_DECOR_TITLE) {
736 *pX = pcd->frameInfo.upperBorderWidth;
737 *pY = pcd->frameInfo.upperBorderWidth;
738 *pWidth = pcd->frameInfo.width -
739 2*pcd->frameInfo.upperBorderWidth;
747 if (decor & MWM_DECOR_MINIMIZE) {
748 *pX = pcd->frameInfo.width -
749 pcd->frameInfo.upperBorderWidth - boxdim -
750 ((decor & MWM_DECOR_MAXIMIZE) ? boxdim : 0);
751 *pY = pcd->frameInfo.upperBorderWidth;
759 if (decor & MWM_DECOR_MAXIMIZE) {
760 *pX = pcd->frameInfo.width -
761 pcd->frameInfo.upperBorderWidth - boxdim;
762 *pY = pcd->frameInfo.upperBorderWidth;
770 * For very small windows, the resize pieces will shrink
771 * equally until the corner pieces get within two pixels
772 * of the resize border width. At this point the "side" section
773 * is killed off (by giving it a zero length) and the corner
774 * pieces claim the additional space
776 case FRAME_RESIZE_NW:
777 if (decor & MWM_DECOR_RESIZEH) {
781 if ((int)pcd->frameInfo.cornerWidth >
782 (int)pcd->frameInfo.lowerBorderWidth+2) {
783 *pWidth = pcd->frameInfo.cornerWidth;
786 horiz = pcd->frameInfo.width -
787 2*pcd->frameInfo.cornerWidth;
788 *pWidth = pcd->frameInfo.cornerWidth +
792 if ((int)pcd->frameInfo.cornerHeight >
793 (int)pcd->frameInfo.lowerBorderWidth+2) {
794 *pHeight = pcd->frameInfo.cornerHeight;
797 vert = pcd->frameInfo.height -
798 2*pcd->frameInfo.cornerHeight;
799 *pHeight = pcd->frameInfo.cornerHeight +
807 if (decor & MWM_DECOR_RESIZEH) {
808 *pX = pcd->frameInfo.cornerWidth;
810 *pHeight = pcd->frameInfo.upperBorderWidth;
811 if ((int)pcd->frameInfo.cornerWidth >
812 (int)pcd->frameInfo.lowerBorderWidth+2) {
813 *pWidth = pcd->frameInfo.width -
814 2*pcd->frameInfo.cornerWidth;
823 case FRAME_RESIZE_NE:
824 if (decor & MWM_DECOR_RESIZEH) {
825 if ((int)pcd->frameInfo.cornerWidth >
826 (int)pcd->frameInfo.lowerBorderWidth+2) {
827 *pWidth = pcd->frameInfo.cornerWidth;
830 horiz = pcd->frameInfo.width -
831 2*pcd->frameInfo.cornerWidth;
832 *pWidth = pcd->frameInfo.cornerWidth + horiz/2;
834 *pX = pcd->frameInfo.width - *pWidth;
836 if ((int)pcd->frameInfo.cornerHeight >
837 (int)pcd->frameInfo.lowerBorderWidth+2) {
838 *pHeight = pcd->frameInfo.cornerHeight;
841 vert = pcd->frameInfo.height -
842 2*pcd->frameInfo.cornerHeight;
843 *pHeight = pcd->frameInfo.cornerHeight +
852 if (decor & MWM_DECOR_RESIZEH) {
853 *pX = pcd->frameInfo.width -
854 pcd->frameInfo.lowerBorderWidth;
855 *pY = pcd->frameInfo.cornerHeight;
856 *pWidth = pcd->frameInfo.lowerBorderWidth;
857 if ((int)pcd->frameInfo.cornerHeight >
858 (int)pcd->frameInfo.lowerBorderWidth+2) {
859 *pHeight = pcd->frameInfo.height -
860 2*pcd->frameInfo.cornerHeight;
869 case FRAME_RESIZE_SE:
870 if (decor & MWM_DECOR_RESIZEH) {
871 if ((int)pcd->frameInfo.cornerWidth >
872 (int)pcd->frameInfo.lowerBorderWidth+2) {
873 *pWidth = pcd->frameInfo.cornerWidth;
876 horiz = pcd->frameInfo.width -
877 2*pcd->frameInfo.cornerWidth;
878 *pWidth = pcd->frameInfo.cornerWidth + horiz/2;
880 *pX = pcd->frameInfo.width - *pWidth;
882 if ((int)pcd->frameInfo.cornerHeight >
883 (int)pcd->frameInfo.lowerBorderWidth+2) {
884 *pHeight = pcd->frameInfo.cornerHeight;
887 vert = pcd->frameInfo.height -
888 2*pcd->frameInfo.cornerHeight;
889 *pHeight = pcd->frameInfo.cornerHeight + vert/2;
891 *pY = pcd->frameInfo.height - *pHeight;
897 if (decor & MWM_DECOR_RESIZEH) {
898 *pX = pcd->frameInfo.cornerWidth;
899 *pY = pcd->frameInfo.height -
900 pcd->frameInfo.lowerBorderWidth;
901 if ((int)pcd->frameInfo.cornerWidth >
902 (int)pcd->frameInfo.lowerBorderWidth+2) {
903 *pWidth = pcd->frameInfo.width -
904 2*pcd->frameInfo.cornerWidth;
909 *pHeight = pcd->frameInfo.lowerBorderWidth;
914 case FRAME_RESIZE_SW:
915 if (decor & MWM_DECOR_RESIZEH) {
916 if ((int)pcd->frameInfo.cornerWidth >
917 (int)pcd->frameInfo.lowerBorderWidth+2) {
918 *pWidth = pcd->frameInfo.cornerWidth;
921 horiz = pcd->frameInfo.width -
922 2*pcd->frameInfo.cornerWidth;
923 *pWidth = pcd->frameInfo.cornerWidth +
928 if ((int)pcd->frameInfo.cornerHeight >
929 (int)pcd->frameInfo.lowerBorderWidth+2) {
930 *pHeight = pcd->frameInfo.cornerHeight;
933 vert = pcd->frameInfo.height -
934 2*pcd->frameInfo.cornerHeight;
935 *pHeight = pcd->frameInfo.cornerHeight + vert/2;
937 *pY = pcd->frameInfo.height - *pHeight;
943 if (decor & MWM_DECOR_RESIZEH) {
945 *pY = pcd->frameInfo.cornerHeight;
946 *pWidth = pcd->frameInfo.lowerBorderWidth;
947 if ((int)pcd->frameInfo.cornerHeight >
948 (int)pcd->frameInfo.lowerBorderWidth+2) {
949 *pHeight = pcd->frameInfo.height -
950 2*pcd->frameInfo.cornerHeight;
967 /*************************************<->*************************************
969 * IdentifyFramePart (pCD, x, y)
974 * Returns an ID representing which part of the frame received the event
979 * pCD - pointer to client data
981 * x, y - client coordinates of event
986 * Return - ID of frame part where the button event occurred.
991 *************************************<->***********************************/
993 int IdentifyFramePart (ClientData *pCD, int x, int y)
995 unsigned long decor = pCD->decor;
996 int clientWidth = (pCD->maxConfig) ? pCD->maxWidth : pCD->clientWidth;
997 int clientHeight= (pCD->maxConfig) ? pCD->maxHeight : pCD->clientHeight;
1001 /* check for client window */
1003 if ( (x >= pCD->clientOffset.x) &&
1004 (x < pCD->clientOffset.x + clientWidth) &&
1005 (y >= pCD->clientOffset.y) &&
1006 (y < pCD->clientOffset.y + clientHeight) )
1008 return (FRAME_CLIENT);
1012 /* check for client matte */
1014 if (pCD->matteWidth)
1016 if ( (x >= pCD->matteRectangle.x) &&
1017 (x < (int)pCD->matteRectangle.x + (int)pCD->matteRectangle.width) &&
1018 (y >= pCD->matteRectangle.y) &&
1019 (y < (int)pCD->matteRectangle.y + (int)pCD->matteRectangle.height) )
1021 return (FRAME_MATTE);
1026 /* check title bar */
1028 if (decor & MWM_DECOR_TITLE)
1030 if ( (x >= pCD->titleRectangle.x) &&
1031 (x < (int)pCD->titleRectangle.x + (int)pCD->titleRectangle.width) &&
1032 (y >= pCD->titleRectangle.y) &&
1033 (y < (int)pCD->titleRectangle.y + (int)pCD->titleRectangle.height) )
1035 return(GadgetID(x, y, pCD->pTitleGadgets,
1036 (unsigned int)pCD->cTitleGadgets));
1041 /* try resize border */
1043 if (decor & MWM_DECOR_RESIZEH)
1045 rval = GadgetID(x, y, pCD->pResizeGadgets, STRETCH_COUNT);
1053 /* if not a resize border, but still in bounds return FRAME_NBORDER */
1055 if (rval == FRAME_NONE)
1057 if ((x >= 0) && (y >= 0) &&
1058 (x < FrameWidth (pCD)) && (y < FrameHeight (pCD)))
1060 rval = FRAME_NBORDER;
1066 } /* END OF FUNCTION IdentifyFramePart */
1071 /*************************************<->*************************************
1073 * GadgetID (x, y, pgadget, count)
1078 * returns the id of the gadget in the list that the event occured in
1083 * x - x coordinate of event
1084 * y - y coordinate of event
1085 * pgadget - pointer to a list of GadgetRectangles
1086 * count - number of elements in the pgadget list
1090 * Return - ID of gadget if found, FRAME_NONE if not found
1097 *************************************<->***********************************/
1098 int GadgetID (int x, int y, GadgetRectangle *pgadget, unsigned int count)
1102 for (ix = 0; ix < count; ix++, pgadget++) {
1103 if ( (x >= pgadget->rect.x) &&
1104 (x < (int)pgadget->rect.x + (int)pgadget->rect.width) &&
1105 (y >= pgadget->rect.y) &&
1106 (y < (int)pgadget->rect.y + (int)pgadget->rect.height) ) {
1107 return ((unsigned long) pgadget->id);
1116 /*************************************<->*************************************
1118 * FrameToClient (pcd, pX, pY, pWidth, pHeight)
1123 * Converts frame position and size to client position and size
1128 * pcd - pointer to client data
1129 * pX - pointer to frame x-coord
1130 * pY - pointer to frame y-coord
1131 * pWidth - pointer to frame width in pixels
1132 * pHeight - pointer to frame height in pixels
1136 * *pX - client x-coord
1137 * *pY - client y-coord
1138 * *pWidth - client width in pixels
1139 * *pHeight - client height in pixels
1145 *************************************<->***********************************/
1146 void FrameToClient (ClientData *pcd, int *pX, int *pY, unsigned int *pWidth, unsigned int *pHeight)
1148 /* compute client window coordinates from frame coordinates */
1150 *pWidth = *pWidth - 2*pcd->clientOffset.x;
1151 *pHeight = *pHeight - pcd->clientOffset.x - pcd->clientOffset.y;
1152 *pX = *pX + pcd->clientOffset.x;
1153 *pY = *pY + pcd->clientOffset.y;
1157 /*************************************<->*************************************
1159 * ClientToFrame (pcd, pX, pY, pWidth, pHeight)
1164 * Converts frame position and size to client position and size
1169 * pcd - pointer to client data
1170 * pX - client x-coord
1171 * pY - client y-coord
1172 * pWidth - client width in pixels
1173 * pHeight - client height in pixels
1177 * *pX - frame x-coord
1178 * *pY - frame y-coord
1179 * *pWidth - frame width in pixels
1180 * *pHeight - frame height in pixels
1186 *************************************<->***********************************/
1187 void ClientToFrame (ClientData *pcd, int *pX, int *pY, unsigned int *pWidth, unsigned int *pHeight)
1189 /* compute client window coordinates from frame coordinates */
1190 *pWidth = *pWidth + 2*pcd->clientOffset.x;
1191 *pHeight = *pHeight + pcd->clientOffset.x + pcd->clientOffset.y;
1192 *pX = *pX - pcd->clientOffset.x;
1193 *pY = *pY - pcd->clientOffset.y;
1198 /*************************************<->*************************************
1200 * Boolean GetDepressInfo (pcd, part, pX, pY, pWidth, pHeight)
1205 * Gets frame relative position, size, and width of the beveling
1206 * to show the gadget in its depressed state.
1211 * pcd - pointer to client data
1212 * part - part id (e.g. FRAME_TITLE, FRAME_SYSTEM, etc.)
1213 * pX - pointer to x-coord return value
1214 * pY - pointer to y-coord return value
1215 * pWidth - pointer to width return value
1216 * pHeight - pointer to width return value
1217 * pInverWidth - pointer to inversion width return value
1222 * Return - True if values returned, false if no such part for this
1223 * frame (values undefined).
1228 * o The "part" must be a title bar gadget.
1230 *************************************<->***********************************/
1231 Boolean GetDepressInfo (ClientData *pcd, int part, int *pX, int *pY, unsigned int *pWidth, unsigned int *pHeight, unsigned int *pInvertWidth)
1234 unsigned int exBevel, eBevel;
1235 unsigned int wBevel, sBevel;
1236 unsigned int insideBevel, meBevel;
1237 unsigned int decoration = pcd->decor;
1244 case FRAME_MINIMIZE:
1245 case FRAME_MAXIMIZE:
1246 if ((rval = GetFramePartInfo (pcd, part, pX, pY, pWidth, pHeight)))
1249 * set bevel width based on join bevel
1251 *pInvertWidth = 1 + (JOIN_BEVEL(pcd) / 2);
1253 /* bevel between title and client (or matte) */
1254 insideBevel = (pcd->matteWidth > 0) ? JOIN_BEVEL(pcd) :
1259 * Compute beveling around the title area of the
1262 if (decoration & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
1264 exBevel = JOIN_BEVEL(pcd); /* north side */
1265 sBevel = insideBevel; /* south side */
1266 eBevel = JOIN_BEVEL(pcd); /* east side */
1267 wBevel = JOIN_BEVEL(pcd); /* west side */
1268 meBevel = JOIN_BEVEL(pcd); /* east of Min */
1272 /* borderless window */
1274 exBevel = EXTERNAL_BEVEL(pcd);
1276 sBevel = (pcd->matteWidth > 0) ? insideBevel :
1277 EXTERNAL_BEVEL(pcd);
1279 eBevel = (decoration & (MWM_DECOR_MINIMIZE |
1280 MWM_DECOR_MAXIMIZE))?
1281 JOIN_BEVEL(pcd) : EXTERNAL_BEVEL(pcd);
1283 wBevel = (decoration & MWM_DECOR_MENU) ?
1284 JOIN_BEVEL(pcd) : EXTERNAL_BEVEL(pcd);
1286 meBevel = (decoration & (MWM_DECOR_MAXIMIZE)) ?
1287 JOIN_BEVEL(pcd) : EXTERNAL_BEVEL(pcd);
1291 * Adjust height of all title bar gadgets if necessary.
1292 * (The bottom bevel is the same for all the pieces.)
1295 if (sBevel > *pInvertWidth)
1297 *pHeight -= (sBevel - *pInvertWidth);
1301 * Adjust the beveling on the other sides of the
1307 /* west and north sides */
1308 if (exBevel > *pInvertWidth)
1310 tmp = exBevel - *pInvertWidth;
1318 if (wBevel > *pInvertWidth)
1320 *pWidth -= (wBevel - *pInvertWidth);
1326 if (wBevel > *pInvertWidth)
1328 tmp = wBevel - *pInvertWidth;
1334 if (exBevel > *pInvertWidth)
1336 tmp = exBevel - *pInvertWidth;
1342 if (eBevel > *pInvertWidth)
1344 *pWidth -= eBevel - *pInvertWidth;
1348 case FRAME_MINIMIZE:
1350 if (exBevel > *pInvertWidth)
1352 tmp = exBevel - *pInvertWidth;
1358 if (eBevel > *pInvertWidth)
1360 tmp = eBevel - *pInvertWidth;
1366 if (meBevel > *pInvertWidth)
1368 *pWidth -= meBevel - *pInvertWidth;
1372 case FRAME_MAXIMIZE:
1373 /* north and east sides */
1374 if (exBevel > *pInvertWidth)
1376 tmp = exBevel - *pInvertWidth;
1383 if (eBevel > *pInvertWidth)
1385 tmp = eBevel - *pInvertWidth;
1391 } /* end case "title bar part" */
1406 /*************************************<->*************************************
1408 * SetFrameInfo (pcd)
1413 * Sets frame information into client data structure for easy access.
1418 * pcd - pointer to client data
1425 * o Sets values into the FrameInfo component of the client data structure
1427 *************************************<->***********************************/
1428 void SetFrameInfo (ClientData *pcd)
1432 * The title bar height value stored in pcd->frameInfo is used by the
1433 * macro TitleBarHeight(pcd).
1436 pcd->frameInfo.titleBarHeight = InitTitleBarHeight (pcd);
1438 pcd->frameInfo.x = FrameX (pcd);
1439 pcd->frameInfo.y = FrameY (pcd);
1440 pcd->frameInfo.width = FrameWidth (pcd);
1441 pcd->frameInfo.height = FrameHeight (pcd);
1442 pcd->frameInfo.upperBorderWidth = UpperBorderWidth (pcd);
1443 pcd->frameInfo.lowerBorderWidth = LowerBorderWidth (pcd);
1444 pcd->frameInfo.cornerWidth = CornerWidth (pcd);
1445 pcd->frameInfo.cornerHeight = CornerHeight (pcd);
1447 /* set client offset */
1449 if ( (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER)) ||
1450 (pcd->matteWidth > 0) )
1453 * The window has a window manager border.
1455 pcd->clientOffset.x = pcd->frameInfo.lowerBorderWidth +
1457 pcd->clientOffset.y = pcd->frameInfo.upperBorderWidth +
1458 pcd->frameInfo.titleBarHeight +
1464 * No window manager border, the original X border is showing
1467 pcd->clientOffset.x = pcd->xBorderWidth + pcd->matteWidth;
1468 pcd->clientOffset.y = pcd->xBorderWidth +
1469 pcd->frameInfo.titleBarHeight +
1477 /*************************************<->*************************************
1479 * SetClientOffset (pcd)
1484 * Sets the client offset into client data structure
1489 * pcd - pointer to client data
1496 * This can be called before SetFrameInfo to set up the client offset
1497 * without the danger of using uninitialized variables during
1498 * extraneous computation.
1500 *************************************<->***********************************/
1501 void SetClientOffset (ClientData *pcd)
1504 * The title bar height value stored in pcd->frameInfo is used by the
1505 * macro TitleBarHeight(pcd).
1508 pcd->frameInfo.titleBarHeight = InitTitleBarHeight (pcd);
1510 pcd->frameInfo.upperBorderWidth = UpperBorderWidth (pcd);
1511 pcd->frameInfo.lowerBorderWidth = LowerBorderWidth (pcd);
1513 /* set client offset */
1515 if ( (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER)) ||
1516 (pcd->matteWidth > 0) )
1519 * The window has a window manager border.
1521 pcd->clientOffset.x = pcd->frameInfo.lowerBorderWidth +
1523 pcd->clientOffset.y = pcd->frameInfo.upperBorderWidth +
1524 pcd->frameInfo.titleBarHeight +
1530 * No window manager border, the original X border is showing
1533 pcd->clientOffset.x = pcd->xBorderWidth + pcd->matteWidth;
1534 pcd->clientOffset.y = pcd->xBorderWidth +
1535 pcd->frameInfo.titleBarHeight +
1542 /*************************************<->*************************************
1544 * XBorderIsShowing (pcd)
1549 * Returns true if the X border is showing.
1554 * pcd - pointer to client data
1558 * XBorderIsShowing - True if no window manager border & x border is
1559 * visible, False otherwise
1564 *************************************<->***********************************/
1565 Boolean XBorderIsShowing (ClientData *pcd)
1569 if ( (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER)) ||
1570 (pcd->matteWidth > 0) )
1572 rval = False; /* hidden by window manager */
1576 rval = True; /* it's showing */