123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058 |
- /*
- * CDE - Common Desktop Environment
- *
- * Copyright (c) 1993-2012, The Open Group. All rights reserved.
- *
- * These libraries and programs are free software; you can
- * redistribute them and/or modify them under the terms of the GNU
- * Lesser General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * These libraries and programs are distributed in the hope that
- * they will be useful, but WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with these libraries and programs; if not, write
- * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
- * Floor, Boston, MA 02110-1301 USA
- */
- /*
- * (c) Copyright 1989, 1990, 1991, 1992, 1993 OPEN SOFTWARE FOUNDATION, INC.
- * ALL RIGHTS RESERVED
- */
- /*
- * Motif Release 1.2.3
- */
- /*
- * (c) Copyright 1987, 1988, 1989, 1990 HEWLETT-PACKARD COMPANY */
- /*
- * Included Files:
- */
- #include "WmGlobal.h"
- #include <Xm/Xm.h>
- #include <Xm/DrawP.h> /* for XmeClearBorder */
- /*
- * include extern functions
- */
- #include "WmIDecor.h"
- #include "WmError.h"
- #include "WmGraphics.h"
- #include "WmIconBox.h"
- #include "WmMenu.h"
- #include "WmWinInfo.h"
- #include "WmWrkspace.h"
- /*
- * Global Variables:
- */
- static unsigned int activeIconTextWidth = 1;
- static unsigned int activeIconTextHeight = 1;
- static RList *pActiveIconTopRects = NULL;
- static RList *pActiveIconBotRects = NULL;
- static int iconShrinkX;
- static int iconShrinkY;
- static unsigned int iconShrinkWidth;
- static unsigned int iconShrinkHeight;
- /*************************************<->*************************************
- *
- * MakeIcon (pWS, pcd)
- *
- *
- * Description:
- * -----------
- * Create an icon frame and fill it in as appropriate for the client.
- *
- *
- * Inputs:
- * ------
- * pWS - pointer to workspace data
- * pcd - pointer to client data
- *
- *
- * Outputs:
- * -------
- * Return - TRUE if success, FALSE if failure.
- *
- *
- * Comments:
- * --------
- *
- *
- *************************************<->***********************************/
- Boolean MakeIcon (WmWorkspaceData *pWS, ClientData *pcd)
- {
- XSetWindowAttributes window_attribs;
- unsigned long attr_mask;
- int xOffset;
- int yOffset;
- WsClientData *pWsc = GetWsClientData (pWS, pcd);
- /*
- * Common to all icons
- */
- /* compute dimensions of outer icon frame */
- /* create icon frame window */
- attr_mask = CWEventMask | CWCursor;
- window_attribs.event_mask = (ButtonPressMask | ButtonReleaseMask |
- SELECT_BUTTON_MOTION_MASK |
- DMANIP_BUTTON_MOTION_MASK |
- ExposureMask |
- SubstructureRedirectMask |
- FocusChangeMask);
- window_attribs.cursor = wmGD.workspaceCursor;
- if ((wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_POINTER) ||
- (wmGD.colormapFocusPolicy == CMAP_FOCUS_POINTER))
- {
- window_attribs.event_mask |= EnterWindowMask | LeaveWindowMask;
- }
- /*
- * Use background pixmap if one is specified, otherwise set the
- * appropriate background color.
- */
- if (ICON_APPEARANCE(pcd).backgroundPixmap)
- {
- attr_mask |= CWBackPixmap;
- window_attribs.background_pixmap =
- ICON_APPEARANCE(pcd).backgroundPixmap;
- }
- else
- {
- attr_mask |= CWBackPixel;
- window_attribs.background_pixel =
- ICON_APPEARANCE(pcd).background;
- }
-
- if ((!pcd->pSD->useIconBox) ||
- (pcd->clientFlags & (CLIENT_WM_CLIENTS | FRONT_PANEL_BOX)))
- {
- pWsc->iconFrameWin = XCreateWindow (DISPLAY,
- ROOT_FOR_CLIENT(pcd), /* parent */
- pWsc->iconX,
- pWsc->iconY,
- (unsigned int) ICON_WIDTH(pcd),
- (unsigned int) ICON_HEIGHT(pcd),
- 0, /* border width */
- CopyFromParent, /* depth */
- InputOutput, /* class */
- CopyFromParent, /* visual */
- attr_mask,
- &window_attribs);
- }
- else
- {
- /*
- * Insert the icon into the icon box.
- * Don't make icon in the box for any icon box (or any WM window)
- * OR any client that doesn't have the MWM_FUNC_MINIMIZE bit set
- * in pcd->clientFunctions
- */
- if ((pcd->pSD->useIconBox) &&
- (!(pcd->clientFlags & CLIENT_WM_CLIENTS)) &&
- (pcd->clientFunctions & MWM_FUNC_MINIMIZE) )
- {
- if (!InsertIconIntoBox(pWS->pIconBox, pcd))
- Warning(((char *)GETMESSAGE(30, 1, "Could not make icon to go in icon box")));
- }
- }
- /* make space for the top/bottom changing shadow rectangles */
- if ((pcd->piconTopShadows =
- AllocateRList ((unsigned)NUM_BOTH_TOP_RECTS)) == NULL)
- {
- /* Out of memory! */
- Warning (((char *)GETMESSAGE(30, 2, "Insufficient memory for icon creation")));
- return(FALSE);
- }
-
- if ((pcd->piconBottomShadows =
- AllocateRList ((unsigned)NUM_BOTH_BOTTOM_RECTS)) == NULL)
- {
- /* Out of memory! */
- Warning (((char *)GETMESSAGE(30, 3, "Insufficient memory for icon creation")));
- return(FALSE);
- }
- /*
- * Adjust for icons in the box
- * Don't adjust the icon for the icon box itself
- */
- if (pWS->pIconBox && (pWS->pIconBox->pCD_iconBox != pcd) &&
- !(pcd->clientFlags & FRONT_PANEL_BOX))
- {
- xOffset = IB_MARGIN_WIDTH;
- yOffset = IB_MARGIN_HEIGHT;
- }
- else
- {
- xOffset = 0;
- yOffset = 0;
- }
- /*
- * Reparent the icon window if there is one
- */
- if ((ICON_DECORATION(pcd) & ICON_IMAGE_PART) &&
- (pcd->iconWindow))
- {
- ReparentIconWindow (pcd, xOffset, yOffset);
- }
- if (pcd->piconTopShadows->used == 0)
- MakeIconShadows (pcd, xOffset, yOffset);
- return(TRUE);
- } /* END OF FUNCTION MakeIcon */
- /*************************************<->*************************************
- *
- * MakeIconShadows (pcd, xOffset, yOffset)
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- void MakeIconShadows (ClientData *pcd, int xOffset, int yOffset)
- {
- /*
- * Handle different icon styles
- */
-
- switch (ICON_DECORATION(pcd) & (ICON_LABEL_PART | ICON_IMAGE_PART))
- {
- case ICON_LABEL_PART:
- BevelRectangle (pcd->piconTopShadows, /* label */
- pcd->piconBottomShadows,
- 0 + xOffset, (int)ICON_IMAGE_HEIGHT(pcd) + yOffset,
- (unsigned int) ICON_WIDTH(pcd),
- (unsigned int) ICON_LABEL_HEIGHT(pcd),
- ICON_EXTERNAL_SHADOW_WIDTH,
- ICON_EXTERNAL_SHADOW_WIDTH,
- ICON_EXTERNAL_SHADOW_WIDTH,
- ICON_EXTERNAL_SHADOW_WIDTH);
- break;
- case ICON_IMAGE_PART:
- BevelRectangle (pcd->piconTopShadows, /* image outside */
- pcd->piconBottomShadows,
- 0 + xOffset, 0 + yOffset,
- (unsigned int) ICON_WIDTH(pcd),
- (unsigned int) ICON_IMAGE_HEIGHT(pcd),
- ICON_EXTERNAL_SHADOW_WIDTH,
- ICON_EXTERNAL_SHADOW_WIDTH,
- ICON_EXTERNAL_SHADOW_WIDTH,
- ICON_EXTERNAL_SHADOW_WIDTH);
- if (wmGD.frameStyle == WmRECESSED)
- BevelRectangle (pcd->piconBottomShadows, /* image inside */
- pcd->piconTopShadows,
- ICON_INNER_X_OFFSET + xOffset,
- ICON_INNER_Y_OFFSET + yOffset,
- (unsigned int) (ICON_IMAGE_MAXIMUM(pcd).width +
- 4*ICON_INTERNAL_SHADOW_WIDTH),
- (unsigned int) (ICON_IMAGE_MAXIMUM(pcd).height +
- 4*ICON_INTERNAL_SHADOW_WIDTH),
- ICON_INTERNAL_SHADOW_WIDTH,
- ICON_INTERNAL_SHADOW_WIDTH,
- ICON_INTERNAL_SHADOW_WIDTH,
- ICON_INTERNAL_SHADOW_WIDTH);
- break;
- case (ICON_IMAGE_PART | ICON_LABEL_PART):
- if (wmGD.frameStyle == WmSLAB)
- {
- BevelRectangle (pcd->piconTopShadows, /* image outside */
- pcd->piconBottomShadows,
- 0 + xOffset, 0 + yOffset,
- (unsigned int) ICON_WIDTH(pcd),
- (unsigned int) (ICON_IMAGE_HEIGHT(pcd) +
- ICON_LABEL_HEIGHT(pcd)),
- ICON_EXTERNAL_SHADOW_WIDTH,
- ICON_EXTERNAL_SHADOW_WIDTH,
- ICON_EXTERNAL_SHADOW_WIDTH,
- ICON_EXTERNAL_SHADOW_WIDTH);
- }
- else
- {
- BevelRectangle (pcd->piconTopShadows, /* image outside */
- pcd->piconBottomShadows,
- 0 + xOffset, 0 + yOffset,
- (unsigned int) ICON_WIDTH(pcd),
- (unsigned int) ICON_IMAGE_HEIGHT(pcd),
- ICON_EXTERNAL_SHADOW_WIDTH,
- ICON_EXTERNAL_SHADOW_WIDTH,
- ICON_INTERNAL_SHADOW_WIDTH,
- ICON_EXTERNAL_SHADOW_WIDTH);
- }
- if (wmGD.frameStyle == WmRECESSED)
- BevelRectangle (pcd->piconBottomShadows, /* image inside */
- pcd->piconTopShadows,
- ICON_INNER_X_OFFSET + xOffset,
- ICON_INNER_Y_OFFSET + yOffset,
- (unsigned int) (ICON_IMAGE_MAXIMUM(pcd).width +
- 4*ICON_INTERNAL_SHADOW_WIDTH),
- (unsigned int) (ICON_IMAGE_MAXIMUM(pcd).height +
- 4*ICON_INTERNAL_SHADOW_WIDTH),
- ICON_INTERNAL_SHADOW_WIDTH,
- ICON_INTERNAL_SHADOW_WIDTH,
- ICON_INTERNAL_SHADOW_WIDTH,
- ICON_INTERNAL_SHADOW_WIDTH);
- if (wmGD.frameStyle == WmRECESSED)
- BevelRectangle (pcd->piconTopShadows, /* label */
- pcd->piconBottomShadows,
- 0 + xOffset, (int)ICON_IMAGE_HEIGHT(pcd) + yOffset,
- (unsigned int) ICON_WIDTH(pcd),
- (unsigned int) ICON_LABEL_HEIGHT(pcd),
- ICON_INTERNAL_SHADOW_WIDTH,
- ICON_EXTERNAL_SHADOW_WIDTH,
- ICON_EXTERNAL_SHADOW_WIDTH,
- ICON_EXTERNAL_SHADOW_WIDTH);
- break;
- }
- } /* END OF FUNCTION MakeIconShadows */
- /*************************************<->*************************************
- *
- * IconExposureProc (pcd, expose)
- *
- *
- * Description:
- * -----------
- * Repaint the icon.
- *
- *
- * Inputs:
- * ------
- * pcd - pointer to client data
- *
- *
- * Outputs:
- * -------
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- void IconExposureProc (ClientData *pcd, Boolean expose)
- {
- Pixmap image;
- int dest_x, dest_y;
- int xOffset;
- int yOffset;
- unsigned int width, height;
- GC iconGC, topGC, botGC;
- static XRectangle shrinkRects[4];
- /*
- * Adjust for icons in the iconBox
- */
- if (P_ICON_BOX(pcd))
- {
- xOffset = IB_MARGIN_WIDTH;
- yOffset = IB_MARGIN_HEIGHT;
- }
- else
- {
- xOffset = 0;
- yOffset = 0;
- }
-
- /* get appropriate GCs */
- if ((wmGD.keyboardFocus == pcd) && (pcd->clientState == MINIMIZED_STATE))
- {
- iconGC = ICON_APPEARANCE(pcd).activeGC;
- topGC = ICON_APPEARANCE(pcd).activeTopShadowGC;
- botGC = ICON_APPEARANCE(pcd).activeBottomShadowGC;
- }
- else
- {
- iconGC = ICON_APPEARANCE(pcd).inactiveGC;
- topGC = ICON_APPEARANCE(pcd).inactiveTopShadowGC;
- botGC = ICON_APPEARANCE(pcd).inactiveBottomShadowGC;
- }
- if (ACTIVE_PSD->useIconBox && P_ICON_BOX(pcd))
- {
- /* draw shadowing */
- if (expose)
- {
- XClearArea (DISPLAY,
- ICON_FRAME_WIN(pcd),
- IB_MARGIN_WIDTH,
- IB_MARGIN_HEIGHT,
- (unsigned int) ICON_WIDTH(pcd),
- (unsigned int) ICON_HEIGHT(pcd), False);
- }
- if (pcd->clientState == MINIMIZED_STATE)
- {
- /*
- * This is the "raised" icon appearance
- */
- if (pcd->piconTopShadows)
- {
- XFillRectangles (DISPLAY,
- ICON_FRAME_WIN(pcd),
- topGC,
- pcd->piconTopShadows->prect,
- pcd->piconTopShadows->used);
- }
- if (pcd->piconBottomShadows)
- {
- XFillRectangles (DISPLAY,
- ICON_FRAME_WIN(pcd),
- botGC,
- pcd->piconBottomShadows->prect,
- pcd->piconBottomShadows->used);
- }
- }
- else
- {
- shrinkRects[0].x = IB_MARGIN_WIDTH;
- shrinkRects[0].y = IB_MARGIN_HEIGHT;
- shrinkRects[0].width = (unsigned int) ICON_WIDTH(pcd);
- shrinkRects[0].height = iconShrinkY - IB_MARGIN_HEIGHT;
- shrinkRects[1].x = IB_MARGIN_WIDTH;
- shrinkRects[1].y = iconShrinkY;
- shrinkRects[1].width = iconShrinkX - IB_MARGIN_WIDTH;
- shrinkRects[1].height = iconShrinkHeight;
- shrinkRects[2].x = iconShrinkX + iconShrinkWidth;
- shrinkRects[2].y = iconShrinkY;
- shrinkRects[2].width = iconShrinkX - IB_MARGIN_WIDTH;
- shrinkRects[2].height = iconShrinkHeight;
- shrinkRects[3].x = IB_MARGIN_WIDTH;
- shrinkRects[3].y = iconShrinkY + iconShrinkHeight;
- shrinkRects[3].width = (unsigned int) ICON_WIDTH(pcd);
- shrinkRects[3].height = iconShrinkY - IB_MARGIN_HEIGHT;
- XFillRectangles (DISPLAY,
- ICON_FRAME_WIN(pcd),
- SHRINK_WRAP_GC(pcd),
- &shrinkRects[0], 4);
-
- }
- }
- else
- {
- /* draw shadowing */
- if (pcd->clientState == MINIMIZED_STATE)
- {
- /*
- * This is the "raised" icon appearance
- */
- if (pcd->piconTopShadows->prect)
- {
- XFillRectangles (DISPLAY,
- ICON_FRAME_WIN(pcd),
- topGC,
- pcd->piconTopShadows->prect,
- pcd->piconTopShadows->used);
- }
- if (pcd->piconBottomShadows->prect)
- {
- XFillRectangles (DISPLAY,
- ICON_FRAME_WIN(pcd),
- botGC,
- pcd->piconBottomShadows->prect,
- pcd->piconBottomShadows->used);
- }
- }
- }
- /* draw icon text */
- /*
- if ((ICON_DECORATION(pcd) & ICON_LABEL_PART) &&
- (expose || !(ICON_DECORATION(pcd) & ICON_ACTIVE_LABEL_PART)))
- */
- if (ICON_DECORATION(pcd) & ICON_LABEL_PART)
- {
- DrawIconTitle (pcd);
- }
- /*
- * Draw image if no icon window (client has to redraw that!)
- * OR if using the iconbox, draw the default image where
- * the icon window was.
- */
- if (expose &&
- ((!pcd->iconWindow && (ICON_DECORATION(pcd) & ICON_IMAGE_PART)) ||
- (ACTIVE_PSD->useIconBox && P_ICON_BOX(pcd) &&
- pcd->iconWindow &&
- pcd->clientState != MINIMIZED_STATE &&
- (ICON_DECORATION(pcd) & ICON_IMAGE_PART))))
- {
- if (pcd->iconWindow)
- {
- image = DEFAULT_PIXMAP(pcd);
- }
- else
- {
- image = pcd->iconPixmap;
- }
- if (image)
- {
- if ((ACTIVE_PSD->useIconBox) && (P_ICON_BOX(pcd)))
- {
- if (pcd->clientState != MINIMIZED_STATE)
- {
- dest_x = ICON_IMAGE_X_OFFSET
- + ICON_INTERNAL_SHADOW_WIDTH
- + xOffset;
- dest_y = ICON_IMAGE_Y_OFFSET
- + ICON_INTERNAL_SHADOW_WIDTH
- + yOffset;
- if (wmGD.frameStyle == WmSLAB)
- {
- /* less beveling in this style */
- dest_x -= ICON_INTERNAL_SHADOW_WIDTH;
- dest_y -= ICON_INTERNAL_SHADOW_WIDTH;
- }
- width = ICON_IMAGE_MAXIMUM(pcd).width;
- height= ICON_IMAGE_MAXIMUM(pcd).height;
- if (wmGD.frameStyle == WmSLAB)
- {
- width += 2;
- height += 2;
- }
- XCopyArea (DISPLAY, image,
- ICON_FRAME_WIN(pcd),
- iconGC,
- ICON_INTERNAL_SHADOW_WIDTH,
- ICON_INTERNAL_SHADOW_WIDTH,
- width, height, dest_x, dest_y);
- if (FADE_NORMAL_ICON(pcd))
- {
- iconGC = FADE_ICON_GC(pcd);
- XFillRectangle (DISPLAY,
- ICON_FRAME_WIN(pcd),
- iconGC,
- dest_x, dest_y,
- width, height);
- }
- }
- else
- {
- dest_x = ICON_IMAGE_X_OFFSET
- + xOffset;
- dest_y = ICON_IMAGE_Y_OFFSET
- + yOffset;
- if (wmGD.frameStyle == WmSLAB)
- {
- /* less beveling in this style */
- dest_x -= ICON_INTERNAL_SHADOW_WIDTH;
- dest_y -= ICON_INTERNAL_SHADOW_WIDTH;
- }
- width = ICON_IMAGE_MAXIMUM(pcd).width
- + (2 * ICON_INTERNAL_SHADOW_WIDTH);
- height= ICON_IMAGE_MAXIMUM(pcd).height
- + (2 * ICON_INTERNAL_SHADOW_WIDTH);
- if (wmGD.frameStyle == WmSLAB)
- {
- width += 2;
- height += 2;
- }
- XCopyArea (DISPLAY, image,
- ICON_FRAME_WIN(pcd),
- iconGC, 0, 0, width, height,
- dest_x, dest_y);
- }
- }
- else
- {
- width = ICON_IMAGE_MAXIMUM(pcd).width +
- 2 * ICON_INTERNAL_SHADOW_WIDTH;
- height= ICON_IMAGE_MAXIMUM(pcd).height +
- 2 * ICON_INTERNAL_SHADOW_WIDTH;
- if (wmGD.frameStyle == WmSLAB)
- {
- dest_x = ICON_INNER_X_OFFSET;
- dest_y = ICON_INNER_Y_OFFSET;
- width += 2;
- height += 2;
- }
- else
- {
- dest_x = ICON_INNER_X_OFFSET + ICON_INTERNAL_SHADOW_WIDTH;
- dest_y = ICON_INNER_Y_OFFSET + ICON_INTERNAL_SHADOW_WIDTH;
- }
- XCopyArea (DISPLAY, image,
- ICON_FRAME_WIN(pcd),
- iconGC, 0, 0, width, height,
- dest_x, dest_y);
- }
- }
- }
- } /* END OF FUNCTION IconExposureProc */
- /*************************************<->*************************************
- *
- * GetIconTitleBox (pcd, pBox)
- *
- *
- * Description:
- * -----------
- * Returns a rectangle containing the icon text box
- *
- *
- * Inputs:
- * ------
- * pcd - pointer to client data
- * pBox - pointer to an XRectangle structure that gets returned data
- *
- * Outputs:
- * -------
- * pBox - returned data
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- void GetIconTitleBox (ClientData *pcd, XRectangle *pBox)
- {
- int xOffset;
- int yOffset;
- /*
- * Adjust for icons in the iconBox
- */
- if (P_ICON_BOX(pcd))
- {
- xOffset = IB_MARGIN_WIDTH;
- yOffset = IB_MARGIN_HEIGHT;
- }
- else
- {
- xOffset = 0;
- yOffset = 0;
- }
- if ((P_ICON_BOX(pcd)) && (pcd->clientState != MINIMIZED_STATE))
- {
- /* move label up to enhance shrink wrap effect */
- pBox->x = ICON_EXTERNAL_SHADOW_WIDTH
- + ICON_IMAGE_LEFT_PAD
- + (2 * ICON_INTERNAL_SHADOW_WIDTH)
- + ICON_IMAGE_LEFT_PAD
- + xOffset;
- pBox->y = ICON_IMAGE_HEIGHT(pcd)
- + yOffset
- + ((ICON_IMAGE_HEIGHT(pcd) > 0)
- ? - ICON_IMAGE_BOTTOM_PAD
- : ICON_EXTERNAL_SHADOW_WIDTH)
- + ((ICON_IMAGE_HEIGHT(pcd) >0)
- ? 0
- : WM_TOP_TITLE_PADDING );
- if (wmGD.frameStyle == WmSLAB)
- {
- /* account for less beveling in this style */
- pBox->x -= ICON_INTERNAL_SHADOW_WIDTH;
- pBox->y -= ICON_INTERNAL_SHADOW_WIDTH;
- }
- pBox->width = ICON_IMAGE_MAXIMUM(pcd).width
- + ((wmGD.frameStyle == WmSLAB) ? 2 : 0)
- - ICON_IMAGE_LEFT_PAD
- - ICON_EXTERNAL_SHADOW_WIDTH;
- pBox->height = TEXT_HEIGHT(ICON_APPEARANCE(pcd).font);
- }
- else if ((P_ICON_BOX(pcd)) && (pcd->clientState == MINIMIZED_STATE))
- {
- pBox->x = ICON_EXTERNAL_SHADOW_WIDTH
- + ICON_IMAGE_LEFT_PAD
- + (2 * ICON_INTERNAL_SHADOW_WIDTH)
- + ICON_IMAGE_LEFT_PAD
- + xOffset;
- pBox->y = ICON_IMAGE_HEIGHT(pcd)
- + yOffset
- + ((ICON_IMAGE_HEIGHT(pcd) > 0)
- ? ICON_INTERNAL_SHADOW_WIDTH
- : ICON_EXTERNAL_SHADOW_WIDTH)
- + WM_TOP_TITLE_PADDING ;
- pBox->width = ICON_IMAGE_MAXIMUM(pcd).width
- + ((wmGD.frameStyle == WmSLAB) ? 2 : 0)
- - ICON_IMAGE_LEFT_PAD;
- pBox->height = TEXT_HEIGHT(ICON_APPEARANCE(pcd).font);
- if (wmGD.frameStyle == WmSLAB)
- {
- /* account for less beveling in this style */
- pBox->x -= ICON_INTERNAL_SHADOW_WIDTH + 2*ICON_IMAGE_LEFT_PAD;
- pBox->y -= 3 * ICON_INTERNAL_SHADOW_WIDTH;
- pBox->width += ICON_IMAGE_LEFT_PAD + 2;
- }
- }
- else
- {
- pBox->x = ICON_EXTERNAL_SHADOW_WIDTH
- + WM_TOP_TITLE_PADDING
- + xOffset;
- if (wmGD.frameStyle == WmSLAB)
- {
- /* account for less beveling in this style */
- yOffset -= ICON_INTERNAL_SHADOW_WIDTH;
- }
- pBox->y = ICON_IMAGE_HEIGHT(pcd)
- + WM_TOP_TITLE_PADDING
- + yOffset
- + ((ICON_IMAGE_HEIGHT(pcd) > 0)
- ? ICON_INTERNAL_SHADOW_WIDTH
- : ICON_EXTERNAL_SHADOW_WIDTH);
- pBox->width = ICON_WIDTH(pcd) - 2 * ICON_EXTERNAL_SHADOW_WIDTH -
- WM_TOP_TITLE_PADDING - WM_BOTTOM_TITLE_PADDING;
- pBox->height = TEXT_HEIGHT(ICON_APPEARANCE(pcd).font);
- }
- } /* END OF FUNCTION GetIconTitleBox */
- /*************************************<->*************************************
- *
- * DrawIconTitle (pcd)
- *
- *
- * Description:
- * -----------
- * Draws the title in the Icon title area
- *
- *
- * Inputs:
- * ------
- * pcd - pointer to client data
- *
- * Outputs:
- * -------
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- void DrawIconTitle (ClientData *pcd)
- {
- XRectangle textBox;
- GC iconGC;
-
-
- GetIconTitleBox (pcd, &textBox);
- /* get appropriate GCs */
- if ((ACTIVE_PSD->useIconBox &&
- !((pcd->dtwmBehaviors & (DtWM_BEHAVIOR_PANEL)) ||
- (pcd->clientFlags & CLIENT_WM_CLIENTS))) ||
- !(wmGD.keyboardFocus == pcd))
- {
- iconGC = ICON_APPEARANCE(pcd).inactiveGC;
- }
- else
- {
- iconGC = ICON_APPEARANCE(pcd).activeGC;
- }
- /*
- * Dim text if this is in the icon box and the client is mapped
- */
- if ((ACTIVE_PSD->useIconBox) &&
- (P_ICON_BOX(pcd)) &&
- (FADE_NORMAL_ICON(pcd)) &&
- (!(pcd->clientState == MINIMIZED_STATE)))
- {
- iconGC = FADE_ICON_TEXT_GC(pcd);
- }
- /* paint the text */
- WmDrawXmString(DISPLAY, ICON_FRAME_WIN(pcd), ICON_APPEARANCE(pcd).fontList,
- pcd->iconTitle, iconGC,
- textBox.x, textBox.y, textBox.width, &textBox, True);
- } /* END OF FUNCTION DrawIconTitle */
- /*************************************<->*************************************
- *
- * RedisplayIconTitle (pcd)
- *
- *
- * Description:
- * -----------
- * Draws the title in the Icon title area
- *
- *
- * Inputs:
- * ------
- * pcd - pointer to client data
- *
- * Outputs:
- * -------
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- void RedisplayIconTitle (ClientData *pcd)
- {
- XRectangle textBox;
- GC iconGC;
- /*
- * only proceed if we've got the right icon parts to work on
- */
- if (ICON_DECORATION(pcd) & ICON_LABEL_PART && ICON_FRAME_WIN(pcd))
- {
- /* nothing to do if no labels */
- if (!(ICON_DECORATION(pcd) & ICON_LABEL_PART))
- return;
- /* get the box that the text sits in */
- GetIconTitleBox (pcd, &textBox);
- /*
- * Get appropriate GCs
- * Dim text if this is in the icon box and the client is mapped
- */
- if ((ACTIVE_PSD->useIconBox && (P_ICON_BOX(pcd)) &&
- !(pcd->clientFlags & CLIENT_WM_CLIENTS)) ||
- !(wmGD.keyboardFocus == pcd))
- {
- iconGC = ICON_APPEARANCE(pcd).inactiveGC;
- }
- else
- {
- iconGC = ICON_APPEARANCE(pcd).activeGC;
- }
- if ((ACTIVE_PSD->useIconBox) &&
- (P_ICON_BOX(pcd)) &&
- (FADE_NORMAL_ICON(pcd)) &&
- (!(pcd->clientState == MINIMIZED_STATE)))
- {
- iconGC = FADE_ICON_TEXT_GC(pcd);
- }
- /* out with the old */
- XClearArea (DISPLAY,
- ICON_FRAME_WIN(pcd),
- textBox.x, textBox.y,
- (unsigned int) textBox.width, (unsigned int) textBox.height,
- FALSE);
- /* in with the new */
- WmDrawXmString(DISPLAY, ICON_FRAME_WIN(pcd),
- ICON_APPEARANCE(pcd).fontList,
- pcd->iconTitle, iconGC,
- textBox.x, textBox.y, textBox.width, &textBox,
- True);
- /*
- * Erase & paint text in the active icon text window
- */
- if ((wmGD.keyboardFocus == pcd) &&
- (ICON_DECORATION(pcd) & ICON_ACTIVE_LABEL_PART))
- {
- PaintActiveIconText (pcd, True);
- }
- }
- } /* END OF FUNCTION RedisplayIconTitle */
- /*************************************<->*************************************
- *
- * GetIconDimensions (pSD, &pWidth, &pLabelHeight, &pImageHeight)
- *
- *
- * Description:
- * -----------
- * returns dimensions of icon frame parts
- *
- *
- * Inputs:
- * ------
- * pSD - pointer to screen data
- * pWidth - pointer to width of frame
- * pLabelHeight - pointer to height of label part of icon
- * pImageHeight - pointer to height of image part of icon
- *
- *
- * Outputs:
- * -------
- * *pWidth - width of frame
- * *pLabelHeight - height of label part of icon
- * *pImageHeight - height of image part of icon
- *
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- void GetIconDimensions (WmScreenData *pSD, unsigned int *pWidth, unsigned int *pLabelHeight, unsigned int *pImageHeight)
- {
- /*
- * The icon width is always keyed to the icon image maximum regardless
- * of whether an icon image part appears or not.
- */
- *pWidth = pSD->iconImageMaximum.width +
- ((wmGD.frameStyle == WmSLAB) ? 2 : 0) +
- ICON_IMAGE_LEFT_PAD +
- ICON_IMAGE_RIGHT_PAD +
- 2 * ICON_EXTERNAL_SHADOW_WIDTH +
- 4 * ICON_INTERNAL_SHADOW_WIDTH;
- if (wmGD.frameStyle == WmSLAB)
- {
- /* less beveling in this style */
- *pWidth -= 2 * ICON_INTERNAL_SHADOW_WIDTH;
- }
- switch (pSD->iconDecoration & (ICON_IMAGE_PART | ICON_LABEL_PART))
- {
- case ICON_LABEL_PART:
- *pImageHeight = 0;
- *pLabelHeight = ICON_EXTERNAL_SHADOW_WIDTH +
- WM_TOP_TITLE_PADDING +
- TEXT_HEIGHT(pSD->iconAppearance.font) +
- WM_BOTTOM_TITLE_PADDING +
- ICON_EXTERNAL_SHADOW_WIDTH;
- break;
- case ICON_IMAGE_PART:
- *pImageHeight = ICON_EXTERNAL_SHADOW_WIDTH +
- ICON_IMAGE_TOP_PAD +
- ICON_INTERNAL_SHADOW_WIDTH +
- ICON_INTERNAL_SHADOW_WIDTH +
- pSD->iconImageMaximum.height +
- ((wmGD.frameStyle == WmSLAB) ? 2 : 0) +
- ICON_INTERNAL_SHADOW_WIDTH +
- ICON_INTERNAL_SHADOW_WIDTH +
- ICON_IMAGE_BOTTOM_PAD +
- ICON_EXTERNAL_SHADOW_WIDTH;
- if (wmGD.frameStyle == WmSLAB)
- {
- /* less beveling in this style */
- *pImageHeight -= 2 * ICON_INTERNAL_SHADOW_WIDTH;
- }
- *pLabelHeight = 0;
- break;
- case (ICON_IMAGE_PART | ICON_LABEL_PART):
- *pImageHeight = ICON_EXTERNAL_SHADOW_WIDTH +
- ICON_IMAGE_TOP_PAD +
- ICON_INTERNAL_SHADOW_WIDTH +
- ICON_INTERNAL_SHADOW_WIDTH +
- pSD->iconImageMaximum.height +
- ((wmGD.frameStyle == WmSLAB) ? 2 : 0) +
- ICON_INTERNAL_SHADOW_WIDTH +
- ICON_INTERNAL_SHADOW_WIDTH +
- ICON_IMAGE_BOTTOM_PAD +
- ICON_INTERNAL_SHADOW_WIDTH;
- *pLabelHeight = ICON_INTERNAL_SHADOW_WIDTH +
- WM_TOP_TITLE_PADDING +
- TEXT_HEIGHT(pSD->iconAppearance.font) +
- WM_BOTTOM_TITLE_PADDING +
- ICON_EXTERNAL_SHADOW_WIDTH;
- if (wmGD.frameStyle == WmSLAB)
- {
- /*
- * In this style there is less beveling and no
- * etching between the icon image and label.
- */
- *pImageHeight -= 3 * ICON_INTERNAL_SHADOW_WIDTH;
- *pLabelHeight -= ICON_INTERNAL_SHADOW_WIDTH;
- }
- break;
- default:
- *pLabelHeight = *pImageHeight = 0;
- break;
-
- }
- }
- /*************************************<->*************************************
- *
- * InitIconSize (pSD)
- *
- *
- * Description:
- * -----------
- * set global icon size variables
- *
- *
- * Inputs:
- * ------
- *
- *
- * Outputs:
- * -------
- *
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- void InitIconSize (WmScreenData *pSD)
- {
- Cardinal label, image;
- GetIconDimensions (pSD, (unsigned int *)&(pSD->iconWidth),
- &label, &image);
-
- pSD->iconHeight = label+image;
- pSD->iconImageHeight = image;
- pSD->iconLabelHeight = label;
- iconShrinkX = IB_MARGIN_WIDTH
- + ICON_EXTERNAL_SHADOW_WIDTH
- + ICON_IMAGE_LEFT_PAD
- + 2 * ICON_INTERNAL_SHADOW_WIDTH;
-
- iconShrinkY = IB_MARGIN_HEIGHT
- + ICON_EXTERNAL_SHADOW_WIDTH
- + ((pSD->iconDecoration & ICON_IMAGE_PART)
- ? (ICON_IMAGE_TOP_PAD +
- (2 * ICON_INTERNAL_SHADOW_WIDTH))
- : (WM_TOP_TITLE_PADDING));
- if (wmGD.frameStyle == WmSLAB)
- {
- /* less beveling in this style */
- iconShrinkX -= ICON_INTERNAL_SHADOW_WIDTH;
- iconShrinkY -= ICON_INTERNAL_SHADOW_WIDTH;
- }
- iconShrinkWidth = pSD->iconImageMaximum.width ;
- if (wmGD.frameStyle == WmSLAB)
- {
- iconShrinkWidth += 2;
- }
- switch (pSD->iconDecoration & (ICON_IMAGE_PART | ICON_LABEL_PART))
- {
- case ICON_LABEL_PART:
- iconShrinkHeight = TEXT_HEIGHT(pSD->iconAppearance.font);
- break;
- case ICON_IMAGE_PART:
- iconShrinkHeight = pSD->iconImageMaximum.height;
- break;
- case (ICON_IMAGE_PART | ICON_LABEL_PART):
- iconShrinkHeight = pSD->iconHeight
- - ICON_EXTERNAL_SHADOW_WIDTH
- - ICON_IMAGE_TOP_PAD
- - ICON_INTERNAL_SHADOW_WIDTH
- - ICON_INTERNAL_SHADOW_WIDTH
- - ICON_IMAGE_BOTTOM_PAD
- - WM_BOTTOM_TITLE_PADDING
- - ICON_EXTERNAL_SHADOW_WIDTH;
- if (wmGD.frameStyle == WmSLAB)
- {
- /* adjust for less beveling in this style */
- iconShrinkHeight += ICON_INTERNAL_SHADOW_WIDTH;
- }
- break;
- }
-
- } /* END OF FUNCTION InitIconSize */
- /*************************************<->*************************************
- *
- * ShowActiveIcon (pcd)
- *
- *
- * Description:
- * -----------
- * Paint the icon to indicate an "active" state
- *
- *
- * Inputs:
- * ------
- * pcd - pointer to client data
- *
- *
- * Outputs:
- * -------
- *
- *
- * Comments:
- * --------
- *
- *
- *************************************<->***********************************/
- void ShowActiveIcon (ClientData *pcd)
- {
- unsigned long attr_mask;
- XSetWindowAttributes window_attribs;
- if (ICON_FRAME_WIN(pcd))
- {
- /*
- * Use background pixmap if one is specified, otherwise set the
- * appropriate background color.
- */
- if (ICON_APPEARANCE(pcd).activeBackgroundPixmap)
- {
- attr_mask = CWBackPixmap;
- window_attribs.background_pixmap =
- ICON_APPEARANCE(pcd).activeBackgroundPixmap;
- }
- else
- {
- attr_mask = CWBackPixel;
- window_attribs.background_pixel =
- ICON_APPEARANCE(pcd).activeBackground;
- }
-
- /* set active window attributes */
- XChangeWindowAttributes (DISPLAY,
- ICON_FRAME_WIN(pcd),
- attr_mask, &window_attribs);
- /* clear the frame to the right background */
- if ((!ACTIVE_PSD->useIconBox) ||
- (P_ICON_BOX(pcd) == NULL))
- {
- if (ICON_DECORATION(pcd) & ICON_IMAGE_PART)
- {
- Dimension dheight, dwidth;
- dwidth = ICON_WIDTH(pcd) -
- 2*ICON_EXTERNAL_SHADOW_WIDTH;
- if (ICON_DECORATION(pcd) & ICON_LABEL_PART)
- {
- dheight = ICON_IMAGE_HEIGHT(pcd) -
- ICON_EXTERNAL_SHADOW_WIDTH;
- }
- else
- {
- dheight = ICON_IMAGE_HEIGHT(pcd) -
- 2*ICON_EXTERNAL_SHADOW_WIDTH;
- }
- if (wmGD.frameStyle == WmRECESSED)
- {
- dheight -= ICON_INTERNAL_SHADOW_WIDTH;
- }
- XmeClearBorder (DISPLAY, ICON_FRAME_WIN(pcd),
- ICON_EXTERNAL_SHADOW_WIDTH,
- ICON_EXTERNAL_SHADOW_WIDTH,
- dwidth,
- dheight,
- ICON_IMAGE_TOP_PAD);
- }
- if (ICON_DECORATION(pcd) & ICON_LABEL_PART)
- {
- XClearArea (DISPLAY,
- ICON_FRAME_WIN(pcd),
- 0,
- ICON_IMAGE_HEIGHT(pcd),
- (unsigned int) ICON_WIDTH(pcd),
- (unsigned int) ICON_HEIGHT(pcd), False);
- }
- }
- else
- {
- /*
- * clear only area of real frame, not highlight area
- */
- XClearArea (DISPLAY,
- ICON_FRAME_WIN(pcd),
- IB_MARGIN_WIDTH,
- IB_MARGIN_HEIGHT,
- (unsigned int) ICON_WIDTH(pcd),
- (unsigned int) ICON_HEIGHT(pcd), False);
- }
- /*
- * Put up a big icon text label.
- */
- if (ICON_DECORATION(pcd) & ICON_ACTIVE_LABEL_PART)
-
- {
- if (wmGD.activeIconTextDisplayed)
- PaintActiveIconText(pcd, True);
- else
- ShowActiveIconText(pcd);
- }
- /* simulate exposure of window */
- IconExposureProc(pcd, False);
- }
- } /* END OF FUNCTION ShowActiveIcon */
- /*************************************<->*************************************
- *
- * ShowInactiveIcon (pcd, refresh)
- *
- *
- * Description:
- * -----------
- * Make the icon appear "inactive"
- *
- *
- * Inputs:
- * ------
- * pcd - pointer to client data
- *
- * refresh - if True redraw the icon
- *
- *************************************<->***********************************/
- void ShowInactiveIcon (ClientData *pcd, Boolean refresh)
- {
- unsigned long attr_mask = 0;
- XSetWindowAttributes window_attribs;
- /* turn off the active icon text */
- if (ICON_DECORATION(pcd) & ICON_ACTIVE_LABEL_PART)
- {
- /* pass in screen to fix multiscreen bug [P3385] */
- HideActiveIconText(pcd->pSD);
- }
-
- if (ICON_FRAME_WIN(pcd))
- {
- /*
- * Use background pixmap if one is specified, otherwise set the
- * appropriate background color.
- */
- if (ICON_APPEARANCE(pcd).backgroundPixmap)
- {
- attr_mask |= CWBackPixmap;
- window_attribs.background_pixmap =
- ICON_APPEARANCE(pcd).backgroundPixmap;
- }
- else
- {
- attr_mask |= CWBackPixel;
- window_attribs.background_pixel =
- ICON_APPEARANCE(pcd).background;
- }
-
- /* set active window attributes */
- XChangeWindowAttributes (DISPLAY, ICON_FRAME_WIN(pcd), attr_mask,
- &window_attribs);
- if (refresh)
- {
- /* clear the frame to the right background */
- if ((!ACTIVE_PSD->useIconBox) ||
- (P_ICON_BOX(pcd) == NULL))
- {
- XmeClearBorder (DISPLAY, ICON_FRAME_WIN(pcd),
- 0, 0,
- ICON_WIDTH(pcd), ICON_IMAGE_HEIGHT(pcd), 4);
- XClearArea (DISPLAY,
- ICON_FRAME_WIN(pcd),
- 0, ICON_IMAGE_HEIGHT(pcd),
- (unsigned int) ICON_WIDTH(pcd),
- (unsigned int) ICON_HEIGHT(pcd), False);
- }
- else
- {
- /*
- * clear only area of real frame, not highlight area
- */
- XClearArea (DISPLAY,
- ICON_FRAME_WIN(pcd),
- IB_MARGIN_WIDTH,
- IB_MARGIN_HEIGHT,
- (unsigned int) ICON_WIDTH(pcd),
- (unsigned int) ICON_HEIGHT(pcd), False);
- }
-
- /* simulate exposure of window */
- IconExposureProc(pcd, False);
- }
- }
- } /* END OF FUNTION ShowInactiveIcon */
- /*************************************<->*************************************
- *
- * ReparentIconWindow (pcd, xOffset, yOffset)
- *
- *
- * Description:
- * -----------
- * Reparent the icon window in the center of the image area
- *
- *
- * Inputs:
- * ------
- * pcd - pointer to client data
- * xOffset - adjusts for icons in the iconBox
- * yOffset - adjusts for icons in the iconBox
- *
- *
- * Outputs:
- * -------
- *
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- void ReparentIconWindow (ClientData *pcd, int xOffset, int yOffset)
- {
- int x, y, rpX, rpY;
- unsigned int width, height, bw, depth;
- Window root;
- XWindowChanges windowChanges;
- unsigned int mask;
- if (!pcd->pECD)
- {
- /*
- * Check if window size is too big
- */
- XGetGeometry (DISPLAY, pcd->iconWindow, &root, &x, &y, &width, &height,
- &bw, &depth);
- /*
- * strip off previous window border and set window geometry to
- * fit inside icon frame
- */
- if (width != 0) {
- mask = CWBorderWidth;
- windowChanges.border_width = 0;
- }
- else
- {
- mask = 0;
- }
- if (width > ((ICON_IMAGE_MAXIMUM(pcd).width) +
- ((wmGD.frameStyle == WmSLAB) ? 2 : 0)))
- {
- width = windowChanges.width = ICON_IMAGE_MAXIMUM(pcd).width +
- ((wmGD.frameStyle == WmSLAB) ? 2 : 0);
- mask |= CWWidth;
- }
- else if (width < ICON_IMAGE_MINIMUM(pcd).width) {
- width = windowChanges.width = ICON_IMAGE_MINIMUM(pcd).width;
- mask |= CWWidth;
- }
- if (height > ((ICON_IMAGE_MAXIMUM(pcd).height) +
- ((wmGD.frameStyle == WmSLAB) ? 2 : 0)))
- {
- height = windowChanges.height = ICON_IMAGE_MAXIMUM(pcd).height +
- ((wmGD.frameStyle == WmSLAB) ? 2 : 0);
- mask |= CWHeight;
- }
- else if (height < ICON_IMAGE_MINIMUM(pcd).height) {
- height = windowChanges.height = ICON_IMAGE_MINIMUM(pcd).height;
- mask |= CWHeight;
- }
- if (mask)
- XConfigureWindow (DISPLAY, pcd->iconWindow, mask, &windowChanges);
- /*
- * Reparent the icon window to the center of the icon image frame
- */
- if (ICON_DECORATION(pcd) & ICON_LABEL_PART)
- {
- yOffset += ICON_INTERNAL_SHADOW_WIDTH;
- }
- rpX = ((ICON_WIDTH(pcd) - width)/2) + xOffset;
- rpY = ((ICON_IMAGE_HEIGHT(pcd) - height)/2) + yOffset;
- XReparentWindow (DISPLAY, pcd->iconWindow, ICON_FRAME_WIN(pcd), rpX, rpY);
- pcd->clientFlags |= ICON_REPARENTED;
- /*
- * Map the icon window when the icon frame is mapped.
- */
- } /* END if (!pcd->pECD) */
- } /* END OF FUNCTION ReparentIconWindow */
- /*************************************<->*************************************
- *
- * PutBoxOnScreen (screen, px, py, width, height)
- *
- *
- * Description:
- * -----------
- * Changes the position of the passed box so that it is all on screen
- *
- *
- * Inputs:
- * ------
- * screen - screen we're talking about
- * px - pointer to x-coord
- * py - pointer to y-coord
- * width - width of box
- * height - height of box
- *
- * Outputs:
- * -------
- * *px - new x-coord
- * *py - new y-coord
- *
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- void PutBoxOnScreen (int screen, int *px, int *py, unsigned int width, unsigned int height)
- {
- /*
- * Place active label text nicely on screen
- */
- if (*px+width+1 > DisplayWidth (DISPLAY, screen))
- *px -= (*px+width+1) - DisplayWidth (DISPLAY, screen);
- if (*py+height+1 > DisplayHeight (DISPLAY, screen))
- *py -= (*py+height+1) - DisplayHeight (DISPLAY, screen);
- if (*px < 1) *px = 1;
- if (*py < 1) *py = 1;
- } /* END OF FUNCTION PutBoxOnScreen */
- /*************************************<->*************************************
- *
- * PutBoxInIconBox (pCD, px, py, width, height)
- *
- *
- * Description:
- * -----------
- * Changes the position of the passed box so that it is not
- * clipped by the bulletin board
- *
- *
- *
- * Inputs:
- * ------
- * pCD - pointer to client data
- * px - pointer to x-coord
- * py - pointer to y-coord
- * width - width of box
- * height - height of box
- *
- * Outputs:
- * -------
- * *px - new x-coord
- * *py - new y-coord
- *
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- void PutBoxInIconBox (ClientData *pCD, int *px, int *py, unsigned int *width, unsigned int *height)
- {
- int i;
- Arg getArgs[3];
- Dimension bBoardWidth;
- Dimension bBoardHeight;
- int clipWidth;
- int clipHeight;
- i=0;
- XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &bBoardWidth ); i++;
- XtSetArg (getArgs[i], XmNheight, (XtArgVal) &bBoardHeight ); i++;
- XtGetValues (P_ICON_BOX(pCD)->bBoardWidget, getArgs, i);
- clipWidth = (int) bBoardWidth;
- clipHeight = (int) bBoardHeight;
- if (*px + *width-1 > clipWidth)
- *px -= (*px + *width-1) - clipWidth;
- if (*py + *height-1 > clipHeight)
- *py -= (*py + *height-1) - clipHeight;
- if (*px < 0) *px = 0;
- if (*py < 0) *py = 0;
- } /* END OF FUNCTION PutBoxInIconBox */
- /*************************************<->*************************************
- *
- * CreateActiveIconTextWindow (pSD)
- *
- *
- * Description:
- * -----------
- * creates the window that's popped up when an icon is activated
- *
- * Inputs:
- * ------
- * pSD - pointer to screen data
- *
- * Outputs:
- * -------
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- void CreateActiveIconTextWindow (WmScreenData *pSD)
- {
- XSetWindowAttributes window_attribs;
- unsigned long attr_mask;
- /* create active icon text window */
- attr_mask = CWEventMask| CWCursor;
- window_attribs.event_mask = ExposureMask;
- window_attribs.cursor = wmGD.workspaceCursor;
- /*
- * Use background pixmap if one is specified, otherwise set the
- * appropriate background color.
- */
- if (pSD->iconAppearance.activeBackgroundPixmap)
- {
- attr_mask |= CWBackPixmap;
- window_attribs.background_pixmap =
- pSD->iconAppearance.activeBackgroundPixmap;
- }
- else
- {
- attr_mask |= CWBackPixel;
- window_attribs.background_pixel =
- pSD->iconAppearance.activeBackground;
- }
-
- pSD->activeIconTextWin = XCreateWindow (DISPLAY,
- pSD->rootWindow, /* parent */
- 0, 0, /* x, y */
- 1, 1, /* width, height */
- 0, /* border width */
- CopyFromParent, /* depth */
- InputOutput, /* class */
- CopyFromParent, /* visual */
- attr_mask,
- &window_attribs);
-
- pSD->activeLabelParent = pSD->rootWindow;
- } /* END OF FUNCTION CreateActiveIconTextWindow */
- /*************************************<->*************************************
- *
- * PaintActiveIconText (pcd, erase)
- *
- *
- * Description:
- * -----------
- *
- *
- * Inputs:
- * ------
- * pcd - pointer to client data
- * erase - if true, then erase the area before repainting
- *
- * Outputs:
- * -------
- *
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- void PaintActiveIconText (ClientData *pcd, Boolean erase)
- {
- XRectangle textBox;
- GC iconGC, topGC, botGC;
- if (!(ICON_DECORATION(pcd) & ICON_ACTIVE_LABEL_PART))
- return;
- /* get appropriate GCs */
- iconGC = ICON_APPEARANCE(pcd).activeGC;
- topGC = ICON_APPEARANCE(pcd).activeTopShadowGC;
- botGC = ICON_APPEARANCE(pcd).activeBottomShadowGC;
- /* draw shadowing */
- if (pActiveIconTopRects) {
- XFillRectangles (DISPLAY,
- pcd->pSD->activeIconTextWin,
- topGC,
- pActiveIconTopRects->prect,
- pActiveIconTopRects->used);
- }
- if (pActiveIconBotRects) {
- XFillRectangles (DISPLAY,
- pcd->pSD->activeIconTextWin,
- botGC,
- pActiveIconBotRects->prect,
- pActiveIconBotRects->used);
- }
- /* paint the text */
- textBox.x = ICON_EXTERNAL_SHADOW_WIDTH;
- textBox.y = ICON_EXTERNAL_SHADOW_WIDTH;
- textBox.width = activeIconTextWidth - 2*ICON_EXTERNAL_SHADOW_WIDTH;
- textBox.height = activeIconTextHeight - 2*ICON_EXTERNAL_SHADOW_WIDTH;
- if (erase)
- {
- XClearArea (DISPLAY, pcd->pSD->activeIconTextWin, textBox.x, textBox.y,
- (unsigned int) textBox.width,
- (unsigned int) textBox.height,
- FALSE);
- }
- WmDrawXmString(DISPLAY, pcd->pSD->activeIconTextWin,
- ICON_APPEARANCE(pcd).fontList,
- pcd->iconTitle, iconGC,
- textBox.x, textBox.y, textBox.width, &textBox, True);
- } /* END OF FUNCTION PaintActiveIconText */
- /*************************************<->*************************************
- *
- * ShowActiveIconText (pcd)
- *
- *
- * Description:
- * -----------
- *
- *
- * Inputs:
- * ------
- *
- * Outputs:
- * -------
- *
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- void ShowActiveIconText (ClientData *pcd)
- {
- XWindowAttributes iconFrameAttribs;
- XSetWindowAttributes window_attribs;
- XWindowChanges windowChanges;
- unsigned int mask;
- int x, y;
- unsigned int junk;
- Window root;
- Dimension dWidth, dHeight;
- /*
- * put up a big icon text label
- */
- if (pcd->pSD->activeIconTextWin) {
- /* copy event mask from icon frame window */
- XGetWindowAttributes (DISPLAY, ICON_FRAME_WIN(pcd), &iconFrameAttribs);
- /* set attributes of window */
- window_attribs.event_mask = iconFrameAttribs.your_event_mask;
- XChangeWindowAttributes (DISPLAY, pcd->pSD->activeIconTextWin,
- CWEventMask, &window_attribs);
- /* set up geometry for the window */
- XmStringExtent (ICON_APPEARANCE(pcd).fontList, pcd->iconTitle,
- &dWidth, &dHeight);
- activeIconTextHeight = (unsigned int) dHeight +
- WM_BOTTOM_TITLE_PADDING +
- 2*ICON_EXTERNAL_SHADOW_WIDTH;
- activeIconTextWidth = (unsigned int) dWidth;
- if (activeIconTextWidth < (1.2 * ICON_WIDTH(pcd)))
- {
- activeIconTextWidth = 1.2 * ICON_WIDTH(pcd);
- }
- activeIconTextWidth += 2*ICON_EXTERNAL_SHADOW_WIDTH;
- XGetGeometry (DISPLAY,
- (Drawable) ICON_FRAME_WIN(pcd),
- &root, &x, &y,
- &junk, &junk, &junk, &junk);
- y += ICON_IMAGE_HEIGHT(pcd);
- x -= (activeIconTextWidth - ICON_WIDTH(pcd))/2;
- if (!(P_ICON_BOX(pcd)))
- {
- /*
- * This is a normal icon
- */
- PutBoxOnScreen (SCREEN_FOR_CLIENT(pcd), &x, &y,
- activeIconTextWidth, activeIconTextHeight);
- if (ACTIVE_LABEL_PARENT(pcd) != root)
- {
- XReparentWindow(DISPLAY, pcd->pSD->activeIconTextWin ,
- root, x, y );
- ACTIVE_LABEL_PARENT(pcd) = root;
- }
-
- }
- else
- {
- /*
- * This is an icon in an icon box
- */
- x = x + IB_MARGIN_WIDTH;
- y = y + IB_MARGIN_HEIGHT;
- if(!(pcd->pSD->iconDecoration & ( ICON_LABEL_PART)))
- {
- y -= activeIconTextHeight;
- }
- PutBoxInIconBox (pcd, &x, &y,
- &activeIconTextWidth, &activeIconTextHeight);
- if (ACTIVE_LABEL_PARENT(pcd) != pcd->client)
- {
- XReparentWindow(DISPLAY, pcd->pSD->activeIconTextWin ,
- XtWindow(P_ICON_BOX(pcd)->bBoardWidget),
- x, y );
- ACTIVE_LABEL_PARENT(pcd) = pcd->client;
- }
- }
- mask = CWX | CWY | CWWidth | CWHeight;
- windowChanges.x = x;
- windowChanges.y = y;
- windowChanges.width = activeIconTextWidth;
- windowChanges.height = activeIconTextHeight;
- XConfigureWindow (DISPLAY, pcd->pSD->activeIconTextWin, mask,
- &windowChanges);
- /* bevel the rectangle around the edges */
- if ((pActiveIconTopRects && pActiveIconBotRects) ||
- ((pActiveIconTopRects =
- AllocateRList((unsigned)4*ICON_EXTERNAL_SHADOW_WIDTH)) &&
- (pActiveIconBotRects =
- AllocateRList((unsigned)4*ICON_EXTERNAL_SHADOW_WIDTH))))
- {
- pActiveIconTopRects->used = 0;
- pActiveIconBotRects->used = 0;
- BevelRectangle (pActiveIconTopRects,
- pActiveIconBotRects,
- 0, 0,
- activeIconTextWidth,
- activeIconTextHeight,
- ICON_EXTERNAL_SHADOW_WIDTH,
- ICON_EXTERNAL_SHADOW_WIDTH,
- ICON_EXTERNAL_SHADOW_WIDTH,
- ICON_EXTERNAL_SHADOW_WIDTH);
- }
- XMapRaised (DISPLAY, pcd->pSD->activeIconTextWin);
- wmGD.activeIconTextDisplayed = True;
- /* save context for this window */
- XSaveContext (DISPLAY, pcd->pSD->activeIconTextWin,
- wmGD.windowContextType, (caddr_t) pcd);
- }
- } /* END OF FUNCTION ShowActiveIconText */
- /*************************************<->*************************************
- *
- * HideActiveIconText ()
- *
- *
- * Description:
- * -----------
- * Hides the big label shown over the active icon.
- *
- *
- * Inputs:
- * ------
- *
- * Outputs:
- * -------
- *
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- void HideActiveIconText (WmScreenData *pSD)
- {
- if ((pSD && pSD->activeIconTextWin) || ACTIVE_ICON_TEXT_WIN)
- {
- /* disassociate the big label window with this client */
- XDeleteContext (DISPLAY,
- pSD
- ? pSD->activeIconTextWin
- : ACTIVE_PSD->activeIconTextWin,
- wmGD.windowContextType);
- /* hide the big label */
- XUnmapWindow (DISPLAY,
- pSD
- ? pSD->activeIconTextWin
- : ACTIVE_PSD->activeIconTextWin);
- wmGD.activeIconTextDisplayed = False;
- }
- }
- /*************************************<->*************************************
- *
- * MoveActiveIconText (pcd)
- *
- *
- * Description:
- * -----------
- *
- *
- * Inputs:
- * ------
- *
- * Outputs:
- * -------
- *
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- void MoveActiveIconText (ClientData *pcd)
- {
- int x, y;
- unsigned int junk;
- Window root;
- Dimension dWidth, dHeight;
-
-
- /*
- * put up a big icon text label
- */
- if (pcd->pSD->activeIconTextWin && wmGD.activeIconTextDisplayed) {
- /* set up geometry for the window */
- XmStringExtent (ICON_APPEARANCE(pcd).fontList, pcd->iconTitle,
- &dWidth, &dHeight);
- activeIconTextHeight = (unsigned int) dHeight +
- WM_BOTTOM_TITLE_PADDING +
- 2 * ICON_EXTERNAL_SHADOW_WIDTH;
-
- activeIconTextWidth = (unsigned int) dWidth;
- if (activeIconTextWidth < (1.2 * ICON_WIDTH(pcd)))
- {
- activeIconTextWidth = 1.2 * ICON_WIDTH(pcd);
- }
-
- activeIconTextWidth += 2 * ICON_EXTERNAL_SHADOW_WIDTH;
- XGetGeometry (DISPLAY,
- (Drawable) ICON_FRAME_WIN(pcd),
- &root, &x, &y,
- &junk, &junk, &junk, &junk);
-
- y += ICON_IMAGE_HEIGHT(pcd);
- x -= (activeIconTextWidth - ICON_WIDTH(pcd))/2;
- if (!(P_ICON_BOX(pcd)))
- {
- /* This is a normal icon */
- PutBoxOnScreen (SCREEN_FOR_CLIENT(pcd), &x, &y,
- activeIconTextWidth, activeIconTextHeight);
- }
- else
- {
- /* icon box */
- x = x + IB_MARGIN_WIDTH;
- y = y + IB_MARGIN_HEIGHT;
- if(!(pcd->pSD->iconDecoration & ( ICON_LABEL_PART)))
- {
- y -= activeIconTextHeight;
- }
- PutBoxInIconBox (pcd, &x, &y,
- &activeIconTextWidth, &activeIconTextHeight);
- }
-
- XMoveWindow(DISPLAY, pcd->pSD->activeIconTextWin, x, y );
- }
- } /* END OF FUNCTION MoveActiveIconText */
|