WmFunction.c 105 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /*
  24. * (c) Copyright 1989, 1990, 1991, 1992, 1993, 1994 OPEN SOFTWARE FOUNDATION, INC.
  25. * ALL RIGHTS RESERVED
  26. */
  27. /*
  28. * Motif Release 1.2.4
  29. */
  30. /*
  31. * (c) Copyright 1987, 1988, 1989, 1990, 1993, 1994 HEWLETT-PACKARD COMPANY
  32. * (c) Copyright 1993, 1994 International Business Machines Corp.
  33. * (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  34. * (c) Copyright 1993, 1994 Novell, Inc.
  35. */
  36. /*
  37. * Included Files:
  38. */
  39. #include "WmGlobal.h"
  40. #include <stdio.h>
  41. #include <X11/Xos.h>
  42. #include "WmICCC.h"
  43. #include "WmWrkspace.h" /* for ClientInWorkspace() test */
  44. #include <Dt/EnvControlP.h> /* for restoring **environ before an exec() */
  45. #include "WmResNames.h"
  46. #include <Dt/Message.h>
  47. #include <Dt/Help.h>
  48. #include <Dt/DtStrDefs.h>
  49. #include "WmPanelP.h"
  50. #include "WmSignal.h"
  51. #include "WmManage.h"
  52. /*
  53. * include extern functions
  54. */
  55. #include "WmFunction.h"
  56. #include "WmCEvent.h"
  57. #include "WmHelp.h"
  58. #include "WmCDInfo.h"
  59. #include "WmColormap.h"
  60. #include "WmError.h"
  61. #include "WmEvent.h"
  62. #include "WmFeedback.h"
  63. #include "WmIPC.h"
  64. #include "WmIPlace.h"
  65. #include "WmIconBox.h"
  66. #include "WmKeyFocus.h"
  67. #include "WmMenu.h"
  68. #include "WmPresence.h"
  69. #include "WmProperty.h"
  70. #include "WmProtocol.h"
  71. #include "WmResParse.h"
  72. #include "WmWinConf.h"
  73. #include "WmWinInfo.h"
  74. #include "WmWinList.h"
  75. #include "WmWinState.h"
  76. #include "WmXSMP.h"
  77. #include <Xm/RowColumnP.h> /* for MS_LastManagedMenuTime */
  78. extern XmMenuState _XmGetMenuState();
  79. extern int putenv ();
  80. extern char * getenv ();
  81. #ifndef PORT_NOVFORK
  82. extern pid_t vfork();
  83. #endif /* PORT_NOVFORK */
  84. static unsigned int GetEventInverseMask(XEvent *event);
  85. #if (defined(__linux__) || defined(sun) || defined(CSRG_BASED)) && !defined(_NFILE)
  86. #define _NFILE FOPEN_MAX
  87. #endif
  88. #define CLOSE_FILES_ON_EXEC() \
  89. {int ifx; for (ifx=3; ifx < _NFILE; ifx++) (void) fcntl (ifx, F_SETFD, 1);}
  90. /*
  91. * Global Variables:
  92. */
  93. /*
  94. * The 'dirty' variables are used to keep track of the transient window
  95. * that has been lowered via "f.lower freeFamily".
  96. */
  97. static ClientData *dirtyStackEntry = NULL;
  98. static ClientData *dirtyLeader = NULL;
  99. /***********************<->*************************************
  100. *
  101. * F_Action (args, pCD, event)
  102. *
  103. *
  104. * Description:
  105. * -----------
  106. * This is the window manager function handler for invoking actions.
  107. *
  108. *
  109. * Inputs:
  110. * ------
  111. * args = action function and arguments
  112. *
  113. * pCD = pointer to the ClientData for the whole front panel
  114. *
  115. * event = X event that invoked the function (key, button, or menu/NULL)
  116. *
  117. *
  118. * Outputs:
  119. * -------
  120. * RETURN = if True then further button binding/function processing can
  121. * be done for the event that caused this function to be called.
  122. *
  123. * Comments:
  124. * -------
  125. * The pCD->controlWindow is a temporary area used solely for
  126. * this function invocation--it stores the pCW of the control
  127. * that want the function to happen.
  128. ******************************<->***********************************/
  129. Boolean
  130. F_Action (String actionName, ClientData *pCD, XEvent *event)
  131. {
  132. WmActionArg *pAP = (WmActionArg *) actionName;
  133. /* make sure the command runs on the right display. */
  134. if (wmGD.pActiveSD->displayString)
  135. {
  136. putenv(wmGD.pActiveSD->displayString);
  137. }
  138. if (wmGD.dtSD)
  139. {
  140. WmFrontPanelSetBusy (True);
  141. }
  142. DtActionInvoke (wmGD.pActiveSD->screenTopLevelW1,
  143. pAP->actionName, pAP->aap, pAP->numArgs,
  144. pAP->szExecParms, NULL, NULL, 1, NULL, NULL);
  145. /*
  146. * Restore original DISPLAY environment variable
  147. */
  148. if(wmGD.pActiveSD->displayString && wmGD.displayString)
  149. {
  150. putenv(wmGD.displayString);
  151. }
  152. return (True);
  153. } /* END OF FUNCTION F_Action */
  154. /******************************<->*************************************
  155. *
  156. * F_Beep (args, pCD, event)
  157. *
  158. *
  159. * Description:
  160. * -----------
  161. * This is the window manager function handler for beeping.
  162. *
  163. *
  164. * Inputs:
  165. * ------
  166. * args = function arguments (specified in .mwmrc file)
  167. *
  168. * pCD = pointer to the client data for the client window to which the
  169. * function is to be applied
  170. *
  171. * event = X event that invoked the function (key, button, or menu/NULL)
  172. *
  173. *
  174. * Outputs:
  175. * -------
  176. * RETURN = if True then further button binding/function processing can
  177. * be done for the event that caused this function to be called.
  178. *
  179. ******************************<->***********************************/
  180. Boolean F_Beep (String args, ClientData *pCD, XEvent *event)
  181. {
  182. /* !!! what is a good value for percent (the second arg) !!! */
  183. XBell (DISPLAY, 0);
  184. return (True);
  185. } /* END OF FUNCTION F_Beep */
  186. /*
  187. * Handle Special case where the dirty window is the top most
  188. * transient window. When this is the case, raising the window
  189. * that was on top (the window just below the dirty window) will
  190. * fail because Mwm stack database is out of sync. So the solution
  191. * is to restack the dirty transient relative to the second to the
  192. * top transient. This function is used to support freeFamily stacking.
  193. */
  194. ClientData * FindSecondToTopTransient (ClientData *pcd)
  195. {
  196. ClientData *pcdNext;
  197. static ClientData *second;
  198. pcdNext = pcd->transientChildren;
  199. while (pcdNext)
  200. {
  201. if (pcdNext->transientChildren)
  202. {
  203. if (!pcdNext->transientChildren->transientChildren)
  204. {
  205. second = pcdNext;
  206. }
  207. FindSecondToTopTransient (pcdNext);
  208. }
  209. pcdNext = pcdNext->transientSiblings;
  210. if (pcdNext && !pcdNext->transientSiblings)
  211. {
  212. second = pcdNext;
  213. }
  214. }
  215. return (second);
  216. } /* END OF FUNCTION */
  217. Boolean ForceLowerWindow (ClientData *pcd)
  218. {
  219. #if 0
  220. Window stackWindow;
  221. WmScreenData *pSD = (ACTIVE_WS)->pSD;
  222. #endif
  223. XWindowChanges changes;
  224. Boolean restack = False;
  225. Window stackWindow;
  226. WmScreenData *pSD = (ACTIVE_WS)->pSD;
  227. unsigned int mask;
  228. ClientListEntry *pCLE;
  229. /*
  230. * Find lowest window in this workspace. We'll stack this transient
  231. * below it.
  232. */
  233. pCLE = pSD->lastClient;
  234. stackWindow = None;
  235. mask = CWStackMode;
  236. while (pCLE != NULL)
  237. {
  238. if ((pCLE->pCD != pcd) &&
  239. (ClientInWorkspace (ACTIVE_WS, pCLE->pCD)))
  240. {
  241. if ((pCLE->type == MINIMIZED_STATE) &&
  242. (pCLE->pCD->clientState == MINIMIZED_STATE))
  243. {
  244. stackWindow = ICON_FRAME_WIN(pCLE->pCD);
  245. }
  246. else if ((pCLE->type == NORMAL_STATE) &&
  247. ((pCLE->pCD->clientState == NORMAL_STATE) ||
  248. (pCLE->pCD->clientState == MAXIMIZED_STATE)))
  249. {
  250. stackWindow = pCLE->pCD->clientFrameWin;
  251. }
  252. if (stackWindow != None)
  253. {
  254. mask |= CWSibling;
  255. changes.sibling = stackWindow;
  256. break;
  257. }
  258. }
  259. if (stackWindow == None)
  260. {
  261. pCLE = pCLE->prevSibling;
  262. }
  263. }
  264. #if 0
  265. if (pSD->lastClient->type == MINIMIZED_STATE)
  266. {
  267. stackWindow = ICON_FRAME_WIN(pSD->lastClient->pCD);
  268. }
  269. else
  270. {
  271. stackWindow = pSD->lastClient->pCD->clientFrameWin;
  272. }
  273. #endif
  274. changes.stack_mode = Below;
  275. if (mask)
  276. {
  277. XConfigureWindow (DISPLAY, pcd->clientFrameWin, mask, &changes);
  278. }
  279. return (restack);
  280. }
  281. /*************************************<->*************************************
  282. *
  283. * F_Lower (args, pCD, event)
  284. *
  285. *
  286. * Description:
  287. * -----------
  288. * This is the window manager function handler for bottoming a client window
  289. * or icon.
  290. *
  291. *
  292. * Inputs:
  293. * ------
  294. * args = function arguments (specified in .mwmrc file)
  295. *
  296. * pCD = pointer to the client data for the client window to which the
  297. * function is to be applied
  298. *
  299. * event = X event that invoked the function (key, button, or menu/NULL)
  300. *
  301. *
  302. * Outputs:
  303. * -------
  304. * RETURN = if True then further button binding/function processing can
  305. * be done for the event that caused this function to be called.
  306. *
  307. *************************************<->***********************************/
  308. Boolean F_Lower (String args, ClientData *pCD, XEvent *event)
  309. {
  310. ClientListEntry *pEntry;
  311. ClientListEntry *pNextEntry;
  312. ClientListEntry *pStackEntry;
  313. String string = args;
  314. int flags = STACK_NORMAL;
  315. WmWorkspaceData *pWS = ACTIVE_WS;
  316. if (string)
  317. {
  318. /* process '-client' argument */
  319. if (string[0] == '-')
  320. {
  321. string = &string[1];
  322. string = (String) GetString ((unsigned char **) &string);
  323. pStackEntry = NULL;
  324. pNextEntry = ACTIVE_PSD->lastClient;
  325. while (pNextEntry &&
  326. (pEntry = FindClientNameMatch (pNextEntry, False,
  327. string, F_GROUP_ALL)))
  328. {
  329. pNextEntry = pEntry->prevSibling;
  330. if (ClientInWorkspace (pWS, pEntry->pCD))
  331. {
  332. Do_Lower (pEntry->pCD, pStackEntry, STACK_NORMAL);
  333. pStackEntry = pEntry;
  334. }
  335. }
  336. }
  337. /* process family stacking stuff */
  338. else if (*string)
  339. {
  340. unsigned int slen, len, index;
  341. slen = strlen(args) - 2; /* subtract '\n' and NULL */
  342. for (index = 0; index < slen; string = &args[index+1])
  343. {
  344. if ((string = (String) GetString ((unsigned char **) &string)) == NULL)
  345. break;
  346. len = strlen(string);
  347. if (!strcmp(string,"within"))
  348. {
  349. flags |= STACK_WITHIN_FAMILY;
  350. }
  351. else if (!strcmp(string,"freeFamily"))
  352. {
  353. flags |= STACK_FREE_FAMILY;
  354. }
  355. index += len;
  356. }
  357. if (ClientInWorkspace (pWS, pCD))
  358. {
  359. Do_Lower (pCD, (ClientListEntry *) NULL, flags);
  360. }
  361. }
  362. }
  363. else if (pCD)
  364. {
  365. if (ClientInWorkspace (pWS, pCD))
  366. {
  367. Do_Lower (pCD, (ClientListEntry *) NULL, STACK_NORMAL);
  368. }
  369. }
  370. /*
  371. * If caused by button press, event may ALSO cause focus to be
  372. * passed to this client - prepare to disable focusAutoRaise.
  373. */
  374. if (pCD && event && (event->type == ButtonPress))
  375. pCD->focusAutoRaiseDisablePending = True;
  376. wmGD.passButtonsCheck = False;
  377. return (True);
  378. } /* END OF FUNCTION F_Lower */
  379. /*************************************<->*************************************
  380. *
  381. * Do_Lower (pCD, pStackEntry)
  382. *
  383. *
  384. * Description:
  385. * -----------
  386. * This is the window manager function handler for lowering the client window
  387. * so that it does not obscure any other window above the stack entry
  388. * window.
  389. *
  390. *
  391. * Inputs:
  392. * ------
  393. * pCD = pointer to the client data of the window (or icon) to be lowered.
  394. *
  395. * pStackEntry = pointer to client list entry for window that is to be
  396. * below the lowered window (if NULL, window is lowered to the bottom
  397. * of the stack).
  398. *
  399. *************************************<->***********************************/
  400. void Do_Lower (ClientData *pCD, ClientListEntry *pStackEntry, int flags)
  401. {
  402. Boolean restackTransients;
  403. ClientData *pcdLeader;
  404. WmWorkspaceData *pWS = ACTIVE_WS;
  405. Boolean bLeaderRestacked;
  406. if (pCD->pECD)
  407. {
  408. /*
  409. * Window has been reparented into the front panel.
  410. * Don't follow through on window stacking change.
  411. */
  412. return;
  413. }
  414. else
  415. if (ClientInWorkspace(pWS, pCD) &&
  416. (!pStackEntry || ClientInWorkspace (pWS, pStackEntry->pCD)))
  417. {
  418. /*
  419. * Both clients are in the current workspace. Set
  420. * client indices so that the access macros work.
  421. */
  422. SetClientWsIndex (pCD);
  423. if (pStackEntry)
  424. {
  425. SetClientWsIndex (pStackEntry->pCD);
  426. }
  427. }
  428. else
  429. {
  430. /*
  431. * One or both of the clients are not in the current workspace
  432. * Do nothing.
  433. */
  434. return;
  435. }
  436. pcdLeader = (pCD->transientLeader) ? FindTransientTreeLeader (pCD) : pCD;
  437. if ((pcdLeader->clientState == MINIMIZED_STATE) && !P_ICON_BOX(pcdLeader))
  438. {
  439. /*
  440. * If a dirtyStackEntry exists, return it to its original place
  441. * in the stack (for all stacking types)
  442. */
  443. if (dirtyStackEntry)
  444. {
  445. if (dirtyStackEntry->transientChildren ||
  446. dirtyStackEntry->transientLeader)
  447. RestackTransients (dirtyStackEntry);
  448. dirtyStackEntry = NULL;
  449. dirtyLeader = NULL;
  450. }
  451. /*
  452. * Only restack the icon if it is not currently lowered.
  453. */
  454. if (pStackEntry)
  455. {
  456. if (pStackEntry->prevSibling != &pcdLeader->iconEntry)
  457. {
  458. StackWindow (pWS, &pcdLeader->iconEntry, True /*above*/,
  459. pStackEntry);
  460. MoveEntryInList (pWS, &pcdLeader->iconEntry, True /*above*/,
  461. pStackEntry);
  462. }
  463. }
  464. else
  465. {
  466. if (ACTIVE_PSD->lastClient != &pcdLeader->iconEntry)
  467. {
  468. StackWindow (pWS, &pcdLeader->iconEntry,
  469. False /*on bottom*/, (ClientListEntry *) NULL);
  470. MoveEntryInList (pWS, &pcdLeader->iconEntry,
  471. False /*on bottom*/, (ClientListEntry *) NULL);
  472. }
  473. }
  474. }
  475. else /* NORMAL_STATE, MAXIMIZED_STATE, adoption */
  476. {
  477. /*
  478. * Handle restacking of primary/secondary windows
  479. * within the transient window tree.
  480. */
  481. bLeaderRestacked = False;
  482. if ((pcdLeader->transientChildren) &&
  483. (!pcdLeader->secondariesOnTop) &&
  484. (!wmGD.bSuspendSecondaryRestack))
  485. {
  486. if (pCD == pcdLeader)
  487. {
  488. /*
  489. * Lower requested on the leader itself, insure it's
  490. * at the bottom.
  491. */
  492. bLeaderRestacked = BumpPrimaryToBottom (pcdLeader);
  493. }
  494. else if (pCD->transientChildren)
  495. {
  496. /*
  497. * Lower requested on the leader of a subtree. Insure
  498. * that this subtree leader is at the bottom of the
  499. * subtree.
  500. */
  501. bLeaderRestacked = BumpPrimaryToBottom (pCD);
  502. }
  503. else if (pCD->transientLeader)
  504. {
  505. ClientData *pcdLdr;
  506. /*
  507. * Lower requested on a transient. Insure all the
  508. * subtree leaders up to the top are at the bottom
  509. * of their respective transient subtrees.
  510. */
  511. for (pcdLdr = pCD->transientLeader;
  512. pcdLdr;
  513. pcdLdr = pcdLdr->transientLeader)
  514. {
  515. bLeaderRestacked |= BumpPrimaryToBottom (pcdLdr);
  516. }
  517. }
  518. }
  519. /*
  520. * If this is a transient window then put it below its
  521. * sibling transient windows.
  522. */
  523. restackTransients = False;
  524. if (pCD->transientLeader)
  525. {
  526. /*
  527. * If freeFamily stacking, then put dirty transient window
  528. * (if any) back in place before force lowering current window
  529. * to the bottom of the global window stack. Then return.
  530. */
  531. if (flags & STACK_FREE_FAMILY)
  532. {
  533. /* Restore dirty transient if not current window. */
  534. if ((dirtyStackEntry) &&
  535. (dirtyStackEntry != pCD))
  536. {
  537. RestackTransients (dirtyStackEntry);
  538. }
  539. dirtyStackEntry = pCD;
  540. dirtyLeader = pcdLeader;
  541. ForceLowerWindow (pCD);
  542. return;
  543. }
  544. /*
  545. * Reach here only if NOT doing a f.lower freeFamily (see
  546. * return; statement above). Put current transient below
  547. * its sibling transient windows.
  548. */
  549. restackTransients = PutTransientBelowSiblings (pCD);
  550. }
  551. /*
  552. * If doing a regular f.lower and you have a dirty window, then
  553. * clean up dirty transient window.
  554. */
  555. if (dirtyStackEntry)
  556. {
  557. /*
  558. * If lowering a window in the same family as the dirty
  559. * transient window, then just restack before lowering.
  560. * Else, restore the dirty transient in place before
  561. * lowering the current window. Clear dirtyStack.
  562. */
  563. if (dirtyLeader == pcdLeader)
  564. {
  565. restackTransients = True;
  566. }
  567. else
  568. {
  569. RestackTransients (dirtyStackEntry);
  570. }
  571. dirtyStackEntry = NULL;
  572. }
  573. /*
  574. * Only restack the window or transient window tree if it is
  575. * not currently lowered and the window is not a system
  576. * modal window.
  577. */
  578. if (pStackEntry)
  579. {
  580. if ((pStackEntry->prevSibling != &pcdLeader->clientEntry) &&
  581. !(wmGD.systemModalActive &&
  582. (pcdLeader == wmGD.systemModalClient)))
  583. {
  584. StackWindow (pWS, &pcdLeader->clientEntry, True /*above*/,
  585. pStackEntry);
  586. MoveEntryInList (pWS, &pcdLeader->clientEntry, True /*above*/,
  587. pStackEntry);
  588. }
  589. else if ((restackTransients) || (bLeaderRestacked))
  590. {
  591. RestackTransients (pCD);
  592. }
  593. }
  594. else
  595. {
  596. if ((pWS->pSD->lastClient != &pcdLeader->clientEntry) &&
  597. !(wmGD.systemModalActive &&
  598. (pcdLeader == wmGD.systemModalClient)) &&
  599. !(flags & STACK_WITHIN_FAMILY))
  600. {
  601. StackWindow (pWS, &pcdLeader->clientEntry, False /*on bottom*/,
  602. (ClientListEntry *) NULL);
  603. MoveEntryInList (pWS, &pcdLeader->clientEntry,
  604. False /*on bottom*/, (ClientListEntry *) NULL);
  605. }
  606. else if ((restackTransients) || (bLeaderRestacked))
  607. {
  608. RestackTransients (pCD);
  609. }
  610. }
  611. }
  612. } /* END OF FUNCTION Do_Lower */
  613. /*************************************<->*************************************
  614. *
  615. * F_CircleDown (args, pCD, event)
  616. *
  617. *
  618. * Description:
  619. * -----------
  620. * This is the window manager function handler for moving the client window
  621. * on top of stack to the bottom.
  622. *
  623. *
  624. * Inputs:
  625. * ------
  626. * args = function arguments (specified in .mwmrc file)
  627. *
  628. * pCD = pointer to the client data for the client window to which the
  629. * function is to be applied
  630. *
  631. * event = X event that invoked the function (key, button, or menu/NULL)
  632. *
  633. *
  634. * Outputs:
  635. * -------
  636. * RETURN = if True then further button binding/function processing can
  637. * be done for the event that caused this function to be called.
  638. *
  639. *************************************<->***********************************/
  640. Boolean F_Circle_Down (String args, ClientData *pCD, XEvent *event)
  641. {
  642. unsigned long types;
  643. unsigned long windowType;
  644. ClientListEntry *pNextEntry;
  645. ClientData *pcdNext;
  646. /*
  647. * Go down through the client list looking for a window of an
  648. * appropriate type that is obscuring lower windows.
  649. */
  650. types = (unsigned long)args;
  651. pNextEntry = ACTIVE_PSD->clientList;
  652. while (pNextEntry)
  653. {
  654. /*
  655. * Only check out the window if it is onscreen.
  656. */
  657. pcdNext = pNextEntry->pCD;
  658. if (((pNextEntry->type == NORMAL_STATE) &&
  659. (pcdNext->clientState != MINIMIZED_STATE)) ||
  660. ((pNextEntry->type == MINIMIZED_STATE) &&
  661. (pcdNext->clientState == MINIMIZED_STATE)))
  662. {
  663. if (pcdNext->clientState == MINIMIZED_STATE)
  664. {
  665. windowType = F_GROUP_ICON;
  666. }
  667. else
  668. {
  669. windowType = F_GROUP_WINDOW;
  670. if (pcdNext->transientLeader || pcdNext->transientChildren)
  671. {
  672. windowType |= F_GROUP_TRANSIENT;
  673. }
  674. }
  675. if (types & windowType)
  676. {
  677. if (CheckIfClientObscuringAny (pcdNext))
  678. {
  679. /*
  680. * This window (or window tree) is obscuring another window
  681. * on the screen. Lower the window.
  682. */
  683. wmGD.bSuspendSecondaryRestack = True;
  684. F_Lower (NULL, pcdNext, (XEvent *) NULL);
  685. wmGD.bSuspendSecondaryRestack = False;
  686. break;
  687. }
  688. }
  689. }
  690. pNextEntry = pNextEntry->nextSibling;
  691. }
  692. return (True);
  693. } /* END OF FUNCTION F_Circle_Down */
  694. /*************************************<->*************************************
  695. *
  696. * F_Circle_Up (args, pCD, event)
  697. *
  698. *
  699. * Description:
  700. * -----------
  701. * This is the window manager function handler for moving the client window
  702. * on the bottom of the stack to the top.
  703. *
  704. *
  705. * Inputs:
  706. * ------
  707. * args = function arguments (specified in .mwmrc file)
  708. *
  709. * pCD = pointer to the client data for the client window to which the
  710. * function is to be applied
  711. *
  712. * event = X event that invoked the function (key, button, or menu/NULL)
  713. *
  714. *
  715. * Outputs:
  716. * -------
  717. * RETURN = if True then further button binding/function processing can
  718. * be done for the event that caused this function to be called.
  719. *
  720. *************************************<->***********************************/
  721. Boolean F_Circle_Up (String args, ClientData *pCD, XEvent *event)
  722. {
  723. unsigned long types;
  724. unsigned long windowType;
  725. ClientListEntry *pNextEntry;
  726. ClientData *pcdNext;
  727. /*
  728. * Go up through the client list looking for a window of an
  729. * appropriate type that is obscured by higher windows.
  730. */
  731. types = (unsigned long)args;
  732. pNextEntry = ACTIVE_PSD->lastClient;
  733. while (pNextEntry)
  734. {
  735. /*
  736. * Only check out the window if it is onscreen.
  737. */
  738. pcdNext = pNextEntry->pCD;
  739. if (((pNextEntry->type == NORMAL_STATE) &&
  740. (pcdNext->clientState != MINIMIZED_STATE)) ||
  741. ((pNextEntry->type == MINIMIZED_STATE) &&
  742. (pcdNext->clientState == MINIMIZED_STATE)))
  743. {
  744. if (pcdNext->clientState == MINIMIZED_STATE)
  745. {
  746. windowType = F_GROUP_ICON;
  747. }
  748. else
  749. {
  750. windowType = F_GROUP_WINDOW;
  751. if (pcdNext->transientLeader || pcdNext->transientChildren)
  752. {
  753. windowType |= F_GROUP_TRANSIENT;
  754. }
  755. }
  756. if (types & windowType)
  757. {
  758. if (CheckIfClientObscuredByAny (pcdNext))
  759. {
  760. /*
  761. * This window (or window tree) is obscured by another
  762. * window on the screen. Raise the window.
  763. */
  764. wmGD.bSuspendSecondaryRestack = True;
  765. F_Raise (NULL, pcdNext, (XEvent *) NULL);
  766. wmGD.bSuspendSecondaryRestack = False;
  767. break;
  768. }
  769. }
  770. }
  771. pNextEntry = pNextEntry->prevSibling;
  772. }
  773. return (True);
  774. } /* END OF FUNCTION F_Circle_Up */
  775. /*************************************<->*************************************
  776. *
  777. * F_Focus_Color (args, pCD, event)
  778. *
  779. *
  780. * Description:
  781. * -----------
  782. * This is the window manager function handler for setting the colormap
  783. * focus to a client window or reinstalling the default colormap.
  784. *
  785. *************************************<->***********************************/
  786. Boolean F_Focus_Color (String args, ClientData *pCD, XEvent *event)
  787. {
  788. if (wmGD.colormapFocusPolicy == CMAP_FOCUS_EXPLICIT)
  789. {
  790. if (pCD)
  791. {
  792. /*
  793. * The window selected for the colormap focus is a top-level client
  794. * window. If there are subwindow colormaps then determine if the
  795. * selection was in one of the subwindows.
  796. */
  797. if (pCD->clientState == MINIMIZED_STATE)
  798. {
  799. /* !!! colormap for client supplied icon window !!! */
  800. pCD = NULL;
  801. }
  802. }
  803. SetColormapFocus (ACTIVE_PSD, pCD);
  804. }
  805. return (True);
  806. } /* END OF FUNCTION F_Focus_Color */
  807. /*************************************<->*************************************
  808. *
  809. * F_Exec (args, pCD, event)
  810. *
  811. *
  812. * Description:
  813. * -----------
  814. * This is the window manager function handler for executing a command
  815. * (with /bin/sh).
  816. *
  817. *************************************<->***********************************/
  818. Boolean F_Exec (String args, ClientData *pCD, XEvent *event)
  819. {
  820. int pid;
  821. char *shell;
  822. char *shellname;
  823. /* make sure the f.exec command runs on the right display. */
  824. if (wmGD.pActiveSD->displayString)
  825. {
  826. putenv(wmGD.pActiveSD->displayString);
  827. }
  828. if (wmGD.dtSD)
  829. {
  830. /*
  831. * Start the busy indicator, waiting for a pushbutton window
  832. * for the given duration
  833. */
  834. WmFrontPanelSetBusy (True);
  835. }
  836. /*
  837. * Fork a process to exec a shell to run the specified command:
  838. */
  839. #ifdef PORT_NOVFORK
  840. if ((pid = fork ()) == 0)
  841. #else
  842. if ((pid = vfork ()) == 0)
  843. #endif
  844. {
  845. #if defined(SVR4) || defined(__linux__)
  846. setsid();
  847. #else
  848. #ifdef SYSV
  849. setpgrp();
  850. #else
  851. int tpid;
  852. tpid = getpid();
  853. setpgrp(tpid, tpid);
  854. #endif /* SYSV */
  855. #endif /* SVR4 */
  856. /*
  857. * Clean up window manager resources.
  858. * The X file descriptor should be automatically closed.
  859. */
  860. /*
  861. * Fix up signal handling.
  862. */
  863. RestoreDefaultSignalHandlers ();
  864. /*
  865. * Fix up the child application's environment NOT to
  866. * inherit the XFILESEARCHPATH, XBMLANGPATH, NLSPATH, etc.
  867. * used by dtwm.
  868. */
  869. _DtEnvControl(DT_ENV_RESTORE_PRE_DT);
  870. CLOSE_FILES_ON_EXEC();
  871. /*
  872. * Exec the command using $MWMSHELL if set or
  873. * $SHELL if set and $MWMSHELL not set or sh.
  874. */
  875. if (((shell = getenv ("MWMSHELL")) != NULL) ||
  876. ((shell = getenv ("SHELL")) != NULL))
  877. {
  878. shellname = strrchr (shell, '/');
  879. if (shellname == NULL)
  880. {
  881. /*
  882. If the shell pathname obtained from SHELL or MWMSHELL does not
  883. have a "/" in the path and if the user expects this shell to be
  884. obtained using the PATH variable rather than the current
  885. directory, then we must call execlp and not execl
  886. */
  887. shellname = shell;
  888. execlp (shell, shellname, "-c", args, NULL);
  889. }
  890. else
  891. {
  892. shellname++;
  893. execl (shell, shellname, "-c", args, NULL);
  894. }
  895. }
  896. /*
  897. * There is no SHELL environment variable or the first execl failed.
  898. * Try /bin/sh .
  899. */
  900. #ifdef SVR4
  901. execl ("/usr/bin/sh", "sh", "-c", args, NULL);
  902. #else
  903. execl ("/bin/sh", "sh", "-c", args, NULL);
  904. #endif
  905. /*
  906. * Error - command could not be exec'ed.
  907. */
  908. _exit (127);
  909. }
  910. else if (pid == -1)
  911. return(True);
  912. /*
  913. * Have the window manager wait for the shell to complete.
  914. */
  915. /*
  916. * Don't need to wait because WSM sets SIGCLD handler
  917. */
  918. /*
  919. * Restore original DISPLAY environment variable value
  920. * so a restart will start on the same screen
  921. */
  922. if(wmGD.pActiveSD->displayString &&
  923. wmGD.displayString)
  924. {
  925. putenv(wmGD.displayString);
  926. }
  927. return (True);
  928. } /* END OF FUNCTION F_Exec */
  929. /*************************************<->*************************************
  930. *
  931. * F_Quit_Mwm (args, pCD, event)
  932. *
  933. *
  934. * Description:
  935. * -----------
  936. * This is the window manager function handler for terminating the window
  937. * manager.
  938. *
  939. *************************************<->***********************************/
  940. Boolean F_Quit_Mwm (String args, ClientData *pCD, XEvent *event)
  941. {
  942. if (wmGD.showFeedback & WM_SHOW_FB_QUIT)
  943. {
  944. ConfirmAction (ACTIVE_PSD, QUIT_MWM_ACTION);
  945. }
  946. else
  947. {
  948. Do_Quit_Mwm(False);
  949. }
  950. return (False);
  951. } /* END OF FUNCTION F_Quit_Mwm */
  952. /*************************************<->*************************************
  953. *
  954. * Do_Quit_Mwm (diedOnRestart)
  955. *
  956. *
  957. * Description:
  958. * -----------
  959. * Callback to do the f.quit_mwm function.
  960. *
  961. *************************************<->***********************************/
  962. void Do_Quit_Mwm (Boolean diedOnRestart)
  963. {
  964. int scr;
  965. ClientListEntry *pNextEntry;
  966. /*
  967. * Close the X connection to get all the X resources cleaned up.
  968. * !!! maybe windows should be reparented / rebordered before closing? !!!
  969. * !!! clean up the _MOTIF_WM_INFO property on the root window !!!
  970. */
  971. if (DISPLAY)
  972. {
  973. XSetInputFocus(DISPLAY, PointerRoot, RevertToPointerRoot, CurrentTime);
  974. for (scr = 0; scr < wmGD.numScreens; scr++)
  975. {
  976. if (wmGD.Screens[scr].managed)
  977. {
  978. SaveResources(&wmGD.Screens[scr]);
  979. pNextEntry = wmGD.Screens[scr].lastClient;
  980. while (pNextEntry)
  981. {
  982. if (pNextEntry->type == NORMAL_STATE)
  983. {
  984. if (!(pNextEntry->pCD->clientFlags &
  985. CLIENT_WM_CLIENTS))
  986. {
  987. ReBorderClient (pNextEntry->pCD, diedOnRestart);
  988. }
  989. }
  990. pNextEntry = pNextEntry->prevSibling;
  991. }
  992. UnParentControls (&wmGD.Screens[scr], False);
  993. }
  994. }
  995. /* shut down the messaging connection */
  996. dtCloseIPC();
  997. ResignFromSM();
  998. XSync (DISPLAY, False);
  999. XCloseDisplay (DISPLAY);
  1000. }
  1001. if(diedOnRestart)
  1002. {
  1003. exit (WM_ERROR_EXIT_VALUE);
  1004. }
  1005. else
  1006. {
  1007. exit (0);
  1008. }
  1009. } /* END OF FUNCTION Do_Quit_Mwm */
  1010. /*************************************<->*************************************
  1011. *
  1012. * ReBorderClient (pCD, reMapClient)
  1013. *
  1014. *
  1015. * Description:
  1016. * -----------
  1017. * Restores X border for client window and reparents the
  1018. * window back to the root.
  1019. *
  1020. *
  1021. * Inputs:
  1022. * -------
  1023. * pCD = pointer to the client data for the window to be re-bordered.
  1024. *
  1025. *************************************<->***********************************/
  1026. void ReBorderClient (ClientData *pCD, Boolean reMapClient)
  1027. {
  1028. int x, y;
  1029. int xoff, yoff;
  1030. XWindowChanges windowChanges;
  1031. while (pCD)
  1032. {
  1033. if (pCD->iconWindow && (pCD->clientFlags & ICON_REPARENTED) &&
  1034. (!(reMapClient)))
  1035. {
  1036. XUnmapWindow (DISPLAY, pCD->iconWindow);
  1037. XReparentWindow (DISPLAY, pCD->iconWindow,
  1038. ROOT_FOR_CLIENT(pCD), pCD->pWsList->iconX,
  1039. pCD->pWsList->iconY);
  1040. }
  1041. if (!(reMapClient))
  1042. {
  1043. if (pCD->maxConfig)
  1044. {
  1045. x = pCD->maxX;
  1046. y = pCD->maxY;
  1047. }
  1048. else
  1049. {
  1050. if(wmGD.positionIsFrame)
  1051. {
  1052. CalculateGravityOffset (pCD, &xoff, &yoff);
  1053. x = pCD->clientX - xoff;
  1054. y = pCD->clientY - yoff;
  1055. }
  1056. else
  1057. {
  1058. x = pCD->clientX;
  1059. y = pCD->clientY;
  1060. }
  1061. }
  1062. XUnmapWindow(DISPLAY, pCD->clientFrameWin);
  1063. XReparentWindow (DISPLAY, pCD->client,
  1064. ROOT_FOR_CLIENT(pCD), x, y);
  1065. }
  1066. else
  1067. {
  1068. XMapWindow(wmGD.display, pCD->client);
  1069. }
  1070. if (pCD->transientChildren)
  1071. {
  1072. ReBorderClient (pCD->transientChildren, reMapClient);
  1073. }
  1074. if (!(reMapClient))
  1075. {
  1076. /*
  1077. * restore X border
  1078. */
  1079. windowChanges.x = x;
  1080. windowChanges.y = y;
  1081. windowChanges.border_width = pCD->xBorderWidth;
  1082. XConfigureWindow (DISPLAY, pCD->client,
  1083. CWBorderWidth | CWX | CWY, &windowChanges);
  1084. }
  1085. if (pCD->transientLeader)
  1086. {
  1087. pCD = pCD->transientSiblings;
  1088. }
  1089. else
  1090. {
  1091. pCD = NULL;
  1092. }
  1093. }
  1094. } /* END OF FUNCTION ReBorderClient */
  1095. /*************************************<->*************************************
  1096. *
  1097. * F_Focus_Key (args, pCD, event)
  1098. *
  1099. *
  1100. * Description:
  1101. * -----------
  1102. * This is the window manager function handler for setting the keyboard
  1103. * focus to a particular client window.
  1104. *
  1105. *
  1106. * Inputs:
  1107. * ------
  1108. * args = (immediate value) focus flags
  1109. *
  1110. * pCD = pointer to the client data
  1111. *
  1112. * event = X event that invoked the function (key, button, or menu/NULL)
  1113. *
  1114. *************************************<->***********************************/
  1115. Boolean F_Focus_Key (String args, ClientData *pCD, XEvent *event)
  1116. {
  1117. long focusFlags = (long)args;
  1118. if (pCD && (wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_EXPLICIT))
  1119. {
  1120. Do_Focus_Key (pCD, GetFunctionTimestamp ((XButtonEvent *)event),
  1121. (focusFlags | ALWAYS_SET_FOCUS));
  1122. }
  1123. return (True);
  1124. } /* END OF FUNCTION F_Focus_Key */
  1125. /*************************************<->*************************************
  1126. *
  1127. * FindSomeReasonableClient
  1128. *
  1129. * Description:
  1130. * -----------
  1131. * Find a client, any client to set the focus to, return client or NULL.
  1132. * This code is ripped off from AutoResetKeyFocus().
  1133. *
  1134. *************************************<->***********************************/
  1135. static Window FindSomeReasonableClient(void)
  1136. {
  1137. ClientData *pcdNoFocus=NULL;
  1138. ClientListEntry *pNextEntry;
  1139. ClientData *pCD;
  1140. ClientData *pcdLastFocus = (ClientData *) NULL;
  1141. ClientData *pcdFocus;
  1142. Window focusWindow = (Window) NULL;
  1143. /*
  1144. * Scan through the list of clients to find a window to get the focus.
  1145. */
  1146. pNextEntry = ACTIVE_PSD->clientList;
  1147. while (pNextEntry)
  1148. {
  1149. pCD = pNextEntry->pCD;
  1150. if (!wmGD.systemModalActive ||
  1151. (wmGD.systemModalClient == pCD))
  1152. {
  1153. if ((pNextEntry->type != MINIMIZED_STATE) &&
  1154. (pCD->clientState != MINIMIZED_STATE) &&
  1155. (ClientInWorkspace (ACTIVE_WS, pCD)) &&
  1156. (pCD != pcdNoFocus))
  1157. {
  1158. if (pCD->transientChildren)
  1159. {
  1160. pcdFocus = FindLastTransientTreeFocus (pCD, pcdNoFocus);
  1161. }
  1162. else
  1163. {
  1164. pcdFocus = pCD;
  1165. }
  1166. if (pcdFocus &&
  1167. ((pcdLastFocus == NULL) ||
  1168. (pcdFocus->focusPriority > pcdLastFocus->focusPriority)))
  1169. {
  1170. pcdLastFocus = pcdFocus;
  1171. }
  1172. }
  1173. }
  1174. pNextEntry = pNextEntry->nextSibling;
  1175. }
  1176. /*
  1177. * Set the focus window if one is found
  1178. */
  1179. if (pcdLastFocus &&
  1180. ClientInWorkspace (ACTIVE_WS, pcdLastFocus))
  1181. focusWindow = pcdLastFocus->client;
  1182. /*
  1183. * If a client window could not be found, then just put focus
  1184. * on any icon.
  1185. */
  1186. if (focusWindow == (Window) NULL)
  1187. {
  1188. pNextEntry = ACTIVE_PSD->clientList;
  1189. while (pNextEntry)
  1190. {
  1191. pCD = pNextEntry->pCD;
  1192. if (ClientInWorkspace (ACTIVE_WS, pCD))
  1193. {
  1194. if ((pNextEntry->type == MINIMIZED_STATE) ||
  1195. (pCD->clientState == MINIMIZED_STATE))
  1196. {
  1197. focusWindow = ICON_FRAME_WIN(pCD);
  1198. break;
  1199. }
  1200. }
  1201. pNextEntry = pNextEntry->nextSibling;
  1202. }
  1203. }
  1204. return (focusWindow);
  1205. } /* END OF FUNCTION FindSomeReasonableClient */
  1206. /*************************************<->*************************************
  1207. *
  1208. * Do_Focus_Key (pCD, focusTime, flags)
  1209. *
  1210. *
  1211. * Description:
  1212. * -----------
  1213. * This function is used to set the focus to a window. The focus indication
  1214. * is not changed until the FocusIn event is received.
  1215. *
  1216. *
  1217. * Inputs:
  1218. * ------
  1219. * pCD = pointer to the client data
  1220. *
  1221. * focusTime = focus change time
  1222. *
  1223. * flags = wm focus change flags
  1224. *
  1225. *************************************<->***********************************/
  1226. void Do_Focus_Key (ClientData *pCD, Time focusTime, long flags)
  1227. {
  1228. ClientData *pcdFocus;
  1229. Window focusWindow;
  1230. /* Clear the replay flag */
  1231. wmGD.replayEnterEvent = False;
  1232. pcdFocus = pCD;
  1233. /*
  1234. * Make sure the client is in the current workspace
  1235. */
  1236. if ((pCD) &&
  1237. (ClientInWorkspace (ACTIVE_WS, pCD)))
  1238. {
  1239. if (pCD->clientState == MINIMIZED_STATE)
  1240. {
  1241. focusWindow = ICON_FRAME_WIN(pCD);
  1242. }
  1243. else if (wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_EXPLICIT)
  1244. {
  1245. /*
  1246. * Set the keyboard focus to the indicated client window.
  1247. * If the window has an application modal subordinate then
  1248. * set the input focus to that window if the focus isn't
  1249. * already owned by a subordinate.
  1250. */
  1251. if (IS_APP_MODALIZED(pCD))
  1252. {
  1253. ClientData *pcdFocusLeader,*currFocusLeader;
  1254. /*
  1255. * Handle case where a modal window exists when Mwm starts up.
  1256. * wmGD.keyboardFocus is NULL, give focus to the modal dialog.
  1257. */
  1258. if (wmGD.keyboardFocus)
  1259. {
  1260. currFocusLeader = wmGD.keyboardFocus->transientLeader;
  1261. }
  1262. else
  1263. {
  1264. currFocusLeader = (ClientData *) NULL;
  1265. }
  1266. /*
  1267. * Find focus leader for pCD
  1268. */
  1269. pcdFocusLeader = pCD;
  1270. while (pcdFocusLeader->transientLeader &&
  1271. (pcdFocusLeader != currFocusLeader))
  1272. {
  1273. pcdFocusLeader = pcdFocusLeader->transientLeader;
  1274. }
  1275. if (pcdFocusLeader == currFocusLeader)
  1276. {
  1277. pcdFocus = wmGD.keyboardFocus;
  1278. flags = 0;
  1279. }
  1280. else
  1281. {
  1282. pcdFocus = FindTransientFocus (pcdFocusLeader);
  1283. }
  1284. }
  1285. /*
  1286. * !!! !!! !!! !!! !!! !!! !!! !!! !!! !!!
  1287. * We must look at why FindTransientFocus is
  1288. * returning a NULL pcd. The old code simply set
  1289. * focusWindow = pcdFocus->client;
  1290. * !!! !!! !!! !!! !!! !!! !!! !!! !!! !!!
  1291. *
  1292. * 11/26/96 rswiston - In tracking down CDExc22816, we
  1293. * discovered that pCD could get tricked into thinking
  1294. * it had modal transients when in fact all its transients
  1295. * had been withdrawn (fixed in WithdrawTransientChildren()).
  1296. * As a result, FindTransientFocus() returns wmGD.keyboardFocus;
  1297. * if nobody has the focus, FindTransientFocus() returns NULL.
  1298. */
  1299. if (pcdFocus)
  1300. {
  1301. focusWindow = pcdFocus->client;
  1302. }
  1303. else
  1304. {
  1305. focusWindow = (wmGD.keyboardFocus) ?
  1306. wmGD.keyboardFocus->client : ACTIVE_PSD->wmWorkspaceWin;
  1307. }
  1308. }
  1309. else
  1310. {
  1311. /*
  1312. * If the focus policy is "pointer" don't set the focus to a
  1313. * window if it has an application modal subordinate.
  1314. */
  1315. if (IS_APP_MODALIZED(pCD))
  1316. {
  1317. pcdFocus = NULL;
  1318. focusWindow = ACTIVE_PSD->wmWorkspaceWin;
  1319. /* Replay this later when the modal window is removed. */
  1320. wmGD.replayEnterEvent = True;
  1321. }
  1322. else
  1323. {
  1324. focusWindow = pcdFocus->client;
  1325. }
  1326. }
  1327. }
  1328. else
  1329. {
  1330. /*
  1331. * Set up the default (non client specific) keyboard input focus.
  1332. */
  1333. if (wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_POINTER)
  1334. {
  1335. focusWindow = PointerRoot;
  1336. }
  1337. else
  1338. {
  1339. /*
  1340. * The WORKSPACE_IF_NULL flag is used to prevent client
  1341. * windows from flashing when deiconifying a client.
  1342. */
  1343. if (WORKSPACE_IF_NULL & flags)
  1344. {
  1345. focusWindow = ACTIVE_PSD->wmWorkspaceWin;
  1346. }
  1347. else
  1348. {
  1349. /* find some reasonable client so that focus is not lost */
  1350. focusWindow = FindSomeReasonableClient();
  1351. if (focusWindow == (Window)NULL)
  1352. {
  1353. focusWindow = ACTIVE_PSD->wmWorkspaceWin;
  1354. }
  1355. }
  1356. }
  1357. }
  1358. if ((pcdFocus != wmGD.keyboardFocus) || (flags & ALWAYS_SET_FOCUS))
  1359. {
  1360. if (pcdFocus)
  1361. {
  1362. /*
  1363. * Set the focus and/or send a take focus client message. This
  1364. * is not done if a client area button press was done to set
  1365. * set the focus and the window is a globally active input
  1366. * style window (See ICCCM).
  1367. */
  1368. if ( (flags & CLIENT_AREA_FOCUS) &&
  1369. (pcdFocus->protocolFlags & PROTOCOL_WM_TAKE_FOCUS) &&
  1370. ! pcdFocus->inputFocusModel &&
  1371. (pcdFocus == pCD) &&
  1372. (wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_EXPLICIT) &&
  1373. !(pcdFocus->clientState == MINIMIZED_STATE)
  1374. )
  1375. {
  1376. /*
  1377. * We get here if:
  1378. * 1. User clicked in the client area AND
  1379. * 2. Input model is Globally Active AND
  1380. * 3. Keyboard focus policy is explicit
  1381. */
  1382. /* this window has WM_TAKE_FOCUS set and InputField false. */
  1383. /* just send a message. */
  1384. SendClientMsg (pcdFocus->client,
  1385. (long) wmGD.xa_WM_PROTOCOLS,
  1386. (long) wmGD.xa_WM_TAKE_FOCUS,
  1387. focusTime, NULL, 0);
  1388. }
  1389. else
  1390. {
  1391. if ((pcdFocus->protocolFlags & PROTOCOL_WM_TAKE_FOCUS) &&
  1392. !(pcdFocus->clientState == MINIMIZED_STATE))
  1393. {
  1394. /*
  1395. * Locally Active Input Model - Send a take focus message to the client.
  1396. */
  1397. SendClientMsg (pcdFocus->client,
  1398. (long) wmGD.xa_WM_PROTOCOLS,
  1399. (long) wmGD.xa_WM_TAKE_FOCUS,
  1400. focusTime, NULL, 0);
  1401. }
  1402. /*
  1403. * Don't set the input focus if the window has input_field set
  1404. * to False or has expressed an interest in WM_TAKE_FOCUS
  1405. * (ie. 'No Input', 'Globally Active', or 'Locally Active'),
  1406. * and the user click in the client area. If the user clicks
  1407. * on the titlebar or traverses to this window via f.next_key,
  1408. * set the focus so that the user can access the window menu
  1409. * and accelerators.
  1410. */
  1411. if ( wmGD.enforceKeyFocus || /* res - default == True. */
  1412. (flags & ALWAYS_SET_FOCUS) ||
  1413. !(flags & CLIENT_AREA_FOCUS)|| /* clicked on frame? */
  1414. pcdFocus->inputFocusModel || /* Pass.|Glob. Active */
  1415. (pcdFocus->clientState == MINIMIZED_STATE)
  1416. )
  1417. {
  1418. if ( !(flags & CLIENT_AREA_FOCUS) &&
  1419. !pcdFocus->inputFocusModel &&
  1420. !(pcdFocus->clientState == MINIMIZED_STATE))
  1421. {
  1422. /* the window doesn't want the focus - set it to the frame */
  1423. /* user clicked on the frame but we don't want the focus */
  1424. /* set it to the client's frame */
  1425. XSetInputFocus (DISPLAY, pcdFocus->clientBaseWin,
  1426. RevertToPointerRoot, focusTime);
  1427. }
  1428. else if ( !(flags & CLIENT_AREA_FOCUS) &&
  1429. !(pcdFocus->protocolFlags & PROTOCOL_WM_TAKE_FOCUS) &&
  1430. pcdFocus->inputFocusModel
  1431. )
  1432. {
  1433. XSetInputFocus (DISPLAY, focusWindow,
  1434. RevertToPointerRoot, focusTime);
  1435. }
  1436. else
  1437. {
  1438. XSetInputFocus (DISPLAY, focusWindow,
  1439. RevertToParent, focusTime);
  1440. }
  1441. }
  1442. else
  1443. {
  1444. /*
  1445. * We've decided that the window shouldn't get the focus,
  1446. * so don't change the focus.
  1447. */
  1448. pcdFocus = wmGD.nextKeyboardFocus;
  1449. }
  1450. }
  1451. }
  1452. else
  1453. {
  1454. XSetInputFocus (DISPLAY, focusWindow, RevertToPointerRoot,
  1455. focusTime);
  1456. }
  1457. wmGD.nextKeyboardFocus = pcdFocus;
  1458. }
  1459. } /* END OF FUNCTION Do_Focus_Key */
  1460. /***********************<->*************************************
  1461. *
  1462. * F_Goto_Workspace (args, pCD, event)
  1463. *
  1464. * Description:
  1465. * -----------
  1466. * This is the window manager function handler for switching
  1467. * to another workspace by name.
  1468. *
  1469. * Inputs:
  1470. * ------
  1471. * args = action function and arguments
  1472. *
  1473. * pCD = pointer to the ClientData
  1474. *
  1475. * event = X event that invoked the function (key, button, or menu/NULL)
  1476. *
  1477. * Outputs:
  1478. * -------
  1479. * Always False
  1480. *
  1481. * Comments:
  1482. * -------
  1483. ******************************<->***********************************/
  1484. Boolean
  1485. F_Goto_Workspace (String args, ClientData *pCD, XEvent *event)
  1486. {
  1487. WmScreenData *pSD = ACTIVE_PSD;
  1488. int iwsx;
  1489. XmString xms;
  1490. /*
  1491. * Compare argument against both resource name
  1492. * and workspace title, take the first match.
  1493. */
  1494. xms = XmStringCreate (args, XmFONTLIST_DEFAULT_TAG);
  1495. for (iwsx = 0; iwsx < pSD->numWorkspaces; iwsx++)
  1496. {
  1497. if (!strcmp(pSD->pWS[iwsx].name, args) ||
  1498. XmStringCompare (xms, pSD->pWS[iwsx].title))
  1499. {
  1500. break;
  1501. }
  1502. }
  1503. XmStringFree (xms);
  1504. /* check bounds */
  1505. if (iwsx >= pSD->numWorkspaces)
  1506. {
  1507. Warning (((char *)GETMESSAGE(26, 4,
  1508. "Invalid workspace name specified for f.goto_workspace")));
  1509. }
  1510. else
  1511. {
  1512. ChangeToWorkspace (&pSD->pWS[iwsx]);
  1513. }
  1514. return (False);
  1515. } /* END OF FUNCTION F_Goto_Workspace */
  1516. /******************************<->*************************************
  1517. *
  1518. * Boolean F_Help (String args, ClientData *pCD, XEvent *event)
  1519. *
  1520. * Description:
  1521. * -----------
  1522. * Invoke help on the workspace manager
  1523. *
  1524. * Inputs:
  1525. * ------
  1526. * args - incoming values
  1527. * pCD - associated client data structure
  1528. * event - what triggered this call
  1529. *
  1530. * Outputs:
  1531. * -------
  1532. * Return - True if the call occurs; false otherwise.
  1533. *
  1534. * Comments:
  1535. * --------
  1536. *
  1537. ******************************<->***********************************/
  1538. Boolean
  1539. F_Help (String args, ClientData *pCD, XEvent *event)
  1540. {
  1541. Boolean rval;
  1542. rval = WmDtHelp(args);
  1543. return (rval);
  1544. } /* END OF FUNCTION F_Help */
  1545. /******************************<->*************************************
  1546. *
  1547. * Boolean F_Help_Mode (String args, ClientData *pCD, XEvent *event)
  1548. *
  1549. * Description:
  1550. * -----------
  1551. * Invoke item help on the frontpanel
  1552. *
  1553. * Inputs:
  1554. * ------
  1555. * args - NULL
  1556. * pCD - associated client data structure ??
  1557. * event - what triggered this call
  1558. *
  1559. * Outputs:
  1560. * -------
  1561. * Return - True if the call occurs; false otherwise.
  1562. *
  1563. * Comments:
  1564. * --------
  1565. *
  1566. ******************************<->***********************************/
  1567. Boolean
  1568. F_Help_Mode (String args, ClientData *pCD, XEvent *event)
  1569. {
  1570. /*
  1571. * Help mode event processing interferes
  1572. * with slide up windows. Don't continue
  1573. * if windows are sliding.
  1574. */
  1575. if (wmGD.iSlideUpsInProgress == 0)
  1576. {
  1577. (void) WmDtHelpMode();
  1578. }
  1579. return (False);
  1580. } /* END OF FUNCTION F_Help_Mode */
  1581. /******************************<->*************************************
  1582. *
  1583. * F_Next_Key (args, pCD, event)
  1584. *
  1585. *
  1586. * Description:
  1587. * -----------
  1588. * This is the window manager function handler for setting the keyboard
  1589. * input focus to the next window in the set of managed windows.
  1590. *
  1591. *
  1592. * Inputs:
  1593. * ------
  1594. * args = (immediate value) window type flags
  1595. *
  1596. * pCD = pointer to the client data
  1597. *
  1598. * event = X event that invoked the function (key, button, or menu/NULL)
  1599. *
  1600. *************************************<->***********************************/
  1601. Boolean F_Next_Key (String args, ClientData *pCD, XEvent *event)
  1602. {
  1603. if (wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_EXPLICIT)
  1604. {
  1605. FocusNextWindow ((unsigned long)args,
  1606. GetFunctionTimestamp ((XButtonEvent *)event));
  1607. }
  1608. return (True);
  1609. } /* END OF FUNCTION F_Next_Key */
  1610. /*************************************<->*************************************
  1611. *
  1612. * F_Prev_Cmap (args, pCD, event)
  1613. *
  1614. *
  1615. * Description:
  1616. * -----------
  1617. * This is the window manager function handler installing the previous
  1618. * colormap in the list of client window colormaps.
  1619. *
  1620. *************************************<->***********************************/
  1621. Boolean F_Prev_Cmap (String args, ClientData *pCD, XEvent *event)
  1622. {
  1623. if (pCD == NULL)
  1624. {
  1625. pCD = ACTIVE_PSD->colormapFocus;
  1626. }
  1627. if (pCD && (pCD->clientCmapCount > 0) &&
  1628. ((pCD->clientState == NORMAL_STATE) ||
  1629. (pCD->clientState == MAXIMIZED_STATE)))
  1630. {
  1631. if (--(pCD->clientCmapIndex) < 0)
  1632. {
  1633. pCD->clientCmapIndex = pCD->clientCmapCount - 1;
  1634. }
  1635. pCD->clientColormap = pCD->clientCmapList[pCD->clientCmapIndex];
  1636. if (ACTIVE_PSD->colormapFocus == pCD)
  1637. {
  1638. /*
  1639. * We just re-ordered the colormaps list,
  1640. * so we need to re-run the whole thing.
  1641. */
  1642. pCD->clientCmapFlagsInitialized = 0;
  1643. ProcessColormapList (ACTIVE_PSD, pCD);
  1644. }
  1645. }
  1646. return (True);
  1647. } /* END OF FUNCTION F_Prev_Cmap */
  1648. /*************************************<->*************************************
  1649. *
  1650. * F_Prev_Key (args, pCD, event)
  1651. *
  1652. *
  1653. * Description:
  1654. * -----------
  1655. * This is the window manager function handler for setting the keyboard
  1656. * input focus to the previous window in the set of managed windows.
  1657. *
  1658. *
  1659. * Inputs:
  1660. * ------
  1661. * args = (immediate value) window type flags
  1662. *
  1663. * pCD = pointer to the client data
  1664. *
  1665. * event = X event that invoked the function (key, button, or menu/NULL)
  1666. *
  1667. *************************************<->***********************************/
  1668. Boolean F_Prev_Key (String args, ClientData *pCD, XEvent *event)
  1669. {
  1670. if (wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_EXPLICIT)
  1671. {
  1672. FocusPrevWindow ((unsigned long)args,
  1673. GetFunctionTimestamp ((XButtonEvent *)event));
  1674. }
  1675. return (True);
  1676. } /* END OF FUNCTION F_Prev_Key */
  1677. /***********************<->*************************************
  1678. *
  1679. * F_Post_FpMenu (args, pCD, event)
  1680. *
  1681. *
  1682. * Description:
  1683. * -----------
  1684. * This is the window manager function handler for posting
  1685. * the Front Panel window menu.
  1686. *
  1687. * Inputs:
  1688. * ------
  1689. * args = arguments (none)
  1690. *
  1691. * pCD = pointer to the FP ClientData
  1692. *
  1693. * event = X button press that invoked the function
  1694. *
  1695. ******************************<->***********************************/
  1696. Boolean
  1697. F_Post_FpMenu (String args, ClientData *pCD, XEvent *event)
  1698. {
  1699. static MenuSpec *fpMenuSpec = (MenuSpec *)NULL;
  1700. if (event->type != ButtonPress)
  1701. return False;
  1702. if (!fpMenuSpec)
  1703. {
  1704. WmScreenData *pSD = (pCD) ? PSD_FOR_CLIENT(pCD) : ACTIVE_PSD;
  1705. MenuSpec *oldSpec;
  1706. Widget tmpWidget;
  1707. char *newMenuName;
  1708. newMenuName = pCD ? pCD->systemMenu : "DtPanelMenu";
  1709. for (oldSpec = pSD->menuSpecs;
  1710. oldSpec != (MenuSpec *)NULL;
  1711. oldSpec = oldSpec->nextMenuSpec)
  1712. {
  1713. if (oldSpec->name && (strcmp(oldSpec->name, newMenuName) == 0))
  1714. break;
  1715. }
  1716. if (!oldSpec)
  1717. return False;
  1718. fpMenuSpec = DuplicateMenuSpec(oldSpec);
  1719. /*
  1720. * TEMPORARILY modify pSD so the new menu will be
  1721. * created on DISPLAY1 instead of DISPLAY.
  1722. */
  1723. fpMenuSpec->nextMenuSpec = pSD->menuSpecs;
  1724. pSD->menuSpecs = fpMenuSpec;
  1725. tmpWidget = pSD->screenTopLevelW;
  1726. pSD->screenTopLevelW = pSD->screenTopLevelW1;
  1727. (void)MAKE_MENU (pSD, pCD, newMenuName,
  1728. F_CONTEXT_NORMAL, F_CONTEXT_NORMAL,
  1729. (MenuItem *) NULL, FALSE);
  1730. /* Restore pSD */
  1731. pSD->screenTopLevelW = tmpWidget;
  1732. pSD->menuSpecs = fpMenuSpec->nextMenuSpec;
  1733. }
  1734. PostMenu (fpMenuSpec, pCD, event->xbutton.x_root, event->xbutton.y_root,
  1735. event->xbutton.button, F_CONTEXT_NORMAL, POST_AT_XY, event);
  1736. _XmGetMenuState(XtParent(fpMenuSpec->menuWidget))
  1737. ->MS_LastManagedMenuTime = event->xbutton.time;
  1738. return False;
  1739. }
  1740. /***********************<->*************************************
  1741. *
  1742. * F_Push_Recall (args, pCD, event)
  1743. *
  1744. *
  1745. * Description:
  1746. * -----------
  1747. * This is the window manager function handler for invoking/topping
  1748. * push_recall clients.
  1749. *
  1750. *
  1751. * Inputs:
  1752. * ------
  1753. * args = arguments
  1754. *
  1755. * pCD = pointer to the ClientData
  1756. *
  1757. * event = X event that invoked the function (key, button, or menu/NULL)
  1758. *
  1759. *
  1760. * Outputs:
  1761. * -------
  1762. * RETURN = if True then further button binding/function processing can
  1763. * be done for the event that caused this function to be called.
  1764. *
  1765. * Comments:
  1766. * -------
  1767. ******************************<->***********************************/
  1768. Boolean
  1769. F_Push_Recall (String args, ClientData *pCD, XEvent *event)
  1770. {
  1771. WmPushRecallArg *pPRP;
  1772. WmScreenData *pSD;
  1773. WmFpPushRecallClientData *pPRCD;
  1774. pPRP = (WmPushRecallArg *) args;
  1775. pSD = (pCD) ? PSD_FOR_CLIENT(pCD) : ACTIVE_PSD;
  1776. if (pPRP->ixReg < pSD->numPushRecallClients)
  1777. {
  1778. /* get slot for this client */
  1779. pPRCD = &(pSD->pPRCD[pPRP->ixReg]);
  1780. /*
  1781. * If the client is already running, then top it in this workspace,
  1782. * else invoke the function to start it.
  1783. */
  1784. if (pPRCD->pCD)
  1785. {
  1786. /* Client is managed already. */
  1787. if (!(ClientInWorkspace (pSD->pActiveWS, pPRCD->pCD)))
  1788. {
  1789. WorkspaceID *wsRemoveList;
  1790. int sizeRemoveList;
  1791. /*
  1792. * Move client to current workspace
  1793. */
  1794. wsRemoveList = GetListOfOccupiedWorkspaces (pPRCD->pCD,
  1795. &sizeRemoveList);
  1796. RemoveClientFromWorkspaces (pPRCD->pCD, wsRemoveList,
  1797. sizeRemoveList);
  1798. XtFree ((char *)wsRemoveList);
  1799. AddClientToWorkspaces (pPRCD->pCD, &(pSD->pActiveWS->id), 1);
  1800. SetClientWsIndex(pPRCD->pCD);
  1801. SetClientState(pPRCD->pCD,
  1802. pPRCD->pCD->clientState & ~UNSEEN_STATE, CurrentTime);
  1803. }
  1804. /* Make this client visible */
  1805. wmGD.bSuspendSecondaryRestack = True;
  1806. F_Normalize_And_Raise (NULL, pPRCD->pCD, event);
  1807. wmGD.bSuspendSecondaryRestack = False;
  1808. }
  1809. else
  1810. {
  1811. struct timeval tvNow;
  1812. struct timezone tz;
  1813. Boolean bWaiting = False;
  1814. if (pPRCD->tvTimeout.tv_sec != 0)
  1815. {
  1816. gettimeofday (&tvNow, &tz);
  1817. if ((pPRCD->tvTimeout.tv_sec > tvNow.tv_sec) ||
  1818. ((pPRCD->tvTimeout.tv_sec == tvNow.tv_sec) &&
  1819. (pPRCD->tvTimeout.tv_usec > tvNow.tv_usec)))
  1820. {
  1821. /* still waiting for client to start */
  1822. bWaiting = True;
  1823. }
  1824. }
  1825. if (!bWaiting)
  1826. {
  1827. long clientTimeout = 0;
  1828. Arg al[5];
  1829. int ac;
  1830. WmPanelistObject pPanelist;
  1831. pPanelist = (WmPanelistObject) pSD->wPanelist;
  1832. /* invoke the function to start the client */
  1833. pPRP->wmFunc ( pPRP->pArgs, pCD, event);
  1834. if (pPanelist && panel.busy_light_data)
  1835. {
  1836. /* set timeout value */
  1837. ac = 0;
  1838. XtSetArg (al[ac],
  1839. XmNclientTimeoutInterval, &clientTimeout); ac++;
  1840. XtGetValues (panel.busy_light_data->icon, (ArgList)al, ac);
  1841. }
  1842. /*
  1843. * ClientTimeout is in milliseconds, timeval values
  1844. * are in seconds and microseconds.
  1845. */
  1846. gettimeofday (&(pPRCD->tvTimeout), &tz);
  1847. pPRCD->tvTimeout.tv_sec += clientTimeout / 1000;
  1848. pPRCD->tvTimeout.tv_usec +=
  1849. (clientTimeout % 1000) * 1000;
  1850. pPRCD->tvTimeout.tv_sec += pPRCD->tvTimeout.tv_usec / 1000000;
  1851. pPRCD->tvTimeout.tv_usec %= 1000000;
  1852. }
  1853. }
  1854. }
  1855. return (True);
  1856. } /* END OF FUNCTION F_Push_Recall */
  1857. /*************************************<->*************************************
  1858. *
  1859. * F_Pass_Key (args, pCD, event)
  1860. *
  1861. *
  1862. * Description:
  1863. * -----------
  1864. * This is a function stub for the f.pass_key window manager function.
  1865. *
  1866. *
  1867. * Inputs:
  1868. * ------
  1869. * args = (immediate value) window type flags
  1870. *
  1871. * pCD = pointer to the client data
  1872. *
  1873. * event = X event that invoked the function (key, button, or menu/NULL)
  1874. *
  1875. *************************************<->***********************************/
  1876. Boolean F_Pass_Key (String args, ClientData *pCD, XEvent *event)
  1877. {
  1878. if (wmGD.passKeysActive)
  1879. {
  1880. /*
  1881. * Get out of pass keys mode.
  1882. */
  1883. wmGD.passKeysActive = False;
  1884. wmGD.passKeysKeySpec = NULL;
  1885. }
  1886. else
  1887. {
  1888. /*
  1889. * Get into pass keys mode.
  1890. */
  1891. wmGD.passKeysActive = True;
  1892. }
  1893. return (False);
  1894. } /* END OF FUNCTION F_Pass_Key */
  1895. /*************************************<->*************************************
  1896. *
  1897. * F_Maximize (args, pCD, event)
  1898. *
  1899. *
  1900. * Description:
  1901. * -----------
  1902. * This is the window manager function handler for maximizing a client
  1903. * window.
  1904. *
  1905. *************************************<->***********************************/
  1906. Boolean F_Maximize (String args, ClientData *pCD, XEvent *event)
  1907. {
  1908. if (pCD && (pCD->clientFunctions & MWM_FUNC_MAXIMIZE))
  1909. {
  1910. SetClientStateWithEventMask (pCD, MAXIMIZED_STATE,
  1911. GetFunctionTimestamp ((XButtonEvent *)event),
  1912. GetEventInverseMask(event));
  1913. }
  1914. return (False);
  1915. } /* END OF FUNCTION F_Maximize */
  1916. /*************************************<->*************************************
  1917. *
  1918. * F_Menu (args, pCD, event)
  1919. *
  1920. *
  1921. * Description:
  1922. * -----------
  1923. * This is the window manager function handler for posting a menu.
  1924. * This function can only be invoked by a key or button event.
  1925. * wmGD.menuUnpostKeySpec is assumed set appropriately; it will be set to
  1926. * NULL when the menu is unposted.
  1927. *
  1928. *************************************<->***********************************/
  1929. Boolean F_Menu (String args, ClientData *pCD, XEvent *event)
  1930. {
  1931. MenuSpec *menuSpec;
  1932. Context menuContext;
  1933. unsigned int button;
  1934. int x;
  1935. int y;
  1936. long flags = POST_AT_XY;
  1937. WmScreenData *pSD;
  1938. if (event &&
  1939. ((event->type == ButtonPress) || (event->type == ButtonRelease)))
  1940. {
  1941. button = event->xbutton.button;
  1942. x = event->xbutton.x_root;
  1943. y = event->xbutton.y_root;
  1944. if (event->type == ButtonRelease)
  1945. {
  1946. flags |= POST_TRAVERSAL_ON;
  1947. }
  1948. /*
  1949. * Root menu, if posted with button press, then
  1950. * set up to handle root menu click to make the menu
  1951. * sticky.
  1952. */
  1953. else if (wmGD.rootButtonClick && (event->type == ButtonPress))
  1954. {
  1955. if (wmGD.bReplayedButton)
  1956. {
  1957. /* This button was replayed, it most likely dismissed
  1958. a previous sticky menu, don't post a menu here */
  1959. return (False);
  1960. }
  1961. wmGD.checkHotspot = True;
  1962. wmGD.hotspotRectangle.x = x - wmGD.moveThreshold/2;
  1963. wmGD.hotspotRectangle.y = y - wmGD.moveThreshold/2;
  1964. wmGD.hotspotRectangle.width = wmGD.moveThreshold;
  1965. wmGD.hotspotRectangle.height = wmGD.moveThreshold;
  1966. }
  1967. }
  1968. else if (event &&
  1969. ((event->type == KeyPress) || (event->type == KeyRelease)))
  1970. {
  1971. button = NoButton;
  1972. x = event->xkey.x_root;
  1973. y = event->xkey.y_root;
  1974. }
  1975. else
  1976. {
  1977. /*
  1978. * A button or key event must be used to post a menu using this
  1979. * function.
  1980. */
  1981. return (False);
  1982. }
  1983. if (pCD)
  1984. {
  1985. if (pCD->clientState == NORMAL_STATE)
  1986. {
  1987. menuContext = F_CONTEXT_NORMAL;
  1988. }
  1989. else if (pCD->clientState == MAXIMIZED_STATE)
  1990. {
  1991. menuContext = F_CONTEXT_MAXIMIZE;
  1992. }
  1993. else
  1994. {
  1995. menuContext = F_CONTEXT_ICON;
  1996. }
  1997. if (P_ICON_BOX(pCD) &&
  1998. event->xany.window == ICON_FRAME_WIN(pCD))
  1999. {
  2000. if (pCD->clientState == MINIMIZED_STATE)
  2001. {
  2002. menuContext = F_SUBCONTEXT_IB_IICON;
  2003. }
  2004. else
  2005. {
  2006. menuContext = F_SUBCONTEXT_IB_WICON;
  2007. }
  2008. }
  2009. }
  2010. else
  2011. {
  2012. menuContext = F_CONTEXT_ROOT;
  2013. }
  2014. /* We do not add this MenuSpec to wmGD.acceleratorMenuSpecs.
  2015. * This should have been done in MakeWmFunctionResources().
  2016. */
  2017. pSD = (pCD) ? PSD_FOR_CLIENT(pCD) : ACTIVE_PSD;
  2018. if ((menuSpec = MAKE_MENU (pSD, pCD, args, menuContext,
  2019. menuContext, (MenuItem *) NULL, FALSE)) != NULL)
  2020. {
  2021. PostMenu (menuSpec, pCD, x, y, button, menuContext, flags, event);
  2022. }
  2023. return (False);
  2024. } /* END OF FUNCTION F_Menu */
  2025. /*************************************<->*************************************
  2026. *
  2027. * F_Minimize (args, pCD, event)
  2028. *
  2029. *
  2030. * Description:
  2031. * -----------
  2032. * This is the window manager function handler for minimizing a client
  2033. * window.
  2034. *
  2035. *************************************<->***********************************/
  2036. Boolean F_Minimize (String args, ClientData *pCD, XEvent *event)
  2037. {
  2038. ClientData *pcdLeader;
  2039. if (pCD)
  2040. {
  2041. /*
  2042. * If the window is a transient then minimize the entire transient
  2043. * tree including the transient leader.
  2044. */
  2045. pcdLeader = (pCD->transientLeader) ?
  2046. FindTransientTreeLeader (pCD) : pCD;
  2047. if (pcdLeader->clientFunctions & MWM_FUNC_MINIMIZE)
  2048. {
  2049. SetClientStateWithEventMask (pCD, MINIMIZED_STATE,
  2050. GetFunctionTimestamp ((XButtonEvent *)event),
  2051. GetEventInverseMask(event));
  2052. }
  2053. }
  2054. return (False);
  2055. } /* END OF FUNCTION F_Minimize */
  2056. /*************************************<->*************************************
  2057. *
  2058. * F_Move (args, pCD, event)
  2059. *
  2060. *
  2061. * Description:
  2062. * -----------
  2063. * This is the window manager function handler for moving a client window
  2064. * or icon.
  2065. *
  2066. *************************************<->***********************************/
  2067. Boolean F_Move (String args, ClientData *pCD, XEvent *event)
  2068. {
  2069. if (pCD && (pCD->clientFunctions & MWM_FUNC_MOVE))
  2070. {
  2071. StartClientMove (pCD, event);
  2072. HandleClientFrameMove (pCD, event);
  2073. }
  2074. return (False);
  2075. } /* END OF FUNCTION F_Move */
  2076. /*************************************<->*************************************
  2077. *
  2078. * F_Next_Cmap (args, pCD, event)
  2079. *
  2080. *
  2081. * Description:
  2082. * -----------
  2083. * This is the window manager function handler installing the next
  2084. * colormap in the list of client window colormaps.
  2085. *
  2086. *************************************<->***********************************/
  2087. Boolean F_Next_Cmap (String args, ClientData *pCD, XEvent *event)
  2088. {
  2089. if (pCD == NULL)
  2090. {
  2091. pCD = ACTIVE_PSD->colormapFocus;
  2092. }
  2093. if (pCD && (pCD->clientCmapCount > 0) &&
  2094. ((pCD->clientState == NORMAL_STATE) ||
  2095. (pCD->clientState == MAXIMIZED_STATE)))
  2096. {
  2097. if (++(pCD->clientCmapIndex) >= pCD->clientCmapCount)
  2098. {
  2099. pCD->clientCmapIndex = 0;
  2100. }
  2101. pCD->clientColormap = pCD->clientCmapList[pCD->clientCmapIndex];
  2102. if (ACTIVE_PSD->colormapFocus == pCD)
  2103. {
  2104. /*
  2105. * We just re-ordered the colormaps list,
  2106. * so we need to re-run the whole thing.
  2107. */
  2108. pCD->clientCmapFlagsInitialized = 0;
  2109. ProcessColormapList (ACTIVE_PSD, pCD);
  2110. }
  2111. }
  2112. return (True);
  2113. } /* END OF FUNCTION F_Next_Cmap */
  2114. /*************************************<->*************************************
  2115. *
  2116. * F_Nop (args, pCD, event)
  2117. *
  2118. *
  2119. * Description:
  2120. * -----------
  2121. * This is the window manager function handler for doing nothing.
  2122. *
  2123. *************************************<->***********************************/
  2124. Boolean F_Nop (String args, ClientData *pCD, XEvent *event)
  2125. {
  2126. return (True);
  2127. } /* END OF FUNCTION F_Nop */
  2128. /*************************************<->*************************************
  2129. *
  2130. * F_Normalize (args, pCD, event)
  2131. *
  2132. *
  2133. * Description:
  2134. * -----------
  2135. * This is the window manager function handler for putting a client window
  2136. * in the normal state.
  2137. *
  2138. *************************************<->***********************************/
  2139. Boolean F_Normalize (String args, ClientData *pCD, XEvent *event)
  2140. {
  2141. if (pCD)
  2142. {
  2143. SetClientStateWithEventMask (pCD, NORMAL_STATE,
  2144. GetFunctionTimestamp ((XButtonEvent *)event),
  2145. GetEventInverseMask(event));
  2146. }
  2147. return (False);
  2148. } /* END OF FUNCTION F_Normalize */
  2149. /*************************************<->*************************************
  2150. *
  2151. * F_Normalize_And_Raise (args, pCD, event)
  2152. *
  2153. *
  2154. * Description:
  2155. * -----------
  2156. * This is the window manager function handler for putting a client window
  2157. * in the normal state and raising it from and icon.
  2158. *
  2159. *************************************<->***********************************/
  2160. Boolean F_Normalize_And_Raise (String args, ClientData *pCD, XEvent *event)
  2161. {
  2162. WmScreenData *pSD;
  2163. WmWorkspaceData *pWS;
  2164. if (args)
  2165. {
  2166. if (pCD)
  2167. pSD = PSD_FOR_CLIENT (pCD);
  2168. else
  2169. pSD = ACTIVE_PSD;
  2170. pWS = pSD->pActiveWS;
  2171. if (pSD->useIconBox &&
  2172. wmGD.useFrontPanel &&
  2173. pSD->iconBoxControl &&
  2174. (!strcmp(args, WmNiconBox)))
  2175. {
  2176. /*
  2177. * There's an icon box in the front panel and this is a
  2178. * request to pop up the icon box.
  2179. */
  2180. IconBoxPopUp (pWS, True);
  2181. return (False);
  2182. }
  2183. }
  2184. if (pCD)
  2185. {
  2186. if (pCD->clientState == MINIMIZED_STATE)
  2187. {
  2188. /* normalize window */
  2189. SetClientStateWithEventMask (pCD, NORMAL_STATE,
  2190. (Time)
  2191. (event
  2192. ? GetFunctionTimestamp ((XButtonEvent *)event)
  2193. : GetTimestamp ()),
  2194. GetEventInverseMask(event));
  2195. }
  2196. else
  2197. {
  2198. /* Make sure we are in NORMAL_STATE */
  2199. SetClientStateWithEventMask (pCD, NORMAL_STATE,
  2200. GetFunctionTimestamp ((XButtonEvent *)event),
  2201. GetEventInverseMask(event));
  2202. /* Raise the window and set the keyboard focus to the window */
  2203. wmGD.bSuspendSecondaryRestack = True;
  2204. F_Raise (NULL, pCD, (XEvent *)NULL);
  2205. wmGD.bSuspendSecondaryRestack = False;
  2206. if (wmGD.raiseKeyFocus)
  2207. {
  2208. F_Focus_Key (NULL, pCD,
  2209. (event
  2210. ? ((XEvent *)event)
  2211. : ((XEvent *)NULL)));
  2212. }
  2213. }
  2214. wmGD.clickData.clickPending = False;
  2215. wmGD.clickData.doubleClickPending = False;
  2216. }
  2217. return (False);
  2218. } /* END OF FUNCTION F_Normalize_And_Raise */
  2219. /*************************************<->*************************************
  2220. *
  2221. * F_Restore (args, pCD, event)
  2222. *
  2223. *
  2224. * Description:
  2225. * -----------
  2226. * This is the window manager function handler for putting a client window
  2227. * in the normal state.
  2228. *
  2229. *************************************<->***********************************/
  2230. Boolean F_Restore (String args, ClientData *pCD, XEvent *event)
  2231. {
  2232. int newState;
  2233. if (pCD)
  2234. {
  2235. /*
  2236. * If current state is MAXIMIZED state then just go to NORMAL state,
  2237. * otherwise (you are in MINIMIZED state) return to previous state.
  2238. */
  2239. if (pCD->clientState == MAXIMIZED_STATE)
  2240. {
  2241. SetClientStateWithEventMask (pCD, NORMAL_STATE,
  2242. GetFunctionTimestamp ((XButtonEvent *)event),
  2243. GetEventInverseMask(event));
  2244. }
  2245. else
  2246. {
  2247. if (pCD->maxConfig)
  2248. {
  2249. newState = MAXIMIZED_STATE;
  2250. }
  2251. else
  2252. {
  2253. newState = NORMAL_STATE;
  2254. }
  2255. SetClientStateWithEventMask (pCD, newState,
  2256. GetFunctionTimestamp ((XButtonEvent *)event),
  2257. GetEventInverseMask(event));
  2258. }
  2259. }
  2260. return (False);
  2261. } /* END OF FUNCTION F_Restore */
  2262. /*************************************<->*************************************
  2263. *
  2264. * F_Restore_And_Raise (args, pCD, event)
  2265. *
  2266. *
  2267. * Description:
  2268. * -----------
  2269. * This is the window manager function handler for putting a client window
  2270. * in the normal state and raising it from and icon.
  2271. *
  2272. *************************************<->***********************************/
  2273. Boolean F_Restore_And_Raise (String args, ClientData *pCD, XEvent *event)
  2274. {
  2275. int newState;
  2276. if (pCD)
  2277. {
  2278. if (pCD->clientState == MINIMIZED_STATE)
  2279. {
  2280. /* Restore window */
  2281. if (pCD->maxConfig)
  2282. {
  2283. newState = MAXIMIZED_STATE;
  2284. }
  2285. else
  2286. {
  2287. newState = NORMAL_STATE;
  2288. }
  2289. SetClientStateWithEventMask (pCD, newState,
  2290. (Time)
  2291. (event
  2292. ? GetFunctionTimestamp ((XButtonEvent *)event)
  2293. : GetTimestamp ()),
  2294. GetEventInverseMask(event));
  2295. }
  2296. else
  2297. {
  2298. /* Make sure we restore the window first */
  2299. F_Restore (NULL, pCD, event);
  2300. /* Raise the window and set the keyboard focus to the window */
  2301. wmGD.bSuspendSecondaryRestack = True;
  2302. F_Raise (NULL, pCD, (XEvent *)NULL);
  2303. wmGD.bSuspendSecondaryRestack = False;
  2304. if (wmGD.raiseKeyFocus)
  2305. {
  2306. F_Focus_Key (NULL, pCD,
  2307. (event
  2308. ? ((XEvent *)event)
  2309. : ((XEvent *)NULL)));
  2310. }
  2311. }
  2312. wmGD.clickData.clickPending = False;
  2313. wmGD.clickData.doubleClickPending = False;
  2314. }
  2315. return (False);
  2316. } /* END OF FUNCTION F_Restore_And_Raise */
  2317. /*************************************<->*************************************
  2318. *
  2319. * F_Pack_Icons (args, pCD, event)
  2320. *
  2321. *
  2322. * Description:
  2323. * -----------
  2324. * This is the window manager function handler for packing icons in the
  2325. * icon box or on the desktop.
  2326. *
  2327. *************************************<->***********************************/
  2328. Boolean F_Pack_Icons (String args, ClientData *pCD, XEvent *event)
  2329. {
  2330. IconBoxData *pIBD;
  2331. if (ACTIVE_PSD->useIconBox)
  2332. {
  2333. pIBD = ACTIVE_WS->pIconBox;
  2334. if (pCD)
  2335. {
  2336. while (pCD != pIBD->pCD_iconBox)
  2337. {
  2338. if (pIBD->pNextIconBox)
  2339. {
  2340. pIBD = pIBD->pNextIconBox;
  2341. }
  2342. else
  2343. {
  2344. pIBD = NULL;
  2345. break;
  2346. }
  2347. }
  2348. }
  2349. if (pIBD)
  2350. {
  2351. PackIconBox (pIBD, False, False, 0, 0);
  2352. }
  2353. else
  2354. {
  2355. PackRootIcons ();
  2356. }
  2357. }
  2358. else
  2359. {
  2360. PackRootIcons ();
  2361. }
  2362. return (True);
  2363. } /* END OF FUNCTION F_Pack_Icons */
  2364. /*************************************<->*************************************
  2365. *
  2366. * F_Post_SMenu (args, pCD, event)
  2367. *
  2368. *
  2369. * Description:
  2370. * -----------
  2371. * This is the window manager function handler for posting the system menu
  2372. * for the specified client.
  2373. * This function can only be invoked by a key or button event.
  2374. * wmGD.menuUnpostKeySpec is assumed set appropriately; it will be set to
  2375. * NULL when the menu is unposted.
  2376. *
  2377. *************************************<->***********************************/
  2378. Boolean F_Post_SMenu (String args, ClientData *pCD, XEvent *event)
  2379. {
  2380. Context menuContext;
  2381. /*
  2382. * An event must be used to post the system menu using this function.
  2383. */
  2384. if (event && pCD && pCD->systemMenuSpec)
  2385. {
  2386. /*
  2387. * Determine whether the keyboard is posting the menu and post
  2388. * the menu at an appropriate place.
  2389. */
  2390. if (pCD->clientState == NORMAL_STATE)
  2391. {
  2392. menuContext = F_CONTEXT_NORMAL;
  2393. }
  2394. else if (pCD->clientState == MAXIMIZED_STATE)
  2395. {
  2396. menuContext = F_CONTEXT_MAXIMIZE;
  2397. }
  2398. else
  2399. {
  2400. menuContext = F_CONTEXT_ICON;
  2401. }
  2402. if (P_ICON_BOX(pCD) &&
  2403. event->xany.window == ICON_FRAME_WIN(pCD))
  2404. {
  2405. if (pCD->clientState == MINIMIZED_STATE)
  2406. {
  2407. menuContext = F_SUBCONTEXT_IB_IICON;
  2408. }
  2409. else
  2410. {
  2411. menuContext = F_SUBCONTEXT_IB_WICON;
  2412. }
  2413. }
  2414. if ((event->type == KeyPress) || (event->type == KeyRelease))
  2415. {
  2416. /*
  2417. * Set up for "sticky" menu processing if specified.
  2418. */
  2419. if (pCD->clientState == MINIMIZED_STATE ||
  2420. menuContext == (F_SUBCONTEXT_IB_IICON | F_SUBCONTEXT_IB_WICON))
  2421. {
  2422. if (wmGD.iconClick)
  2423. {
  2424. wmGD.checkHotspot = True;
  2425. }
  2426. }
  2427. else if (wmGD.systemButtonClick && (pCD->decor & MWM_DECOR_MENU))
  2428. {
  2429. wmGD.checkHotspot = True;
  2430. }
  2431. PostMenu (pCD->systemMenuSpec, pCD, 0, 0, NoButton, menuContext,
  2432. 0, event);
  2433. }
  2434. else if (event->type == ButtonPress)
  2435. {
  2436. /*
  2437. * Root menu, if posted with button press, then
  2438. * set up to handle root menu click to make the menu
  2439. * sticky.
  2440. */
  2441. if (wmGD.rootButtonClick && (!wmGD.checkHotspot))
  2442. {
  2443. wmGD.checkHotspot = True;
  2444. wmGD.hotspotRectangle.x =
  2445. event->xbutton.x_root - wmGD.moveThreshold/2;
  2446. wmGD.hotspotRectangle.y =
  2447. event->xbutton.y_root - wmGD.moveThreshold/2;
  2448. wmGD.hotspotRectangle.width = wmGD.moveThreshold;
  2449. wmGD.hotspotRectangle.height = wmGD.moveThreshold;
  2450. }
  2451. PostMenu (pCD->systemMenuSpec, pCD,
  2452. event->xbutton.x_root, event->xbutton.y_root,
  2453. event->xbutton.button, menuContext, POST_AT_XY, event);
  2454. }
  2455. else if (event->type == ButtonRelease)
  2456. {
  2457. PostMenu (pCD->systemMenuSpec, pCD,
  2458. event->xbutton.x_root, event->xbutton.y_root,
  2459. event->xbutton.button, menuContext,
  2460. POST_AT_XY | POST_TRAVERSAL_ON, event);
  2461. }
  2462. }
  2463. return (False);
  2464. } /* END OF FUNCTION F_PostSMenu */
  2465. /*************************************<->*************************************
  2466. *
  2467. * F_Kill (args, pCD, event)
  2468. *
  2469. *
  2470. * Description:
  2471. * -----------
  2472. * This is the window manager function handler for terminating a client.
  2473. * Essentially the client connection is shut down.
  2474. *
  2475. *************************************<->***********************************/
  2476. Boolean F_Kill (String args, ClientData *pCD, XEvent *event)
  2477. {
  2478. if (pCD && (pCD->clientFunctions & MWM_FUNC_CLOSE))
  2479. {
  2480. Boolean do_delete_window =
  2481. pCD->protocolFlags & PROTOCOL_WM_DELETE_WINDOW;
  2482. Boolean do_save_yourself =
  2483. pCD->protocolFlags & PROTOCOL_WM_SAVE_YOURSELF;
  2484. if (pCD->dtwmBehaviors & DtWM_BEHAVIOR_SUBPANEL)
  2485. {
  2486. Widget wPanel;
  2487. /*
  2488. * Get the widget for the subpanel
  2489. * (Should be only child of the shell!)
  2490. */
  2491. wPanel = WmPanelistWindowToSubpanel (DISPLAY1, pCD->client);
  2492. if (wPanel)
  2493. {
  2494. SlideSubpanelBackIn (pCD, wPanel);
  2495. }
  2496. return (False);
  2497. }
  2498. if (pCD->clientFlags & ICON_BOX)
  2499. {
  2500. /*
  2501. * When the front panel is used with the icon box,
  2502. * "Close" hides the icon box into the front panel.
  2503. */
  2504. if ((wmGD.useFrontPanel) &&
  2505. (pCD->pSD->iconBoxControl) &&
  2506. (IconBoxShowing(pCD->pSD->pActiveWS)))
  2507. {
  2508. IconBoxPopUp (pCD->pSD->pActiveWS, False);
  2509. }
  2510. }
  2511. else if (!do_delete_window && !do_save_yourself)
  2512. {
  2513. XKillClient (DISPLAY, pCD->client);
  2514. }
  2515. else
  2516. {
  2517. if (do_delete_window)
  2518. {
  2519. /*
  2520. * The client wants to be notified, not killed.
  2521. */
  2522. SendClientMsg (pCD->client, (long) wmGD.xa_WM_PROTOCOLS,
  2523. (long) wmGD.xa_WM_DELETE_WINDOW, CurrentTime, NULL, 0);
  2524. }
  2525. /*
  2526. * HP does not want to send a client message for both
  2527. * delete_window AND save_yourself. The current OSF
  2528. * patch did just that. This "else if" returns dtwm
  2529. * to the behavior of dt 2.01
  2530. */
  2531. else if (do_save_yourself)
  2532. {
  2533. /*
  2534. * Send a WM_SAVE_YOURSELF message and wait for a change to
  2535. * the WM_COMMAND property.
  2536. * !!! button and key input should be kept from the window !!!
  2537. */
  2538. if (AddWmTimer (TIMER_QUIT,
  2539. (unsigned long) wmGD.quitTimeout, pCD))
  2540. {
  2541. SendClientMsg (pCD->client, (long) wmGD.xa_WM_PROTOCOLS,
  2542. (long) wmGD.xa_WM_SAVE_YOURSELF, CurrentTime, NULL, 0);
  2543. pCD->clientFlags |= CLIENT_TERMINATING;
  2544. }
  2545. else
  2546. {
  2547. XKillClient (DISPLAY, pCD->client);
  2548. }
  2549. }
  2550. }
  2551. }
  2552. return (False);
  2553. } /* END OF FUNCTION F_Kill */
  2554. /*************************************<->*************************************
  2555. *
  2556. * F_Marquee_Selection (args, pCD, event)
  2557. *
  2558. *
  2559. * Description:
  2560. * -----------
  2561. * This is the window manager function handler for selecting
  2562. * non-window manager objects on the root window.
  2563. *
  2564. *************************************<->***********************************/
  2565. Boolean F_Marquee_Selection (String args, ClientData *pCD, XEvent *event)
  2566. {
  2567. if (!pCD)
  2568. {
  2569. /*
  2570. * This function only valid in root context
  2571. */
  2572. StartMarqueeSelect (ACTIVE_PSD, event);
  2573. HandleMarqueeSelect (ACTIVE_PSD, event);
  2574. }
  2575. return (False);
  2576. } /* END OF FUNCTION F_Marquee_Selection */
  2577. /*************************************<->*************************************
  2578. *
  2579. * RefreshByClearing (win)
  2580. *
  2581. *
  2582. * Description:
  2583. * -----------
  2584. * Recursively refresh this window and its children by doing
  2585. * XClearAreas
  2586. *
  2587. *************************************<->***********************************/
  2588. static void
  2589. RefreshByClearing (Window win)
  2590. {
  2591. Status status;
  2592. int i;
  2593. Window root, parent;
  2594. unsigned int nchildren;
  2595. Window *winChildren;
  2596. /* clear this window */
  2597. XClearArea(DISPLAY, win, 0, 0, 0, 0, True);
  2598. /* find any children and clear them, too */
  2599. status = XQueryTree(DISPLAY, win, &root, &parent, &winChildren,
  2600. &nchildren);
  2601. if (status != 0)
  2602. {
  2603. /* recurse for each child window */
  2604. for (i=0; i<nchildren; ++i)
  2605. {
  2606. RefreshByClearing(winChildren[i]);
  2607. }
  2608. /* clean up */
  2609. if (nchildren > 0)
  2610. XFree((char *)winChildren);
  2611. }
  2612. }
  2613. /*************************************<->*************************************
  2614. *
  2615. * F_Refresh (args, pCD, event)
  2616. *
  2617. *
  2618. * Description:
  2619. * -----------
  2620. * This is the window manager function handler for causing all windows
  2621. * in the workspace to be redrawn.
  2622. *
  2623. *************************************<->***********************************/
  2624. Boolean F_Refresh (String args, ClientData *pCD, XEvent *event)
  2625. {
  2626. Window win;
  2627. if (wmGD.refreshByClearing)
  2628. {
  2629. RefreshByClearing (ACTIVE_ROOT);
  2630. }
  2631. else
  2632. {
  2633. /* default background_pixmap is None */
  2634. win = XCreateWindow (DISPLAY,
  2635. ACTIVE_ROOT, 0, 0,
  2636. (unsigned int) DisplayWidth (DISPLAY,
  2637. ACTIVE_SCREEN),
  2638. (unsigned int) DisplayHeight (DISPLAY,
  2639. ACTIVE_SCREEN),
  2640. 0,
  2641. 0,
  2642. InputOutput,
  2643. CopyFromParent,
  2644. 0,
  2645. (XSetWindowAttributes *)NULL);
  2646. XMapWindow (DISPLAY, win);
  2647. XDestroyWindow (DISPLAY, win);
  2648. }
  2649. XFlush (DISPLAY);
  2650. return (True);
  2651. } /* END OF FUNCTION F_Refresh */
  2652. /*************************************<->*************************************
  2653. *
  2654. * F_Resize (args, pCD, event)
  2655. *
  2656. *
  2657. * Description:
  2658. * -----------
  2659. * This is the window manager function handler for resizing a client window.
  2660. *
  2661. *************************************<->***********************************/
  2662. Boolean F_Resize (String args, ClientData *pCD, XEvent *event)
  2663. {
  2664. if (pCD && (pCD->clientFunctions & MWM_FUNC_RESIZE) &&
  2665. ((pCD->clientState == NORMAL_STATE) ||
  2666. (pCD->clientState == MAXIMIZED_STATE)))
  2667. {
  2668. StartClientResize (pCD, event);
  2669. HandleClientFrameResize (pCD, event);
  2670. }
  2671. return (False);
  2672. } /* END OF FUNCTION F_Resize */
  2673. /*************************************<->*************************************
  2674. *
  2675. * F_Restart (args, pCD, event)
  2676. *
  2677. *
  2678. * Description:
  2679. * -----------
  2680. * This is the window manager function handler for restarting the window
  2681. * manager.
  2682. *
  2683. *************************************<->***********************************/
  2684. Boolean F_Restart (String args, ClientData *pCD, XEvent *event)
  2685. {
  2686. if (args && *args && !strcmp (args, DTWM_REQP_NO_CONFIRM))
  2687. {
  2688. RestartWm (MWM_INFO_STARTUP_CUSTOM);
  2689. }
  2690. else if (wmGD.showFeedback & WM_SHOW_FB_RESTART)
  2691. {
  2692. ConfirmAction (ACTIVE_PSD, RESTART_ACTION);
  2693. }
  2694. else
  2695. {
  2696. RestartWm (MWM_INFO_STARTUP_CUSTOM);
  2697. }
  2698. return (False);
  2699. } /* END OF FUNCTION F_Restart */
  2700. /*************************************<->*************************************
  2701. *
  2702. * Do_Restart (dummy)
  2703. *
  2704. *
  2705. * Description:
  2706. * -----------
  2707. * Callback function for restarting the window manager.
  2708. *
  2709. *************************************<->***********************************/
  2710. void Do_Restart (Boolean dummy)
  2711. {
  2712. RestartWm (MWM_INFO_STARTUP_CUSTOM);
  2713. } /* END OF FUNCTION Do_Restart */
  2714. /*************************************<->*************************************
  2715. *
  2716. * RestartWm (startupFlags)
  2717. *
  2718. *
  2719. * Description:
  2720. * -----------
  2721. * Actually restarts the window manager.
  2722. *
  2723. *
  2724. * Inputs:
  2725. * ------
  2726. * startupFlags = flags to be put into the Wm_INFO property for restart.
  2727. *
  2728. *************************************<->***********************************/
  2729. void RestartWm (long startupFlags)
  2730. {
  2731. ClientListEntry *pNextEntry;
  2732. int scr;
  2733. for (scr=0; scr<wmGD.numScreens; scr++)
  2734. {
  2735. if(wmGD.Screens[scr].managed)
  2736. {
  2737. /*
  2738. * Set up the _MOTIF_WM_INFO property on the root window
  2739. * to indicate a restart.
  2740. */
  2741. SetMwmInfo (wmGD.Screens[scr].rootWindow, startupFlags, 0);
  2742. SaveResources(&wmGD.Screens[scr]);
  2743. /*
  2744. * Unmap client windows and reparent them to the root window.
  2745. */
  2746. pNextEntry = wmGD.Screens[scr].lastClient;
  2747. while (pNextEntry)
  2748. {
  2749. if (pNextEntry->type == NORMAL_STATE)
  2750. {
  2751. if (pNextEntry->pCD->clientFlags & CLIENT_WM_CLIENTS)
  2752. {
  2753. if (pNextEntry->pCD->clientState != MINIMIZED_STATE)
  2754. {
  2755. XUnmapWindow (DISPLAY,
  2756. pNextEntry->pCD->clientFrameWin);
  2757. }
  2758. }
  2759. else
  2760. {
  2761. DeFrameClient (pNextEntry->pCD);
  2762. }
  2763. }
  2764. pNextEntry = pNextEntry->prevSibling;
  2765. }
  2766. UnParentControls (&wmGD.Screens[scr], True);
  2767. }
  2768. }
  2769. /* shut down the messaging connection */
  2770. dtCloseIPC();
  2771. ResignFromSM();
  2772. /*
  2773. * This fixes restart problem when going from explicit focus to
  2774. * pointer focus. Window under pointer was not getting focus indication
  2775. * until pointer was moved to new window, or out of and into the
  2776. * window.
  2777. */
  2778. XSetInputFocus (DISPLAY, PointerRoot, RevertToPointerRoot, CurrentTime);
  2779. XSync (DISPLAY, False);
  2780. CLOSE_FILES_ON_EXEC();
  2781. _DtEnvControl(DT_ENV_RESTORE_PRE_DT);
  2782. /*
  2783. * Restart the window manager with the initial arguments plus
  2784. * the restart settings.
  2785. */
  2786. execvp (*(wmGD.argv), wmGD.argv);
  2787. Warning (((char *)GETMESSAGE(26, 1,
  2788. "The window manager restart failed. The window manager program could not \
  2789. be found or could not be executed.")));
  2790. Do_Quit_Mwm (True);
  2791. } /* END OF FUNCTION RestartWm */
  2792. /*************************************<->*************************************
  2793. *
  2794. * DeFrameClient (pCD)
  2795. *
  2796. *
  2797. * Description:
  2798. * -----------
  2799. * Unmaps a client window (and client icon window) and reparents the
  2800. * window back to the root.
  2801. *
  2802. *
  2803. * Inputs:
  2804. * -------
  2805. * pCD = pointer to the client data for the window to be de-framed.
  2806. *
  2807. *************************************<->***********************************/
  2808. void DeFrameClient (ClientData *pCD)
  2809. {
  2810. int x, y;
  2811. int xoff, yoff;
  2812. XWindowChanges windowChanges;
  2813. while (pCD)
  2814. {
  2815. if (pCD->clientState != MINIMIZED_STATE)
  2816. {
  2817. XUnmapWindow (DISPLAY, pCD->clientFrameWin);
  2818. }
  2819. if (pCD->iconWindow && (pCD->clientFlags & ICON_REPARENTED))
  2820. {
  2821. XUnmapWindow (DISPLAY, pCD->iconWindow);
  2822. XRemoveFromSaveSet (DISPLAY, pCD->iconWindow);
  2823. XReparentWindow (DISPLAY, pCD->iconWindow,
  2824. ROOT_FOR_CLIENT(pCD), pCD->pWsList->iconX,
  2825. pCD->pWsList->iconY);
  2826. }
  2827. if (pCD->maxConfig)
  2828. {
  2829. x = pCD->maxX;
  2830. y = pCD->maxY;
  2831. }
  2832. else
  2833. {
  2834. if(wmGD.positionIsFrame)
  2835. {
  2836. CalculateGravityOffset (pCD, &xoff, &yoff);
  2837. x = pCD->clientX - xoff;
  2838. y = pCD->clientY - yoff;
  2839. }
  2840. else
  2841. {
  2842. x = pCD->clientX;
  2843. y = pCD->clientY;
  2844. }
  2845. }
  2846. #ifndef UNMAP_ON_RESTART
  2847. if (pCD->clientState == MINIMIZED_STATE)
  2848. {
  2849. XUnmapWindow (DISPLAY, pCD->client);
  2850. }
  2851. #else
  2852. XUnmapWindow (DISPLAY, pCD->client);
  2853. #endif
  2854. XRemoveFromSaveSet (DISPLAY, pCD->client);
  2855. XReparentWindow (DISPLAY, pCD->client,
  2856. ROOT_FOR_CLIENT(pCD), x, y);
  2857. if (pCD->transientChildren)
  2858. {
  2859. DeFrameClient (pCD->transientChildren);
  2860. }
  2861. /*
  2862. * restore X border
  2863. */
  2864. windowChanges.x = x;
  2865. windowChanges.y = y;
  2866. windowChanges.border_width = pCD->xBorderWidth;
  2867. XConfigureWindow (DISPLAY, pCD->client, CWBorderWidth | CWX | CWY,
  2868. &windowChanges);
  2869. if (pCD->transientLeader)
  2870. {
  2871. pCD = pCD->transientSiblings;
  2872. }
  2873. else
  2874. {
  2875. pCD = NULL;
  2876. }
  2877. }
  2878. } /* END OF FUNCTION DeFrameClient */
  2879. /******************************<->*************************************
  2880. *
  2881. * F_Toggle_Front_Panel (args, pCD, event)
  2882. *
  2883. *
  2884. * Description:
  2885. * -----------
  2886. * This is the window manager function handler for toggling the
  2887. * front panel off and on.
  2888. ******************************<->***********************************/
  2889. Boolean
  2890. F_Toggle_Front_Panel (String args, ClientData *pCD, XEvent *event)
  2891. {
  2892. WmPanelistObject pPanelist;
  2893. if (pCD)
  2894. {
  2895. pPanelist = (WmPanelistObject) pCD->pSD->wPanelist;
  2896. }
  2897. else
  2898. {
  2899. pPanelist = (WmPanelistObject) ACTIVE_PSD->wPanelist;
  2900. }
  2901. pCD = NULL;
  2902. if (pPanelist)
  2903. {
  2904. (void) XFindContext (DISPLAY, XtWindow(O_Shell(pPanelist)),
  2905. wmGD.windowContextType, (caddr_t *)&pCD);
  2906. }
  2907. if (pCD)
  2908. {
  2909. if (pCD->clientState & MINIMIZED_STATE)
  2910. {
  2911. SetClientState (pCD, NORMAL_STATE,
  2912. GetFunctionTimestamp ((XButtonEvent *)event));
  2913. }
  2914. else
  2915. {
  2916. SetClientState (pCD, MINIMIZED_STATE,
  2917. GetFunctionTimestamp ((XButtonEvent *)event));
  2918. }
  2919. }
  2920. return(True);
  2921. } /* END OF FUNCTION F_Toggle_Front_Panel */
  2922. /******************************<->*************************************
  2923. *
  2924. * Boolean F_Version (String args, ClientData *pCD, XEvent *event)
  2925. *
  2926. * Description:
  2927. * -----------
  2928. * Invoke the help on version dialogue.
  2929. *
  2930. * Inputs:
  2931. * ------
  2932. * args - incoming values
  2933. * pCD - associated client data structure
  2934. * event - what triggered this call
  2935. *
  2936. * Outputs:
  2937. * -------
  2938. * Return - True if the call occurs; false otherwise.
  2939. *
  2940. * Comments:
  2941. * --------
  2942. *
  2943. ******************************<->***********************************/
  2944. Boolean
  2945. F_Version (String args, ClientData *pCD, XEvent *event)
  2946. {
  2947. WmPanelistObject pPanelist;
  2948. if (pCD)
  2949. {
  2950. pPanelist = (WmPanelistObject) pCD->pSD->wPanelist;
  2951. }
  2952. else
  2953. {
  2954. pPanelist = (WmPanelistObject) ACTIVE_PSD->wPanelist;
  2955. }
  2956. if (pPanelist)
  2957. {
  2958. WmDtHelpOnVersion (O_Shell (pPanelist));
  2959. }
  2960. return (True);
  2961. } /* END OF FUNCTION F_Version */
  2962. /******************************<->*************************************
  2963. *
  2964. * F_Send_Msg (args, pCD, event)
  2965. *
  2966. *
  2967. * Description:
  2968. * -----------
  2969. * This is the window manager function handler for sending a client
  2970. * message event to a client window.
  2971. *
  2972. *
  2973. * Inputs:
  2974. * ------
  2975. * args = (immediate value) message id
  2976. *
  2977. * pCD = pointer to the client data
  2978. *
  2979. * event = X event that invoked the function (key, button, or menu/NULL)
  2980. *
  2981. *
  2982. ******************************<->***********************************/
  2983. Boolean F_Send_Msg (String args, ClientData *pCD, XEvent *event)
  2984. {
  2985. int i;
  2986. if (pCD && pCD->mwmMessagesCount)
  2987. {
  2988. /*
  2989. * A message id must be made "active" by being included in the
  2990. * _MWM_MESSAGES property before the associated message can be sent.
  2991. */
  2992. for (i = 0; i < pCD->mwmMessagesCount; i++)
  2993. {
  2994. if (pCD->mwmMessages[i] == (long)args)
  2995. {
  2996. SendClientMsg (pCD->client, (long) wmGD.xa_MWM_MESSAGES,
  2997. (long)args, CurrentTime, NULL, 0);
  2998. return (True);
  2999. }
  3000. }
  3001. }
  3002. return (True);
  3003. } /* END OF FUNCTION F_Send_Msg */
  3004. /*************************************<->*************************************
  3005. *
  3006. * F_Separator (args, pCD, event)
  3007. *
  3008. *
  3009. * Description:
  3010. * -----------
  3011. * This is a placeholder function; it should never be called.
  3012. *
  3013. *************************************<->***********************************/
  3014. Boolean F_Separator (String args, ClientData *pCD, XEvent *event)
  3015. {
  3016. return (True);
  3017. } /* END OF FUNCTION F_Separator */
  3018. Boolean ForceRaiseWindow (ClientData *pcd)
  3019. {
  3020. #if 0
  3021. Window stackWindow;
  3022. WmScreenData *pSD = (ACTIVE_WS)->pSD;
  3023. #endif
  3024. XWindowChanges changes;
  3025. Boolean restack = False;
  3026. #if 0
  3027. if (pSD->clientList->type == MINIMIZED_STATE)
  3028. {
  3029. stackWindow = ICON_FRAME_WIN(pSD->clientList->pCD);
  3030. }
  3031. else
  3032. {
  3033. stackWindow = pSD->clientList->pCD->clientFrameWin;
  3034. }
  3035. #endif
  3036. /*
  3037. * Windows did not raise on regular f.raise because the raise was
  3038. * not relative to another window (methinks).
  3039. */
  3040. changes.stack_mode = Above;
  3041. XConfigureWindow (DISPLAY, pcd->clientFrameWin, CWStackMode,
  3042. &changes);
  3043. return (restack);
  3044. }
  3045. /*************************************<->*************************************
  3046. *
  3047. * F_Raise (args, pCD, event)
  3048. *
  3049. *
  3050. * Description:
  3051. * -----------
  3052. * This is the window manager function handler for topping the client window
  3053. * so that it is unobscured.
  3054. *
  3055. *************************************<->***********************************/
  3056. Boolean F_Raise (String args, ClientData *pCD, XEvent *event)
  3057. {
  3058. ClientListEntry *pEntry;
  3059. ClientListEntry *pNextEntry;
  3060. ClientListEntry *pStackEntry;
  3061. String string = args;
  3062. int flags = STACK_NORMAL;
  3063. WmWorkspaceData *pWS = ACTIVE_WS;
  3064. if (string)
  3065. {
  3066. /* process '-client' argument */
  3067. if (string[0] == '-')
  3068. {
  3069. string = &string[1];
  3070. string = (String) GetString ((unsigned char **) &string);
  3071. pStackEntry = NULL;
  3072. pNextEntry = ACTIVE_PSD->clientList;
  3073. while (pNextEntry &&
  3074. (pEntry = FindClientNameMatch (pNextEntry, True, string,
  3075. F_GROUP_ALL)))
  3076. {
  3077. pNextEntry = pEntry->nextSibling;
  3078. if (ClientInWorkspace (pWS, pEntry->pCD))
  3079. {
  3080. Do_Raise (pEntry->pCD, pStackEntry, STACK_NORMAL);
  3081. pStackEntry = pEntry;
  3082. }
  3083. }
  3084. }
  3085. /* process family stacking stuff */
  3086. else if (*string)
  3087. {
  3088. unsigned int slen, len, index;
  3089. slen = strlen(args) - 2; /* subtract '\n' and NULL */
  3090. for (index = 0; index < slen; string = &args[index+1])
  3091. {
  3092. if ((string = (String) GetString ((unsigned char **) &string)) == NULL)
  3093. break;
  3094. len = strlen(string);
  3095. if (!strcmp(string,"within"))
  3096. {
  3097. flags |= STACK_WITHIN_FAMILY;
  3098. }
  3099. else if (!strcmp(string,"freeFamily"))
  3100. {
  3101. flags |= STACK_FREE_FAMILY;
  3102. }
  3103. index += len;
  3104. }
  3105. if (ClientInWorkspace (pWS, pCD))
  3106. {
  3107. Do_Raise (pCD, (ClientListEntry *) NULL, flags);
  3108. }
  3109. }
  3110. }
  3111. else if (pCD)
  3112. {
  3113. if (ClientInWorkspace (pWS, pCD))
  3114. {
  3115. Do_Raise (pCD, (ClientListEntry *) NULL, STACK_NORMAL);
  3116. }
  3117. }
  3118. return (True);
  3119. } /* END OF FUNCTION F_Raise */
  3120. /*************************************<->*************************************
  3121. *
  3122. * Do_Raise (pCD, pStackEntry)
  3123. *
  3124. *
  3125. * Description:
  3126. * -----------
  3127. * This is the window manager function handler for topping the client window
  3128. * so that it is unobscured.
  3129. *
  3130. *
  3131. * Inputs:
  3132. * ------
  3133. * pCD = pointer to the client data of the window (or icon) to be raised.
  3134. *
  3135. * pStackEntry = pointer to client list entry for window that is to be
  3136. * above the raised window (if NULL window is raised to the top of the
  3137. * stack).
  3138. *
  3139. *************************************<->***********************************/
  3140. void Do_Raise (ClientData *pCD, ClientListEntry *pStackEntry, int flags)
  3141. {
  3142. Boolean restackTransients;
  3143. ClientData *pcdLeader;
  3144. WmWorkspaceData *pWS = ACTIVE_WS;
  3145. Boolean bLeaderRestacked;
  3146. if (pCD->pECD)
  3147. {
  3148. /*
  3149. * Window has been reparented into the front panel.
  3150. * Don't follow through on window stacking change.
  3151. */
  3152. return;
  3153. }
  3154. else if (ClientInWorkspace(pWS, pCD) &&
  3155. (!pStackEntry || ClientInWorkspace (pWS, pStackEntry->pCD)))
  3156. {
  3157. /*
  3158. * Both clients are in the current workspace. Set
  3159. * client indices so that the access macros work.
  3160. */
  3161. SetClientWsIndex (pCD);
  3162. if (pStackEntry)
  3163. {
  3164. SetClientWsIndex (pStackEntry->pCD);
  3165. }
  3166. }
  3167. else
  3168. {
  3169. /*
  3170. * One or both of the clients are not in the current workspace
  3171. * Do nothing.
  3172. */
  3173. return;
  3174. }
  3175. pcdLeader = (pCD->transientLeader) ? FindTransientTreeLeader (pCD) : pCD;
  3176. if (wmGD.systemModalActive && (pcdLeader != wmGD.systemModalClient))
  3177. {
  3178. /*
  3179. * Don't raise the window above the system modal window.
  3180. */
  3181. }
  3182. else if ((pcdLeader->clientState == MINIMIZED_STATE) &&
  3183. !P_ICON_BOX(pcdLeader))
  3184. {
  3185. /*
  3186. * If a dirtyStackEntry exists, return it to its original place
  3187. * in the stack (for all stacking types)
  3188. */
  3189. if (dirtyStackEntry)
  3190. {
  3191. if (dirtyStackEntry->transientChildren ||
  3192. dirtyStackEntry->transientLeader)
  3193. RestackTransients (dirtyStackEntry);
  3194. dirtyStackEntry = NULL;
  3195. dirtyLeader = NULL;
  3196. }
  3197. /*
  3198. * Only restack the icon if it is not currently raised.
  3199. */
  3200. if (pStackEntry)
  3201. {
  3202. if (pStackEntry->nextSibling != &pcdLeader->iconEntry)
  3203. {
  3204. StackWindow (pWS, &pcdLeader->iconEntry, False /*below*/,
  3205. pStackEntry);
  3206. MoveEntryInList (pWS, &pcdLeader->iconEntry, False /*below*/,
  3207. pStackEntry);
  3208. }
  3209. }
  3210. else
  3211. {
  3212. if (ACTIVE_PSD->clientList != &pcdLeader->iconEntry)
  3213. {
  3214. StackWindow (pWS, &pcdLeader->iconEntry,
  3215. True /*on top*/, (ClientListEntry *) NULL);
  3216. MoveEntryInList (pWS, &pcdLeader->iconEntry,
  3217. True /*on top*/, (ClientListEntry *) NULL);
  3218. }
  3219. }
  3220. }
  3221. else /* NORMAL_STATE, MAXIMIZED_STATE, adoption */
  3222. {
  3223. /*
  3224. * Handle restacking of primary/secondary windows
  3225. * within the transient window tree. Don't raise this
  3226. * window above any modal transients.
  3227. */
  3228. bLeaderRestacked = False;
  3229. if ((pcdLeader->transientChildren) &&
  3230. (!pCD->secondariesOnTop) &&
  3231. (!wmGD.bSuspendSecondaryRestack) &&
  3232. (!IS_APP_MODALIZED(pCD)))
  3233. {
  3234. if (pCD != pcdLeader)
  3235. {
  3236. /*
  3237. * This is not the transient leader, make sure
  3238. * the transient leader isn't on top.
  3239. * (Brute force solution)
  3240. */
  3241. bLeaderRestacked = NormalizeTransientTreeStacking (pcdLeader);
  3242. if (pCD->transientChildren)
  3243. {
  3244. /*
  3245. * This isn't the overall leader of the transient
  3246. * tree, but it does have transient's of its own.
  3247. * Move it to the top of its own transient sub-tree.
  3248. */
  3249. bLeaderRestacked |= BumpPrimaryToTop (pCD);
  3250. }
  3251. }
  3252. else
  3253. {
  3254. /*
  3255. * This is the transient leader, move it to the
  3256. * top.
  3257. */
  3258. bLeaderRestacked = BumpPrimaryToTop (pcdLeader);
  3259. }
  3260. }
  3261. /*
  3262. * If this is a transient window then put it on top of its
  3263. * sibling transient windows.
  3264. */
  3265. restackTransients = False;
  3266. /*
  3267. * Fix for 5325 - The following code has been reorganized to cause the
  3268. * action of F_Raise to match the current documentation.
  3269. * The new algorithm is as follows:
  3270. *
  3271. * if (dirtyStackEntry)
  3272. * restore dirty tree
  3273. * if (not withinFamily)
  3274. * bring window group to the top of global stack
  3275. * if (freeFamily)
  3276. * raise the requested window to top of family
  3277. * else
  3278. * raise requested window to top of siblings
  3279. * if (need to restack windows)
  3280. * restack windows
  3281. * return
  3282. */
  3283. /*
  3284. * If a dirtyStackEntry exists, return it to its original place
  3285. * in the stack (for all stacking types)
  3286. */
  3287. if (dirtyStackEntry)
  3288. {
  3289. /*
  3290. * Check to make sure that the dirty pCD has either transient
  3291. * children or a transient leader. If not, do not restore
  3292. * the transients.
  3293. */
  3294. if (dirtyStackEntry->transientChildren ||
  3295. dirtyStackEntry->transientLeader)
  3296. RestackTransients (dirtyStackEntry);
  3297. dirtyStackEntry = NULL;
  3298. dirtyLeader = NULL;
  3299. }
  3300. /*
  3301. * If the flags do not indicate "within", raise the window family
  3302. * to the top of the window stack. If the window is the primary,
  3303. * raise it to the top regardless of the flags.
  3304. */
  3305. if (!pCD->transientLeader || !(flags & STACK_WITHIN_FAMILY))
  3306. {
  3307. if (pStackEntry)
  3308. {
  3309. if (pStackEntry->nextSibling != &pcdLeader->clientEntry)
  3310. {
  3311. StackWindow (pWS, &pcdLeader->clientEntry,
  3312. False /*below*/, pStackEntry);
  3313. MoveEntryInList (pWS, &pcdLeader->clientEntry,
  3314. False /*below*/, pStackEntry);
  3315. }
  3316. }
  3317. else
  3318. {
  3319. if (ACTIVE_PSD->clientList != &pcdLeader->clientEntry)
  3320. {
  3321. StackWindow (pWS, &pcdLeader->clientEntry,
  3322. True /*on top*/, (ClientListEntry *) NULL);
  3323. MoveEntryInList (pWS, &pcdLeader->clientEntry,
  3324. True /*on top*/, (ClientListEntry *) NULL);
  3325. }
  3326. }
  3327. }
  3328. /*
  3329. * If freeFamily stacking is requested, check to make sure that
  3330. * the window has either a transientChild or Leader. This will
  3331. * guarantee that windows that form their own family are not
  3332. * labelled as dirty (what's to dirty it up?). If it has either,
  3333. * raise the window to the top of the family stack.
  3334. */
  3335. if ((flags & STACK_FREE_FAMILY) &&
  3336. (pCD->transientLeader || pCD->transientChildren))
  3337. {
  3338. dirtyStackEntry = pCD;
  3339. dirtyLeader = pcdLeader;
  3340. restackTransients = ForceRaiseWindow (pCD);
  3341. }
  3342. /*
  3343. * If withinFamily stacking is requested, put the current transient
  3344. * on top of its sibling transient windows.
  3345. */
  3346. else
  3347. {
  3348. restackTransients = PutTransientOnTop (pCD);
  3349. }
  3350. /* At this point, if doing a regular f.raise the window family has
  3351. * already been brought to the top of the stack, so nothing further
  3352. * needs to be done for it.
  3353. */
  3354. /* Restack the transients if needed */
  3355. if ((restackTransients) || (bLeaderRestacked))
  3356. {
  3357. RestackTransients (pCD);
  3358. }
  3359. }
  3360. } /* END OF FUNCTION Do_Raise */
  3361. /*************************************<->*************************************
  3362. *
  3363. * F_Raise_Lower (args, pCD, event)
  3364. *
  3365. *
  3366. * Description:
  3367. * -----------
  3368. * This window manager function tops an obscured window or icon and bottoms
  3369. * a window or icon that is on top of the window stack.
  3370. *
  3371. *************************************<->***********************************/
  3372. Boolean F_Raise_Lower (String args, ClientData *pCD, XEvent *event)
  3373. {
  3374. ClientData *pcdLeader;
  3375. if (pCD)
  3376. {
  3377. pcdLeader = (pCD->transientLeader) ?
  3378. FindTransientTreeLeader (pCD) : pCD;
  3379. /*
  3380. * Treat a raise/lower on a window in a transient tree as if it is
  3381. * a raise/lower for the whole tree.
  3382. */
  3383. if (CheckIfClientObscuredByAny (pcdLeader))
  3384. {
  3385. /*
  3386. * The window is obscured by another window, raise the window.
  3387. */
  3388. F_Raise (NULL, pCD, (XEvent *)NULL);
  3389. }
  3390. else if (CheckIfClientObscuringAny (pcdLeader) &&
  3391. !(wmGD.systemModalActive &&
  3392. (pcdLeader == wmGD.systemModalClient)))
  3393. {
  3394. /*
  3395. * The window is obscuring another window and is
  3396. * not system modal, lower the window.
  3397. */
  3398. F_Lower (NULL, pcdLeader, (XEvent *)NULL);
  3399. if ((pcdLeader->secondariesOnTop == False) &&
  3400. (pCD->transientLeader != NULL) &&
  3401. (!IS_APP_MODALIZED(pcdLeader)))
  3402. {
  3403. /* Push transient below primary */
  3404. (void) BumpPrimaryToTop (pcdLeader);
  3405. RestackTransients (pcdLeader);
  3406. }
  3407. }
  3408. else if ((pcdLeader->secondariesOnTop == False) &&
  3409. (pcdLeader->transientChildren != NULL) &&
  3410. (!wmGD.systemModalActive) &&
  3411. (!IS_APP_MODALIZED(pcdLeader)))
  3412. {
  3413. if (LeaderOnTop(pcdLeader))
  3414. {
  3415. /* Push primary below transient */
  3416. (void) BumpPrimaryToBottom (pcdLeader);
  3417. RestackTransients (pcdLeader);
  3418. }
  3419. else
  3420. {
  3421. F_Raise (NULL, pCD, (XEvent *)NULL);
  3422. /* Push transient below primary */
  3423. (void) BumpPrimaryToTop (pcdLeader);
  3424. RestackTransients (pcdLeader);
  3425. }
  3426. }
  3427. }
  3428. return (True);
  3429. } /* END OF FUNCTION F_Raise_Lower */
  3430. /*************************************<->*************************************
  3431. *
  3432. * F_Refresh_Win (args, pCD, event)
  3433. *
  3434. *
  3435. * Description:
  3436. * -----------
  3437. * This is the window manager function handler for causing a client window
  3438. * to redisplay itself.
  3439. *
  3440. *************************************<->***********************************/
  3441. Boolean F_Refresh_Win (String args, ClientData *pCD, XEvent *event)
  3442. {
  3443. Window win;
  3444. unsigned int w, h;
  3445. if (pCD && ((pCD->clientState == NORMAL_STATE) ||
  3446. (pCD->clientState == MAXIMIZED_STATE)))
  3447. {
  3448. if (pCD->clientState == NORMAL_STATE)
  3449. {
  3450. w = (unsigned int) pCD->clientWidth;
  3451. h = (unsigned int) pCD->clientHeight;
  3452. }
  3453. else
  3454. {
  3455. w = (unsigned int) pCD->maxWidth;
  3456. h = (unsigned int) pCD->maxHeight;
  3457. }
  3458. if (wmGD.refreshByClearing)
  3459. {
  3460. RefreshByClearing (pCD->clientFrameWin);
  3461. }
  3462. else
  3463. {
  3464. /* default background_pixmap is None */
  3465. win = XCreateWindow (DISPLAY,
  3466. pCD->clientBaseWin,
  3467. pCD->matteWidth,
  3468. pCD->matteWidth,
  3469. w, h,
  3470. 0,
  3471. 0,
  3472. InputOutput,
  3473. CopyFromParent,
  3474. 0,
  3475. (XSetWindowAttributes *)NULL);
  3476. XMapWindow (DISPLAY, win);
  3477. XDestroyWindow (DISPLAY, win);
  3478. }
  3479. XFlush (DISPLAY);
  3480. }
  3481. return (True);
  3482. } /* END OF FUNCTION F_Refresh_Win */
  3483. /*************************************<->*************************************
  3484. *
  3485. * F_Set_Behavior (args, pCD, event)
  3486. *
  3487. *
  3488. * Description:
  3489. * -----------
  3490. * This function is used to switch the window manager configuration between
  3491. * the built-in configuration (for CXI behavior) and the user's custom
  3492. * configuration.
  3493. *
  3494. *************************************<->***********************************/
  3495. Boolean F_Set_Behavior (String args, ClientData *pCD, XEvent *event)
  3496. {
  3497. /*
  3498. * Go system modal in starting to do the set behavior.
  3499. */
  3500. /* !!! grab the server and the pointer !!! */
  3501. /*
  3502. * Confirm that a set_behavior should be done.
  3503. * Execute restart if so.
  3504. */
  3505. if (wmGD.showFeedback & WM_SHOW_FB_BEHAVIOR)
  3506. {
  3507. ConfirmAction (ACTIVE_PSD, (wmGD.useStandardBehavior) ?
  3508. CUSTOM_BEHAVIOR_ACTION : DEFAULT_BEHAVIOR_ACTION);
  3509. }
  3510. else
  3511. {
  3512. RestartWm ((long) ((wmGD.useStandardBehavior) ?
  3513. MWM_INFO_STARTUP_CUSTOM : MWM_INFO_STARTUP_STANDARD));
  3514. }
  3515. return (False);
  3516. } /* END OF FUNCTION F_Set_Behavior */
  3517. /*************************************<->*************************************
  3518. *
  3519. * Do_Set_Behavior (dummy)
  3520. *
  3521. *
  3522. * Description:
  3523. * -----------
  3524. * Callback to do the f.set_behavior function.
  3525. *
  3526. *************************************<->***********************************/
  3527. void Do_Set_Behavior (Boolean dummy)
  3528. {
  3529. RestartWm ((long) ((wmGD.useStandardBehavior) ?
  3530. MWM_INFO_STARTUP_CUSTOM : MWM_INFO_STARTUP_STANDARD));
  3531. } /* END OF FUNCTION Do_Set_Behavior */
  3532. /*************************************<->*************************************
  3533. *
  3534. * F_Set_Context (args, pCD, event)
  3535. *
  3536. *
  3537. * Description:
  3538. * -----------
  3539. * This function is used to set a client context for subsequent
  3540. * WM_REQUESTs
  3541. *
  3542. *************************************<->***********************************/
  3543. Boolean F_Set_Context (String args, ClientData *pCD, XEvent *event)
  3544. {
  3545. wmGD.requestContextWin = (Window) args;
  3546. return (True);
  3547. } /* END OF FUNCTION F_Set_Context */
  3548. /*************************************<->*************************************
  3549. *
  3550. * F_Title (args, pCD, event)
  3551. *
  3552. *
  3553. * Description:
  3554. * -----------
  3555. * This is a placeholder function; it should never be called.
  3556. *
  3557. *************************************<->***********************************/
  3558. Boolean F_Title (String args, ClientData *pCD, XEvent *event)
  3559. {
  3560. return (True);
  3561. } /* END OF FUNCTION F_Title */
  3562. /******************************<->*************************************
  3563. *
  3564. * F_Screen (args, pCD, event)
  3565. *
  3566. *
  3567. * Description:
  3568. * -----------
  3569. * This is the window manager function handler for warping to screens
  3570. *
  3571. *
  3572. * Inputs:
  3573. * ------
  3574. * args = (immediate value) window type flags
  3575. *
  3576. * pCD = pointer to the client data
  3577. *
  3578. * event = X event that invoked the function (key, button, or menu/NULL)
  3579. *
  3580. * NOTE: May want to consider tracking changes in screen because in
  3581. * managing a new window (ie. in ManageWindow()).
  3582. *
  3583. * Outputs:
  3584. * -------
  3585. * RETURN = if True then further button binding/function processing can
  3586. * be done for the event that caused this function to be called.
  3587. *
  3588. *************************************<->***********************************/
  3589. Boolean F_Screen (String args, ClientData *pCD, XEvent *event)
  3590. {
  3591. Window dumwin;
  3592. int x, y, dumint;
  3593. unsigned int dummask;
  3594. WmScreenData *newscr = NULL;
  3595. int scr, inc;
  3596. static int PreviousScreen = -1;
  3597. char pch[80];
  3598. if (PreviousScreen == -1)
  3599. {
  3600. PreviousScreen = DefaultScreen(DISPLAY);
  3601. }
  3602. if (strcmp (args, "next") == 0)
  3603. {
  3604. scr = ACTIVE_PSD->screen + 1;
  3605. inc = 1;
  3606. }
  3607. else if (strcmp (args, "prev") == 0)
  3608. {
  3609. scr = ACTIVE_PSD->screen - 1;
  3610. inc = -1;
  3611. }
  3612. else if (strcmp (args, "back") == 0)
  3613. {
  3614. scr = PreviousScreen;
  3615. inc = 0;
  3616. }
  3617. else
  3618. {
  3619. scr = atoi (args);
  3620. inc = 0;
  3621. }
  3622. while (!newscr) {
  3623. /* wrap around */
  3624. if (scr < 0)
  3625. scr = wmGD.numScreens - 1;
  3626. else if (scr >= wmGD.numScreens)
  3627. scr = 0;
  3628. newscr = &(wmGD.Screens[scr]);
  3629. if (!wmGD.Screens[scr].managed) { /* make sure screen is managed */
  3630. if (inc) { /* walk around the list */
  3631. scr += inc;
  3632. continue;
  3633. }
  3634. sprintf(pch,
  3635. "Unable to warp to unmanaged screen %d\n", scr);
  3636. Warning (&pch[0]);
  3637. XBell (DISPLAY, 0);
  3638. return (False);
  3639. }
  3640. }
  3641. if (ACTIVE_PSD->screen == scr) return (False); /* already on that screen */
  3642. PreviousScreen = ACTIVE_PSD->screen;
  3643. XQueryPointer (DISPLAY, ACTIVE_ROOT, &dumwin, &dumwin, &x, &y,
  3644. &dumint, &dumint, &dummask);
  3645. XWarpPointer (DISPLAY, None, newscr->rootWindow, 0, 0, 0, 0, x, y);
  3646. if (newscr && (wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_EXPLICIT))
  3647. {
  3648. /*
  3649. * Set the ACTIVE_PSD to the new screen so that Do_Focus_Key can
  3650. * uses the new screen instead of the old screen. Then call
  3651. * Do_Focus_Key with a NULL pCD to find a reasonable client to
  3652. * set focus to.
  3653. */
  3654. SetActiveScreen (newscr);
  3655. Do_Focus_Key (NULL, GetFunctionTimestamp ((XButtonEvent *)event),
  3656. ALWAYS_SET_FOCUS);
  3657. }
  3658. return (False);
  3659. }
  3660. /*************************************<->*************************************
  3661. *
  3662. * GetFunctionTimestamp (pEvent)
  3663. *
  3664. *
  3665. * Description:
  3666. * -----------
  3667. * This function is used to extract a timestamp from a key or button event.
  3668. * If the event passed in is not a key or button event then a timestamp
  3669. * is generated.
  3670. *
  3671. *
  3672. * Inputs:
  3673. * ------
  3674. * event = pointer to an X event
  3675. *
  3676. *
  3677. * Outputs:
  3678. * -------
  3679. * RETURN = a timestamp
  3680. *
  3681. *************************************<->***********************************/
  3682. Time GetFunctionTimestamp (XButtonEvent *pEvent)
  3683. {
  3684. Time time;
  3685. if (pEvent &&
  3686. (((pEvent->type == ButtonPress) || (pEvent->type == ButtonRelease)) ||
  3687. ((pEvent->type == KeyPress) || (pEvent->type == KeyRelease))))
  3688. {
  3689. time = pEvent->time;
  3690. }
  3691. else
  3692. {
  3693. time = GetTimestamp ();
  3694. }
  3695. return (time);
  3696. } /* END OF FUNCTION GetFunctionTimestamp */
  3697. /*
  3698. ** name the event mask we need for a grab in order to find the matching
  3699. ** event for an event; right now handle only button-presses
  3700. */
  3701. static unsigned int GetEventInverseMask(XEvent *event)
  3702. {
  3703. if ((XEvent*)NULL == event)
  3704. return 0;
  3705. if (ButtonPress == event->type)
  3706. return ButtonReleaseMask; /* detail ? */
  3707. /*
  3708. expansion further here
  3709. */
  3710. else
  3711. return 0;
  3712. }
  3713. /*************************************<->*************************************
  3714. *
  3715. * ClearDirtyStackEntry (pCD)
  3716. *
  3717. *
  3718. * Description:
  3719. * -----------
  3720. * This function is used to clear the static dirtyStackEntry structure and
  3721. * the dirtyLeader static variable when a pCD is destroyed. This
  3722. * guarantees that freed memory will not be accessed.
  3723. *
  3724. *
  3725. * Inputs:
  3726. * ------
  3727. * pCD = pointer to clientData being freed
  3728. *
  3729. *
  3730. * Outputs:
  3731. * -------
  3732. * RETURN = void
  3733. *
  3734. *************************************<->***********************************/
  3735. void ClearDirtyStackEntry (ClientData *pCD)
  3736. {
  3737. if (pCD == dirtyStackEntry)
  3738. {
  3739. dirtyStackEntry = NULL;
  3740. dirtyLeader = NULL;
  3741. }
  3742. }
  3743. #if defined(DEBUG)
  3744. /***********************<->*************************************
  3745. *
  3746. * F_ZZ_Debug (args, pCD, event)
  3747. *
  3748. *
  3749. * Description:
  3750. * -----------
  3751. * This is the window manager debug (multi) function
  3752. *
  3753. *
  3754. * Inputs:
  3755. * ------
  3756. * args = arguments
  3757. *
  3758. * pCD = pointer to the ClientData for the whole front panel
  3759. *
  3760. * event = X event that invoked the function (key, button, or menu/NULL)
  3761. *
  3762. *
  3763. * Outputs:
  3764. * -------
  3765. * RETURN = if True then further button binding/function processing can
  3766. * be done for the event that caused this function to be called.
  3767. *
  3768. * Comments:
  3769. * -------
  3770. * Argument 1 determines the debug function to execute:
  3771. *
  3772. * Valid arguments:
  3773. *
  3774. * "color_server_info" - dump out color server info
  3775. *
  3776. ******************************<->***********************************/
  3777. Boolean
  3778. F_ZZ_Debug (String subFcn, ClientData *pCD, XEvent *event)
  3779. {
  3780. /* Only do something is sub function is specified */
  3781. if (subFcn)
  3782. {
  3783. if (!(strcmp(subFcn, "dump_resources")))
  3784. {
  3785. int scr;
  3786. char szRes[80];
  3787. for (scr=0; scr<wmGD.numScreens; scr++)
  3788. {
  3789. sprintf (szRes, "/tmp/dtwm.resources.%d", scr);
  3790. XrmPutFileDatabase(XtScreenDatabase(
  3791. XScreenOfDisplay(DISPLAY, scr)),
  3792. szRes);
  3793. }
  3794. }
  3795. }
  3796. return (True);
  3797. }
  3798. #endif /* DEBUG */
  3799. /*************************************<->*************************************
  3800. *
  3801. * F_Next_Workspace (args, pCD, event)
  3802. *
  3803. *
  3804. * Description:
  3805. * -----------
  3806. * This function switches to the next workspace in the list
  3807. *
  3808. *************************************<->***********************************/
  3809. Boolean F_Next_Workspace (String args, ClientData *pCD, XEvent *event)
  3810. {
  3811. WmScreenData *pSD = ACTIVE_PSD;
  3812. int iwsx;
  3813. for (iwsx = 0; iwsx < pSD->numWorkspaces; iwsx++)
  3814. {
  3815. if (pSD->pWS[iwsx].id == pSD->pActiveWS->id)
  3816. {
  3817. iwsx++;
  3818. break;
  3819. }
  3820. }
  3821. /* check bounds and wrap */
  3822. if (iwsx >= pSD->numWorkspaces)
  3823. iwsx = 0;
  3824. ChangeToWorkspace (&pSD->pWS[iwsx]);
  3825. return (False);
  3826. } /* END OF FUNCTION F_Next_Workspace */
  3827. /*************************************<->*************************************
  3828. *
  3829. * F_Prev_Workspace (args, pCD, event)
  3830. *
  3831. *
  3832. * Description:
  3833. * -----------
  3834. * This function switches to the previous workspace in the list
  3835. *
  3836. *************************************<->***********************************/
  3837. Boolean F_Prev_Workspace (String args, ClientData *pCD, XEvent *event)
  3838. {
  3839. WmScreenData *pSD = ACTIVE_PSD;
  3840. int iwsx;
  3841. for (iwsx = 0; iwsx < pSD->numWorkspaces; iwsx++)
  3842. {
  3843. if (pSD->pWS[iwsx].id == pSD->pActiveWS->id)
  3844. {
  3845. iwsx--;
  3846. break;
  3847. }
  3848. }
  3849. /* check bounds and wrap */
  3850. if (iwsx < 0)
  3851. iwsx = pSD->numWorkspaces - 1;
  3852. ChangeToWorkspace (&pSD->pWS[iwsx]);
  3853. return (False);
  3854. } /* END OF FUNCTION F_Prev_Workspace */
  3855. /*************************************<->*************************************
  3856. *
  3857. * F_Workspace_Presence (args, pCD, event)
  3858. *
  3859. *
  3860. * Description:
  3861. * -----------
  3862. * This function pops up the workspace presence dialog box
  3863. *
  3864. *************************************<->***********************************/
  3865. Boolean F_Workspace_Presence (String args, ClientData *pCD, XEvent *event)
  3866. {
  3867. Context wsContext = (Context)NULL;
  3868. if (pCD && (pCD->dtwmFunctions & DtWM_FUNCTION_OCCUPY_WS))
  3869. {
  3870. if (pCD->clientState == NORMAL_STATE)
  3871. {
  3872. wsContext = F_CONTEXT_NORMAL;
  3873. }
  3874. else if (pCD->clientState == MAXIMIZED_STATE)
  3875. {
  3876. wsContext = F_CONTEXT_MAXIMIZE;
  3877. }
  3878. else
  3879. {
  3880. wsContext = F_CONTEXT_ICON;
  3881. /* return (False); */
  3882. }
  3883. ShowPresenceBox (pCD, wsContext);
  3884. }
  3885. return (False);
  3886. } /* END OF FUNCTION F_Workspace_Presence */
  3887. #ifdef DEBUG
  3888. void
  3889. DumpWindowList ()
  3890. {
  3891. WmScreenData *pSD = (ACTIVE_WS)->pSD;
  3892. ClientListEntry *pCLE;
  3893. fprintf (stdout, "Window stacking (bottom to top)\n");
  3894. pCLE = pSD->lastClient;
  3895. while (pCLE)
  3896. {
  3897. if (ClientInWorkspace (ACTIVE_WS, pCLE->pCD))
  3898. fprintf (stdout, "* ");
  3899. else
  3900. fprintf (stdout, " ");
  3901. fprintf (stdout, "%08lx\t%s\n",
  3902. pCLE->pCD->client,
  3903. pCLE->pCD->clientName);
  3904. pCLE = pCLE->prevSibling;
  3905. }
  3906. }
  3907. #endif /* DEBUG */