Use C++ linker
[oweals/cde.git] / cde / programs / dtwm / WmCDInfo.c
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 librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* 
24  * (c) Copyright 1989, 1990, 1991, 1992, 1993 OPEN SOFTWARE FOUNDATION, INC. 
25  * ALL RIGHTS RESERVED 
26 */ 
27 /* 
28  * Motif Release 1.2.3
29 */ 
30 #ifdef REV_INFO
31 #ifndef lint
32 static char rcsid[] = "$XConsortium: WmCDInfo.c /main/4 1995/11/01 11:32:15 rswiston $"
33 #endif
34 #endif
35 /*
36  * (c) Copyright 1987, 1988, 1989, 1990 HEWLETT-PACKARD COMPANY */
37
38 /*
39  * Included Files:
40  */
41
42 #include "WmGlobal.h"
43 #include "WmCDInfo.h"
44
45
46 \f
47 /*************************************<->*************************************
48  *
49  *  unsigned int TitleTextHeight (pcd)
50  *
51  *
52  *  Description:
53  *  -----------
54  *  Returns the height of the title text plus padding
55  *
56  *  Inputs:
57  *  ------
58  *  pcd                 - pointer to client data record
59  * 
60  *  Outputs:
61  *  -------
62  *  TitleTextHeight     -  Height of title text plus padding
63  *
64  *  Comments:
65  *  --------
66  * 
67  *************************************<->***********************************/
68 unsigned int TitleTextHeight (ClientData *pcd)
69 {
70     unsigned int ttextheight;
71
72 #ifndef NO_MULTIBYTE
73     if (DECOUPLE_TITLE_APPEARANCE(pcd))
74     {
75         ttextheight = CLIENT_TITLE_APPEARANCE(pcd).titleHeight;
76     }
77     else
78     {
79         ttextheight = CLIENT_APPEARANCE(pcd).titleHeight;
80     }
81 #else
82
83     XFontStruct *font;
84
85     if (DECOUPLE_TITLE_APPEARANCE(pcd))
86     {
87         font = CLIENT_TITLE_APPEARANCE(pcd).font;
88     }
89     else 
90     {
91         font = CLIENT_APPEARANCE(pcd).font;
92     }
93
94     if (font)
95     {
96         ttextheight = TEXT_HEIGHT(font) + WM_TITLE_BAR_PADDING;
97     }
98     else
99     {
100         /* 
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.
104          *
105          */
106         ttextheight = 16; 
107     }
108 #endif
109     return (ttextheight);
110 }
111
112 \f
113 /*************************************<->*************************************
114  *
115  *  unsigned int InitTitleBarHeight (pcd)
116  *
117  *
118  *  Description:
119  *  -----------
120  *  Used to initialize pCD->frameInfo.titleBarHeight which is used by the new
121  *  macro TitleBarHeight().  Returns the height of the title bar.
122  *
123  *  Inputs:
124  *  ------
125  *  pcd                 - pointer to client data record
126  * 
127  *  Outputs:
128  *  -------
129  *  InitTitleBarHeight  -  height of title bar, 0 if no title bar.
130  *
131  *  Comments:
132  *  --------
133  * 
134  *************************************<->***********************************/
135 unsigned int InitTitleBarHeight (ClientData *pcd)
136 {
137     unsigned int tbarheight;
138
139     if (pcd->decor & MWM_DECOR_TITLE)
140     {
141         tbarheight = TitleTextHeight(pcd);
142     }
143     else
144     {
145         tbarheight = 0;
146     }
147
148     return (tbarheight);
149 }
150
151 \f
152 /*************************************<->*************************************
153  *
154  *  unsigned int UpperBorderWidth (pcd)
155  *
156  *
157  *  Description:
158  *  -----------
159  *  Returns the width of the upper frame border
160  *
161  *  Inputs:
162  *  ------
163  *  pcd                 - pointer to client data record
164  * 
165  *  Outputs:
166  *  -------
167  *  UpperBorderWidth    - width of the upper frame border
168  *
169  *  Comments:
170  *  --------
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.
174  * 
175  *************************************<->***********************************/
176 unsigned int UpperBorderWidth (ClientData *pcd)
177 {
178     unsigned int uswidth;
179     unsigned int decoration = pcd->decor;
180
181     if (decoration & MWM_DECOR_RESIZEH)
182     {
183         uswidth = RESIZE_BORDER_WIDTH(pcd);
184     }
185     else if (decoration & MWM_DECOR_BORDER)
186     {
187         uswidth = FRAME_BORDER_WIDTH(pcd);
188 #ifdef PANELIST
189         if((pcd->clientFlags & FRONT_PANEL_BOX) &&
190            (uswidth > 0))
191         {
192             uswidth -= 1;
193         }
194 #endif /* PANELIST */
195     }
196     else if ((decoration & MWM_DECOR_TITLE) ||
197              (pcd->matteWidth > 0))
198     {
199         uswidth = 0;
200     }
201     else
202     {
203         uswidth = pcd->xBorderWidth;
204     }
205
206     return (uswidth);
207 }
208
209 \f
210 /*************************************<->*************************************
211  *
212  *  unsigned int LowerBorderWidth (pcd)
213  *
214  *
215  *  Description:
216  *  -----------
217  *  Returns the width of the lower frame border
218  *
219  *  Inputs:
220  *  ------
221  *  pcd                 - pointer to client data record
222  * 
223  *  Outputs:
224  *  -------
225  *  LowerBorderWidth    - width of the lower frame border
226  *
227  *  Comments:
228  *  --------
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.
232  * 
233  *************************************<->***********************************/
234 unsigned int LowerBorderWidth (ClientData *pcd)
235 {
236     unsigned int lswidth;
237     unsigned int decoration = pcd->decor;
238
239     if (decoration & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
240     {
241         if ((pcd->matteWidth == 0) && (decoration & MWM_DECOR_TITLE) &&
242                 (wmGD.frameStyle == WmRECESSED))
243             lswidth = UpperBorderWidth (pcd) + 
244                       (pcd->internalBevel - JOIN_BEVEL(pcd));
245         else
246             lswidth = UpperBorderWidth (pcd);
247     }
248     else if (pcd->matteWidth > 0)
249     {
250         lswidth = 0;
251     }
252     else
253     {
254         lswidth = pcd->xBorderWidth;
255     }
256
257     return (lswidth);
258 }
259
260 \f
261 /*************************************<->*************************************
262  *
263  *  unsigned int FrameWidth (pcd)
264  *
265  *
266  *  Description:
267  *  -----------
268  *  Returns the width of the frame
269  *
270  *  Inputs:
271  *  ------
272  *  pcd                 - pointer to client data record
273  * 
274  *  Outputs:
275  *  -------
276  *  FrameWidth  - width of frame
277  *
278  *  Comments:
279  *  --------
280  * 
281  *************************************<->***********************************/
282 unsigned int FrameWidth (ClientData *pcd)
283 {
284     unsigned int frameWidth;
285
286     frameWidth = ((pcd->maxConfig) ? pcd->maxWidth : pcd->clientWidth) +
287                   2*pcd->matteWidth + 2*LowerBorderWidth (pcd);
288
289     return (frameWidth);
290 }
291
292 \f
293 /*************************************<->*************************************
294  *
295  *  unsigned int CornerWidth (pcd)
296  *
297  *
298  *  Description:
299  *  -----------
300  *  Returns the width of the corner frame resize handle
301  *
302  *  Inputs:
303  *  ------
304  *  pcd                 - pointer to client data record
305  * 
306  *  Outputs:
307  *  -------
308  *  CornerWidth - width of the corner resize handle
309  *
310  *  Comments:
311  *  --------
312  * 
313  *************************************<->***********************************/
314 unsigned int CornerWidth (ClientData *pcd)
315 {
316     unsigned int cwidth;
317     unsigned int frameWidth = FrameWidth (pcd);
318
319     /* adjust for resize border (default border if no resize wanted) */
320     if (pcd->decor & MWM_DECOR_RESIZEH)
321     {
322         /* corner size is driven by title bar height */
323         cwidth = TitleTextHeight(pcd) + UpperBorderWidth (pcd);
324
325         /* scale down corners to make resize pieces proportional */
326         if (3*cwidth > frameWidth) cwidth = frameWidth / 3;
327     }
328     else {
329         /* no resizing functions */
330         cwidth = 0;
331     }
332
333     return (cwidth);
334 }
335
336 \f
337 /*************************************<->*************************************
338  *
339  *  unsigned int FrameHeight (pcd)
340  *
341  *
342  *  Description:
343  *  -----------
344  *  Returns the height of the frame
345  *
346  *  Inputs:
347  *  ------
348  *  pcd                 - pointer to client data record
349  * 
350  *  Outputs:
351  *  -------
352  *  FrameHeight -  position of frame
353  *
354  *  Comments:
355  *  --------
356  * 
357  *************************************<->***********************************/
358 unsigned int FrameHeight (ClientData *pcd)
359 {
360     unsigned int frameHeight;
361
362     if (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
363     {
364         frameHeight = ((pcd->maxConfig) ? 
365                           pcd->maxHeight : pcd->clientHeight) +
366                       2*pcd->matteWidth + LowerBorderWidth (pcd) + 
367                       UpperBorderWidth (pcd) + TitleBarHeight(pcd);
368     }
369     else 
370     {
371         frameHeight = ((pcd->maxConfig) ? 
372                           pcd->maxHeight : pcd->clientHeight) +
373                       2*pcd->matteWidth + 2*LowerBorderWidth (pcd) + 
374                       TitleBarHeight(pcd);
375     }
376
377     return (frameHeight);
378 }
379
380 \f
381 /*************************************<->*************************************
382  *
383  *  unsigned int CornerHeight (pcd)
384  *
385  *
386  *  Description:
387  *  -----------
388  *  Returns the height of the corner frame resize handle
389  *
390  *  Inputs:
391  *  ------
392  *  pcd                 - pointer to client data record
393  * 
394  *  Outputs:
395  *  -------
396  *  CornerHeight        - Height of the corner resize handle
397  *
398  *  Comments:
399  *  --------
400  * 
401  *************************************<->***********************************/
402 unsigned int CornerHeight (ClientData *pcd)
403 {
404     unsigned int cheight;
405     unsigned int frameHeight = FrameHeight (pcd);
406
407     /* adjust for resize border (default border if no resize wanted) */
408     if (pcd->decor & MWM_DECOR_RESIZEH)
409     {
410         /* corner size is driven by title bar height */
411         cheight = TitleTextHeight(pcd) + UpperBorderWidth (pcd);
412
413         /* scale down corners to make resize pieces proportional */
414         if (3*cheight > frameHeight) cheight = frameHeight / 3;
415     }
416     else {
417         /* produce default border with no resizing functions */
418         cheight = 0;
419     }
420
421     return (cheight);
422 }
423
424 \f
425 /*************************************<->*************************************
426  *
427  *  int BaseWindowX (pcd)
428  *
429  *
430  *  Description:
431  *  -----------
432  *  Returns the X coord of the base window in the frame
433  *
434  *  Inputs:
435  *  ------
436  *  pcd                 - pointer to client data record
437  * 
438  *  Outputs:
439  *  -------
440  *  BaseWindowX
441  *
442  *  Comments:
443  *  --------
444  * 
445  *************************************<->***********************************/
446 int BaseWindowX (ClientData *pcd)
447 {
448     int rval;
449
450     if (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
451         rval = LowerBorderWidth(pcd);
452     else
453         rval = 0;
454     
455     return (rval);
456 }
457
458 \f
459 /*************************************<->*************************************
460  *
461  *  int BaseWindowY (pcd)
462  *
463  *
464  *  Description:
465  *  -----------
466  *  Returns the Y coord of the base window in the frame
467  *
468  *  Inputs:
469  *  ------
470  *  pcd                 - pointer to client data record
471  * 
472  *  Outputs:
473  *  -------
474  *  BaseWindowY
475  *
476  *  Comments:
477  *  --------
478  * 
479  *************************************<->***********************************/
480 int BaseWindowY (ClientData *pcd)
481 {
482     int rval;
483
484     if (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
485         rval = UpperBorderWidth (pcd) + TitleBarHeight(pcd);
486     else
487         rval = TitleBarHeight(pcd);
488     
489     return (rval);
490 }
491
492
493 \f
494 /*************************************<->*************************************
495  *
496  *  int FrameX (pcd)
497  *
498  *
499  *  Description:
500  *  -----------
501  *  Returns the X-coordinate of the frame for the window
502  *
503  *  Inputs:
504  *  ------
505  *  pcd                 - pointer to client data record
506  * 
507  *  Outputs:
508  *  -------
509  *  FrameX              - X position of frame
510  *
511  *  Comments:
512  *  --------
513  * 
514  *************************************<->***********************************/
515 int FrameX (ClientData *pcd)
516 {
517     int frameX;
518
519     frameX = ((pcd->maxConfig) ? pcd->maxX : pcd->clientX)
520              - LowerBorderWidth (pcd)  - pcd->matteWidth;
521
522     return (frameX);
523 }
524
525 \f
526 /*************************************<->*************************************
527  *
528  *  int FrameY (pcd)
529  *
530  *
531  *  Description:
532  *  -----------
533  *  Returns the Y-coordinate of the frame for the window
534  *
535  *  Inputs:
536  *  ------
537  *  pcd                 - pointer to client data record
538  * 
539  *  Outputs:
540  *  -------
541  *  FrameY              - Y position of frame
542  *
543  *  Comments:
544  *  --------
545  * 
546  *************************************<->***********************************/
547 int FrameY (ClientData *pcd)
548 {
549     int frameY;
550
551     frameY = ((pcd->maxConfig) ? pcd->maxY : pcd->clientY) 
552          - UpperBorderWidth (pcd) 
553          - TitleBarHeight (pcd) - pcd->matteWidth;
554
555     if ((pcd->decor & MWM_DECOR_TITLE) && 
556         !(pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER)) &&
557         !(pcd->matteWidth))
558     {
559         frameY -= pcd->xBorderWidth;
560     }
561
562     return (frameY);
563 }
564
565 \f
566 /*************************************<->*************************************
567  *
568  *  unsigned int BaseWindowWidth (pcd)
569  *
570  *
571  *  Description:
572  *  -----------
573  *  Returns the width of the base window 
574  *
575  *  Inputs:
576  *  ------
577  *  pcd                 - pointer to client data record
578  * 
579  *  Outputs:
580  *  -------
581  *  BaseWindowWidth
582  *
583  *  Comments:
584  *  --------
585  *  o Based on code taken out of FrameWidth to make it a little 
586  *    more efficient.
587  * 
588  *************************************<->***********************************/
589 unsigned int BaseWindowWidth (ClientData *pcd)
590 {
591     unsigned int rval;
592
593     if (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
594     {
595         /*
596          *  rval = FrameWidth(pcd) - 2*LowerBorderWidth(pcd);
597          */
598
599         rval = ((pcd->maxConfig) ? pcd->maxWidth : pcd->clientWidth) +
600                   2*pcd->matteWidth;
601     }
602     else
603     {
604         /*
605          *  rval = FrameWidth(pcd);
606          */
607         rval = ((pcd->maxConfig) ? pcd->maxWidth : pcd->clientWidth) +
608                   2*pcd->matteWidth + 2*LowerBorderWidth (pcd);
609     }
610     
611     return (rval);
612 }
613
614
615 \f
616 /*************************************<->*************************************
617  *
618  *  unsigned int BaseWindowHeight (pcd)
619  *
620  *
621  *  Description:
622  *  -----------
623  *  Returns the height of the base window 
624  *
625  *  Inputs:
626  *  ------
627  *  pcd                 - pointer to client data record
628  * 
629  *  Outputs:
630  *  -------
631  *  BaseWindowHeight
632  *
633  *  Comments:
634  *  --------
635  *  o Based on code taken out of FrameHeight to make it a little 
636  *    more efficient.
637  * 
638  *************************************<->***********************************/
639 unsigned int BaseWindowHeight (ClientData *pcd)
640 {
641     unsigned int rval;
642
643     if (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
644     {
645
646         /* 
647          *  rval = FrameHeight(pcd) - LowerBorderWidth(pcd) - 
648          *             UpperBorderWidth(pcd) - TitleBarHeight(pcd);
649          */
650
651         rval = ((pcd->maxConfig) ? pcd->maxHeight : pcd->clientHeight) +
652                       2*pcd->matteWidth;
653     }
654     else
655     {
656         /* 
657          *  rval = FrameHeight(pcd) - TitleBarHeight(pcd); 
658          */
659
660         rval = ((pcd->maxConfig) ? pcd->maxHeight : pcd->clientHeight) +
661                       2*pcd->matteWidth + 2*LowerBorderWidth (pcd);
662     }
663     
664     return (rval);
665 }
666
667
668 \f
669 /*************************************<->*************************************
670  *
671  *  Boolean GetFramePartInfo (pcd, part, pX, pY, pWidth, pHeight)
672  *
673  *
674  *  Description:
675  *  -----------
676  *  Gets frame relative position and size of the specified frame part
677  *
678  *
679  *  Inputs:
680  *  ------
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
687  *
688  * 
689  *  Outputs:
690  *  -------
691  *  Return      - True if values returned, false if no such part for this
692  *                frame (values undefined).
693  *
694  *
695  *  Comments:
696  *  --------
697  * 
698  *************************************<->***********************************/
699 Boolean GetFramePartInfo (ClientData *pcd, int part, int *pX, int *pY, unsigned int *pWidth, unsigned int *pHeight)
700 {
701     unsigned int boxdim = TitleBarHeight (pcd);
702     unsigned long decor = pcd->decor;
703     int vert, horiz;
704     Boolean rval = FALSE;
705     
706     switch (part) 
707     {
708         case FRAME_SYSTEM:
709                 if (decor & MWM_DECOR_MENU) {
710                     *pX = pcd->frameInfo.upperBorderWidth;
711                     *pY = pcd->frameInfo.upperBorderWidth;
712                     *pWidth = boxdim;
713                     *pHeight = boxdim;
714                     rval = TRUE;
715                 }
716                 break;
717
718         case FRAME_TITLE:
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);
728                     *pHeight = boxdim;
729                     rval = TRUE;
730                 }
731                 break;
732 #ifdef WSM
733
734         case FRAME_TITLEBAR:
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;
740                     *pHeight = boxdim;
741                     rval = TRUE;
742                 }
743                 break;
744 #endif /* WSM */
745
746         case FRAME_MINIMIZE:
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;
752                     *pWidth= boxdim;
753                     *pHeight = boxdim;
754                     rval = TRUE;
755                 }
756                 break;
757
758         case FRAME_MAXIMIZE:
759                 if (decor & MWM_DECOR_MAXIMIZE) {
760                     *pX = pcd->frameInfo.width - 
761                             pcd->frameInfo.upperBorderWidth - boxdim;
762                     *pY = pcd->frameInfo.upperBorderWidth;
763                     *pWidth = boxdim;
764                     *pHeight = boxdim;
765                     rval = TRUE;
766                 }
767                 break;
768
769         /*
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
775          */
776         case FRAME_RESIZE_NW:
777                 if (decor & MWM_DECOR_RESIZEH) {
778                     *pX = 0;
779                     *pY = 0;
780
781                     if ((int)pcd->frameInfo.cornerWidth > 
782                             (int)pcd->frameInfo.lowerBorderWidth+2) {
783                         *pWidth = pcd->frameInfo.cornerWidth;
784                     }
785                     else {
786                         horiz = pcd->frameInfo.width - 
787                                 2*pcd->frameInfo.cornerWidth;
788                         *pWidth = pcd->frameInfo.cornerWidth + 
789                                 horiz/2 + horiz%2;
790                     }
791
792                     if ((int)pcd->frameInfo.cornerHeight > 
793                             (int)pcd->frameInfo.lowerBorderWidth+2) {
794                         *pHeight = pcd->frameInfo.cornerHeight;
795                     }
796                     else {
797                         vert = pcd->frameInfo.height - 
798                                 2*pcd->frameInfo.cornerHeight;
799                         *pHeight = pcd->frameInfo.cornerHeight + 
800                                 vert/2 + vert%2;
801                     }
802                     rval = TRUE;
803                 }
804                 break;
805             
806         case FRAME_RESIZE_N:
807                 if (decor & MWM_DECOR_RESIZEH) {
808                     *pX = pcd->frameInfo.cornerWidth;
809                     *pY = 0;
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;
815                     }
816                     else {
817                         *pWidth = 0;
818                     }
819                     rval = TRUE;
820                 }
821                 break;
822             
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;
828                     }
829                     else {
830                         horiz = pcd->frameInfo.width - 
831                             2*pcd->frameInfo.cornerWidth;
832                         *pWidth = pcd->frameInfo.cornerWidth + horiz/2;
833                     }
834                     *pX = pcd->frameInfo.width - *pWidth;
835
836                     if ((int)pcd->frameInfo.cornerHeight > 
837                            (int)pcd->frameInfo.lowerBorderWidth+2) {
838                         *pHeight = pcd->frameInfo.cornerHeight;
839                     }
840                     else {
841                         vert = pcd->frameInfo.height - 
842                                 2*pcd->frameInfo.cornerHeight;
843                         *pHeight = pcd->frameInfo.cornerHeight + 
844                                 vert/2 + vert%2;
845                     }
846                     *pY = 0;
847                     rval = TRUE;
848                 }
849                 break;
850             
851         case FRAME_RESIZE_E:
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;
861                     }
862                     else {
863                         *pHeight = 0;
864                     }
865                     rval = TRUE;
866                 }
867                 break;
868             
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;
874                     }
875                     else {
876                         horiz = pcd->frameInfo.width - 
877                                 2*pcd->frameInfo.cornerWidth;
878                         *pWidth = pcd->frameInfo.cornerWidth + horiz/2;
879                     }
880                     *pX = pcd->frameInfo.width - *pWidth;
881
882                     if ((int)pcd->frameInfo.cornerHeight > 
883                             (int)pcd->frameInfo.lowerBorderWidth+2) {
884                         *pHeight = pcd->frameInfo.cornerHeight;
885                     }
886                     else {
887                         vert = pcd->frameInfo.height - 
888                                 2*pcd->frameInfo.cornerHeight;
889                         *pHeight = pcd->frameInfo.cornerHeight + vert/2;
890                     }
891                     *pY = pcd->frameInfo.height - *pHeight;
892                     rval = TRUE;
893                 }
894                 break;
895             
896         case FRAME_RESIZE_S:
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;
905                     }
906                     else {
907                         *pWidth = 0;
908                     }
909                     *pHeight = pcd->frameInfo.lowerBorderWidth;
910                     rval = TRUE;
911                 }
912                 break;
913             
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;
919                     }
920                     else {
921                         horiz = pcd->frameInfo.width - 
922                                 2*pcd->frameInfo.cornerWidth;
923                         *pWidth = pcd->frameInfo.cornerWidth + 
924                                 horiz/2 + horiz%2;
925                     }
926                     *pX = 0;
927
928                     if ((int)pcd->frameInfo.cornerHeight > 
929                             (int)pcd->frameInfo.lowerBorderWidth+2) {
930                         *pHeight = pcd->frameInfo.cornerHeight;
931                     }
932                     else {
933                         vert = pcd->frameInfo.height - 
934                                 2*pcd->frameInfo.cornerHeight;
935                         *pHeight = pcd->frameInfo.cornerHeight + vert/2;
936                     }
937                     *pY = pcd->frameInfo.height - *pHeight;
938                     rval = TRUE;
939                 }
940                 break;
941             
942         case FRAME_RESIZE_W:
943                 if (decor & MWM_DECOR_RESIZEH) {
944                     *pX = 0;
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;
951                     }
952                     else {
953                         *pHeight = 0;
954                     }
955                     rval = TRUE;
956                 }
957                 break;
958             
959         default:
960                 break;
961     }
962     return(rval);
963 }
964
965
966 \f
967 /*************************************<->*************************************
968  *
969  *  IdentifyFramePart (pCD, x, y)
970  *
971  *
972  *  Description:
973  *  -----------
974  *  Returns an ID representing which part of the frame received the event
975  *
976  *
977  *  Inputs:
978  *  ------
979  *  pCD         - pointer to client data
980  *
981  *  x, y        - client coordinates of event
982  *
983  * 
984  *  Outputs:
985  *  -------
986  *  Return      - ID of frame part where the button event occurred.
987  *
988  *
989  *  Comments:
990  *  --------
991  *************************************<->***********************************/
992
993 int IdentifyFramePart (ClientData *pCD, int x, int y)
994 {
995     unsigned long decor = pCD->decor;
996     int clientWidth = (pCD->maxConfig) ? pCD->maxWidth : pCD->clientWidth;
997     int clientHeight= (pCD->maxConfig) ? pCD->maxHeight : pCD->clientHeight;
998     int rval;
999
1000
1001     /* check for client window */
1002
1003     if ( (x >= pCD->clientOffset.x) &&
1004          (x <  pCD->clientOffset.x + clientWidth) &&
1005          (y >= pCD->clientOffset.y) &&
1006          (y <  pCD->clientOffset.y + clientHeight) )
1007     {
1008         return (FRAME_CLIENT);
1009     }
1010
1011
1012     /* check for client matte */
1013
1014     if (pCD->matteWidth)
1015     {
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) )
1020         {
1021             return (FRAME_MATTE);
1022         }
1023     }
1024
1025
1026     /* check title bar */
1027
1028     if (decor & MWM_DECOR_TITLE)
1029     {
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) )
1034         {
1035             return(GadgetID(x, y, pCD->pTitleGadgets, 
1036                             (unsigned int)pCD->cTitleGadgets));
1037         }
1038     }
1039
1040
1041     /* try resize border */
1042
1043     if (decor & MWM_DECOR_RESIZEH)
1044     {
1045         rval = GadgetID(x, y, pCD->pResizeGadgets, STRETCH_COUNT);
1046     }
1047     else
1048     {
1049         rval = FRAME_NONE;
1050     }
1051
1052
1053     /* if not a resize border, but still in bounds return FRAME_NBORDER */
1054
1055     if (rval == FRAME_NONE)
1056     {
1057         if ((x >= 0) && (y >= 0) &&
1058             (x < FrameWidth (pCD)) && (y < FrameHeight (pCD))) 
1059         {
1060             rval = FRAME_NBORDER;
1061         }
1062     }
1063
1064     return (rval);
1065
1066 } /* END OF FUNCTION IdentifyFramePart */
1067
1068
1069
1070 \f
1071 /*************************************<->*************************************
1072  *
1073  *  GadgetID (x, y, pgadget, count)
1074  *
1075  *
1076  *  Description:
1077  *  -----------
1078  *  returns the id of the gadget in the list that the event occured in
1079  *
1080  *
1081  *  Inputs:
1082  *  ------
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
1087  * 
1088  *  Outputs:
1089  *  -------
1090  *  Return      - ID of gadget if found, FRAME_NONE if not found
1091  *
1092  *
1093  *  Comments:
1094  *  --------
1095  *  
1096  * 
1097  *************************************<->***********************************/
1098 int GadgetID (int x, int y, GadgetRectangle *pgadget, unsigned int count)
1099 {
1100     int ix;
1101
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);
1108         }
1109     }
1110     return(FRAME_NONE);
1111 }
1112
1113
1114
1115 \f
1116 /*************************************<->*************************************
1117  *
1118  *  FrameToClient (pcd, pX, pY, pWidth, pHeight)
1119  *
1120  *
1121  *  Description:
1122  *  -----------
1123  *  Converts frame position and size to client position and size
1124  *
1125  *
1126  *  Inputs:
1127  *  ------
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
1133  * 
1134  *  Outputs:
1135  *  -------
1136  *  *pX         - client x-coord
1137  *  *pY         - client y-coord
1138  *  *pWidth     - client width in pixels
1139  *  *pHeight    - client height in pixels
1140  *
1141  *
1142  *  Comments:
1143  *  --------
1144  * 
1145  *************************************<->***********************************/
1146 void FrameToClient (ClientData *pcd, int *pX, int *pY, unsigned int *pWidth, unsigned int *pHeight)
1147 {
1148     /* compute client window coordinates from frame coordinates */
1149
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;
1154 }
1155
1156 \f
1157 /*************************************<->*************************************
1158  *
1159  *  ClientToFrame (pcd, pX, pY, pWidth, pHeight)
1160  *
1161  *
1162  *  Description:
1163  *  -----------
1164  *  Converts frame position and size to client position and size
1165  *
1166  *
1167  *  Inputs:
1168  *  ------
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
1174  * 
1175  *  Outputs:
1176  *  -------
1177  *  *pX         - frame x-coord
1178  *  *pY         - frame y-coord
1179  *  *pWidth     - frame width in pixels
1180  *  *pHeight    - frame height in pixels
1181  *
1182  *
1183  *  Comments:
1184  *  --------
1185  * 
1186  *************************************<->***********************************/
1187 void ClientToFrame (ClientData *pcd, int *pX, int *pY, unsigned int *pWidth, unsigned int *pHeight)
1188 {
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;
1194 }
1195
1196
1197 \f
1198 /*************************************<->*************************************
1199  *
1200  *  Boolean GetDepressInfo (pcd, part, pX, pY, pWidth, pHeight)
1201  *
1202  *
1203  *  Description:
1204  *  -----------
1205  *  Gets frame relative position, size, and width of the beveling 
1206  *  to show the gadget in its depressed state.
1207  *
1208  *
1209  *  Inputs:
1210  *  ------
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
1218  *
1219  * 
1220  *  Outputs:
1221  *  -------
1222  *  Return      - True if values returned, false if no such part for this
1223  *                frame (values undefined).
1224  *
1225  *
1226  *  Comments:
1227  *  --------
1228  *  o The "part" must be a title bar gadget.
1229  * 
1230  *************************************<->***********************************/
1231 Boolean GetDepressInfo (ClientData *pcd, int part, int *pX, int *pY, unsigned int *pWidth, unsigned int *pHeight, unsigned int *pInvertWidth)
1232 {
1233     Boolean rval;
1234     unsigned int exBevel, eBevel;
1235     unsigned int wBevel, sBevel;
1236     unsigned int insideBevel, meBevel;
1237     unsigned int decoration = pcd->decor;
1238     unsigned int tmp;
1239
1240     switch (part)
1241     {
1242         case FRAME_SYSTEM:
1243         case FRAME_TITLE:
1244         case FRAME_MINIMIZE:
1245         case FRAME_MAXIMIZE:
1246             if ((rval = GetFramePartInfo (pcd, part, pX, pY, pWidth, pHeight)))
1247             {
1248                 /*
1249                  * set bevel width based on join bevel
1250                  */
1251                 *pInvertWidth = 1 + (JOIN_BEVEL(pcd) / 2);
1252                 
1253                 /* bevel between title and client (or matte) */
1254                 insideBevel = (pcd->matteWidth > 0) ?  JOIN_BEVEL(pcd) : 
1255                                                    pcd->internalBevel;
1256
1257
1258                 /*
1259                  * Compute beveling around the title area of the
1260                  * title bar.
1261                  */
1262                 if (decoration & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER))
1263                 {
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 */
1269                 }
1270                 else 
1271                 {
1272                     /* borderless window */
1273
1274                     exBevel = EXTERNAL_BEVEL(pcd);
1275
1276                     sBevel = (pcd->matteWidth > 0) ? insideBevel : 
1277                                                       EXTERNAL_BEVEL(pcd);
1278
1279                     eBevel = (decoration & (MWM_DECOR_MINIMIZE | 
1280                                                  MWM_DECOR_MAXIMIZE))?
1281                                       JOIN_BEVEL(pcd) : EXTERNAL_BEVEL(pcd);
1282
1283                     wBevel = (decoration & MWM_DECOR_MENU) ?
1284                                       JOIN_BEVEL(pcd) : EXTERNAL_BEVEL(pcd);
1285
1286                     meBevel = (decoration & (MWM_DECOR_MAXIMIZE)) ?
1287                                       JOIN_BEVEL(pcd) : EXTERNAL_BEVEL(pcd);
1288                 }
1289
1290                 /*
1291                  * Adjust height of all title bar gadgets if necessary.
1292                  * (The bottom bevel is the same for all the pieces.)
1293                  */
1294
1295                 if (sBevel > *pInvertWidth)
1296                 {
1297                     *pHeight -= (sBevel - *pInvertWidth);
1298                 }
1299
1300                 /*
1301                  * Adjust the beveling on the other sides of the 
1302                  * gadgets.
1303                  */
1304                 switch (part)
1305                 {
1306                     case FRAME_SYSTEM:
1307                         /* west and north sides */
1308                         if (exBevel > *pInvertWidth) 
1309                         {
1310                             tmp = exBevel - *pInvertWidth;
1311                             *pX += tmp;
1312                             *pWidth -= tmp;
1313                             *pY += tmp;
1314                             *pHeight -= tmp;
1315                         }
1316
1317                         /* east side */
1318                         if (wBevel > *pInvertWidth) 
1319                         {
1320                             *pWidth -= (wBevel - *pInvertWidth);
1321                         }
1322                         break;
1323
1324                     case FRAME_TITLE:
1325                         /* west side */
1326                         if (wBevel > *pInvertWidth) 
1327                         {
1328                             tmp = wBevel - *pInvertWidth;
1329                             *pX += tmp;
1330                             *pWidth -= tmp;
1331                         }
1332
1333                         /* north side */
1334                         if (exBevel > *pInvertWidth) 
1335                         {
1336                             tmp = exBevel - *pInvertWidth;
1337                             *pY += tmp;
1338                             *pHeight -= tmp;
1339                         }
1340
1341                         /* east side */
1342                         if (eBevel > *pInvertWidth) 
1343                         {
1344                             *pWidth -= eBevel - *pInvertWidth;
1345                         }
1346                         break;
1347
1348                     case FRAME_MINIMIZE:
1349                         /* north side */
1350                         if (exBevel > *pInvertWidth) 
1351                         {
1352                             tmp = exBevel - *pInvertWidth;
1353                             *pY += tmp;
1354                             *pHeight -= tmp;
1355                         }
1356
1357                         /* west side */
1358                         if (eBevel > *pInvertWidth) 
1359                         {
1360                             tmp = eBevel - *pInvertWidth;
1361                             *pX += tmp;
1362                             *pWidth -= tmp;
1363                         }
1364
1365                         /* east side */
1366                         if (meBevel > *pInvertWidth) 
1367                         {
1368                             *pWidth -= meBevel - *pInvertWidth;
1369                         }
1370                         break;
1371
1372                     case FRAME_MAXIMIZE:
1373                         /* north and east sides */
1374                         if (exBevel > *pInvertWidth) 
1375                         {
1376                             tmp = exBevel - *pInvertWidth;
1377                             *pY += tmp;
1378                             *pHeight -= tmp;
1379                             *pWidth -= tmp;
1380                         }
1381
1382                         /* west side */
1383                         if (eBevel > *pInvertWidth) 
1384                         {
1385                             tmp = eBevel - *pInvertWidth;
1386                             *pX += tmp;
1387                             *pWidth -= tmp;
1388                         }
1389                         break;
1390                 } /* end switch */
1391             } /* end case "title bar part" */   
1392             break;
1393
1394         default:
1395             rval = False;
1396             break;
1397
1398     }   /* end switch */
1399
1400     return (rval);
1401 }
1402
1403
1404
1405 \f
1406 /*************************************<->*************************************
1407  *
1408  *  SetFrameInfo (pcd)
1409  *
1410  *
1411  *  Description:
1412  *  -----------
1413  *  Sets frame information into client data structure for easy access.
1414  *
1415  *
1416  *  Inputs:
1417  *  ------
1418  *  pcd         - pointer to client data
1419  * 
1420  *  Outputs:
1421  *  -------
1422  *
1423  *  Comments:
1424  *  --------
1425  *  o Sets values into the FrameInfo component of the client data structure
1426  * 
1427  *************************************<->***********************************/
1428 void SetFrameInfo (ClientData *pcd)
1429 {
1430
1431     /*
1432      * The title bar height value stored in pcd->frameInfo is used by the
1433      * macro TitleBarHeight(pcd).
1434      */
1435
1436     pcd->frameInfo.titleBarHeight = InitTitleBarHeight (pcd);
1437
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);
1446
1447     /* set client offset */
1448      
1449     if ( (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER)) ||
1450          (pcd->matteWidth > 0) )
1451     {
1452         /*
1453          *  The window has a window manager border.
1454          */
1455         pcd->clientOffset.x = pcd->frameInfo.lowerBorderWidth + 
1456                                   pcd->matteWidth;
1457         pcd->clientOffset.y = pcd->frameInfo.upperBorderWidth + 
1458                                   pcd->frameInfo.titleBarHeight + 
1459                                   pcd->matteWidth;
1460     }
1461     else 
1462     {
1463         /*
1464          * No window manager border, the original X border is showing
1465          * through.
1466          */
1467         pcd->clientOffset.x =  pcd->xBorderWidth + pcd->matteWidth;
1468         pcd->clientOffset.y =  pcd->xBorderWidth + 
1469                                    pcd->frameInfo.titleBarHeight + 
1470                                    pcd->matteWidth;
1471     }
1472
1473 }
1474
1475
1476 \f
1477 /*************************************<->*************************************
1478  *
1479  *  SetClientOffset (pcd)
1480  *
1481  *
1482  *  Description:
1483  *  -----------
1484  *  Sets the client offset into client data structure
1485  *
1486  *
1487  *  Inputs:
1488  *  ------
1489  *  pcd         - pointer to client data
1490  * 
1491  *  Outputs:
1492  *  -------
1493  *
1494  *  Comments:
1495  *  --------
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.
1499  *
1500  *************************************<->***********************************/
1501 void SetClientOffset (ClientData *pcd)
1502 {
1503     /*
1504      * The title bar height value stored in pcd->frameInfo is used by the
1505      * macro TitleBarHeight(pcd).
1506      */
1507
1508     pcd->frameInfo.titleBarHeight = InitTitleBarHeight (pcd);
1509
1510     pcd->frameInfo.upperBorderWidth = UpperBorderWidth (pcd);
1511     pcd->frameInfo.lowerBorderWidth = LowerBorderWidth (pcd);
1512
1513     /* set client offset */
1514      
1515     if ( (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER)) ||
1516          (pcd->matteWidth > 0) )
1517     {
1518         /*
1519          *  The window has a window manager border.
1520          */
1521         pcd->clientOffset.x = pcd->frameInfo.lowerBorderWidth + 
1522                                   pcd->matteWidth;
1523         pcd->clientOffset.y = pcd->frameInfo.upperBorderWidth + 
1524                                   pcd->frameInfo.titleBarHeight + 
1525                                   pcd->matteWidth;
1526     }
1527     else 
1528     {
1529         /*
1530          * No window manager border, the original X border is showing
1531          * through.
1532          */
1533         pcd->clientOffset.x =  pcd->xBorderWidth + pcd->matteWidth;
1534         pcd->clientOffset.y =  pcd->xBorderWidth + 
1535                                    pcd->frameInfo.titleBarHeight + 
1536                                    pcd->matteWidth;
1537     }
1538 }
1539
1540
1541 \f
1542 /*************************************<->*************************************
1543  *
1544  *  XBorderIsShowing (pcd)
1545  *
1546  *
1547  *  Description:
1548  *  -----------
1549  *  Returns true if the X border is showing.
1550  *
1551  *
1552  *  Inputs:
1553  *  ------
1554  *  pcd         - pointer to client data
1555  * 
1556  *  Outputs:
1557  *  -------
1558  *  XBorderIsShowing    - True if no window manager border & x border is 
1559  *                        visible, False otherwise
1560  *
1561  *  Comments:
1562  *  --------
1563  *
1564  *************************************<->***********************************/
1565 Boolean XBorderIsShowing (ClientData *pcd)
1566 {
1567     Boolean rval;
1568
1569     if ( (pcd->decor & (MWM_DECOR_RESIZEH | MWM_DECOR_BORDER)) ||
1570          (pcd->matteWidth > 0) )
1571     {
1572         rval = False;   /* hidden by window manager */
1573     }
1574     else 
1575     {
1576         rval = True;    /* it's showing */
1577     }
1578     return(rval);
1579 }