WmWinConf.c 97 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350
  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 OPEN SOFTWARE FOUNDATION, INC.
  25. * ALL RIGHTS RESERVED
  26. */
  27. /*
  28. * Motif Release 1.2.2
  29. */
  30. /*
  31. * (c) Copyright 1987, 1988, 1989, 1990 HEWLETT-PACKARD COMPANY */
  32. /*
  33. * Included Files:
  34. */
  35. #include "WmGlobal.h" /* This should be the first include */
  36. #include <X11/X.h>
  37. #define XK_MISCELLANY
  38. #include <X11/keysymdef.h>
  39. #define MOVE_OUTLINE_WIDTH 2
  40. #define CONFIG_MASK (KeyPressMask|ButtonPressMask|\
  41. ButtonReleaseMask|PointerMotionMask)
  42. #define PGRAB_MASK (ButtonPressMask|ButtonReleaseMask|\
  43. PointerMotionMask|PointerMotionHintMask)
  44. /* grab types */
  45. #define NotGrabbed 0
  46. #define ResizeGrab 1
  47. #define MoveGrab 2
  48. /* Anchors */
  49. #define ANCHOR_NONE 0
  50. #define ANCHOR_NW 1
  51. #define ANCHOR_NE 2
  52. #define ANCHOR_SE 3
  53. #define ANCHOR_SW 4
  54. #ifndef ABS
  55. #define ABS(x) ((x)>0?(x):(-(x)))
  56. #endif /* ABS */
  57. /* number of times to poll before blocking on a config event */
  58. #define CONFIG_POLL_COUNT 300
  59. /* mask for all buttons */
  60. #define ButtonMask \
  61. (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask)
  62. /*
  63. * include extern functions
  64. */
  65. #include "WmWinConf.h"
  66. #include "WmCDInfo.h"
  67. #include "WmCDecor.h"
  68. #include "WmCPlace.h"
  69. #include "WmEvent.h"
  70. #include "WmFeedback.h"
  71. #include "WmFunction.h"
  72. #include "WmIDecor.h"
  73. #include "WmIPC.h"
  74. #include "WmIPlace.h"
  75. #include "WmIconBox.h"
  76. #include "WmKeyFocus.h"
  77. #include "WmProtocol.h"
  78. #include "WmWinInfo.h"
  79. /*
  80. * Global Variables:
  81. *
  82. * These statics are set up at the initiation of a configuration
  83. * operation and used for succeeding events.
  84. */
  85. static int pointerX = -1;
  86. static int pointerY = -1;
  87. static int offsetX = 0;
  88. static int offsetY = 0;
  89. static int resizeX, resizeY; /* root coords of UL corner of frame */
  90. static unsigned int resizeWidth, resizeHeight; /* size of frame */
  91. static unsigned int resizeBigWidthInc, resizeBigHeightInc;
  92. static int startX, startY;
  93. static unsigned int startWidth, startHeight;
  94. static unsigned int minWidth, minHeight, maxHeight, maxWidth;
  95. static int marqueeX, marqueeY; /* root coords of UL corner of are */
  96. static long marqueeWidth, marqueeHeight; /* size of area */
  97. static unsigned int marqueeAnchor; /* id of anchor corner */
  98. static long marqueeWidth0, marqueeHeight0; /* old size of area */
  99. static int opaqueMoveX = 0; /* for cancel request on opaque moves */
  100. static int opaqueMoveY = 0;
  101. static int moveX = 0; /* root coords of UL corner of frame */
  102. static int moveY = 0;
  103. static int moveIBbbX = 0; /* root coords of icon box bulletin board */
  104. static int moveIBbbY = 0;
  105. static unsigned int moveWidth = 0; /* size of frame */
  106. static unsigned int moveHeight = 0;
  107. static int moveLastPointerX = 0; /* last pointer position */
  108. static int moveLastPointerY= 0;
  109. static Boolean anyMotion = FALSE;
  110. static Boolean configGrab = FALSE;
  111. Dimension clipWidth = 0;
  112. Dimension clipHeight = 0;
  113. Position clipX = 0;
  114. Position clipY = 0;
  115. /*************************************<->*************************************
  116. *
  117. * GetClipDimensions (pcd, fromRoot)
  118. *
  119. *
  120. * Description:
  121. * -----------
  122. *
  123. *
  124. * Inputs:
  125. * ------
  126. * pcd - pointer to client data
  127. *
  128. *
  129. * Outputs:
  130. * -------
  131. *
  132. *
  133. * Comments:
  134. * --------
  135. *************************************<->***********************************/
  136. void GetClipDimensions (ClientData *pCD, Boolean fromRoot)
  137. {
  138. int i;
  139. Arg getArgs[5];
  140. Position tmpX, tmpY;
  141. i=0;
  142. XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &clipWidth ); i++;
  143. XtSetArg (getArgs[i], XmNheight, (XtArgVal) &clipHeight ); i++;
  144. XtSetArg (getArgs[i], XmNx, (XtArgVal) &tmpX ); i++;
  145. XtSetArg (getArgs[i], XmNy, (XtArgVal) &tmpY ); i++;
  146. XtGetValues (P_ICON_BOX(pCD)->clipWidget, getArgs, i);
  147. if (fromRoot)
  148. {
  149. XtTranslateCoords(P_ICON_BOX(pCD)->scrolledWidget,
  150. tmpX, tmpY,
  151. &clipX, &clipY);
  152. }
  153. else
  154. {
  155. clipX = tmpX;
  156. clipY = tmpY;
  157. }
  158. } /* END OF FUNCTION GetClipDimensions */
  159. /*************************************<->*************************************
  160. *
  161. * HandleClientFrameMove (pcd, pev)
  162. *
  163. *
  164. * Description:
  165. * -----------
  166. * Provide visual feedback of interactive moving of the window.
  167. *
  168. *
  169. * Inputs:
  170. * ------
  171. * pcd - pointer to client data
  172. * pev - pointer to event
  173. *
  174. *
  175. * Outputs:
  176. * -------
  177. *
  178. *
  179. * Comments:
  180. * --------
  181. *************************************<->***********************************/
  182. void HandleClientFrameMove (ClientData *pcd, XEvent *pev)
  183. {
  184. int tmpX, tmpY, warpX, warpY;
  185. Window grab_win;
  186. KeySym keysym;
  187. Boolean control, moveDone;
  188. Boolean firstTime;
  189. int big_inc, keyMultiplier;
  190. int newX, newY;
  191. XEvent event, KeyEvent;
  192. if (pev) {
  193. firstTime = True;
  194. }
  195. else {
  196. firstTime = False;
  197. }
  198. big_inc = DisplayWidth (DISPLAY, SCREEN_FOR_CLIENT(pcd)) / 20;
  199. /*
  200. * Do our grabs and initial setup if we're just starting out
  201. */
  202. if (!configGrab) {
  203. if (!StartClientMove (pcd, pev))
  204. {
  205. /* configuration was not initiated */
  206. return;
  207. }
  208. }
  209. grab_win = GrabWin (pcd, pev);
  210. if (pcd->pSD->useIconBox && P_ICON_BOX(pcd))
  211. {
  212. GetClipDimensions (pcd, True);
  213. }
  214. moveDone = False;
  215. while (!moveDone)
  216. {
  217. tmpX = tmpY = 0;
  218. if (firstTime) {
  219. /* handle the event we were called with first */
  220. firstTime = False;
  221. }
  222. else
  223. {
  224. pev = &event;
  225. GetConfigEvent(DISPLAY, grab_win, CONFIG_MASK,
  226. moveLastPointerX, moveLastPointerY, moveX, moveY,
  227. moveWidth, moveHeight, &event);
  228. }
  229. if (pev->type == KeyPress)
  230. {
  231. keyMultiplier = 1;
  232. while (keyMultiplier <= big_inc &&
  233. XCheckIfEvent (DISPLAY, &KeyEvent, IsRepeatedKeyEvent,
  234. (char *) pev))
  235. {
  236. keyMultiplier++;
  237. }
  238. keysym = XKeycodeToKeysym (DISPLAY, pev->xkey.keycode, 0);
  239. control = (pev->xkey.state & ControlMask) != 0;
  240. tmpX = tmpY = 0;
  241. switch (keysym) {
  242. case XK_Left:
  243. tmpX = keyMultiplier * ((control) ? (-big_inc) : (-1));
  244. break;
  245. case XK_Up:
  246. tmpY = keyMultiplier * ((control) ? (-big_inc) : (-1));
  247. break;
  248. case XK_Right:
  249. tmpX = keyMultiplier * ((control) ? big_inc : 1);
  250. break;
  251. case XK_Down:
  252. tmpY = keyMultiplier * ((control) ? big_inc : 1);
  253. break;
  254. case XK_Return:
  255. CompleteFrameConfig (pcd, pev);
  256. return;
  257. case XK_Escape:
  258. CancelFrameConfig (pcd);
  259. CheckEatButtonRelease (pcd, pev);
  260. return;
  261. default:
  262. break;
  263. }
  264. if (tmpX || tmpY) {
  265. warpX = moveLastPointerX + tmpX;
  266. warpY = moveLastPointerY + tmpY;
  267. ForceOnScreen(SCREEN_FOR_CLIENT(pcd), &warpX, &warpY);
  268. if ((warpX != moveLastPointerX) || (warpY != moveLastPointerY))
  269. {
  270. SetPointerPosition (warpX, warpY, &newX, &newY);
  271. tmpX = newX - moveLastPointerX;
  272. tmpY = newY - moveLastPointerY;
  273. moveLastPointerX = newX;
  274. moveLastPointerY = newY;
  275. moveX += tmpX;
  276. moveY += tmpY;
  277. }
  278. else
  279. {
  280. /*
  281. * make like motion event and move frame.
  282. */
  283. moveX += tmpX;
  284. moveY += tmpY;
  285. }
  286. }
  287. }
  288. else if (pev->type == ButtonRelease)
  289. {
  290. /*
  291. * Update (x,y) to the location of the button release
  292. */
  293. moveX += pev->xbutton.x_root - moveLastPointerX;
  294. moveY += pev->xbutton.y_root - moveLastPointerY;
  295. CompleteFrameConfig (pcd, pev);
  296. moveDone = True;
  297. }
  298. else if (pev->type == MotionNotify)
  299. {
  300. tmpX = pev->xmotion.x_root - moveLastPointerX;
  301. tmpY = pev->xmotion.y_root - moveLastPointerY;
  302. moveLastPointerX = pev->xmotion.x_root;
  303. moveLastPointerY = pev->xmotion.y_root;
  304. moveX += tmpX;
  305. moveY += tmpY;
  306. anyMotion = True;
  307. }
  308. /* draw outline if there is something to draw */
  309. if (tmpX || tmpY) {
  310. FixFrameValues (pcd, &moveX, &moveY, &moveWidth, &moveHeight,
  311. FALSE /* no size checks */);
  312. if (pcd->pSD->moveOpaque)
  313. {
  314. MoveOpaque (pcd, moveX, moveY, moveWidth, moveHeight);
  315. }
  316. else
  317. {
  318. MoveOutline(moveX, moveY, moveWidth, moveHeight);
  319. }
  320. if ( !wmGD.movingIcon &&
  321. (wmGD.showFeedback & WM_SHOW_FB_MOVE))
  322. {
  323. DoFeedback (pcd, moveX, moveY, moveWidth, moveHeight,
  324. (unsigned long) 0, FALSE /* no size checks */);
  325. }
  326. }
  327. }
  328. } /* END OF FUNCTION HandleClientFrameMove */
  329. /*************************************<->*************************************
  330. *
  331. * UpdateAndDrawResize ()
  332. *
  333. *
  334. * Description:
  335. * -----------
  336. *
  337. * Inputs:
  338. * ------
  339. * pcd - pointer to client data
  340. *
  341. * Outputs:
  342. * -------
  343. *
  344. *
  345. * Comments:
  346. * --------
  347. *************************************<->***********************************/
  348. void UpdateAndDrawResize (ClientData *pcd)
  349. {
  350. int tmpHeight, tmpWidth;
  351. /*
  352. * Handle a motion event or a keypress that's like a motion
  353. * event
  354. */
  355. /* set height */
  356. switch (wmGD.configPart) {
  357. case FRAME_RESIZE_NW:
  358. case FRAME_RESIZE_N:
  359. case FRAME_RESIZE_NE:
  360. tmpHeight = (int) startHeight + (startY - pointerY);
  361. if (tmpHeight < (int) minHeight)
  362. {
  363. resizeHeight = minHeight;
  364. resizeY = startY + startHeight - minHeight;
  365. }
  366. else if (pcd->pSD->limitResize
  367. && (tmpHeight > (int) maxHeight)
  368. && (!(pcd->clientFlags & ICON_BOX)))
  369. {
  370. resizeHeight = maxHeight;
  371. resizeY = startY + startHeight - maxHeight;
  372. }
  373. else
  374. {
  375. resizeHeight = (unsigned int) tmpHeight;
  376. resizeY = pointerY;
  377. }
  378. break;
  379. case FRAME_RESIZE_SW:
  380. case FRAME_RESIZE_S:
  381. case FRAME_RESIZE_SE:
  382. resizeY = startY;
  383. tmpHeight = pointerY - startY + 1;
  384. if (tmpHeight < (int) minHeight)
  385. {
  386. resizeHeight = minHeight;
  387. }
  388. else if (pcd->pSD->limitResize
  389. && (tmpHeight > (int) maxHeight)
  390. && (!(pcd->clientFlags & ICON_BOX)))
  391. {
  392. resizeHeight = maxHeight;
  393. }
  394. else
  395. {
  396. resizeHeight = (unsigned int) tmpHeight;
  397. }
  398. break;
  399. default:
  400. resizeY = startY;
  401. resizeHeight = startHeight;
  402. break;
  403. }
  404. /* set width */
  405. switch (wmGD.configPart) {
  406. case FRAME_RESIZE_NW:
  407. case FRAME_RESIZE_W:
  408. case FRAME_RESIZE_SW:
  409. tmpWidth = (int) startWidth + (startX - pointerX);
  410. if (tmpWidth < (int) minWidth)
  411. {
  412. resizeWidth = minWidth;
  413. resizeX = startX + startWidth - minWidth;
  414. }
  415. else if (pcd->pSD->limitResize
  416. && (tmpWidth > (int) maxWidth)
  417. && (!(pcd->clientFlags & ICON_BOX)))
  418. {
  419. resizeWidth = maxWidth;
  420. resizeX = startX + startWidth - maxWidth;
  421. }
  422. else
  423. {
  424. resizeWidth = (unsigned int) tmpWidth;
  425. resizeX = pointerX;
  426. }
  427. break;
  428. case FRAME_RESIZE_NE:
  429. case FRAME_RESIZE_E:
  430. case FRAME_RESIZE_SE:
  431. resizeX = startX;
  432. tmpWidth = pointerX - startX + 1;
  433. if (tmpWidth < (int) minWidth)
  434. {
  435. resizeWidth = minWidth;
  436. }
  437. else if (pcd->pSD->limitResize
  438. && (tmpWidth > (int) maxWidth)
  439. && (!(pcd->clientFlags & ICON_BOX)))
  440. {
  441. resizeWidth = maxWidth;
  442. }
  443. else
  444. {
  445. resizeWidth = (unsigned int) tmpWidth;
  446. }
  447. break;
  448. default:
  449. resizeX = startX;
  450. resizeWidth = startWidth;
  451. break;
  452. }
  453. FixFrameValues (pcd, &resizeX, &resizeY, &resizeWidth,
  454. &resizeHeight, TRUE /* do size checks */);
  455. MoveOutline (resizeX, resizeY, resizeWidth, resizeHeight);
  456. if (wmGD.showFeedback & WM_SHOW_FB_RESIZE)
  457. {
  458. DoFeedback(pcd, resizeX, resizeY, resizeWidth, resizeHeight,
  459. (unsigned long) 0, TRUE /* do size checks */);
  460. }
  461. }
  462. /*************************************<->*************************************
  463. *
  464. * HandleClientFrameResize (pcd, pev)
  465. *
  466. *
  467. * Description:
  468. * -----------
  469. * Provide visual feedback of interactive resizing of the window.
  470. *
  471. *
  472. * Inputs:
  473. * ------
  474. * pcd - pointer to client data
  475. * pev - pointer to event
  476. *
  477. *
  478. * Outputs:
  479. * -------
  480. *
  481. *
  482. * Comments:
  483. * --------
  484. * o The window sizes refer to the frame, not the client window.
  485. *
  486. *************************************<->***********************************/
  487. void HandleClientFrameResize (ClientData *pcd, XEvent *pev)
  488. {
  489. Window grab_win;
  490. Boolean resizeDone;
  491. XEvent event;
  492. /*
  493. * Do our grabs the first time through
  494. */
  495. if (!configGrab) {
  496. if (StartResizeConfig (pcd, pev))
  497. {
  498. configGrab = TRUE;
  499. }
  500. else
  501. {
  502. /* resize could not be initiated */
  503. return;
  504. }
  505. }
  506. grab_win = GrabWin (pcd, pev);
  507. resizeDone = False;
  508. while (!resizeDone)
  509. {
  510. if (!pev) /* first time through will already have event */
  511. {
  512. pev = &event;
  513. GetConfigEvent(DISPLAY, grab_win, CONFIG_MASK,
  514. pointerX, pointerY, resizeX, resizeY,
  515. resizeWidth, resizeHeight, &event);
  516. }
  517. if (pev->type == MotionNotify)
  518. {
  519. pointerX = pev->xmotion.x_root;
  520. pointerY = pev->xmotion.y_root;
  521. anyMotion = TRUE;
  522. /*
  523. * Really start resizing once the pointer hits a resize area
  524. * (This only applies to accelerator and keyboard resizing!)
  525. */
  526. if (!wmGD.configSet && !SetPointerResizePart (pcd, pev)) {
  527. pev = NULL;
  528. continue; /* ignore this event */
  529. }
  530. }
  531. else if (pev->type == KeyPress) {
  532. /*
  533. * Handle key event.
  534. */
  535. resizeDone = HandleResizeKeyPress (pcd, pev);
  536. }
  537. else if (pev->type == ButtonRelease) {
  538. /*
  539. * Update (x,y) to the location of the button release
  540. */
  541. pointerX = pev->xbutton.x_root;
  542. pointerY = pev->xbutton.y_root;
  543. UpdateAndDrawResize(pcd);
  544. CompleteFrameConfig (pcd, pev);
  545. resizeDone = True;
  546. }
  547. else {
  548. pev = NULL;
  549. continue; /* ignore this event */
  550. }
  551. if (!resizeDone)
  552. {
  553. UpdateAndDrawResize(pcd);
  554. }
  555. pev = NULL; /* reset event pointer */
  556. } /* end while */
  557. } /* END OF FUNCTION HandleClientFrameResize */
  558. /*************************************<->*************************************
  559. *
  560. * HandleResizeKeyPress (pcd, pev)
  561. *
  562. *
  563. * Description:
  564. * -----------
  565. * Handles keypress events during resize of window
  566. *
  567. *
  568. * Inputs:
  569. * ------
  570. * pcd - pointer to client data
  571. * pev - pointer to event
  572. *
  573. *
  574. * Outputs:
  575. * -------
  576. * Return - True if this event completes (or cancels) resizing
  577. *
  578. *
  579. * Comments:
  580. * --------
  581. *
  582. *************************************<->***********************************/
  583. Boolean HandleResizeKeyPress (ClientData *pcd, XEvent *pev)
  584. {
  585. KeySym keysym;
  586. Boolean control;
  587. int warpX, warpY, currentX = 0, currentY = 0, newX, newY;
  588. int junk, keyMult;
  589. Window junk_win;
  590. XEvent KeyEvent;
  591. /*
  592. * Compress repeated keys
  593. */
  594. keyMult = 1;
  595. while (keyMult <= 10 &&
  596. XCheckIfEvent (DISPLAY, &KeyEvent, IsRepeatedKeyEvent,
  597. (char *) pev))
  598. {
  599. keyMult++;
  600. }
  601. keysym = XKeycodeToKeysym (DISPLAY, pev->xkey.keycode, 0);
  602. control = (pev->xkey.state & ControlMask) != 0;
  603. switch (keysym) {
  604. case XK_Left:
  605. switch (wmGD.configPart) {
  606. case FRAME_NONE:
  607. wmGD.configPart = FRAME_RESIZE_W;
  608. ReGrabPointer(pcd->clientFrameWin, pev->xkey.time);
  609. warpY = resizeY + resizeHeight/2;
  610. warpX = resizeX + ((control) ?
  611. (-resizeBigWidthInc) :
  612. (-pcd->widthInc));
  613. break;
  614. case FRAME_RESIZE_N:
  615. wmGD.configPart = FRAME_RESIZE_NW;
  616. ReGrabPointer(pcd->clientFrameWin, pev->xkey.time);
  617. warpX = resizeX + ((control) ?
  618. (-resizeBigWidthInc) :
  619. (-pcd->widthInc));
  620. warpY = pointerY;
  621. break;
  622. case FRAME_RESIZE_S:
  623. wmGD.configPart = FRAME_RESIZE_SW;
  624. ReGrabPointer(pcd->clientFrameWin, pev->xkey.time);
  625. warpX = resizeX + ((control) ?
  626. (-resizeBigWidthInc) :
  627. (-pcd->widthInc));
  628. warpY = pointerY;
  629. break;
  630. default:
  631. warpX = pointerX + ((control) ?
  632. (-resizeBigWidthInc * keyMult) :
  633. (-pcd->widthInc * keyMult));
  634. warpY = pointerY;
  635. break;
  636. }
  637. break;
  638. case XK_Up:
  639. switch (wmGD.configPart) {
  640. case FRAME_NONE:
  641. wmGD.configPart = FRAME_RESIZE_N;
  642. warpX = resizeX + resizeWidth/2;
  643. warpY = resizeY + ((control) ?
  644. (-resizeBigHeightInc) :
  645. (-pcd->heightInc));
  646. ReGrabPointer(pcd->clientFrameWin, pev->xkey.time);
  647. break;
  648. case FRAME_RESIZE_W:
  649. wmGD.configPart = FRAME_RESIZE_NW;
  650. ReGrabPointer(pcd->clientFrameWin, pev->xkey.time);
  651. warpX = pointerX;
  652. warpY = resizeY + ((control) ?
  653. (-resizeBigHeightInc) :
  654. (-pcd->heightInc));
  655. break;
  656. case FRAME_RESIZE_E:
  657. wmGD.configPart = FRAME_RESIZE_NE;
  658. ReGrabPointer(pcd->clientFrameWin, pev->xkey.time);
  659. warpX = pointerX;
  660. warpY = resizeY + ((control) ?
  661. (-resizeBigHeightInc) :
  662. (-pcd->heightInc));
  663. break;
  664. default:
  665. warpX = pointerX;
  666. warpY = pointerY + ((control) ?
  667. (-resizeBigHeightInc * keyMult) :
  668. (-pcd->heightInc * keyMult));
  669. break;
  670. }
  671. break;
  672. case XK_Right:
  673. switch (wmGD.configPart) {
  674. case FRAME_NONE:
  675. wmGD.configPart = FRAME_RESIZE_E;
  676. warpY = resizeY + resizeHeight/2;
  677. warpX = resizeX + resizeWidth - 1 +
  678. ((control) ? resizeBigWidthInc :
  679. pcd->widthInc);
  680. ReGrabPointer(pcd->clientFrameWin, pev->xkey.time);
  681. break;
  682. case FRAME_RESIZE_N:
  683. wmGD.configPart = FRAME_RESIZE_NE;
  684. ReGrabPointer(pcd->clientFrameWin, pev->xkey.time);
  685. warpX = resizeX + resizeWidth - 1 +
  686. ((control) ? resizeBigWidthInc :
  687. pcd->widthInc);
  688. warpY = pointerY;
  689. break;
  690. case FRAME_RESIZE_S:
  691. wmGD.configPart = FRAME_RESIZE_SE;
  692. ReGrabPointer(pcd->clientFrameWin, pev->xkey.time);
  693. warpX = resizeX + resizeWidth - 1 +
  694. ((control) ? resizeBigWidthInc :
  695. pcd->widthInc);
  696. warpY = pointerY;
  697. break;
  698. default:
  699. warpX = pointerX + ((control) ?
  700. (resizeBigWidthInc * keyMult) :
  701. (pcd->widthInc * keyMult));
  702. warpY = pointerY;
  703. break;
  704. }
  705. break;
  706. case XK_Down:
  707. switch (wmGD.configPart) {
  708. case FRAME_NONE:
  709. wmGD.configPart = FRAME_RESIZE_S;
  710. warpX = resizeX + resizeWidth/2;
  711. warpY = resizeY + resizeHeight - 1 +
  712. ((control) ? resizeBigHeightInc :
  713. pcd->heightInc);
  714. ReGrabPointer(pcd->clientFrameWin, pev->xkey.time);
  715. break;
  716. case FRAME_RESIZE_E:
  717. wmGD.configPart = FRAME_RESIZE_SE;
  718. ReGrabPointer(pcd->clientFrameWin, pev->xkey.time);
  719. warpX = pointerX;
  720. warpY = resizeY + resizeHeight - 1 +
  721. ((control) ? resizeBigHeightInc :
  722. pcd->heightInc);
  723. break;
  724. case FRAME_RESIZE_W:
  725. wmGD.configPart = FRAME_RESIZE_SW;
  726. ReGrabPointer(pcd->clientFrameWin, pev->xkey.time);
  727. warpX = pointerX;
  728. warpY = resizeY + resizeHeight - 1 +
  729. ((control) ? resizeBigHeightInc :
  730. pcd->heightInc);
  731. break;
  732. default:
  733. warpX = pointerX;
  734. warpY = pointerY + ((control) ?
  735. (resizeBigHeightInc * keyMult) :
  736. (pcd->heightInc * keyMult));
  737. break;
  738. }
  739. break;
  740. case XK_Return:
  741. CompleteFrameConfig (pcd, pev);
  742. return (True);
  743. case XK_Escape:
  744. CancelFrameConfig (pcd);
  745. CheckEatButtonRelease (pcd, pev);
  746. return (True);
  747. default:
  748. return (False); /* ignore this key */
  749. } /* end switch(keysym) */
  750. /*
  751. * Make sure the new pointer position is on screen before doing
  752. * the warp. Warp only if the pointer position changes.
  753. */
  754. pointerX = warpX;
  755. pointerY = warpY;
  756. ForceOnScreen(SCREEN_FOR_CLIENT(pcd), &warpX, &warpY);
  757. /*
  758. * Don't query pointer if enable warp is off.
  759. */
  760. if (!wmGD.enableWarp ||
  761. XQueryPointer (DISPLAY, ROOT_FOR_CLIENT(pcd), &junk_win, &junk_win,
  762. &currentX, &currentY, &junk, &junk, (unsigned int *)&junk))
  763. {
  764. if ( (warpX != currentX) || (warpY != currentY) )
  765. {
  766. SetPointerPosition (warpX, warpY, &newX, &newY);
  767. return (False);
  768. }
  769. }
  770. return (False);
  771. } /* END OF FUNCTION HandleResizeKeyPress */
  772. /*************************************<->*************************************
  773. *
  774. * DoFeedback (pcd, x, y, width, height, newStyle, resizing)
  775. *
  776. *
  777. * Description:
  778. * -----------
  779. * Start or update feedback of size/position info
  780. *
  781. *
  782. * Inputs:
  783. * ------
  784. * pcd - pointer to client data
  785. * x -
  786. * y -
  787. * width -
  788. * height -
  789. * newStyle - style flags.
  790. * resizing - check size constraints iff TRUE
  791. *
  792. *
  793. * Outputs:
  794. * -------
  795. *
  796. *
  797. * Comments:
  798. * --------
  799. * o If newStyle has FB_POSITION and/or FB_SIZE bits set, then it is
  800. * assumed that this is an initial call and a feedback window of the
  801. * desired style should be popped up. If newStyle is zero, then it
  802. * is assumed that the feedback window is already up and the values
  803. * passed in are updates.
  804. *
  805. *************************************<->***********************************/
  806. void DoFeedback (ClientData *pcd, int x, int y, unsigned int width, unsigned int height, unsigned long newStyle, Boolean resizing)
  807. {
  808. int cx = x;
  809. int cy = y;
  810. unsigned int cwidth, cheight;
  811. /* compute client window coordinates from frame coordinates */
  812. FrameToClient (pcd, &cx, &cy, &width, &height);
  813. /* use frame (not client) position if user wishes it */
  814. if (wmGD.positionIsFrame) {
  815. cx = x;
  816. cy = y;
  817. }
  818. /* If resizing, make sure configuration is valid. */
  819. if (resizing)
  820. {
  821. FixWindowConfiguration (pcd, &width, &height,
  822. (unsigned int) pcd->widthInc,
  823. (unsigned int) pcd->heightInc);
  824. }
  825. /*
  826. * Put size in client specific units. Do not include base into calculations
  827. * when increment is not specified (i.e. = 1).
  828. */
  829. cwidth = (width - ((pcd->widthInc==1) ? 0 : pcd->baseWidth))
  830. / pcd->widthInc;
  831. cheight = (height - ((pcd->heightInc==1) ? 0 : pcd->baseHeight))
  832. / pcd->heightInc;
  833. if (newStyle) {
  834. ShowFeedbackWindow (pcd->pSD, cx, cy, cwidth, cheight, newStyle);
  835. }
  836. else {
  837. UpdateFeedbackInfo (pcd->pSD, cx, cy, cwidth, cheight);
  838. }
  839. } /* END OF FUNCTION DoFeedback */
  840. /*************************************<->*************************************
  841. *
  842. * CheckVisualPlace
  843. *
  844. *
  845. * Description:
  846. * -----------
  847. * Prevents icons in the icon box from being moved outside the clip window
  848. *
  849. *
  850. * Inputs:
  851. * ------
  852. * pcd - pointer to client data
  853. *
  854. *
  855. * Outputs:
  856. * -------
  857. *
  858. *
  859. * Comments:
  860. * --------
  861. *
  862. *************************************<->***********************************/
  863. Boolean CheckVisualPlace (ClientData *pCD, int tmpX, int tmpY)
  864. {
  865. Boolean rval = True;
  866. Window child;
  867. int newX;
  868. int newY;
  869. GetClipDimensions(pCD, True);
  870. /*
  871. * Get root coordinates of X and Y for icon.
  872. * We use root coordinates of clip window since clipX and
  873. * clipY are not 0, but the icon X and Y may be 0 in
  874. * local coordinates
  875. */
  876. XTranslateCoordinates(DISPLAY, XtWindow(P_ICON_BOX(pCD)->bBoardWidget),
  877. ROOT_FOR_CLIENT(pCD), tmpX, tmpY,
  878. &newX, &newY, &child);
  879. if (newX < clipX)
  880. {
  881. return(False);
  882. }
  883. if (newY < clipY)
  884. {
  885. return(False);
  886. }
  887. if (((int)newX) > ((int)clipX +
  888. (int)clipWidth - ((int)ICON_WIDTH(pCD))))
  889. {
  890. return(False);
  891. }
  892. if (((int)newY) > ((int)clipY +
  893. (int)clipHeight - ((int)ICON_HEIGHT(pCD))))
  894. {
  895. return(False);
  896. }
  897. return (rval);
  898. } /* END OF FUNCTION CheckVisualPlace */
  899. /*************************************<->*************************************
  900. *
  901. * CompleteFrameConfig (pcd, pev)
  902. *
  903. *
  904. * Description:
  905. * -----------
  906. * Clean up graphic feedback when user stops configuring.
  907. *
  908. *
  909. * Inputs:
  910. * ------
  911. * pcd - pointer to client data
  912. * pev - pointer to event
  913. *
  914. *
  915. * Outputs:
  916. * -------
  917. *
  918. *
  919. * Comments:
  920. * --------
  921. * o This routine assumes that it is called in response to a button release
  922. * event.
  923. *
  924. *************************************<->***********************************/
  925. void CompleteFrameConfig (ClientData *pcd, XEvent *pev)
  926. {
  927. unsigned int tmpWidth, tmpHeight;
  928. int tmpX, tmpY;
  929. Boolean inIconBox;
  930. if (wmGD.configAction == RESIZE_CLIENT) {
  931. /* release the grabs */
  932. UndoGrabs();
  933. /*
  934. * Honor the implied constrained anchor points on the window
  935. * so that the resize doesn't cause the window to move
  936. * unexpectedly.
  937. */
  938. tmpX = resizeX;
  939. tmpY = resizeY;
  940. /* Use dummy x,y so we don't add frame offset to client location */
  941. FrameToClient (pcd, &tmpX, &tmpY, &resizeWidth, &resizeHeight);
  942. tmpWidth = resizeWidth;
  943. tmpHeight = resizeHeight;
  944. FixWindowConfiguration (pcd, &tmpWidth, &tmpHeight,
  945. (unsigned int) pcd->widthInc,
  946. (unsigned int) pcd->heightInc);
  947. AdjustPos (&resizeX, &resizeY,
  948. resizeWidth, resizeHeight, tmpWidth, tmpHeight);
  949. /* reconfigure the window(s) */
  950. ProcessNewConfiguration (pcd, resizeX, resizeY,
  951. resizeWidth, resizeHeight, FALSE);
  952. }
  953. else if (wmGD.configAction == MOVE_CLIENT)
  954. {
  955. /* release the grabs */
  956. UndoGrabs();
  957. /* make sure title bar is popped out */
  958. if ((wmGD.configAction == MOVE_CLIENT) &&
  959. (wmGD.gadgetClient == pcd) &&
  960. (wmGD.gadgetDepressed == FRAME_TITLE))
  961. {
  962. PopGadgetOut (pcd, FRAME_TITLE);
  963. FrameExposureProc(pcd); /* repaint frame */
  964. }
  965. /* handle both icon and normal frames */
  966. if (wmGD.movingIcon)
  967. {
  968. inIconBox = (pcd->pSD->useIconBox && P_ICON_BOX(pcd));
  969. /* only need to move the icon */
  970. if (wmGD.iconAutoPlace || inIconBox)
  971. {
  972. int centerX;
  973. int centerY;
  974. int place;
  975. IconPlacementData *pIPD;
  976. /*
  977. * Get correct icon placement data
  978. */
  979. if (inIconBox)
  980. {
  981. pIPD = &P_ICON_BOX(pcd)->IPD;
  982. moveX -= moveIBbbX;
  983. moveY -= moveIBbbY;
  984. }
  985. else
  986. {
  987. pIPD = &(ACTIVE_WS->IPData);
  988. }
  989. /*
  990. * Check to make sure that there is an unoccupied place
  991. * where the icon is being moved to:
  992. */
  993. centerX = moveX + ICON_WIDTH(pcd) / 2;
  994. centerY = moveY + ICON_HEIGHT(pcd) / 2;
  995. place = CvtIconPositionToPlace (pIPD, centerX, centerY);
  996. if (place != ICON_PLACE(pcd))
  997. {
  998. if (pIPD->placeList[place].pCD)
  999. {
  1000. /*
  1001. * Primary place occupied, try to find an unoccupied
  1002. * place in the proximity.
  1003. */
  1004. place = FindIconPlace (pcd, pIPD, centerX, centerY);
  1005. if (place == NO_ICON_PLACE)
  1006. {
  1007. /*
  1008. * Can't find an unoccupied icon place.
  1009. */
  1010. F_Beep (NULL, pcd, (XEvent *)NULL);
  1011. if (pcd->pSD->moveOpaque && !inIconBox)
  1012. {
  1013. /*
  1014. * Replace icon into same place - as if it
  1015. * didn't move.
  1016. */
  1017. XMoveWindow (DISPLAY, ICON_FRAME_WIN(pcd),
  1018. ICON_X(pcd), ICON_Y(pcd));
  1019. if ((ICON_DECORATION(pcd) &
  1020. ICON_ACTIVE_LABEL_PART) &&
  1021. (wmGD.keyboardFocus == pcd))
  1022. {
  1023. MoveActiveIconText(pcd);
  1024. ShowActiveIconText(pcd);
  1025. }
  1026. }
  1027. }
  1028. }
  1029. if ((place != NO_ICON_PLACE) &&
  1030. (place != ICON_PLACE(pcd)))
  1031. {
  1032. if (inIconBox)
  1033. {
  1034. CvtIconPlaceToPosition (pIPD, place,
  1035. &tmpX, &tmpY);
  1036. if( (CheckIconBoxSize (P_ICON_BOX(pcd))) &&
  1037. (CheckVisualPlace(pcd, tmpX, tmpY)))
  1038. {
  1039. /*
  1040. * Move the icon to the new place.
  1041. */
  1042. MoveIconInfo (pIPD, ICON_PLACE(pcd), place);
  1043. CvtIconPlaceToPosition (pIPD, place,
  1044. &ICON_X(pcd), &ICON_Y(pcd));
  1045. XtMoveWidget (
  1046. pIPD->placeList[ICON_PLACE(pcd)].theWidget,
  1047. ICON_X(pcd), ICON_Y(pcd));
  1048. SetNewBounds (P_ICON_BOX(pcd));
  1049. if (ICON_DECORATION(pcd) &
  1050. ICON_ACTIVE_LABEL_PART)
  1051. {
  1052. MoveActiveIconText(pcd);
  1053. }
  1054. }
  1055. else
  1056. {
  1057. F_Beep (NULL, pcd, (XEvent *)NULL);
  1058. }
  1059. }
  1060. else
  1061. {
  1062. /*
  1063. * Move the icon to the new place.
  1064. */
  1065. MoveIconInfo (pIPD, ICON_PLACE(pcd), place);
  1066. CvtIconPlaceToPosition (pIPD, place, &ICON_X(pcd),
  1067. &ICON_Y(pcd));
  1068. XMoveWindow (DISPLAY, ICON_FRAME_WIN(pcd),
  1069. ICON_X(pcd), ICON_Y(pcd));
  1070. if (pcd->pSD->moveOpaque &&
  1071. (ICON_DECORATION(pcd) &
  1072. ICON_ACTIVE_LABEL_PART) &&
  1073. (wmGD.keyboardFocus == pcd))
  1074. {
  1075. MoveActiveIconText(pcd);
  1076. ShowActiveIconText(pcd);
  1077. }
  1078. }
  1079. }
  1080. }
  1081. else if (pcd->pSD->moveOpaque && !inIconBox)
  1082. {
  1083. /*
  1084. * Replace icon into same place - as if it
  1085. * didn't move.
  1086. */
  1087. XMoveWindow (DISPLAY, ICON_FRAME_WIN(pcd),
  1088. ICON_X(pcd), ICON_Y(pcd));
  1089. if ((ICON_DECORATION(pcd) &
  1090. ICON_ACTIVE_LABEL_PART) &&
  1091. (wmGD.keyboardFocus == pcd))
  1092. {
  1093. MoveActiveIconText(pcd);
  1094. ShowActiveIconText(pcd);
  1095. }
  1096. }
  1097. }
  1098. else
  1099. {
  1100. XMoveWindow (DISPLAY, ICON_FRAME_WIN(pcd), moveX, moveY);
  1101. ICON_X(pcd) = moveX;
  1102. ICON_Y(pcd) = moveY;
  1103. }
  1104. if ((ICON_DECORATION(pcd) & ICON_ACTIVE_LABEL_PART) &&
  1105. (wmGD.keyboardFocus == pcd))
  1106. {
  1107. MoveActiveIconText(pcd);
  1108. }
  1109. }
  1110. else { /* assume normal window frame */
  1111. /* reconfigure the window(s) */
  1112. ProcessNewConfiguration (pcd,
  1113. moveX,
  1114. moveY,
  1115. (unsigned int)
  1116. (moveWidth - 2*offsetX),
  1117. (unsigned int)
  1118. (moveHeight - offsetX - offsetY),
  1119. FALSE);
  1120. }
  1121. }
  1122. else if (wmGD.configAction == MARQUEE_SELECT)
  1123. {
  1124. WmScreenData *pSD;
  1125. UndoGrabs();
  1126. pSD = pcd ? pcd->pSD : ACTIVE_PSD;
  1127. dtSendMarqueeSelectionNotification(pSD, DT_MARQUEE_SELECT_END,
  1128. marqueeX, marqueeY, marqueeWidth, marqueeHeight);
  1129. }
  1130. /*
  1131. * Clear configuration flags and data.
  1132. */
  1133. wmGD.configAction = NO_ACTION;
  1134. wmGD.configPart = FRAME_NONE;
  1135. wmGD.configSet = False;
  1136. configGrab = FALSE;
  1137. anyMotion = FALSE;
  1138. wmGD.movingIcon = FALSE;
  1139. if (pcd)
  1140. {
  1141. /* hide the move/resize config data */
  1142. HideFeedbackWindow(pcd->pSD);
  1143. /*
  1144. * Set the focus back to something reasonable
  1145. */
  1146. RepairFocus ();
  1147. }
  1148. } /* END OF FUNCTION CompleteFrameConfig */
  1149. /*************************************<->*************************************
  1150. *
  1151. * MoveOpaque (pcd, x, y, width, height)
  1152. *
  1153. *
  1154. * Description:
  1155. * -----------
  1156. * Move a window or icon on the root or icon box.
  1157. *
  1158. *
  1159. * Inputs:
  1160. * ------
  1161. * pcd - client data pointer
  1162. * x - x coordinate (on root)
  1163. * y - y coordinate (on root)
  1164. * width - pixel width of frame
  1165. * height - pixel height of frame
  1166. *
  1167. * Outputs:
  1168. * -------
  1169. *
  1170. *
  1171. * Comments:
  1172. * --------
  1173. * o use MoveOutline() for icons in an icon box.
  1174. *
  1175. *************************************<->***********************************/
  1176. void MoveOpaque (ClientData *pcd, int x, int y,
  1177. unsigned int width, unsigned int height)
  1178. {
  1179. /* Check if moving icon */
  1180. if (wmGD.movingIcon)
  1181. {
  1182. if (pcd->pSD->useIconBox && P_ICON_BOX(pcd))
  1183. {
  1184. /*
  1185. * For now just fall back to move outline when the
  1186. * icon is in the icon box
  1187. */
  1188. MoveOutline (x, y, width, height);
  1189. }
  1190. else
  1191. {
  1192. XMoveWindow (DISPLAY,ICON_FRAME_WIN(pcd) , x, y);
  1193. }
  1194. }
  1195. else
  1196. {
  1197. /* This is a window */
  1198. XMoveWindow (DISPLAY, pcd->clientFrameWin, x, y);
  1199. }
  1200. /* cleanup exposed frame parts */
  1201. PullExposureEvents ();
  1202. } /* END OF FUNCTION MoveOpaque */
  1203. /* thickness of outline */
  1204. #define OUTLINE_WIDTH 2
  1205. /* number of points to draw outline once */
  1206. #define SEGS_PER_DRAW (4*OUTLINE_WIDTH)
  1207. /* number of points to flash outline (draw then erase) */
  1208. #define SEGS_PER_FLASH (2*SEGS_PER_DRAW)
  1209. /*************************************<->*************************************
  1210. *
  1211. * DrawSegments (dpy, win, gc, outline, nsegs)
  1212. *
  1213. * Description:
  1214. * -----------
  1215. * Draw segments using either using normal X or using the ALLPLANES
  1216. * extension, depending on #ifdef ALLPLANES and whether the server actually
  1217. * supports the extension. This is a thin wrapper around the Xlib
  1218. * XDrawSegments() call.
  1219. *
  1220. * Inputs:
  1221. * ------
  1222. * dpy - the X display
  1223. * win - the window on which to draw
  1224. * gc - the gc to use, typically whose function is GXxor
  1225. * outline - array of segments
  1226. * nsegs - number of segments in the outline array
  1227. *
  1228. * Outputs:
  1229. * -------
  1230. * (none)
  1231. *
  1232. * Comments:
  1233. * --------
  1234. * Note: no GC is used when drawing with the ALLPLANES extension;
  1235. * therefore, the GC parameter is ignored in that case.
  1236. *
  1237. *************************************<->***********************************/
  1238. static void
  1239. DrawSegments (Display *dpy, Window win, GC gc, XSegment *outline, int nsegs)
  1240. {
  1241. #if defined(sun) && defined(ALLPLANES)
  1242. if (wmGD.allplanes)
  1243. XAllPlanesDrawSegments(dpy, win, outline, nsegs);
  1244. else
  1245. #endif /* defined(sun) && defined(ALLPLANES) */
  1246. XDrawSegments(dpy, win, gc, outline, nsegs);
  1247. } /* END OF FUNCTION DrawSegments */
  1248. /*************************************<->*************************************
  1249. *
  1250. * MoveOutline (x, y, width, height)
  1251. *
  1252. *
  1253. * Description:
  1254. * -----------
  1255. * Draw a window outline on the root window.
  1256. *
  1257. *
  1258. * Inputs:
  1259. * ------
  1260. * x - x coordinate (on root)
  1261. * y - y coordinate (on root)
  1262. * width - pixel width of frame
  1263. * height - pixel height of frame
  1264. *
  1265. * Outputs:
  1266. * -------
  1267. *
  1268. *
  1269. * Comments:
  1270. * --------
  1271. * o get display, root window ID, and xorGC out of global data.
  1272. *
  1273. *************************************<->***********************************/
  1274. void MoveOutline (int x, int y, unsigned int width, unsigned int height)
  1275. {
  1276. if (wmGD.freezeOnConfig)
  1277. {
  1278. DrawOutline (x, y, width, height);
  1279. }
  1280. else
  1281. {
  1282. if (wmGD.useWindowOutline)
  1283. WindowOutline(x,y,width,height);
  1284. else
  1285. FlashOutline(x, y, width, height);
  1286. }
  1287. } /* END OF FUNCTION MoveOutline */
  1288. /*************************************<->*************************************
  1289. *
  1290. * FlashOutline ()
  1291. *
  1292. *
  1293. * Description:
  1294. * -----------
  1295. * flash a window outline on the root window.
  1296. *
  1297. *
  1298. * Inputs:
  1299. * ------
  1300. * x - x coordinate (on root)
  1301. * y - y coordinate (on root)
  1302. * width - pixel width of frame
  1303. * height - pixel height of frame
  1304. *
  1305. * Outputs:
  1306. * -------
  1307. *
  1308. *
  1309. * Comments:
  1310. * --------
  1311. * o get display, root window ID, and xorGC out of global data.
  1312. * o draw on root and erase "atomically"
  1313. *
  1314. *************************************<->***********************************/
  1315. void FlashOutline (int x, int y, unsigned int width, unsigned int height)
  1316. {
  1317. static XSegment outline[SEGS_PER_FLASH];
  1318. /*
  1319. * Do nothing if no box to draw
  1320. */
  1321. if (x == 0 && y == 0 &&
  1322. width == 0 && height == 0)
  1323. return;
  1324. /*
  1325. * Draw outline an even number of times (draw then erase)
  1326. */
  1327. SetOutline (outline, x, y, width, height, OUTLINE_WIDTH);
  1328. memcpy ( (char *) &outline[SEGS_PER_DRAW], (char *) &outline[0],
  1329. SEGS_PER_DRAW*sizeof(XSegment));
  1330. /*
  1331. * Flash the outline at least once, then as long as there's
  1332. * nothing else going on
  1333. */
  1334. DrawSegments(DISPLAY, ACTIVE_ROOT, ACTIVE_PSD->xorGC,
  1335. outline, SEGS_PER_FLASH);
  1336. XSync(DISPLAY, FALSE);
  1337. while (!XtAppPending(wmGD.mwmAppContext)) {
  1338. DrawSegments(DISPLAY, ACTIVE_ROOT, ACTIVE_PSD->xorGC,
  1339. outline, SEGS_PER_FLASH);
  1340. XSync(DISPLAY, FALSE);
  1341. }
  1342. } /* END OF FUNCTION FlashOutline */
  1343. /*************************************<->*************************************
  1344. *
  1345. * CreateOutlineWindows (pSD)
  1346. *
  1347. *
  1348. * Description:
  1349. * -----------
  1350. * create the outline windows
  1351. *
  1352. *
  1353. * Inputs:
  1354. * ------
  1355. *
  1356. * Outputs:
  1357. * -------
  1358. *
  1359. * Comments:
  1360. * --------
  1361. * variables are affected:
  1362. * woN
  1363. * woS
  1364. * woE
  1365. * woW
  1366. *
  1367. *************************************<->***********************************/
  1368. static void
  1369. CreateOutlineWindows (WmScreenData *pSD)
  1370. {
  1371. XSetWindowAttributes xswa;
  1372. unsigned int xswamask;
  1373. int x, y, width, height;
  1374. x = -10;
  1375. y = -10;
  1376. width = OUTLINE_WIDTH;
  1377. height = OUTLINE_WIDTH;
  1378. xswa.override_redirect = True;
  1379. xswa.backing_store = NotUseful;
  1380. xswa.save_under = True;
  1381. xswa.background_pixmap = XmGetPixmap(
  1382. XtScreen(pSD->screenTopLevelW),
  1383. "50_foreground",
  1384. pSD->clientAppearance.foreground,
  1385. pSD->clientAppearance.background);
  1386. xswamask = (CWOverrideRedirect |
  1387. CWBackingStore |
  1388. CWBackPixmap |
  1389. CWSaveUnder);
  1390. pSD->woN = XCreateWindow(DISPLAY, pSD->rootWindow,
  1391. x, y, width, height,
  1392. 0,
  1393. XDefaultDepth(DISPLAY,pSD->screen),
  1394. CopyFromParent,
  1395. CopyFromParent,
  1396. xswamask,
  1397. &xswa);
  1398. pSD->woS = XCreateWindow(DISPLAY, pSD->rootWindow,
  1399. x, y, width, height,
  1400. 0,
  1401. XDefaultDepth(DISPLAY,pSD->screen),
  1402. CopyFromParent,
  1403. CopyFromParent,
  1404. xswamask,
  1405. &xswa);
  1406. pSD->woE = XCreateWindow(DISPLAY, pSD->rootWindow,
  1407. x, y, width, height,
  1408. 0,
  1409. XDefaultDepth(DISPLAY,pSD->screen),
  1410. CopyFromParent,
  1411. CopyFromParent,
  1412. xswamask,
  1413. &xswa);
  1414. pSD->woW = XCreateWindow(DISPLAY, pSD->rootWindow,
  1415. x, y, width, height,
  1416. 0,
  1417. XDefaultDepth(DISPLAY,pSD->screen),
  1418. CopyFromParent,
  1419. CopyFromParent,
  1420. xswamask,
  1421. &xswa);
  1422. } /* END OF FUNCTION CreateOutlineWindows */
  1423. /*************************************<->*************************************
  1424. *
  1425. * WindowOutline ()
  1426. *
  1427. *
  1428. * Description:
  1429. * -----------
  1430. * show an outline on the root window using windows.
  1431. *
  1432. *
  1433. * Inputs:
  1434. * ------
  1435. * x - x coordinate (on root)
  1436. * y - y coordinate (on root)
  1437. * width - pixel width of frame
  1438. * height - pixel height of frame
  1439. *
  1440. * Outputs:
  1441. * -------
  1442. *
  1443. *
  1444. * Comments:
  1445. * --------
  1446. * Always unmap during move/resize of outline windows to let saveunder
  1447. * stuff work. HP server's toss saveunder stuff for windows that
  1448. * configure themselves while mapped.
  1449. *
  1450. *************************************<->***********************************/
  1451. void WindowOutline (int x, int y, unsigned int width, unsigned int height)
  1452. {
  1453. static int lastOutlineX = 0;
  1454. static int lastOutlineY = 0;
  1455. static int lastOutlineWidth = 0;
  1456. static int lastOutlineHeight = 0;
  1457. WmScreenData *pSD = ACTIVE_PSD;
  1458. int iX, iY;
  1459. int iW, iH;
  1460. if (pSD->woN == (Window)0L)
  1461. {
  1462. CreateOutlineWindows(pSD);
  1463. }
  1464. if (x == lastOutlineX && y == lastOutlineY &&
  1465. width == lastOutlineWidth && height == lastOutlineHeight)
  1466. {
  1467. return; /* no change */
  1468. }
  1469. XUnmapWindow(DISPLAY, pSD->woN);
  1470. XUnmapWindow(DISPLAY, pSD->woS);
  1471. XUnmapWindow(DISPLAY, pSD->woE);
  1472. XUnmapWindow(DISPLAY, pSD->woW);
  1473. if ((width == 0) && (height == 0))
  1474. {
  1475. lastOutlineWidth = lastOutlineHeight = 0;
  1476. lastOutlineX = lastOutlineY = 0;
  1477. }
  1478. else
  1479. {
  1480. /* North */
  1481. iX = x;
  1482. iY = y;
  1483. iW = (int) width;
  1484. iH = OUTLINE_WIDTH;
  1485. if (iW < 0) iW = 1;
  1486. XMoveResizeWindow (DISPLAY, pSD->woN, iX, iY, iW, iH);
  1487. /* West */
  1488. iX = x;
  1489. iY = y + OUTLINE_WIDTH;
  1490. iW = OUTLINE_WIDTH;
  1491. iH = (int) height - OUTLINE_WIDTH;
  1492. if (iH < 0) iH = 1;
  1493. XMoveResizeWindow (DISPLAY, pSD->woW, iX, iY, iW, iH);
  1494. /* East */
  1495. iX = x + (int)width - OUTLINE_WIDTH;
  1496. iY = y + OUTLINE_WIDTH;
  1497. iW = OUTLINE_WIDTH;
  1498. iH = (int)height - OUTLINE_WIDTH;
  1499. if (iH < 0) iH = 1;
  1500. XMoveResizeWindow (DISPLAY, pSD->woE, iX, iY, iW, iH);
  1501. /* South */
  1502. iX = x + OUTLINE_WIDTH;
  1503. iY = y + (int)height - OUTLINE_WIDTH;
  1504. iW = (int)width - 2*OUTLINE_WIDTH;
  1505. iH = OUTLINE_WIDTH;
  1506. if (iW < 0) iW = 1;
  1507. XMoveResizeWindow (DISPLAY, pSD->woS, iX, iY, iW, iH);
  1508. lastOutlineX = x;
  1509. lastOutlineY = y;
  1510. lastOutlineWidth = width;
  1511. lastOutlineHeight = height;
  1512. XMapRaised (DISPLAY, pSD->woN);
  1513. XMapRaised (DISPLAY, pSD->woS);
  1514. XMapRaised (DISPLAY, pSD->woE);
  1515. XMapRaised (DISPLAY, pSD->woW);
  1516. /* cleanup exposed frame parts */
  1517. PullExposureEvents ();
  1518. }
  1519. } /* END OF FUNCTION WindowOutline */
  1520. /*************************************<->*************************************
  1521. *
  1522. * DrawOutline (x, y, width, height)
  1523. *
  1524. *
  1525. * Description:
  1526. * -----------
  1527. * Draw a window outline on the root window.
  1528. *
  1529. *
  1530. * Inputs:
  1531. * ------
  1532. * x - x coordinate (on root)
  1533. * y - y coordinate (on root)
  1534. * width - pixel width of frame
  1535. * height - pixel height of frame
  1536. *
  1537. * Outputs:
  1538. * -------
  1539. *
  1540. *
  1541. * Comments:
  1542. * --------
  1543. * o get display, root window ID, and xorGC out of global data.
  1544. *
  1545. *************************************<->***********************************/
  1546. void DrawOutline (int x, int y, unsigned int width, unsigned int height)
  1547. {
  1548. static int lastOutlineX = 0;
  1549. static int lastOutlineY = 0;
  1550. static int lastOutlineWidth = 0;
  1551. static int lastOutlineHeight = 0;
  1552. XSegment outline[SEGS_PER_DRAW];
  1553. if (x == lastOutlineX && y == lastOutlineY &&
  1554. width == lastOutlineWidth && height == lastOutlineHeight)
  1555. {
  1556. return; /* no change */
  1557. }
  1558. if (lastOutlineWidth || lastOutlineHeight) {
  1559. SetOutline (outline, lastOutlineX, lastOutlineY, lastOutlineWidth,
  1560. lastOutlineHeight, OUTLINE_WIDTH);
  1561. DrawSegments(DISPLAY, ACTIVE_ROOT, ACTIVE_PSD->xorGC,
  1562. outline, SEGS_PER_DRAW);
  1563. }
  1564. lastOutlineX = x;
  1565. lastOutlineY = y;
  1566. lastOutlineWidth = width;
  1567. lastOutlineHeight = height;
  1568. if (lastOutlineWidth || lastOutlineHeight) {
  1569. SetOutline (outline, lastOutlineX, lastOutlineY, lastOutlineWidth,
  1570. lastOutlineHeight, OUTLINE_WIDTH);
  1571. DrawSegments(DISPLAY, ACTIVE_ROOT, ACTIVE_PSD->xorGC,
  1572. outline, SEGS_PER_DRAW);
  1573. }
  1574. } /* END OF FUNCTION DrawOutline */
  1575. /*************************************<->*************************************
  1576. *
  1577. * WindowIsOnScreen (pCD, dx, dy)
  1578. *
  1579. *
  1580. * Description:
  1581. * -----------
  1582. * This function is used to check if a window is atleast partially on the
  1583. * screen or not. If the window is completely off the screen, dx and dy
  1584. * will contain the minimum distance to move some part of the window's frame
  1585. * back onto the screen.
  1586. *
  1587. *
  1588. * Inputs:
  1589. * ------
  1590. * pCD - pointer to client data
  1591. *
  1592. *
  1593. * Outputs:
  1594. * -------
  1595. * dx - minimum x distance to move the window back to the screen
  1596. * dy - minimum y distance to move the window back to the screen
  1597. *
  1598. *
  1599. * Returns:
  1600. * --------
  1601. * true - if the window has some part on the screen
  1602. * false - if the window is completely off the screen
  1603. *
  1604. * Comments:
  1605. * --------
  1606. *
  1607. *************************************<->***********************************/
  1608. Boolean WindowIsOnScreen (ClientData *pCD, int *dx, int *dy)
  1609. {
  1610. int x1 = pCD->clientX;
  1611. int x2 = pCD->clientX + pCD->clientWidth;
  1612. int y1 = pCD->clientY;
  1613. int y2 = pCD->clientY + pCD->clientHeight;
  1614. int screenW = DisplayWidth (DISPLAY, SCREEN_FOR_CLIENT(pCD));
  1615. int screenH = DisplayHeight(DISPLAY, SCREEN_FOR_CLIENT(pCD));
  1616. *dx = *dy = 0;
  1617. if (x2 < 0) /* right frame border off left side of screen. */
  1618. *dx = -x2;
  1619. else if (x1 > screenW) /* left frame border off right side of screen. */
  1620. *dx = screenW - x1;
  1621. if (y2 < 0) /* bottom frame border off top of screen. */
  1622. *dy = -y2;
  1623. else if (y1 > screenH) /* top frame border off bottom of screen. */
  1624. *dy = screenH - y1;
  1625. return ((*dx == 0) && (*dy == 0));
  1626. }
  1627. /*************************************<->*************************************
  1628. *
  1629. * ProcessNewConfiguration (pCD, x, y, width, height, clientRequest)
  1630. *
  1631. *
  1632. * Description:
  1633. * -----------
  1634. * This function is used to configure a client window following receipt of
  1635. * a client request or an interactive configuration action.
  1636. *
  1637. *
  1638. * Inputs:
  1639. * ------
  1640. * pCD - pointer to client data
  1641. * x - x coord of client window
  1642. * y - y coord of client window
  1643. * width - width of client window
  1644. * height - height of client window
  1645. * clientRequest - true if configuration requested by client program
  1646. *
  1647. *
  1648. * Outputs:
  1649. * -------
  1650. *
  1651. *
  1652. * Comments:
  1653. * --------
  1654. *
  1655. *************************************<->***********************************/
  1656. void ProcessNewConfiguration (ClientData *pCD, int x, int y, unsigned int width, unsigned int height, Boolean clientRequest)
  1657. {
  1658. unsigned int changedValues = 0;
  1659. int xoff = 0, yoff = 0;
  1660. int dx, dy;
  1661. Boolean originallyOnScreen = WindowIsOnScreen(pCD, &dx, &dy);
  1662. Boolean newMax = False;
  1663. Boolean toNewMax = False;
  1664. /*
  1665. * Fix the configuration values to be compatible with the configuration
  1666. * constraints for this class of windows.
  1667. */
  1668. FixWindowConfiguration (pCD, &width, &height,
  1669. (unsigned int) pCD->widthInc,
  1670. (unsigned int) pCD->heightInc);
  1671. if ((pCD->maxWidth != pCD->oldMaxWidth) ||
  1672. (pCD->maxHeight != pCD->oldMaxHeight))
  1673. {
  1674. /*
  1675. * We've got a new maximum size.
  1676. */
  1677. newMax = True;
  1678. }
  1679. /*
  1680. * If the configuration has changed, update client data
  1681. *
  1682. * Changes in width or height cause maximized windows to return to
  1683. * normal state and update normal geometry (x, y, width, height)
  1684. */
  1685. if (pCD->maxConfig)
  1686. {
  1687. if (newMax &&
  1688. (pCD->maxWidth == width) &&
  1689. (pCD->maxHeight == height))
  1690. {
  1691. /* we're changing to the new max size */
  1692. toNewMax = True;
  1693. }
  1694. changedValues |= (width != pCD->oldMaxWidth) ? CWWidth : 0;
  1695. changedValues |= (height != pCD->oldMaxHeight) ? CWHeight : 0;
  1696. if (!toNewMax && (changedValues & CWWidth)) {
  1697. /*
  1698. * Hacked to update maxWidth for 'vertical' max clients
  1699. */
  1700. if (IS_MAXIMIZE_VERTICAL(pCD)) {
  1701. pCD->maxWidth = width;
  1702. }
  1703. pCD->clientWidth = width;
  1704. if (changedValues & CWHeight) {
  1705. /*
  1706. * Hacked to update maxHeight for 'horizontal' max client
  1707. */
  1708. if (IS_MAXIMIZE_HORIZONTAL(pCD)) {
  1709. pCD->maxHeight = height;
  1710. }
  1711. pCD->clientHeight = height;
  1712. }
  1713. else {
  1714. pCD->clientHeight = pCD->oldMaxHeight;
  1715. }
  1716. }
  1717. else if (!toNewMax && (changedValues & CWHeight)) {
  1718. /*
  1719. * Hacked to update maxHeight for 'horizontal' max client
  1720. */
  1721. if (IS_MAXIMIZE_HORIZONTAL(pCD)) {
  1722. pCD->maxHeight = height;
  1723. }
  1724. pCD->clientHeight = height;
  1725. pCD->clientWidth = pCD->oldMaxWidth;
  1726. }
  1727. }
  1728. else {
  1729. if (width != pCD->clientWidth)
  1730. {
  1731. /*
  1732. * Hacked to update maxWidth for 'vertical' max clients
  1733. */
  1734. if (IS_MAXIMIZE_VERTICAL(pCD)) {
  1735. pCD->maxWidth = width;
  1736. }
  1737. changedValues |= CWWidth;
  1738. pCD->clientWidth = width;
  1739. }
  1740. if (height != pCD->clientHeight)
  1741. {
  1742. /*
  1743. * Hacked to update maxHeight for 'horizontal' max client
  1744. */
  1745. if (IS_MAXIMIZE_HORIZONTAL(pCD)) {
  1746. pCD->maxHeight = height;
  1747. }
  1748. changedValues |= CWHeight;
  1749. pCD->clientHeight = height;
  1750. }
  1751. }
  1752. /*
  1753. * If positionIsFrame or user initiated configuration request,
  1754. * then adjust client position to by frame_width and frame_height.
  1755. */
  1756. if (wmGD.positionIsFrame || (!clientRequest))
  1757. {
  1758. xoff = pCD->clientOffset.x;
  1759. yoff = pCD->clientOffset.y;
  1760. }
  1761. /*
  1762. * Changes in position update maximum geometry on maximized windows
  1763. * if there was no change in size.
  1764. */
  1765. if (pCD->maxConfig) {
  1766. if (x != pCD->maxX) {
  1767. changedValues |= CWX;
  1768. if (!toNewMax && (changedValues & (CWWidth | CWHeight)))
  1769. pCD->clientX = x + xoff;
  1770. else
  1771. pCD->maxX = x + xoff;
  1772. }
  1773. else if (!toNewMax && (changedValues & (CWWidth | CWHeight)))
  1774. {
  1775. pCD->clientX = pCD->maxX;
  1776. }
  1777. if (y != pCD->maxY) {
  1778. changedValues |= CWY;
  1779. if (!toNewMax && (changedValues & (CWWidth | CWHeight)))
  1780. pCD->clientY = y + yoff;
  1781. else
  1782. pCD->maxY = y + yoff;
  1783. }
  1784. else if (!toNewMax && (changedValues & (CWWidth | CWHeight)))
  1785. {
  1786. pCD->clientY = pCD->maxY;
  1787. }
  1788. }
  1789. else {
  1790. if (x + xoff != pCD->clientX) {
  1791. changedValues |= CWX;
  1792. pCD->clientX = x + xoff;
  1793. }
  1794. if (y + yoff != pCD->clientY) {
  1795. changedValues |= CWY;
  1796. pCD->clientY = y + yoff;
  1797. }
  1798. }
  1799. /* check if the window has reconfigured itself off the screen. */
  1800. if (originallyOnScreen && !WindowIsOnScreen(pCD, &dx, &dy))
  1801. {
  1802. if (dx != 0)
  1803. {
  1804. changedValues |= CWX;
  1805. pCD->clientX += dx;
  1806. }
  1807. if (dy != 0)
  1808. {
  1809. changedValues |= CWY;
  1810. pCD->clientY += dy;
  1811. }
  1812. }
  1813. /*
  1814. * Resize the client window if necessary:
  1815. */
  1816. if (changedValues & (CWWidth | CWHeight))
  1817. {
  1818. if (pCD->maxConfig)
  1819. {
  1820. if (!toNewMax)
  1821. {
  1822. /* maximized window resized, return to normal state */
  1823. pCD->maxConfig = FALSE;
  1824. pCD->clientState = NORMAL_STATE;
  1825. }
  1826. }
  1827. XResizeWindow (DISPLAY, pCD->client, width, height);
  1828. RegenerateClientFrame(pCD);
  1829. }
  1830. if (changedValues & (CWX | CWY)) {
  1831. if (pCD->maxConfig)
  1832. {
  1833. /*
  1834. * Fix for 5217 - If the request is from the client, use the clients
  1835. * offsets instead of the static offsets
  1836. */
  1837. if (clientRequest)
  1838. {
  1839. XMoveWindow (DISPLAY, pCD->clientFrameWin,
  1840. pCD->maxX - pCD->clientOffset.x,
  1841. pCD->maxY - pCD->clientOffset.y);
  1842. }
  1843. else
  1844. {
  1845. XMoveWindow (DISPLAY, pCD->clientFrameWin,
  1846. pCD->maxX - offsetX,
  1847. pCD->maxY - offsetY);
  1848. }
  1849. /* End fix 5217 */
  1850. }
  1851. else
  1852. {
  1853. if (clientRequest)
  1854. {
  1855. XMoveWindow (DISPLAY, pCD->clientFrameWin,
  1856. pCD->clientX - pCD->clientOffset.x,
  1857. pCD->clientY - pCD->clientOffset.y);
  1858. }
  1859. else
  1860. {
  1861. XMoveWindow (DISPLAY, pCD->clientFrameWin,
  1862. pCD->clientX - offsetX,
  1863. pCD->clientY - offsetY);
  1864. }
  1865. }
  1866. SetFrameInfo (pCD);
  1867. if (pCD->dtwmBehaviors & DtWM_BEHAVIOR_SUBPANEL)
  1868. {
  1869. /* turn off subpanel behavior if moved */
  1870. pCD->dtwmBehaviors &= ~DtWM_BEHAVIOR_SUBPANEL;
  1871. }
  1872. }
  1873. /*
  1874. * Send a configure notify message if appropriate:
  1875. * 1. rejected client configuration request.
  1876. * 2. client request and move without resize
  1877. */
  1878. if ((!changedValues && clientRequest) ||
  1879. (changedValues && !(changedValues & (CWWidth | CWHeight))))
  1880. {
  1881. SendConfigureNotify (pCD);
  1882. }
  1883. /*
  1884. * Try to send notice directly to icon box that the window
  1885. * has changed size
  1886. */
  1887. if ((pCD->clientFlags & ICON_BOX) &&
  1888. (changedValues & (CWWidth | CWHeight)))
  1889. {
  1890. CheckIconBoxResize(pCD, changedValues, width, height);
  1891. }
  1892. } /* END OF FUNCTION ProcessNewConfiguration */
  1893. /*************************************<->*************************************
  1894. *
  1895. * StartResizeConfig (pcd, pev)
  1896. *
  1897. *
  1898. * Description:
  1899. * -----------
  1900. * Start resize of client window
  1901. *
  1902. *
  1903. * Inputs:
  1904. * ------
  1905. * pcd - pointer to client data
  1906. * pev - pointer to event
  1907. *
  1908. * Outputs:
  1909. * -------
  1910. * return - true if configuration can begin, else false
  1911. *
  1912. *
  1913. * Comments:
  1914. * --------
  1915. *
  1916. *************************************<->***********************************/
  1917. Boolean StartResizeConfig (ClientData *pcd, XEvent *pev)
  1918. {
  1919. Window grab_win, junk_win;
  1920. Boolean grabbed;
  1921. int big_inc, tmp_inc;
  1922. int junk, junkX, junkY;
  1923. /*
  1924. * Do our grabs
  1925. */
  1926. if (!configGrab)
  1927. {
  1928. grab_win = GrabWin (pcd, pev);
  1929. if (pev)
  1930. {
  1931. grabbed = DoGrabs (grab_win, ConfigCursor((int) wmGD.configPart),
  1932. PGRAB_MASK, pev->xbutton.time, pcd, True);
  1933. }
  1934. else
  1935. {
  1936. grabbed = DoGrabs (grab_win, ConfigCursor((int) wmGD.configPart),
  1937. PGRAB_MASK, CurrentTime, pcd, True);
  1938. }
  1939. if (!grabbed)
  1940. {
  1941. return (False);
  1942. }
  1943. configGrab = TRUE;
  1944. }
  1945. else
  1946. {
  1947. /* continue with the configuration in progress (!!!) */
  1948. return (True);
  1949. }
  1950. /*
  1951. * Set up static variables for succeeding events
  1952. */
  1953. if (!XQueryPointer (DISPLAY, ROOT_FOR_CLIENT(pcd), &junk_win, &junk_win,
  1954. &pointerX, &pointerY, &junk, &junk, (unsigned int *)&junk))
  1955. {
  1956. CancelFrameConfig (pcd); /* release grabs */
  1957. return (False);
  1958. };
  1959. wmGD.preMoveX = pointerX;
  1960. wmGD.preMoveY = pointerY;
  1961. anyMotion = FALSE;
  1962. offsetX = pcd->clientOffset.x;
  1963. offsetY = pcd->clientOffset.y;
  1964. /*
  1965. * get window geometry information and convert to frame coordinates
  1966. */
  1967. if (pcd->maxConfig) {
  1968. resizeX = pcd->maxX;
  1969. resizeY = pcd->maxY;
  1970. resizeWidth = pcd->maxWidth;
  1971. resizeHeight = pcd->maxHeight;
  1972. }
  1973. else {
  1974. resizeX = pcd->clientX;
  1975. resizeY = pcd->clientY;
  1976. resizeWidth = pcd->clientWidth;
  1977. resizeHeight = pcd->clientHeight;
  1978. }
  1979. ClientToFrame(pcd, &resizeX, &resizeY, &resizeWidth, &resizeHeight);
  1980. /* save start values to see where we came from */
  1981. startX = resizeX;
  1982. startY = resizeY;
  1983. startWidth = resizeWidth;
  1984. startHeight = resizeHeight;
  1985. /* get min and max frame sizes */
  1986. minWidth = pcd->minWidth;
  1987. minHeight = pcd->minHeight;
  1988. junkX = junkY = 0;
  1989. ClientToFrame(pcd, &junkX, &junkY, &minWidth, &minHeight);
  1990. /*
  1991. * Hack to use maxHeightLimit and maxWidthLimit as the real max when
  1992. * maximumClientSize is set to 'horizontal' or 'vertical', since
  1993. * pCD->maxHeight and pCD->maxWidth is fiddle to on reconfiguration.
  1994. */
  1995. maxWidth = pcd->maxWidthLimit;
  1996. maxHeight = pcd->maxHeightLimit;
  1997. junkX = junkY = 0;
  1998. ClientToFrame(pcd, &junkX, &junkY, &maxWidth, &maxHeight);
  1999. /* compute big increment values */
  2000. big_inc = DisplayWidth (DISPLAY, SCREEN_FOR_CLIENT(pcd)) / 20;
  2001. tmp_inc = big_inc - big_inc%pcd->widthInc;
  2002. if (tmp_inc > 5*pcd->widthInc)
  2003. resizeBigWidthInc = tmp_inc;
  2004. else
  2005. resizeBigWidthInc = 5*pcd->widthInc;
  2006. tmp_inc = big_inc - big_inc%pcd->heightInc;
  2007. if (tmp_inc > 5*pcd->heightInc)
  2008. resizeBigHeightInc = tmp_inc;
  2009. else
  2010. resizeBigHeightInc = 5*pcd->heightInc;
  2011. /* pop up feedback window */
  2012. if (wmGD.showFeedback & WM_SHOW_FB_RESIZE)
  2013. {
  2014. DoFeedback (pcd, resizeX, resizeY, resizeWidth, resizeHeight,
  2015. FB_SIZE, TRUE /* do size checks */);
  2016. }
  2017. /* set configuring data */
  2018. wmGD.configAction = RESIZE_CLIENT;
  2019. wmGD.configButton = pev ? pev->xbutton.button: 0;
  2020. return (True);
  2021. } /* END OF FUNCTION StartResizeConfig */
  2022. /*************************************<->*************************************
  2023. *
  2024. * StartClientResize (pcd, pev)
  2025. *
  2026. *
  2027. * Description:
  2028. * -----------
  2029. * Start resize of client window as invoked from menu
  2030. *
  2031. *
  2032. * Inputs:
  2033. * ------
  2034. * pcd - pointer to client data
  2035. * pev - pointer to event
  2036. *
  2037. * Outputs:
  2038. * -------
  2039. *
  2040. *
  2041. * Comments:
  2042. * --------
  2043. * o This should only be called as the result of a Resize function
  2044. * being selected from the system menu.
  2045. *
  2046. *************************************<->***********************************/
  2047. void StartClientResize (ClientData *pcd, XEvent *pev)
  2048. {
  2049. /* do initial setup for resize */
  2050. wmGD.configPart = FRAME_NONE; /* determined by later action */
  2051. wmGD.configSet = False; /* don't know what it is yet */
  2052. if (!StartResizeConfig (pcd, pev))
  2053. {
  2054. /* resize could not be initiated */
  2055. return;
  2056. }
  2057. /*
  2058. * Warp pointer to middle of window if started from the keyboard
  2059. * or menu (no event).
  2060. */
  2061. if ( !pev || pev->type == KeyPress )
  2062. {
  2063. pointerX = resizeX + resizeWidth/2;
  2064. pointerY = resizeY + resizeHeight/2;
  2065. ForceOnScreen(SCREEN_FOR_CLIENT(pcd), &pointerX, &pointerY);
  2066. if (wmGD.enableWarp)
  2067. {
  2068. XWarpPointer(DISPLAY, None, ROOT_FOR_CLIENT(pcd),
  2069. 0, 0, 0, 0, pointerX, pointerY);
  2070. }
  2071. }
  2072. } /* END OF FUNCTION StartClientResize */
  2073. /*************************************<->*************************************
  2074. *
  2075. * StartClientMove (pcd, pev)
  2076. *
  2077. *
  2078. * Description:
  2079. * -----------
  2080. * Handle move of client window as invoked from menu
  2081. *
  2082. *
  2083. * Inputs:
  2084. * ------
  2085. * pcd - pointer to client data
  2086. * pev - pointer to event
  2087. *
  2088. * Outputs:
  2089. * -------
  2090. * Return - True if configuration was initiated, else False
  2091. *
  2092. *
  2093. * Comments:
  2094. * --------
  2095. * o This should only be called as the result of a Move function
  2096. * being selected from the system menu.
  2097. *
  2098. *************************************<->***********************************/
  2099. Boolean StartClientMove (ClientData *pcd, XEvent *pev)
  2100. {
  2101. Window grab_win, junk_win;
  2102. Boolean grabbed;
  2103. int junk;
  2104. Window child;
  2105. /*
  2106. * Do our grabs if we're just starting out
  2107. */
  2108. if (!configGrab)
  2109. {
  2110. grab_win = GrabWin (pcd, pev);
  2111. if (grab_win == ICON_FRAME_WIN(pcd))
  2112. {
  2113. wmGD.movingIcon = True;
  2114. }
  2115. if (pev)
  2116. {
  2117. grabbed = DoGrabs (grab_win, wmGD.configCursor,
  2118. PGRAB_MASK, pev->xbutton.time, pcd, False);
  2119. }
  2120. else
  2121. {
  2122. grabbed = DoGrabs (grab_win, wmGD.configCursor,
  2123. PGRAB_MASK, CurrentTime, pcd, False);
  2124. }
  2125. if (!grabbed)
  2126. {
  2127. wmGD.movingIcon = False;
  2128. return (False);
  2129. }
  2130. configGrab = TRUE;
  2131. }
  2132. /*
  2133. * Set up static variables for succeeding events if we're not
  2134. * entering with a motion event. If we are, we assume that the
  2135. * preMove variables have been setup.
  2136. */
  2137. if (pev && ((pev->type == ButtonPress) || (pev->type == ButtonRelease)))
  2138. {
  2139. wmGD.preMoveX = pev->xbutton.x_root;
  2140. wmGD.preMoveY = pev->xbutton.y_root;
  2141. }
  2142. else if ((pev && (pev->type != MotionNotify)) || !pev)
  2143. {
  2144. if (!XQueryPointer (DISPLAY, ROOT_FOR_CLIENT(pcd),
  2145. &junk_win, &junk_win,
  2146. &(wmGD.preMoveX), &(wmGD.preMoveY),
  2147. &junk, &junk, (unsigned int *)&junk))
  2148. {
  2149. CancelFrameConfig (pcd);
  2150. return (False);
  2151. }
  2152. }
  2153. offsetX = pcd->clientOffset.x;
  2154. offsetY = pcd->clientOffset.y;
  2155. anyMotion = FALSE;
  2156. moveLastPointerX = wmGD.preMoveX;
  2157. moveLastPointerY = wmGD.preMoveY;
  2158. /* get frame window geometry */
  2159. if (wmGD.movingIcon)
  2160. {
  2161. moveWidth = ICON_WIDTH(pcd);
  2162. moveHeight = ICON_HEIGHT(pcd);
  2163. moveX = ICON_X(pcd);
  2164. moveY = ICON_Y(pcd);
  2165. if (pcd->pSD->useIconBox && P_ICON_BOX(pcd))
  2166. {
  2167. /* get root coords of icon box bulletin board */
  2168. XTranslateCoordinates(DISPLAY,
  2169. XtWindow(P_ICON_BOX(pcd)->bBoardWidget), ROOT_FOR_CLIENT(pcd),
  2170. 0, 0, &moveIBbbX, &moveIBbbY, &child);
  2171. moveX += moveIBbbX;
  2172. moveY += moveIBbbY;
  2173. }
  2174. else if (pcd->pSD->moveOpaque &&
  2175. (ICON_DECORATION(pcd) & ICON_ACTIVE_LABEL_PART) &&
  2176. (wmGD.keyboardFocus == pcd))
  2177. {
  2178. HideActiveIconText ((WmScreenData *)NULL);
  2179. }
  2180. }
  2181. else
  2182. {
  2183. if (pcd->maxConfig) { /* maximized */
  2184. moveWidth = pcd->maxWidth;
  2185. moveHeight = pcd->maxHeight;
  2186. moveX = pcd->maxX;
  2187. moveY = pcd->maxY;
  2188. }
  2189. else { /* normal */
  2190. moveWidth = pcd->clientWidth;
  2191. moveHeight = pcd->clientHeight;
  2192. moveX = pcd->clientX;
  2193. moveY = pcd->clientY;
  2194. }
  2195. ClientToFrame (pcd, &moveX, &moveY, &moveWidth, &moveHeight);
  2196. }
  2197. if (pcd->pSD->moveOpaque)
  2198. {
  2199. opaqueMoveX = moveX;
  2200. opaqueMoveY = moveY;
  2201. }
  2202. /*
  2203. * Warp pointer to middle of window if started from the menu (no event).
  2204. */
  2205. if ( !pev || pev->type == KeyPress )
  2206. {
  2207. moveLastPointerX = moveX + moveWidth/2;
  2208. moveLastPointerY = moveY + moveHeight/2;
  2209. ForceOnScreen (SCREEN_FOR_CLIENT(pcd),
  2210. &moveLastPointerX, &moveLastPointerY);
  2211. if (wmGD.enableWarp)
  2212. {
  2213. XWarpPointer(DISPLAY, None, ROOT_FOR_CLIENT(pcd), 0, 0, 0, 0,
  2214. moveLastPointerX, moveLastPointerY);
  2215. }
  2216. }
  2217. /* pop up feedback window */
  2218. if ( !wmGD.movingIcon && (wmGD.showFeedback & WM_SHOW_FB_MOVE))
  2219. {
  2220. DoFeedback (pcd, moveX, moveY, moveWidth, moveHeight,
  2221. FB_POSITION, FALSE /* no size checks */);
  2222. }
  2223. /* set configuring data */
  2224. wmGD.configAction = MOVE_CLIENT;
  2225. if (pev && pev->type != KeyPress)
  2226. wmGD.configButton = pev->xbutton.button;
  2227. else
  2228. wmGD.configButton = 0;
  2229. return (True);
  2230. } /* END OF FUNCTION StartClientMove */
  2231. /*************************************<->*************************************
  2232. *
  2233. * DoGrabs (grab_win, cursor, pmask, grabTime, alwaysGrab)
  2234. *
  2235. *
  2236. * Description:
  2237. * -----------
  2238. * Do the grabs for window configuration
  2239. *
  2240. *
  2241. * Inputs:
  2242. * ------
  2243. * grab_win - window to grab on
  2244. * cursor - cursor shape to attach to the pointer
  2245. * pmask -
  2246. * grabTime - time stamp
  2247. * alwaysGrab -
  2248. *
  2249. *
  2250. * Outputs:
  2251. * -------
  2252. *
  2253. * Comments:
  2254. * --------
  2255. *
  2256. *************************************<->***********************************/
  2257. Boolean DoGrabs (Window grab_win, Cursor cursor, unsigned int pmask, Time grabTime, ClientData *pCD, Boolean alwaysGrab)
  2258. {
  2259. Window root;
  2260. if (pCD)
  2261. root = ROOT_FOR_CLIENT(pCD);
  2262. else
  2263. root = RootWindow (DISPLAY, ACTIVE_PSD->screen);
  2264. if (pCD && pCD->pSD->useIconBox && wmGD.movingIcon && P_ICON_BOX(pCD))
  2265. {
  2266. /*
  2267. * Confine the pointer to the icon box clip window
  2268. */
  2269. if (XGrabPointer(DISPLAY,
  2270. grab_win,
  2271. FALSE, /* owner_events */
  2272. pmask,
  2273. GrabModeAsync, /* pointer_mode */
  2274. GrabModeAsync, /* keyboard_mode */
  2275. /* confine_to window */
  2276. XtWindow(P_ICON_BOX(pCD)->clipWidget),
  2277. cursor,
  2278. grabTime) != GrabSuccess)
  2279. {
  2280. return(FALSE);
  2281. }
  2282. }
  2283. else
  2284. {
  2285. /*
  2286. * Just confine the pointer to the root window
  2287. */
  2288. if (XGrabPointer(DISPLAY,
  2289. grab_win,
  2290. FALSE, /* owner_events */
  2291. pmask,
  2292. GrabModeAsync, /* pointer_mode */
  2293. GrabModeAsync, /* keyboard_mode */
  2294. root,
  2295. cursor,
  2296. grabTime) != GrabSuccess)
  2297. {
  2298. return(FALSE);
  2299. }
  2300. }
  2301. /*
  2302. * Don't grab keyboard away from menu widget to prevent
  2303. * hosing of traversal.
  2304. */
  2305. if (!wmGD.menuActive)
  2306. {
  2307. if ((XGrabKeyboard(DISPLAY,
  2308. grab_win,
  2309. FALSE, /* owner_events */
  2310. GrabModeAsync, /* pointer_mode */
  2311. GrabModeAsync, /* keyboard_mode */
  2312. grabTime)) != GrabSuccess)
  2313. {
  2314. XUngrabPointer (DISPLAY, CurrentTime);
  2315. return(FALSE);
  2316. }
  2317. }
  2318. if (wmGD.freezeOnConfig)
  2319. {
  2320. if (!pCD || ((pCD->pSD->moveOpaque && alwaysGrab) ||
  2321. (!(pCD->pSD->moveOpaque))))
  2322. {
  2323. XGrabServer(DISPLAY);
  2324. }
  2325. }
  2326. return(TRUE);
  2327. } /* END OF FUNCTION DoGrabs */
  2328. /*************************************<->*************************************
  2329. *
  2330. * UndoGrabs ()
  2331. *
  2332. *
  2333. * Description:
  2334. * -----------
  2335. * Release the grabs
  2336. *
  2337. *
  2338. * Inputs:
  2339. * ------
  2340. *
  2341. *
  2342. * Outputs:
  2343. * -------
  2344. *
  2345. * Comments:
  2346. * --------
  2347. *
  2348. *************************************<->***********************************/
  2349. void UndoGrabs (void)
  2350. {
  2351. /* erase outline */
  2352. MoveOutline(0, 0, 0, 0);
  2353. XSync (DISPLAY, FALSE /*don't discard events*/);
  2354. /* give up grabs */
  2355. if (wmGD.freezeOnConfig) {
  2356. XUngrabServer(DISPLAY);
  2357. }
  2358. /*
  2359. * Don't Ungrab keyboard away from menu widget to prevent
  2360. * hosing of traversal.
  2361. */
  2362. if (!wmGD.menuActive)
  2363. XUngrabKeyboard (DISPLAY,CurrentTime);
  2364. XUngrabPointer (DISPLAY, CurrentTime); /* event time NOT used */
  2365. XFlush (DISPLAY);
  2366. } /* END OF FUNCTION UndoGrabs */
  2367. /*************************************<->*************************************
  2368. *
  2369. * CancelFrameConfig (pcd)
  2370. *
  2371. *
  2372. * Description:
  2373. * -----------
  2374. * Cance a frame configuration (move/resize) operation.
  2375. *
  2376. *
  2377. * Inputs:
  2378. * ------
  2379. * pcd - pointer to client data
  2380. *
  2381. *
  2382. * Outputs:
  2383. * -------
  2384. *
  2385. *
  2386. * Comments:
  2387. * --------
  2388. *
  2389. *************************************<->***********************************/
  2390. void CancelFrameConfig (ClientData *pcd)
  2391. {
  2392. /* remove keyboard, pointer, and server grabs */
  2393. UndoGrabs();
  2394. /* turn off feedback window */
  2395. if (pcd)
  2396. {
  2397. HideFeedbackWindow(pcd->pSD);
  2398. /* make sure title bar is popped out */
  2399. if ((wmGD.configAction == MOVE_CLIENT) &&
  2400. (wmGD.gadgetClient == pcd) && (wmGD.gadgetDepressed == FRAME_TITLE))
  2401. {
  2402. PopGadgetOut (pcd, FRAME_TITLE);
  2403. FrameExposureProc(pcd); /* repaint frame */
  2404. }
  2405. if ((pcd->pSD->moveOpaque) &&
  2406. (wmGD.configAction == MOVE_CLIENT))
  2407. {
  2408. if ((pcd->clientState == MINIMIZED_STATE) &&
  2409. (!(pcd->pSD->useIconBox && P_ICON_BOX(pcd))))
  2410. {
  2411. /*
  2412. * Replace icon into pre-move position
  2413. */
  2414. XMoveWindow (DISPLAY, ICON_FRAME_WIN(pcd),
  2415. ICON_X(pcd), ICON_Y(pcd));
  2416. if ((ICON_DECORATION(pcd) & ICON_ACTIVE_LABEL_PART))
  2417. {
  2418. ShowActiveIconText(pcd);
  2419. }
  2420. }
  2421. else if (! wmGD.movingIcon) /* we are not moving in the iconbox */
  2422. {
  2423. XMoveWindow (DISPLAY, pcd->clientFrameWin,
  2424. opaqueMoveX, opaqueMoveY);
  2425. }
  2426. }
  2427. }
  2428. if (wmGD.configAction == MARQUEE_SELECT)
  2429. {
  2430. dtSendMarqueeSelectionNotification(ACTIVE_PSD, DT_MARQUEE_SELECT_CANCEL,
  2431. marqueeX, marqueeY, 0, 0);
  2432. }
  2433. /* replace pointer if no motion events received */
  2434. if (pcd)
  2435. if (!anyMotion && wmGD.enableWarp) {
  2436. XWarpPointer(DISPLAY, None, ROOT_FOR_CLIENT(pcd),
  2437. 0, 0, 0, 0, wmGD.preMoveX, wmGD.preMoveY);
  2438. }
  2439. anyMotion = FALSE;
  2440. /* Clear configuration flags and data */
  2441. wmGD.configAction = NO_ACTION;
  2442. wmGD.configPart = FRAME_NONE;
  2443. wmGD.configSet = False;
  2444. configGrab = FALSE;
  2445. wmGD.movingIcon = FALSE;
  2446. /* set the focus back to a reasonable window */
  2447. RepairFocus ();
  2448. } /* END OF FUNCTION CancelFrameConfig */
  2449. /*************************************<->*************************************
  2450. *
  2451. * CheckEatButtonRelease (pcd, pev)
  2452. *
  2453. *
  2454. * Description:
  2455. * -----------
  2456. * Set up to eat button releases if buttons are down.
  2457. *
  2458. *
  2459. * Inputs:
  2460. * ------
  2461. * pcd - pointer to client data
  2462. * pev - pointer to key event that caused cancel
  2463. *
  2464. * Outputs:
  2465. * -------
  2466. * none
  2467. *
  2468. *
  2469. * Comments:
  2470. * --------
  2471. *
  2472. *************************************<->***********************************/
  2473. void
  2474. CheckEatButtonRelease (ClientData *pcd, XEvent *pev)
  2475. {
  2476. Window grab_win;
  2477. Window root;
  2478. if (pcd != (ClientData *)NULL)
  2479. root = ROOT_FOR_CLIENT(pcd);
  2480. else
  2481. root = RootWindow (DISPLAY, ACTIVE_PSD->screen);
  2482. if (pcd == (ClientData *) NULL)
  2483. grab_win = root;
  2484. else
  2485. grab_win = GrabWin(pcd, pev);
  2486. if ((pev->type == KeyPress || pev->type == KeyRelease) &&
  2487. (pev->xbutton.state & ButtonMask))
  2488. {
  2489. /*
  2490. * Some buttons are down...
  2491. * Set up conditions to wait for these buttons to go up.
  2492. */
  2493. if (XGrabPointer(DISPLAY,
  2494. grab_win,
  2495. False, /* owner_events */
  2496. ButtonReleaseMask,
  2497. GrabModeAsync, /* pointer_mode */
  2498. GrabModeAsync, /* keyboard_mode */
  2499. root, /* confine_to window */
  2500. wmGD.configCursor,
  2501. pev->xbutton.time) == GrabSuccess)
  2502. {
  2503. EatButtonRelease (pev->xbutton.state & ButtonMask);
  2504. }
  2505. }
  2506. }
  2507. /*************************************<->*************************************
  2508. *
  2509. * EatButtonRelease (releaseButtons)
  2510. *
  2511. *
  2512. * Description:
  2513. * -----------
  2514. * Eat up button release events
  2515. *
  2516. *
  2517. * Inputs:
  2518. * ------
  2519. * releaseButtons = button mask of button releases to eat
  2520. *
  2521. * Outputs:
  2522. * -------
  2523. * none
  2524. *
  2525. *
  2526. * Comments:
  2527. * --------
  2528. *
  2529. *************************************<->***********************************/
  2530. void
  2531. EatButtonRelease (unsigned int releaseButtons)
  2532. {
  2533. unsigned int new_state;
  2534. XEvent event;
  2535. while (releaseButtons)
  2536. {
  2537. PullExposureEvents ();
  2538. XMaskEvent (DISPLAY, ButtonReleaseMask, &event);
  2539. if (event.type == ButtonRelease)
  2540. {
  2541. /* look at the state after this button is released */
  2542. new_state =
  2543. event.xbutton.state & ~ButtonStateBit(event.xbutton.button);
  2544. if (!(new_state & releaseButtons))
  2545. {
  2546. /* all the buttons we were waiting for have been
  2547. * released.
  2548. */
  2549. XUngrabPointer (DISPLAY, event.xbutton.time);
  2550. releaseButtons = 0;
  2551. }
  2552. }
  2553. }
  2554. }
  2555. /*************************************<->*************************************
  2556. *
  2557. * ButtonStateBit (button)
  2558. *
  2559. *
  2560. * Description:
  2561. * -----------
  2562. * Converts a button number to a button state bit
  2563. *
  2564. *
  2565. * Inputs:
  2566. * ------
  2567. * button = button number (Button1, Button2, etc.)
  2568. *
  2569. * Outputs:
  2570. * -------
  2571. * Return = bit used in xbutton state field
  2572. * (Button1Mask, Button2Mask,...)
  2573. *
  2574. *
  2575. * Comments:
  2576. * --------
  2577. *
  2578. *
  2579. *************************************<->***********************************/
  2580. unsigned int
  2581. ButtonStateBit (unsigned int button)
  2582. {
  2583. #define MAX_BUTTON 5
  2584. typedef struct {
  2585. unsigned int button;
  2586. unsigned int maskbit;
  2587. } ButtonAssoc;
  2588. static ButtonAssoc bmap[MAX_BUTTON] = {
  2589. {Button1, Button1Mask},
  2590. {Button2, Button2Mask},
  2591. {Button3, Button3Mask},
  2592. {Button4, Button4Mask},
  2593. {Button5, Button5Mask},
  2594. };
  2595. int i;
  2596. unsigned int rval = 0;
  2597. for (i = 0; i < MAX_BUTTON; i++)
  2598. {
  2599. if (bmap[i].button == button)
  2600. {
  2601. rval = bmap[i].maskbit;
  2602. break;
  2603. }
  2604. }
  2605. return (rval);
  2606. }
  2607. /*************************************<->*************************************
  2608. *
  2609. * ConfigCursor (frame_part)
  2610. *
  2611. *
  2612. * Description:
  2613. * -----------
  2614. * return the config cursor that goes with the config part specified
  2615. *
  2616. *
  2617. * Inputs:
  2618. * ------
  2619. * frame_part - frame part id
  2620. *
  2621. * Outputs:
  2622. * -------
  2623. * return - cursor to use
  2624. *
  2625. *
  2626. * Comments:
  2627. * --------
  2628. *
  2629. *************************************<->***********************************/
  2630. Cursor ConfigCursor (int frame_part)
  2631. {
  2632. Cursor cursor;
  2633. switch (frame_part) {
  2634. case FRAME_RESIZE_NW:
  2635. cursor = wmGD.stretchCursors[STRETCH_NORTH_WEST];
  2636. break;
  2637. case FRAME_RESIZE_N:
  2638. cursor = wmGD.stretchCursors[STRETCH_NORTH];
  2639. break;
  2640. case FRAME_RESIZE_NE:
  2641. cursor = wmGD.stretchCursors[STRETCH_NORTH_EAST];
  2642. break;
  2643. case FRAME_RESIZE_E:
  2644. cursor = wmGD.stretchCursors[STRETCH_EAST];
  2645. break;
  2646. case FRAME_RESIZE_SE:
  2647. cursor = wmGD.stretchCursors[STRETCH_SOUTH_EAST];
  2648. break;
  2649. case FRAME_RESIZE_S:
  2650. cursor = wmGD.stretchCursors[STRETCH_SOUTH];
  2651. break;
  2652. case FRAME_RESIZE_SW:
  2653. cursor = wmGD.stretchCursors[STRETCH_SOUTH_WEST];
  2654. break;
  2655. case FRAME_RESIZE_W:
  2656. cursor = wmGD.stretchCursors[STRETCH_WEST];
  2657. break;
  2658. default:
  2659. cursor = wmGD.configCursor;
  2660. }
  2661. return(cursor);
  2662. } /* END OF FUNCTION ConfigCursor */
  2663. /*************************************<->*************************************
  2664. *
  2665. * ReGrabPointer (grab_win, grabTime)
  2666. *
  2667. *
  2668. * Description:
  2669. * -----------
  2670. * Grab the pointer again to change the cursor
  2671. *
  2672. *
  2673. * Inputs:
  2674. * ------
  2675. * grab_win -
  2676. * grabTime - time stamp
  2677. *
  2678. * Outputs:
  2679. * -------
  2680. *
  2681. *
  2682. * Comments:
  2683. * --------
  2684. *
  2685. *************************************<->***********************************/
  2686. void ReGrabPointer (Window grab_win, Time grabTime)
  2687. {
  2688. XGrabPointer(DISPLAY,
  2689. grab_win,
  2690. FALSE, /* owner_events */
  2691. PGRAB_MASK,
  2692. GrabModeAsync, /* pointer_mode */
  2693. GrabModeAsync, /* keyboard_mode */
  2694. ACTIVE_ROOT, /* confine_to window */
  2695. ConfigCursor((int)wmGD.configPart),
  2696. grabTime);
  2697. } /* END OF FUNCTION ReGrabPointer */
  2698. /*************************************<->*************************************
  2699. *
  2700. * SetPointerResizePart (pcd, pev)
  2701. *
  2702. *
  2703. * Description:
  2704. * -----------
  2705. * Sets the global configuration part for resize based on the current
  2706. * configuration part and the location of the event
  2707. *
  2708. *
  2709. * Inputs:
  2710. * ------
  2711. * pcd - pointer to client data
  2712. * pev - pointer to event
  2713. *
  2714. *
  2715. * Outputs:
  2716. * -------
  2717. * Return - TRUE if wmGD.configPart is a valid resize part
  2718. *
  2719. *
  2720. * Comments:
  2721. * --------
  2722. * o Assumes the static data for resizing has been set up.
  2723. *************************************<->***********************************/
  2724. Boolean SetPointerResizePart (ClientData *pcd, XEvent *pev)
  2725. {
  2726. int newPart;
  2727. Time grabTime;
  2728. newPart = ResizeType(pcd, pev); /* get part id for this event */
  2729. grabTime = (pev) ? pev->xmotion.time : CurrentTime;
  2730. switch (wmGD.configPart) {
  2731. case FRAME_NONE:
  2732. if (newPart == FRAME_NONE)
  2733. return(FALSE); /* still not valid */
  2734. wmGD.configPart = newPart;
  2735. ReGrabPointer(pcd->clientFrameWin, grabTime);
  2736. return(TRUE);
  2737. case FRAME_RESIZE_N:
  2738. switch (newPart) {
  2739. case FRAME_RESIZE_W:
  2740. case FRAME_RESIZE_NW:
  2741. wmGD.configPart = FRAME_RESIZE_NW;
  2742. ReGrabPointer(pcd->clientFrameWin, grabTime);
  2743. break;
  2744. case FRAME_RESIZE_E:
  2745. case FRAME_RESIZE_NE:
  2746. wmGD.configPart = FRAME_RESIZE_NE;
  2747. ReGrabPointer(pcd->clientFrameWin, grabTime);
  2748. break;
  2749. default:
  2750. break;
  2751. }
  2752. break;
  2753. case FRAME_RESIZE_E:
  2754. switch (newPart) {
  2755. case FRAME_RESIZE_N:
  2756. case FRAME_RESIZE_NE:
  2757. wmGD.configPart = FRAME_RESIZE_NE;
  2758. ReGrabPointer(pcd->clientFrameWin, grabTime);
  2759. break;
  2760. case FRAME_RESIZE_S:
  2761. case FRAME_RESIZE_SE:
  2762. wmGD.configPart = FRAME_RESIZE_SE;
  2763. ReGrabPointer(pcd->clientFrameWin, grabTime);
  2764. break;
  2765. default:
  2766. break;
  2767. }
  2768. break;
  2769. case FRAME_RESIZE_S:
  2770. switch (newPart) {
  2771. case FRAME_RESIZE_E:
  2772. case FRAME_RESIZE_SE:
  2773. wmGD.configPart = FRAME_RESIZE_SE;
  2774. ReGrabPointer(pcd->clientFrameWin, grabTime);
  2775. break;
  2776. case FRAME_RESIZE_W:
  2777. case FRAME_RESIZE_SW:
  2778. wmGD.configPart = FRAME_RESIZE_SW;
  2779. ReGrabPointer(pcd->clientFrameWin, grabTime);
  2780. break;
  2781. default:
  2782. break;
  2783. }
  2784. break;
  2785. case FRAME_RESIZE_W:
  2786. switch (newPart) {
  2787. case FRAME_RESIZE_N:
  2788. case FRAME_RESIZE_NW:
  2789. wmGD.configPart = FRAME_RESIZE_NW;
  2790. ReGrabPointer(pcd->clientFrameWin, grabTime);
  2791. break;
  2792. case FRAME_RESIZE_S:
  2793. case FRAME_RESIZE_SW:
  2794. wmGD.configPart = FRAME_RESIZE_SW;
  2795. ReGrabPointer(pcd->clientFrameWin, grabTime);
  2796. break;
  2797. default:
  2798. break;
  2799. }
  2800. break;
  2801. case FRAME_RESIZE_NW:
  2802. case FRAME_RESIZE_NE:
  2803. case FRAME_RESIZE_SW:
  2804. case FRAME_RESIZE_SE:
  2805. break;
  2806. default:
  2807. return(FALSE); /* not a valid resize part */
  2808. }
  2809. return(TRUE);
  2810. } /* END OF FUNCTION SetPointerResizePart */
  2811. /*************************************<->*************************************
  2812. *
  2813. * ResizeType (pcd, pev)
  2814. *
  2815. *
  2816. * Description:
  2817. * -----------
  2818. * Returns a resize part ID for an event outside of the current
  2819. * resize area.
  2820. *
  2821. *
  2822. * Inputs:
  2823. * ------
  2824. * pcd - pointer to client data
  2825. * pev - pointer to event
  2826. *
  2827. *
  2828. * Outputs:
  2829. * -------
  2830. *
  2831. *
  2832. * Comments:
  2833. * --------
  2834. * o Assumes the static data for resizing has been set up.
  2835. *************************************<->***********************************/
  2836. int ResizeType (ClientData *pcd, XEvent *pev)
  2837. {
  2838. int x, y;
  2839. if (!pev) return(FRAME_NONE);
  2840. x = pev->xmotion.x_root;
  2841. y = pev->xmotion.y_root;
  2842. /* if inside all resize areas, then forget it */
  2843. if ( (x > resizeX) &&
  2844. (y > resizeY) &&
  2845. (x < (resizeX + resizeWidth - 1)) &&
  2846. (y < (resizeY + resizeHeight - 1)) )
  2847. {
  2848. return(FRAME_NONE);
  2849. }
  2850. /* left side */
  2851. if (x <= resizeX) {
  2852. if (y < resizeY + (int)pcd->frameInfo.cornerHeight)
  2853. return (FRAME_RESIZE_NW);
  2854. else if (y >= resizeY + resizeHeight -(int)pcd->frameInfo.cornerHeight)
  2855. return (FRAME_RESIZE_SW);
  2856. else
  2857. return (FRAME_RESIZE_W);
  2858. }
  2859. /* right side */
  2860. if (x >= resizeX + resizeWidth - 1) {
  2861. if (y < resizeY + (int)pcd->frameInfo.cornerHeight)
  2862. return (FRAME_RESIZE_NE);
  2863. else if (y >= resizeY + resizeHeight -(int)pcd->frameInfo.cornerHeight)
  2864. return (FRAME_RESIZE_SE);
  2865. else
  2866. return (FRAME_RESIZE_E);
  2867. }
  2868. /* top side */
  2869. if (y <= resizeY) {
  2870. if (x < resizeX + (int)pcd->frameInfo.cornerWidth)
  2871. return (FRAME_RESIZE_NW);
  2872. else if (x >= resizeX + resizeWidth - (int)pcd->frameInfo.cornerWidth)
  2873. return (FRAME_RESIZE_NE);
  2874. else
  2875. return (FRAME_RESIZE_N);
  2876. }
  2877. /* bottom side */
  2878. if (y >= resizeY + resizeHeight - 1) {
  2879. if (x < resizeX + (int)pcd->frameInfo.cornerWidth)
  2880. return (FRAME_RESIZE_SW);
  2881. else if (x >= resizeX + resizeWidth - (int)pcd->frameInfo.cornerWidth)
  2882. return (FRAME_RESIZE_SE);
  2883. else
  2884. return (FRAME_RESIZE_S);
  2885. }
  2886. return(FRAME_NONE);
  2887. } /* END OF FUNCTION ResizeType */
  2888. /*************************************<->*************************************
  2889. *
  2890. * FixFrameValues (pcd, pfX, pfY, pfWidth, pfHeight, resizing)
  2891. *
  2892. *
  2893. * Description:
  2894. * -----------
  2895. * Fix up the frame values so that they do not exceed maximum or minimum
  2896. * size and that at least part of the frame is on screen
  2897. *
  2898. *
  2899. * Inputs:
  2900. * ------
  2901. * pcd - pointer to client data
  2902. * pfX - pointer to frame x-coord
  2903. * pfY - pointer to frame y-coord
  2904. * pfWidth - pointer to frame width
  2905. * pfHeight - pointer to frame height
  2906. * resizing - check size constraints iff TRUE
  2907. *
  2908. *
  2909. * Outputs:
  2910. * -------
  2911. * *pfX - fixed up frame x-coord
  2912. * *pfY - fixed up frame y-coord
  2913. * *pfWidth - fixed up frame width
  2914. * *pfHeight - fixed up frame height
  2915. *
  2916. *
  2917. * Comments:
  2918. * --------
  2919. * 1. This could be more efficient
  2920. * 2. Interactive resize with aspect ratio constraints may cause part of the
  2921. * outline to disappear off screen. The critical case is when the title
  2922. * bar disappears ABOVE the screen.
  2923. *
  2924. *************************************<->***********************************/
  2925. void FixFrameValues (ClientData *pcd, int *pfX, int *pfY, unsigned int *pfWidth, unsigned int *pfHeight, Boolean resizing)
  2926. {
  2927. unsigned int lswidth;
  2928. unsigned int oWidth, oHeight;
  2929. /*
  2930. * Fix size if resizing and not icon.
  2931. */
  2932. if (resizing && !wmGD.movingIcon)
  2933. {
  2934. FrameToClient(pcd, pfX, pfY, pfWidth, pfHeight);
  2935. oWidth = *pfWidth;
  2936. oHeight = *pfHeight;
  2937. FixWindowSize (pcd, pfWidth, pfHeight, 1, 1);
  2938. AdjustPos (pfX, pfY, oWidth, oHeight, *pfWidth, *pfHeight);
  2939. ClientToFrame(pcd, pfX, pfY, pfWidth, pfHeight);
  2940. }
  2941. /*
  2942. * Don't move if we'd end up totally offscreen
  2943. */
  2944. if (wmGD.movingIcon)
  2945. {
  2946. lswidth = FRAME_BORDER_WIDTH(pcd);
  2947. }
  2948. else
  2949. {
  2950. lswidth = pcd->frameInfo.lowerBorderWidth;
  2951. }
  2952. if (lswidth < 5) lswidth = 5;
  2953. if (wmGD.movingIcon && P_ICON_BOX(pcd))
  2954. {
  2955. /*
  2956. * Constrain outline to icon box
  2957. */
  2958. /* left edge of outline */
  2959. if (*pfX < clipX)
  2960. {
  2961. *pfX = clipX;
  2962. }
  2963. /* top of outline */
  2964. if (*pfY < clipY)
  2965. {
  2966. *pfY = clipY;
  2967. }
  2968. /* right edge of outline */
  2969. if (((int)*pfX) > ((int)clipX + (int)clipWidth - ((int)*pfWidth)))
  2970. {
  2971. *pfX = clipX + clipWidth - *pfWidth;
  2972. }
  2973. /* bottom edge of outline */
  2974. if (((int)*pfY) > ((int)clipY + (int)clipHeight - ((int)*pfHeight)))
  2975. {
  2976. *pfY = clipY + clipHeight - *pfHeight;
  2977. }
  2978. }
  2979. else
  2980. {
  2981. /*
  2982. * keep outline on screen
  2983. */
  2984. /* keep right border on screen */
  2985. if (*pfX < ((int) lswidth - (int) *pfWidth))
  2986. {
  2987. *pfX = (int) lswidth - (int) *pfWidth;
  2988. }
  2989. /* keep bottom border on screen */
  2990. if (*pfY < ((int) lswidth - (int) *pfHeight))
  2991. {
  2992. *pfY = (int) lswidth - (int) *pfHeight;
  2993. }
  2994. /* keep left border on screen */
  2995. if (*pfX > (DisplayWidth(DISPLAY, SCREEN_FOR_CLIENT(pcd)) -
  2996. (int) lswidth))
  2997. {
  2998. *pfX = DisplayWidth(DISPLAY, SCREEN_FOR_CLIENT(pcd)) -
  2999. (int) lswidth;
  3000. }
  3001. /* keep top border on screen */
  3002. if (*pfY > (DisplayHeight(DISPLAY,SCREEN_FOR_CLIENT(pcd)) -
  3003. (int) lswidth))
  3004. {
  3005. *pfY = DisplayHeight(DISPLAY, SCREEN_FOR_CLIENT(pcd)) -
  3006. (int) lswidth;
  3007. }
  3008. }
  3009. } /* END OF FUNCTION FixFrameValues */
  3010. /*************************************<->*************************************
  3011. *
  3012. * ForceOnScreen (screen, pX, pY)
  3013. *
  3014. *
  3015. * Description:
  3016. * -----------
  3017. * Correct (if necessary) the coords specified to make them on screen
  3018. *
  3019. *
  3020. * Inputs:
  3021. * ------
  3022. * screen - screen number
  3023. * pX - pointer to x-coord
  3024. * pY - pointer to y-coord
  3025. *
  3026. * Outputs:
  3027. * -------
  3028. * *pX - x-coord (on screen)
  3029. * *pY - y-coord (on screen)
  3030. *
  3031. *
  3032. * Comments:
  3033. * --------
  3034. * XXComments ...
  3035. *
  3036. *************************************<->***********************************/
  3037. void ForceOnScreen (int screen, int *pX, int *pY)
  3038. {
  3039. if (*pX >= (DisplayWidth(DISPLAY, screen)))
  3040. *pX = DisplayWidth(DISPLAY, screen) - 1;
  3041. else if (*pX < 0)
  3042. *pX = 0;
  3043. if (*pY >= (DisplayHeight(DISPLAY, screen)))
  3044. *pY = DisplayHeight(DISPLAY, screen) - 1;
  3045. else if (*pY < 0)
  3046. *pY = 0;
  3047. } /* END OF FUNCTION ForceOnScreen */
  3048. /*************************************<->*************************************
  3049. *
  3050. * SetPointerPosition (newX, newY, actualX, actualY)
  3051. *
  3052. *
  3053. * Description:
  3054. * -----------
  3055. * Attempt to set the pointer to position at newX, newY.
  3056. *
  3057. *
  3058. * Inputs:
  3059. * ------
  3060. * newX - X-coordinate to set pointer at
  3061. * newY - Y-coordinate to set pointer at
  3062. *
  3063. *
  3064. * Outputs:
  3065. * -------
  3066. * *actualX - actual X-coord of pointer on return
  3067. * *actualY - actual Y-coord of pointer on return
  3068. *
  3069. * Comments:
  3070. * --------
  3071. *
  3072. *************************************<->***********************************/
  3073. void SetPointerPosition (int newX, int newY, int *actualX, int *actualY)
  3074. {
  3075. int junk;
  3076. Window junk_win;
  3077. /*
  3078. * Warp pointer ...
  3079. */
  3080. if (wmGD.enableWarp)
  3081. {
  3082. XWarpPointer(DISPLAY, None, ACTIVE_ROOT,
  3083. 0, 0, 0, 0, newX, newY);
  3084. }
  3085. /*
  3086. * Get pointer position
  3087. * NOTE: if we are not warping, we don't want to do the Query pointer,
  3088. * hence enableWarp is tested first.
  3089. */
  3090. if (!wmGD.enableWarp ||
  3091. !XQueryPointer (DISPLAY, ACTIVE_ROOT, &junk_win, &junk_win,
  3092. actualX, actualY, &junk, &junk, (unsigned int *)&junk))
  3093. {
  3094. /* failed to get pointer position or not warping, return something */
  3095. *actualX = newX;
  3096. *actualY = newY;
  3097. }
  3098. } /* END OF FUNCTION SetPointerPositio */
  3099. /*************************************<->*************************************
  3100. *
  3101. * GetConfigEvent (display, window, mask, curX, curY, oX, oY,
  3102. * oWidth, oHeight, pev,)
  3103. *
  3104. *
  3105. * Description:
  3106. * -----------
  3107. * Get next configuration event
  3108. *
  3109. *
  3110. * Inputs:
  3111. * ------
  3112. * display - pointer to display
  3113. * window - window to get event relative to
  3114. * mask - event mask - acceptable events to return
  3115. * pev - pointer to a place to put the event
  3116. * curX - current X value of pointer
  3117. * curY - current Y value of pointer
  3118. * oX - X value of outline
  3119. * oY - Y value of outline
  3120. * oWidth - width of outline
  3121. * oHeight - height of outline
  3122. *
  3123. * Outputs:
  3124. * -------
  3125. * *pev - event returned.
  3126. *
  3127. * Comments:
  3128. * --------
  3129. *
  3130. *************************************<->***********************************/
  3131. void GetConfigEvent (Display *display, Window window, unsigned long mask, int curX, int curY, int oX, int oY, unsigned oWidth, unsigned oHeight, XEvent *pev)
  3132. {
  3133. Window root_ret, child_ret;
  3134. int root_x, root_y, win_x, win_y;
  3135. unsigned int mask_ret;
  3136. Boolean polling;
  3137. int pollCount;
  3138. Boolean gotEvent;
  3139. Boolean eventToReturn = False;
  3140. while (!eventToReturn)
  3141. {
  3142. /*
  3143. * Suck up pointer motion events
  3144. */
  3145. gotEvent = False;
  3146. while (XCheckWindowEvent(display, window, mask, pev))
  3147. {
  3148. gotEvent = True;
  3149. if (pev->type != MotionNotify)
  3150. break;
  3151. }
  3152. /*
  3153. * Only poll if we are warping the pointer.
  3154. * (uses PointerMotionHints exclusively).
  3155. */
  3156. polling = wmGD.enableWarp;
  3157. pollCount = CONFIG_POLL_COUNT;
  3158. if (!gotEvent && (polling || !wmGD.freezeOnConfig))
  3159. {
  3160. /*
  3161. * poll for events and flash the frame outline
  3162. * if not move opaque
  3163. */
  3164. while (True)
  3165. {
  3166. if (XCheckWindowEvent(display, window,
  3167. (mask & ~PointerMotionMask), pev))
  3168. {
  3169. gotEvent = True;
  3170. break;
  3171. }
  3172. if (!wmGD.freezeOnConfig && !wmGD.pActiveSD->moveOpaque)
  3173. {
  3174. /* flash the outline if server is not grabbed */
  3175. MoveOutline (oX, oY, oWidth, oHeight);
  3176. }
  3177. if (!XQueryPointer (display, window, &root_ret, &child_ret,
  3178. &root_x, &root_y, &win_x, &win_y, &mask_ret))
  3179. {
  3180. continue; /* query failed, try again */
  3181. }
  3182. if ((root_x != curX) || (root_y != curY))
  3183. {
  3184. /*
  3185. * Pointer moved to a new position.
  3186. * Cobble a motion event together.
  3187. * NOTE: SOME FIELDS NOT SET !!!
  3188. */
  3189. pev->type = MotionNotify;
  3190. /* pev->xmotion.serial = ??? */
  3191. pev->xmotion.send_event = False;
  3192. pev->xmotion.display = display;
  3193. pev->xmotion.window = root_ret;
  3194. pev->xmotion.subwindow = child_ret;
  3195. pev->xmotion.time = CurrentTime; /* !!! !!! */
  3196. pev->xmotion.x = root_x;
  3197. pev->xmotion.y = root_y;
  3198. pev->xmotion.x_root = root_x;
  3199. pev->xmotion.y_root = root_y;
  3200. /* pev->xmotion.state = ??? */
  3201. /* pev->xmotion.is_hint = ???? */
  3202. /* pev->xmotion.same_screen = ??? */
  3203. eventToReturn = True;
  3204. break; /* from while loop */
  3205. }
  3206. else if (wmGD.freezeOnConfig)
  3207. {
  3208. if (!(--pollCount))
  3209. {
  3210. /*
  3211. * No pointer motion in some time. Stop polling
  3212. * and wait for next event.
  3213. */
  3214. polling = False;
  3215. break; /* from while loop */
  3216. }
  3217. }
  3218. } /* end while */
  3219. }
  3220. if (!gotEvent && !polling && wmGD.freezeOnConfig)
  3221. {
  3222. /*
  3223. * Wait for next event on window
  3224. */
  3225. XWindowEvent (display, window, mask, pev);
  3226. gotEvent = True;
  3227. }
  3228. if (gotEvent)
  3229. {
  3230. eventToReturn = True;
  3231. if (pev->type == MotionNotify &&
  3232. pev->xmotion.is_hint == NotifyHint)
  3233. {
  3234. /*
  3235. * "Ack" the motion notify hint
  3236. */
  3237. if ((XQueryPointer (display, window, &root_ret,
  3238. &child_ret, &root_x, &root_y, &win_x,
  3239. &win_y, &mask_ret)) &&
  3240. ((root_x != curX) ||
  3241. (root_y != curY)))
  3242. {
  3243. /*
  3244. * The query pointer values say that the pointer
  3245. * moved to a new location.
  3246. */
  3247. pev->xmotion.window = root_ret;
  3248. pev->xmotion.subwindow = child_ret;
  3249. pev->xmotion.x = root_x;
  3250. pev->xmotion.y = root_y;
  3251. pev->xmotion.x_root = root_x;
  3252. pev->xmotion.y_root = root_y;
  3253. }
  3254. else {
  3255. /*
  3256. * Query failed. Change curX to force position
  3257. * to be returned on first sucessful query.
  3258. */
  3259. eventToReturn = False;
  3260. curX++;
  3261. }
  3262. }
  3263. }
  3264. } /* end while */
  3265. } /* END OF FUNCTION GetConfigEvent */
  3266. /*************************************<->*************************************
  3267. *
  3268. * SetOutline (pOutline, x, y, width, height, fatness)
  3269. *
  3270. *
  3271. * Description:
  3272. * -----------
  3273. * Sets the outline of for config/move/placement operations
  3274. *
  3275. *
  3276. * Inputs:
  3277. * ------
  3278. * pOutline - ptr to outline structure to fill in
  3279. * x - x of upper-left corner of outline
  3280. * y - y of upper-left corner of outline
  3281. * width - width of outline.
  3282. * height - height of outline.
  3283. * fatness - pixel-width of outline
  3284. *
  3285. * Outputs:
  3286. * -------
  3287. *
  3288. * Comments:
  3289. * --------
  3290. * o Be sure that pOutline points to a big enough area of memory
  3291. * for the outline to be set!
  3292. *
  3293. *************************************<->***********************************/
  3294. void SetOutline (XSegment *pOutline, int x, int y, unsigned int width, unsigned int height, int fatness)
  3295. {
  3296. int i;
  3297. for (i=0; i<fatness; i++)
  3298. {
  3299. pOutline->x1 = x;
  3300. pOutline->y1 = y;
  3301. pOutline->x2 = x + width -1;
  3302. pOutline++->y2 = y;
  3303. pOutline->x1 = x + width -1;
  3304. pOutline->y1 = y;
  3305. pOutline->x2 = x + width -1;
  3306. pOutline++->y2 = y + height - 1;
  3307. pOutline->x1 = x + width -1;
  3308. pOutline->y1 = y + height - 1;
  3309. pOutline->x2 = x;
  3310. pOutline++->y2 = y + height - 1;
  3311. pOutline->x1 = x;
  3312. pOutline->y1 = y + height - 1;
  3313. pOutline->x2 = x;
  3314. pOutline++->y2 = y;
  3315. /*
  3316. * Modify values for next pass (if any)
  3317. * Next outline will be on inside of current one.
  3318. */
  3319. x += 1;
  3320. y += 1;
  3321. width -= 2;
  3322. height -= 2;
  3323. }
  3324. } /* END OF FUNCTION SetOutline */
  3325. /*************************************<->*************************************
  3326. *
  3327. * AdjustPos (pX, pY, oWidth, oHeight, nWidth, nHeight)
  3328. *
  3329. *
  3330. * Description:
  3331. * -----------
  3332. * Adjusts the position according to wmGD.configPart and any change in
  3333. * client size.
  3334. *
  3335. *
  3336. * Inputs:
  3337. * ------
  3338. * pX, pY -- pointers to positions
  3339. * oWidth, oHeight -- original dimensions
  3340. * nWidth, nHeight -- new dimensions
  3341. * wmGD.configPart
  3342. *
  3343. * Outputs:
  3344. * -------
  3345. * pX, pY -- pointers to adjusted positions
  3346. *
  3347. * Comments:
  3348. * --------
  3349. *
  3350. *************************************<->***********************************/
  3351. void AdjustPos (int *pX, int *pY, unsigned int oWidth, unsigned int oHeight, unsigned int nWidth, unsigned int nHeight)
  3352. {
  3353. switch (wmGD.configPart)
  3354. {
  3355. case FRAME_RESIZE_NW:
  3356. /* anchor lower right corner */
  3357. *pX += oWidth - nWidth;
  3358. *pY += oHeight - nHeight;
  3359. break;
  3360. case FRAME_RESIZE_N:
  3361. /* anchor bottom */
  3362. *pY += oHeight - nHeight;
  3363. break;
  3364. case FRAME_RESIZE_NE:
  3365. /* anchor lower left corner */
  3366. *pY += oHeight - nHeight;
  3367. break;
  3368. case FRAME_RESIZE_E:
  3369. /* anchor left side */
  3370. break;
  3371. case FRAME_RESIZE_SE:
  3372. /* anchor upper left corner */
  3373. break;
  3374. case FRAME_RESIZE_S:
  3375. /* anchor top */
  3376. break;
  3377. case FRAME_RESIZE_SW:
  3378. /* anchor upper right corner */
  3379. *pX += oWidth - nWidth;
  3380. break;
  3381. case FRAME_RESIZE_W:
  3382. /* anchor right side */
  3383. *pX += oWidth - nWidth;
  3384. break;
  3385. default:
  3386. break;
  3387. }
  3388. } /* END OF FUNCTION AdjustPos */
  3389. /*************************************<->*************************************
  3390. *
  3391. * GrabWin (pcd, pev)
  3392. *
  3393. *
  3394. * Description:
  3395. * -----------
  3396. * return window to do grab on for config operation
  3397. *
  3398. *
  3399. * Inputs:
  3400. * ------
  3401. * pcd - ptr to client data
  3402. * pev - ptr to event
  3403. *
  3404. * Outputs:
  3405. * -------
  3406. * Return - window
  3407. *
  3408. *
  3409. * Comments:
  3410. * --------
  3411. *
  3412. *************************************<->***********************************/
  3413. Window GrabWin (ClientData *pcd, XEvent *pev)
  3414. {
  3415. Window grab_win;
  3416. /*
  3417. * The grab window is the icon if the client is minimized
  3418. * or if the event was on a "normalized" icon in the icon box.
  3419. */
  3420. if ((pcd->clientState == MINIMIZED_STATE) ||
  3421. (pcd->pSD->useIconBox && pev &&
  3422. ((pev->xany.window == ICON_FRAME_WIN(pcd)) ||
  3423. (pev->xany.window == ACTIVE_ICON_TEXT_WIN))))
  3424. {
  3425. grab_win = ICON_FRAME_WIN(pcd);
  3426. }
  3427. else if (pev &&
  3428. (pev->xany.window == pcd->clientFrameWin ||
  3429. pev->xany.window == pcd->clientBaseWin ))
  3430. {
  3431. grab_win = pcd->clientFrameWin;
  3432. }
  3433. else if (pcd->pSD->useIconBox &&
  3434. P_ICON_BOX(pcd) &&
  3435. wmGD.grabContext == F_SUBCONTEXT_IB_WICON)
  3436. {
  3437. grab_win = ICON_FRAME_WIN(pcd);
  3438. }
  3439. else
  3440. {
  3441. grab_win = pcd->clientFrameWin;
  3442. }
  3443. return (grab_win);
  3444. } /* END OF FUNCTION GrabWin */
  3445. /*************************************<->*************************************
  3446. *
  3447. * HandleMarqueeSelect (pSD, event)
  3448. *
  3449. *
  3450. * Description:
  3451. * -----------
  3452. * Does a marquee selection on the root window
  3453. *
  3454. *
  3455. * Inputs:
  3456. * ------
  3457. *
  3458. * Outputs:
  3459. * -------
  3460. *
  3461. * Comments:
  3462. * --------
  3463. * Selection info is dumped into a root window property:
  3464. * _DT_MARQUEE_SELECTION
  3465. *
  3466. *************************************<->***********************************/
  3467. void
  3468. HandleMarqueeSelect (WmScreenData *pSD, XEvent *pev)
  3469. {
  3470. Window grab_win;
  3471. Boolean bDone;
  3472. XEvent event;
  3473. grab_win = RootWindow (DISPLAY, pSD->screen);
  3474. bDone = False;
  3475. while (!bDone && (wmGD.configAction == MARQUEE_SELECT))
  3476. {
  3477. if (!pev) /* first time through will already have event */
  3478. {
  3479. pev = &event;
  3480. GetConfigEvent(DISPLAY, grab_win, CONFIG_MASK,
  3481. pointerX, pointerY, resizeX, resizeY,
  3482. resizeWidth, resizeHeight, &event);
  3483. }
  3484. if (pev->type == MotionNotify)
  3485. {
  3486. pointerX = pev->xmotion.x_root;
  3487. pointerY = pev->xmotion.y_root;
  3488. UpdateMarqueeSelectData (pSD);
  3489. }
  3490. else if (pev->type == KeyPress) {
  3491. /*
  3492. * Handle key event.
  3493. */
  3494. bDone = HandleMarqueeKeyPress (pSD, pev);
  3495. }
  3496. else if (pev->type == ButtonRelease) {
  3497. /*
  3498. * Update (x,y) to the location of the button release
  3499. */
  3500. pointerX = pev->xbutton.x_root;
  3501. pointerY = pev->xbutton.y_root;
  3502. UpdateMarqueeSelectData (pSD);
  3503. CompleteFrameConfig ((ClientData *)NULL, pev);
  3504. bDone = True;
  3505. }
  3506. else {
  3507. pev = NULL;
  3508. continue; /* ignore this event */
  3509. }
  3510. if (!bDone)
  3511. {
  3512. MoveOutline (marqueeX, marqueeY, marqueeWidth, marqueeHeight);
  3513. }
  3514. pev = NULL; /* reset event pointer */
  3515. } /* end while */
  3516. } /* END OF FUNCTION HandleMarqueeSelect */
  3517. /*************************************<->*************************************
  3518. *
  3519. * StartMarqueeSelect ()
  3520. *
  3521. *
  3522. * Description:
  3523. * -----------
  3524. * Start marquee selection on root window
  3525. *
  3526. *
  3527. * Inputs:
  3528. * ------
  3529. *
  3530. * Outputs:
  3531. * -------
  3532. *
  3533. *
  3534. * Comments:
  3535. * --------
  3536. *
  3537. *************************************<->***********************************/
  3538. void
  3539. StartMarqueeSelect(WmScreenData *pSD, XEvent *pev)
  3540. {
  3541. Window grab_win, junk_win;
  3542. Boolean grabbed;
  3543. int big_inc;
  3544. int junk;
  3545. if (!pSD->bMarqueeSelectionInitialized)
  3546. {
  3547. /*
  3548. * If we haven't initialized the marquee selection messaging
  3549. * then do so here before we do any grabs. Sending a dummy
  3550. * message will do.
  3551. *
  3552. * (If we move off of ICCCM messaging, then this can go away.)
  3553. */
  3554. dtSendMarqueeSelectionNotification(pSD, DT_MARQUEE_SELECT_END,
  3555. 0, 0, 0, 0);
  3556. pSD->bMarqueeSelectionInitialized = True;
  3557. }
  3558. /*
  3559. * Do our grabs
  3560. */
  3561. if (!configGrab)
  3562. {
  3563. grab_win = RootWindow (DISPLAY, pSD->screen);
  3564. if (pev)
  3565. {
  3566. grabbed = DoGrabs (grab_win, wmGD.configCursor,
  3567. PGRAB_MASK, pev->xbutton.time, NULL, True);
  3568. }
  3569. else
  3570. {
  3571. grabbed = DoGrabs (grab_win, wmGD.configCursor,
  3572. PGRAB_MASK, CurrentTime, NULL, True);
  3573. }
  3574. if (!grabbed)
  3575. {
  3576. return;
  3577. }
  3578. configGrab = TRUE;
  3579. }
  3580. else
  3581. {
  3582. /* continue with the configuration in progress (!!!) */
  3583. return;
  3584. }
  3585. /*
  3586. * Set up static variables for succeeding events
  3587. */
  3588. if (pev && ((pev->type == ButtonPress) || (pev->type == ButtonRelease)))
  3589. {
  3590. pointerX = pev->xbutton.x_root;
  3591. pointerY = pev->xbutton.y_root;
  3592. }
  3593. else if (!XQueryPointer (DISPLAY, pSD->rootWindow,
  3594. &junk_win, &junk_win,
  3595. &pointerX, &pointerY,
  3596. &junk, &junk, (unsigned int *)&junk))
  3597. {
  3598. CancelFrameConfig ((ClientData *)NULL); /* release grabs */
  3599. return;
  3600. }
  3601. /* save start values to see where we came from */
  3602. marqueeX = startX = pointerX;
  3603. marqueeY = startY = pointerY;
  3604. marqueeWidth0 = marqueeWidth = 0;
  3605. marqueeHeight0 = marqueeHeight = 0;
  3606. marqueeAnchor = ANCHOR_NW;
  3607. /* compute increment value for dynamic update */
  3608. big_inc = DisplayWidth (DISPLAY, pSD->screen) / 20;
  3609. /* set configuring data */
  3610. wmGD.configAction = MARQUEE_SELECT;
  3611. wmGD.configButton = pev ? pev->xbutton.button: 0;
  3612. dtSendMarqueeSelectionNotification(pSD, DT_MARQUEE_SELECT_BEGIN,
  3613. marqueeX, marqueeY, marqueeWidth, marqueeHeight);
  3614. } /* END OF FUNCTION StartMarqueeSelect */
  3615. /*************************************<->*************************************
  3616. *
  3617. * UpdateMarqueeSelectData ()
  3618. *
  3619. *
  3620. * Description:
  3621. * -----------
  3622. *
  3623. * Inputs:
  3624. * ------
  3625. * pSD - pointer to screen data
  3626. *
  3627. * Outputs:
  3628. * -------
  3629. *
  3630. *
  3631. * Comments:
  3632. * --------
  3633. *************************************<->***********************************/
  3634. void UpdateMarqueeSelectData (WmScreenData *pSD)
  3635. {
  3636. /* validate and update anchor point and marquee data */
  3637. switch (marqueeAnchor)
  3638. {
  3639. case ANCHOR_NW:
  3640. marqueeWidth = pointerX - marqueeX;
  3641. marqueeHeight = pointerY - marqueeY;
  3642. if (marqueeWidth < 0)
  3643. {
  3644. marqueeWidth = -marqueeWidth;
  3645. marqueeX = pointerX;
  3646. if (marqueeHeight < 0)
  3647. {
  3648. marqueeHeight = -marqueeHeight;
  3649. marqueeY = pointerY;
  3650. marqueeAnchor = ANCHOR_SE;
  3651. }
  3652. else
  3653. {
  3654. marqueeAnchor = ANCHOR_NE;
  3655. }
  3656. }
  3657. else if (marqueeHeight < 0)
  3658. {
  3659. marqueeHeight = -marqueeHeight;
  3660. marqueeY = pointerY;
  3661. marqueeAnchor = ANCHOR_SW;
  3662. }
  3663. break;
  3664. case ANCHOR_NE:
  3665. marqueeWidth += marqueeX - pointerX;
  3666. marqueeHeight = pointerY - marqueeY;
  3667. marqueeX = pointerX;
  3668. if (marqueeWidth < 0)
  3669. {
  3670. marqueeWidth = -marqueeWidth;
  3671. marqueeX = pointerX - marqueeWidth;
  3672. if (marqueeHeight < 0)
  3673. {
  3674. marqueeHeight = -marqueeHeight;
  3675. marqueeY = pointerY;
  3676. marqueeAnchor = ANCHOR_SW;
  3677. }
  3678. else
  3679. {
  3680. marqueeAnchor = ANCHOR_NW;
  3681. }
  3682. }
  3683. else if (marqueeHeight < 0)
  3684. {
  3685. marqueeHeight = -marqueeHeight;
  3686. marqueeY = pointerY;
  3687. marqueeAnchor = ANCHOR_SE;
  3688. }
  3689. break;
  3690. case ANCHOR_SE:
  3691. marqueeWidth += marqueeX - pointerX;
  3692. marqueeHeight += marqueeY - pointerY;
  3693. marqueeX = pointerX;
  3694. marqueeY = pointerY;
  3695. if (marqueeWidth < 0)
  3696. {
  3697. marqueeWidth = -marqueeWidth;
  3698. marqueeX = pointerX - marqueeWidth;
  3699. if (marqueeHeight < 0)
  3700. {
  3701. marqueeHeight = -marqueeHeight;
  3702. marqueeY = pointerY - marqueeHeight;
  3703. marqueeAnchor = ANCHOR_NW;
  3704. }
  3705. else
  3706. {
  3707. marqueeAnchor = ANCHOR_SW;
  3708. }
  3709. }
  3710. else if (marqueeHeight < 0)
  3711. {
  3712. marqueeHeight = -marqueeHeight;
  3713. marqueeY = pointerY - marqueeHeight;
  3714. marqueeAnchor = ANCHOR_NE;
  3715. }
  3716. break;
  3717. case ANCHOR_SW:
  3718. marqueeWidth = pointerX - marqueeX;
  3719. marqueeHeight += marqueeY - pointerY;
  3720. marqueeY = pointerY;
  3721. if (marqueeWidth < 0)
  3722. {
  3723. marqueeWidth = -marqueeWidth;
  3724. marqueeX = pointerX;
  3725. if (marqueeHeight < 0)
  3726. {
  3727. marqueeHeight = -marqueeHeight;
  3728. marqueeY = pointerY - marqueeHeight;
  3729. marqueeAnchor = ANCHOR_NE;
  3730. }
  3731. else
  3732. {
  3733. marqueeAnchor = ANCHOR_SE;
  3734. }
  3735. }
  3736. else if (marqueeHeight < 0)
  3737. {
  3738. marqueeHeight = -marqueeHeight;
  3739. marqueeY = pointerY - marqueeHeight;
  3740. marqueeAnchor = ANCHOR_NW;
  3741. }
  3742. break;
  3743. }
  3744. if ((wmGD.marqueeSelectGranularity > 0) &&
  3745. ((ABS(marqueeWidth-marqueeWidth0) > wmGD.marqueeSelectGranularity) ||
  3746. (ABS(marqueeHeight-marqueeHeight0)>wmGD.marqueeSelectGranularity)))
  3747. {
  3748. dtSendMarqueeSelectionNotification(pSD, DT_MARQUEE_SELECT_CONTINUE,
  3749. marqueeX, marqueeY, marqueeWidth, marqueeHeight);
  3750. marqueeWidth0 = marqueeWidth;
  3751. marqueeHeight0 = marqueeHeight;
  3752. }
  3753. }
  3754. /*************************************<->*************************************
  3755. *
  3756. * HandleMarqueeKeyPress (pSD, pev)
  3757. *
  3758. *
  3759. * Description:
  3760. * -----------
  3761. * Handles keypress events during resize of window
  3762. *
  3763. *
  3764. * Inputs:
  3765. * ------
  3766. * pSD - pointer to screen data
  3767. * pev - pointer to event
  3768. *
  3769. *
  3770. * Outputs:
  3771. * -------
  3772. * Return - True if this event completes (or cancels) resizing
  3773. *
  3774. *
  3775. * Comments:
  3776. * --------
  3777. *
  3778. *************************************<->***********************************/
  3779. Boolean HandleMarqueeKeyPress (WmScreenData *pSD, XEvent *pev)
  3780. {
  3781. KeySym keysym;
  3782. Boolean control;
  3783. int keyMult;
  3784. XEvent KeyEvent;
  3785. /*
  3786. * Compress repeated keys
  3787. */
  3788. keyMult = 1;
  3789. while (keyMult <= 10 &&
  3790. XCheckIfEvent (DISPLAY, &KeyEvent, IsRepeatedKeyEvent,
  3791. (char *) pev))
  3792. {
  3793. keyMult++;
  3794. }
  3795. keysym = XKeycodeToKeysym (DISPLAY, pev->xkey.keycode, 0);
  3796. control = (pev->xkey.state & ControlMask) != 0;
  3797. switch (keysym) {
  3798. case XK_Return:
  3799. CompleteFrameConfig ((ClientData *)NULL, pev);
  3800. return (True);
  3801. case XK_Escape:
  3802. CancelFrameConfig ((ClientData *)NULL);
  3803. CheckEatButtonRelease ((ClientData *)NULL, pev);
  3804. return (True);
  3805. default:
  3806. return (False); /* ignore this key */
  3807. } /* end switch(keysym) */
  3808. } /* END OF FUNCTION HandleResizeKeyPress */