2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
24 * (c) Copyright 1989, 1990, 1991, 1992, 1993, 1994 OPEN SOFTWARE FOUNDATION, INC.
31 * (c) Copyright 1987, 1988, 1989, 1990, 1993, 1994 Hewlett-Packard Company
32 * (c) Copyright 1993, 1994 International Business Machines Corp.
33 * (c) Copyright 1993, 1994 Sun Microsystems, Inc.
34 * (c) Copyright 1993, 1994 Novell, Inc.
43 #include <X11/StringDefs.h>
44 #include <X11/Intrinsic.h>
45 #include <X11/Shell.h>
46 #include <X11/Xutil.h>
47 #include <X11/Vendor.h>
49 #include <X11/keysymdef.h>
50 #include <X11/keysym.h>
54 #include <Xm/DialogS.h>
58 #include <Xm/DrawnB.h>
59 #include <Xm/ScrolledW.h>
60 #include <Xm/BulletinB.h>
61 #include <Xm/ToggleB.h>
63 #define MWM_NEED_IIMAGE
64 #define MWM_NEED_GREYED75
65 #define MWM_NEED_SLANT2
66 #include "WmIBitmap.h"
68 #include "WmResNames.h"
73 * include extern functions
76 #include "WmIconBox.h"
80 #include "WmFunction.h"
84 #include "WmPanelP.h" /* for typedef in WmManage.h */
87 #include "WmResParse.h"
88 #include "WmResource.h"
89 #include "WmWinInfo.h"
90 #include "WmWrkspace.h"
93 #define MAX(a,b) ((a)>(b)?(a):(b))
106 int frameShadowThickness;
108 Cardinal insertPosition = 0;
109 #define DEFAULT_ICON_BOX_TITLE "Icons"
110 Const char *szhorizontal = "horizontal";
111 Const char *szvertical = "vertical";
114 /*************************************<->*************************************
121 * This function controls creation of icon boxes
124 *************************************<->***********************************/
125 void InitIconBox (WmScreenData *pSD)
130 * Start the process of making the icon boxes
136 * Manage a separate icon box in every workspace
139 for (iws = 0; iws < pSD->numWorkspaces; iws++)
141 AddIconBoxForWorkspace (&pSD->pWS[iws]);
144 if (pSD->fadeNormalIcon)
146 MakeFadeIconGC (pSD);
150 } /* END OF FUNCTION InitIconBox */
152 /*************************************<->*************************************
154 * AddIconBoxForWorkspace (pWS)
159 * This function adds an iconbox to a workspace
162 *************************************<->***********************************/
163 void AddIconBoxForWorkspace (WmWorkspaceData *pWS)
166 extern WmWorkspaceData *pIconBoxInitialWS;
168 pIconBoxInitialWS = pWS;
169 ManageWindow (pWS->pSD, None, MANAGEW_ICON_BOX);
171 } /* END OF FUNCTION AddIconBoxForWorkspace */
173 /*************************************<->*************************************
175 * MakeIconBox (pWS, pCD);
185 * pWS = pointer to workspace data
186 * pCD = a pointer to ClientData
192 * Return = (Boolean) True iff successful.
197 * If fails, frees the ClientData structure pointed to by pCD.
199 *************************************<->***********************************/
201 Boolean MakeIconBox (WmWorkspaceData *pWS, ClientData *pCD)
207 * Make an icon box and return the pCD
212 if (!(pIBD = (IconBoxData *)XtMalloc (sizeof (IconBoxData))))
215 * We need a pointer to icon box data to add to the
216 * list of icon boxes linked to pWS->pIconBox. If
217 * we can't allocate space we need to free the space
218 * allocated for the ClientData structure
221 Warning (((char *)GETMESSAGE(36, 1, "Insufficient memory to create icon box data")));
222 XtFree ((char *)pCD);
226 InitializeIconBoxData (pWS, pIBD);
227 InitializeClientData (pCD, pIBD);
229 if (!(pIBD->IPD.placeList =
230 (IconInfo *)XtMalloc (pIBD->IPD.totalPlaces * sizeof (IconInfo))))
232 Warning (((char *)GETMESSAGE(36, 2, "Insufficient memory to create icon box data")));
233 XtFree ((char *)pIBD);
234 XtFree ((char *)pCD);
237 memset (pIBD->IPD.placeList, 0,
238 pIBD->IPD.totalPlaces * sizeof (IconInfo));
241 * Make the top level shell for this icon box
243 MakeShell (pWS, pIBD);
246 * Make the scrolled window for this icon box
249 MakeScrolledWindow (pWS, pIBD);
252 * Make the row column manager for this icon box
254 MakeBulletinBoard (pWS, pIBD);
257 * Realize the widget tree and set client data fields
260 RealizeIconBox (pWS, pIBD, pCD);
263 * Link the new icon box to list of icon boxes
265 AddNewBox (pWS, pIBD);
270 } /* END OF FUNCTION MakeIconBox */
272 /*************************************<->*************************************
274 * DestroyIconBox (pWS)
279 * Destroys an icon box
284 * pWS = pointer to workspace data
295 * Used when deleting a workspace
296 * Should be called AFTER all clients have been removed from the
297 * workspace -- there should be no icons in the icon box.
299 *************************************<->***********************************/
301 void DestroyIconBox (WmWorkspaceData *pWS)
305 pIBD = pWS->pIconBox;
307 XtDestroyWidget (pIBD->shellWidget);
309 UnManageWindow (pIBD->pCD_iconBox);
311 XtFree ((char *) pIBD);
313 } /* END OF FUNCTION DestroyIconBox */
315 /*************************************<->*************************************
317 * MakeShell (pWS, pIBD)
327 * pWS = pointer to workspace data
329 * pIBD = pointer to IconBoxData
344 *************************************<->***********************************/
346 void MakeShell (WmWorkspaceData *pWS, IconBoxData *pIBD)
351 char *pchIBTitle = NULL;
354 * Create top level application shell for icon box
359 XtSetArg (setArgs[i], XmNallowShellResize, (XtArgVal)True); i++;
361 XtSetArg (setArgs[i], XmNborderWidth, (XtArgVal)0); i++;
363 XtSetArg (setArgs[i], XmNkeyboardFocusPolicy, (XtArgVal)XmEXPLICIT); i++;
365 if (pWS->pSD->iconBoxTitle)
367 pchIBTitle = WmXmStringToString (pWS->pSD->iconBoxTitle);
369 XtSetArg (setArgs[i], XmNtitle, (XtArgVal)pchIBTitle); i++;
370 XtSetArg (setArgs[i], XmNiconName, (XtArgVal)pchIBTitle); i++;
372 XtSetArg (setArgs[i], XmNmappedWhenManaged, (XtArgVal)False); i++;
373 XtSetArg (setArgs[i], XmNdialogStyle, (XtArgVal)XmDIALOG_MODELESS); i++;
374 XtSetArg (setArgs[i], XmNdepth,
375 (XtArgVal) DefaultDepth (DISPLAY, pWS->pSD->screen)); i++;
376 XtSetArg (setArgs[i], XmNscreen,
377 (XtArgVal) ScreenOfDisplay (DISPLAY, pWS->pSD->screen)); i++;
379 pIBD->shellWidget = (Widget) XtCreatePopupShell (WmNclient,
380 topLevelShellWidgetClass,
381 pWS->workspaceTopLevelW,
382 (ArgList)setArgs, i);
384 if (pchIBTitle != NULL) XtFree (pchIBTitle);
386 } /* END OF FUNCTION MakeShell */
390 /*************************************<->*************************************
392 * MakeScrolledWindow (pWS, pIBD)
402 * pWS = pointer to workspace data
403 * pIBD = pointer to IconBoxData
410 * Return = pIBD with the pIBD->scrolledWidget set
417 *************************************<->***********************************/
419 void MakeScrolledWindow (WmWorkspaceData *pWS, IconBoxData *pIBD)
426 * Create frame widget to give the scrolled window
431 XtSetArg (setArgs[i], XmNborderWidth, (XtArgVal) 0 ); i++;
432 XtSetArg (setArgs[i], XmNmarginWidth, (XtArgVal) 0 ); i++;
433 XtSetArg (setArgs[i], XmNmarginHeight, (XtArgVal) 0 ); i++;
434 XtSetArg (setArgs[i], XmNshadowType, (XtArgVal) XmSHADOW_OUT); i++;
435 XtSetArg (setArgs[i], XmNshadowThickness,
436 (XtArgVal) frameShadowThickness); i++;
437 pIBD->frameWidget = XtCreateManagedWidget ("IBframe",
440 (ArgList)setArgs, i);
442 XtAddCallback (pIBD->frameWidget, XmNhelpCallback,
443 WmDtWmTopicHelpCB, WM_DT_ICONBOX_TOPIC);
446 * Create scrolled window to hold row column manager
451 XtSetArg (setArgs[i], XmNscrollingPolicy , (XtArgVal) XmAUTOMATIC ); i++;
453 XtSetArg (setArgs[i], XmNborderWidth , (XtArgVal) 0 ); i++;
454 XtSetArg (setArgs[i], XmNspacing , (XtArgVal) IB_MARGIN_WIDTH ); i++;
456 * do we want to get these from a resource or set it here
457 * to control the appearance of the iconBox
460 XtSetArg (setArgs[i], XmNscrolledWindowMarginWidth, (XtArgVal) 3); i++;
461 XtSetArg (setArgs[i], XmNscrolledWindowMarginHeight, (XtArgVal) 3); i++;
462 XtSetArg (setArgs[i], XmNshadowThickness,
463 (XtArgVal) FRAME_EXTERNAL_SHADOW_WIDTH); i++;
465 XtSetArg (setArgs[i], XmNscrollBarDisplayPolicy,(XtArgVal) XmSTATIC ); i++;
466 XtSetArg (setArgs[i], XmNvisualPolicy, (XtArgVal) XmVARIABLE ); i++;
468 pIBD->scrolledWidget = XtCreateManagedWidget ("IBsWindow",
469 xmScrolledWindowWidgetClass,
471 (ArgList)setArgs, i);
473 XtAddCallback(pIBD->scrolledWidget, XmNtraverseObscuredCallback,
474 (XtCallbackProc) IconScrollVisibleCallback, (caddr_t)NULL);
476 XtAddEventHandler(pIBD->scrolledWidget,
479 (XtEventHandler)UpdateIncrements,
484 } /* END OF FUNCTION MakeScrolledWindow */
488 /*************************************<->*************************************
490 * MakeBulletinBoard (pWS, pIBD)
500 * pWS = pointer to workspace data
501 * pIBD = pointer to IconBoxData
509 * Return = pIBD with the pIBD->bBoardWidget
516 *************************************<->***********************************/
518 void MakeBulletinBoard (WmWorkspaceData *pWS, IconBoxData *pIBD)
525 * Create bulletin board to hold icons
529 #ifdef DEBUG_ICON_BOX
530 XtSetArg (setArgs[i], XmNborderWidth , 1); i++;
532 XtSetArg (setArgs[i], XmNborderWidth , 0); i++;
533 #endif /* DEBUG_ICON_BOX */
535 XtSetArg (setArgs[i], XmNshadowThickness,(XtArgVal) 0); i++;
537 XtSetArg (setArgs[i], XmNspacing , 0); i++;
538 XtSetArg (setArgs[i], XmNmarginHeight , 0); i++;
539 XtSetArg (setArgs[i], XmNmarginWidth , 0); i++;
541 XtSetArg (setArgs[i], XmNdialogStyle, (XtArgVal) XmDIALOG_WORK_AREA); i++;
543 XtSetArg (setArgs[i], XmNresizePolicy, (XtArgVal) XmRESIZE_NONE); i++;
544 XtSetArg (setArgs[i], XmNdefaultPosition , (XtArgVal) False); i++;
546 XtSetArg (setArgs[i], XtNinsertPosition , InsertPosition); i++;
548 pIBD->bBoardWidget = XtCreateManagedWidget ("IBbBoard",
549 xmBulletinBoardWidgetClass,
550 pIBD->scrolledWidget,
551 (ArgList)setArgs, i);
553 } /* END OF FUNCTION MakeBulletinBoard */
557 /*************************************<->*************************************
559 * RealizeIconBox (pWS, pIBD, pCD)
569 * pWS = pointer to workspace data
571 * pIBD = pointer to IconBoxData
573 * pCD = pointer to ClientData
580 * Return = pIBD with the pIBD->shellWin set
581 * Return = pIBD with the pIBD->scrolledWin set
582 * Return = pIBD with the pIBD->bBoardWin set
585 * Return = pCD with appropriate fields set
592 *************************************<->***********************************/
594 void RealizeIconBox (WmWorkspaceData *pWS, IconBoxData *pIBD, ClientData *pCD)
605 XtRealizeWidget (pIBD->shellWidget);
607 pCD->client = XtWindow (pIBD->shellWidget);
610 * This will set the scrolling granularity for the icon box
613 SetGeometry (pWS, pCD, pIBD);
616 * Point to the iconBox
619 pIBD->pCD_iconBox = pCD;
620 pCD->thisIconBox = pIBD;
622 * get the background color of the bulletin board for
627 XtSetArg (setArgs[i], XmNbackground, (XtArgVal) select_color ); i++;
628 XtSetValues (pIBD->bBoardWidget, (ArgList) setArgs, i);
632 XtSetArg (getArgs[i], XmNbackgroundPixmap, (XtArgVal) &bgPixmap ); i++;
633 XtGetValues (pIBD->bBoardWidget, getArgs, i);
636 XtSetArg (getArgs[i], XmNclipWindow, (XtArgVal) &clipWidget ); i++;
637 XtGetValues (pIBD->scrolledWidget, getArgs, i);
640 * Set the background of the clip window for the scrolled
641 * window so the default widget background doesn't flash
645 XtSetArg(setArgs[i], XmNbackground, (XtArgVal) select_color); i++;
646 XtSetValues (clipWidget, (ArgList) setArgs, i);
650 * Save the clipWidget id to use in constraining icon moves in box
653 pIBD->clipWidget = clipWidget;
655 MakeShrinkWrapIconsGC (pWS->pSD, bgPixmap);
658 if (pWS->pSD->iconDecoration & ICON_IMAGE_PART)
661 * Make a pixmap to use when iconWindows are unmapped
663 defaultImage = XCreateBitmapFromData (DISPLAY, pWS->pSD->rootWindow,
664 (char*)iImage_bits, iImage_width,
667 pWS->pSD->defaultPixmap = MakeIconPixmap (pCD,
674 } /* END OF FUNCTION RealizeIconBox */
678 /*************************************<->*************************************
680 * AddNewBox (pWS, pIBD)
690 * pWS = pointer to workspace data
692 * pIBD = pointer to IconBoxData
701 * Finds the last iconbox on the list starting at pWS->pIconBox and
702 * adds the new icon box to the end of the list.
704 *************************************<->***********************************/
706 void AddNewBox (WmWorkspaceData *pWS, IconBoxData *pIBD)
713 pibd = pWS->pIconBox;
715 while (pibd->pNextIconBox)
717 pibd = pibd->pNextIconBox;
720 pibd->pNextIconBox = pIBD;
724 pWS->pIconBox = pIBD;
728 } /* END OF FUNCTION AddNewBox */
732 /*************************************<->*************************************
734 * InitializeIconBoxData (pWS, pIBD)
744 * pWS = pointer to Workspace Data
746 * pIBD = pointer to IconBoxData
755 * Initializes all pIBD fields to NULL
757 *************************************<->***********************************/
759 void InitializeIconBoxData (WmWorkspaceData *pWS, IconBoxData *pIBD)
768 frameShadowThickness = FRAME_INTERNAL_SHADOW_WIDTH;
770 pIBD->numberOfIcons = 0;
771 pIBD->currentRow = 0;
772 pIBD->currentCol = 0;
775 pIBD->IPD.placeList = NULL;
777 pIBD->scrolledWidget = NULL;
778 pIBD->bBoardWidget = NULL;
779 pIBD->clipWidget = NULL;
780 pIBD->wsID = pWS->id;
782 ToLower (pWS->pSD->iconBoxSBDisplayPolicy);
784 if (!((!strcmp(pWS->pSD->iconBoxSBDisplayPolicy , "all")) ||
785 (!strcmp(pWS->pSD->iconBoxSBDisplayPolicy , szvertical)) ||
786 (!strcmp(pWS->pSD->iconBoxSBDisplayPolicy , szhorizontal))))
788 strcpy(pWS->pSD->iconBoxSBDisplayPolicy, "all");
794 * this will be set by the iconPlacement resource if
795 * iconBoxGeometry width and height are not specified
798 if (pWS->iconBoxGeometry == NULL) /* not set by user */
801 * Use the iconPlacement resource
804 if (pWS->pSD->iconPlacement &
805 (ICON_PLACE_TOP_PRIMARY | ICON_PLACE_BOTTOM_PRIMARY))
807 pIBD->IPD.iconPlacement = ICON_PLACE_TOP_PRIMARY;
808 pIBD->IPD.placementCols = 1;
809 pIBD->IPD.placementRows = 6;
813 pIBD->IPD.iconPlacement = ICON_PLACE_LEFT_PRIMARY;
814 pIBD->IPD.placementCols = 6;
815 pIBD->IPD.placementRows = 1;
821 mask = XParseGeometry(pWS->iconBoxGeometry, &X, &Y,
824 if ((mask & WidthValue) && (width > 0))
826 pIBD->IPD.placementCols = (int)width;
830 pIBD->IPD.placementCols = 6;
833 if ((mask & HeightValue) && (height > 0))
835 pIBD->IPD.placementRows = (int)height;
839 pIBD->IPD.placementRows = 1;
846 if (pIBD->IPD.placementRows <= pIBD->IPD.placementCols)
848 pIBD->IPD.iconPlacement = ICON_PLACE_LEFT_PRIMARY;
852 pIBD->IPD.iconPlacement = ICON_PLACE_TOP_PRIMARY;
858 * Override orientation if iconBoxSBDisplayPolicy is set to
859 * horizontal or vertical
862 if (!(strcmp(pWS->pSD->iconBoxSBDisplayPolicy , szvertical)))
864 pIBD->IPD.iconPlacement = ICON_PLACE_LEFT_PRIMARY;
866 else if (!(strcmp(pWS->pSD->iconBoxSBDisplayPolicy , szhorizontal)))
868 pIBD->IPD.iconPlacement = ICON_PLACE_TOP_PRIMARY;
875 * set initial size of placement space to size of screen
878 sW = DisplayWidth (DISPLAY, pWS->pSD->screen) / pWS->pSD->iconWidth;
879 sH = DisplayHeight (DISPLAY, pWS->pSD->screen) / pWS->pSD->iconHeight;
881 pIBD->IPD.totalPlaces = sW * sH;
883 pIBD->IPD.onRootWindow = False;
886 * The icon box does not live in an icon box in this version
889 pIBD->pNextIconBox =NULL;
892 } /* END OF FUNCTION InitializeIconBoxData */
896 /*************************************<->*************************************
898 * SetIconBoxInfo (pWS, pCD)
912 *************************************<->***********************************/
914 void SetIconBoxInfo (WmWorkspaceData *pWS, ClientData *pCD)
916 pCD->clientClass = WmCIconBox;
917 pCD->clientName = pWS->pSD->iconBoxName;
918 ProcessClientResources (pCD);
920 } /* END OF FUNCTION SetIconBoxInfo */
924 /*************************************<->*************************************
926 * InitializeClientData (pCD)
945 * Initializes geometry, etc. fields
947 *************************************<->***********************************/
949 void InitializeClientData (ClientData *pCD, IconBoxData *pIBD)
951 pCD->internalBevel = (wmGD.frameStyle == WmSLAB) ? 0 :
952 FRAME_INTERNAL_SHADOW_WIDTH;
957 pCD->clientFlags |= ICON_BOX ;
959 pCD->widthInc = pIBD->IPD.iPlaceW = ICON_WIDTH(pCD)
961 + (2 * IB_MARGIN_WIDTH);
963 pCD->heightInc = pIBD->IPD.iPlaceH = ICON_HEIGHT(pCD)
965 + (2 * IB_MARGIN_HEIGHT);
967 pCD->clientWidth = pIBD->IPD.placementCols * pCD->widthInc;
968 pCD->clientHeight = pIBD->IPD.placementRows * pCD->heightInc;
970 if (!(pCD->pSD->iconBoxTitle))
972 #ifndef NO_MESSAGE_CATALOG
973 pCD->pSD->iconBoxTitle =
974 XmStringCreateLocalized(wmNLS.default_icon_box_title);
976 pCD->pSD->iconBoxTitle =
977 XmStringCreateLocalized(DEFAULT_ICON_BOX_TITLE);
981 pCD->clientTitle = pCD->pSD->iconBoxTitle;
982 pCD->iconTitle = pCD->pSD->iconBoxTitle;
984 } /* END OF FUNCTION InitializeClientData */
988 /*************************************<->*************************************
990 * MakeShrinkWrapIconsGC (pSD, bgPixmap)
995 * Make an graphic context to shrink the icons in the icon box
996 * box that are not in the MINIMIZED_STATE.
1001 * pSD - pointer to screen data
1005 * Modifies global data
1011 *************************************<->***********************************/
1013 void MakeShrinkWrapIconsGC (WmScreenData *pSD, Pixmap bgPixmap)
1019 if (!pSD->shrinkWrapGC)
1021 pSD->shrinkWrapGC = XCreateGC (DISPLAY, pSD->rootWindow, 0,
1022 (XGCValues *) NULL);
1026 XCopyGC (DISPLAY, pSD->iconAppearance.inactiveGC,
1027 copyMask, pSD->shrinkWrapGC);
1029 if (bgPixmap != XmUNSPECIFIED_PIXMAP)
1031 XSetTile (DISPLAY, pSD->shrinkWrapGC, bgPixmap);
1032 XSetFillStyle (DISPLAY, pSD->shrinkWrapGC, FillTiled);
1033 XSetBackground (DISPLAY, pSD->shrinkWrapGC, select_color);
1037 XSetForeground (DISPLAY, pSD->shrinkWrapGC, select_color);
1041 } /* END OF FUNCTION MakeShrinkWrapIconsGC */
1045 /*************************************<->*************************************
1047 * MakeFadeIconGC (pSD)
1052 * Make an graphic context for "greying" the icons in the icon
1053 * box that are not in the MINIMIZED_STATE.
1058 * pSD = pointer to screen data
1062 * Modifies global data
1068 *************************************<->***********************************/
1070 void MakeFadeIconGC (WmScreenData *pSD)
1074 static Pixmap tmpFontClipMask;
1077 pSD->fadeIconGC = XCreateGC (DISPLAY, pSD->rootWindow, 0,
1078 (XGCValues *) NULL);
1079 pSD->fadeIconTextGC = XCreateGC (DISPLAY, pSD->rootWindow, 0,
1080 (XGCValues *) NULL);
1084 XCopyGC (DISPLAY, pSD->iconAppearance.inactiveGC,
1085 copyMask, pSD->fadeIconGC);
1087 XCopyGC (DISPLAY, pSD->iconAppearance.inactiveGC,
1088 copyMask, pSD->fadeIconTextGC);
1090 tmpFontClipMask = XCreateBitmapFromData (DISPLAY, pSD->rootWindow,
1091 (char*)greyed75_bits, greyed75_width, greyed75_height);
1093 greyedPixmap = XCreateBitmapFromData (DISPLAY, pSD->rootWindow,
1094 (char*)slant2_bits, slant2_width, slant2_height);
1096 XSetStipple (DISPLAY, pSD->fadeIconTextGC, tmpFontClipMask);
1097 XSetFillStyle (DISPLAY, pSD->fadeIconTextGC, FillStippled);
1099 XSetStipple (DISPLAY, pSD->fadeIconGC, greyedPixmap);
1100 XSetFillStyle (DISPLAY, pSD->fadeIconGC, FillStippled);
1101 XSetForeground (DISPLAY, pSD->fadeIconGC, select_color);
1103 } /* END OF FUNCTION MakeFadeIconGC */
1107 /*************************************<->*************************************
1109 * SetGeometry (pWS, pCD, pIBD)
1119 * pIBD = pointer to IconBoxData
1120 * pCD = pointer to ClientData
1134 *************************************<->***********************************/
1136 void SetGeometry (WmWorkspaceData *pWS, ClientData *pCD, IconBoxData *pIBD)
1146 unsigned int height;
1147 unsigned int boxdim, tmpMin;
1149 unsigned long decoration;
1152 * Set horizontal and vertical scrolling granularity
1155 SetGranularity (pWS, pCD, pIBD );
1158 * Set the initial width and height of the icon box bulletin board
1162 XtSetArg (setArgs[i], XmNwidth, (XtArgVal) pCD->clientWidth); i++;
1163 XtSetArg (setArgs[i], XmNheight, (XtArgVal) pCD->clientHeight); i++;
1164 XtSetValues (pIBD->bBoardWidget, (ArgList) setArgs, i);
1167 * Adjust icon box window height for height of
1168 * horizontal scroll bar etc.
1171 pCD->clientHeight = pCD->clientHeight + pCD->baseHeight;
1172 pCD->oldMaxHeight = pCD->maxHeight = pCD->clientHeight;
1175 * Adjust iconbox window width for width of
1176 * vertical scroll bar etc.
1179 pCD->clientWidth = pCD->clientWidth + pCD->baseWidth;
1180 pCD->oldMaxWidth = pCD->maxWidth = pCD->clientWidth;
1184 * Check that minWidth is large enough to disallow overlap
1185 * of title bar gadgets
1188 /* compute for minimum frame size */
1189 if ((decoration = pCD->decor) & MWM_DECOR_TITLE)
1191 boxdim = InitTitleBarHeight(pCD); /* macro not valid yet */
1193 ((decoration & MWM_DECOR_MENU) ? boxdim : 0) +
1194 ((decoration & MWM_DECOR_MINIMIZE) ? boxdim : 0) +
1195 ((decoration & MWM_DECOR_MAXIMIZE) ? boxdim : 0) -
1196 2*(pCD->matteWidth);
1203 * minWidth >= tmpMin
1204 * minWidth >= max (baseWidth, widthInc) > 0
1205 * & an integral number of widthInc from baseWidth.
1208 if (pCD->minWidth < tmpMin)
1210 if ((diff = ((tmpMin - pCD->baseWidth)%pCD->widthInc)) != 0)
1212 pCD->minWidth = tmpMin + pCD->widthInc - diff;
1216 pCD->minWidth = tmpMin;
1220 if (pCD->minWidth < pCD->baseWidth)
1222 pCD->minWidth = pCD->baseWidth;
1225 if (pCD->minWidth == 0)
1227 pCD->minWidth = pCD->widthInc;
1229 else if ((diff = ((pCD->minWidth - pCD->baseWidth)%pCD->widthInc)) != 0)
1231 pCD->minWidth += pCD->widthInc - diff;
1236 if (pCD->clientWidth < pCD->minWidth)
1238 pCD->clientWidth = pCD->minWidth;
1241 pIBD->IPD.placementCols = (int)((pCD->clientWidth - pCD->baseWidth)
1248 * maxWidth >= minWidth
1249 * & an integral number of widthInc from baseWidth.
1252 if (pCD->maxWidth < pCD->minWidth)
1254 pCD->maxWidth = pCD->minWidth;
1257 pCD->maxWidthLimit = pCD->maxWidth;
1259 pCD->maxWidth -= ((pCD->maxWidth - pCD->baseWidth)% pCD->widthInc);
1260 pCD->oldMaxWidth = pCD->maxWidth;
1262 pCD->maxHeightLimit = pCD->maxHeight;
1266 * Set the initial width and height of the icon box bulletin board
1270 XtSetArg (setArgs[i], XmNwidth, (XtArgVal) pCD->clientWidth
1271 - pCD->baseWidth ); i++;
1272 XtSetArg (setArgs[i], XmNheight, (XtArgVal) pCD->clientHeight
1273 - pCD->baseHeight ); i++;
1274 XtSetValues (pIBD->bBoardWidget, (ArgList) setArgs, i);
1278 * Set the initial width and height of the icon box scrolled Window
1282 XtSetArg (setArgs[i], XmNwidth, (XtArgVal)
1283 (pCD->clientWidth - (2 * frameShadowThickness))); i++;
1284 XtSetArg (setArgs[i], XmNheight, (XtArgVal)
1285 (pCD->clientHeight - (2 * frameShadowThickness))); i++;
1287 XtSetValues (pIBD->scrolledWidget, (ArgList) setArgs, i);
1292 * Call SetFrameInfo with fake X and Y so we can get clientOffset
1295 pCD->xBorderWidth = 0;
1300 * Set initial placement of icon box
1303 mask = XParseGeometry(pWS->iconBoxGeometry, &X, &Y,
1308 if (mask & XNegative)
1311 + DisplayWidth(DISPLAY, SCREEN_FOR_CLIENT(pCD))
1313 - pCD->clientOffset.x;
1317 pCD->clientX = X + pCD->clientOffset.x;
1322 pCD->clientX = pCD->clientOffset.x;
1327 if (mask & YNegative)
1330 + DisplayHeight(DISPLAY, SCREEN_FOR_CLIENT(pCD))
1332 - pCD->clientOffset.x ;
1336 pCD->clientY = Y + pCD->clientOffset.y;
1341 pCD->clientY = pCD->clientOffset.x
1342 + DisplayHeight(DISPLAY, SCREEN_FOR_CLIENT(pCD))
1343 - pCD->clientHeight;
1347 PlaceFrameOnScreen (pCD, &pCD->clientX, &pCD->clientY, pCD->clientWidth,
1349 pCD->clientX -= (wmGD.positionIsFrame
1350 ? pCD->clientOffset.x
1353 pCD->clientY -= (wmGD.positionIsFrame
1354 ? pCD->clientOffset.y
1360 XtSetArg (setArgs[i], XmNx, (XtArgVal) pCD->clientX); i++;
1361 XtSetArg (setArgs[i], XmNy, (XtArgVal) pCD->clientY); i++;
1363 XtSetValues (pIBD->shellWidget, (ArgList) setArgs, i);
1365 pCD->maxX = pCD->clientX;
1366 pCD->maxY = pCD->clientY;
1369 } /* END OF FUNCTION SetGeometry */
1373 /*************************************<->*************************************
1375 * SetGranularity (pWS, pCD, pIBD )
1385 * pIBD = pointer to IconBoxData
1386 * pCD = pointer to ClientData
1400 *************************************<->***********************************/
1402 void SetGranularity (WmWorkspaceData *pWS, ClientData *pCD, IconBoxData *pIBD)
1406 Dimension hScrollBarHeight = 0;
1407 Dimension hBarHeight = 0;
1408 Dimension vScrollBarWidth = 0;
1409 Dimension vBarWidth = 0;
1412 short shadowThickness;
1416 short hShighlightThickness;
1417 short vShighlightThickness;
1426 XtSetArg(getArgs[i], XmNspacing, (XtArgVal) &spacing ); i++;
1427 XtSetArg(getArgs[i], XmNshadowThickness, (XtArgVal) &shadowThickness); i++;
1428 XtSetArg(getArgs[i], XmNscrolledWindowMarginWidth,
1429 (XtArgVal) &marginWidth); i++;
1430 XtSetArg(getArgs[i], XmNscrolledWindowMarginHeight,
1431 (XtArgVal) &marginHeight); i++;
1432 XtSetArg (getArgs[i], XmNverticalScrollBar,
1433 (XtArgVal) &pIBD->vScrollBar); i++;
1434 XtSetArg(getArgs[i], XmNhorizontalScrollBar,
1435 (XtArgVal) &pIBD->hScrollBar); i++;
1436 XtGetValues (pIBD->scrolledWidget, getArgs, i);
1439 if (strcmp(pWS->pSD->iconBoxSBDisplayPolicy , szvertical))
1443 * Set horizontal scrolling granularity
1446 XtSetArg (getArgs[i], XmNheight, (XtArgVal) &hBarHeight ); i++;
1447 XtSetArg (getArgs[i], XmNhighlightThickness,
1448 (XtArgVal) &hShighlightThickness); i++;
1449 XtGetValues (pIBD->hScrollBar, getArgs, i);
1453 XtSetArg(setArgs[i], XmNincrement, (XtArgVal) pCD->widthInc); i++;
1454 XtSetArg (setArgs[i], XmNhighlightThickness ,
1455 IB_HIGHLIGHT_BORDER); i++;
1456 XtSetArg(setArgs[i], XmNheight,
1457 (XtArgVal) (hBarHeight - (2 * hShighlightThickness)) +
1458 (2 * IB_HIGHLIGHT_BORDER)); i++;
1460 XtSetValues (pIBD->hScrollBar, (ArgList) setArgs, i);
1463 * Get hScrollBarHeight and troughColor
1467 XtSetArg (getArgs[i], XmNtroughColor, (XtArgVal) &select_color ); i++;
1468 XtSetArg (getArgs[i], XmNheight, (XtArgVal) &hScrollBarHeight ); i++;
1469 XtGetValues (pIBD->hScrollBar, getArgs, i);
1474 if (strcmp(pWS->pSD->iconBoxSBDisplayPolicy , szhorizontal))
1478 * Set vertical scrolling granularity
1481 XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &vBarWidth ); i++;
1482 XtSetArg (getArgs[i], XmNhighlightThickness,
1483 (XtArgVal) &vShighlightThickness); i++;
1484 XtGetValues (pIBD->vScrollBar, getArgs, i);
1488 XtSetArg (setArgs[i], XmNincrement, (XtArgVal) pCD->heightInc); i++;
1489 XtSetArg (setArgs[i], XmNhighlightThickness ,
1490 IB_HIGHLIGHT_BORDER); i++;
1491 XtSetArg(setArgs[i], XmNwidth,
1492 (XtArgVal) (vBarWidth - (2 * vShighlightThickness)) +
1493 (2 * IB_HIGHLIGHT_BORDER)); i++;
1495 XtSetValues (pIBD->vScrollBar, (ArgList) setArgs, i);
1498 * Get vScrollBarWidth
1502 XtSetArg (getArgs[i], XmNtroughColor, (XtArgVal) &select_color ); i++;
1503 XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &vScrollBarWidth ); i++;
1504 XtGetValues (pIBD->vScrollBar, getArgs, i);
1509 if (!strcmp(pWS->pSD->iconBoxSBDisplayPolicy , szvertical))
1511 XtUnmanageChild(pIBD->hScrollBar);
1512 hScrollBarHeight = 0;
1515 XtSetArg (setArgs[i], XmNscrollBarDisplayPolicy,
1516 (XtArgVal) XmAS_NEEDED ); i++;
1517 XtSetValues (pIBD->scrolledWidget, (ArgList) setArgs, i);
1520 else if (!strcmp(pWS->pSD->iconBoxSBDisplayPolicy , szhorizontal))
1522 XtUnmanageChild(pIBD->vScrollBar);
1523 vScrollBarWidth = 0;
1526 XtSetArg (setArgs[i], XmNscrollBarDisplayPolicy,
1527 (XtArgVal) XmAS_NEEDED ); i++;
1528 XtSetValues (pIBD->scrolledWidget, (ArgList) setArgs, i);
1534 pCD->baseWidth = IB_SPACING
1535 + 2 * IB_HIGHLIGHT_BORDER
1536 #ifdef DEBUG_ICON_BOX
1539 #endif /* DEBUG_ICON_BOX */
1540 + (int) vScrollBarWidth
1541 + 2 * frameShadowThickness
1542 + (int) 2 * marginWidth
1544 ? 2 * (int) shadowThickness
1549 pCD->baseHeight = IB_SPACING
1550 + 2 * IB_HIGHLIGHT_BORDER
1551 #ifdef DEBUG_ICON_BOX
1553 #endif /* DEBUG_ICON_BOX */
1555 + (int) hScrollBarHeight
1556 + 2 * frameShadowThickness
1557 + (int) 2 * marginHeight
1559 ? 2 * (int) shadowThickness
1562 pCD->minWidth = pCD->baseWidth + pCD->widthInc;
1563 pCD->minHeight = pCD->baseHeight + pCD->heightInc;
1565 pCD->oldMaxWidth = pCD->maxWidth = pCD->minWidth;
1567 pCD->oldMaxHeight = pCD->maxHeight = pCD->minHeight;
1569 } /* END OF FUNCTION SetGranularity */
1573 /*************************************<->*************************************
1575 * GetIconBoxMenuItems ()
1582 *************************************<->***********************************/
1584 MenuItem *GetIconBoxMenuItems (WmScreenData *pSD)
1587 return(ParseMwmMenuStr (pSD,
1588 (unsigned char *)((char *)GETMESSAGE(36, 3, "\"Pack Icons\" _P Alt Shift<Key>F7 f.pack_icons\n"))));
1590 } /* END OF FUNCTION GetIconBoxMenuItems */
1594 /*************************************<->*************************************
1614 * Maps all iconboxes on the list starting at pWS->pIconBox
1616 *************************************<->***********************************/
1618 void MapIconBoxes (WmWorkspaceData *pWS)
1625 pibd = pWS->pIconBox;
1629 XtPopup(pibd->shellWidget, XtGrabNone);
1630 pibd = pibd->pNextIconBox;
1635 } /* END OF FUNCTION MapIconBoxes */
1637 /*************************************<->*************************************
1639 * UnmapIconBoxes (pWS)
1644 * Unmaps all the iconboxes in the specified workspace
1649 * pWS = pointer to workspace data
1657 * Unmaps all iconboxes on the list starting at pWS->pIconBox
1658 * Does not do anything with icon windows.
1660 *************************************<->***********************************/
1662 void UnmapIconBoxes (WmWorkspaceData *pWS)
1669 pibd = pWS->pIconBox;
1673 XUnmapWindow (DISPLAY, pibd->pCD_iconBox->clientFrameWin);
1674 pibd = pibd->pNextIconBox;
1678 } /* END OF FUNCTION UnmapIconBoxes */
1680 /******************************<->*************************************
1686 * Returns True if an icon box tied to a front panel button is
1691 * pWS = pointer to workspace data
1692 * pCW = pointer to control window data (for front panel button )
1696 * Return = True if icon box is up, False if it's invisible
1701 ******************************<->***********************************/
1705 IconBoxShowing (WmWorkspaceData *pWS)
1707 Boolean rval = False;
1709 if (pWS->pIconBox &&
1710 ClientInWorkspace (pWS, pWS->pIconBox->pCD_iconBox))
1717 } /* END OF FUNCTION IconBoxShowing */
1721 /******************************<->*************************************
1723 * IconBoxPopUp (pWS, pCW, up)
1727 * Sets the state of the icon box attached to a front panel control.
1731 * pWS = pointer to workspace data
1732 * pCW = pointer to control window data (for front panel button )
1733 * up = flag, if True, pop the icon box up; if False, hide it.
1742 ******************************<->***********************************/
1745 IconBoxPopUp (WmWorkspaceData *pWS, Boolean up)
1752 pibd = pWS->pIconBox;
1758 if (ClientInWorkspace(pWS, pibd->pCD_iconBox))
1760 F_Raise (NULL, pibd->pCD_iconBox, (XEvent *)NULL);
1764 AddClientToWorkspaces (pibd->pCD_iconBox,
1769 else if (!up && ClientInWorkspace (pWS, pibd->pCD_iconBox))
1771 RemoveClientFromWorkspaces (pibd->pCD_iconBox,
1775 pibd = pibd->pNextIconBox;
1780 } /* END OF FUNCTION IconBoxPopUp */
1785 /******************************<->*************************************
1791 * pCD - pointer to data for client to insert
1797 *************************************<->***********************************/
1799 Boolean InsertIconIntoBox (IconBoxData *pIBD, ClientData *pCD)
1802 Boolean rval = False;
1805 int iconWidth, iconHeight;
1806 IconBoxData *tmpPointerToIconBox;
1808 IconInfo *pIconInfo;
1809 static XmString dummyString = NULL;
1811 WmWorkspaceData *pWS = GetWorkspaceData (pCD->pSD, pIBD->wsID);
1813 pWsc = GetWsClientData (pWS, pCD);
1816 * If we go to multiple icon boxes, find the box this client
1817 * wants to live in. For now, we only have one, so point to
1821 tmpPointerToIconBox = pIBD;
1826 pWsc->pIconBox = tmpPointerToIconBox;
1828 iconWidth = ICON_WIDTH(pCD)
1829 + (2 * IB_MARGIN_WIDTH);
1831 iconHeight = ICON_HEIGHT(pCD)
1832 + (2 * IB_MARGIN_HEIGHT);
1834 pIconInfo = InsertIconInfo (pWsc->pIconBox, pCD, (Widget) NULL);
1838 pWsc->pIconBox->numberOfIcons++;
1841 XtSetArg (setArgs[i], XmNbackground,
1842 (XtArgVal) ICON_APPEARANCE(pCD).background ); i++;
1843 XtSetArg (setArgs[i], XmNforeground,
1844 (XtArgVal) ICON_APPEARANCE(pCD).foreground ); i++;
1846 XtSetArg (setArgs[i], XmNx , (XtArgVal) pWsc->iconX); i++;
1847 XtSetArg (setArgs[i], XmNy , (XtArgVal) pWsc->iconY); i++;
1849 XtSetArg (setArgs[i], XmNwidth , (XtArgVal) iconWidth); i++;
1850 XtSetArg (setArgs[i], XmNheight , (XtArgVal) iconHeight); i++;
1852 XtSetArg (setArgs[i], XmNborderWidth , (XtArgVal) 0); i++;
1854 XtSetArg (setArgs[i], XmNhighlightThickness ,
1855 IB_HIGHLIGHT_BORDER); i++;
1857 XtSetArg (setArgs[i], XmNmarginHeight , (XtArgVal) 0); i++;
1858 XtSetArg (setArgs[i], XmNmarginWidth , (XtArgVal) 0); i++;
1860 * Use type XmString so we don't get a message from XmLabel
1862 XtSetArg (setArgs[i], XmNlabelType, (XtArgVal) XmSTRING); i++;
1864 XtSetArg (setArgs[i], XmNrecomputeSize, (XtArgVal) False); i++;
1866 XtSetArg (setArgs[i], XmNtraversalOn, (XtArgVal) True); i++;
1868 XtSetArg (setArgs[i], XmNpushButtonEnabled, (XtArgVal) False); i++;
1870 XtSetArg (setArgs[i], XmNshadowThickness, (XtArgVal) 0); i++;
1872 iconWidget = XtCreateManagedWidget("iconInIconBox",
1873 xmDrawnButtonWidgetClass,
1874 pWsc->pIconBox->bBoardWidget,
1875 (ArgList)setArgs, i);
1877 if (dummyString == NULL)
1880 XmStringCreateLocalized("");
1884 XtSetArg (setArgs[i], XmNlabelString,
1885 (XtArgVal) dummyString); i++;
1887 XtSetValues (iconWidget, setArgs, i);
1889 pIconInfo->theWidget = iconWidget;
1891 pWsc->iconFrameWin = XtWindow (iconWidget);
1893 XtAddCallback (iconWidget, XmNactivateCallback,
1894 (XtCallbackProc)IconActivateCallback,
1897 XtAddEventHandler(iconWidget,
1898 SELECT_BUTTON_MOTION_MASK,
1900 (XtEventHandler)HandleIconBoxButtonMotion,
1903 XtAddEventHandler(iconWidget,
1904 DMANIP_BUTTON_MOTION_MASK,
1906 (XtEventHandler)HandleIconBoxButtonMotion,
1909 XtAddEventHandler(iconWidget,
1912 (XtEventHandler)HandleIconBoxIconKeyPress,
1917 if (ICON_DECORATION(pCD) & ICON_ACTIVE_LABEL_PART)
1919 XtAddEventHandler(iconWidget,
1922 (XtEventHandler)ChangeActiveIconboxIconText,
1925 if (pCD->pSD->activeLabelParent != pCD->pSD->rootWindow)
1927 XRaiseWindow (DISPLAY, pCD->pSD->activeIconTextWin);
1931 ResetIconBoxMaxSize(pWsc->pIconBox->pCD_iconBox,
1932 pWsc->pIconBox->bBoardWidget);
1934 ResetArrowButtonIncrements (pWsc->pIconBox->pCD_iconBox);
1941 } /* END FUNCTION InsertIconIntoBox() */
1945 /*************************************<->*************************************
1947 * InsertIconInfo (pIBD, pCD, theWidget)
1952 * Finds next available spot and inserts the icon
1957 * pIBD - pointer to icon box data
1958 * pCD - pointer to client data for this client
1959 * theWidget - widget containing the icon (may be null)
1967 *************************************<->***********************************/
1969 IconInfo *InsertIconInfo (IconBoxData *pIBD, ClientData *pCD, Widget theWidget)
1976 Dimension clipWidth, clipHeight;
1979 place = GetNextIconPlace (&pIBD->IPD);
1980 if (place == NO_ICON_PLACE)
1982 if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
1984 amt = pIBD->IPD.placementCols; /* add a new row */
1988 amt = pIBD->IPD.placementRows; /* add a new column */
1991 if (!ExtendIconList (pIBD, amt))
1993 Warning (((char *)GETMESSAGE(36, 4, "Insufficient memory to create icon box data")));
1997 if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
1999 pIBD->IPD.placementRows++;
2003 pIBD->IPD.placementCols++;
2005 place = GetNextIconPlace (&pIBD->IPD);
2008 insertPosition = place;
2011 * Update icon info values
2014 pII = &pIBD->IPD.placeList[place];
2015 pII->theWidget = theWidget;
2019 pWsc = GetWsClientData (GetWorkspaceData (pCD->pSD, pIBD->wsID), pCD);
2020 pWsc->iconPlace = place;
2022 CvtIconPlaceToPosition (&pIBD->IPD, pWsc->iconPlace,
2023 &pWsc->iconX, &pWsc->iconY);
2026 /* update next free position */
2028 pIBD->currentCol = pWsc->iconX / pIBD->pCD_iconBox->widthInc;
2029 pIBD->currentRow = pWsc->iconY / pIBD->pCD_iconBox->heightInc;
2033 * Increase bboard size if necessary
2036 XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &clipWidth ); i++;
2037 XtSetArg (getArgs[i], XmNheight, (XtArgVal) &clipHeight ); i++;
2038 XtGetValues (pIBD->clipWidget, getArgs, i);
2041 if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
2043 if (pIBD->currentCol > pIBD->lastCol)
2045 pIBD->lastCol = pIBD->currentCol;
2048 if (pIBD->currentRow > pIBD->lastRow)
2050 pIBD->lastRow = pIBD->currentRow;
2051 if (clipHeight <= (Dimension) (pWsc->iconY +
2052 pIBD->pCD_iconBox->heightInc))
2055 * Increase bulletin board height as needed.
2057 XtSetArg (setArgs[i], XmNheight, (XtArgVal)
2058 pWsc->iconY + pIBD->pCD_iconBox->heightInc); i++;
2064 if (pIBD->currentCol > pIBD->lastCol)
2066 pIBD->lastCol = pIBD->currentCol;
2067 if (clipWidth <= (Dimension)
2068 (pWsc->iconX + pIBD->pCD_iconBox->widthInc))
2071 * Increase bulletin board width as needed
2073 XtSetArg (setArgs[i], XmNwidth,
2074 (XtArgVal) pWsc->iconX +
2075 pIBD->pCD_iconBox->widthInc); i++;
2079 if (pIBD->currentRow > pIBD->lastRow)
2081 pIBD->lastRow = pIBD->currentRow;
2087 XtSetValues (pIBD->bBoardWidget, setArgs, i);
2094 } /* END OF FUNCTION InsertIconInfo */
2098 /*************************************<->*************************************
2107 *************************************<->***********************************/
2109 void DeleteIconFromBox (IconBoxData *pIBD, ClientData *pCD)
2112 ClientData *pCD_tmp;
2114 Dimension clipWidth, clipHeight;
2115 Dimension oldWidth, oldHeight;
2116 int newWidth, newHeight;
2117 int i, newCols, newRows;
2118 WmWorkspaceData *pWS = GetWorkspaceData (pCD->pSD, pIBD->wsID);
2121 pWsc = GetWsClientData (pWS, pCD);
2124 XtSetArg (args[i], XmNwidth, (XtArgVal) &oldWidth ); i++;
2125 XtSetArg (args[i], XmNheight, (XtArgVal) &oldHeight ); i++;
2126 XtGetValues (pIBD->bBoardWidget, args, i);
2129 XtSetArg (args[i], XmNwidth, (XtArgVal) &clipWidth); i++;
2130 XtSetArg (args[i], XmNheight, (XtArgVal) &clipHeight ); i++;
2131 XtGetValues (pIBD->clipWidget, args, i);
2133 clipHeight /= (Dimension) pIBD->pCD_iconBox->heightInc;
2134 clipWidth /= (Dimension) pIBD->pCD_iconBox->widthInc;
2137 * find context of the activeIconTextWin to get pCD and then
2138 * if it is the same as this client, hide it.
2141 if (!(XFindContext (DISPLAY, pCD->pSD->activeIconTextWin,
2142 wmGD.windowContextType, (caddr_t *)&pCD_tmp)))
2146 /* hide activeIconTextWin */
2147 HideActiveIconText ((WmScreenData *)NULL);
2151 DeleteIconInfo (pWsc->pIconBox, pCD);
2153 pWsc->pIconBox->numberOfIcons--;
2155 theChild = XtWindowToWidget (DISPLAY, pWsc->iconFrameWin);
2157 pWsc->pIconBox = NULL;
2158 pWsc->iconPlace = NO_ICON_PLACE;
2159 XtUnmanageChild (theChild);
2161 XtDestroyWidget (theChild);
2163 /* update last row and col */
2165 SetNewBounds (pIBD);
2167 /* resize Bulletin board (so scroll bars show correctly */
2170 if (clipWidth <= (Dimension) (pIBD->lastCol + 1))
2172 newWidth = (pIBD->lastCol + 1) * pIBD->pCD_iconBox->widthInc;
2173 XtSetArg (args[i], XmNwidth, (XtArgVal) newWidth); i++;
2174 newCols = newWidth / pIBD->pCD_iconBox->widthInc;
2178 newWidth = clipWidth * pIBD->pCD_iconBox->widthInc;
2179 XtSetArg (args[i], XmNwidth, (XtArgVal) newWidth); i++;
2180 newCols = newWidth / pIBD->pCD_iconBox->widthInc;
2183 if (clipHeight <= (Dimension) (pIBD->lastRow + 1))
2185 /* set height of bboard */
2186 newHeight = (pIBD->lastRow + 1) * pIBD->pCD_iconBox->heightInc;
2187 XtSetArg (args[i], XmNheight, (XtArgVal) newHeight ); i++;
2188 newRows = newHeight / pIBD->pCD_iconBox->heightInc;
2192 newHeight = clipHeight * pIBD->pCD_iconBox->heightInc;
2193 XtSetArg (args[i], XmNheight, (XtArgVal) newHeight ); i++;
2194 newRows = newHeight / pIBD->pCD_iconBox->heightInc;
2197 if (i > 0 && ExpandVirtualSpace(pIBD, newWidth, newHeight))
2199 XtSetValues (pIBD->bBoardWidget, args, i);
2200 RealignIconList (pIBD, newCols, newRows);
2201 pIBD->IPD.placementCols = newCols;
2202 pIBD->IPD.placementRows = newRows;
2206 /* reset max size for icon box */
2207 ResetIconBoxMaxSize(pIBD->pCD_iconBox, pIBD->bBoardWidget);
2209 ResetArrowButtonIncrements (pIBD->pCD_iconBox);
2211 } /* END FUNCTION DeleteIconFromBox */
2215 /*************************************<->*************************************
2217 * DeleteIconInfo (pIBD, pCD)
2222 * Deletes an icon info record from the icon box list based on the
2223 * client data pointer.
2228 * pIBD - pointer to icon box data
2229 * pCD - pointer to client data
2237 * o The deleted item is freed
2238 * o Is pCD the correct key???? !!!
2240 *************************************<->***********************************/
2241 void DeleteIconInfo (IconBoxData *pIBD, ClientData *pCD)
2246 /* find first matching entry in list */
2248 pII = &pIBD->IPD.placeList[0];
2249 count = pIBD->IPD.totalPlaces;
2251 for (ix = 0; ix < count && pII->pCD != pCD; ix++, pII++)
2257 /* found it, zero the entry out */
2258 pII->theWidget = NULL;
2263 } /* END FUNCTION DeleteIconInfo */
2267 /*************************************<->*************************************
2269 * ResetIconBoxMaxSize(pCD, bBoardWidget)
2276 *************************************<->***********************************/
2278 void ResetIconBoxMaxSize (ClientData *pCD, Widget bBoardWidget)
2283 Dimension newHeight;
2286 XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &newWidth ); i++;
2287 XtSetArg (getArgs[i], XmNheight, (XtArgVal) &newHeight ); i++;
2288 XtGetValues (bBoardWidget, getArgs, i);
2290 pCD->oldMaxWidth = pCD->maxWidth = newWidth + pCD->baseWidth;
2292 pCD->oldMaxHeight = pCD->maxHeight = newHeight + pCD->baseHeight;
2294 pCD->maxX = pCD->clientX;
2295 pCD->maxY = pCD->clientY;
2296 PlaceFrameOnScreen (pCD, &pCD->maxX, &pCD->maxY,
2297 pCD->maxWidth, pCD->maxHeight);
2299 } /* END OF FUNCTION ResetIconBoxMaxSize */
2303 /*************************************<->*************************************
2305 * CheckIconBoxSize(pIBD)
2312 *************************************<->***********************************/
2314 Boolean CheckIconBoxSize (IconBoxData *pIBD)
2320 Dimension oldHeight;
2322 Dimension newHeight;
2324 Boolean rval = True;
2327 XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &oldWidth ); i++;
2328 XtSetArg (getArgs[i], XmNheight, (XtArgVal) &oldHeight ); i++;
2329 XtGetValues (pIBD->bBoardWidget, getArgs, i);
2331 newWidth = oldWidth;
2332 newHeight = oldHeight;
2333 oldCol = oldWidth / (Dimension) pIBD->pCD_iconBox->widthInc;
2334 oldRow = oldHeight / (Dimension) pIBD->pCD_iconBox->heightInc;
2337 * Increase bboard size if necessary
2341 if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
2343 if (oldRow < pIBD->lastRow + 1)
2346 * increase bulletin board height as needed
2348 newHeight = (pIBD->lastRow * pIBD->pCD_iconBox->heightInc)
2349 + pIBD->pCD_iconBox->heightInc;
2351 XtSetArg (setArgs[i], XmNheight, (XtArgVal) newHeight); i++;
2356 if (oldCol < pIBD->lastCol + 1)
2359 * increase bulletin board width as needed
2361 newWidth = (pIBD->lastCol * pIBD->pCD_iconBox->widthInc)
2362 + pIBD->pCD_iconBox->widthInc;
2364 XtSetArg (setArgs[i], XmNwidth, newWidth); i++;
2370 if (! ExpandVirtualSpace(pIBD, newWidth, newHeight))
2373 * The user has resized the iconbox larger than
2374 * memory will allow. Don't honor the resize request
2379 XtSetValues (pIBD->bBoardWidget, setArgs, i);
2382 ResetIconBoxMaxSize(pIBD->pCD_iconBox, pIBD->bBoardWidget);
2387 } /* END OF FUNCTION CheckIconBoxSize */
2391 /*************************************<->*************************************
2393 * CheckIconBoxResize(pCD, changedValues)
2400 *************************************<->***********************************/
2402 void CheckIconBoxResize (ClientData *pCD, unsigned int changedValues, int newWidth, int newHeight)
2405 Boolean packVert = False;
2406 Boolean packHorz = False;
2410 IconPlacementData *pIPD;
2411 int i, newCols, newRows;
2415 Dimension oldHeight;
2417 pIPD = &pCD->thisIconBox->IPD;
2418 pIBD = pCD->thisIconBox;
2420 pSD = &(wmGD.Screens[SCREEN_FOR_CLIENT(pCD)]);
2424 XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &oldWidth ); i++;
2425 XtSetArg (getArgs[i], XmNheight, (XtArgVal) &oldHeight ); i++;
2426 XtGetValues (pIBD->bBoardWidget, getArgs, i);
2428 newCols = pIPD->placementCols;
2429 newRows = pIPD->placementRows;
2430 newWidth = newWidth - pCD->baseWidth;
2431 newHeight = newHeight - pCD->baseHeight;
2435 if (changedValues & CWWidth)
2438 * There was a change in Width, see if we need to change the
2441 if (newWidth > (int) oldWidth)
2443 newCols = newWidth / pCD->widthInc;
2444 XtSetArg (setArgs[i], XmNwidth, (XtArgVal) newWidth ); i++;
2447 if (newWidth < (int) oldWidth)
2449 if ((!strcmp(pSD->iconBoxSBDisplayPolicy, szvertical)) &&
2450 (newWidth / pCD->widthInc < pIBD->lastCol + 1))
2452 XtSetArg (setArgs[i], XmNwidth, (XtArgVal) newWidth ); i++;
2453 newCols = newWidth / pCD->widthInc;
2456 else if (newWidth / pCD->widthInc < pIBD->lastCol + 1)
2458 newWidth = (pIBD->lastCol +1) * pCD->widthInc;
2459 XtSetArg (setArgs[i], XmNwidth, (XtArgVal) newWidth ); i++;
2463 newCols = newWidth / pCD->widthInc;
2464 XtSetArg (setArgs[i], XmNwidth, (XtArgVal) newWidth ); i++;
2470 newWidth = oldWidth;
2473 if (changedValues & CWHeight)
2476 * There was a change in Height, see if we need to change the
2479 if (newHeight > (int) oldHeight)
2481 newRows = newHeight / pCD->heightInc;
2482 XtSetArg (setArgs[i], XmNheight, (XtArgVal) newHeight ); i++;
2485 if (newHeight < (int) oldHeight)
2487 if ((!strcmp(pSD->iconBoxSBDisplayPolicy, szhorizontal)) &&
2488 (newHeight / pCD->heightInc < pIBD->lastRow + 1))
2490 XtSetArg (setArgs[i], XmNheight, (XtArgVal) newHeight ); i++;
2491 newRows = newHeight / pCD->heightInc;
2494 else if (newHeight / pCD->heightInc < pIBD->lastRow + 1)
2496 newHeight = (pIBD->lastRow + 1) * pCD->heightInc;
2497 XtSetArg (setArgs[i], XmNheight, (XtArgVal) newHeight ); i++;
2501 newRows = newHeight / pCD->heightInc;
2502 XtSetArg (setArgs[i], XmNheight, (XtArgVal) newHeight ); i++;
2508 newHeight = oldHeight;
2511 if ( i >0 && ExpandVirtualSpace(pIBD, newWidth, newHeight))
2513 XtSetValues (pIBD->bBoardWidget, setArgs, i);
2516 RealignIconList (pIBD, newCols, newRows);
2518 pIPD->placementCols = newCols;
2519 pIPD->placementRows = newRows;
2521 ResetIconBoxMaxSize(pCD, pIBD->bBoardWidget);
2524 * Pack the icon box if there are icons that can no longer
2525 * be scrolled to due to iconBoxSBDisplayPolicy.
2529 PackIconBox (pIBD, packVert, False , newWidth, 0);
2533 PackIconBox (pIBD, False, packHorz , 0, newHeight);
2537 } /* END OF FUNCTION CheckIconBoxResize */
2541 /*************************************<->*************************************
2543 * ExpandVirtualSpace (pIBD, newWidth, newHeight)
2548 * Add virtural space (really the icon list )
2553 * pIBD - ptr to icon box data
2558 * Return - True if successful, False otherwise
2563 *************************************<->***********************************/
2565 Boolean ExpandVirtualSpace (IconBoxData *pIBD, int newWidth, int newHeight)
2567 Boolean rval = True;
2571 newSize = (newWidth / pIBD->pCD_iconBox->widthInc) *
2572 (newHeight / pIBD->pCD_iconBox->heightInc);
2574 if (newSize > pIBD->IPD.totalPlaces )
2576 increment = newSize - pIBD->IPD.totalPlaces;
2577 rval = ExtendIconList (pIBD, increment);
2582 } /* END OF FUNCTION ExpandVirtualSpace */
2586 /*************************************<->*************************************
2588 * ExtendIconList (pIBD, incr);
2593 * Add space to the icon list
2598 * pIBD - ptr to icon box data
2599 * incr - number of cells to add
2604 * Return - True if successful, False otherwise
2609 *************************************<->***********************************/
2611 Boolean ExtendIconList (IconBoxData *pIBD, int incr)
2617 newSize = pIBD->IPD.totalPlaces + incr;
2619 if ((pTmp = (IconInfo *) XtMalloc (newSize*sizeof(IconInfo))) != NULL)
2622 memcpy (pTmp, pIBD->IPD.placeList,
2623 pIBD->IPD.totalPlaces*sizeof(IconInfo));
2624 memset (&pTmp[pIBD->IPD.totalPlaces], 0, incr*sizeof(IconInfo));
2626 /* out with the old, in with the new */
2627 XtFree ((char *)pIBD->IPD.placeList);
2628 pIBD->IPD.placeList = pTmp;
2629 pIBD->IPD.totalPlaces = newSize;
2638 } /* END OF FUNCTION ExtendIconList */
2642 /*************************************<->*************************************
2644 * PackIconBox(pIBD, packVert, packHorz, passedInWidth, passedInHeight)
2649 * Packs the icons in the icon box
2654 * pIBD - pointer to icon box data
2664 *************************************<->***********************************/
2665 void PackIconBox (IconBoxData *pIBD, Boolean packVert, Boolean packHorz, int passedInWidth, int passedInHeight)
2667 IconInfo *pII_2, *pII_1;
2671 ClientData *pCD_tmp = NULL, *pMyCD;
2672 int hasActiveText = 1;
2674 Dimension majorDimension, minorDimension;
2675 Dimension oldWidth, oldHeight;
2676 int newWidth, newHeight;
2678 Boolean rippling = False;
2680 WmWorkspaceData *pWS;
2683 XtSetArg (args[i], XmNwidth, (XtArgVal) &oldWidth ); i++;
2684 XtSetArg (args[i], XmNheight, (XtArgVal) &oldHeight ); i++;
2685 XtGetValues (pIBD->bBoardWidget, args, i);
2688 * packing to visual space, first update IconBoxData
2693 if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
2695 XtSetArg (args[i], XmNwidth, (XtArgVal) &majorDimension ); i++;
2696 XtSetArg (args[i], XmNheight, (XtArgVal) &minorDimension ); i++;
2697 XtGetValues (pIBD->clipWidget, args, i);
2700 majorDimension = passedInWidth;
2703 minorDimension /= (Dimension) pIBD->pCD_iconBox->heightInc;
2704 majorDimension /= (Dimension) pIBD->pCD_iconBox->widthInc;
2705 if (majorDimension != pIBD->IPD.placementCols)
2707 pIBD->IPD.placementCols = majorDimension;
2712 XtSetArg (args[i], XmNheight, (XtArgVal) &majorDimension ); i++;
2713 XtSetArg (args[i], XmNwidth, (XtArgVal) &minorDimension ); i++;
2714 XtGetValues (pIBD->clipWidget, args, i);
2717 majorDimension = passedInHeight;
2720 minorDimension /= (Dimension) pIBD->pCD_iconBox->widthInc;
2721 majorDimension /= (Dimension) pIBD->pCD_iconBox->heightInc;
2722 if (majorDimension != pIBD->IPD.placementRows)
2724 pIBD->IPD.placementRows = majorDimension;
2729 * find context of the activeIconTextWin to get pCD and then
2730 * if it is the same as this client, hide it.
2733 pMyCD = pIBD->pCD_iconBox;
2734 if (ICON_DECORATION(pMyCD) & ICON_ACTIVE_LABEL_PART)
2736 if (XFindContext (DISPLAY, pMyCD->pSD->activeIconTextWin,
2737 wmGD.windowContextType, (caddr_t *)&pCD_tmp))
2743 pII_2 = pII_1 = pIBD->IPD.placeList;
2745 count = pIBD->IPD.totalPlaces;
2749 if (!rippling && (pII_2->pCD != NULL))
2752 * We need to start rippling the icons into new positions if
2753 * their (x,y) position changed
2755 pWS = GetWorkspaceData (pII_2->pCD->pSD, pIBD->wsID);
2756 pWsc = GetWsClientData (pWS, pII_2->pCD);
2757 CvtIconPlaceToPosition (&pIBD->IPD, pWsc->iconPlace,
2760 rippling = ((newX != pWsc->iconX) ||
2761 (newY != pWsc->iconY));
2764 if ((pII_2->pCD == NULL) || rippling)
2766 /* find next one to move */
2767 while ((ix1 < count) && (pII_1->pCD == NULL))
2773 if ((ix1 < count) && (pII_1->pCD != NULL))
2777 MoveIconInfo (&pIBD->IPD, ix1, ix2);
2780 CvtIconPlaceToPosition (&pIBD->IPD, ix2, &newX, &newY);
2782 pWS = GetWorkspaceData (pII_2->pCD->pSD, pIBD->wsID);
2783 pWsc = GetWsClientData (pWS, pII_2->pCD);
2787 if (hasActiveText && (pII_2->pCD == pCD_tmp))
2789 /* hide activeIconTextWin first */
2790 HideActiveIconText ((WmScreenData *)NULL);
2791 XtMoveWidget (pII_2->theWidget, newX, newY);
2792 ShowActiveIconText (pII_2->pCD);
2796 XtMoveWidget (pII_2->theWidget, newX, newY);
2811 /* update last row and col */
2813 SetNewBounds (pIBD);
2815 /* resize Bulletin board (so scroll bars show correctly */
2817 if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
2819 if (majorDimension <= (Dimension) (pIBD->lastCol + 1))
2821 newWidth = (pIBD->lastCol + 1) * pIBD->pCD_iconBox->widthInc;
2822 XtSetArg (args[i], XmNwidth, (XtArgVal) newWidth); i++;
2826 newWidth = oldWidth;
2829 if (minorDimension <= (Dimension) (pIBD->lastRow + 1))
2831 /* set height of bboard */
2832 newHeight = (pIBD->lastRow + 1) * pIBD->pCD_iconBox->heightInc;
2833 XtSetArg (args[i], XmNheight, (XtArgVal) newHeight ); i++;
2837 newHeight = minorDimension * pIBD->pCD_iconBox->heightInc;
2838 XtSetArg (args[i], XmNheight, (XtArgVal) newHeight ); i++;
2843 if (majorDimension <= (Dimension) (pIBD->lastRow + 1))
2845 newHeight = (pIBD->lastRow + 1) * pIBD->pCD_iconBox->heightInc;
2846 XtSetArg (args[i], XmNheight, (XtArgVal) newHeight ); i++;
2850 newHeight = oldHeight;
2853 if (minorDimension <= (Dimension) (pIBD->lastCol + 1))
2855 /* set width of bboard */
2856 newWidth = (pIBD->lastCol + 1) * pIBD->pCD_iconBox->widthInc;
2857 XtSetArg (args[i], XmNwidth, (XtArgVal) newWidth); i++;
2861 newWidth = minorDimension * pIBD->pCD_iconBox->widthInc;
2862 XtSetArg (args[i], XmNwidth, (XtArgVal) newWidth); i++;
2866 if (i > 0 && ExpandVirtualSpace(pIBD, newWidth, newHeight))
2868 XtSetValues (pIBD->bBoardWidget, args, i);
2872 /* reset max size for icon box */
2874 ResetIconBoxMaxSize (pIBD->pCD_iconBox, pIBD->bBoardWidget);
2876 ResetArrowButtonIncrements (pIBD->pCD_iconBox);
2878 } /* END FUNCTION PackIconBox */
2881 /*************************************<->*************************************
2883 * RealignIconList (pIBD, newRows, newCols)
2888 * Realigns the icon list according to the new virtual space dimensions
2893 * pIBD - ptr to icon box data
2894 * newRows - new number of rows
2895 * newCols - new number of columns
2903 * o The placement data structure contains the old values.
2905 *************************************<->***********************************/
2907 void RealignIconList (IconBoxData *pIBD, int newCols, int newRows)
2909 int c1, c2, ix1, ix2;
2910 int oldRows, oldCols;
2911 IconPlacementData ipdNew;
2915 * create new icon placement data for ease of calling conversion
2918 ipdNew.onRootWindow = pIBD->IPD.onRootWindow;
2919 ipdNew.iconPlacement = pIBD->IPD.iconPlacement;
2920 ipdNew.placementRows = newRows;
2921 ipdNew.placementCols = newCols;
2922 ipdNew.iPlaceW = pIBD->IPD.iPlaceW;
2923 ipdNew.iPlaceH = pIBD->IPD.iPlaceH;
2924 ipdNew.placeList = pIBD->IPD.placeList;
2925 ipdNew.totalPlaces = pIBD->IPD.totalPlaces;
2927 oldRows = pIBD->IPD.placementRows;
2928 oldCols = pIBD->IPD.placementCols;
2931 * Use the new organization and placement discipline to
2932 * determine how to move the icon info data around.
2934 if (((oldRows < newRows) &&
2935 (pIBD->IPD.iconPlacement & ICON_PLACE_TOP_PRIMARY)) ||
2936 ((oldCols < newCols) &&
2937 (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)))
2942 for (ix1 = pIBD->IPD.totalPlaces - 1,
2943 pII = &pIBD->IPD.placeList[ix1]; ix1 >= 0; ix1--, pII--)
2945 if (pII->pCD != NULL)
2947 CvtIconPlaceToPosition (&pIBD->IPD, ix1, &c1, &c2);
2948 ix2 = CvtIconPositionToPlace (&ipdNew, c1, c2);
2951 MoveIconInfo (&pIBD->IPD, ix1, ix2);
2957 if (((oldRows > newRows) &&
2958 (pIBD->IPD.iconPlacement & ICON_PLACE_TOP_PRIMARY)) ||
2959 ((oldCols > newCols) &&
2960 (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)))
2965 for (ix1 = 0, pII = &pIBD->IPD.placeList[ix1];
2966 ix1 < pIBD->IPD.totalPlaces; ix1++, pII++)
2968 if (pII->pCD != NULL)
2970 CvtIconPlaceToPosition (&pIBD->IPD, ix1, &c1, &c2);
2971 ix2 = CvtIconPositionToPlace (&ipdNew, c1, c2);
2974 MoveIconInfo (&pIBD->IPD, ix1, ix2);
2981 * update info in placement structure to reflect new reality
2983 pIBD->IPD.placementRows = newRows;
2984 pIBD->IPD.placementCols = newCols;
2986 } /* END OF FUNCTION RealignIconList */
2991 /*************************************<->*************************************
2993 * SetNewBounds (pIBD)
3010 *************************************<->***********************************/
3012 void SetNewBounds (IconBoxData *pIBD)
3019 WidgetList children;
3021 cw = (CompositeWidget) pIBD->bBoardWidget;
3022 children = cw->composite.children;
3024 for (i = 0; i < cw->composite.num_children; i++)
3026 if (children[i]->core.x > X)
3028 X = children[i]->core.x;
3030 if (children[i]->core.y > Y)
3032 Y = children[i]->core.y;
3036 pIBD->lastCol = X / pIBD->pCD_iconBox->widthInc;
3037 pIBD->lastRow = Y / pIBD->pCD_iconBox->heightInc;
3039 } /* END OF FUNCTION SetNewBounds */
3043 /*************************************<->*************************************
3045 * InsertPosition (w)
3050 * This procedure is passed to the bulletin board at create time
3051 * to be used when a child is inserted into the bulletin board
3054 *************************************<->***********************************/
3055 Cardinal InsertPosition (Widget w)
3057 return (insertPosition);
3059 } /* END OF FUNCTION InsertPosition */
3063 /*************************************<->*************************************
3065 * ShowClientIconState ();
3072 *************************************<->***********************************/
3074 void ShowClientIconState (ClientData *pCD, int newState)
3078 * Changing the appearance of an icon window in the box to
3079 * reflect the client's state
3082 if ((newState == MINIMIZED_STATE) && (pCD->iconWindow))
3083 XMapRaised (DISPLAY, pCD->iconWindow);
3085 if (((newState == NORMAL_STATE) || (newState == MAXIMIZED_STATE ))
3086 && (pCD->iconWindow))
3088 XUnmapWindow (DISPLAY, pCD->iconWindow);
3091 } /* END FUNCTION ShowClientIconState */
3094 /*************************************<->*************************************
3096 * IconScrollVisibleCallback
3101 * for each icon in the icon box
3103 *************************************<->***********************************/
3105 void IconScrollVisibleCallback (Widget w, caddr_t client_data, XmAnyCallbackStruct *call_data)
3107 XmTraverseObscuredCallbackStruct *vis_data;
3109 vis_data = (XmTraverseObscuredCallbackStruct *) call_data;
3111 XmScrollVisible(ACTIVE_WS->pIconBox->scrolledWidget,
3112 vis_data->traversal_destination,
3115 IB_MARGIN_WIDTH, IB_MARGIN_HEIGHT);
3117 } /* END OF FUNCTION IconScrollVisibleCallback */
3120 /*************************************<->*************************************
3122 * IconActivateCallback
3127 * for each icon in the icon box
3129 *************************************<->***********************************/
3131 void IconActivateCallback (Widget w, caddr_t client_data, XmAnyCallbackStruct *call_data)
3136 theIcon = XtWindow(w);
3139 * find context to get pCD and then carry out
3143 if (!(XFindContext (DISPLAY, theIcon,
3144 wmGD.windowContextType, (caddr_t *)&pCD)))
3146 F_Restore_And_Raise ((String)NULL, pCD, (XEvent *)NULL );
3147 /* F_Normalize_And_Raise ((String)NULL, pCD, (XEvent *)NULL );
3150 } /* END OF FUNCTION IconActivateCallback */
3154 /*************************************<->*************************************
3163 *************************************<->***********************************/
3165 void UpdateIncrements (Widget sWidget, IconBoxData *pIBD, XConfigureEvent *event)
3167 ResetArrowButtonIncrements (pIBD->pCD_iconBox);
3169 } /* END OF FUNCTION UpdateIncrements */
3172 /*************************************<->*************************************
3174 * ResetArrowButtonIncrements(pCD)
3176 *************************************<->***********************************/
3178 void ResetArrowButtonIncrements (ClientData *pCD)
3184 XtSetArg (setArgs[i], XmNincrement, (XtArgVal) pCD->heightInc); i++;
3185 XtSetValues (pCD->thisIconBox->vScrollBar, (ArgList) setArgs, i);
3188 XtSetArg (setArgs[i], XmNincrement, (XtArgVal) pCD->widthInc); i++;
3189 XtSetValues (pCD->thisIconBox->hScrollBar, (ArgList) setArgs, i);
3191 } /* END OF FUNCTION ResetArrowButtonIncrements */
3195 /*************************************<->*************************************
3197 * ChangeActiveIconboxIconText
3204 *************************************<->***********************************/
3206 void ChangeActiveIconboxIconText (Widget icon, caddr_t dummy, XFocusChangeEvent *event)
3213 * find context to get pCD and then hide or show active icon text.
3214 * Show/hide the active icon text only if the icon box is not
3218 theIcon = XtWindow(icon);
3220 if (!(XFindContext (DISPLAY, theIcon,
3221 wmGD.windowContextType, (caddr_t *)&pCD)) &&
3223 P_ICON_BOX(pCD)->pCD_iconBox &&
3224 P_ICON_BOX(pCD)->pCD_iconBox->clientState != MINIMIZED_STATE)
3226 if (event->type == FocusIn)
3228 if (event->send_event)
3230 ShowActiveIconText (pCD);
3235 if (event->send_event)
3237 HideActiveIconText (pCD->pSD);
3242 } /* END OF FUNCTION ChangeActiveIconboxIconText */
3246 /*************************************<->*************************************
3248 * HandleIconBoxIconKeyPress
3253 * This event handler catches keyevents for icons in the icon box and
3254 * passes them on to the standard key handling routine for mwm.
3256 *************************************<->***********************************/
3258 void HandleIconBoxIconKeyPress (Widget icon, caddr_t dummy, XKeyEvent *keyEvent)
3266 * find context to get pCD and then post menu show active icon text.
3269 theIcon = XtWindow(icon);
3270 if (!(XFindContext (DISPLAY, theIcon,
3271 wmGD.windowContextType, (caddr_t *)&pCD)))
3273 SetClientWsIndex (pCD);
3274 keyEvent->window = ICON_FRAME_WIN(pCD);
3276 if (pCD->clientState == MINIMIZED_STATE)
3278 context = F_SUBCONTEXT_IB_IICON;
3279 pCD->grabContext = F_SUBCONTEXT_IB_IICON;
3283 context = F_SUBCONTEXT_IB_WICON;
3284 pCD->grabContext = F_SUBCONTEXT_IB_WICON;
3287 if(!(HandleKeyPress (keyEvent, ACTIVE_PSD->keySpecs,
3288 True, context, False, pCD)))
3290 keyEvent->window = 0;
3296 } /* END OF FUNCTION HandleIconBoxIconKeyPress */
3299 /*************************************<->*************************************
3301 * HandleIconBoxButtonMotion
3306 * Event handler for button motion events on icon frame window in
3312 * icon - widget for icon frame
3313 * client_data - extra client data
3314 * pev - ptr to event
3323 * o This is added to make sure that ButtonXMotion gets added to the
3324 * event mask for icons in the icon box.
3326 *************************************<->***********************************/
3328 void HandleIconBoxButtonMotion (Widget icon, caddr_t client_data, XEvent *pev)
3331 } /* END OF FUNCTION HandleIconBoxButtonMotion */
3335 /*************************************<->*************************************
3337 * GetIconBoxIconRootXY (pCD, pX, pY)
3346 * pCD - pointer to client data
3347 * pX - pointer to X return value
3348 * pY - pointer to Y return value
3356 * o returns root-window coords
3358 *************************************<->***********************************/
3359 void GetIconBoxIconRootXY (ClientData *pCD, int *pX, int *pY)
3363 WsClientData *pWsc = GetWsClientData (pCD->pSD->pActiveWS, pCD);
3365 if (pCD->pSD->useIconBox && pWsc->pIconBox)
3367 XTranslateCoordinates(DISPLAY,
3368 XtWindow(pWsc->pIconBox->bBoardWidget),
3369 ROOT_FOR_CLIENT(pCD),
3370 pWsc->iconX + IB_MARGIN_WIDTH,
3371 pWsc->iconY + IB_MARGIN_HEIGHT,
3378 } /* END FUNCTION GetIconBoxIconRootXY */
3381 /*************************************<->*************************************
3391 * pCD - pointer to client data
3400 *************************************<->***********************************/
3401 Boolean IconVisible (ClientData *pCD)
3405 * May use icon->core.visible field if that gets fixed and
3406 * we want to accept the Intrinsics idea of what is visible.
3409 Boolean rval = True;
3410 WsClientData *pWsc = GetWsClientData (pCD->pSD->pActiveWS, pCD);
3417 Dimension tmpWidth = 0;
3418 Dimension tmpHeight = 0;
3426 XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &tmpWidth ); i++;
3427 XtSetArg (getArgs[i], XmNheight, (XtArgVal) &tmpHeight ); i++;
3428 XtSetArg (getArgs[i], XmNx, (XtArgVal) &tmpX ); i++;
3429 XtSetArg (getArgs[i], XmNy, (XtArgVal) &tmpY ); i++;
3430 XtGetValues (pWsc->pIconBox->clipWidget, getArgs, i);
3431 XtTranslateCoords(pWsc->pIconBox->scrolledWidget,
3435 GetIconBoxIconRootXY(pCD, &iconX, &iconY);
3439 * demand at least 2 pixels of the
3440 * real icon (not drawnButton) be showing
3443 if (iconX + 2 > ((int)clipX + (int)tmpWidth))
3447 if (iconY + 2 > ((int)clipY + (int)tmpHeight))
3452 if ((iconX + (ICON_WIDTH(pCD) -2)) < (int)clipX)
3456 if ((iconY + (ICON_HEIGHT(pCD) -2)) < (int)clipY)
3463 } /* END OF FUNCTION IconVisible */
3465 /*************************************<->*************************************
3467 * WmXmStringToString (xmString
3483 * Return the ascii part of the first segment of an XmString
3484 * If xmString is NULL, then do nothing
3486 *************************************<->***********************************/
3488 String WmXmStringToString (XmString xmString)
3490 XmStringContext xmStrContext;
3491 char *asciiString = NULL;
3492 XmStringCharSet ibTitleCharset;
3493 XmStringDirection ibTitleDirection;
3498 XmStringInitContext (&xmStrContext, xmString);
3500 XmStringGetNextSegment (xmStrContext, &asciiString,
3501 &ibTitleCharset, &ibTitleDirection,
3504 if (ibTitleCharset != NULL)
3506 XtFree ((char *)ibTitleCharset);
3509 XmStringFreeContext (xmStrContext);
3512 return(asciiString);
3514 } /* END OF FUNCTION WmXmStringToString */