Use C++ linker
[oweals/cde.git] / cde / programs / dtwm / WmIDecor.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: WmIDecor.c /main/6 1996/06/20 09:38:43 rswiston $"
33 #endif
34 #endif
35 /*
36  * (c) Copyright 1987, 1988, 1989, 1990 HEWLETT-PACKARD COMPANY */
37
38 /*
39  * Included Files:
40  */
41
42
43 #include "WmGlobal.h"
44 #include <Xm/Xm.h>
45 #include <Xm/DrawP.h>           /* for XmeClearBorder */
46 /*
47  * include extern functions
48  */
49 #include "WmIDecor.h"
50 #include "WmError.h"
51 #include "WmGraphics.h"
52 #include "WmIconBox.h"
53 #include "WmMenu.h"
54 #include "WmWinInfo.h"
55 #ifdef WSM
56 #include "WmWrkspace.h"
57 #endif /* WSM */
58
59
60
61 /*
62  * Global Variables:
63  */
64 static unsigned int activeIconTextWidth = 1;
65 static unsigned int activeIconTextHeight = 1;
66 static RList *pActiveIconTopRects = NULL;
67 static RList *pActiveIconBotRects = NULL;
68
69 static int  iconShrinkX; 
70 static int  iconShrinkY;
71 static unsigned int iconShrinkWidth;
72 static unsigned int iconShrinkHeight;
73
74 \f
75 /*************************************<->*************************************
76  *
77  *  MakeIcon (pWS, pcd)
78  *
79  *
80  *  Description:
81  *  -----------
82  *  Create an icon frame and fill it in as appropriate for the client.
83  *
84  *
85  *  Inputs:
86  *  ------
87  *  pWS         - pointer to workspace data
88  *  pcd         - pointer to client data
89  *
90  * 
91  *  Outputs:
92  *  -------
93  *  Return      - TRUE if success, FALSE if failure.
94  *
95  *
96  *  Comments:
97  *  --------
98  *  
99  * 
100  *************************************<->***********************************/
101
102 Boolean MakeIcon (WmWorkspaceData *pWS, ClientData *pcd)
103 {
104     XSetWindowAttributes window_attribs;
105     unsigned long attr_mask;
106     int xOffset;
107     int yOffset;
108 #ifdef WSM
109     WsClientData *pWsc = GetWsClientData (pWS, pcd);
110 #endif /* WSM */
111
112
113     /*
114      * Common to all icons
115      */
116
117     /* compute dimensions of outer icon frame */
118     /* create icon frame window */
119
120     attr_mask = CWEventMask | CWCursor;
121     window_attribs.event_mask = (ButtonPressMask | ButtonReleaseMask |
122                                  SELECT_BUTTON_MOTION_MASK |
123                                  DMANIP_BUTTON_MOTION_MASK |
124                                  ExposureMask |
125                                  SubstructureRedirectMask |
126                                  FocusChangeMask);
127     window_attribs.cursor = wmGD.workspaceCursor;
128
129     if ((wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_POINTER) ||
130         (wmGD.colormapFocusPolicy == CMAP_FOCUS_POINTER))
131     {
132         window_attribs.event_mask |= EnterWindowMask | LeaveWindowMask;
133     }
134
135     /* 
136      * Use background pixmap if one is specified, otherwise set the
137      * appropriate background color. 
138      */
139
140     if (ICON_APPEARANCE(pcd).backgroundPixmap)
141     {
142         attr_mask |= CWBackPixmap;
143         window_attribs.background_pixmap = 
144                             ICON_APPEARANCE(pcd).backgroundPixmap;
145     }
146     else
147     {
148         attr_mask |= CWBackPixel;
149         window_attribs.background_pixel = 
150                                 ICON_APPEARANCE(pcd).background;
151     }
152    
153 #ifdef WSM
154     if ((!pcd->pSD->useIconBox) || 
155         (pcd->clientFlags & (CLIENT_WM_CLIENTS | FRONT_PANEL_BOX)))
156 #else
157     if ((!pcd->pSD->useIconBox) || (pcd->clientFlags & ICON_BOX))
158 #endif /* WSM */
159     {
160 #ifdef WSM
161         pWsc->iconFrameWin = XCreateWindow (DISPLAY,
162                                ROOT_FOR_CLIENT(pcd),    /* parent */
163                                pWsc->iconX,
164                                pWsc->iconY,
165 #else /* WSM */
166         pcd->iconFrameWin = XCreateWindow (DISPLAY,
167                                ROOT_FOR_CLIENT(pcd),    /* parent */
168                                pcd->iconX,
169                                pcd->iconY,
170 #endif /* WSM */
171                                (unsigned int) ICON_WIDTH(pcd),
172                                (unsigned int) ICON_HEIGHT(pcd),
173                                0,               /* border width */
174                                CopyFromParent,  /* depth */
175                                InputOutput,     /* class */
176                                CopyFromParent,  /* visual */
177                                attr_mask,
178                                &window_attribs);
179
180     }
181     else
182     {
183         /*
184          * Insert the icon into the icon box.
185          * Don't make icon in the box for any icon box (or any WM window)
186          * OR any client that doesn't have the MWM_FUNC_MINIMIZE bit set
187          * in pcd->clientFunctions
188          */
189
190         if ((pcd->pSD->useIconBox) && 
191 #ifdef WSM
192             (!(pcd->clientFlags & CLIENT_WM_CLIENTS)) &&
193 #else
194             (!(pcd->clientFlags & ICON_BOX)) &&
195 #endif /* WSM */
196             (pcd->clientFunctions & MWM_FUNC_MINIMIZE) )
197         {
198             if (!InsertIconIntoBox(pWS->pIconBox, pcd))
199                 Warning(((char *)GETMESSAGE(30, 1, "Could not make icon to go in icon box")));
200
201         }
202
203     }
204
205
206     /* make space for the top/bottom changing shadow rectangles */
207
208     if ((pcd->piconTopShadows = 
209             AllocateRList ((unsigned)NUM_BOTH_TOP_RECTS)) == NULL)
210     {
211         /* Out of memory! */
212         Warning (((char *)GETMESSAGE(30, 2, "Insufficient memory for icon creation")));
213         return(FALSE);
214     }
215     
216     if ((pcd->piconBottomShadows = 
217          AllocateRList ((unsigned)NUM_BOTH_BOTTOM_RECTS)) == NULL)
218     {
219         /* Out of memory! */
220         Warning (((char *)GETMESSAGE(30, 3, "Insufficient memory for icon creation")));
221         return(FALSE);
222     }
223
224
225     /*
226      * Adjust for icons in the box 
227      * Don't adjust the icon for the icon box itself
228      */
229
230 #ifdef PANELIST
231     if (pWS->pIconBox && (pWS->pIconBox->pCD_iconBox != pcd) &&
232         !(pcd->clientFlags & FRONT_PANEL_BOX))
233 #else /* PANELIST */
234     if (pWS->pIconBox && (pWS->pIconBox->pCD_iconBox != pcd))
235 #endif /* PANELIST */
236     {
237         xOffset = IB_MARGIN_WIDTH;
238         yOffset = IB_MARGIN_HEIGHT;
239     }
240     else
241     {
242         xOffset = 0;
243         yOffset = 0;
244     }
245
246
247     /*
248      * Reparent the icon window if there is one
249      */
250     if ((ICON_DECORATION(pcd) & ICON_IMAGE_PART) && 
251         (pcd->iconWindow))
252     {
253         ReparentIconWindow (pcd, xOffset, yOffset);
254     }
255
256 #ifdef WSM
257     if (pcd->piconTopShadows->used == 0)
258 #endif /* WSM */
259     MakeIconShadows (pcd, xOffset, yOffset);
260
261     return(TRUE);
262
263 } /* END OF FUNCTION MakeIcon */
264
265
266 \f
267 /*************************************<->*************************************
268  *
269  *  MakeIconShadows (pcd, xOffset, yOffset)
270  *
271  *  Comments:
272  *  --------
273  * 
274  *************************************<->***********************************/
275
276 void MakeIconShadows (ClientData *pcd, int xOffset, int yOffset)
277 {        
278
279     /*
280      * Handle different icon styles
281      */
282     
283     switch (ICON_DECORATION(pcd) & (ICON_LABEL_PART | ICON_IMAGE_PART)) 
284     {
285         case ICON_LABEL_PART:
286             BevelRectangle (pcd->piconTopShadows,       /* label */
287                             pcd->piconBottomShadows, 
288                             0 + xOffset, (int)ICON_IMAGE_HEIGHT(pcd) + yOffset,
289                             (unsigned int) ICON_WIDTH(pcd), 
290                             (unsigned int) ICON_LABEL_HEIGHT(pcd),
291                             ICON_EXTERNAL_SHADOW_WIDTH,
292                             ICON_EXTERNAL_SHADOW_WIDTH,
293                             ICON_EXTERNAL_SHADOW_WIDTH,
294                             ICON_EXTERNAL_SHADOW_WIDTH);
295             break;
296
297         case ICON_IMAGE_PART:
298             BevelRectangle (pcd->piconTopShadows,       /* image outside */
299                             pcd->piconBottomShadows, 
300                             0 + xOffset, 0 + yOffset,
301                             (unsigned int) ICON_WIDTH(pcd), 
302                             (unsigned int) ICON_IMAGE_HEIGHT(pcd),
303                             ICON_EXTERNAL_SHADOW_WIDTH,
304                             ICON_EXTERNAL_SHADOW_WIDTH,
305                             ICON_EXTERNAL_SHADOW_WIDTH,
306                             ICON_EXTERNAL_SHADOW_WIDTH);
307
308             if (wmGD.frameStyle == WmRECESSED)
309                 BevelRectangle (pcd->piconBottomShadows, /* image inside */
310                             pcd->piconTopShadows, 
311                             ICON_INNER_X_OFFSET + xOffset,
312                             ICON_INNER_Y_OFFSET + yOffset,
313                             (unsigned int) (ICON_IMAGE_MAXIMUM(pcd).width + 
314                                 4*ICON_INTERNAL_SHADOW_WIDTH),
315                             (unsigned int) (ICON_IMAGE_MAXIMUM(pcd).height + 
316                                 4*ICON_INTERNAL_SHADOW_WIDTH),
317                             ICON_INTERNAL_SHADOW_WIDTH,
318                             ICON_INTERNAL_SHADOW_WIDTH,
319                             ICON_INTERNAL_SHADOW_WIDTH,
320                             ICON_INTERNAL_SHADOW_WIDTH);
321
322             break;
323
324         case (ICON_IMAGE_PART | ICON_LABEL_PART):
325             if (wmGD.frameStyle == WmSLAB)
326             {
327                 BevelRectangle (pcd->piconTopShadows,   /* image outside */
328                             pcd->piconBottomShadows, 
329                             0 + xOffset, 0 + yOffset,
330                             (unsigned int) ICON_WIDTH(pcd), 
331                             (unsigned int) (ICON_IMAGE_HEIGHT(pcd) +
332                                             ICON_LABEL_HEIGHT(pcd)),
333                             ICON_EXTERNAL_SHADOW_WIDTH,
334                             ICON_EXTERNAL_SHADOW_WIDTH,
335                             ICON_EXTERNAL_SHADOW_WIDTH,
336                             ICON_EXTERNAL_SHADOW_WIDTH);
337             }
338             else
339             {
340                 BevelRectangle (pcd->piconTopShadows,   /* image outside */
341                             pcd->piconBottomShadows, 
342                             0 + xOffset, 0 + yOffset, 
343                             (unsigned int) ICON_WIDTH(pcd), 
344                             (unsigned int) ICON_IMAGE_HEIGHT(pcd),
345                             ICON_EXTERNAL_SHADOW_WIDTH,
346                             ICON_EXTERNAL_SHADOW_WIDTH,
347                             ICON_INTERNAL_SHADOW_WIDTH,
348                             ICON_EXTERNAL_SHADOW_WIDTH);
349             }
350
351             if (wmGD.frameStyle == WmRECESSED)
352                 BevelRectangle (pcd->piconBottomShadows, /* image inside */
353                             pcd->piconTopShadows, 
354                             ICON_INNER_X_OFFSET + xOffset,
355                             ICON_INNER_Y_OFFSET + yOffset,
356                             (unsigned int) (ICON_IMAGE_MAXIMUM(pcd).width + 
357                                 4*ICON_INTERNAL_SHADOW_WIDTH),
358                             (unsigned int) (ICON_IMAGE_MAXIMUM(pcd).height + 
359                                 4*ICON_INTERNAL_SHADOW_WIDTH),
360                             ICON_INTERNAL_SHADOW_WIDTH,
361                             ICON_INTERNAL_SHADOW_WIDTH,
362                             ICON_INTERNAL_SHADOW_WIDTH,
363                             ICON_INTERNAL_SHADOW_WIDTH);
364
365             if (wmGD.frameStyle == WmRECESSED)
366                 BevelRectangle (pcd->piconTopShadows,   /* label */
367                             pcd->piconBottomShadows, 
368                             0 + xOffset, (int)ICON_IMAGE_HEIGHT(pcd) + yOffset,
369                             (unsigned int) ICON_WIDTH(pcd), 
370                             (unsigned int) ICON_LABEL_HEIGHT(pcd),
371                             ICON_INTERNAL_SHADOW_WIDTH,
372                             ICON_EXTERNAL_SHADOW_WIDTH,
373                             ICON_EXTERNAL_SHADOW_WIDTH,
374                             ICON_EXTERNAL_SHADOW_WIDTH);
375
376             break;
377     }
378
379 } /* END OF FUNCTION MakeIconShadows */
380
381
382
383
384
385 \f
386 /*************************************<->*************************************
387  *
388  *  IconExposureProc (pcd, expose)
389  *
390  *
391  *  Description:
392  *  -----------
393  *  Repaint the icon.
394  *
395  *
396  *  Inputs:
397  *  ------
398  *  pcd         - pointer to client data
399  *
400  * 
401  *  Outputs:
402  *  -------
403  *
404  *  Comments:
405  *  --------
406  * 
407  *************************************<->***********************************/
408
409 void IconExposureProc (ClientData *pcd, Boolean expose)
410 {
411
412     Pixmap image;
413     int dest_x, dest_y;
414     int xOffset;
415     int yOffset;
416     unsigned int width, height;
417     GC iconGC, topGC, botGC;
418     static XRectangle   shrinkRects[4];
419
420
421
422     /*
423      * Adjust for icons in the iconBox
424      */
425
426     if (P_ICON_BOX(pcd))
427     {
428         xOffset = IB_MARGIN_WIDTH;
429         yOffset = IB_MARGIN_HEIGHT;
430     }
431     else
432     {
433         xOffset = 0;
434         yOffset = 0;
435     }
436     
437     /* get appropriate GCs */
438
439     if ((wmGD.keyboardFocus == pcd) && (pcd->clientState == MINIMIZED_STATE))
440     {
441         iconGC = ICON_APPEARANCE(pcd).activeGC;
442         topGC = ICON_APPEARANCE(pcd).activeTopShadowGC;
443         botGC = ICON_APPEARANCE(pcd).activeBottomShadowGC;
444     }
445     else
446     {
447         iconGC = ICON_APPEARANCE(pcd).inactiveGC;
448         topGC = ICON_APPEARANCE(pcd).inactiveTopShadowGC;
449         botGC = ICON_APPEARANCE(pcd).inactiveBottomShadowGC;
450     }
451
452     if (ACTIVE_PSD->useIconBox && P_ICON_BOX(pcd))
453     {
454         /* draw shadowing */
455
456         if (expose)
457         {
458             XClearArea (DISPLAY, 
459                             ICON_FRAME_WIN(pcd), 
460                             IB_MARGIN_WIDTH, 
461                             IB_MARGIN_HEIGHT, 
462                             (unsigned int) ICON_WIDTH(pcd), 
463                             (unsigned int) ICON_HEIGHT(pcd), False);
464         }
465
466         if (pcd->clientState == MINIMIZED_STATE)
467         {
468             /*
469              * This is the "raised" icon appearance
470              */
471
472             if (pcd->piconTopShadows)
473             {
474
475                 XFillRectangles (DISPLAY, 
476                                     ICON_FRAME_WIN(pcd), 
477                                     topGC,
478                                     pcd->piconTopShadows->prect,
479                                     pcd->piconTopShadows->used);
480             }
481
482             if (pcd->piconBottomShadows)
483             { 
484                 XFillRectangles (DISPLAY,
485                                     ICON_FRAME_WIN(pcd), 
486                                     botGC,
487                                     pcd->piconBottomShadows->prect,
488                                     pcd->piconBottomShadows->used);
489             }
490         }
491         else 
492         {
493             shrinkRects[0].x = IB_MARGIN_WIDTH;
494             shrinkRects[0].y = IB_MARGIN_HEIGHT;
495             shrinkRects[0].width = (unsigned int) ICON_WIDTH(pcd);
496             shrinkRects[0].height = iconShrinkY - IB_MARGIN_HEIGHT;
497
498             shrinkRects[1].x = IB_MARGIN_WIDTH;
499             shrinkRects[1].y = iconShrinkY;
500             shrinkRects[1].width = iconShrinkX - IB_MARGIN_WIDTH;
501             shrinkRects[1].height = iconShrinkHeight;
502
503             shrinkRects[2].x = iconShrinkX + iconShrinkWidth;
504             shrinkRects[2].y = iconShrinkY;
505             shrinkRects[2].width = iconShrinkX - IB_MARGIN_WIDTH;
506             shrinkRects[2].height = iconShrinkHeight;
507
508             shrinkRects[3].x = IB_MARGIN_WIDTH;
509             shrinkRects[3].y = iconShrinkY + iconShrinkHeight;
510             shrinkRects[3].width = (unsigned int) ICON_WIDTH(pcd);
511             shrinkRects[3].height = iconShrinkY - IB_MARGIN_HEIGHT;
512
513             XFillRectangles (DISPLAY, 
514                             ICON_FRAME_WIN(pcd), 
515                             SHRINK_WRAP_GC(pcd),
516                             &shrinkRects[0], 4);
517                             
518         }
519
520     }
521     else 
522     {
523         /* draw shadowing */
524
525         if (pcd->clientState == MINIMIZED_STATE)
526         {
527             /*
528              * This is the "raised" icon appearance
529              */
530
531             if (pcd->piconTopShadows->prect)
532             {
533
534                 XFillRectangles (DISPLAY, 
535                                 ICON_FRAME_WIN(pcd), 
536                                 topGC,
537                                 pcd->piconTopShadows->prect,
538                                 pcd->piconTopShadows->used);
539             }
540
541             if (pcd->piconBottomShadows->prect)
542             { 
543                 XFillRectangles (DISPLAY,
544                                 ICON_FRAME_WIN(pcd), 
545                                 botGC,
546                                 pcd->piconBottomShadows->prect,
547                                 pcd->piconBottomShadows->used);
548             }
549
550         }
551     }
552
553
554     /* draw icon text */
555 /*
556     if ((ICON_DECORATION(pcd) & ICON_LABEL_PART) &&
557         (expose || !(ICON_DECORATION(pcd) & ICON_ACTIVE_LABEL_PART)))
558 */
559     if (ICON_DECORATION(pcd) & ICON_LABEL_PART)
560     {
561         DrawIconTitle (pcd);
562     }
563
564     /* 
565      * Draw image if no icon window (client has to redraw that!) 
566      *  OR if using the iconbox, draw the default image where
567      *  the icon window was.
568      */
569
570     if (expose &&
571         ((!pcd->iconWindow && (ICON_DECORATION(pcd) & ICON_IMAGE_PART)) ||
572          (ACTIVE_PSD->useIconBox && P_ICON_BOX(pcd) &&
573                 pcd->iconWindow && 
574                 pcd->clientState != MINIMIZED_STATE &&
575                 (ICON_DECORATION(pcd) & ICON_IMAGE_PART))))
576     {
577         if (pcd->iconWindow)
578         {
579             image = DEFAULT_PIXMAP(pcd);
580         }
581         else
582         {
583             image = pcd->iconPixmap;
584         }
585
586         if (image)
587         {
588
589             if ((ACTIVE_PSD->useIconBox) && (P_ICON_BOX(pcd)))
590             {
591
592                 if (pcd->clientState != MINIMIZED_STATE)
593                 {
594                     dest_x = ICON_IMAGE_X_OFFSET 
595                             + ICON_INTERNAL_SHADOW_WIDTH
596                             + xOffset;
597
598                     dest_y = ICON_IMAGE_Y_OFFSET 
599                             + ICON_INTERNAL_SHADOW_WIDTH
600                             + yOffset;
601                     if (wmGD.frameStyle == WmSLAB)
602                     {
603                         /* less beveling in this style */
604                         dest_x -= ICON_INTERNAL_SHADOW_WIDTH;
605                         dest_y -= ICON_INTERNAL_SHADOW_WIDTH;
606                     } 
607
608                     width = ICON_IMAGE_MAXIMUM(pcd).width;
609                     height= ICON_IMAGE_MAXIMUM(pcd).height;
610                     if (wmGD.frameStyle == WmSLAB)
611                     {
612                         width += 2;
613                         height += 2;
614                     } 
615                     XCopyArea (DISPLAY, image, 
616                                 ICON_FRAME_WIN(pcd), 
617                                 iconGC,
618                                 ICON_INTERNAL_SHADOW_WIDTH, 
619                                 ICON_INTERNAL_SHADOW_WIDTH, 
620                                 width, height, dest_x, dest_y);
621
622                     if (FADE_NORMAL_ICON(pcd))
623                     {
624                         iconGC = FADE_ICON_GC(pcd);
625                         XFillRectangle (DISPLAY, 
626                                     ICON_FRAME_WIN(pcd), 
627                                     iconGC,
628                                     dest_x, dest_y,
629                                     width, height);
630                     }
631
632                 }
633                 else
634                 {
635                     dest_x = ICON_IMAGE_X_OFFSET 
636                             + xOffset;
637
638                     dest_y = ICON_IMAGE_Y_OFFSET 
639                             + yOffset;
640                     if (wmGD.frameStyle == WmSLAB)
641                     {
642                         /* less beveling in this style */
643                         dest_x -= ICON_INTERNAL_SHADOW_WIDTH;
644                         dest_y -= ICON_INTERNAL_SHADOW_WIDTH;
645                     } 
646
647                     width = ICON_IMAGE_MAXIMUM(pcd).width
648                             + (2 * ICON_INTERNAL_SHADOW_WIDTH);
649                     height= ICON_IMAGE_MAXIMUM(pcd).height
650                             + (2 * ICON_INTERNAL_SHADOW_WIDTH);
651
652                     if (wmGD.frameStyle == WmSLAB)
653                     {
654                         width += 2;
655                         height += 2;
656                     } 
657                     XCopyArea (DISPLAY, image, 
658                                 ICON_FRAME_WIN(pcd), 
659                                 iconGC, 0, 0, width, height, 
660                                 dest_x, dest_y);
661
662                 }
663             }
664             else
665
666             {
667                 width = ICON_IMAGE_MAXIMUM(pcd).width +
668                         2 * ICON_INTERNAL_SHADOW_WIDTH;
669
670                 height= ICON_IMAGE_MAXIMUM(pcd).height +
671                         2 * ICON_INTERNAL_SHADOW_WIDTH;
672
673                 if (wmGD.frameStyle == WmSLAB)
674                 {
675                     dest_x = ICON_INNER_X_OFFSET;
676                     dest_y = ICON_INNER_Y_OFFSET;
677                     width += 2;
678                     height += 2;
679                 } 
680                 else 
681                 {
682                     dest_x = ICON_INNER_X_OFFSET + ICON_INTERNAL_SHADOW_WIDTH;
683                     dest_y = ICON_INNER_Y_OFFSET + ICON_INTERNAL_SHADOW_WIDTH;
684                 }
685                 XCopyArea (DISPLAY, image, 
686                             ICON_FRAME_WIN(pcd), 
687                             iconGC, 0, 0, width, height, 
688                             dest_x, dest_y);
689
690
691             }
692
693         }
694     }
695
696
697 } /* END OF FUNCTION IconExposureProc */
698
699
700
701 \f
702 /*************************************<->*************************************
703  *
704  *  GetIconTitleBox (pcd, pBox)
705  *
706  *
707  *  Description:
708  *  -----------
709  *  Returns a rectangle containing the icon text box
710  *
711  *
712  *  Inputs:
713  *  ------
714  *  pcd - pointer to client data
715  *  pBox - pointer to an XRectangle structure that gets returned data
716  *
717  *  Outputs:
718  *  -------
719  *  pBox - returned data
720  *
721  *  Comments:
722  *  --------
723  * 
724  *************************************<->***********************************/
725
726 void GetIconTitleBox (ClientData *pcd, XRectangle *pBox)
727 {
728     int xOffset;
729     int yOffset;
730
731
732     /*
733      * Adjust for icons in the iconBox
734      */
735
736     if (P_ICON_BOX(pcd))
737     {
738         xOffset = IB_MARGIN_WIDTH;
739         yOffset = IB_MARGIN_HEIGHT;
740     }
741     else
742     {
743         xOffset = 0;
744         yOffset = 0;
745     }
746
747     if ((P_ICON_BOX(pcd)) && (pcd->clientState != MINIMIZED_STATE))
748     {
749         /* move label up to enhance shrink wrap effect */
750         pBox->x = ICON_EXTERNAL_SHADOW_WIDTH 
751                 + ICON_IMAGE_LEFT_PAD
752                 + (2 * ICON_INTERNAL_SHADOW_WIDTH)
753                 + ICON_IMAGE_LEFT_PAD
754                 + xOffset;
755
756         pBox->y = ICON_IMAGE_HEIGHT(pcd) 
757                 +  yOffset
758                 + ((ICON_IMAGE_HEIGHT(pcd) > 0) 
759                         ? - ICON_IMAGE_BOTTOM_PAD
760                         : ICON_EXTERNAL_SHADOW_WIDTH)
761                 +  ((ICON_IMAGE_HEIGHT(pcd) >0)
762                         ? 0
763                         : WM_TOP_TITLE_PADDING );
764
765         if (wmGD.frameStyle == WmSLAB)
766         {
767             /* account for less beveling in this style */
768             pBox->x -= ICON_INTERNAL_SHADOW_WIDTH;
769             pBox->y -= ICON_INTERNAL_SHADOW_WIDTH;
770         }
771
772
773
774         pBox->width = ICON_IMAGE_MAXIMUM(pcd).width 
775                         + ((wmGD.frameStyle == WmSLAB) ? 2 : 0) 
776                         - ICON_IMAGE_LEFT_PAD
777                         - ICON_EXTERNAL_SHADOW_WIDTH;
778
779         pBox->height = TEXT_HEIGHT(ICON_APPEARANCE(pcd).font);
780
781     }
782     else if ((P_ICON_BOX(pcd)) && (pcd->clientState == MINIMIZED_STATE))
783     {
784         pBox->x = ICON_EXTERNAL_SHADOW_WIDTH 
785                 + ICON_IMAGE_LEFT_PAD
786                 + (2 * ICON_INTERNAL_SHADOW_WIDTH)
787                 + ICON_IMAGE_LEFT_PAD
788                 + xOffset;
789
790         pBox->y = ICON_IMAGE_HEIGHT(pcd) 
791                 +  yOffset
792                 + ((ICON_IMAGE_HEIGHT(pcd) > 0) 
793                         ? ICON_INTERNAL_SHADOW_WIDTH 
794                         : ICON_EXTERNAL_SHADOW_WIDTH)
795                 +  WM_TOP_TITLE_PADDING ;
796
797         pBox->width = ICON_IMAGE_MAXIMUM(pcd).width 
798                         + ((wmGD.frameStyle == WmSLAB) ? 2 : 0) 
799                         - ICON_IMAGE_LEFT_PAD;
800
801         pBox->height = TEXT_HEIGHT(ICON_APPEARANCE(pcd).font);
802
803         if (wmGD.frameStyle == WmSLAB)
804         {
805             /* account for less beveling in this style */
806             pBox->x -= ICON_INTERNAL_SHADOW_WIDTH + 2*ICON_IMAGE_LEFT_PAD;
807             pBox->y -= 3 * ICON_INTERNAL_SHADOW_WIDTH;
808             pBox->width += ICON_IMAGE_LEFT_PAD + 2;
809         }
810
811     }
812     else
813     {
814         pBox->x = ICON_EXTERNAL_SHADOW_WIDTH 
815                 + WM_TOP_TITLE_PADDING
816                 + xOffset;
817
818         if (wmGD.frameStyle == WmSLAB)
819         {
820             /* account for less beveling in this style */
821             yOffset -= ICON_INTERNAL_SHADOW_WIDTH;
822         }
823         pBox->y = ICON_IMAGE_HEIGHT(pcd) 
824                 +  WM_TOP_TITLE_PADDING 
825                 +  yOffset
826                 + ((ICON_IMAGE_HEIGHT(pcd) > 0) 
827                         ? ICON_INTERNAL_SHADOW_WIDTH 
828                         : ICON_EXTERNAL_SHADOW_WIDTH);
829
830         pBox->width = ICON_WIDTH(pcd) - 2 * ICON_EXTERNAL_SHADOW_WIDTH - 
831                   WM_TOP_TITLE_PADDING - WM_BOTTOM_TITLE_PADDING;
832         pBox->height = TEXT_HEIGHT(ICON_APPEARANCE(pcd).font);
833
834     }
835
836
837 } /* END OF FUNCTION GetIconTitleBox */
838
839
840 \f
841 /*************************************<->*************************************
842  *
843  *  DrawIconTitle (pcd)
844  *
845  *
846  *  Description:
847  *  -----------
848  *  Draws the title in the Icon title area
849  *
850  *
851  *  Inputs:
852  *  ------
853  *  pcd - pointer to client data
854  *
855  *  Outputs:
856  *  -------
857  *
858  *  Comments:
859  *  --------
860  * 
861  *************************************<->***********************************/
862
863 void DrawIconTitle (ClientData *pcd)
864 {
865     XRectangle textBox;
866     GC iconGC;
867     
868     
869     GetIconTitleBox (pcd, &textBox);
870
871     /* get appropriate GCs */
872 #ifdef WSM
873 #ifdef PANELIST
874     if ((ACTIVE_PSD->useIconBox && 
875         !((pcd->dtwmBehaviors & (DtWM_BEHAVIOR_PANEL)) ||
876           (pcd->clientFlags & CLIENT_WM_CLIENTS))) ||
877 #else /* PANELIST */
878     if ((ACTIVE_PSD->useIconBox && !(pcd->clientFlags & CLIENT_WM_CLIENTS)) || 
879 #endif /* PANELIST */
880 #else
881     if ((ACTIVE_PSD->useIconBox && !(pcd->clientFlags & ICON_BOX)) || 
882 #endif /* WSM */
883         !(wmGD.keyboardFocus == pcd)) 
884     {
885         iconGC = ICON_APPEARANCE(pcd).inactiveGC;
886     }
887     else 
888     {
889         iconGC = ICON_APPEARANCE(pcd).activeGC;
890     }
891
892     /* 
893      * Dim text if this is in the icon box and the client is mapped 
894      */
895
896     if ((ACTIVE_PSD->useIconBox) && 
897         (P_ICON_BOX(pcd)) &&
898         (FADE_NORMAL_ICON(pcd)) && 
899         (!(pcd->clientState == MINIMIZED_STATE)))
900     {
901             iconGC = FADE_ICON_TEXT_GC(pcd);
902     }
903
904
905
906
907     /* paint the text */
908 #ifdef WSM
909     WmDrawXmString(DISPLAY, ICON_FRAME_WIN(pcd), ICON_APPEARANCE(pcd).fontList,
910                    pcd->iconTitle, iconGC, 
911                    textBox.x, textBox.y, textBox.width, &textBox, True);
912 #else /* WSM */
913     WmDrawXmString(DISPLAY, ICON_FRAME_WIN(pcd), ICON_APPEARANCE(pcd).fontList,
914                    pcd->iconTitle, iconGC, 
915                    textBox.x, textBox.y, textBox.width, &textBox);
916 #endif /* WSM */
917
918 } /* END OF FUNCTION DrawIconTitle */
919
920
921
922 \f
923 /*************************************<->*************************************
924  *
925  *  RedisplayIconTitle (pcd)
926  *
927  *
928  *  Description:
929  *  -----------
930  *  Draws the title in the Icon title area
931  *
932  *
933  *  Inputs:
934  *  ------
935  *  pcd - pointer to client data
936  *
937  *  Outputs:
938  *  -------
939  *
940  *  Comments:
941  *  --------
942  * 
943  *************************************<->***********************************/
944
945 void RedisplayIconTitle (ClientData *pcd)
946 {
947     XRectangle textBox;
948     GC iconGC;
949
950     /*
951      * only proceed if we've got the right icon parts to work on
952      */
953
954     if (ICON_DECORATION(pcd) & ICON_LABEL_PART && ICON_FRAME_WIN(pcd))
955     {
956
957         /* nothing to do if no labels */
958         if (!(ICON_DECORATION(pcd) & ICON_LABEL_PART))
959             return;
960
961         /* get the box that the text sits in */
962         GetIconTitleBox (pcd, &textBox);
963
964         /* 
965          * Get appropriate GCs 
966          * Dim text if this is in the icon box and the client is mapped 
967          */
968 #ifdef WSM
969         if ((ACTIVE_PSD->useIconBox && (P_ICON_BOX(pcd)) &&
970             !(pcd->clientFlags & CLIENT_WM_CLIENTS)) || 
971 #else
972         if ((ACTIVE_PSD->useIconBox && (P_ICON_BOX(pcd)) &&
973             !(pcd->clientFlags & ICON_BOX)) || 
974 #endif /* WSM */
975             !(wmGD.keyboardFocus == pcd)) 
976         {
977             iconGC = ICON_APPEARANCE(pcd).inactiveGC;
978         }
979         else 
980         {
981             iconGC = ICON_APPEARANCE(pcd).activeGC;
982         }
983
984         if ((ACTIVE_PSD->useIconBox) && 
985             (P_ICON_BOX(pcd)) &&
986             (FADE_NORMAL_ICON(pcd)) && 
987             (!(pcd->clientState == MINIMIZED_STATE)))
988         {
989             iconGC = FADE_ICON_TEXT_GC(pcd);
990         }
991
992         /* out with the old */
993         XClearArea (DISPLAY, 
994             ICON_FRAME_WIN(pcd), 
995             textBox.x, textBox.y,
996             (unsigned int) textBox.width, (unsigned int) textBox.height, 
997             FALSE);
998
999         /* in with the new */
1000 #ifdef WSM
1001         WmDrawXmString(DISPLAY, ICON_FRAME_WIN(pcd), 
1002                        ICON_APPEARANCE(pcd).fontList,
1003                        pcd->iconTitle, iconGC, 
1004                        textBox.x, textBox.y, textBox.width, &textBox,
1005                        True);
1006 #else /* WSM */
1007         WmDrawXmString(DISPLAY, ICON_FRAME_WIN(pcd), 
1008                        ICON_APPEARANCE(pcd).fontList,
1009                        pcd->iconTitle, iconGC, 
1010                        textBox.x, textBox.y, textBox.width, &textBox);
1011 #endif /* WSM */
1012
1013         /* 
1014          * Erase & paint text in the active icon text window
1015          */
1016         if ((wmGD.keyboardFocus == pcd) && 
1017             (ICON_DECORATION(pcd) & ICON_ACTIVE_LABEL_PART))
1018         {
1019             PaintActiveIconText (pcd, True);
1020         }
1021     }
1022 } /* END OF FUNCTION  RedisplayIconTitle */
1023
1024
1025 \f
1026 /*************************************<->*************************************
1027  *
1028  *  GetIconDimensions (pSD, &pWidth, &pLabelHeight, &pImageHeight)
1029  *
1030  *
1031  *  Description:
1032  *  -----------
1033  *  returns dimensions of icon frame parts
1034  *
1035  *
1036  *  Inputs:
1037  *  ------
1038  *  pSD           - pointer to screen data
1039  *  pWidth        - pointer to width of frame
1040  *  pLabelHeight  - pointer to height of label part of icon
1041  *  pImageHeight  - pointer to height of image part of icon 
1042  *
1043  * 
1044  *  Outputs:
1045  *  -------
1046  *  *pWidth       - width of frame
1047  *  *pLabelHeight - height of label part of icon
1048  *  *pImageHeight - height of image part of icon 
1049  *
1050  *
1051  *  Comments:
1052  *  --------
1053  * 
1054  *************************************<->***********************************/
1055 void GetIconDimensions (WmScreenData *pSD, unsigned int *pWidth, unsigned int *pLabelHeight, unsigned int *pImageHeight)
1056 {
1057     /*
1058      * The icon width is always keyed to the icon image maximum regardless
1059      * of whether an icon image part appears or not.
1060      */
1061     *pWidth = pSD->iconImageMaximum.width + 
1062                 ((wmGD.frameStyle == WmSLAB) ? 2 : 0) +
1063                 ICON_IMAGE_LEFT_PAD +
1064                 ICON_IMAGE_RIGHT_PAD +
1065                 2 * ICON_EXTERNAL_SHADOW_WIDTH +
1066                 4 * ICON_INTERNAL_SHADOW_WIDTH;
1067     if (wmGD.frameStyle == WmSLAB)
1068     {
1069         /* less beveling in this style */
1070         *pWidth -= 2 * ICON_INTERNAL_SHADOW_WIDTH;
1071     }
1072
1073     switch (pSD->iconDecoration & (ICON_IMAGE_PART | ICON_LABEL_PART)) 
1074     {
1075         case ICON_LABEL_PART:
1076             *pImageHeight = 0;
1077
1078             *pLabelHeight = ICON_EXTERNAL_SHADOW_WIDTH            +
1079                             WM_TOP_TITLE_PADDING                  +
1080                             TEXT_HEIGHT(pSD->iconAppearance.font) +
1081                             WM_BOTTOM_TITLE_PADDING               +
1082                             ICON_EXTERNAL_SHADOW_WIDTH;
1083             break;
1084
1085         case ICON_IMAGE_PART:
1086             *pImageHeight = ICON_EXTERNAL_SHADOW_WIDTH   +
1087                             ICON_IMAGE_TOP_PAD           +
1088                             ICON_INTERNAL_SHADOW_WIDTH   +
1089                             ICON_INTERNAL_SHADOW_WIDTH   +
1090                             pSD->iconImageMaximum.height + 
1091                             ((wmGD.frameStyle == WmSLAB) ? 2 : 0) +
1092                             ICON_INTERNAL_SHADOW_WIDTH   +
1093                             ICON_INTERNAL_SHADOW_WIDTH   +
1094                             ICON_IMAGE_BOTTOM_PAD        +
1095                             ICON_EXTERNAL_SHADOW_WIDTH;
1096             if (wmGD.frameStyle == WmSLAB)
1097             {
1098                 /* less beveling in this style */
1099                 *pImageHeight -= 2 * ICON_INTERNAL_SHADOW_WIDTH;
1100             }
1101
1102
1103             *pLabelHeight = 0;
1104
1105             break;
1106
1107         case (ICON_IMAGE_PART | ICON_LABEL_PART):
1108             *pImageHeight = ICON_EXTERNAL_SHADOW_WIDTH   +
1109                             ICON_IMAGE_TOP_PAD           +
1110                             ICON_INTERNAL_SHADOW_WIDTH   +
1111                             ICON_INTERNAL_SHADOW_WIDTH   +
1112                             pSD->iconImageMaximum.height + 
1113                             ((wmGD.frameStyle == WmSLAB) ? 2 : 0) +
1114                             ICON_INTERNAL_SHADOW_WIDTH   +
1115                             ICON_INTERNAL_SHADOW_WIDTH   +
1116                             ICON_IMAGE_BOTTOM_PAD        +
1117                             ICON_INTERNAL_SHADOW_WIDTH;
1118
1119             *pLabelHeight = ICON_INTERNAL_SHADOW_WIDTH            +
1120                             WM_TOP_TITLE_PADDING                  +
1121                             TEXT_HEIGHT(pSD->iconAppearance.font) +
1122                             WM_BOTTOM_TITLE_PADDING               +
1123                             ICON_EXTERNAL_SHADOW_WIDTH;
1124             if (wmGD.frameStyle == WmSLAB)
1125             {
1126                 /*
1127                  * In this style there is less beveling and no 
1128                  * etching between the icon image and label.
1129                  */
1130                 *pImageHeight -= 3 * ICON_INTERNAL_SHADOW_WIDTH;
1131                 *pLabelHeight -= ICON_INTERNAL_SHADOW_WIDTH;
1132             }
1133
1134             break;
1135
1136         default:
1137             *pLabelHeight = *pImageHeight = 0;
1138             break;
1139             
1140     }
1141 }
1142
1143 \f
1144 /*************************************<->*************************************
1145  *
1146  *  InitIconSize (pSD)
1147  *
1148  *
1149  *  Description:
1150  *  -----------
1151  *  set global icon size variables
1152  *
1153  *
1154  *  Inputs:
1155  *  ------
1156  *
1157  * 
1158  *  Outputs:
1159  *  -------
1160  *
1161  *
1162  *  Comments:
1163  *  --------
1164  * 
1165  *************************************<->***********************************/
1166 void InitIconSize (WmScreenData *pSD)
1167 {
1168     Cardinal label, image;
1169
1170     GetIconDimensions (pSD, (unsigned int *)&(pSD->iconWidth), 
1171         &label, &image);
1172     
1173     pSD->iconHeight = label+image;
1174
1175     pSD->iconImageHeight = image;
1176     pSD->iconLabelHeight = label;
1177
1178
1179     iconShrinkX =   IB_MARGIN_WIDTH 
1180                   + ICON_EXTERNAL_SHADOW_WIDTH
1181                   + ICON_IMAGE_LEFT_PAD
1182                   + 2 * ICON_INTERNAL_SHADOW_WIDTH;
1183
1184                 
1185     iconShrinkY =   IB_MARGIN_HEIGHT
1186                   + ICON_EXTERNAL_SHADOW_WIDTH 
1187                   + ((pSD->iconDecoration & ICON_IMAGE_PART)
1188                         ? (ICON_IMAGE_TOP_PAD + 
1189                             (2 * ICON_INTERNAL_SHADOW_WIDTH))
1190                         : (WM_TOP_TITLE_PADDING));
1191     if (wmGD.frameStyle == WmSLAB)
1192     {
1193         /* less beveling in this style */
1194         iconShrinkX -= ICON_INTERNAL_SHADOW_WIDTH;
1195         iconShrinkY -= ICON_INTERNAL_SHADOW_WIDTH;
1196     }
1197
1198
1199     iconShrinkWidth  =  pSD->iconImageMaximum.width ;
1200     if (wmGD.frameStyle == WmSLAB)
1201     {
1202         iconShrinkWidth  += 2;
1203     }
1204
1205
1206
1207
1208     switch (pSD->iconDecoration & (ICON_IMAGE_PART | ICON_LABEL_PART)) 
1209     {
1210         case ICON_LABEL_PART:
1211             iconShrinkHeight = TEXT_HEIGHT(pSD->iconAppearance.font);
1212             break;
1213
1214         case ICON_IMAGE_PART:
1215             iconShrinkHeight = pSD->iconImageMaximum.height;
1216
1217             break;
1218
1219         case (ICON_IMAGE_PART | ICON_LABEL_PART):
1220             iconShrinkHeight =  pSD->iconHeight
1221                     - ICON_EXTERNAL_SHADOW_WIDTH
1222                     - ICON_IMAGE_TOP_PAD
1223                     - ICON_INTERNAL_SHADOW_WIDTH
1224                     - ICON_INTERNAL_SHADOW_WIDTH
1225                     - ICON_IMAGE_BOTTOM_PAD
1226                     - WM_BOTTOM_TITLE_PADDING
1227                     - ICON_EXTERNAL_SHADOW_WIDTH;
1228             if (wmGD.frameStyle == WmSLAB)
1229             {
1230                 /* adjust for less beveling in this style */
1231                 iconShrinkHeight += ICON_INTERNAL_SHADOW_WIDTH;
1232             }
1233             break;
1234
1235     }
1236
1237     
1238 } /* END OF FUNCTION InitIconSize */
1239
1240 \f
1241 /*************************************<->*************************************
1242  *
1243  *  ShowActiveIcon (pcd)
1244  *
1245  *
1246  *  Description:
1247  *  -----------
1248  *  Paint the icon to indicate an "active" state
1249  *
1250  *
1251  *  Inputs:
1252  *  ------
1253  *  pcd         - pointer to client data
1254  *
1255  * 
1256  *  Outputs:
1257  *  -------
1258  *
1259  *
1260  *  Comments:
1261  *  --------
1262  *  
1263  * 
1264  *************************************<->***********************************/
1265
1266 void ShowActiveIcon (ClientData *pcd)
1267 {
1268     unsigned long attr_mask;
1269     XSetWindowAttributes window_attribs;
1270
1271     if (ICON_FRAME_WIN(pcd))
1272     {
1273         /* 
1274          * Use background pixmap if one is specified, otherwise set the
1275          * appropriate background color. 
1276          */
1277
1278         if (ICON_APPEARANCE(pcd).activeBackgroundPixmap)
1279         {
1280             attr_mask = CWBackPixmap;
1281             window_attribs.background_pixmap = 
1282                                 ICON_APPEARANCE(pcd).activeBackgroundPixmap;
1283         }
1284         else
1285         {
1286             attr_mask = CWBackPixel;
1287             window_attribs.background_pixel = 
1288                                 ICON_APPEARANCE(pcd).activeBackground;
1289         }
1290         
1291
1292         /* set active window attributes */
1293         XChangeWindowAttributes (DISPLAY, 
1294                                 ICON_FRAME_WIN(pcd), 
1295                                 attr_mask, &window_attribs);
1296
1297         /* clear the frame to the right background */
1298         if ((!ACTIVE_PSD->useIconBox) || 
1299             (P_ICON_BOX(pcd) == NULL))
1300         {
1301 #ifndef MOTIF_ONE_DOT_ONE
1302             if (ICON_DECORATION(pcd) & ICON_IMAGE_PART)
1303             {
1304                 Dimension dheight, dwidth;
1305
1306                 dwidth = ICON_WIDTH(pcd) -
1307                         2*ICON_EXTERNAL_SHADOW_WIDTH;
1308                 if (ICON_DECORATION(pcd) & ICON_LABEL_PART)
1309                 {
1310                     dheight =   ICON_IMAGE_HEIGHT(pcd) -
1311                                 ICON_EXTERNAL_SHADOW_WIDTH;
1312                 }
1313                 else
1314                 {
1315                     dheight =   ICON_IMAGE_HEIGHT(pcd) -
1316                                 2*ICON_EXTERNAL_SHADOW_WIDTH;
1317                 }
1318                 if (wmGD.frameStyle == WmRECESSED)
1319                 {
1320                     dheight -=  ICON_INTERNAL_SHADOW_WIDTH;
1321                 }
1322
1323                 XmeClearBorder (DISPLAY, ICON_FRAME_WIN(pcd),
1324                                 ICON_EXTERNAL_SHADOW_WIDTH, 
1325                                 ICON_EXTERNAL_SHADOW_WIDTH,
1326                                 dwidth,
1327                                 dheight,
1328                                 ICON_IMAGE_TOP_PAD);
1329             }
1330
1331             if (ICON_DECORATION(pcd) & ICON_LABEL_PART)
1332             {
1333                 XClearArea (DISPLAY, 
1334                             ICON_FRAME_WIN(pcd), 
1335                             0, 
1336                             ICON_IMAGE_HEIGHT(pcd),
1337                             (unsigned int) ICON_WIDTH(pcd), 
1338                             (unsigned int) ICON_HEIGHT(pcd), False);
1339             }
1340 #else
1341             XClearWindow (DISPLAY, ICON_FRAME_WIN(pcd));
1342 #endif
1343         }
1344         else
1345         {
1346             /*
1347              * clear only area of real frame, not highlight area
1348              */
1349
1350             XClearArea (DISPLAY, 
1351                             ICON_FRAME_WIN(pcd), 
1352                             IB_MARGIN_WIDTH,
1353                             IB_MARGIN_HEIGHT,
1354                             (unsigned int) ICON_WIDTH(pcd), 
1355                             (unsigned int) ICON_HEIGHT(pcd), False);
1356         }
1357
1358
1359         /* 
1360          * Put up a big icon text label.
1361          */
1362
1363         if (ICON_DECORATION(pcd) & ICON_ACTIVE_LABEL_PART)
1364             
1365         {
1366             if (wmGD.activeIconTextDisplayed)
1367                 PaintActiveIconText(pcd, True);
1368             else
1369                 ShowActiveIconText(pcd);
1370         }
1371
1372         /* simulate exposure of window */
1373 #ifndef MOTIF_ONE_DOT_ONE
1374         IconExposureProc(pcd, False);
1375 #else
1376         IconExposureProc(pcd, True);
1377 #endif
1378
1379     }
1380
1381 } /* END OF FUNCTION ShowActiveIcon */
1382
1383
1384 \f
1385 /*************************************<->*************************************
1386  *
1387  *  ShowInactiveIcon (pcd, refresh)
1388  *
1389  *
1390  *  Description:
1391  *  -----------
1392  *  Make the icon appear "inactive"
1393  *
1394  *
1395  *  Inputs:
1396  *  ------
1397  *  pcd         - pointer to client data
1398  *
1399  *  refresh     - if True redraw the icon
1400  *
1401  *************************************<->***********************************/
1402 void ShowInactiveIcon (ClientData *pcd, Boolean refresh)
1403 {
1404     unsigned long attr_mask = 0;
1405     XSetWindowAttributes window_attribs;
1406
1407     /* turn off the active icon text */
1408     if (ICON_DECORATION(pcd) & ICON_ACTIVE_LABEL_PART)
1409     {
1410         /* pass in screen to fix multiscreen bug [P3385] */
1411         HideActiveIconText(pcd->pSD);
1412     }
1413    
1414     if (ICON_FRAME_WIN(pcd))
1415     {
1416         /* 
1417          * Use background pixmap if one is specified, otherwise set the
1418          * appropriate background color. 
1419          */
1420
1421         if (ICON_APPEARANCE(pcd).backgroundPixmap)
1422         {
1423             attr_mask |= CWBackPixmap;
1424             window_attribs.background_pixmap = 
1425                                 ICON_APPEARANCE(pcd).backgroundPixmap;
1426         }
1427         else
1428         {
1429             attr_mask |= CWBackPixel;
1430             window_attribs.background_pixel = 
1431                                 ICON_APPEARANCE(pcd).background;
1432         }
1433         
1434
1435         /* set active window attributes */
1436         XChangeWindowAttributes (DISPLAY, ICON_FRAME_WIN(pcd), attr_mask, 
1437                                  &window_attribs);
1438
1439
1440         if (refresh)
1441         {
1442             /* clear the frame to the right background */
1443             if ((!ACTIVE_PSD->useIconBox) || 
1444                 (P_ICON_BOX(pcd) == NULL))
1445             {
1446 #ifndef MOTIF_ONE_DOT_ONE
1447                 XmeClearBorder (DISPLAY, ICON_FRAME_WIN(pcd),
1448                                 0, 0,
1449                                 ICON_WIDTH(pcd), ICON_IMAGE_HEIGHT(pcd), 4);
1450
1451                 XClearArea (DISPLAY, 
1452                             ICON_FRAME_WIN(pcd), 
1453                             0, ICON_IMAGE_HEIGHT(pcd),
1454                             (unsigned int) ICON_WIDTH(pcd), 
1455                             (unsigned int) ICON_HEIGHT(pcd), False);
1456 #else
1457                 XClearWindow (DISPLAY, ICON_FRAME_WIN(pcd));
1458 #endif
1459             }
1460             else
1461             {
1462                 /*
1463                  * clear only area of real frame, not highlight area
1464                  */
1465
1466                 XClearArea (DISPLAY, 
1467                             ICON_FRAME_WIN(pcd), 
1468                             IB_MARGIN_WIDTH,
1469                             IB_MARGIN_HEIGHT,
1470                             (unsigned int) ICON_WIDTH(pcd), 
1471                             (unsigned int) ICON_HEIGHT(pcd), False);
1472             }
1473         
1474
1475         /* simulate exposure of window */
1476 #ifndef MOTIF_ONE_DOT_ONE
1477             IconExposureProc(pcd, False);
1478 #else
1479             IconExposureProc(pcd, True);
1480 #endif
1481         }
1482
1483     }
1484
1485 } /* END OF FUNTION ShowInactiveIcon  */
1486
1487
1488 \f
1489 /*************************************<->*************************************
1490  *
1491  *  ReparentIconWindow (pcd, xOffset, yOffset)
1492  *
1493  *
1494  *  Description:
1495  *  -----------
1496  *  Reparent the icon window in the center of the image area
1497  *
1498  *
1499  *  Inputs:
1500  *  ------
1501  *  pcd         - pointer to client data
1502  *  xOffset     - adjusts for icons in the iconBox
1503  *  yOffset     - adjusts for icons in the iconBox
1504  *
1505  * 
1506  *  Outputs:
1507  *  -------
1508  *
1509  *
1510  *  Comments:
1511  *  --------
1512  * 
1513  *************************************<->***********************************/
1514 void ReparentIconWindow (ClientData *pcd, int xOffset, int yOffset)
1515 {
1516     int x, y, rpX, rpY;
1517     unsigned int width, height, bw, depth;
1518     Window root;
1519     XWindowChanges windowChanges;
1520     unsigned int mask;
1521
1522 #ifdef PANELIST
1523     if (!pcd->pECD)
1524     {
1525 #endif /* PANELIST */
1526     /*
1527      * Check if window size is too big
1528      */
1529     XGetGeometry (DISPLAY, pcd->iconWindow, &root, &x, &y, &width, &height, 
1530                   &bw, &depth);
1531
1532     /*
1533      * strip off previous window border and set window geometry to 
1534      * fit inside icon frame
1535      */
1536     if (width != 0) {
1537         mask = CWBorderWidth;
1538         windowChanges.border_width = 0;
1539     }
1540     else
1541     {
1542         mask = 0;
1543     }
1544
1545     if (width > ((ICON_IMAGE_MAXIMUM(pcd).width) +
1546                  ((wmGD.frameStyle == WmSLAB) ? 2 : 0)))
1547     {
1548         width = windowChanges.width = ICON_IMAGE_MAXIMUM(pcd).width +
1549                                      ((wmGD.frameStyle == WmSLAB) ? 2 : 0);
1550         mask |= CWWidth;
1551     }
1552     else if (width < ICON_IMAGE_MINIMUM(pcd).width) {
1553         width = windowChanges.width = ICON_IMAGE_MINIMUM(pcd).width;
1554         mask |= CWWidth;
1555     }
1556
1557     if (height > ((ICON_IMAGE_MAXIMUM(pcd).height) +
1558                  ((wmGD.frameStyle == WmSLAB) ? 2 : 0)))
1559     {
1560         height = windowChanges.height = ICON_IMAGE_MAXIMUM(pcd).height +
1561                                      ((wmGD.frameStyle == WmSLAB) ? 2 : 0);
1562         mask |= CWHeight;
1563     }
1564     else if (height < ICON_IMAGE_MINIMUM(pcd).height) {
1565         height = windowChanges.height = ICON_IMAGE_MINIMUM(pcd).height;
1566         mask |= CWHeight;
1567     }
1568
1569     if (mask)
1570         XConfigureWindow (DISPLAY, pcd->iconWindow, mask, &windowChanges);
1571
1572     /*
1573      * Reparent the icon window to the center of the icon image frame
1574      */
1575
1576     if (ICON_DECORATION(pcd) & ICON_LABEL_PART)
1577     {
1578         yOffset += ICON_INTERNAL_SHADOW_WIDTH;
1579     }
1580
1581     rpX = ((ICON_WIDTH(pcd) - width)/2)    + xOffset;
1582     rpY = ((ICON_IMAGE_HEIGHT(pcd) - height)/2) + yOffset;
1583
1584
1585
1586
1587     XReparentWindow (DISPLAY, pcd->iconWindow, ICON_FRAME_WIN(pcd), rpX, rpY);
1588     pcd->clientFlags  |= ICON_REPARENTED;
1589
1590     /*
1591      * Map the icon window when the icon frame is mapped.
1592      */
1593 #ifdef PANELIST
1594     } /* END if (!pcd->pECD) */
1595 #endif /* PANELIST */
1596 } /* END OF FUNCTION ReparentIconWindow */
1597
1598 \f
1599 /*************************************<->*************************************
1600  *
1601  *  PutBoxOnScreen (screen, px, py, width, height)
1602  *
1603  *
1604  *  Description:
1605  *  -----------
1606  *  Changes the position of the passed box so that it is all on screen
1607  *
1608  *
1609  *  Inputs:
1610  *  ------
1611  *  screen      - screen we're talking about
1612  *  px          - pointer to x-coord
1613  *  py          - pointer to y-coord
1614  *  width       - width of box
1615  *  height      - height of box
1616  * 
1617  *  Outputs:
1618  *  -------
1619  *  *px         - new x-coord
1620  *  *py         - new y-coord
1621  *
1622  *
1623  *  Comments:
1624  *  --------
1625  * 
1626  *************************************<->***********************************/
1627 void PutBoxOnScreen (int screen, int *px, int *py, unsigned int width, unsigned int height)
1628 {
1629     /*
1630      * Place active label text nicely on screen
1631      */
1632
1633     if (*px+width+1 > DisplayWidth (DISPLAY, screen))
1634         *px -= (*px+width+1) - DisplayWidth (DISPLAY, screen);
1635
1636     if (*py+height+1 > DisplayHeight (DISPLAY, screen))
1637         *py -= (*py+height+1) - DisplayHeight (DISPLAY, screen);
1638
1639     if (*px < 1) *px = 1;
1640
1641     if (*py < 1) *py = 1;
1642
1643 } /* END OF FUNCTION PutBoxOnScreen */
1644
1645 \f
1646 /*************************************<->*************************************
1647  *
1648  *  PutBoxInIconBox (pCD, px, py, width, height)
1649  *
1650  *
1651  *  Description:
1652  *  -----------
1653  *  Changes the position of the passed box so that it is not
1654  *  clipped by the bulletin board
1655  *  
1656  *
1657  *
1658  *  Inputs:
1659  *  ------
1660  *  pCD         - pointer to client data
1661  *  px          - pointer to x-coord
1662  *  py          - pointer to y-coord
1663  *  width       - width of box
1664  *  height      - height of box
1665  * 
1666  *  Outputs:
1667  *  -------
1668  *  *px         - new x-coord
1669  *  *py         - new y-coord
1670  *
1671  *
1672  *  Comments:
1673  *  --------
1674  * 
1675  *************************************<->***********************************/
1676 void PutBoxInIconBox (ClientData *pCD, int *px, int *py, unsigned int *width, unsigned int *height)
1677 {
1678
1679     int i;
1680     Arg getArgs[3];
1681     Dimension bBoardWidth;
1682     Dimension bBoardHeight;
1683
1684     int clipWidth;
1685     int clipHeight;
1686
1687
1688     i=0;
1689     XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &bBoardWidth ); i++;
1690     XtSetArg (getArgs[i], XmNheight, (XtArgVal) &bBoardHeight ); i++;
1691     XtGetValues (P_ICON_BOX(pCD)->bBoardWidget, getArgs, i);
1692
1693     clipWidth = (int) bBoardWidth;
1694     clipHeight = (int) bBoardHeight;
1695
1696     if (*px + *width-1 > clipWidth)
1697         *px -= (*px + *width-1) - clipWidth;
1698
1699     if (*py + *height-1 > clipHeight)
1700         *py -= (*py + *height-1) - clipHeight;
1701
1702     if (*px < 0) *px = 0;
1703
1704     if (*py < 0) *py = 0;
1705
1706
1707 } /* END OF FUNCTION PutBoxInIconBox */
1708
1709 \f
1710 /*************************************<->*************************************
1711  *
1712  *  CreateActiveIconTextWindow (pSD)
1713  *
1714  *
1715  *  Description:
1716  *  -----------
1717  *  creates the window that's popped up when an icon is activated
1718  *
1719  *  Inputs:
1720  *  ------
1721  *  pSD         - pointer to screen data
1722  * 
1723  *  Outputs:
1724  *  -------
1725  *
1726  *  Comments:
1727  *  --------
1728  * 
1729  *************************************<->***********************************/
1730
1731 void CreateActiveIconTextWindow (WmScreenData *pSD)
1732 {
1733     XSetWindowAttributes window_attribs;
1734     unsigned long attr_mask;
1735
1736     /* create active icon text window */
1737     attr_mask = CWEventMask| CWCursor;
1738     window_attribs.event_mask =  ExposureMask;
1739     window_attribs.cursor = wmGD.workspaceCursor;
1740
1741     /* 
1742      * Use background pixmap if one is specified, otherwise set the
1743      * appropriate background color. 
1744      */
1745
1746     if (pSD->iconAppearance.activeBackgroundPixmap)
1747     {
1748         attr_mask |= CWBackPixmap;
1749         window_attribs.background_pixmap = 
1750                                 pSD->iconAppearance.activeBackgroundPixmap;
1751     }
1752     else
1753     {
1754         attr_mask |= CWBackPixel;
1755         window_attribs.background_pixel = 
1756                                 pSD->iconAppearance.activeBackground;
1757     }
1758         
1759
1760     pSD->activeIconTextWin = XCreateWindow (DISPLAY,
1761                                        pSD->rootWindow, /* parent */
1762                                        0, 0,            /* x, y */
1763                                        1, 1,            /* width, height */
1764                                        0,               /* border width */
1765                                        CopyFromParent,  /* depth */
1766                                        InputOutput,     /* class */
1767                                        CopyFromParent,  /* visual */
1768                                        attr_mask,
1769                                        &window_attribs);
1770
1771     
1772     pSD->activeLabelParent = pSD->rootWindow;
1773
1774 } /* END OF FUNCTION CreateActiveIconTextWindow */
1775
1776
1777 \f
1778 /*************************************<->*************************************
1779  *
1780  *  PaintActiveIconText (pcd, erase)
1781  *
1782  *
1783  *  Description:
1784  *  -----------
1785  *
1786  *
1787  *  Inputs:
1788  *  ------
1789  *  pcd         - pointer to client data
1790  *  erase       - if true, then erase the area before repainting
1791  * 
1792  *  Outputs:
1793  *  -------
1794  *
1795  *
1796  *  Comments:
1797  *  --------
1798  * 
1799  *************************************<->***********************************/
1800 void PaintActiveIconText (ClientData *pcd, Boolean erase)
1801 {
1802     XRectangle textBox;
1803     GC iconGC, topGC, botGC;
1804
1805     if (!(ICON_DECORATION(pcd) & ICON_ACTIVE_LABEL_PART))
1806         return;
1807
1808     /* get appropriate GCs */
1809     iconGC = ICON_APPEARANCE(pcd).activeGC;
1810     topGC = ICON_APPEARANCE(pcd).activeTopShadowGC;
1811     botGC = ICON_APPEARANCE(pcd).activeBottomShadowGC;
1812
1813     /* draw shadowing */
1814
1815     if (pActiveIconTopRects) {
1816         XFillRectangles (DISPLAY, 
1817                          pcd->pSD->activeIconTextWin,
1818                          topGC,
1819                          pActiveIconTopRects->prect,
1820                          pActiveIconTopRects->used);
1821     }
1822
1823     if (pActiveIconBotRects) {
1824         XFillRectangles (DISPLAY,
1825                          pcd->pSD->activeIconTextWin,
1826                          botGC,
1827                          pActiveIconBotRects->prect,
1828                          pActiveIconBotRects->used);
1829     }
1830
1831     /* paint the text */
1832     textBox.x = ICON_EXTERNAL_SHADOW_WIDTH;
1833     textBox.y = ICON_EXTERNAL_SHADOW_WIDTH;
1834     textBox.width = activeIconTextWidth - 2*ICON_EXTERNAL_SHADOW_WIDTH;
1835     textBox.height = activeIconTextHeight - 2*ICON_EXTERNAL_SHADOW_WIDTH;
1836
1837     if (erase)
1838     {
1839         XClearArea (DISPLAY, pcd->pSD->activeIconTextWin, textBox.x, textBox.y,
1840                     (unsigned int) textBox.width, 
1841                     (unsigned int) textBox.height, 
1842                     FALSE);
1843     }
1844
1845 #ifdef WSM
1846     WmDrawXmString(DISPLAY, pcd->pSD->activeIconTextWin, 
1847                    ICON_APPEARANCE(pcd).fontList,
1848                    pcd->iconTitle, iconGC, 
1849                    textBox.x, textBox.y, textBox.width, &textBox, True);
1850 #else /* WSM */
1851     WmDrawXmString(DISPLAY, pcd->pSD->activeIconTextWin, 
1852                    ICON_APPEARANCE(pcd).fontList,
1853                    pcd->iconTitle, iconGC, 
1854                    textBox.x, textBox.y, textBox.width, &textBox);
1855 #endif /* WSM */
1856
1857
1858 } /* END OF FUNCTION PaintActiveIconText */
1859
1860 \f
1861 /*************************************<->*************************************
1862  *
1863  *  ShowActiveIconText (pcd)
1864  *
1865  *
1866  *  Description:
1867  *  -----------
1868  *
1869  *
1870  *  Inputs:
1871  *  ------
1872  * 
1873  *  Outputs:
1874  *  -------
1875  *
1876  *
1877  *  Comments:
1878  *  --------
1879  * 
1880  *************************************<->***********************************/
1881 void ShowActiveIconText (ClientData *pcd)
1882 {
1883     XWindowAttributes iconFrameAttribs;
1884     XSetWindowAttributes window_attribs;
1885     XWindowChanges windowChanges;
1886     unsigned int mask;
1887     int x, y; 
1888     unsigned int junk;
1889     Window root;
1890     Dimension dWidth, dHeight;
1891
1892
1893     /* 
1894      * put up a big icon text label
1895      */
1896     if (pcd->pSD->activeIconTextWin) {
1897         /* copy event mask from icon frame window */
1898         XGetWindowAttributes (DISPLAY, ICON_FRAME_WIN(pcd), &iconFrameAttribs);
1899
1900         /* set attributes of window */
1901         window_attribs.event_mask =  iconFrameAttribs.your_event_mask;
1902         XChangeWindowAttributes (DISPLAY, pcd->pSD->activeIconTextWin,
1903                                  CWEventMask, &window_attribs);
1904
1905         /* set up geometry for the window */
1906
1907         XmStringExtent (ICON_APPEARANCE(pcd).fontList, pcd->iconTitle,
1908                         &dWidth, &dHeight);
1909
1910         activeIconTextHeight =  (unsigned int) dHeight + 
1911                   WM_BOTTOM_TITLE_PADDING +
1912                   2*ICON_EXTERNAL_SHADOW_WIDTH;
1913
1914         activeIconTextWidth = (unsigned int) dWidth;
1915
1916         if (activeIconTextWidth < (1.2 * ICON_WIDTH(pcd))) 
1917         {
1918             activeIconTextWidth = 1.2 * ICON_WIDTH(pcd);
1919         }
1920
1921         activeIconTextWidth += 2*ICON_EXTERNAL_SHADOW_WIDTH;
1922
1923         XGetGeometry (DISPLAY, 
1924                         (Drawable) ICON_FRAME_WIN(pcd), 
1925                         &root, &x, &y, 
1926                         &junk, &junk, &junk, &junk);
1927
1928
1929         y += ICON_IMAGE_HEIGHT(pcd);
1930         x -= (activeIconTextWidth - ICON_WIDTH(pcd))/2;
1931
1932
1933
1934         if (!(P_ICON_BOX(pcd)))
1935         {
1936             /* 
1937              * This is a normal icon
1938              */
1939             PutBoxOnScreen (SCREEN_FOR_CLIENT(pcd), &x, &y, 
1940                     activeIconTextWidth, activeIconTextHeight);
1941             if (ACTIVE_LABEL_PARENT(pcd) != root)
1942             {
1943                 XReparentWindow(DISPLAY, pcd->pSD->activeIconTextWin , 
1944                                 root, x, y );
1945                 ACTIVE_LABEL_PARENT(pcd) = root;
1946             }
1947             
1948         }
1949         else
1950         {
1951             /* 
1952              * This is an icon in an icon box
1953              */
1954             x = x + IB_MARGIN_WIDTH;
1955             y = y + IB_MARGIN_HEIGHT;
1956
1957             if(!(pcd->pSD->iconDecoration & ( ICON_LABEL_PART)))
1958             {
1959                 y -= activeIconTextHeight;
1960             }
1961
1962             PutBoxInIconBox (pcd, &x, &y, 
1963                                 &activeIconTextWidth, &activeIconTextHeight);
1964             if (ACTIVE_LABEL_PARENT(pcd) != pcd->client)
1965             {
1966                 XReparentWindow(DISPLAY, pcd->pSD->activeIconTextWin , 
1967                     XtWindow(P_ICON_BOX(pcd)->bBoardWidget),
1968                     x, y );
1969                 ACTIVE_LABEL_PARENT(pcd) = pcd->client;
1970             }
1971         }
1972
1973
1974         mask = CWX | CWY | CWWidth | CWHeight; 
1975         windowChanges.x = x;
1976         windowChanges.y = y;
1977         windowChanges.width = activeIconTextWidth;
1978         windowChanges.height = activeIconTextHeight;
1979         XConfigureWindow (DISPLAY, pcd->pSD->activeIconTextWin, mask, 
1980                           &windowChanges);
1981
1982         /* bevel the rectangle around the edges */
1983         if ((pActiveIconTopRects && pActiveIconBotRects) || 
1984             ((pActiveIconTopRects = 
1985                  AllocateRList((unsigned)4*ICON_EXTERNAL_SHADOW_WIDTH)) &&
1986              (pActiveIconBotRects = 
1987                  AllocateRList((unsigned)4*ICON_EXTERNAL_SHADOW_WIDTH))))
1988         {
1989             pActiveIconTopRects->used = 0;
1990             pActiveIconBotRects->used = 0;
1991             BevelRectangle (pActiveIconTopRects,        
1992                             pActiveIconBotRects, 
1993                             0, 0, 
1994                             activeIconTextWidth, 
1995                             activeIconTextHeight,
1996                             ICON_EXTERNAL_SHADOW_WIDTH,
1997                             ICON_EXTERNAL_SHADOW_WIDTH,
1998                             ICON_EXTERNAL_SHADOW_WIDTH,
1999                             ICON_EXTERNAL_SHADOW_WIDTH);
2000         }
2001
2002         XMapRaised (DISPLAY, pcd->pSD->activeIconTextWin);
2003         wmGD.activeIconTextDisplayed = True;
2004
2005         /* save context for this window */
2006         XSaveContext (DISPLAY, pcd->pSD->activeIconTextWin, 
2007             wmGD.windowContextType, (caddr_t) pcd);
2008     }
2009 } /* END OF FUNCTION ShowActiveIconText */
2010
2011 \f
2012 /*************************************<->*************************************
2013  *
2014  *  HideActiveIconText ()
2015  *
2016  *
2017  *  Description:
2018  *  -----------
2019  *  Hides the big label shown over the active icon.
2020  *
2021  *
2022  *  Inputs:
2023  *  ------
2024  * 
2025  *  Outputs:
2026  *  -------
2027  *
2028  *
2029  *  Comments:
2030  *  --------
2031  * 
2032  *************************************<->***********************************/
2033 void HideActiveIconText (WmScreenData *pSD)
2034 {
2035
2036
2037     if ((pSD && pSD->activeIconTextWin) || ACTIVE_ICON_TEXT_WIN)
2038     {
2039         /* disassociate the big label window with this client */
2040         XDeleteContext (DISPLAY, 
2041                         pSD 
2042                          ? pSD->activeIconTextWin
2043                          : ACTIVE_PSD->activeIconTextWin, 
2044                         wmGD.windowContextType);
2045
2046         /* hide the big label */
2047         XUnmapWindow (DISPLAY,
2048                       pSD 
2049                        ? pSD->activeIconTextWin
2050                        : ACTIVE_PSD->activeIconTextWin);
2051         wmGD.activeIconTextDisplayed = False;
2052     }
2053 }
2054
2055 \f
2056 /*************************************<->*************************************
2057  *
2058  *  MoveActiveIconText (pcd)
2059  *
2060  *
2061  *  Description:
2062  *  -----------
2063  *
2064  *
2065  *  Inputs:
2066  *  ------
2067  * 
2068  *  Outputs:
2069  *  -------
2070  *
2071  *
2072  *  Comments:
2073  *  --------
2074  * 
2075  *************************************<->***********************************/
2076 void MoveActiveIconText (ClientData *pcd)
2077 {
2078     int x, y; 
2079     unsigned int junk;
2080     Window root;
2081     Dimension dWidth, dHeight;
2082     
2083     
2084     /* 
2085      * put up a big icon text label
2086      */
2087     if (pcd->pSD->activeIconTextWin && wmGD.activeIconTextDisplayed) {
2088         /* set up geometry for the window */
2089
2090         XmStringExtent (ICON_APPEARANCE(pcd).fontList, pcd->iconTitle,
2091                         &dWidth, &dHeight);
2092
2093         activeIconTextHeight =  (unsigned int) dHeight +
2094                   WM_BOTTOM_TITLE_PADDING +
2095                   2 * ICON_EXTERNAL_SHADOW_WIDTH;
2096         
2097         activeIconTextWidth = (unsigned int) dWidth;
2098
2099         if (activeIconTextWidth < (1.2 * ICON_WIDTH(pcd))) 
2100         {
2101             activeIconTextWidth = 1.2 * ICON_WIDTH(pcd);
2102         }
2103         
2104         activeIconTextWidth += 2 * ICON_EXTERNAL_SHADOW_WIDTH;
2105
2106         XGetGeometry (DISPLAY, 
2107                         (Drawable) ICON_FRAME_WIN(pcd), 
2108                         &root, &x, &y, 
2109                         &junk, &junk, &junk, &junk);
2110
2111         
2112         y += ICON_IMAGE_HEIGHT(pcd);
2113         x -= (activeIconTextWidth - ICON_WIDTH(pcd))/2;
2114
2115         if (!(P_ICON_BOX(pcd)))
2116         {
2117             /* This is a normal icon */
2118             PutBoxOnScreen (SCREEN_FOR_CLIENT(pcd), &x, &y, 
2119                 activeIconTextWidth, activeIconTextHeight);
2120         }
2121         else 
2122         {
2123             /* icon box */
2124             x = x + IB_MARGIN_WIDTH;
2125             y = y + IB_MARGIN_HEIGHT;
2126
2127             if(!(pcd->pSD->iconDecoration & ( ICON_LABEL_PART)))
2128             {
2129                 y -= activeIconTextHeight;
2130             }
2131
2132             PutBoxInIconBox (pcd, &x, &y, 
2133                              &activeIconTextWidth, &activeIconTextHeight);
2134         }
2135         
2136         XMoveWindow(DISPLAY, pcd->pSD->activeIconTextWin, x, y );
2137
2138     }
2139 }  /* END OF FUNCTION  MoveActiveIconText */
2140
2141