12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906 |
- /*
- * 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, 1994 OPEN SOFTWARE FOUNDATION, INC.
- * ALL RIGHTS RESERVED
- */
- /*
- * Motif Release 1.2.4
- */
- /*
- * (c) Copyright 1987, 1988, 1989, 1990, 1992, 1993 HEWLETT-PACKARD COMPANY
- */
- /*
- * Included Files:
- */
- #include "WmGlobal.h"
- #include "WmICCC.h"
- /*
- * include extern functions
- */
- #include "WmCDecor.h"
- #include "WmCEvent.h"
- #include "WmColormap.h"
- #include "WmError.h"
- #include "WmEvent.h"
- #include "WmFunction.h"
- #include "WmGraphics.h"
- #include "WmIDecor.h"
- #include "WmIconBox.h"
- #include "WmImage.h"
- #include "WmInstantTitle.h"
- #include "WmKeyFocus.h"
- #include "WmPanelP.h" /* typedef needed in WmManage.h */
- #include <Dt/Message.h>
- #include "WmIPC.h"
- #include "WmManage.h"
- #include "WmMenu.h"
- #include "WmProperty.h"
- #include "WmProtocol.h"
- #include "WmWinInfo.h"
- #include "WmWinList.h"
- #include "WmWinState.h"
- #include "WmPresence.h"
- #include "WmWrkspace.h"
- #include "WmXSMP.h"
- /*
- * Function Declarations:
- */
- Boolean IsEmbeddedClient (
- ClientData *pCD,
- WmFpEmbeddedClientData **ppECD);
- Boolean ManageEmbeddedClient (
- ClientData *pCD,
- WmFpEmbeddedClientData *pECD,
- long manageFlags);
- Boolean IsPushRecallClient (
- ClientData *pCD,
- WmFpPushRecallClientData **ppPRCD);
- static void HandleSubstructEvents(
- Widget w,
- caddr_t ptr,
- XEvent *event );
- Boolean UpdateEmbeddedClientsProperty(
- WmScreenData *pSD );
- static void ForceSubpanelWMState(Window win);
- static void ReManageWindow (ClientData *pCD);
- static void CheckPushRecallClient (ClientData *pCD);
- /*
- * Global Variables:
- */
- static void ApplyPrematureClientMessages (ClientData *pCD)
- {
- unsigned long i, nitems, leftover;
- int actualFormat;
- Atom actualType;
- Atom property = wmGD.xa_PREMATURE_XCLIENTMESSAGEEVENT_LIST;
- XClientMessageEvent *messages = NULL;
- if (!HasProperty (pCD, property)) goto err;
- if (XGetWindowProperty (DISPLAY, pCD->client, property, 0L, 1000000L, True,
- property, &actualType, &actualFormat, &nitems,
- &leftover, (unsigned char **)&messages) != Success)
- goto err;
- if (actualType != property) goto err;
- nitems /= sizeof (XClientMessageEvent);
- if (!nitems) goto err;
- for (i = 0; i < nitems; ++i) HandleClientMessage (pCD, &messages[i]);
- err:
- if (messages) XFree (messages);
- }
- /*************************************<->*************************************
- *
- * AdoptInitialClients (pSD)
- *
- * Inputs:
- * -------
- * pSD = pointer to screen data
- *
- *
- * Description:
- * -----------
- * This function is called to find client windows that were mapped prior to
- * starting (or restarting) the window manager. These windows are included
- * in the set of windows managed by the window manager.
- *
- *************************************<->***********************************/
- void AdoptInitialClients (WmScreenData *pSD)
- {
- Window root;
- Window parent;
- Window *clients;
- int nAncillaries, iAnc;
- Window *pAncillaryWindows, *pWin1;
- WmWorkspaceData *pWS0;
- unsigned int nclients;
- ClientData *pcd = NULL;
- PropWMState *wmStateProp;
- Boolean manageOnRestart;
- int i,j;
- long manageFlags;
- /*
- * Generate list of ancillary windows (not to be managed)
- */
- nAncillaries = 2 + pSD->numWorkspaces;
- pAncillaryWindows = (Window *) XtMalloc (sizeof(Window)*(nAncillaries));
- if (!pAncillaryWindows)
- {
- Warning (((char *)GETMESSAGE(46, 1, "Insufficient memory to adopt initial clients")));
- ExitWM (WM_ERROR_EXIT_VALUE);
- }
- pWS0 = pSD->pWS;
- pWin1 = pAncillaryWindows;
- for (iAnc = 0; iAnc < pSD->numWorkspaces; iAnc++)
- {
- *pWin1 = XtWindow((pWS0)->workspaceTopLevelW);
- pWin1++;
- pWS0++;
- }
- *pWin1++ = XtWindow (pSD->screenTopLevelW);
- *pWin1 = pSD->activeIconTextWin;
- /*
- * Look for mapped top-level windows and start managing them:
- */
- if (XQueryTree (DISPLAY, pSD->rootWindow, &root, &parent, &clients,
- &nclients))
- {
- /*
- * Filter out icon windows so they don't get managed as a client
- * window. Icon windows will be process in SetupClientIconWindow().
- */
- XWMHints *tmphint;
- for (i = 0; i < nclients; i++) {
- if (clients[i]) {
- if ((tmphint = XGetWMHints (DISPLAY, clients[i])) != NULL) {
- if (tmphint->flags & IconWindowHint) {
- for (j = 0; j < nclients; j++) {
- if (clients[j] == tmphint->icon_window) {
- clients[j] = None;
- break;
- }
- }
- }
- XFree ((char *) tmphint);
- }
- }
- }
- for (i = 0; i < nclients; i++)
- {
- /* determine if the client window should be managed by wm */
- if (InWindowList (clients[i], pAncillaryWindows, nAncillaries))
- {
- /* don't manage ancillary window manager windows */
- continue;
- }
- if (!XFindContext (DISPLAY, clients[i], wmGD.windowContextType,
- (caddr_t *)&pcd))
- {
- /* don't manage a window we've already established a
- context for (e.g. icon windows) */
- continue;
- }
- if (!WmGetWindowAttributes (clients[i]))
- {
- /* can't access the window; ignore it */
- continue;
- }
- /* window attributes are put into the global cache */
- /*
- * Get the window WM_STATE property value to determine the
- * initial window state if the wm is being restarted.
- */
- manageFlags = MANAGEW_WM_STARTUP;
- manageOnRestart = True;
- if (wmGD.wmRestarted)
- {
- manageFlags |= MANAGEW_WM_RESTART;
- if ((wmStateProp = GetWMState (clients[i])) != NULL)
- {
- if (wmStateProp->state == IconicState)
- {
- manageFlags |= MANAGEW_WM_RESTART_ICON;
- }
- else if (wmStateProp->state != NormalState)
- {
- manageOnRestart = False;
- }
- XFree ((char *)wmStateProp);
- }
- else
- {
- manageOnRestart = False;
- }
- }
- /*
- * Don't manage any override_redirect windows (mapped or not).
- * Manage an unmapped window if it has a WM_STATE property
- * and it is not Withdrawn.
- * Manage any window that is mapped.
- */
- if ((wmGD.windowAttributes.override_redirect != True) &&
- ((wmGD.wmRestarted && manageOnRestart) ||
- (wmGD.windowAttributes.map_state != IsUnmapped)))
- {
- ManageWindow (pSD, clients[i], manageFlags);
- }
- }
- if (nclients)
- {
- XFree ((char *)clients);
- }
- }
- if (pAncillaryWindows)
- {
- XtFree ((char *) pAncillaryWindows);
- }
- } /* END OF FUNCTION AdoptInitialClients */
- /*************************************<->*************************************
- *
- * ManageWindow (pSD, clientWindow, manageFlags)
- *
- *
- * Description:
- * -----------
- * This is the highlevel function that is used to include a window in
- * the set of windows that are managed by the window manager. The window
- * gets reparented and decorated, gets an icon, is setup for window
- * management event handling, etc. Client windows that are controlled
- * by the window manager (e.g., the icon box) are also managed with
- * this function.
- *
- *
- * Inputs:
- * ------
- * clientWindow = window of the client that we should manage
- *
- * manageFlags = additional control information
- *
- *
- * Outputs:
- * -------
- * pCD = initialized client data
- *
- *************************************<->***********************************/
- void
- ManageWindow (WmScreenData *pSD, Window clientWindow, long manageFlags)
- {
- ClientData *pCD;
- int initialState;
- int i;
- Boolean sendConfigNotify;
- WmWorkspaceData *pwsi;
- WmFpEmbeddedClientData *pECD;
- /*
- * Get client information including window attributes and window
- * property values. Use this information to determine how the window
- * is to be managed.
- */
- if (!(pCD = GetClientInfo (pSD, clientWindow, manageFlags)))
- {
- /* error getting client info; do not manage the client window */
- return;
- }
- /*
- * Handle case of transients that derive from embedded clients.
- */
- if (wmGD.dtSD && (wmGD.dtSD == pCD->pSD))
- {
- if (pCD->transientLeader && pCD->transientLeader->pECD)
- {
- WmPanelistObject pPanelist;
- ClientData *pCDfp = NULL;
- pPanelist = (WmPanelistObject) pCD->pSD->wPanelist;
- (void) XFindContext (DISPLAY, XtWindow(O_Shell (pPanelist)),
- wmGD.windowContextType, (caddr_t *)&pCDfp);
- pCD->transientLeader = pCDfp;
- }
- }
- if (IsEmbeddedClient (pCD, &pECD))
- {
- /*
- * This client is embedded in the front panel
- */
-
- if (ManageEmbeddedClient(pCD, pECD, manageFlags))
- {
- /*
- * ...then we've embedded it in the front
- * panel--no further processing required.
- */
- if (smAckState == SM_START_ACK)
- {
- SendClientMsg( wmGD.dtSmWindow,
- (long) wmGD.xa_DT_SM_WM_PROTOCOL,
- (long) wmGD.xa_DT_WM_WINDOW_ACK,
- CurrentTime, NULL, 0);
- }
- return;
- }
- }
-
- /*
- * Handle case of transients that derive from embedded clients.
- * !!!!
- */
- #if 0
- if (pCD->transientLeader && pCD->transientLeader->pAccessPanel)
- {
- pCD->transientLeader =
- pCD->transientLeader->pAccessPanel->pCD_accessPanel;
- }
- #endif
- if (pCD->inputMode == MWM_INPUT_SYSTEM_MODAL)
- {
- /*
- * Put system modal windows in all workspaces to
- * avoid the race condition of the window coming up
- * just as the user switches workspaces.
- */
- pCD->dtwmFunctions |= DtWM_FUNCTION_OCCUPY_WS;
- F_AddToAllWorkspaces(0, pCD, 0);
- pCD->dtwmFunctions &= ~DtWM_FUNCTION_OCCUPY_WS;
- }
- if (manageFlags & MANAGEW_WM_RESTART)
- {
- if (manageFlags & MANAGEW_WM_RESTART_ICON)
- {
- pCD->clientState = MINIMIZED_STATE;
- }
- else
- {
- pCD->clientState = NORMAL_STATE;
- }
- }
- /*
- * Setup the initial placement of the client window. Do interactive
- * placement if configured.
- */
- sendConfigNotify = InitClientPlacement (pCD, manageFlags);
- /*
- * Make a window frame for the client window and reparent the client
- * window.
- */
- if (!FrameWindow (pCD))
- {
- /*
- * Error in framing the window; clean up the wm resources made
- * up to this point for the client window. Do not manage the
- * client window.
- */
- UnManageWindow (pCD);
- return;
- }
- ApplyPrematureClientMessages (pCD);
- if (!HasProperty (pCD, wmGD.xa__NET_WM_STATE))
- UpdateNetWmState (pCD->client, NULL, 0, _NET_WM_STATE_REMOVE);
- /*
- * Send config notify if the client's been moved/resized
- */
- if (sendConfigNotify)
- {
- SendConfigureNotify (pCD);
- }
- /*
- * Send client offset message if:
- *
- * 1. The client is interested.
- * 2. The position we report to the user is not the client's real
- * position.
- * 3. There is a client offset to report.
- */
- if ((pCD->protocolFlags & PROTOCOL_MWM_OFFSET) &&
- (wmGD.positionIsFrame) &&
- ((pCD->clientOffset.x != 0) ||
- (pCD->clientOffset.y != 0)))
- {
- SendClientOffsetMessage (pCD);
- }
- /*
- * Make an icon for the client window if it is not a valid transient
- * window.
- */
- if ((pCD->clientFunctions & MWM_FUNC_MINIMIZE) &&
- (pCD->transientLeader == NULL))
- {
- /*
- * Make icons frames
- * Only make one icon frame for root icons.
- * Make one per workspace for icon box icons.
- */
- for (i = 0; i < pCD->numInhabited; i++)
- {
- if ((pwsi = GetWorkspaceData(pCD->pSD, pCD->pWsList[i].wsID)))
- {
- if ((pCD->pSD->useIconBox &&
- !(manageFlags & MANAGEW_WM_CLIENTS) &&
- !(pCD->clientFlags & FRONT_PANEL_BOX)) || (i == 0))
- {
- /*
- * Make icon inside an icon box for non-root case
- */
- if (!MakeIcon (pwsi, pCD))
- {
- /*
- * Error in making an icon for the client window;
- * clean up the wm resources; do not manage the
- * client window.
- */
- UnManageWindow (pCD);
- return;
- }
- else
- {
- XSaveContext (DISPLAY, pCD->pWsList[i].iconFrameWin,
- wmGD.windowContextType, (caddr_t)pCD);
- if (pCD->iconWindow && pCD->pWsList[i].iconFrameWin)
- {
- XGrabButton (DISPLAY, AnyButton, AnyModifier,
- pCD->pWsList[i].iconFrameWin, True,
- ButtonPressMask|ButtonReleaseMask|
- ButtonMotionMask,
- GrabModeAsync, GrabModeAsync, None,
- wmGD.workspaceCursor);
- }
- }
- }
- else
- {
- /*
- * Make root icons for a client
- */
- if ((pCD->clientFunctions & MWM_FUNC_MINIMIZE) &&
- (pCD->transientLeader == NULL))
- {
- if ((i == 0) &&
- (!MakeIcon (pwsi, pCD)))
- {
- /*
- * Error in making an icon for the client
- * window; clean up the wm resources; do
- * not manage the client window.
- */
-
- UnManageWindow (pCD);
- return;
- }
- else
- {
- /* copy root icon frame reference to other
- * workspaces
- */
- pCD->pWsList[i].iconFrameWin =
- pCD->pWsList[0].iconFrameWin;
- }
- }
- }
- }
- }
- }
- /*
- * Register window contexts to facilitate event handling:
- */
- XSaveContext (DISPLAY, pCD->clientFrameWin, wmGD.windowContextType,
- (caddr_t)pCD);
- XSaveContext (DISPLAY, pCD->clientBaseWin, wmGD.windowContextType,
- (caddr_t)pCD);
- if (DECOUPLE_TITLE_APPEARANCE(pCD) && pCD->clientTitleWin)
- {
- /*
- * handle exposures on title bar if it has its own appearance
- */
- XSaveContext (DISPLAY, pCD->clientTitleWin, wmGD.windowContextType,
- (caddr_t)pCD);
- }
- if (pCD->clientCmapCount > 0)
- {
- for (i = 0; i < pCD->clientCmapCount; i++)
- {
- if (pCD->cmapWindows[i] != pCD->client)
- {
- #ifndef IBM_169380
- AddColormapWindowReference(pCD, pCD->cmapWindows[i]);
- #else
- XSaveContext (DISPLAY, pCD->cmapWindows[i],
- wmGD.windowContextType, (caddr_t)pCD);
- #endif
- }
- }
- }
- pCD->clientFlags |= CLIENT_CONTEXT_SAVED;
- /*
- * Setup button binding handling for actions that apply to the client
- * window.
- */
- if (BUTTON_SPECS(pCD))
- {
- SetupCButtonBindings (pCD->clientBaseWin, BUTTON_SPECS(pCD));
- }
- /*
- * Setup key binding handling for system menu accelerators.
- */
- if (pCD->systemMenuSpec &&
- (pCD->systemMenuSpec->accelKeySpecs))
- {
- SetupKeyBindings (pCD->systemMenuSpec->accelKeySpecs,
- pCD->clientFrameWin, GrabModeSync, F_CONTEXT_ALL);
- for (i = 0; i < pCD->numInhabited; i++)
- {
- if (!pCD->pWsList[i].pIconBox && pCD->pWsList[i].iconFrameWin)
- {
- SetupKeyBindings (pCD->systemMenuSpec->accelKeySpecs,
- pCD->pWsList[i].iconFrameWin, GrabModeSync,
- F_CONTEXT_ALL);
- }
- }
- }
- for (i = 0; i < pCD->numInhabited; i++)
- {
- if (!pCD->pWsList[i].pIconBox && pCD->pWsList[i].iconFrameWin)
- {
- static int iconKeySpec = 1;
- static int iconAccelSpec = 1;
- if ((iconKeySpec != 0) && KEY_SPECS(pCD))
- {
- iconKeySpec = SetupKeyBindings (KEY_SPECS(pCD),
- pCD->pWsList[i].iconFrameWin,
- GrabModeSync, F_CONTEXT_ICON);
- }
- if ((iconAccelSpec != 0) && ACCELERATOR_MENU_COUNT(pCD))
- {
- int n;
- iconAccelSpec = 0;
- for (n= 0; n < pSD->acceleratorMenuCount; n++)
- {
- iconAccelSpec += SetupKeyBindings (
- ACCELERATOR_MENU_SPECS(pCD)[n]->accelKeySpecs,
- pCD->pWsList[i].iconFrameWin, GrabModeSync,
- F_CONTEXT_ICON);
- }
- }
- }
- }
- /*
- * Setup keyboard focus handling if policy is "explicit".
- */
- if (wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_EXPLICIT)
- {
- DoExplicitSelectGrab (pCD->clientBaseWin);
- }
- UpdateWorkspacePresenceProperty(pCD);
- /*
- * Make sure the client window has been reparented ...
- */
- if (!(manageFlags & MANAGEW_WM_CLIENTS))
- {
- XSync (DISPLAY, False);
- if (pCD->clientFlags & CLIENT_DESTROYED)
- {
- UnManageWindow (pCD);
- return;
- }
- }
- /*
- * Setup the initial display state for the client window:
- */
- initialState = pCD->clientState;
- if (!ClientInWorkspace (pSD->pActiveWS, pCD))
- {
- initialState |= UNSEEN_STATE;
- }
- pCD->clientState = WITHDRAWN_STATE;
- pCD->clientFlags &= ~WM_INITIALIZATION;
- /*
- * Add to stacking list using the client's zero'th workspace
- * instead of the current one because it may not be in
- * the current one.
- */
- AddClientToList (GetWorkspaceData (pSD, pCD->pWsList[0].wsID),
- pCD, True /*on top*/);
- SetClientState (pCD, initialState, GetTimestamp());
- /*
- * Set the keyboard input focus to the newly managed window if appropriate:
- * - focus is automatically set only if the focus policy is explicit
- * - if there is a system modal window active then set the focus only
- * if the new window is in the system modal hierarchy
- * - focus is automatically set if startupKeyFocus is selected or
- * the new window is a system modal window or the current focus window
- * has the new window as an application modal subordinate
- * - don't automatically set the focus if the window is minimized or
- * is a window that generally doesn't take input
- */
- if ((wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_EXPLICIT) &&
- ((pCD->inputMode == MWM_INPUT_SYSTEM_MODAL) ||
- ((!wmGD.systemModalActive ||
- (wmGD.systemModalClient == FindTransientTreeLeader (pCD))) &&
- (wmGD.startupKeyFocus ||
- (wmGD.keyboardFocus && (IS_APP_MODALIZED(wmGD.keyboardFocus)))) &&
- !(manageFlags &
- (MANAGEW_WM_STARTUP | MANAGEW_WM_RESTART | MANAGEW_WM_CLIENTS)) &&
- (pCD->clientState != MINIMIZED_STATE) &&
- !(pCD->clientState & UNSEEN_STATE) &&
- (pCD->inputFocusModel ||
- (pCD->protocolFlags & PROTOCOL_WM_TAKE_FOCUS)))))
- {
- Do_Focus_Key (pCD, GetTimestamp() , ALWAYS_SET_FOCUS);
- }
- else if ((pCD->inputMode == MWM_INPUT_SYSTEM_MODAL) ||
- (wmGD.keyboardFocus && IS_APP_MODALIZED(wmGD.keyboardFocus)))
- {
- Do_Focus_Key ((ClientData *)NULL, GetTimestamp() , ALWAYS_SET_FOCUS);
- }
- if (smAckState == SM_START_ACK)
- {
- SendClientMsg( wmGD.dtSmWindow, (long) wmGD.xa_DT_SM_WM_PROTOCOL,
- (long) wmGD.xa_DT_WM_WINDOW_ACK,
- CurrentTime, NULL, 0);
- }
- /*
- * Free the initial property list. This will force
- * reads of properties that change after the initial
- * management (see HasProperty() function.)
- */
- DiscardInitialPropertyList (pCD);
- CheckPushRecallClient (pCD);
- } /* END OF FUNCTION ManageWindow */
- /*************************************<->*************************************
- *
- * UnManageWindow (pCD)
- *
- *
- * Description:
- * -----------
- * This function removes a top-level client window and it's transients
- * from the set of windows that is managed by the window manager.
- *
- *
- * Inputs:
- * ------
- * pCD - pointer to client data of window to unmanage
- *
- *************************************<->***********************************/
- void UnManageWindow (ClientData *pCD)
- {
- if (pCD->pECD)
- {
- WmFpEmbeddedClientData *pECD;
- pECD = (WmFpEmbeddedClientData *) pCD->pECD;
- XtRemoveEventHandler(XtWindowToWidget (DISPLAY1, pECD->winParent),
- (SubstructureRedirectMask | SubstructureNotifyMask),
- False,
- (XtEventHandler)HandleSubstructEvents,
- (XtPointer)(pCD));
- pECD->pCD = NULL;
- UpdateEmbeddedClientsProperty (pCD->pSD);
- }
- if (pCD->pPRCD)
- {
- WmFpPushRecallClientData *pPRCD;
- int j;
- pPRCD = (WmFpPushRecallClientData *) pCD->pSD->pPRCD;
- for (j = 0;
- j < pCD->pSD->numPushRecallClients;
- j++, pPRCD++)
- {
- /*
- * Clean out all slots used by this client.
- */
- if ((!strcmp ((char *)pCD->clientName,
- (char *)(pPRCD->pchResName))) &&
- (pPRCD->pCD == pCD))
- {
- pPRCD->pCD = NULL;
- }
- }
- pCD->pPRCD = NULL;
- }
- /*
- * Withdraw all the transient children of this window.
- */
- if (pCD->transientChildren != NULL)
- {
- WithdrawTransientChildren (pCD);
- }
- /*
- * If this is a transient window, then delete it from the leader's
- * list of transients.
- */
- if (pCD->transientLeader)
- {
- DeleteTransient (pCD);
- /* If this was a modal dialog box, then replay the event. */
- if ( wmGD.replayEnterEvent )
- {
- XPutBackEvent( DISPLAY, (XEvent*)&wmGD.savedEnterEvent );
- /* Reset event flag to false */
- wmGD.replayEnterEvent = False;
- }
- }
- /*
- * Withdraw this window
- */
- WithdrawWindow (pCD);
- } /* END OF FUNCTION UnManageWindow */
- /*************************************<->*************************************
- *
- * WithdrawTransientChildren (pCD)
- *
- *
- * Description:
- * -----------
- * This function withdraws all transient children of the specified window.
- *
- *
- * Inputs:
- * ------
- * pCD = pointer to client data of the leader of the transient tree.
- *
- *************************************<->***********************************/
- void WithdrawTransientChildren (ClientData *pCD)
- {
- ClientData *pcdNext;
- ClientData *pcdThis;
- pcdNext = pCD->transientChildren;
- while (pcdNext)
- {
- if (pcdNext->transientChildren)
- {
- WithdrawTransientChildren (pcdNext);
- }
- pcdThis = pcdNext;
- pcdNext = pcdThis->transientSiblings;
- DeleteTransient(pcdThis);
- WithdrawWindow (pcdThis);
- }
- } /* END OF FUNCTION WithdrawTransientChildren */
- /*************************************<->*************************************
- *
- * WithdrawWindow (pCD)
- *
- *
- * Description:
- * -----------
- * This function removes a top-level client window from the set of windows
- * that is managed by the window manager. All window manager resources
- * associtated with the client window are freed up (possibly cached for
- * reuse). Any custom system menu is destroyed.
- *
- *
- * Inputs:
- * ------
- * pCD - pointer to client data of window to withdraw
- *
- *************************************<->***********************************/
- void WithdrawWindow (ClientData *pCD)
- {
- int x;
- int y;
- int i;
- XWindowChanges xwc;
- /*
- * Put the client window into a withdrawn state:
- *
- * - remove the icon/client window from the screen
- * - make sure the input focus no longer is associted with the window
- * - free the icon placement (if necessary)
- */
- SetClientWsIndex (pCD);
- if (!(pCD->clientFlags & WM_INITIALIZATION))
- {
- if (!pCD->transientLeader)
- {
- DeleteClientFromList (pCD->pSD->pActiveWS, pCD);
- }
- ResetWithdrawnFocii (pCD);
- if (pCD->clientState & MINIMIZED_STATE)
- {
- if (wmGD.iconAutoPlace && (!(P_ICON_BOX(pCD))))
- {
- WmWorkspaceData *pWsTmp;
- WsClientData *pWsc;
- int j;
- /*
- * Clean up icon placement data in all inhabited
- * workspaces
- */
- for (j = 0; j< pCD->numInhabited; j++)
- {
- pWsc = &(pCD->pWsList[j]);
- if (pWsc->iconPlace != NO_ICON_PLACE)
- {
- if ((pWsTmp=GetWorkspaceData(pCD->pSD, pWsc->wsID)))
- {
- pWsTmp->IPData.placeList[pWsc->iconPlace].pCD
- = NULL;
- }
- }
- }
- }
- if (ICON_FRAME_WIN(pCD))
- {
- XUnmapWindow (DISPLAY, ICON_FRAME_WIN(pCD));
- }
- XFlush (DISPLAY);
- }
- else if ((pCD->clientState == NORMAL_STATE) ||
- (pCD->clientState == MAXIMIZED_STATE))
- {
- XUnmapWindow (DISPLAY, pCD->clientFrameWin);
- XFlush (DISPLAY);
- }
- }
- /*
- * Clean up the workspace presence dialog if it's
- * connected to this client.
- */
- if ((pCD->pSD->presence.shellW) &&
- (pCD->pSD->presence.pCDforClient == pCD))
- {
- if (pCD->pSD->presence.onScreen)
- {
- HidePresenceBox (pCD->pSD, True);
- }
- pCD->pSD->presence.pCDforClient = NULL;
- }
- InstantTitleHideDialog (pCD);
- /*
- * Check to see if the window is being unmanaged because the window
- * was destroyed.
- */
- if (!(pCD->clientFlags & CLIENT_DESTROYED))
- {
- XEvent eventReturn;
- if (XCheckTypedWindowEvent (DISPLAY, pCD->clientBaseWin, DestroyNotify,
- &eventReturn))
- {
- pCD->clientFlags |= CLIENT_DESTROYED;
- }
- }
- /*
- * Reparent the client window back to root if the window has been
- * reparented by the window manager. Remove the window from the
- * window managers save-set if necessary.
- */
- if ((pCD->clientFlags & CLIENT_REPARENTED) &&
- !(pCD->clientFlags & CLIENT_DESTROYED))
- {
- SetWMState (pCD->client, WithdrawnSTATE,
- pCD->pWsList[0].iconFrameWin);
- if (pCD->maxConfig)
- {
- x = pCD->maxX;
- y = pCD->maxY;
- }
- else
- {
- int xoff, yoff;
-
- if(wmGD.positionIsFrame)
- {
- CalculateGravityOffset (pCD, &xoff, &yoff);
- x = pCD->clientX - xoff;
- y = pCD->clientY - yoff;
- }
- else
- {
- x = pCD->clientX;
- y = pCD->clientY;
- }
- }
- XDeleteProperty (DISPLAY, pCD->client, wmGD.xa__NET_WM_STATE);
- XDeleteProperty (DISPLAY, pCD->client,
- wmGD.xa_PREMATURE_XCLIENTMESSAGEEVENT_LIST);
- XUnmapWindow (DISPLAY, pCD->client);
- XReparentWindow (DISPLAY, pCD->client, ROOT_FOR_CLIENT(pCD), x, y);
- /* give the window back it's X border */
- xwc.border_width = pCD->xBorderWidth;
- XConfigureWindow(DISPLAY, pCD->client, CWBorderWidth, &xwc);
- if (pCD->iconWindow && (pCD->clientFlags & ICON_REPARENTED))
- {
- XUnmapWindow (DISPLAY, pCD->iconWindow);
- XReparentWindow (DISPLAY, pCD->iconWindow, ROOT_FOR_CLIENT(pCD),
- pCD->pWsList[0].iconX, pCD->pWsList[0].iconY);
- }
- }
- if ((pCD->clientFlags & CLIENT_IN_SAVE_SET) &&
- !(pCD->clientFlags & CLIENT_DESTROYED))
- {
- XRemoveFromSaveSet (DISPLAY, pCD->client);
- if (pCD->iconWindow && (pCD->clientFlags & ICON_IN_SAVE_SET))
- {
- XRemoveFromSaveSet (DISPLAY, pCD->iconWindow);
- }
- }
- /*
- * Free a custom system menu if one was created.
- */
- FreeCustomMenuSpec (pCD->systemMenuSpec);
- /*
- * Free the client window frame:
- */
- if (pCD->clientFrameWin)
- {
- FreeClientFrame (pCD);
- }
- /*
- * Free the icon associated with the client window:
- */
- if ((pCD->iconFlags & ICON_HINTS_PIXMAP) && pCD->iconPixmap)
- {
- XFreePixmap (DISPLAY, pCD->iconPixmap);
- }
- if ((pCD->numInhabited > 0) && ICON_FRAME_WIN(pCD))
- {
- FreeIcon (pCD);
- }
- /*
- * Free up the client protocol list:
- */
- if (pCD->clientProtocols)
- {
- XtFree ((char *)pCD->clientProtocols);
- }
- /*
- * Free up the mwm messages list:
- */
- if (pCD->mwmMessages)
- {
- XtFree ((char *)pCD->mwmMessages);
- }
- /*
- * Delete client window manager timers:
- */
- DeleteClientWmTimers (pCD);
- /*
- * Free up window context associations.
- */
- DeleteClientContext (pCD);
- /*
- * Count backward for efficiency --
- * removes from end of list.
- */
- for (i = pCD->numInhabited - 1; i >= 0; i--)
- {
- TakeClientOutOfWorkspace (
- GetWorkspaceData(pCD->pSD, pCD->pWsList[i].wsID),
- pCD);
- }
- /*
- * Free up window manager resources:
- */
- if (!(pCD->clientFlags & CLIENT_WM_CLIENTS))
- {
- if (pCD->clientName)
- {
- XFree ((char *) (pCD->clientName));
- }
- if (pCD->clientClass)
- {
- XFree ((char *) (pCD->clientClass));
- }
- }
- if ((pCD->clientFlags & CLIENT_HINTS_TITLE) && pCD->clientTitle)
- {
- XmStringFree (pCD->clientTitle);
- }
- if ((pCD->iconFlags & ICON_HINTS_TITLE) && pCD->iconTitle)
- {
- XmStringFree (pCD->iconTitle);
- }
- if (pCD->instantTitle)
- {
- XmStringFree (pCD->instantTitle);
- }
- if (pCD->clientCmapCount > 0)
- {
- for (i = 0; i < pCD->clientCmapCount; i++)
- {
- if (pCD->cmapWindows[i] != pCD->client)
- {
- #ifndef IBM_169380
- RemoveColormapWindowReference(pCD, pCD->cmapWindows[i]);
- #else
- XDeleteContext (DISPLAY, pCD->cmapWindows[i],
- wmGD.windowContextType);
- #endif
- }
- }
- XtFree ((char *) (pCD->cmapWindows));
- XtFree ((char *) (pCD->clientCmapList));
- XtFree ((char *) (pCD->clientCmapFlags));
- }
- /*
- * Insure list of initial properties has been freed.
- */
- DiscardInitialPropertyList (pCD);
- /*
- * free up list of workspace specific data
- */
- if ((pCD)->pWsList)
- {
- XtFree ((char *) (pCD->pWsList));
- }
- /*
- * free up workspace hints
- */
- if (pCD->pWorkspaceHints)
- {
- XtFree ((char *)pCD->pWorkspaceHints);
- }
- if (pCD->smClientID)
- XFree (pCD->smClientID);
- /*
- * Clean up references to this data before we free it.
- */
- if (wmGD.menuClient == pCD) {
- wmGD.menuClient = NULL;
- }
- if (wmGD.gadgetClient == pCD) {
- wmGD.gadgetClient = NULL;
- wmGD.gadgetDepressed = 0;
- }
- if (wmGD.clickData.pCD == pCD) {
- wmGD.clickData.pCD = NULL;
- }
- if (wmGD.nextKeyboardFocus == pCD)
- wmGD.nextKeyboardFocus = NULL;
- if (wmGD.keyboardFocus == pCD)
- wmGD.keyboardFocus = NULL;
- /*
- * Fix for 5325 - Delete reference by dirty stack
- */
- ClearDirtyStackEntry(pCD);
- XtFree ((char *)pCD);
- } /* END OF FUNCTION WithdrawWindow */
- /*************************************<->*************************************
- *
- * DeleteClientContext (pCD)
- *
- *
- * Description:
- * -----------
- * This function deletes the client from the X context manager
- *
- *
- * Inputs:
- * ------
- * pCD - pointer to client data
- *
- * Outputs:
- * -------
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- void DeleteClientContext (ClientData *pCD)
- {
- /*
- * Free up window context associations. The context for the client
- * window is always set if there is a client data structure.
- */
- XDeleteContext (DISPLAY, pCD->client, wmGD.windowContextType);
- if (pCD->clientFlags & CLIENT_CONTEXT_SAVED)
- {
- XDeleteContext (DISPLAY, pCD->clientFrameWin, wmGD.windowContextType);
- XDeleteContext (DISPLAY, pCD->clientBaseWin, wmGD.windowContextType);
- if (DECOUPLE_TITLE_APPEARANCE(pCD))
- {
- XDeleteContext (DISPLAY, pCD->clientTitleWin,
- wmGD.windowContextType);
- }
- if (ICON_FRAME_WIN(pCD))
- {
- int k;
- for (k=0; k < pCD->numInhabited; k++)
- {
- XDeleteContext (DISPLAY, pCD->pWsList[k].iconFrameWin,
- wmGD.windowContextType);
- }
- }
- pCD->clientFlags &= ~CLIENT_CONTEXT_SAVED;
- }
- } /* END OF FUNCTION DeleteClientContext */
- /*************************************<->*************************************
- *
- * ResetWitdrawnFocii (pCD)
- *
- *
- * Description:
- * -----------
- * This function resets the various types of focus if they are set to a
- * window being withdrawn.
- *
- *
- *
- * Inputs:
- * ------
- * pCD - pointer to client data
- *
- * Outputs:
- * -------
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- void ResetWithdrawnFocii (ClientData *pCD)
- {
- if ((wmGD.keyboardFocus == pCD) ||
- /* BEGIN fix for CDExc21090 */
- ((wmGD.keyboardFocus == (ClientData *)NULL) &&
- (wmGD.nextKeyboardFocus == pCD) &&
- (wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_EXPLICIT)))
- /* END fix for CDExc21090 */
- {
- if (wmGD.autoKeyFocus &&
- (wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_EXPLICIT))
- {
- /* local hack: if we've already received a map for a new
- ** focus window, be sure to use wmGD.nextKeyboardFocus; otherwise
- ** AutoResetKeyFocus chooses an essentially arbitrary window to
- ** set focus to.
- */
- if (wmGD.nextKeyboardFocus == pCD)
- AutoResetKeyFocus (pCD, GetTimestamp());
- else
- Do_Focus_Key ((ClientData *)wmGD.nextKeyboardFocus,
- GetTimestamp(), ALWAYS_SET_FOCUS);
- }
- else
- {
- /*
- * Set the focus to the default state if the focus is not in
- * the process of being set (i.e. a FocusIn event will be
- * coming along shortly.
- */
- if (wmGD.nextKeyboardFocus == wmGD.keyboardFocus)
- {
- Do_Focus_Key ((ClientData *)NULL, GetTimestamp(),
- ALWAYS_SET_FOCUS | WORKSPACE_IF_NULL);
- }
- }
- SetKeyboardFocus ((ClientData *)NULL, 0);
- }
- if (((pCD->inputMode == MWM_INPUT_PRIMARY_APPLICATION_MODAL) ||
- (pCD->inputMode == MWM_INPUT_FULL_APPLICATION_MODAL)) &&
- (wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_POINTER))
- {
- /*
- * Repair the focus if an application modal dialog went
- * away. We may not see an enter event and have the focus
- * set to the wrong place.
- */
- RepairFocus ();
- }
- if (wmGD.nextKeyboardFocus == pCD)
- {
- wmGD.nextKeyboardFocus = NULL;
- }
- if (ACTIVE_PSD->colormapFocus == pCD)
- {
- SetColormapFocus (ACTIVE_PSD, (ClientData *)NULL);
- }
- } /* END OF FUNCTION ResetWithdrawnFocii */
- /*************************************<->*************************************
- *
- * FreeClientFrame (pCD)
- *
- *
- * Description:
- * -----------
- * This function frees up frame windows and associated resources.
- *
- *
- * Inputs:
- * ------
- * pCD - pointer to client data
- *
- *************************************<->***********************************/
- void FreeClientFrame (ClientData *pCD)
- {
- if (pCD->pclientTopShadows) {
- FreeRList (pCD->pclientTopShadows);
- pCD->pclientTopShadows = NULL;
- }
- if (pCD->pclientBottomShadows) {
- FreeRList (pCD->pclientBottomShadows);
- pCD->pclientBottomShadows = NULL;
- }
- if (pCD->pclientTitleTopShadows) {
- FreeRList (pCD->pclientTitleTopShadows);
- pCD->pclientTitleTopShadows = NULL;
- }
- if (pCD->pclientTitleBottomShadows) {
- FreeRList (pCD->pclientTitleBottomShadows);
- pCD->pclientTitleBottomShadows = NULL;
- }
- if (pCD->pclientMatteTopShadows) {
- FreeRList (pCD->pclientMatteTopShadows);
- pCD->pclientMatteTopShadows = NULL;
- }
- if (pCD->pclientMatteBottomShadows) {
- FreeRList (pCD->pclientMatteBottomShadows);
- pCD->pclientMatteBottomShadows = NULL;
- }
- if (pCD->pTitleGadgets) {
- XtFree ((char *)pCD->pTitleGadgets);
- pCD->pTitleGadgets = NULL;
- pCD->cTitleGadgets = 0;
- }
- if (pCD->pResizeGadgets) {
- XtFree ((char *)pCD->pResizeGadgets);
- pCD->pResizeGadgets = NULL;
- }
- /* destroy frame window & all children */
- XDestroyWindow (DISPLAY, pCD->clientFrameWin);
- } /* END OF FUNCTION FreeClientFrame */
- /*************************************<->*************************************
- *
- * FreeIcon (pCD)
- *
- *
- * Description:
- * -----------
- * This function frees up icon windows and associated resources.
- *
- *
- * Inputs:
- * ------
- * pCD - pointer to client data
- *
- *************************************<->***********************************/
- void FreeIcon (ClientData *pCD)
- {
- WmWorkspaceData *pWsTmp;
- int i;
- if (pCD->piconTopShadows) {
- FreeRList (pCD->piconTopShadows);
- pCD->piconTopShadows = NULL;
- }
- if (pCD->piconBottomShadows) {
- FreeRList (pCD->piconBottomShadows);
- pCD->piconBottomShadows = NULL;
- }
- /*
- * destroy frame window & all children
- */
- if ((pCD->pSD->useIconBox) && pCD->pWsList[0].pIconBox)
- {
- /*
- * We're using icon boxes and it's in at least one ...
- * Delete from all workspaces we live in
- */
- for (i = 0; i< pCD->numInhabited; i++)
- {
- if ((pWsTmp = GetWorkspaceData(pCD->pSD, pCD->pWsList[i].wsID)))
- {
- DeleteIconFromBox (pWsTmp->pIconBox, pCD);
- }
- }
- }
- else
- {
- /* only one window, so destroying its first reference will
- * clean it up adequately
- */
- if (pCD->pWsList[0].iconFrameWin)
- {
- XDestroyWindow (DISPLAY, pCD->pWsList[0].iconFrameWin);
- }
- }
- } /* END OF FUNCTION FreeIcon */
- /*************************************<->*************************************
- *
- * WithdrawDialog (dialogboxW)
- *
- *
- * Description:
- * -----------
- * This function removes a DialogBox widget "client" from the set of windows
- * that are managed by the window manager.
- *
- *
- * Inputs:
- * ------
- * dialogboxW = DialogBox widget to withdraw.
- *
- * Comments:
- * --------
- * Does not maintain the WM_STATE property on the dialog "client".
- *
- *************************************<->***********************************/
- void WithdrawDialog (Widget dialogboxW)
- {
- int i;
- ClientData *pCD = NULL;
- /*
- * Get the dialog shell window client data.
- */
- if (XFindContext (DISPLAY, XtWindow (XtParent (dialogboxW)),
- wmGD.windowContextType, (caddr_t *)&pCD))
- return;
- XtUnmanageChild (dialogboxW);
- DeleteClientFromList (ACTIVE_WS, pCD);
- /* TakeClientOutOfWorkspace (ACTIVE_WS, pCD); */
- /*
- * Count backward for efficiency --
- * removes from end of list.
- */
- for (i = pCD->numInhabited - 1; i >= 0; i--)
- {
- TakeClientOutOfWorkspace (
- GetWorkspaceData(pCD->pSD, pCD->pWsList[i].wsID),
- pCD);
- }
- ResetWithdrawnFocii (pCD);
- XUnmapWindow (DISPLAY, pCD->clientFrameWin);
- } /* END OF FUNCTION WithdrawDialog */
- /*************************************<->*************************************
- *
- * ReManageDialog (pSD, dialogboxW)
- *
- *
- * Description:
- * -----------
- * This function remanages a DialogBox "client" that was unmanaged via
- * WithdrawDialog ().
- *
- *
- * Inputs:
- * ------
- * pSD = pointer to screen data
- * dialogboxW = DialogBox widget to remanage.
- *
- *
- * Outputs:
- * -------
- * Does not maintain the WM_STATE property on the dialog "client".
- *
- *************************************<->***********************************/
- void ReManageDialog (WmScreenData *pSD, Widget dialogboxW)
- {
- ClientData *pCD = NULL;
- /*
- * Get the dialog shell window client data.
- */
- if (XFindContext (DISPLAY, XtWindow (XtParent (dialogboxW)),
- wmGD.windowContextType, (caddr_t *)&pCD))
- return;
- /*
- * The order is important here:
- */
- /*
- * Put system modal windows in all workspaces to
- * avoid the race condition of the window coming up
- * just as the user switches workspaces OR when
- * the window is up and a user switces workspaces
- * with a key binding. We may want to eventually short
- * circuit F_Functions any time there is a modal
- * window up, but for now, we will just make sure
- * the modal window appears in all workspaces
- */
- pCD->dtwmFunctions |= DtWM_FUNCTION_OCCUPY_WS;
- F_AddToAllWorkspaces(0, pCD, 0);
- pCD->dtwmFunctions &= ~DtWM_FUNCTION_OCCUPY_WS;
- if (pSD->clientList)
- {
- StackWindow (pSD->pActiveWS, &pCD->clientEntry,
- TRUE, (ClientListEntry *) NULL);
- }
- AddClientToList (pSD->pActiveWS, pCD, True /*on top*/);
- XMapWindow (DISPLAY, pCD->clientFrameWin);
- XtManageChild (dialogboxW);
- if (wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_EXPLICIT)
- {
- Do_Focus_Key (pCD, GetTimestamp() , ALWAYS_SET_FOCUS);
- }
- } /* END OF FUNCTION ReManageDialog */
- /*************************************<->*************************************
- *
- * RegisterEmbeddedClients (wPanelist, pECD, count)
- *
- *
- * Description:
- * -----------
- * This function registers a list of clients to be embedded in the
- * front panel subsystem.
- *
- *
- * Inputs:
- * ------
- * wPanelist = front panel object (widget)
- * pECD = pointer to list of data for clients to embed
- * count = number of elements in the list
- *
- *
- * Outputs:
- * -------
- *
- *************************************<->***********************************/
- void
- RegisterEmbeddedClients (
- Widget wPanelist,
- WmFpEmbeddedClientList pECD,
- int count)
- {
- WmScreenData *pSD;
- int i;
- for (i= 0; i < wmGD.numScreens; i++)
- {
- pSD = &(wmGD.Screens[i]);
- if (pSD->managed)
- {
- if (pSD->wPanelist == wPanelist)
- break;
- }
- }
- if (i < wmGD.numScreens)
- {
- pSD->pECD = (struct _WmFpEmbeddedClientData *) pECD;
- pSD->numEmbeddedClients = count;
- }
- #ifdef DEBUG
- else
- {
- fprintf (stderr, "Couldn't match wPanelist to screen data\n");
- }
- #endif /* DEBUG */
- } /* END OF FUNCTION RegisterEmbeddedClients */
- #define LTT_INCREMENT 16
- /*************************************<->*************************************
- *
- * ListTransientSubtree (pCD, ppWins, pSize, pCount)
- *
- *
- * Description:
- * -----------
- * This function returns the list of windows in a transient window
- * tree.
- *
- *
- * Inputs:
- * ------
- * pCD - pointer to client data of a window.
- * ppWins - address of a pointer to a list of windows
- * (this must be in the heap -- XtMalloc).
- * pSize - address of variable with size of list
- * pCount - address of variable with number of windows in list
- *
- * Outputs:
- * -------
- * *ppWins - may point to a new area of memory if list grows
- * *pSize - if list has to grow, this may be bigger
- * *pCount - number of windows in the list
- *
- * Comments
- * --------
- * The list should be freed when done with XtFree().
- *
- *************************************<->***********************************/
- static void
- ListTransientSubtree (
- ClientData *pCD,
- Window **ppWins,
- int *pSize,
- int *pCount)
- {
- /*
- * Check size
- */
- if (*pCount == *pSize)
- {
- *pSize += LTT_INCREMENT;
- *ppWins = (Window *)
- XtRealloc ((char *) *ppWins, (*pSize * sizeof(Window)));
- }
- /*
- * Add this window to the list
- */
- (*ppWins)[*pCount] = pCD->client;
- *pCount += 1;
- /*
- * Add siblings
- */
- if (pCD->transientSiblings)
- ListTransientSubtree (pCD->transientSiblings, ppWins, pSize, pCount);
- /*
- * Add children
- */
- if (pCD->transientChildren)
- ListTransientSubtree (pCD->transientChildren, ppWins, pSize, pCount);
-
- } /* END OF FUNCTION ListTransientSubtree */
- /*************************************<->*************************************
- *
- * ListTransientTree (pCD)
- *
- *
- * Description:
- * -----------
- * This function returns the list of windows in a transient window
- * tree.
- *
- *
- * Inputs:
- * ------
- * pCD - pointer to client data of a primary window.
- *
- * Outputs:
- * -------
- * none
- *
- * Comments
- * --------
- * The list should be freed when done with XtFree().
- *
- *************************************<->***********************************/
- static Window *
- ListTransientTree (
- ClientData *pCD)
- {
- Window *pWins;
- int count;
- int iSize;
- /*
- * Initial allocation
- */
- iSize = LTT_INCREMENT;
- pWins = (Window *) XtMalloc (iSize * sizeof(Window));
- count = 0;
- /*
- * Add this window to the list
- */
- ListTransientSubtree (pCD, &pWins, &iSize, &count);
- /*
- * Add terminator to end of window list
- */
- if (count == iSize)
- {
- iSize += LTT_INCREMENT;
- pWins = (Window *)
- XtRealloc ((char *)pWins, (iSize * sizeof(Window)));
- }
- pWins[count++] = None;
- /*
- * Return the list of windows found
- */
- return (pWins);
-
- } /* END OF FUNCTION ListTransientTree */
- /*************************************<->*************************************
- *
- * ReManageWindow (pCD)
- *
- *
- * Description:
- * -----------
- * This function unmanages and remanages a window and it's associated
- * transients.
- *
- *
- * Inputs:
- * ------
- * pCD - pointer to client data of a primary window.
- *
- * Outputs:
- * -------
- * none
- *
- * Comments
- * --------
- * The pointer pCD is invalid after calling this function -- a
- * side-effect of unmanaging the client before remanaging it.
- *
- *************************************<->***********************************/
- static void
- ReManageWindow (
- ClientData *pCD)
- {
- long manageFlags = MANAGEW_NORMAL;
- Window *pWins, *pW;
- WmScreenData *pSD;
- /*
- * Get the list of windows in the transient window tree.
- */
- pWins = ListTransientTree (pCD);
- pSD = pCD->pSD;
- /*
- * Unmanage this window and associated transients
- */
- UnManageWindow (pCD);
- /*** pCD is no longer a valid pointer!!! ***/
-
- /*
- * Remanage this window and its secondaries
- */
- pW = pWins;
- while (*pW != None)
- {
- ManageWindow (pSD, *pW, manageFlags);
- pW++;
- }
- XtFree ((char *) pWins);
- } /* END OF FUNCTION ReManageWindow */
- /*************************************<->*************************************
- *
- * ScanForEmbeddedClients (pSD)
- *
- *
- * Description:
- * -----------
- * This function scans the managed windows and identifies those that
- * should be embedded clients in the front panel
- *
- *
- * Inputs:
- * ------
- * pSD - pointer to screen data.
- *
- * Outputs:
- * -------
- *
- *************************************<->***********************************/
- void
- ScanForEmbeddedClients (
- WmScreenData *pSD)
- {
- ClientData *pCD;
- ClientListEntry *pCLE;
- WmFpEmbeddedClientData *pECD;
- Boolean bReset;
- /*
- * Search through all the windows we're managing right now to
- * see if any should be embedded in a front/sub panel.
- */
- pCLE = pSD->clientList;
- bReset = False;
- while (pCLE != NULL)
- {
- /*
- * See if this is an previously unrecognized embedded client
- */
- pCD = pCLE->pCD;
- if ((pCD->pECD == NULL ) && IsEmbeddedClient (pCD, &pECD))
- {
- /*
- * Remanage this window and associated transients
- */
- ReManageWindow (pCD);
- /*
- * At this point pCD is no longer valid and the
- * pSD->clientList has been changed.
- */
- bReset = True;
- }
-
- /*
- * Test for exit condition
- */
- if (pCLE == pSD->lastClient)
- {
- /*
- * Gone all the way through the list without finding
- * anything -- time to quit
- */
- break;
- }
- else if (bReset)
- {
- /*
- * Remanaging a client restructures the client list.
- * Start over at the beginning.
- */
- bReset = False;
- pCLE = pSD->clientList;
- }
- else
- {
- /*
- * Move to next client.
- */
- pCLE = pCLE->nextSibling;
- }
- }
- } /* END OF FUNCTION ScanForEmbeddedClients */
- /*************************************<->*************************************
- *
- * IsEmbeddedClient (pCD, ppECD)
- *
- *
- * Description:
- * -----------
- * This function tests a a client to see if it should be embedded
- * in the front panel.
- *
- *
- * Inputs:
- * ------
- * pCD = ptr to Client Data
- * ppECD = ptr to returned embedded client data ptr
- *
- *
- * Outputs:
- * -------
- * *ppECD = ptr to embedded client data
- *
- *************************************<->***********************************/
- Boolean
- IsEmbeddedClient (ClientData *pCD, WmFpEmbeddedClientData **ppECD)
- {
- WmScreenData *pSD;
- int i;
- Boolean bFoundMatch = False;
- WmFpEmbeddedClientData *pECD;
- pSD = pCD->pSD;
- pECD = (WmFpEmbeddedClientData *) pSD->pECD;
- for (i = 0; i < pSD->numEmbeddedClients && !bFoundMatch; i++, pECD++)
- {
- /*
- * It's an embedded client if
- * the resource name matches a slot and
- * it's not a subpanel and
- * the slot isn't already filled.
- */
- if ((!strcmp ((char *)pCD->clientName,
- (char *)(pECD->pchResName))) &&
- (!(pCD->dtwmBehaviors & DtWM_BEHAVIOR_SUBPANEL)) &&
- (!pECD->pCD))
- {
- *ppECD = pECD;
- bFoundMatch = True;
- }
- }
- return (bFoundMatch);
- } /* END OF FUNCTION IsEmbeddedClient */
- /******************************<->*************************************
- *
- * ManageEmbeddedClient (pCD, pECD, manageFlags)
- *
- *
- * Description:
- * -----------
- * This is the function that is used to setup a client window
- * in the front panel.
- *
- * Inputs:
- * ------
- * pCD = initialized client data, including window of client that
- * we want to manage.
- * pECD = ptr to embedded client entry for this client
- *
- * manageFlags = additional control information
- *
- * Outputs:
- * -------
- * Returns False if normal client processing needs to be done.
- *
- * Returns True if this client has been embedded directly in the
- * front panel and is NOT to be managed as a normal top level
- * window--no further processing required.
- ******************************<->***********************************/
- Boolean
- ManageEmbeddedClient (
- ClientData *pCD,
- WmFpEmbeddedClientData *pECD,
- long manageFlags)
- {
- XWindowChanges windowChanges;
- unsigned int mask;
- WmFpPushRecallClientData *pPRCD;
- if (!pECD || !pCD)
- {
- return (False);
- }
-
- /*
- * Add to all workspaces
- */
- pCD->dtwmFunctions |= DtWM_FUNCTION_OCCUPY_WS;
- F_AddToAllWorkspaces(0, pCD, 0);
- pCD->dtwmFunctions &= ~DtWM_FUNCTION_OCCUPY_WS;
- /*
- * Set client list entries
- * (in a list by itself)
- */
- pCD->clientEntry.type = NORMAL_STATE;
- pCD->clientEntry.pCD = pCD;
- pCD->clientEntry.nextSibling = NULL;
- pCD->clientEntry.prevSibling = NULL;
- pCD->iconEntry.type = MINIMIZED_STATE;
- pCD->iconEntry.pCD = pCD;
- pCD->iconEntry.nextSibling = NULL;
- pCD->iconEntry.prevSibling = NULL;
- /*
- * Save context for event processing.
- *
- */
- XSaveContext (DISPLAY, pCD->client, wmGD.windowContextType,
- (caddr_t)pCD);
- if (!(pCD->clientFlags & CLIENT_WM_CLIENTS))
- {
- XChangeSaveSet (DISPLAY, pCD->client, SetModeInsert);
- XChangeSaveSet (DISPLAY1, pCD->client, SetModeInsert);
- pCD->clientFlags |= CLIENT_IN_SAVE_SET;
- }
- if (!(manageFlags & MANAGEW_WM_CLIENTS))
- {
- XSync (DISPLAY1, False);
- if (pCD->clientFlags & CLIENT_DESTROYED)
- {
- UnManageWindow (pCD);
- return (True);
- }
- }
- XtAddEventHandler(XtWindowToWidget (DISPLAY1, pECD->winParent),
- (SubstructureRedirectMask | SubstructureNotifyMask),
- False,
- (XtEventHandler)HandleSubstructEvents,
- (XtPointer)(pCD));
- /*
- * Fill in more client data
- */
- pCD->clientX = pECD->x;
- pCD->clientY = pECD->y;
- pCD->clientWidth = pECD->width;
- pCD->clientHeight = pECD->height;
- pCD->clientFrameWin = 0;
- pCD->clientBaseWin = pECD->winParent;
- pECD->pCD = pCD;
- pCD->pECD = (void *) pECD;
- SetClientWsIndex(pCD);
- SetClientWMState (pCD, NormalState, NORMAL_STATE);
- /*
- * Set state on subpanel in case it never gets mapped
- * to prevent session manager from finding an embedded
- * client on its own.
- */
- ForceSubpanelWMState (pECD->winParent);
- XReparentWindow (DISPLAY1, pCD->client,
- pECD->winParent,
- pECD->x, pECD->y);
- pCD->clientFlags |= CLIENT_REPARENTED;
- windowChanges.width = pECD->width;
- windowChanges.height = pECD->height;
- windowChanges.border_width = 0;
- mask = (CWWidth | CWHeight | CWBorderWidth);
- XConfigureWindow (DISPLAY1, pCD->client, mask, &windowChanges);
- XMapWindow (DISPLAY1, pCD->client);
- if (pCD->iconWindow)
- {
- XUnmapWindow (DISPLAY, pCD->iconWindow);
- }
- UpdateEmbeddedClientsProperty (pCD->pSD);
- SendConfigureNotify (pCD);
- if (IsPushRecallClient (pCD, &pPRCD))
- {
- /*
- * There should only be one instance of this
- * client started from a front panel button.
- */
- pPRCD->pCD = pCD;
- pCD->pPRCD = (void *) pPRCD;
- }
- WmStopWaiting();
- return(True); /* successful embedation */
- } /* END OF FUNCTION ManageEmbeddedClient */
- /******************************<->*************************************
- *
- * ReparentEmbeddedClient (pECD, newControl, newWin, x, y, width, height)
- *
- *
- * Description:
- * -----------
- *
- * Inputs:
- * ------
- * pECD = ptr to embedded client entry for this client
- * newControl = widget for new "parent" widget
- * newWin = window ID of window that this embedded client will be
- * a parent of. This is needed in case the control is a
- * gadget.
- * x = x-coord position within newWin where UL corner of the embedded
- * client will go.
- * y = y-coord as described above.
- * width = desired width of embedded client in this new location
- * height = desired height as above.
- *
- *
- * Outputs:
- * -------
- * Returns False if embedded client was is not moved to the new
- * location.
- *
- * Returns True if this client has been reparented to the new
- * control.
- ******************************<->***********************************/
- Boolean
- ReparentEmbeddedClient (
- WmFpEmbeddedClientData *pECD,
- Widget newControl,
- Window newWin,
- int x,
- int y,
- unsigned int width,
- unsigned int height
- )
- {
- XWindowChanges windowChanges;
- unsigned int mask;
- ClientData *pCD;
- /*
- * If we have bogus data or if we're asked
- * to reparent to our current parent, then just
- * say no.
- */
- if ((pECD == NULL) ||
- (pECD->pCD == NULL) ||
- (pECD->winParent == newWin))
- {
- return (False);
- }
- pCD=pECD->pCD;
- /*
- * Need event handler on new parent window?
- */
- if (newWin != pECD->winParent)
- {
- XtRemoveEventHandler(XtWindowToWidget (DISPLAY1, pECD->winParent),
- (SubstructureRedirectMask | SubstructureNotifyMask),
- False,
- (XtEventHandler)HandleSubstructEvents,
- (XtPointer)(pCD));
- XtAddEventHandler(XtWindowToWidget (DISPLAY1, newWin),
- (SubstructureRedirectMask | SubstructureNotifyMask),
- False,
- (XtEventHandler)HandleSubstructEvents,
- (XtPointer)(pCD));
- }
- /*
- * Update embedding and client data
- */
- pECD->wControl = newControl;
- pECD->winParent = newWin;
- pCD->clientX = pECD->x = x;
- pCD->clientY = pECD->y = y;
- pCD->clientWidth = pECD->width = width;
- pCD->clientHeight = pECD->height = height;
- pCD->clientBaseWin = pECD->winParent;
- /*
- * Set state on subpanel in case it never gets mapped
- * to prevent session manager from finding an embedded
- * client on its own.
- */
- ForceSubpanelWMState (pECD->winParent);
- /*
- * Do the actual reparent
- */
- XReparentWindow (DISPLAY1, pCD->client,
- pECD->winParent,
- pECD->x, pECD->y);
- /*
- * Configure the embedded client
- */
- windowChanges.width = pECD->width;
- windowChanges.height = pECD->height;
- windowChanges.border_width = 0;
- mask = (CWWidth | CWHeight | CWBorderWidth);
- XConfigureWindow (DISPLAY1, pCD->client, mask, &windowChanges);
- XMapWindow (DISPLAY1, pCD->client);
- UpdateEmbeddedClientsProperty (pCD->pSD);
- SendConfigureNotify (pCD);
- return(True); /* successful reparent */
- } /* END OF FUNCTION ReparentEmbeddedClient */
- /*************************************<->*************************************
- *
- * ForceSubpanelWMState (win)
- *
- *
- * Description:
- * -----------
- * This function forces a WM_STATE property on a subpanel window
- * so that the session manager doesn't save multiple copies
- * of embedded clients for subpanels that never get mapped.
- *
- *
- * Inputs:
- * ------
- * win = window ID of a subpanel window (not necessarily the top level!)
- *
- *
- * Outputs:
- * -------
- *
- *************************************<->***********************************/
- static void
- ForceSubpanelWMState (Window win)
- {
- ClientData *pCD = NULL;
- Window root, parent;
- Window *children = NULL;
- unsigned int numChildren;
- PropWMState *wmStateProp;
- Boolean bDone = False;
- while (!bDone)
- {
- if (!XQueryTree (DISPLAY, win, &root, &parent,
- &children, &numChildren))
- {
- break;
- }
- if (!XFindContext(DISPLAY, win, wmGD.windowContextType,
- (caddr_t *)&pCD))
- {
- /*
- * Only continue if we're not already managing this subpanel.
- */
- bDone = True;
- }
- else if (parent == root)
- {
- if ((wmStateProp = GetWMState (win)))
- {
- /*
- * Already has a WM_STATE.
- */
- XFree ((char *)wmStateProp);
- }
- else
- {
- /*
- * Add a dummy WM_STATE to foil the session manager
- * search.
- */
- SetWMState (win, WITHDRAWN_STATE, 0);
- }
- bDone = True;
- }
- else
- {
- /* continue ascent up to root */
- win = parent;
- }
- XFree ((char *) children);
- }
- } /* END OF FUNCTION ForceSubpanelWMState */
- /*************************************<->*************************************
- *
- * RegisterPushRecallClients (wPanelist, pPRCD, count)
- *
- *
- * Description:
- * -----------
- * This function registers a list of push_recallclients for the
- * front panel subsystem.
- *
- *
- * Inputs:
- * ------
- * wPanelist = front panel object (widget)
- * pPRCD = pointer to list of data for clients
- * count = number of elements in the list
- *
- *
- * Outputs:
- * -------
- *
- *************************************<->***********************************/
- void
- RegisterPushRecallClients (
- Widget wPanelist,
- WmFpPushRecallClientList pPRCD,
- int count)
- {
- WmScreenData *pSD = NULL;
- int i;
- for (i= 0; i < wmGD.numScreens; i++)
- {
- pSD = &(wmGD.Screens[i]);
- if (pSD->managed)
- {
- if (pSD->wPanelist == wPanelist)
- break;
- }
- }
- if (i < wmGD.numScreens)
- {
- pSD->pPRCD = (struct _WmFpPushRecallClientData *) pPRCD;
- pSD->numPushRecallClients = count;
- }
- #ifdef DEBUG
- else
- {
- fprintf (stderr, "Couldn't match wPanelist to screen data\n");
- }
- #endif /* DEBUG */
- for (i = 0; i < pSD->numPushRecallClients ; i++, pPRCD++)
- {
- /*
- * Initialize data in each slot
- */
- pPRCD->tvTimeout.tv_sec = 0;
- }
- } /* END OF FUNCTION RegisterPushRecallClients */
- /*************************************<->*************************************
- *
- * IsPushRecallClient (pCD, ppPRCD)
- *
- *
- * Description:
- * -----------
- * This function tests a a client to see if it should be embedded
- * in the front panel.
- *
- *
- * Inputs:
- * ------
- * pCD = ptr to Client Data
- * ppPRCD = ptr to returned embedded client data ptr
- *
- *
- * Outputs:
- * -------
- * *ppPRCD = ptr to embedded client data
- *
- *************************************<->***********************************/
- Boolean
- IsPushRecallClient (ClientData *pCD, WmFpPushRecallClientData **ppPRCD)
- {
- WmScreenData *pSD;
- int i;
- Boolean bFoundMatch = False;
- WmFpPushRecallClientData *pPRCD;
- pSD = pCD->pSD;
- pPRCD = (WmFpPushRecallClientData *) pSD->pPRCD;
- for (i = 0; i < pSD->numPushRecallClients && !bFoundMatch; i++, pPRCD++)
- {
- /*
- * It's a push_recall client if the resource name matches
- * a slot and the slot isn't already filled.
- */
- if ((!strcmp ((char *)pCD->clientName,
- (char *)(pPRCD->pchResName))) &&
- (!pPRCD->pCD))
- {
- *ppPRCD = pPRCD;
- bFoundMatch = True;
- }
- }
- return (bFoundMatch);
- } /* END OF FUNCTION IsPushRecallClient */
- /*************************************<->*************************************
- *
- * ScanForPushRecallClients (pSD)
- *
- *
- * Description:
- * -----------
- * This function scans the managed windows and identifies those that
- * should be push recall clients of the front panel
- *
- *
- * Inputs:
- * ------
- * pSD - pointer to screen data.
- *
- * Outputs:
- * -------
- *
- *************************************<->***********************************/
- void
- ScanForPushRecallClients (
- WmScreenData *pSD)
- {
- ClientData *pCD;
- ClientListEntry *pCLE;
- WmFpPushRecallClientData *pPRCD;
- /*
- * Search through all the windows we're managing right now
- */
- pCLE = pSD->clientList;
- while (pCLE != NULL)
- {
- /*
- * See if this is an previously unrecognized push recall client
- */
- pCD = pCLE->pCD;
- if ((pCD->pPRCD == NULL ) && IsPushRecallClient (pCD, &pPRCD))
- {
- CheckPushRecallClient (pCD);
- }
-
- /*
- * Test for exit condition
- */
- if (pCLE == pSD->lastClient)
- {
- /*
- * Gone all the way through the list without finding
- * anything -- time to quit
- */
- break;
- }
- else
- {
- /*
- * Move to next client.
- */
- pCLE = pCLE->nextSibling;
- }
- }
- } /* END OF FUNCTION ScanForPushRecallClients */
- /******************************<->*************************************
- *
- * static void CheckPushRecallClient (pCD)
- *
- *
- * Description:
- * -----------
- * Checks a client against the list of push recall clients to see
- * if there are any matches. All matches are marked.
- *
- * Inputs:
- * ------
- * pCD - pointer to the Client Data structure
- *
- * Outputs:
- * -------
- *
- * Comments:
- * --------
- *
- ******************************<->***********************************/
- static void
- CheckPushRecallClient(
- ClientData *pCD)
- {
- WmFpPushRecallClientData *pPRCD;
- while (IsPushRecallClient (pCD, &pPRCD))
- {
- /*
- * There should only be one instance of this
- * client started from a front panel button.
- */
- pPRCD->pCD = pCD;
- pPRCD->tvTimeout.tv_sec = 0;
- if (!pCD->pPRCD)
- pCD->pPRCD = (void *) pPRCD;
- }
- }
- /******************************<->*************************************
- *
- * static void HandleSubstructEvents (Widget w, caddr_t pCD, XEvent *event)
- *
- *
- * Description:
- * -----------
- * Causes death of embedded clients to run through UnManageWindow()
- * for proper cleanup.
- *
- * Note there is one of these event handlers instantiated for
- * each live client window in the front panel. Hence, for each
- * live client window death, each of the event handlers gets called
- * once. We need to ensure that we've got the right pCD before
- * calling UnManageWindow() on it.
- *
- *
- * Inputs:
- * ------
- * w - not used
- * pCD - pointer to the Client Data structure
- * event - we only care about UnMapNotify
- *
- * Outputs:
- * -------
- *
- * Comments:
- * --------
- * This routine is called LOTS of times, for all types of events.
- *
- ******************************<->***********************************/
- static void
- HandleSubstructEvents(
- Widget w,
- caddr_t ptr,
- XEvent *event )
- {
- struct _ClientData *pCD = (struct _ClientData *)ptr;
- switch (event->type)
- {
- case UnmapNotify:
- {
- if (pCD->client == event->xunmap.window)
- {
- UnManageWindow (pCD);
- }
- break;
- }
- }
- } /* END OF FUNCTION HandleSubstructEvents */
- /*******************************<->*************************************
- *
- * UpdateEmbeddedClientsProperty (pSD)
- *
- * Description:
- * -----------
- *
- * Inputs:
- * ------
- * pSD - pointer to the screen data
- *
- * Outputs:
- * -------
- * True if successful, False otherwise.
- *
- * Comments:
- * --------
- * The _DT_WORKSPACE_EMBEDDED_CLIENTS property on the
- * root window for the screen will be updated to reflect the
- * current contents of the front panel
- *
- *
- ******************************<->***********************************/
- Boolean
- UpdateEmbeddedClientsProperty(
- WmScreenData *pSD )
- {
- unsigned int numClients = 0;
- Window *pClients = NULL;
- Boolean rval = True;
- int i;
- WmFpEmbeddedClientData *pECD;
- pECD = (WmFpEmbeddedClientData *) pSD->pECD;
- for (i = 0; i < pSD->numEmbeddedClients; i++, pECD++)
- {
- if (pECD->pCD)
- {
- numClients += 1;
- if (!pClients)
- {
- pClients = (Window *) XtMalloc (sizeof(Window));
- }
- else
- {
- pClients = (Window *) XtRealloc ((char *)pClients,
- (numClients * (sizeof(Window))));
- }
- if (!pClients)
- {
- Warning (
- ((char *)GETMESSAGE(4, 17, "Insufficient memory to write _DT_WORKSPACE_EMBEDDED_CLIENTS."))
- );
- rval = False;
- break;
- }
- else
- {
- pClients[numClients-1] = pECD->pCD->client;
- }
- }
- }
- SetEmbeddedClientsProperty (pSD->rootWindow, pClients,
- numClients);
- if (pClients != NULL)
- {
- XtFree ((char *)pClients);
- }
- return (rval);
- } /* END OF FUNCTION UpdateEmbeddedClientsProperty */
- /*******************************<->*************************************
- *
- * UnParentControls (pSD, unmap)
- *
- * Description:
- * -----------
- *
- * Inputs:
- * ------
- * pSD - pointer to the screen data
- * unmap - if True, then unmap the windows after reparenting to root
- *
- * Outputs:
- * -------
- * none
- *
- * Comments:
- * --------
- * Reparents clients embedded in the front panel back to the
- * root window
- *
- ******************************<->***********************************/
- void
- UnParentControls(
- WmScreenData *pSD,
- Boolean unmap )
- {
- int i;
- ClientData *pCD;
- WmFpEmbeddedClientData *pECD;
-
- if (pSD && pSD->managed)
- {
- pECD = (WmFpEmbeddedClientData *) pSD->pECD;
- for (i = 0; i < pSD->numEmbeddedClients; i++, pECD++)
- {
- pCD = pECD->pCD;
- if (pCD)
- {
- if ((pCD->clientFlags & CLIENT_IN_SAVE_SET) &&
- !(pCD->clientFlags & CLIENT_DESTROYED))
- {
- XRemoveFromSaveSet (DISPLAY, pCD->client);
- XRemoveFromSaveSet (DISPLAY1, pCD->client);
- }
-
- XReparentWindow (DISPLAY,
- pCD->client,
- pSD->rootWindow,
- pCD->clientX,
- pCD->clientY);
- if (unmap)
- {
- XUnmapWindow (DISPLAY, pCD->client);
- if (pCD->iconWindow)
- {
- if (pCD->clientFlags & ICON_IN_SAVE_SET)
- {
- XRemoveFromSaveSet (DISPLAY, pCD->iconWindow);
- pCD->clientFlags &= ~ICON_IN_SAVE_SET;
- }
- XUnmapWindow (DISPLAY, pCD->iconWindow);
- }
- }
- }
- }
- }
-
- } /* END OF FUNCTION UnParentControl */
- /*************************************<->*************************************
- *
- * RegisterIconBoxControl (wPanelist)
- *
- *
- * Description:
- * -----------
- * This function registers the icon box control in a front panel
- *
- *
- * Inputs:
- * ------
- * wPanelist = front panel object (widget)
- *
- * Outputs:
- * -------
- *
- *************************************<->***********************************/
- void
- RegisterIconBoxControl (Widget wPanelist)
- {
- WmScreenData *pSD;
- int i;
- for (i= 0; i < wmGD.numScreens; i++)
- {
- pSD = &(wmGD.Screens[i]);
- if (pSD->managed)
- {
- if (pSD->wPanelist == wPanelist)
- break;
- }
- }
- if (i < wmGD.numScreens)
- {
- pSD->iconBoxControl = True;
- pSD->useIconBox = True;
- }
- #ifdef DEBUG
- else
- {
- fprintf (stderr, "Couldn't match wPanelist to screen data\n");
- }
- #endif /* DEBUG */
- } /* END OF FUNCTION RegisterIconBoxControl */
|