12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780 |
- /*
- * 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, 1993, 1994 Hewlett-Packard Company
- * (c) Copyright 1993, 1994 International Business Machines Corp.
- * (c) Copyright 1993, 1994 Sun Microsystems, Inc.
- * (c) Copyright 1993, 1994 Novell, Inc.
- */
- /*
- * Included Files:
- */
- #include "WmGlobal.h"
- /*
- * include extern functions
- */
- #include "WmWinList.h"
- #include "WmCEvent.h"
- #include "WmEvent.h"
- #include "WmFunction.h"
- #include "WmKeyFocus.h"
- #include "WmMenu.h"
- #include "WmResource.h"
- #include "WmWinInfo.h"
- #include "WmWrkspace.h"
- #include <X11/bitmaps/xm_noenter16>
- #include <X11/bitmaps/xm_noenter16m>
- #include <X11/bitmaps/xm_noenter32>
- #include <X11/bitmaps/xm_noenter32m>
- /*
- * Global Variables:
- */
- /*************************************<->*************************************
- *
- * AddClientToList (pWS, pCD, onTop)
- *
- *
- * Description:
- * -----------
- * This function adds a client window to the client window list. If it is
- * a transient window then it is added to the transient window tree that
- * contains its transient leader. The window stacking order is also
- * maintained for the cases where there is a system modal window active
- * or the window is a transient window. If a system modal window is being
- * added then the system modal "input screen" window is setup.
- *
- *
- * Inputs:
- * ------
- * pCD = pointer to client data for the window to be added to the list
- *
- * pWS = pointer to workspace data
- *
- * onTop = if True then the window is displayed on top of the window
- * stack and is added to the beginning of the window list, otherwise
- * it is added to the end of the window list.
- *
- *
- * Outputs:
- * -------
- * pWS = (clientList, lastClient)
- *
- *************************************<->***********************************/
- void AddClientToList (WmWorkspaceData *pWS, ClientData *pCD, Boolean onTop)
- {
- Boolean belowSystemModal = False;
- XWindowChanges windowChanges;
- WmScreenData *pSD = pWS->pSD;
- WsClientData *pWsc = GetWsClientData (pWS, pCD);
- if (pCD->inputMode == MWM_INPUT_SYSTEM_MODAL)
- {
- /*
- * Set up the system modal input screen window just below the
- * system modal window.
- */
- SetupSystemModalState (pCD);
- if (!wmGD.systemModalActive || (wmGD.systemModalClient != pCD))
- {
- /*
- * If we failed to setup as system modal, then
- * back off to MWM_INPUT_FULL_APPLICATION_MODAL.
- * This will do *something* if this is a transient
- * window.
- */
- pCD->inputMode = MWM_INPUT_FULL_APPLICATION_MODAL;
- }
- }
- else if (wmGD.systemModalActive &&
- ((FindTransientTreeLeader (pCD))->inputMode !=
- MWM_INPUT_SYSTEM_MODAL))
- {
- /*
- * If a system modal window is active then place the window below
- * the system modal input screen window if the window is not a
- * descendant of the system modal window.
- */
- windowChanges.sibling = pSD->inputScreenWindow;
- windowChanges.stack_mode = Below;
- XConfigureWindow (DISPLAY, pCD->clientFrameWin,
- CWSibling | CWStackMode, &windowChanges);
- belowSystemModal = True;
- }
- if (pCD->transientLeader)
- {
- AddTransient (pWS, pCD);
- }
- else
- {
- pCD->clientEntry.type = NORMAL_STATE;
- pCD->clientEntry.pCD = pCD;
- if (belowSystemModal && wmGD.systemModalClient)
- {
- AddEntryToList (pWS, &pCD->clientEntry, False /*below*/,
- pSD->clientList);
- }
- else if (onTop)
- {
- AddEntryToList (pWS, &pCD->clientEntry, True /*on top*/, NULL);
- }
- else
- {
- AddEntryToList (pWS, &pCD->clientEntry, False /*on bottom*/, NULL);
- }
- if (!pWsc->pIconBox && pWsc->iconFrameWin)
- {
- /*
- * Put the icon on the bottom of the stack.
- */
- if (pSD->lastClient->type == MINIMIZED_STATE)
- {
- WsClientData *pWsib;
- pWsib = &pSD->lastClient->pCD->pWsList[0];
- windowChanges.sibling = pWsib->iconFrameWin;
- }
- else
- {
- windowChanges.sibling = pSD->lastClient->pCD->clientFrameWin;
- }
- windowChanges.stack_mode = Below;
- XConfigureWindow (DISPLAY, pWsc->iconFrameWin,
- CWSibling | CWStackMode, &windowChanges);
- pCD->iconEntry.type = MINIMIZED_STATE;
- pCD->iconEntry.pCD = pCD;
- pCD->iconEntry.nextSibling = NULL;
- pCD->iconEntry.prevSibling = pSD->lastClient;
- pSD->lastClient->nextSibling = &pCD->iconEntry;
- pSD->lastClient = &pCD->iconEntry;
- }
- }
- } /* END OF FUNCTION AddClientToList */
- /*************************************<->*************************************
- *
- * AddEntryToList (pWS, pEntry, onTop, pStackEntry)
- *
- *
- * Description:
- * -----------
- * This function adds a client list entry to the client window list.
- * This is usually done as part of the process of changing the ordering
- * of the window list.
- *
- *
- * Inputs:
- * ------
- * pWS = pointer to workspace data
- * pEntry = pointer to a client list entry to be added to the client list
- *
- * onTop = if True then the client list entry is added on top of the
- * specified client list stack entry (if the stack entry is not
- * specified then the entry is added to the front of the list);
- * otherwise the entry is added after the specified stacking entry
- * (or to the end of the list if the stacking entry is not specified).
- *
- * pStackEntry = pointer to a client list entry to be used as a reference
- * in adding an entry to the client list.
- *
- * Outputs:
- * -------
- * pWS = (clientList, lastClient)
- *
- *************************************<->***********************************/
- void AddEntryToList (WmWorkspaceData *pWS, ClientListEntry *pEntry, Boolean onTop, ClientListEntry *pStackEntry)
- {
- WmScreenData *pSD = pWS->pSD;
- if (onTop)
- {
- if (pStackEntry)
- {
- if (pEntry != pStackEntry)
- {
- pEntry->nextSibling = pStackEntry;
- pEntry->prevSibling = pStackEntry->prevSibling;
- pStackEntry->prevSibling = pEntry;
- if (pEntry->prevSibling)
- {
- pEntry->prevSibling->nextSibling = pEntry;
- }
- else
- {
- pSD->clientList = pEntry;
- }
- }
- }
- else
- {
- if (pSD->clientList != pEntry)
- {
- pEntry->nextSibling = pSD->clientList;
- pEntry->prevSibling = NULL;
- if (pSD->clientList)
- {
- pSD->clientList->prevSibling = pEntry;
- }
- else
- {
- pSD->lastClient = pEntry;
- }
- pSD->clientList = pEntry;
- }
- }
- }
- else
- {
- if (pStackEntry)
- {
- if (pEntry != pStackEntry)
- {
- pEntry->nextSibling = pStackEntry->nextSibling;
- pEntry->prevSibling = pStackEntry;
- pStackEntry->nextSibling = pEntry;
- if (pEntry->nextSibling)
- {
- pEntry->nextSibling->prevSibling = pEntry;
- }
- else
- {
- pSD->lastClient = pEntry;
- }
- }
- }
- else
- {
- if (pSD->lastClient != pEntry)
- {
- pEntry->nextSibling = NULL;
- pEntry->prevSibling = pSD->lastClient;
- if (pSD->clientList)
- {
- pSD->lastClient->nextSibling = pEntry;
- }
- else
- {
- pSD->clientList = pEntry;
- }
- pSD->lastClient = pEntry;
- }
- }
- }
- } /* END OF FUNCTION AddEntryToList */
- /*************************************<->*************************************
- *
- * MoveEntryInList (pWS, pEntry, onTop, pStackEntry)
- *
- *
- * Description:
- * -----------
- * This function moves a client list entry in the client window list.
- *
- *
- * Inputs:
- * ------
- * pWS = pointer to workspace data
- *
- * pEntry = pointer to a client list entry to be moved in the client list
- *
- * onTop = if True then the client list entry is moved on top of the
- * specified client list stack entry (if the stack entry is not
- * specified then the entry is moved to the front of the list);
- * otherwise the entry is moved after the specified stacking entry
- * (or to the end of the list if the stacking entry is not specified).
- *
- * pStackEntry = pointer to a client list entry to be used as a reference
- * in moving an entry in the client list.
- *
- * Outputs:
- * -------
- * pWS = (clientList, lastClient)
- *
- *************************************<->***********************************/
- void MoveEntryInList (WmWorkspaceData *pWS, ClientListEntry *pEntry, Boolean onTop, ClientListEntry *pStackEntry)
- {
- DeleteEntryFromList (pWS, pEntry);
- AddEntryToList (pWS, pEntry, onTop, pStackEntry);
- } /* END OF FUNCTION MoveEntryInList */
- /*************************************<->*************************************
- *
- * DeleteEntryFromList (pWS, pListEntry)
- *
- *
- * Description:
- * -----------
- * This function deletes a client list entry from the client window list.
- * This is usually done as part of the process of changing the ordering
- * of the window list.
- *
- *
- * Inputs:
- * ------
- * pWS = pointer to workspace data
- * listEntry = pointer to a client list entry
- *
- * Outputs:
- * -------
- * pWS = (clientList, lastClient)
- *
- *************************************<->***********************************/
- void DeleteEntryFromList (WmWorkspaceData *pWS, ClientListEntry *pListEntry)
- {
-
- if (pListEntry->prevSibling)
- {
- pListEntry->prevSibling->nextSibling = pListEntry->nextSibling;
- }
- else
- {
- pWS->pSD->clientList = pListEntry->nextSibling;
- }
- if (pListEntry->nextSibling)
- {
- pListEntry->nextSibling->prevSibling = pListEntry->prevSibling;
- }
- else
- {
- pWS->pSD->lastClient = pListEntry->prevSibling;
- }
- } /* END OF FUNCTION DeleteEntryFromList */
- /*************************************<->*************************************
- *
- * DeleteClientFromList (pWS, pCD)
- *
- *
- * Description:
- * -----------
- * This function deletes a client from the client window list. If this is
- * a transient window then it is deleted from its transient window tree.
- * If this is a system modal window then clean up the system modal state.
- *
- *
- * Inputs:
- * ------
- * pCD = pointer to client data for the window to be added to the list
- *
- * Outputs:
- * -------
- * pWS = (clientList, lastClient)
- *
- *************************************<->***********************************/
- void DeleteClientFromList (WmWorkspaceData *pWS, ClientData *pCD)
- {
- WsClientData *pWsc = GetWsClientData (pWS, pCD);
- WmScreenData *pSD = pWS->pSD;
- if (pCD->transientLeader)
- {
- DeleteTransient (pCD);
- }
- else
- {
- /*
- * If this is a system modal window then clean up the system modal
- * state.
- */
- if (pCD->inputMode == MWM_INPUT_SYSTEM_MODAL)
- {
- UndoSystemModalState ();
- }
- /*
- * Remove the client and icon entries from the window list.
- */
- if (!pWsc->pIconBox && pWsc->iconFrameWin)
- {
- if (pCD->iconEntry.prevSibling)
- {
- pCD->iconEntry.prevSibling->nextSibling =
- pCD->iconEntry.nextSibling;
- }
- else
- {
- pSD->clientList = pCD->iconEntry.nextSibling;
- }
- if (pCD->iconEntry.nextSibling)
- {
- pCD->iconEntry.nextSibling->prevSibling =
- pCD->iconEntry.prevSibling;
- }
- else
- {
- pSD->lastClient = pCD->iconEntry.prevSibling;
- }
- }
- if (pCD->clientEntry.prevSibling)
- {
- pCD->clientEntry.prevSibling->nextSibling =
- pCD->clientEntry.nextSibling;
- }
- else
- {
- pSD->clientList = pCD->clientEntry.nextSibling;
- }
- if (pCD->clientEntry.nextSibling)
- {
- pCD->clientEntry.nextSibling->prevSibling =
- pCD->clientEntry.prevSibling;
- }
- else
- {
- pSD->lastClient = pCD->clientEntry.prevSibling;
- }
- }
- } /* END OF FUNCTION DeleteClientFromList */
- /*************************************<->*************************************
- *
- * AddTransient (pWS, pCD)
- *
- *
- * Description:
- * -----------
- * This function adds the transient window to the lead window's list of
- * transients.
- *
- *
- * Inputs:
- * ------
- * pWS = pointer to workspace data
- * pCD = pointer to client data of a transient window
- *
- *
- * Outputs:
- * -------
- * pCD->transientLeader = (transientChildren, modalCount)
- *
- *************************************<->***********************************/
- void AddTransient (WmWorkspaceData *pWS, ClientData *pCD)
- {
- ClientData *pcdLeader = pCD->transientLeader;
- ClientData *pcdTop = FindTransientTreeLeader (pCD);
- Boolean restackTransients;
- WmScreenData *pSD = pWS->pSD;
- pCD->transientSiblings = pcdLeader->transientChildren;
- pcdLeader->transientChildren = pCD;
- /*
- * Insure that the new transient window is on top of its siblings
- * and that the transient window tree is on top of the window
- * stack (this is the standard behavior for newly mapped and
- * managed windows). If there is a system modal window that the
- * transient window is not associated with then don't raise the
- * transient tree.
- */
- restackTransients = PutTransientOnTop (pCD);
- /*
- * Handle application modal transient windows
- */
- if (pCD->inputMode == MWM_INPUT_PRIMARY_APPLICATION_MODAL)
- {
- /*
- * If this is a primary application modal window then increment
- * the modal count for transient leaders that are directly up
- * the transient tree.
- *
- * (This is the old MWM_INPUT_APPLICATION_MODAL behavior.)
- */
- while (pcdLeader)
- {
- MarkModalTransient (pcdLeader, pCD);
- pcdLeader = pcdLeader->transientLeader;
- }
- }
- else if (pCD->inputMode == MWM_INPUT_FULL_APPLICATION_MODAL)
- {
- /*
- * If this is a full application modal window then increment
- * the modal count for the rest of the transient tree.
- */
- MarkModalSubtree (pcdTop, pCD);
- }
- else if (pcdTop->fullModalCount)
- {
- /*
- * There is already a full application modal window in the tree
- */
- pcdLeader = pCD->transientLeader;
- if ((pcdLeader->inputMode != MWM_INPUT_FULL_APPLICATION_MODAL) ||
- (IS_APP_MODALIZED(pcdLeader)))
- {
- /*
- * The immediate parent of this transient is not the
- * current full application modal window. Set the full
- * modal count to the parent's so that they both become
- * unmodalized at the same time. This allows a full
- * app modal window to have active, non-modal transients.
- */
- pCD->fullModalCount = pcdLeader->fullModalCount;
- }
- }
- /*
- * Do the actual restacking in the X window stack if necessary.
- */
- if ((pSD->clientList != &pcdTop->clientEntry) && !wmGD.systemModalActive)
- {
- F_Raise (NULL, pCD, NULL);
- }
- else if (restackTransients)
- {
- RestackTransientsAtWindow (pCD);
- }
- else if (pCD != FindTransientOnTop (pcdTop))
- {
- StackTransientWindow (pCD);
- }
- } /* END OF FUNCTION AddTransient */
- /*************************************<->*************************************
- *
- * MarkModalSubtree (pcdTree, pcdAvoid)
- *
- *
- * Description:
- * -----------
- * This function marks the transient tree with pcdTree as its leader.
- * If pcdAvoid is in the tree, it is not marked.
- *
- * Inputs:
- * ------
- * pcdTree = pointer to client data of the tree to mark
- * pcdAvoid = pointer to client data to not mark if in tree
- *
- *
- *************************************<->***********************************/
- void MarkModalSubtree (ClientData *pcdTree, ClientData *pcdAvoid)
- {
- /* Mark children, if any */
- if (pcdTree->transientChildren)
- MarkModalSubtree (pcdTree->transientChildren, pcdAvoid);
- /* Mark this node */
- if (pcdTree != pcdAvoid)
- {
- MarkModalTransient (pcdTree, pcdAvoid);
- }
- /* Mark siblings */
- if (pcdTree->transientSiblings)
- MarkModalSubtree (pcdTree->transientSiblings, pcdAvoid);
- }
- /*************************************<->*************************************
- *
- * MarkModalTransient (pcdLeader, pCD)
- *
- *
- * Description:
- * -----------
- * This function marks a transient window for application modal processing.
- * Grabs are done to eat up pointer button events.
- *
- * Inputs:
- * ------
- * pcdLeader = pointer to client data to mark
- * pCD = pointer to client data of new transient
- *
- *
- *************************************<->***********************************/
- void MarkModalTransient (ClientData *pcdLeader, ClientData *pCD)
- {
- if (!IS_APP_MODALIZED(pcdLeader))
- {
- /*
- * Eat pointer button events while application modal.
- */
- XGrabButton (DISPLAY, AnyButton, AnyModifier,
- pcdLeader->clientBaseWin, True,
- ButtonPressMask | ButtonMotionMask, GrabModeAsync,
- GrabModeAsync, None, wmGD.workspaceCursor);
- }
- /* bump application modal count */
- if (pCD->inputMode == MWM_INPUT_FULL_APPLICATION_MODAL)
- pcdLeader->fullModalCount++;
- else
- pcdLeader->primaryModalCount++;
- }
- /*************************************<->*************************************
- *
- * DeleteTransient (pCD)
- *
- *
- * Description:
- * -----------
- * This function deletes the transient window from the lead window's list
- * of transients
- *
- * Much of the complication of this code arises from trying to handle
- * mixtures of both full- and primary-application modal transients.
- * It also tries to handle the case where a sequence of application
- * modal transients appear in different places in the transient tree
- * (i.e. not as descendents of a previously existing full app modal
- * transient).
- *
- * Inputs:
- * ------
- * pCD = pointer to client data of transient.
- *
- *************************************<->***********************************/
- void DeleteTransient (ClientData *pCD)
- {
- ClientData *pcdLeader;
- ClientData *pcdPrev;
- int modalCount;
- /*
- * Handle primary application modality.
- * Reset the modal window counts for the leader windows up through the
- * transient window tree.
- */
- modalCount = pCD->primaryModalCount;
- if (pCD->inputMode == MWM_INPUT_PRIMARY_APPLICATION_MODAL)
- {
- modalCount += 1;
- }
- if (modalCount)
- {
- pcdLeader = pCD->transientLeader;
- while (pcdLeader)
- {
- if (modalCount)
- UnMarkModalTransient (pcdLeader, modalCount, pCD);
- pcdLeader = pcdLeader->transientLeader;
- }
- }
- /*
- * Handle full application modality.
- * Undo application modal windows in a depth first manner.
- */
- pcdLeader = FindTransientTreeLeader (pCD);
- if (pCD->transientChildren)
- {
- DeleteFullAppModalChildren (pcdLeader, pCD->transientChildren);
- }
- if (pCD->inputMode == MWM_INPUT_FULL_APPLICATION_MODAL)
- {
- /*
- * If this is a full application modal window then decrement
- * the modal count for the rest of the transient tree.
- */
- FixupFullAppModalCounts (pcdLeader, pCD);
- }
- /*
- * Delete this transient from its parent's list of transient windows.
- */
- pcdPrev = pCD->transientLeader->transientChildren;
- if(pcdPrev)
- {
- if (pcdPrev == pCD)
- {
- pCD->transientLeader->transientChildren = pCD->transientSiblings;
- }
- else
- {
- while (pcdPrev && (pcdPrev->transientSiblings != pCD))
- {
- pcdPrev = pcdPrev->transientSiblings;
- }
- if (pcdPrev)
- pcdPrev->transientSiblings = pCD->transientSiblings;
- }
- }
- } /* END OF FUNCTION DeleteTransient */
- /*************************************<->*************************************
- *
- * DeleteFullAppModalChildren (pcdLeader, pCD)
- *
- *
- * Description:
- * -----------
- * This function handles the clean-up of nested full application modal
- * windows. The deletion has to be handled carefully to keep a correct
- * fullModalCount on the transients that remain in the tree.
- *
- * The algorithm is to traverse the transient children depth first and
- * fix up the tree's fullModalCount for each full application modal
- * window that's found.
- *
- * Inputs:
- * ------
- * pcdLeader = pointer to client data of transient tree root.
- * pCD = pointer to client data of transient subtree to delete.
- *
- *************************************<->***********************************/
- void DeleteFullAppModalChildren (ClientData *pcdLeader, ClientData *pCD)
- {
- /* recursively do children first */
- if (pCD->transientChildren)
- DeleteFullAppModalChildren (pcdLeader, pCD->transientChildren);
- /* do fullAppModal fixup for this guy */
- FixupFullAppModalCounts (pcdLeader, pCD);
- /* do siblings of passed transient */
- if (pCD->transientSiblings)
- DeleteFullAppModalChildren (pcdLeader, pCD->transientSiblings);
-
- } /* END OF FUNCTION DeleteFullAppModalChildren */
- /*************************************<->*************************************
- *
- * FixupFullAppModalCounts (pcdLeader, pcdDelete)
- *
- *
- * Description:
- * -----------
- * This function traverses the entire transient tree (pointed to by
- * pcdLeader) and fixes up the fullModalCounts to reflect the removal
- * of pcdDelete.
- *
- * The fix-up consists of decrementing the count
- * of the remaining full app modal windows in the tree iff the remaining
- * window's fullModalCount is greater than the fullModalCount of the
- * transient being deleted.
- *
- * Inputs:
- * ------
- * pcdLeader = pointer to client data for head of transient tree.
- * pcdDelet = pointer to client data of transient being deleted.
- *
- *************************************<->***********************************/
- void
- FixupFullAppModalCounts (ClientData *pcdLeader, ClientData *pcdDelete)
- {
- /* fixup children */
- if (pcdLeader->transientChildren)
- {
- FixupFullAppModalCounts (pcdLeader->transientChildren, pcdDelete);
- }
- /*
- * fixup leader: decrement the count if it is greater than
- * the transient being deleted.
- *
- */
- if (pcdLeader->fullModalCount > pcdDelete->fullModalCount)
- {
- UnMarkModalTransient (pcdLeader, 1, pcdDelete);
- }
- /* fixup siblings */
- if (pcdLeader->transientSiblings)
- {
- FixupFullAppModalCounts (pcdLeader->transientSiblings, pcdDelete);
- }
-
- } /* END OF FUNCTION FixupFullAppModalCounts */
- /*************************************<->*************************************
- *
- * UnMarkModalTransient (pcdModee, modalCount, pcdModal)
- *
- *
- * Description:
- * -----------
- * This function unmarks a transient window for application modal processing.
- * Original grabs are restored.
- *
- * Inputs:
- * ------
- * pcdModee = pointer to client data for transient to unmark
- * pcdModal = pointer to client data for modal transient
- * modalCount = amount to decrement the client's modal count by
- *
- *
- *************************************<->***********************************/
- void UnMarkModalTransient (ClientData *pcdModee, int modalCount, ClientData *pcdModal)
- {
- /* decrement application modal count */
- if (pcdModal->inputMode == MWM_INPUT_FULL_APPLICATION_MODAL)
- pcdModee->fullModalCount -= modalCount;
- else if (pcdModal->inputMode == MWM_INPUT_PRIMARY_APPLICATION_MODAL)
- pcdModee->primaryModalCount -= modalCount;
- /*
- * Restore original button bindings/grabs if not modal anymore
- */
- if (!IS_APP_MODALIZED(pcdModee))
- {
- XUngrabButton (DISPLAY, AnyButton, AnyModifier,
- pcdModee->clientBaseWin);
- SetupCButtonBindings (pcdModee->clientBaseWin, BUTTON_SPECS(pcdModee));
- if ((wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_EXPLICIT) &&
- (wmGD.keyboardFocus != pcdModee))
- {
- DoExplicitSelectGrab (pcdModee->clientBaseWin);
- }
- }
- }
- /*************************************<->*************************************
- *
- * PutTransientOnTop (pcd)
- *
- *
- * Description:
- * -----------
- * This function changes the transient window list to insure that the
- * specified transient window is on top of its siblings and its parent
- * is on top of its siblings, etc. The sibling list is ordered such
- * that the first window in the list is on top of second window in the
- * list, etc.
- *
- *
- * Inputs:
- * ------
- * pcd = pointer to client data of a transient window
- *
- *
- * Outputs:
- * -------
- * pcdLeader = (transientSiblings)
- *
- * RETURN = True if the transient tree needs to be restacked
- *
- *************************************<->***********************************/
- Boolean PutTransientOnTop (ClientData *pcd)
- {
- ClientData *pcdLeader;
- ClientData *pcdPrev;
- Boolean restack = False;
- pcdLeader = pcd->transientLeader;
- if (pcdLeader != NULL)
- {
- pcdPrev = pcdLeader->transientChildren;
- if (pcdPrev != pcd)
- {
- while (pcdPrev->transientSiblings != pcd)
- {
- pcdPrev = pcdPrev->transientSiblings;
- }
- pcdPrev->transientSiblings = pcd->transientSiblings;
- pcd->transientSiblings = pcdLeader->transientChildren;
- pcdLeader->transientChildren = pcd;
- restack = True;
- }
- if (PutTransientOnTop (pcdLeader))
- {
- restack = True;
- }
- if (BumpPrimaryToBottom (pcdLeader))
- {
- restack = True;
- }
- }
- return (restack);
- } /* END OF FUNCTION PutTransientOnTop */
- /*************************************<->*************************************
- *
- * PutTransientBelowSiblings (pcd)
- *
- *
- * Description:
- * -----------
- * This function changes the transient window list to insure that the
- * specified transient window is below its sibling windows.
- *
- *
- * Inputs:
- * ------
- * pcd = pointer to client data of a transient window
- *
- *
- * Outputs:
- * -------
- * pcdLeader = (transientSiblings)
- *
- * RETURN = True if restacking has been done in the transient window tree.
- *
- *************************************<->***********************************/
- Boolean PutTransientBelowSiblings (ClientData *pcd)
- {
- ClientData *pcdLeader;
- ClientData *pcdNext;
- Boolean restack = False;
- pcdLeader = pcd->transientLeader;
- if (pcdLeader)
- {
- if (pcd->transientSiblings || (pcdLeader->transientChildren != pcd))
- {
- restack = True;
- if (pcdLeader->transientChildren == pcd)
- {
- pcdLeader->transientChildren = pcd->transientSiblings;
- }
- pcdNext = pcdLeader->transientChildren;
- while (pcdNext->transientSiblings)
- {
- if (pcdNext->transientSiblings == pcd)
- {
- pcdNext->transientSiblings = pcd->transientSiblings;
- }
- else
- {
- pcdNext = pcdNext->transientSiblings;
- }
- }
- pcdNext->transientSiblings = pcd;
- }
- pcd->transientSiblings = NULL;
- }
- return (restack);
- } /* END OF FUNCTION PutTransientBelowSiblings */
- /*************************************<->*************************************
- *
- * RestackTransients (pcd)
- *
- *
- * Description:
- * -----------
- * This function restacks windows in a transient window tree. Secondary
- * (transient) windows are stacked on top of their associated primary
- * windows and the first secondary window in the transientSiblings list
- * is stacked on top of the second window in the list, etc.
- *
- *
- * Inputs:
- * ------
- * pcd = pointer to client data of a window in a transient tree
- *
- *************************************<->***********************************/
- void RestackTransients (ClientData *pcd)
- {
- ClientData *pcdLeader;
- int count;
- static int size = 0;
- static Window *windows = NULL;
- XWindowChanges windowChanges;
- int i;
- int leaderIndex;
- /*
- * Build a restacking list and do the restacking.
- */
- pcdLeader = FindTransientTreeLeader (pcd);
- count = CountTransientChildren (pcdLeader);
- /* No work to do if no transient children; count includes leader. */
- if (count < 2)
- return;
- if (count > size)
- {
- /*
- * Expand the (static) windows buffer that is used in restacking.
- */
- if (!(windows =
- (Window *)WmMalloc ((char*)windows, (count + 5) * sizeof (Window))))
- {
- /* cannot get memory space */
- size = 0;
- return;
- }
- size = count + 5;
- }
- MakeTransientFamilyStackingList (windows, pcdLeader);
- /*
- * Changes for CDExc19397.
- * XRestackWindows may move pcdLeader; that messes up the
- * global window stack. Call XConfigureWindow() instead,
- * and don't change location of pcdLeader.
- */
- for (leaderIndex = 0; leaderIndex < count; leaderIndex++)
- {
- if (windows[leaderIndex] == pcdLeader->clientFrameWin)
- break;
- }
- if (leaderIndex >= count) /* ? Couldn't find leader; should NOT happen. */
- leaderIndex = count - 1;
- windowChanges.stack_mode = Above;
- for (i = leaderIndex; i > 0; i--)
- {
- windowChanges.sibling = windows[i];
- XConfigureWindow (DISPLAY, windows[i - 1],
- CWSibling | CWStackMode, &windowChanges);
- }
- windowChanges.stack_mode = Below;
- for (i = leaderIndex; i < count - 1; i++)
- {
- windowChanges.sibling = windows[i];
- XConfigureWindow (DISPLAY, windows[i + 1],
- CWSibling | CWStackMode, &windowChanges);
- }
- } /* END OF FUNCTION RestackTransients */
- /*************************************<->*************************************
- *
- * RestackTransientsAtWindow (pcd)
- *
- *
- * Description:
- * -----------
- * This function restacks windows in a transient window tree. The
- * "anchor point" in the stack for the transient window tree is the
- * specified window.
- *
- *
- * Inputs:
- * ------
- * pcd = pointer to client data of a window in a transient tree
- *
- *************************************<->***********************************/
- void RestackTransientsAtWindow (ClientData *pcd)
- {
- ClientData *pcdLeader;
- XWindowChanges windowChanges;
- pcdLeader = FindTransientTreeLeader (pcd);
- if (pcdLeader && (pcdLeader != pcd))
- {
- windowChanges.sibling = pcd->clientFrameWin;
- windowChanges.stack_mode = Below;
- XConfigureWindow (DISPLAY, pcdLeader->clientFrameWin,
- CWSibling | CWStackMode, &windowChanges);
- }
- RestackTransients (pcd);
- } /* END OF FUNCTION RestackTransientsAtWindow */
- /*************************************<->*************************************
- *
- * FindTransientTreeLeader (pcd)
- *
- *
- * Description:
- * -----------
- * This function identifies the leader of the transient tree that
- * contains the specified client.
- *
- *
- * Inputs:
- * ------
- * pcd = pointer to client data of a window in a transient tree.
- *
- * Outputs:
- * -------
- * RETURN = pointer to the client data for the transient tree leader.
- *
- *************************************<->***********************************/
- ClientData * FindTransientTreeLeader (ClientData *pcd)
- {
- /*
- * Find the head of the transient window tree.
- */
- while (pcd->transientLeader)
- {
- pcd = pcd->transientLeader;
- }
- return (pcd);
- } /* END OF FUNCTION FindTransientTreeLeader */
- /*************************************<->*************************************
- *
- * CountTransientChildren (pcd)
- *
- *
- * Description:
- * -----------
- * This function returns a count of the number of children in the
- * transient window tree headed by the specified client window.
- *
- *
- * Inputs:
- * ------
- * pcd = pointer to client data of a window in a transient tree
- *
- * Outputs:
- * -------
- * RETURN = count of transient windows in the transient window tree
- *
- *************************************<->***********************************/
- int
- CountTransientChildren (ClientData *pcd)
- {
- ClientData *pcdNext;
- int count = 1;
- pcdNext = pcd->transientChildren;
- while (pcdNext)
- {
- if (pcdNext->transientChildren)
- {
- count += CountTransientChildren (pcdNext);
- }
- else
- {
- count++;
- }
- pcdNext = pcdNext->transientSiblings;
- }
- return (count);
- } /* END OF FUNCTION CountTransientChildren */
- /*************************************<->*************************************
- *
- * MakeTransientWindowList (windows, pcd)
- *
- *
- * Description:
- * -----------
- * This function makes a transient window list of windows in the
- * transient window tree headed by the specified client. This list is
- * to be passed to XRestackWindows.
- *
- *
- * Inputs:
- * ------
- * windows = pointer to the windows list to be filled out
- *
- * pcd = pointer to client data of a window in a transient tree
- *
- * Outputs:
- * -------
- * RETURN = pointer to the next entry in the windows list
- *
- *************************************<->***********************************/
- Window * MakeTransientWindowList (Window *windows, ClientData *pcd)
- {
- ClientData *pcdNext;
- pcdNext = pcd->transientChildren;
- while (pcdNext)
- {
- if (pcdNext->transientChildren)
- {
- windows = MakeTransientWindowList (windows, pcdNext);
- }
- *windows = pcdNext->clientFrameWin;
- windows++;
- pcdNext = pcdNext->transientSiblings;
- }
- return (windows);
- } /* END OF FUNCTION MakeTransientWindowList */
- /*************************************<->*************************************
- *
- * FindTransientFocus (pcd)
- *
- *
- * Description:
- * -----------
- * This function identifies a window in the transient tree that is headed
- * by the specified client that can accept the keyboard input. The
- * effect of application modal windows is taken into account.
- *
- *
- * Inputs:
- * ------
- * pcd = pointer to client data of a window in a transient tree.
- *
- * Outputs:
- * -------
- * RETURN = pointer to the client data for a window that can accept the
- * keyboard input focus.
- *
- *************************************<->***********************************/
- ClientData * FindTransientFocus (ClientData *pcd)
- {
- ClientData *pcdFocus;
- /*
- * Find a window that does not have an application modal subordinate.
- * First, search descendents
- */
- pcdFocus = pcd;
- while (pcdFocus->transientChildren && IS_APP_MODALIZED(pcdFocus))
- {
- pcdFocus = pcdFocus->transientChildren;
- }
- /*
- * If (search of descendents FAILS) then search siblings.
- */
-
- if (IS_APP_MODALIZED(pcdFocus))
- {
- ClientData *pcdSibling;
- pcdFocus = pcd;
- while (pcdFocus && IS_APP_MODALIZED(pcdFocus))
- {
- pcdSibling = pcdFocus;
- while (pcdSibling->transientSiblings && IS_APP_MODALIZED(pcdFocus))
- {
- pcdSibling = pcdSibling->transientSiblings;
- }
- if (IS_APP_MODALIZED(pcdSibling))
- {
- pcdFocus = pcdFocus->transientChildren;
- }
- else
- {
- pcdFocus = pcdSibling;
- break;
- }
- }
- }
- return (pcdFocus ? pcdFocus : wmGD.keyboardFocus);
- } /* END OF FUNCTION FindTransientFocus */
- /*************************************<->*************************************
- *
- * FindTransientOnTop (pcd)
- *
- *
- * Description:
- * -----------
- * This function identifies the top-most transient window in the
- * transient window tree that contains the specified client.
- *
- *
- * Inputs:
- * ------
- * pcd = pointer to client data of a window in a transient tree.
- *
- * Outputs:
- * -------
- * RETURN = pointer to the client data for the top-most transient window.
- *
- *************************************<->***********************************/
- ClientData * FindTransientOnTop (ClientData *pcd)
- {
- /*
- * Find the head of the transient window tree.
- */
- pcd = FindTransientTreeLeader (pcd);
- if (!(pcd->secondariesOnTop) &&
- (LeaderOnTop (pcd)))
- {
- ClientData *pcdSub;
- if (LeaderOnTop (pcd))
- {
- /* The primary window is on top! */
- return (pcd);
- }
- else
- {
- pcdSub = FindSubLeaderToTop (pcd);
- if (pcdSub)
- return (pcdSub);
- }
- }
- /*
- * Find the top-most transient window (the window in the transient tree
- * that is highest in the window stack).
- */
- while (pcd->transientChildren)
- {
- pcd = pcd->transientChildren;
- }
- return (pcd);
- } /* END OF FUNCTION FindTransientOnTop */
- /*************************************<->*************************************
- *
- * StackWindow (pWS, pEntry, onTop, pStackEntry)
- *
- *
- * Description:
- * -----------
- * This function stacks a window of a particular type (normal or icon)
- * to the top or botton of the window stack on the screen.
- *
- *
- * Inputs:
- * ------
- * pWS = pointer to workspace data
- *
- * pEntry = pointer to the client list entry for the window to be restacked.
- *
- * onTop = if True then the window is to be restacked on top of the
- * specified stack window (if the stack window is not specified then
- * the entry is added to the top of the window stack)
- * otherwise the window is stacked below the specified stack window
- * (or at the bottom of the window stack if the stack window is not
- * specified).
- *
- * pStackEntry = pointer to a client list entry for a window in the window
- * stack that is to be used as a reference in restacking.
- *
- *************************************<->***********************************/
- void StackWindow (WmWorkspaceData *pWS, ClientListEntry *pEntry, Boolean onTop, ClientListEntry *pStackEntry)
- {
- Window stackWindow;
- Boolean stackTransientTreeWindows = False;
- Window activeIconWindow;
- Window window;
- XWindowChanges changes;
- WmScreenData *pSD = pWS->pSD;
- if (pStackEntry)
- {
- if (pStackEntry->type == MINIMIZED_STATE)
- {
- stackWindow = ICON_FRAME_WIN(pStackEntry->pCD);
- }
- else
- {
- stackWindow = pStackEntry->pCD->clientFrameWin;
- }
- }
- else
- {
- stackWindow = (Window)0;
- }
- if (pEntry->type == MINIMIZED_STATE)
- {
- window = ICON_FRAME_WIN(pEntry->pCD);
- }
- else
- {
- /*
- * Restack the transient tree if appropriate.
- */
- if (pEntry->pCD->transientLeader || pEntry->pCD->transientChildren)
- {
- stackTransientTreeWindows = True;
- window = (FindTransientOnTop (pEntry->pCD))->clientFrameWin;
- }
- else
- {
- window = pEntry->pCD->clientFrameWin;
- }
- }
- /*
- * The active icon text label must be restacked along with the associated
- * icon.
- */
- if ((pEntry->type == MINIMIZED_STATE) &&
- (pEntry->pCD == wmGD.keyboardFocus) &&
- (ICON_DECORATION(pEntry->pCD) & ICON_ACTIVE_LABEL_PART) &&
- (ACTIVE_ICON_TEXT_WIN))
- {
- activeIconWindow = ACTIVE_ICON_TEXT_WIN;
- }
- else
- {
- activeIconWindow = (Window)0;
- }
- if (onTop)
- {
- if ((stackWindow == 0) && (pSD->clientList))
- {
- if (pSD->clientList->type == MINIMIZED_STATE)
- {
- stackWindow = ICON_FRAME_WIN(pSD->clientList->pCD);
- }
- else
- {
- if (pSD->clientList->pCD->transientChildren)
- {
- stackWindow =
- (FindTransientOnTop(pSD->clientList->pCD))->clientFrameWin;
- }
- else
- {
- stackWindow = pSD->clientList->pCD->clientFrameWin;
- }
- }
- }
- if (activeIconWindow)
- {
- changes.sibling = stackWindow;
- changes.stack_mode = Above;
- XConfigureWindow (DISPLAY, activeIconWindow,
- (CWSibling | CWStackMode), &changes);
- changes.sibling = activeIconWindow;
- changes.stack_mode = Below;
- XConfigureWindow (DISPLAY, window, (CWSibling | CWStackMode),
- &changes);
- }
- else
- {
- changes.sibling = stackWindow;
- changes.stack_mode = Above;
- XConfigureWindow (DISPLAY, window, (CWSibling | CWStackMode),
- &changes);
- if (stackTransientTreeWindows)
- {
- /* make sure that the leader is in the correct spot */
- changes.sibling = window;
- changes.stack_mode = Below;
- XConfigureWindow (DISPLAY, pEntry->pCD->clientFrameWin,
- (CWSibling | CWStackMode), &changes);
- RestackTransients (pEntry->pCD);
- }
- }
- }
- else
- {
- /*
- * Adjust stack entry window if we're stacking below a
- * transient tree.
- */
- if (pStackEntry && pStackEntry->pCD->transientChildren)
- {
- stackWindow = LowestWindowInTransientFamily (pStackEntry->pCD);
- }
- if (stackWindow == 0)
- {
- if (pSD->lastClient->type == MINIMIZED_STATE)
- {
- stackWindow = ICON_FRAME_WIN(pSD->lastClient->pCD);
- }
- else
- {
- if (pSD->lastClient->pCD->transientChildren)
- {
- stackWindow =
- LowestWindowInTransientFamily (pSD->lastClient->pCD);
- }
- else
- stackWindow = pSD->lastClient->pCD->clientFrameWin;
- }
- }
- if (activeIconWindow)
- {
- changes.sibling = stackWindow;
- changes.stack_mode = Below;
- XConfigureWindow (DISPLAY, activeIconWindow,
- (CWSibling | CWStackMode), &changes);
- changes.sibling = activeIconWindow;
- changes.stack_mode = Below;
- XConfigureWindow (DISPLAY, window, (CWSibling | CWStackMode),
- &changes);
- }
- else
- {
- changes.sibling = stackWindow;
- changes.stack_mode = Below;
- XConfigureWindow (DISPLAY, window, (CWSibling | CWStackMode),
- &changes);
- if (stackTransientTreeWindows)
- {
- /* make sure that the leader is in the correct spot */
- changes.sibling = window;
- changes.stack_mode = Below;
- XConfigureWindow (DISPLAY, pEntry->pCD->clientFrameWin,
- (CWSibling | CWStackMode), &changes);
- RestackTransients (pEntry->pCD);
- }
- }
- }
- } /* END OF FUNCTION StackWindow */
- /*************************************<->*************************************
- *
- * StackTransientWindow (pcd)
- *
- *
- * Description:
- * -----------
- * This function stacks a transient window within its transient window
- * tree on the screen. The transient window tree should indicate the
- * intended stacking position.
- *
- *
- * Inputs:
- * ------
- * pcd = pointer to client data of a window in a transient tree
- *
- *************************************<->***********************************/
- void StackTransientWindow (ClientData *pcd)
- {
- XWindowChanges changes;
- ClientData *pcdPrev;
- if (pcd->transientLeader->transientChildren == pcd)
- {
- if (pcd->transientSiblings)
- {
- changes.sibling = pcd->transientSiblings->clientFrameWin;
- }
- else
- {
- changes.sibling = pcd->transientLeader->clientFrameWin;
- }
- changes.stack_mode = Above;
- }
- else
- {
- pcdPrev = pcd->transientLeader;
- while (pcdPrev->transientSiblings != pcd)
- {
- pcdPrev = pcdPrev->transientSiblings;
- }
- changes.sibling = pcdPrev->clientFrameWin;
- changes.stack_mode = Below;
- }
- XConfigureWindow (DISPLAY, pcd->clientFrameWin, (CWSibling | CWStackMode),
- &changes);
- } /* END OF FUNCTION StackTransientWindow */
- /*************************************<->*************************************
- *
- * CheckIfClientObscuring (pcdTop, pcd)
- *
- *
- * Description:
- * -----------
- * This function determines whether a window or a transient window tree
- * is obscuring (at least partially) a window or a transient window tree
- * that is below it in the window stack.
- *
- *
- * Inputs:
- * ------
- * pcdTop = pointer to client data for a window (it may be the leader of
- * a transient tree; this window is the higher in the window stack
- * than the window it is be checked against.
- *
- * pcd = pointer to client data for a window (it may be the leader of
- * a transient tree.
- *
- *
- * Outputs:
- * -------
- * RETURN = True if the top window(s) overlap the lower window(s)
- *
- *************************************<->***********************************/
- Boolean CheckIfClientObscuring (ClientData *pcdTop, ClientData *pcd)
- {
- Boolean obscuring = False;
- ClientData *pcdNext;
- /*
- * Check only if the top window is visible onscreen.
- */
- if (pcdTop->transientChildren && (pcdTop->clientState != MINIMIZED_STATE))
- {
- pcdNext = pcdTop->transientChildren;
- while (pcdNext && !obscuring)
- {
- obscuring = CheckIfClientObscuring (pcdNext, pcd);
- pcdNext = pcdNext->transientSiblings;
- }
- }
- if (!obscuring && pcd->transientChildren &&
- (pcd->clientState != MINIMIZED_STATE))
- {
- pcdNext = pcd->transientChildren;
- while (pcdNext && !obscuring)
- {
- obscuring = CheckIfClientObscuring (pcdTop, pcdNext);
- pcdNext = pcdNext->transientSiblings;
- }
- }
- if (!obscuring)
- {
- obscuring = CheckIfObscuring (pcdTop, pcd);
- }
- return (obscuring);
- } /* END OF FUNCTION CheckIfClientObscuring */
- /*************************************<->*************************************
- *
- * CheckIfObscuring (pcdA, pcdB)
- *
- *
- * Description:
- * -----------
- * This function determines whether a window (not a transient tree)
- * is obscuring (at least partially) a window (not a transient tree)
- * that is below it in the window stack.
- *
- *
- * Inputs:
- * ------
- * pcdA = pointer to client data for a window; this window is higher in
- * the window stack than the window it is be checked against.
- *
- * pcdB = pointer to client data for a window.
- *
- *
- * Outputs:
- * -------
- * RETURN = True if the top window overlaps the lower window
- *
- *************************************<->***********************************/
- Boolean CheckIfObscuring (ClientData *pcdA, ClientData *pcdB)
- {
- Boolean obscuring = False;
- int aX1;
- int aX2;
- int aY1;
- int aY2;
- int bX1;
- int bX2;
- int bY1;
- int bY2;
- /*
- * For workspace stuff: if either is unseen, then neither
- * is obscured.
- */
- if ((pcdA->clientState & UNSEEN_STATE) ||
- (pcdB->clientState & UNSEEN_STATE))
- {
- return (False);
- }
- if (pcdA->clientState == NORMAL_STATE)
- {
- aX1 = pcdA->clientX - pcdA->clientOffset.x;
- aY1 = pcdA->clientY - pcdA->clientOffset.y;
- aX2 = aX1 + pcdA->clientWidth + (2 * pcdA->clientOffset.x) - 1;
- aY2 = aY1 + pcdA->clientHeight + pcdA->clientOffset.y +
- pcdA->clientOffset.x - 1;
- }
- else if (pcdA->clientState == MINIMIZED_STATE)
- {
- aX1 = ICON_X(pcdA);
- aY1 = ICON_Y(pcdA);
- aX2 = aX1 + ICON_WIDTH(pcdA) - 1;
- aY2 = aY1 + ICON_HEIGHT(pcdA) - 1;
- }
- else /* (pcdA->clientState == MAXIMIZED_STATE) */
- {
- aX1 = pcdA->maxX - pcdA->clientOffset.x;
- aY1 = pcdA->maxY - pcdA->clientOffset.y;
- aX2 = aX1 + pcdA->maxWidth + (2 * pcdA->clientOffset.x) - 1;
- aY2 = aY1 + pcdA->maxHeight + pcdA->clientOffset.y +
- pcdA->clientOffset.x - 1;
- }
- if (pcdB->clientState == NORMAL_STATE)
- {
- bX1 = pcdB->clientX - pcdB->clientOffset.x;
- bY1 = pcdB->clientY - pcdB->clientOffset.y;
- bX2 = bX1 + pcdB->clientWidth + (2 * pcdB->clientOffset.x) - 1;
- bY2 = bY1 + pcdB->clientHeight + pcdB->clientOffset.y +
- pcdB->clientOffset.x - 1;
- }
- else if (pcdB->clientState == MINIMIZED_STATE)
- {
- bX1 = ICON_X(pcdB);
- bY1 = ICON_Y(pcdB);
- bX2 = bX1 + ICON_WIDTH(pcdB) - 1;
- bY2 = bY1 + ICON_HEIGHT(pcdB) - 1;
- }
- else /* (pcdB->clientState == MAXIMIZED_STATE) */
- {
- bX1 = pcdB->maxX - pcdB->clientOffset.x;
- bY1 = pcdB->maxY - pcdB->clientOffset.y;
- bX2 = bX1 + pcdB->maxWidth + (2 * pcdB->clientOffset.x) - 1;
- bY2 = bY1 + pcdB->maxHeight + pcdB->clientOffset.y +
- pcdB->clientOffset.x - 1;
- }
- /*
- * Check if there is overlap in both dimensions.
- */
- if (((aX1 >= bX1) && (aX1 <= bX2)) || ((aX2 >= bX1) && (aX2 <= bX2)) ||
- ((bX1 >= aX1) && (bX1 <= aX2)) || ((bX2 >= aX1) && (bX2 <= aX2)))
- {
- if (((aY1 >= bY1) && (aY1 <= bY2)) || ((aY2 >= bY1) && (aY2 <= bY2)) ||
- ((bY1 >= aY1) && (bY1 <= aY2)) || ((bY2 >= aY1) && (bY2 <= aY2)))
- {
- obscuring = True;
- }
- }
- return (obscuring);
- } /* END OF FUNCTION CheckIfObscuring */
- /*************************************<->*************************************
- *
- * CheckIfClientObscuredByAny (pcd)
- *
- *
- * Description:
- * -----------
- * This function determines whether a window or a transient window tree
- * is obscured (at least partially) by any other window.
- *
- *
- * Inputs:
- * ------
- * pcd = pointer to client data for a window (it may be the leader of
- * a transient tree.
- *
- *
- * Outputs:
- * -------
- * RETURN = True if the window(s) are overlapped.
- *
- *************************************<->***********************************/
- Boolean CheckIfClientObscuredByAny (ClientData *pcd)
- {
- Boolean obscured = False;
- ClientListEntry *pListEntry;
- pListEntry = ACTIVE_PSD->clientList;
- while (pListEntry && !obscured)
- {
- if (pListEntry->pCD == pcd)
- {
- if (((pListEntry->type == MINIMIZED_STATE) &&
- (pListEntry->pCD->clientState == MINIMIZED_STATE)) ||
- ((pListEntry->type != MINIMIZED_STATE) &&
- (pListEntry->pCD->clientState != MINIMIZED_STATE)))
- {
- pListEntry = NULL;
- }
- }
- else if (((pListEntry->type == MINIMIZED_STATE) &&
- (pListEntry->pCD->clientState == MINIMIZED_STATE)) ||
- ((pListEntry->type != MINIMIZED_STATE) &&
- (pListEntry->pCD->clientState != MINIMIZED_STATE)))
- {
- /*
- * The window for the entry is visible on screen. See if it
- * obscures the indicated window.
- */
- obscured = CheckIfClientObscuring (pListEntry->pCD, pcd);
- }
- if (pListEntry)
- {
- pListEntry = pListEntry->nextSibling;
- }
- }
- return (obscured);
- } /* END OF FUNCTION CheckIfClientObscuredByAny */
- /*************************************<->*************************************
- *
- * CheckIfClientObscuringAny (pcd)
- *
- *
- * Description:
- * -----------
- * This function determines whether a window or a transient window tree
- * is obscuring another window.
- *
- *
- * Inputs:
- * ------
- * pcd = pointer to client data for a window (it may be the leader of
- * a transient tree.
- *
- *
- * Outputs:
- * -------
- * RETURN = True if the window(s) overlaps anther window.
- *
- *************************************<->***********************************/
- Boolean CheckIfClientObscuringAny (ClientData *pcd)
- {
- Boolean obscuring = False;
- ClientListEntry *pListEntry;
- pListEntry = (pcd->clientState == MINIMIZED_STATE) ?
- &pcd->iconEntry : &pcd->clientEntry;
- while (pListEntry && !obscuring)
- {
- if ((pListEntry->pCD != pcd) &&
- (((pListEntry->type == MINIMIZED_STATE) &&
- (pListEntry->pCD->clientState == MINIMIZED_STATE)) ||
- ((pListEntry->type != MINIMIZED_STATE) &&
- (pListEntry->pCD->clientState != MINIMIZED_STATE))))
- {
- obscuring = CheckIfClientObscuring (pcd, pListEntry->pCD);
- }
- pListEntry = pListEntry->nextSibling;
- }
- return (obscuring);
- } /* END OF FUNCTION CheckIfClientObscuringAny */
- /*************************************<->*************************************
- *
- * SetupSystemModalState (pCD)
- *
- *
- * Description:
- * -----------
- * This function prepares for mapping a system modal window. An input
- * screen window is mapped below the system modal window to prevent input
- * to the windows not related to the system modal window.
- *
- *
- * Inputs:
- * ------
- * pCD = pointer to client data for the system modal window; if NULL the
- * system modal window is a special window manager dialog box
- *
- *
- * Outputs:
- * -------
- * wmGD = changes to system modal state data
- *
- *************************************<->***********************************/
- void SetupSystemModalState (ClientData *pCD)
- {
- XWindowChanges windowChanges;
- unsigned int width, height;
- unsigned int x_hot, y_hot;
- unsigned char *bits;
- unsigned char *mask_bits;
- WmScreenData *pSD;
- int scr;
- /*
- * If we've got a menu active, then unpost it first
- * so that grabs from the menu don't interfere with
- * the system modal dialog. We want to avoid lock-ups.
- */
- if (wmGD.menuActive != NULL)
- {
- UnpostMenu (wmGD.menuActive);
- XSync (DISPLAY, False);
- }
- /*
- * Try to grab the pointer and keyboard. If either
- * fails because event processing is frozen by another grab, then
- * don't do system modal for fear of leaving the system unusable.
- */
- if (XGrabPointer(DISPLAY,
- ROOT_FOR_CLIENT(pCD),
- FALSE, /* owner_events */
- (unsigned int) 0, /* event mask */
- GrabModeAsync, /* pointer_mode */
- GrabModeAsync, /* keyboard_mode */
- None, /* confine_to window */
- None, /* cursor */
- CurrentTime) == GrabFrozen)
- {
- return;
- }
- else
- {
- XUngrabPointer (DISPLAY, CurrentTime);
- }
- if (XGrabKeyboard(DISPLAY,
- ROOT_FOR_CLIENT(pCD),
- FALSE, /* owner_events */
- GrabModeAsync, /* pointer_mode */
- GrabModeAsync, /* keyboard_mode */
- CurrentTime) == GrabFrozen)
- {
- return;
- }
- else
- {
- XUngrabKeyboard (DISPLAY, CurrentTime);
- }
- #ifdef LARGECURSORS
- if (wmGD.useLargeCursors)
- {
- width = noenter32_width;
- height = noenter32_height;
- x_hot = noenter32_x_hot;
- y_hot = noenter32_y_hot;
- bits = noenter32_bits;
- mask_bits = noenter32m_bits;
- }
- else
- #endif /* LARGECURSORS */
- {
- width = noenter16_width;
- height = noenter16_height;
- x_hot = noenter16_x_hot;
- y_hot = noenter16_y_hot;
- bits = noenter16_bits;
- mask_bits = noenter16m_bits;
- }
- for (scr=0; scr<wmGD.numScreens; scr++)
- {
- pSD = &(wmGD.Screens[scr]);
-
- /*
- * Make the system modal input screen window if necessary.
- */
-
- if (pSD->managed && pSD->inputScreenWindow == 0)
- {
- XSetWindowAttributes windowAttributes;
- Pixmap pixmap;
- Pixmap maskPixmap;
- XColor xcolors[2];
-
- windowAttributes.event_mask = ButtonPressMask;
- if (wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_POINTER)
- {
- windowAttributes.event_mask |= EnterWindowMask;
- }
- windowAttributes.override_redirect = True;
-
- pixmap = XCreateBitmapFromData (DISPLAY, pSD->rootWindow,
- (char *)bits, width, height);
-
- maskPixmap = XCreateBitmapFromData (DISPLAY, pSD->rootWindow,
- (char *)mask_bits, width, height);
-
- xcolors[0].pixel = BlackPixel (DISPLAY, pSD->screen);
- xcolors[1].pixel = WhitePixel (DISPLAY, pSD->screen);
- XQueryColors (DISPLAY, DefaultColormap (DISPLAY, pSD->screen),
- xcolors, 2);
- windowAttributes.cursor =
- XCreatePixmapCursor (DISPLAY, pixmap, maskPixmap,
- &(xcolors[0]), &(xcolors[1]),
- x_hot, y_hot);
- XFreePixmap (DISPLAY, pixmap);
- XFreePixmap (DISPLAY, maskPixmap);
-
- pSD->inputScreenWindow =
- XCreateWindow (DISPLAY, pSD->rootWindow, 0, 0,
- DisplayWidth (DISPLAY, pSD->screen),
- DisplayHeight (DISPLAY, pSD->screen),
- 0,
- 0,
- InputOnly,
- CopyFromParent,
- CWEventMask | CWOverrideRedirect | CWCursor,
- &windowAttributes);
- }
- if (pSD->managed && pSD != ACTIVE_PSD)
- {
- XMapRaised (DISPLAY, pSD->inputScreenWindow);
- }
- }
-
- if (pCD)
- {
- wmGD.systemModalWindow = pCD->clientFrameWin;
- }
- else
- {
- /*
- * ELSE: the system modal window is a special window manager dialog
- * box and wmGD.systemModalWindow is set prior to the call to
- * SetupSystemModalState. Set the focus to the special window manager
- * dialog box.
- */
-
- SetKeyboardFocus (NULL, REFRESH_LAST_FOCUS);
- XSetInputFocus (DISPLAY, wmGD.systemModalWindow, RevertToPointerRoot,
- CurrentTime);
- }
-
-
- /*
- * Map the system modal input screen window below the system modal
- * window.
- */
-
- windowChanges.sibling = wmGD.systemModalWindow;
- windowChanges.stack_mode = Below;
- XConfigureWindow (DISPLAY, ACTIVE_PSD->inputScreenWindow,
- CWSibling | CWStackMode, &windowChanges);
-
- XMapWindow (DISPLAY, ACTIVE_PSD->inputScreenWindow);
-
-
- /*
- * Setup the system modal global data.
- */
-
- wmGD.systemModalActive = True;
- wmGD.systemModalClient = pCD;
-
-
- } /* END OF FUNCTION SetupSystemModalState */
- /*************************************<->*************************************
- *
- * UndoSystemModalState ()
- *
- *
- * Description:
- * -----------
- * This function cleans up after a system modal window goes away.
- *
- *
- * Inputs:
- * ------
- * wmGD = (system modal state data)
- *
- *
- * Outputs:
- * -------
- * wmGD = changes to system modal state data
- *
- *************************************<->***********************************/
- void UndoSystemModalState (void)
- {
- int scr;
-
- /*
- * Unmap the system modal input screen window.
- */
- for (scr = 0; scr < wmGD.numScreens; scr++)
- {
- if(wmGD.Screens[scr].managed)
- {
- XUnmapWindow (DISPLAY, wmGD.Screens[scr].inputScreenWindow);
- }
- }
- /*
- * Reset the focus if a window manager system modal dialog box was
- * being displayed.
- */
- if (!wmGD.systemModalClient)
- {
- AutoResetKeyFocus (NULL, GetTimestamp());
- }
- /*
- * Reset the system modal global data.
- */
- wmGD.systemModalActive = False;
- wmGD.systemModalClient = NULL;
- wmGD.systemModalWindow = 0;
- } /* END OF FUNCTION UndoSystemModalState */
- /*************************************<->*************************************
- *
- * FindClientNameMatch (pStartingEntry, toNext, clientName, types)
- *
- *
- * Description:
- * -----------
- * This function searches for a client that has a particular name or class.
- * A match will be indicated if the client with the name or class also
- * is in a particular state.
- *
- *
- * Inputs:
- * ------
- * pEntry = pointer to the client list entry where the search is
- * to begin.
- *
- * toNext = if True then search client list from first to last; otherwise
- * search the client list last to first.
- *
- * clientName = string that indicates a client name or class.
- *
- * type = types of objects (icon, window, ...) that are to be matched.
- *
- *
- * Outputs:
- * -------
- * RETURN = pointer to client list entry for matched client.
- *
- *************************************<->***********************************/
- ClientListEntry * FindClientNameMatch (ClientListEntry *pEntry,
- Boolean toNext,
- String clientName,
- unsigned long types)
- {
- Boolean foundMatch = False;
- Boolean checkEntry;
- ClientData *pCD;
- while (!foundMatch && pEntry)
- {
- checkEntry = False;
- pCD = pEntry->pCD;
- if (pEntry->type == MINIMIZED_STATE)
- {
- if ((pCD->clientState == MINIMIZED_STATE) &&
- (types & F_GROUP_ICON))
- {
- checkEntry = True;
- }
- }
- else
- {
- if ((pCD->clientState != MINIMIZED_STATE) &&
- (types & F_GROUP_WINDOW))
- {
- checkEntry = True;
- }
- }
- if (checkEntry &&
- ((pCD->clientName && (strcmp (clientName,pCD->clientName) == 0)) ||
- (pCD->clientClass && (strcmp (clientName,pCD->clientClass) == 0))))
- {
- foundMatch = True;
- }
- else
- {
- pEntry = (toNext) ? pEntry->nextSibling : pEntry->prevSibling;
- }
- }
- return (pEntry);
- } /* END OF FUNCTION FindClientNameMatch */
- /*************************************<->*************************************
- *
- * BumpPrimaryToTop (pcdLeader)
- *
- *
- * Description:
- * -----------
- * This function moves the primary window to the "top" of the transient
- * tree.
- *
- * Inputs:
- * ------
- * pcdLeader = pointer to client data of transient tree root.
- *
- * Returns: True if stacking order of leader window changed.
- * False if not stacking change.
- *
- * Comments:
- * ---------
- * This affects only the clientData structures. There is no immediate
- * effect on the actual stacking order on the display. That is done
- * by StackWindow and/or RestackTransients.
- *
- *************************************<->***********************************/
- Boolean BumpPrimaryToTop (ClientData *pcdLeader)
- {
- int count;
- Boolean rval;
- count = CountTransientChildren (pcdLeader);
- if (pcdLeader->primaryStackPosition != (count-1))
- {
- pcdLeader->primaryStackPosition = count - 1;
- rval = True;
- }
- else
- {
- rval = False;
- }
- return (rval);
- }
- /*************************************<->*************************************
- *
- * BumpPrimaryToBottom (pcdLeader)
- *
- *
- * Description:
- * -----------
- * This function moves the primary window to the "bottom" of the transient
- * tree.
- *
- * Inputs:
- * ------
- * pcdLeader = pointer to client data of transient tree root.
- *
- * Returns: True if stacking order of leader window changed.
- * False if not stacking change.
- *
- * Comments:
- * ---------
- * This affects only the clientData structures. There is no immediate
- * effect on the actual stacking order on the display. That is done
- * by StackWindow and/or RestackTransients.
- *
- *************************************<->***********************************/
- Boolean BumpPrimaryToBottom (ClientData *pcdLeader)
- {
- Boolean rval;
- if (pcdLeader->primaryStackPosition != 0)
- {
- pcdLeader->primaryStackPosition = 0;
- rval = True;
- }
- else
- {
- rval = False;
- }
- return (rval);
- }
- /*************************************<->*************************************
- *
- * LowestWindowInTransientFamily (pcdLeader)
- *
- *
- * Description:
- * -----------
- * This function returns the lowest stacked window in a transient
- * tree family.
- *
- * Inputs:
- * ------
- * pcdLeader = pointer to client data of leader of a transient tree
- *
- * Returns: id of lowest window in the transient tree for this family
- *
- *************************************<->***********************************/
- Window
- LowestWindowInTransientFamily (ClientData *pcdLeader)
- {
- int count;
- static int size = 0;
- static Window *windows = NULL;
- Window wReturn = None;
- /*
- * Build a window list
- */
- count = CountTransientChildren (pcdLeader);
- if (count > size)
- {
- /*
- * Expand the (static) windows buffer
- */
- if (!(windows =
- (Window *)WmMalloc ((char*)windows, (count + 5) * sizeof (Window))))
- {
- /* cannot get memory space */
- size = 0;
- return None;
- }
- size = count + 5;
- }
- MakeTransientFamilyStackingList (windows, pcdLeader);
- if (count > 0)
- {
- wReturn = windows[count-1];
- }
- else
- {
- wReturn = None;
- }
- return (wReturn);
- } /* END OF FUNCTION LowestWindowInTransientFamily */
- /*************************************<->*************************************
- *
- * FindSubLeaderToTop (pcd)
- *
- *
- * Description:
- * -----------
- * This function identifies a candidate window to top within the
- * transient tree that is a local transient leader (the window has
- * transients hanging off of it, too).
- *
- *
- * Inputs:
- * ------
- * pcd = pointer to client data of a transient leader window
- *
- * Return: ptr to client data for client that should be topped, or NULL
- *
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- ClientData *
- FindSubLeaderToTop (
- ClientData *pcd)
- {
- ClientData *pcdRet = NULL;
- ClientData *pcdNext;
- pcdNext = pcd->transientChildren;
- while (pcdNext && (!pcdRet))
- {
- if (pcdNext->transientChildren)
- {
- if (LeaderOnTop (pcdNext))
- {
- pcdRet = pcdNext;
- }
- else
- {
- pcdRet = FindSubLeaderToTop (pcdNext);
- }
- }
- pcdNext = pcdNext->transientSiblings;
- }
- return (pcdRet);
- }
- /*************************************<->*************************************
- *
- * MakeTransientFamilyStackingList (windows, pcdLeader)
- *
- *
- * Description:
- * -----------
- * This function makes a transient window list of windows in the
- * transient window tree headed by the specified client.
- *
- *
- * Inputs:
- * ------
- * windows = pointer to the windows list to be filled out
- *
- * pcdLeader = pointer to client data of a window in a transient tree
- *
- * Outputs:
- * -------
- * The windows array is modified.
- *
- * Comments:
- * --------
- * This function puts the transient leader window in the list in the
- * right place.
- *
- *************************************<->***********************************/
- void
- MakeTransientFamilyStackingList (
- Window *windows,
- ClientData *pcdLeader)
- {
- ClientData *pcdSub;
- Window *nextWindow, wSave, wTemp, wTop;
- int count = CountTransientChildren (pcdLeader);
- int i, j;
- /*
- * Construct the transient stacking list according to
- * normal Motif rules.
- */
- nextWindow = MakeTransientWindowList (windows, pcdLeader);
- if (!(pcdLeader->secondariesOnTop))
- {
- /*
- * If the leader window shouldn't be on the bottom , then
- * adjust the stacking of the list.
- */
- if ((pcdLeader->primaryStackPosition > 0) &&
- (pcdLeader->primaryStackPosition < count))
- {
- for (i=0; i<pcdLeader->primaryStackPosition; i++)
- {
- j = count - i - 1;
- windows[j] = windows[j-1];
- }
- j = count - pcdLeader->primaryStackPosition - 1;
- windows[j] = pcdLeader->clientFrameWin;
- }
- else
- {
- /*
- * Put the leader at the bottom.
- */
- *nextWindow = pcdLeader->clientFrameWin;
- /*
- * If one of the transients is also a local leader
- * and wants to be on top, then adjust the list.
- */
- pcdSub = FindSubLeaderToTop (pcdLeader);
- if (pcdSub && (pcdSub->clientFrameWin != None))
- {
- /* insert this window at top */
- wTop = wSave = pcdSub->clientFrameWin;
- /* shuffle the rest down */
- for (i=0; i<count; i++)
- {
- wTemp = windows[i];
- windows[i] = wSave;
- wSave = wTemp;
- if (wTop == wSave)
- break;
- }
- }
- }
- }
- else
- {
- /*
- * Put the leader at the bottom.
- */
- *nextWindow = pcdLeader->clientFrameWin;
- }
- } /* END OF FUNCTION MakeTransientFamilyStackingList */
- /*************************************<->*************************************
- *
- * NormalizeTransientTreeStacking (pcdLeader)
- *
- *
- * Description:
- * -----------
- * This function traverses the transient tree and cleans up any
- * local primary windows that are above their respective secondary
- * windows.
- *
- *
- * Inputs:
- * ------
- * pcdLeader = pointer to client data of a transient tree leader
- *
- * Return: True if any changes in stacking order were made
- *
- *
- * Comments:
- * --------
- * This only touches the data structures.
- *
- *************************************<->***********************************/
- Boolean
- NormalizeTransientTreeStacking (
- ClientData *pcdLeader)
- {
- ClientData *pcdNext;
- Boolean bChanged = False;
- pcdNext = pcdLeader->transientChildren;
- bChanged = BumpPrimaryToBottom (pcdLeader);
- while (pcdNext)
- {
- if (pcdNext->transientChildren)
- {
- bChanged |= BumpPrimaryToBottom (pcdNext);
- bChanged |= NormalizeTransientTreeStacking (pcdNext);
- }
- pcdNext = pcdNext->transientSiblings;
- }
- return (bChanged);
- }
- /*************************************<->*************************************
- *
- * LeaderOnTop (pcdLeader)
- *
- *
- * Description:
- * -----------
- * This function tests a leader of a transient (sub) tree to see if
- * it should be on top of its transient windows.
- *
- *
- * Inputs:
- * ------
- * pcdLeader = pointer to client data of a transient tree leader
- *
- * Return: True if this leader is on top of its transients
- *
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- Boolean
- LeaderOnTop (
- ClientData *pcdLeader)
- {
- Boolean bOnTop = False;
- int count = CountTransientChildren (pcdLeader);
- if ((pcdLeader->primaryStackPosition > 0) &&
- (pcdLeader->primaryStackPosition < count))
- {
- bOnTop = True;
- }
- return (bOnTop);
- }
|