12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789 |
- /*
- * CDE - Common Desktop Environment
- *
- * Copyright (c) 1993-2012, The Open Group. All rights reserved.
- *
- * These libraries and programs are free software; you can
- * redistribute them and/or modify them under the terms of the GNU
- * Lesser General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * These libraries and programs are distributed in the hope that
- * they will be useful, but WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with these libraries and programs; if not, write
- * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
- * Floor, Boston, MA 02110-1301 USA
- */
- /*
- * (c) Copyright 1989, 1990, 1991, 1992, 1993, 1994 OPEN SOFTWARE FOUNDATION, INC.
- * ALL RIGHTS RESERVED
- */
- /*
- * Motif Release 1.2.4
- */
- /*
- * (c) Copyright 1987, 1988, 1989, 1990 HEWLETT-PACKARD COMPANY */
- /*
- * Included Files:
- */
- #include "WmGlobal.h"
- #include "WmICCC.h"
- #include <X11/Xatom.h>
- /*
- * include extern functions
- */
- #include "WmCEvent.h"
- #include "WmCDecor.h"
- #include "WmCDInfo.h"
- #include "WmColormap.h"
- #include "WmEvent.h"
- #include "WmEwmh.h"
- #include "WmFeedback.h"
- #include "WmFunction.h"
- #include "WmIDecor.h"
- #include "WmKeyFocus.h"
- #include "WmPanelP.h"
- #include "WmManage.h"
- #include "WmMenu.h"
- #include "WmProperty.h"
- #include "WmProtocol.h"
- #include "WmWinConf.h"
- #include "WmWinInfo.h"
- #include "WmWinList.h"
- #include "WmWinState.h"
- #include "WmWrkspace.h"
- /*
- * Global Variables:
- */
- extern unsigned int buttonModifierMasks[];
- static void AcceptPrematureClientMessage (XClientMessageEvent *clientEvent)
- {
- XChangeProperty (DISPLAY, clientEvent->window,
- wmGD.xa_PREMATURE_XCLIENTMESSAGEEVENT_LIST,
- wmGD.xa_PREMATURE_XCLIENTMESSAGEEVENT_LIST, 8,
- PropModeAppend, (unsigned char *) clientEvent,
- sizeof(XClientMessageEvent));
- }
- /*************************************<->*************************************
- *
- * SetupCButtonBindings (window, buttonSpecs)
- *
- *
- * Description:
- * -----------
- * This function sets up the event handling necessary to support user
- * specified button bindings for window manager functions that apply to
- * the client window.
- *
- *
- * Inputs:
- * ------
- * window = grab window id
- *
- * buttonSpecs = list of button bindings for window manager functions
- *
- *************************************<->***********************************/
- void SetupCButtonBindings (Window window, ButtonSpec *buttonSpecs)
- {
- ButtonSpec *buttonSpec;
- unsigned int eventMask;
- unsigned int grabState;
- /*
- * If the context of the button binding includes "window" do button
- * grabs to get the button events that invoke window manger functions.
- * !!! don't do redundant grabs !!!
- */
- buttonSpec = buttonSpecs;
- while (buttonSpec)
- {
- if ((buttonSpec->context & F_CONTEXT_WINDOW) &&
- (buttonSpec->subContext & F_SUBCONTEXT_W_CLIENT))
- {
- eventMask = ButtonMotionMask | ButtonReleaseMask;
- if (buttonSpec->eventType == ButtonRelease)
- {
- /*
- * Don't include the button down in the grab state.
- */
- grabState = buttonSpec->state &
- ~(buttonModifierMasks[buttonSpec->button]);
- }
- else
- {
- grabState = buttonSpec->state;
- }
- WmGrabButton (DISPLAY, buttonSpec->button, grabState,
- window, False, eventMask, GrabModeSync,
- GrabModeAsync, None, None);
- }
- /*
- * If the window context is not "window" a general grab is not
- * necessary.
- */
- buttonSpec = buttonSpec->nextButtonSpec;
- }
- } /* END OF FUNCTION SetupCButtonBindings */
- /*************************************<->*************************************
- *
- * WmDispatchClientEvent (event)
- *
- *
- * Description:
- * -----------
- * This function detects and dispatches events that are reported to a client
- * frame or icon window that are not widget-related (i.e. they would not be
- * dispatched by the Xtk intrinsics).
- *
- *
- * Inputs:
- * ------
- * event = This is an X event that has been retrieved by XtNextEvent.
- *
- *
- * Outputs:
- * -------
- * RETURN = If True the event should be dispatched by the toolkit,
- * otherwise the event should not be dispatched.
- *
- *************************************<->***********************************/
- Boolean WmDispatchClientEvent (XEvent *event)
- {
- ClientData * pCD = NULL;
- #ifndef IBM_169380
- ClientData **cmap_window_data = NULL;
- #endif
- Boolean dispatchEvent = False;
- /*
- * Detect and dispatch non-widget events that have been reported to
- * an icon or a client window frame.
- */
- #ifndef IBM_169380
- if ((XFindContext (DISPLAY, event->xany.window, wmGD.windowContextType,
- (caddr_t *)&pCD)) &&
- (XFindContext (DISPLAY, event->xany.window, wmGD.cmapWindowContextType,
- (caddr_t *)&cmap_window_data)))
- #else
- if (XFindContext (DISPLAY, event->xany.window, wmGD.windowContextType,
- (caddr_t *)&pCD))
- #endif
- {
- /*
- * Set active screen if we're not sure.
- */
- if (wmGD.queryScreen)
- DetermineActiveScreen (event);
- /*
- * Handle events on windows that are made by mwm for
- * non-client-specific functions. Also handle "leftover"
- * events on windows that used to be managed by mwm
- * (e.g. ConfigureRequest events).
- */
- return (HandleEventsOnSpecialWindows (event));
- }
- #ifndef IBM_169380
- if (cmap_window_data)
- /*
- * Event is on a subwindow that is specified in one or more toplevel
- * window's WM_COLORMAP_WINDOWS property. (Most likely this is a
- * ColormapNotify event.) It could have more than one pCD associated
- * with it, so we have to choose one. If one of the pCD's currently has
- * the Colormap Focus, then let's use that one. Otherwise, just use
- * the 1st one.
- */
- {
- int j;
- for (j = 0; cmap_window_data[j]; j++)
- {
- if (ACTIVE_PSD->colormapFocus == cmap_window_data[j])
- {
- pCD = cmap_window_data[j];
- break;
- }
- }
- /*
- * None of the pCD's in the list have Colormap Focus. So, just
- * set pCD to the 1st one in the list.
- */
- if (!pCD)
- pCD = cmap_window_data[0];
- }
- #endif
- /*
- * Set active screen if this is not a FocusOut event.
- * We don't need to set it on focus out AND we use
- * (SCREEN_FOR_CLIENT(pCD) != ACTIVE_SCREEN) in
- * in HandleCFocusOut to determine if a new colormap needs
- * to be installed.
- */
- if (!(event->type == FocusOut))
- {
- SetActiveScreen (PSD_FOR_CLIENT(pCD));
- }
- /* Get workspace specific client data */
- SetClientWsIndex (pCD);
- /*
- * Handle events on top-level client windows.
- */
- if (event->xany.window == pCD->client)
- {
- return (HandleEventsOnClientWindow (pCD, event));
- }
- /*
- * Handle events on windows created by mwm (for icons and client window
- * frames) and on non-top-level client windows (e.g., colormap
- * windows).
- */
- switch (event->type)
- {
- case ButtonPress:
- {
- dispatchEvent = HandleCButtonPress (pCD, (XButtonEvent *)event);
- break;
- }
- case ButtonRelease:
- {
- if (wmGD.menuActive)
- {
- dispatchEvent = True; /* have the toolkit dispatch the event */
- }
- else
- {
- HandleCButtonRelease (pCD, (XButtonEvent *)event);
- }
- break;
- }
- case KeyPress:
- {
- dispatchEvent = HandleCKeyPress (pCD, (XKeyEvent *)event);
- break;
- }
- case MotionNotify:
- {
- HandleCMotionNotify (pCD, (XMotionEvent *)event);
- break;
- }
- case Expose:
- {
- /*
- * If multiple expose events, wait for last one.
- */
- if (event->xexpose.count == 0)
- {
- if (event->xexpose.window == ICON_FRAME_WIN(pCD))
- {
- IconExposureProc (pCD, True);
- if (P_ICON_BOX(pCD))
- {
- dispatchEvent = True;
- }
- }
- else if (event->xexpose.window ==
- pCD->pSD->activeIconTextWin)
- {
- PaintActiveIconText (pCD, FALSE);
- }
- else if (!(pCD->clientFlags & CLIENT_DESTROYED))
- {
- if ((event->xexpose.window == pCD->clientFrameWin) ||
- (event->xexpose.window == pCD->clientTitleWin))
- {
- FrameExposureProc (pCD);
- }
- if (event->xexpose.window == pCD->clientBaseWin)
- {
- BaseWinExposureProc (pCD);
- }
- }
- else if (pCD->clientFlags & FRONT_PANEL_BOX)
- {
- /*
- *
- * Then this client is the shell for the
- * front panel and we want the toolkit to repaint
- * it.
- *
- */
- dispatchEvent = True;
- }
- }
- break;
- }
- case EnterNotify:
- {
- HandleCEnterNotify (pCD, (XEnterWindowEvent *)event);
- break;
- }
- case LeaveNotify:
- {
- HandleCLeaveNotify (pCD, (XLeaveWindowEvent *)event);
- break;
- }
- case FocusIn:
- {
- dispatchEvent = HandleCFocusIn (pCD, (XFocusChangeEvent *)event);
- break;
- }
- case FocusOut:
- {
- dispatchEvent = HandleCFocusOut (pCD, (XFocusChangeEvent *)event);
- break;
- }
- case DestroyNotify:
- {
- if (((XDestroyWindowEvent *)event)->window == pCD->client)
- {
- pCD->clientFlags |= CLIENT_DESTROYED;
- UnManageWindow (pCD);
- }
- break;
- }
- case UnmapNotify:
- {
- /*
- * This event is generated when a managed client window is
- * unmapped by the client or when the window manager unmaps the
- * client window; check the wmMapCount to determine if this is
- * the result of a window manager unmap. If this is a client
- * unmap then the window is to be withdrawn from window manager
- * control.
- */
- if (((XUnmapEvent *)event)->window == pCD->client)
- {
- if (pCD->wmUnmapCount)
- {
- pCD->wmUnmapCount--;
- }
- else
- {
- UnManageWindow (pCD);
- }
- }
- break;
- }
- case MapRequest:
- {
- /*
- * This is a request to change the state of the client window from
- * iconic (minimized) to normal.
- */
- if (!ClientInWorkspace (ACTIVE_WS, pCD))
- {
- if (pCD->absentMapBehavior == AMAP_BEHAVIOR_IGNORE)
- {
- SetClientState (pCD, NORMAL_STATE|UNSEEN_STATE,
- GetTimestamp ());
- }
- else
- {
- HonorAbsentMapBehavior(pCD);
- SetClientState (pCD, NORMAL_STATE, GetTimestamp ());
- }
- }
- else
- {
- SetClientState (pCD, NORMAL_STATE, GetTimestamp ());
- }
- break;
- }
- case ConfigureRequest:
- {
- HandleCConfigureRequest (pCD, (XConfigureRequestEvent *)event);
- break;
- }
- case ColormapNotify:
- {
- /*
- * Process changes to client window colormaps:
- */
- HandleCColormapNotify (pCD, (XColormapEvent *)event);
- break;
- }
- case ClientMessage:
- {
- /*
- * Handle client message events.
- */
- HandleClientMessage (pCD, (XClientMessageEvent *)event);
- break;
- }
- case ReparentNotify:
- {
- if ((((XReparentEvent *)event)->window == pCD->client) &&
- (((XReparentEvent *)event)->parent != pCD->clientBaseWin))
- {
- /*
- * The window was reparented away from the frame.
- * Unmanage to clean up the now empty frame.
- *
- * Note: We get here when the reparent is done while
- * the client is unmapped (e.g. iconified). Otherwise
- * the reparent will generate an UnmapNotify which
- * will also cause us to unmanage the client.
- */
- UnManageWindow (pCD);
- }
- break;
- }
- } /* end of event.type switch */
- return (dispatchEvent);
- } /* END OF FUNCTION WmDispatchClientEvent */
- /*************************************<->*************************************
- *
- * HandleEventsOnSpecialWindows (pEvent)
- *
- *
- * Description:
- * -----------
- * Handles events on special window manager windows and "leftover" events
- * from destroyed client window frames.
- *
- *
- * Inputs:
- * ------
- * pEvent = pointer to an XEvent structure
- *
- *
- * Outputs:
- * -------
- * RETURN = If True the event should be dispatched by the toolkit,
- * otherwise the event should not be dispatched.
- *
- *************************************<->***********************************/
- Boolean HandleEventsOnSpecialWindows (XEvent *pEvent)
- {
- Boolean dispatchEvent = True;
- WmScreenData *pSD;
- /*
- * The window is not a root window or a client frame window. Check for
- * a special window manager window. Have the toolkit dispatch the event
- * if the event is not on a special window.
- */
- if (pEvent->xany.window == ACTIVE_ROOT)
- {
- if (pEvent->type == FocusIn)
- {
- SetKeyboardFocus ((ClientData *) NULL, REFRESH_LAST_FOCUS);
- }
- }
- else if (pEvent->xany.window == ACTIVE_PSD->feedbackWin)
- {
- if (pEvent->type == Expose)
- {
- if (pEvent->xexpose.count == 0)
- {
- PaintFeedbackWindow(ACTIVE_PSD);
- }
- }
- dispatchEvent = False; /* don't have the toolkit dispatch the event */
- }
- else if (pEvent->xany.window == ACTIVE_PSD->inputScreenWindow)
- {
- if (pEvent->type == ButtonPress)
- {
- F_Beep (NULL, (ClientData *) NULL, (XEvent *) NULL);
- }
- else if ((wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_POINTER) &&
- (pEvent->type == EnterNotify))
- {
- HandleWsEnterNotify ((XEnterWindowEvent *)pEvent);
- }
- dispatchEvent = False; /* don't have the toolkit dispatch the event */
- }
- else if (!XFindContext (DISPLAY, pEvent->xany.window,
- wmGD.mwmWindowContextType, (caddr_t *)&pSD))
- {
- if ((pEvent->type == PropertyNotify) &&
- (pEvent->xproperty.atom == wmGD.xa_DT_WM_REQUEST) &&
- (pEvent->xproperty.state == PropertyNewValue))
- {
- HandleDtWmRequest (pSD, pEvent);
- }
- if (pEvent->type == ClientMessage)
- {
- HandleDtWmClientMessage ((XClientMessageEvent *)pEvent);
- }
- }
- else
- {
- /*
- * Events may come in for a client frame base window that no
- * longer exists (the client window was just unmanaged but the
- * the client did some action before the un-reparenting was
- * actually done). Confirm that this is the case and then
- * handle the request as if it came in as a root window event.
- */
- switch (pEvent->type)
- {
- case ConfigureRequest:
- {
- if (GetParentWindow (pEvent->xconfigurerequest.window) ==
- ACTIVE_ROOT)
- {
- /*
- * This is an event for a client base window that
- * no longer exists. Handle the event as if it is a
- * root window event.
- */
- dispatchEvent = WmDispatchWsEvent (pEvent);
- }
- break;
- }
- case MapRequest:
- {
- if (GetParentWindow (pEvent->xmaprequest.window) ==
- ACTIVE_ROOT)
- {
- /*
- * This is an event for a client base window that
- * no longer exists. Handle the event as if it is a
- * root window event.
- */
- dispatchEvent = WmDispatchWsEvent (pEvent);
- }
- break;
- }
- case ClientMessage:
- {
- AcceptPrematureClientMessage ((XClientMessageEvent *)pEvent);
- break;
- }
- }
- }
- return (dispatchEvent);
- } /* END OF FUNCTION HandleEventsOnSpecialWindows */
- /*************************************<->*************************************
- *
- * HandleEventsOnClientWindow (pCD, pEvent)
- *
- *
- * Description:
- * -----------
- * Handles events on a client top-level window.
- *
- *
- * Inputs:
- * ------
- * pCD = pointer to client data
- *
- * pEvent = pointer to an XEvent structure
- *
- *
- * Outputs:
- * -------
- * RETURN = If True the event should be dispatched by the toolkit,
- * otherwise the event should not be dispatched.
- *
- *************************************<->***********************************/
- Boolean HandleEventsOnClientWindow (ClientData *pCD, XEvent *pEvent)
- {
- Boolean doXtDispatchEvent = True;
- if (pEvent->type == (wmGD.shapeEventBase+ShapeNotify))
- {
- HandleCShapeNotify (pCD, (XShapeEvent *)pEvent);
- }
- else
- switch (pEvent->type)
- {
- case ColormapNotify:
- {
- /*
- * Process changes to top-level client window colormaps:
- */
- HandleCColormapNotify (pCD, (XColormapEvent *)pEvent);
- doXtDispatchEvent = False;
- break;
- }
- case PropertyNotify:
- {
- /*
- * Process property changes on managed client windows:
- */
-
- HandleCPropertyNotify (pCD, (XPropertyEvent *)pEvent);
- doXtDispatchEvent = False;
- break;
- }
- case ClientMessage:
- {
- /*
- * Handle client message events.
- */
- HandleClientMessage (pCD, (XClientMessageEvent *)pEvent);
- break;
- }
- }
- return (doXtDispatchEvent);
- } /* END OF FUNCTION HandleEventsOnClientWindow */
- /*************************************<->*************************************
- *
- * HandleCPropertyNotify (pCD, propertyEvent)
- *
- *
- * Description:
- * -----------
- * This function handles propertyNotify events (indicating window property
- * changes) that are reported to the client window.
- *
- *
- * Inputs:
- * ------
- * pCD = pointer to the client data for the client window that got the event
- *
- * propertyEvent = propertyNotify event that was received
- *
- *************************************<->***********************************/
- void HandleCPropertyNotify (ClientData *pCD, XPropertyEvent *propertyEvent)
- {
- switch (propertyEvent->atom)
- {
- case XA_WM_HINTS:
- {
- ProcessWmHints (pCD, FALSE /*not first time*/);
- break;
- }
-
- case XA_WM_NORMAL_HINTS:
- {
- ProcessWmNormalHints (pCD, FALSE /*not first time*/, 0);
- break;
- }
-
- case XA_WM_CLASS:
- {
- break;
- }
-
- case XA_WM_COMMAND:
- {
- if (pCD->clientFlags & CLIENT_TERMINATING)
- {
- DeleteClientWmTimers (pCD);
- XKillClient (DISPLAY, pCD->client);
- }
- break;
- }
- case XA_WM_TRANSIENT_FOR:
- {
- /*
- * here we handle the special case of dialogs that are
- * mapped before the windows they are transient for are
- * mapped. Xm handles this case by waiting for the
- * transient_for window to appear before setting the
- * WM_TRANSIENT_FOR property on the dialog. Mwm has to
- * notice this property change and re-organize things
- * so the dialog is treated as a transient window.
- *
- * Note that we also handle the case of the WM_TRANSIENT_FOR
- * property being removed.
- */
- DeleteClientFromList (pCD->pSD->pActiveWS, pCD);
- ProcessWmTransientFor(pCD);
- AddClientToList(pCD->pSD->pActiveWS, pCD, True);
- if (pCD->transientLeader != NULL)
- StackTransientWindow(pCD);
- break;
- }
-
- default:
- {
- if (propertyEvent->atom == wmGD.xa_WM_PROTOCOLS)
- {
- ProcessWmProtocols (pCD);
- }
- else if (propertyEvent->atom == wmGD.xa_DT_WORKSPACE_HINTS)
- {
- (void) ProcessWorkspaceHints (pCD);
- }
- else if (propertyEvent->atom == wmGD.xa_MWM_MESSAGES)
- {
- if (pCD->protocolFlags & PROTOCOL_MWM_MESSAGES)
- {
- ProcessMwmMessages (pCD);
- }
- }
- else if (propertyEvent->atom == wmGD.xa_SM_CLIENT_ID)
- {
- ProcessSmClientID(pCD);
- }
- else if (propertyEvent->atom == wmGD.xa_WMSAVE_HINT)
- {
- ProcessWmSaveHint(pCD);
- }
- else if (propertyEvent->atom == wmGD.xa_WM_COLORMAP_WINDOWS)
- {
- if (propertyEvent->state == PropertyNewValue)
- {
- ProcessWmColormapWindows (pCD);
- }
- else
- {
- /* property was deleted */
- ResetColormapData (pCD, NULL, 0);
- }
- if ((ACTIVE_PSD->colormapFocus == pCD) &&
- ((pCD->clientState == NORMAL_STATE) ||
- (pCD->clientState == MAXIMIZED_STATE)))
- {
- /*
- * The client window has the colormap focus, install the
- * colormap.
- */
- /*
- * We just changed the colormaps list,
- * so we need to re-run the whole thing.
- */
- pCD->clientCmapFlagsInitialized = 0;
- ProcessColormapList (ACTIVE_PSD, pCD);
- }
- }
- else if (propertyEvent->atom == wmGD.xa_MWM_HINTS)
- {
- long suppliedReturn;
- XSizeHints hintsReturn = {0};
- XGetWMNormalHints (DISPLAY, pCD->client, &hintsReturn,
- &suppliedReturn);
- hintsReturn.flags |= P_MAX_SIZE;
- hintsReturn.max_width = -1;
- hintsReturn.max_height = -1;
- XSetWMNormalHints (DISPLAY, pCD->client, &hintsReturn);
- ProcessMwmHints (pCD);
- SetClientOffset (pCD);
- }
- else if (propertyEvent->atom == XA_WM_NAME ||
- propertyEvent->atom == wmGD.xa__NET_WM_NAME)
- {
- ProcessWmWindowTitle (pCD, FALSE /*not first time*/);
- }
- else if (propertyEvent->atom == XA_WM_ICON_NAME ||
- propertyEvent->atom == wmGD.xa__NET_WM_ICON_NAME)
- {
- ProcessWmIconTitle (pCD, FALSE /*not first time*/);
- }
- break;
- }
- }
- } /* END OF FUNCTION HandleCPropertyNotify */
- /*************************************<->*************************************
- *
- * HandleCButtonPress (pCD, buttonEvent)
- *
- *
- * Description:
- * -----------
- * This function does window management actions associated with a button
- * press event on the client window (including frame) or icon.
- *
- *
- * Inputs:
- * ------
- * pCD = pointer to client data (identifies client window)
- *
- * buttonEvent = ButtonPress event on client window
- *
- *
- * Outputs:
- * -------
- * RETURN = True if the event should be dispatched by XtDispatchEvent
- *
- *************************************<->***********************************/
- Boolean HandleCButtonPress (ClientData *pCD, XButtonEvent *buttonEvent)
- {
- Boolean dispatchEvent = False;
- Boolean replayEvent = True;
- Context context;
- int partContext;
- Context subContext;
- static Time baseWinTime = 0;
- static unsigned int baseWinButton = 0;
- wmGD.passButtonsCheck = True;
- /*
- * Find out the event context and process the event accordingly.
- * If the event is due to a key focus selection grab or an application
- * modal grab then handle the grab (only these types of grabs are
- * done on the client window frame base window)..
- */
- if (wmGD.menuActive)
- {
- dispatchEvent = True; /* have the toolkit dispatch the event */
- }
- else
- {
- IdentifyEventContext (buttonEvent, pCD, &context, &partContext);
- subContext = (1L << partContext);
- if (buttonEvent->window == pCD->clientBaseWin)
- {
- /* save time of event caught by base window grab */
- baseWinTime = buttonEvent->time;
- baseWinButton = buttonEvent->button;
- }
-
- /*
- * If this event was caught by the base window grab and
- * replayed, then don't reprocess if caught by the frame
- * window. (Replayed events have the same time.)
- */
- if (!((buttonEvent->window == pCD->clientFrameWin) &&
- (buttonEvent->button == baseWinButton) &&
- (buttonEvent->time == baseWinTime)))
- {
- /*
- * Motif 1.2, ignore replayed events UNPOST_AND_REPLAY events
- * generated from the menu system (time stamps are exactly
- * the same for the replayed event)
- */
- if (wmGD.clickData.time == buttonEvent->time)
- {
- dispatchEvent = False;
- }
- else
- {
- ProcessClickBPress (buttonEvent, pCD, context, subContext);
- }
- if (CheckForButtonAction (buttonEvent, context, subContext, pCD))
- {
- /*
- * Button bindings have been processed, now check for bindings
- * that associated with the built-in semantics of the window
- * frame decorations.
- */
- CheckButtonPressBuiltin (buttonEvent, context, subContext,
- partContext, pCD);
- /*
- * For case where button action causes lower, but
- * builtin causes focus - disable auto raise until
- * we receive focusIn or focusOut.
- */
- pCD->focusAutoRaiseDisablePending = False;
- }
- else
- {
- /*
- * Else skip built-in processing due to execution of a function
- * that does on-going event processing or that has changed the
- * client state (e.g., f.move or f.minimize).
- */
- replayEvent = False;
- }
- }
- }
- if (buttonEvent->window == pCD->clientBaseWin)
- {
- ProcessButtonGrabOnClient (pCD, buttonEvent, replayEvent);
- }
- return (dispatchEvent);
- } /* END OF FUNCTION HandleCButtonPress */
- /*************************************<->*************************************
- *
- * ProcessButtonGrabOnClient (pCD, buttonEvent, replayEvent)
- *
- *
- * Description:
- * -----------
- * This function handles an activated button grab on the client window
- * frame base window.
- *
- *
- * Inputs:
- * ------
- * pCD = pointer to client data of window associated with the grab
- *
- * buttonEvent = ButtonPress event on client window
- *
- * replayEvent = True if event should be replayed
- *
- *************************************<->***********************************/
- void ProcessButtonGrabOnClient (ClientData *pCD, XButtonEvent *buttonEvent, Boolean replayEvent)
- {
- ButtonSpec *buttonSpec;
- Boolean passButton;
- if ((buttonEvent->button == SELECT_BUTTON) &&
- ((buttonEvent->state == 0) ||
- (NOLOCKMOD(buttonEvent->state) == 0)))
- {
- passButton = wmGD.passSelectButton;
- }
- else
- {
- passButton = wmGD.passButtons;
- }
- if (IS_APP_MODALIZED(pCD) || !passButton)
- {
- replayEvent = False;
- }
- else if (replayEvent)
- {
- /*
- * Replay the event as long as there is not another button binding
- * for the button release.
- */
- buttonSpec = ACTIVE_PSD->buttonSpecs;
- while (buttonSpec)
- {
- if ((buttonSpec->eventType == ButtonRelease) &&
- ((buttonEvent->state == buttonSpec->state) ||
- (NOLOCKMOD(buttonEvent->state) == buttonSpec->state)) &&
- (buttonEvent->button == buttonSpec->button))
- {
- replayEvent = False;
- break;
- }
- buttonSpec = buttonSpec->nextButtonSpec;
- }
- }
- if (replayEvent && wmGD.passButtonsCheck)
- {
- XAllowEvents (DISPLAY, ReplayPointer, CurrentTime);
- }
- else
- {
- if (IS_APP_MODALIZED(pCD))
- {
- /*
- * The grab is done on a window that has an application modal
- * secondary window. Beep to indicate no client processing of
- * the event.
- */
- F_Beep (NULL, pCD, (XEvent *) NULL);
- }
- XAllowEvents (DISPLAY, AsyncPointer, CurrentTime);
- }
- XAllowEvents (DISPLAY, AsyncKeyboard, CurrentTime);
- } /* END OF FUNCTION ProcessButtonGrabOnClient */
- /*************************************<->*************************************
- *
- * CheckButtonPressBuiltin (buttonEvent, context, subContext, partContext, pCD)
- *
- *
- * Description:
- * -----------
- * This function checks to see if a built-in window manager function
- * has been selected. If yes, then the function is done.
- *
- *
- * Inputs:
- * ------
- * buttonEvent = pointer to button event
- *
- * context = button event context (root, icon, window)
- *
- * subContext = button event subcontext (title, system button, ...)
- *
- * partContext = part context within a window manager component
- *
- *************************************<->***********************************/
- void CheckButtonPressBuiltin (XButtonEvent *buttonEvent, Context context, Context subContext, int partContext, ClientData *pCD)
- {
- /*
- * All builtin button bindings are based on button 1 with no
- * modifiers. (Ignore locking modifiers)
- */
- if (((buttonEvent->button != SELECT_BUTTON) &&
- (buttonEvent->button != DMANIP_BUTTON)) ||
- NOLOCKMOD(buttonEvent->state))
- {
- return;
- }
- /*
- * Process the builtin button bindings based on the window manager
- * component that was selected.
- */
- if (context & F_CONTEXT_ICON)
- {
- HandleIconButtonPress (pCD, buttonEvent);
- }
- else if (context & F_CONTEXT_ICONBOX)
- {
- HandleIconBoxButtonPress (pCD, buttonEvent, subContext);
- }
- else if (context & F_CONTEXT_WINDOW)
- {
- /*
- * A client window frame component was selected.
- */
- /*
- * If the keyboard focus policy is explicit then all window frame
- * components set the keyboard input focus when selected.
- */
- if (wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_EXPLICIT)
- {
- /* If we've just done f.lower, disable focusAutoRaise. */
- if (pCD && pCD->focusAutoRaiseDisablePending)
- pCD->focusAutoRaiseDisabled = True;
- Do_Focus_Key (pCD, buttonEvent->time,
- (long)((partContext == FRAME_CLIENT) ? CLIENT_AREA_FOCUS : 0));
- }
- /*
- * Process the builtin button bindings based on the client window
- * frame component that was selected.
- */
- if ((buttonEvent->button == SELECT_BUTTON) &&
- (subContext == F_SUBCONTEXT_W_SYSTEM))
- {
- int flags = 0;
- /*
- * System menu button component:
- * SELECT_BUTTON Press - post the system menu.
- * SELECT_BUTTON double-click - close the window.
- */
- PushGadgetIn (pCD, partContext);
- if ((wmGD.clickData.doubleClickContext == F_SUBCONTEXT_W_SYSTEM) &&
- wmGD.systemButtonClick2 &&
- (pCD->clientFunctions & MWM_FUNC_CLOSE))
- {
- /*
- * Close the client window. Don't do any of the other
- * system menu button actions.
- */
- wmGD.clickData.clickPending = False;
- wmGD.clickData.doubleClickPending = False;
- F_Kill (NULL, pCD, (XEvent *) buttonEvent);
- return;
- }
- if (pCD->clientState == NORMAL_STATE)
- {
- context = F_CONTEXT_NORMAL;
- }
- else if (pCD->clientState == MAXIMIZED_STATE)
- {
- context = F_CONTEXT_MAXIMIZE;
- }
- else
- {
- context = F_CONTEXT_ICON;
- }
- /*
- * Set up for "sticky" menu processing if specified.
- */
- if (wmGD.systemButtonClick)
- {
- wmGD.checkHotspot = True;
- flags |= POST_STICKY;
- }
- pCD->grabContext = context;
- PostMenu (pCD->systemMenuSpec, pCD, 0, 0, SELECT_BUTTON,
- context, flags, (XEvent *)buttonEvent);
- }
- else if (subContext == F_SUBCONTEXT_W_TITLE)
- {
- /*
- * Title component:
- * SELECT_BUTTON or DMANIP_BUTTON Press -
- * start looking for a move.
- */
- PushGadgetIn (pCD, partContext);
- /*
- * Fix for 5075 - Check to make sure that MWM_FUNC_MOVE is set in the
- * clientFunctions. This is necessary because the title
- * bar is added based on a number of decorations even if
- * the resources or the user has specifically requested
- * that "move" not be one of them.
- */
- if (pCD && (pCD->clientFunctions & MWM_FUNC_MOVE))
- {
- wmGD.preMove = True;
- wmGD.preMoveX = buttonEvent->x_root;
- wmGD.preMoveY = buttonEvent->y_root;
- wmGD.configButton = buttonEvent->button;
- wmGD.configAction = MOVE_CLIENT;
- }
- /*
- * End fix 5075
- */
- }
- else if (subContext & F_SUBCONTEXT_W_RBORDER)
- {
- /*
- * Resize border handle components:
- * SELECT_BUTTON or DMANIP_BUTTON Press -
- * start looking for a resize.
- */
- wmGD.preMove = True;
- wmGD.preMoveX = buttonEvent->x_root;
- wmGD.preMoveY = buttonEvent->y_root;
- wmGD.configButton = buttonEvent->button;
- wmGD.configAction = RESIZE_CLIENT;
- wmGD.configPart = partContext;
- wmGD.configSet = True;
- }
- else if ((buttonEvent->button == SELECT_BUTTON) &&
- (subContext & (F_SUBCONTEXT_W_MINIMIZE|F_SUBCONTEXT_W_MAXIMIZE)))
- {
- /*
- * Minimize and maximize button components:
- * SELECT_BUTTON Press - start of a click.
- */
- PushGadgetIn (pCD, partContext);
- }
-
- /*
- * Other components: no action
- */
- }
- } /* END OF FUNCTION CheckButtonPressBuiltin */
- /*************************************<->*************************************
- *
- * HandleIconButtonPress (pCD, buttonEvent)
- *
- *
- * Description:
- * -----------
- * This function handles builtin functions in the icon context.
- *
- *
- * Inputs:
- * ------
- * pCD = pointer to client data of the icon that received the button event
- *
- * buttonEvent = pointer to the button event that occurred
- *
- *************************************<->***********************************/
- void HandleIconButtonPress (ClientData *pCD, XButtonEvent *buttonEvent)
- {
- int newState;
- /*
- * Do icon component button press actions:
- * Button 1 press - set the keyboard input focus if policy is explicit
- * Button 1 double-click - normalize the icon
- */
- if (wmGD.clickData.doubleClickContext == F_SUBCONTEXT_I_ALL)
- {
- /*
- * A double-click was done, normalize the icon.
- */
- if (pCD->maxConfig)
- {
- newState = MAXIMIZED_STATE;
- }
- else
- {
- newState = NORMAL_STATE;
- }
- SetClientState (pCD, newState, buttonEvent->time);
- wmGD.clickData.clickPending = False;
- wmGD.clickData.doubleClickPending = False;
- }
- else
- {
- /*
- * This is a regular button press (it may be the start of a
- * double-click). Set the focus and top the icon if appropriate.
- */
- if (wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_EXPLICIT)
- {
- Do_Focus_Key (pCD, buttonEvent->time, ALWAYS_SET_FOCUS);
- }
- /*
- * Indicate that a move may be starting; wait for button motion
- * events before moving the icon.
- */
- wmGD.preMove = True;
- wmGD.preMoveX = buttonEvent->x_root;
- wmGD.preMoveY = buttonEvent->y_root;
- wmGD.configButton = buttonEvent->button;
- wmGD.configAction = MOVE_CLIENT;
- }
- } /* END OF FUNCTION HandleIconButtonPress */
- /*************************************<->*************************************
- *
- * HandleIconBoxButtonPress (pCD, buttonEvent, subContext)
- *
- *
- * Description:
- * -----------
- * This function handles builtin functions in the iconbox context.
- *
- *
- * Inputs:
- * ------
- * pCD = pointer to client data of the icon that received the button event
- *
- * buttonEvent = pointer to the button event that occurred
- *
- * subContext = context id of event location inside icon box
- *
- *************************************<->***********************************/
- void HandleIconBoxButtonPress (ClientData *pCD, XButtonEvent *buttonEvent, Context subContext)
- {
- /*
- * Do iconbox icon component button press actions:
- * Button 1 press - select the icon
- * Button 1 double-click - normalize the icon or raise the window
- */
- if ((wmGD.clickData.doubleClickContext == F_SUBCONTEXT_IB_IICON) ||
- (wmGD.clickData.doubleClickContext == F_SUBCONTEXT_IB_WICON))
- {
- F_Restore_And_Raise ((String)NULL, pCD, (XEvent *)NULL);
- }
- else if ((subContext == F_SUBCONTEXT_IB_IICON) ||
- (subContext == F_SUBCONTEXT_IB_WICON))
- {
- /*
- * Indicate that a move may be starting; wait for button motion
- * events before moving the icon.
- */
- wmGD.preMove = True;
- wmGD.preMoveX = buttonEvent->x_root;
- wmGD.preMoveY = buttonEvent->y_root;
- wmGD.configButton = buttonEvent->button;
- wmGD.configAction = MOVE_CLIENT;
- }
- /*
- * Do icon box icon actions:
- * Button 1 press - select the icon in the icon box
- */
- /*
- * XmProcessTraversal will move the selection cursor to the
- * widget that was "boinked" with the mouse
- */
- if ((P_ICON_BOX(pCD)->pCD_iconBox == wmGD.keyboardFocus) ||
- (P_ICON_BOX(pCD)->pCD_iconBox == wmGD.nextKeyboardFocus))
- {
- XmProcessTraversal (XtWindowToWidget(DISPLAY, ICON_FRAME_WIN(pCD)),
- XmTRAVERSE_CURRENT);
- }
- } /* END OF FUNCTION HandleIconBoxButtonPress */
- /*************************************<->*************************************
- *
- * HandleCButtonRelease (pCD, buttonEvent)
- *
- *
- * Description:
- * -----------
- * This function does window management actions associated with a button
- * release event on the client window (including frame) or icon.
- *
- *
- * Inputs:
- * ------
- * pCD = pointer to client data for the window/icon that got the event
- *
- * buttonEvent = pointer to the button event that occurred
- *
- * Comments:
- * ---------
- * Skip builtin processing if move or resize button actions were started
- * due to button-up bindings.
- *
- *************************************<->***********************************/
- void HandleCButtonRelease (ClientData *pCD, XButtonEvent *buttonEvent)
- {
- Context context;
- Context subContext;
- int partContext;
- /*
- * Find out whether the event was on the client window frame or the icon
- * and process the event accordingly.
- */
- IdentifyEventContext (buttonEvent, pCD, &context, &partContext);
- subContext = (1L << partContext);
- ProcessClickBRelease (buttonEvent, pCD, context, subContext);
- if (CheckForButtonAction (buttonEvent, context, subContext, pCD) && pCD)
- {
- /*
- * Button bindings have been processed, now check for bindings
- * that associated with the built-in semantics of the window
- * frame decorations.
- */
- CheckButtonReleaseBuiltin (buttonEvent, context, subContext, pCD);
- }
- /*
- * Else skip built-in processing due to execution of a function that
- * does on-going event processing or that has changed the client state
- * (e.g., f.move or f.minimize).
- */
- /* clear preMove state */
- wmGD.preMove = False;
- } /* END OF FUNCTION HandleCButtonRelease */
- /*************************************<->*************************************
- *
- * HandleCKeyPress (pCD, keyEvent)
- *
- *
- * Description:
- * -----------
- * This function does window management actions associated with a key
- * press event on the client window (including frame) or icon.
- *
- *
- * Inputs:
- * ------
- * pCD = pointer to client data for the window/icon that got the event
- *
- * keyEvent = pointer to the key event that occurred
- *
- *
- * Outputs:
- * -------
- * RETURN = True if the event should be dispatched by XtDispatchEvent
- *
- *************************************<->***********************************/
- Boolean HandleCKeyPress (ClientData *pCD, XKeyEvent *keyEvent)
- {
- Boolean dispatchEvent = False;
- Boolean checkKeyEvent = True;
- if (wmGD.menuActive)
- {
- /*
- * The active menu accelerators have been checked and keyEvent was
- * not one of them. We will check for an iconbox icon widget key and
- * for pass keys mode and then have the toolkit dispatch the event,
- * without rechecking the client accelerator list.
- */
- dispatchEvent = True;
- checkKeyEvent = False;
- }
- /*
- * If pass keys is active then only check for getting out of the pass
- * keys mode if the event is on the client frame or icon frame window.
- * Unfreeze the keyboard and replay the key if pass keys is active.
- */
- if (((keyEvent->window == ICON_FRAME_WIN(pCD)) ||
- (keyEvent->window == pCD->pSD->activeIconTextWin)) &&
- P_ICON_BOX(pCD))
- {
- /*
- * This is a non-grabbed key that is intended for the icon widget
- * in the iconbox.
- */
- dispatchEvent = True; /* have the toolkit dispatch the event */
- checkKeyEvent = False;
- if (keyEvent->window == pCD->pSD->activeIconTextWin)
- {
- /*
- * The event is really for the icon, not the active
- * label, so ... correct the window id
- */
- keyEvent->window = ICON_FRAME_WIN(pCD);
- }
- }
- else if (wmGD.passKeysActive)
- {
- if (wmGD.passKeysKeySpec &&
- ((wmGD.passKeysKeySpec->state == keyEvent->state) ||
- (wmGD.passKeysKeySpec->state == NOLOCKMOD(keyEvent->state))) &&
- (wmGD.passKeysKeySpec->keycode == keyEvent->keycode))
- {
- /*
- * Get out of the pass keys mode.
- */
- F_Pass_Key (NULL, (ClientData *) NULL, (XEvent *) NULL);
- XAllowEvents (DISPLAY, AsyncKeyboard, CurrentTime);
- }
- else
- {
- XAllowEvents (DISPLAY, ReplayKeyboard, CurrentTime);
- }
- checkKeyEvent = False;
- }
- else
- {
- XAllowEvents (DISPLAY, AsyncKeyboard, CurrentTime);
- }
- /*
- * Check for a "general" key binding that has been set only for the
- * icon context. These key bindings are set with the keyBinding
- * resource or as accelerators in icon context menus.
- */
- if (checkKeyEvent && (keyEvent->window == ICON_FRAME_WIN(pCD)))
- {
- if ((checkKeyEvent = HandleKeyPress (keyEvent,
- ACTIVE_PSD->keySpecs, True,
- F_CONTEXT_ICON, False,
- (ClientData *)NULL))
- && ACTIVE_PSD->acceleratorMenuCount)
- {
- int n;
- for (n = 0; ((keyEvent->keycode != 0) &&
- (n < ACTIVE_PSD->acceleratorMenuCount)); n++)
- {
- if (!HandleKeyPress (keyEvent,
- ACTIVE_PSD->acceleratorMenuSpecs[n]->accelKeySpecs,
- True, F_CONTEXT_ICON, True,(ClientData *)NULL))
- {
- checkKeyEvent = False;
- break;
- }
- }
- }
- }
- /*
- * Check for a key binding that has been set as an accelerator in the
- * system menu. We only do the first accelerator found.
- */
- if (checkKeyEvent && pCD->systemMenuSpec &&
- (pCD->systemMenuSpec->accelKeySpecs))
- {
- HandleKeyPress (keyEvent, pCD->systemMenuSpec->accelKeySpecs,
- FALSE, 0, TRUE,(ClientData *)NULL );
- }
- return (dispatchEvent);
- } /* END OF FUNCTION HandleCKeyPress */
- /*************************************<->*************************************
- *
- * CheckButtonReleaseBuiltin (buttonEvent, context, subContext, pCD)
- *
- *
- * Description:
- * -----------
- * This function checks to see if a built-in window manager function
- * has been activated as a result of a button release. If yes, then the
- * associated function is done.
- *
- *
- * Inputs:
- * ------
- * buttonEvent = pointer to a button release event
- *
- * context = button event context (root, icon, window)
- *
- * subContext = button event subcontext (title, system button, ...)
- *
- * pCD = pointer to client data for the window/icon that got the event
- *
- *************************************<->***********************************/
- void CheckButtonReleaseBuiltin (XButtonEvent *buttonEvent, Context context, Context subContext, ClientData *pCD)
- {
- /*
- * All builtin button buindings are based on button 1 with no modifiers.
- * (Ignore locking modifiers).
- *
- * Test the event for a ``button up'' transition on buttons we are
- * interested in.
- */
- if (!((buttonEvent->button == SELECT_BUTTON) &&
- (NOLOCKMOD(buttonEvent->state) == SELECT_BUTTON_MASK)) &&
- !((buttonEvent->button == DMANIP_BUTTON) &&
- (NOLOCKMOD(buttonEvent->state) == DMANIP_BUTTON_MASK)))
- {
- return;
- }
- /*
- * Process the builtin button bindings based on the window manager
- * component that was selected.
- */
- if ((buttonEvent->button == SELECT_BUTTON) &&
- (context & F_CONTEXT_ICON))
- {
- /*
- * Do the icon component button release actions:
- * SELECT_BUTTON click - post the system menu if specified.
- */
- if (wmGD.iconClick &&
- (wmGD.clickData.clickContext == F_SUBCONTEXT_I_ALL))
- {
- wmGD.checkHotspot = True;
- /*
- * Post the system menu with traversal on (Button 1 should be
- * used to manipulate the menu).
- */
- pCD->grabContext = F_CONTEXT_ICON;
- PostMenu (pCD->systemMenuSpec, pCD, 0, 0, NoButton,
- F_CONTEXT_ICON, POST_STICKY, (XEvent *)buttonEvent);
- }
- }
- /* post menu from icon in iconbox */
- else if ((buttonEvent->button == SELECT_BUTTON) &&
- (context & F_CONTEXT_ICONBOX))
- {
- if ((wmGD.iconClick) &&
- (((pCD->clientState == MINIMIZED_STATE) &&
- (wmGD.clickData.clickContext == F_SUBCONTEXT_IB_IICON)) ||
- (wmGD.clickData.clickContext == F_SUBCONTEXT_IB_WICON)) )
- {
- wmGD.checkHotspot = True;
-
- /*
- * Post the system menu with traversal on (Button 1 should be
- * used to manipulate the menu.
- */
- if ((wmGD.clickData.clickContext == F_SUBCONTEXT_IB_IICON) &&
- (pCD->clientState == MINIMIZED_STATE))
- {
- pCD->grabContext = F_SUBCONTEXT_IB_IICON;
- PostMenu (pCD->systemMenuSpec, pCD, 0, 0, NoButton,
- F_SUBCONTEXT_IB_IICON, POST_STICKY, (XEvent *)buttonEvent);
- }
- else
- {
- pCD->grabContext = F_SUBCONTEXT_IB_WICON;
- PostMenu (pCD->systemMenuSpec, pCD, 0, 0, NoButton,
- F_SUBCONTEXT_IB_WICON, POST_STICKY, (XEvent *)buttonEvent);
- }
- }
- }
- /* end of post menu from icon in iconbox */
- else if (context & F_CONTEXT_WINDOW)
- {
- /*
- * The button release is on a client window frame component.
- */
- if ((buttonEvent->button == SELECT_BUTTON) &&
- (subContext == F_SUBCONTEXT_W_MINIMIZE))
- {
- /*
- * Minimize button:
- * Button 1 click - minimize the window.
- */
- if (wmGD.clickData.clickContext == F_SUBCONTEXT_W_MINIMIZE)
- {
- SetClientState (pCD, MINIMIZED_STATE, buttonEvent->time);
- }
- }
- else if ((buttonEvent->button == SELECT_BUTTON) &&
- (subContext == F_SUBCONTEXT_W_MAXIMIZE))
- {
- /*
- * Maximize button:
- * Button 1 click - maximize the window.
- */
- if (wmGD.clickData.clickContext == F_SUBCONTEXT_W_MAXIMIZE)
- {
- if (pCD->clientState == NORMAL_STATE)
- {
- SetClientState (pCD, MAXIMIZED_STATE, buttonEvent->time);
- }
- else
- {
- SetClientState (pCD, NORMAL_STATE, buttonEvent->time);
- }
- }
- }
- }
- /*
- * Clear the pre-configuration info that supports the move threshold.
- */
- wmGD.preMove = False;
- } /* END OF FUNCTION CheckButtonReleaseBuiltin */
- /*************************************<->*************************************
- *
- * HandleCMotionNotify (pCD, motionEvent)
- *
- *
- * Description:
- * -----------
- * This function does window management actions associated with a motion
- * notify event on the client window (including frame) or icon.
- *
- *
- * Inputs:
- * ------
- * pCD = pointer to the client data for the window/icon that got the motion
- *
- * motionEvent = pointer to the motion event
- *
- *************************************<->***********************************/
- void HandleCMotionNotify (ClientData *pCD, XMotionEvent *motionEvent)
- {
- int diffX;
- int diffY;
- /*
- * Do pre-move processing (to support the move threshold) if appropriate:
- */
- if (wmGD.preMove)
- {
- diffX = motionEvent->x_root - wmGD.preMoveX;
- if (diffX < 0) diffX = -diffX;
- diffY = motionEvent->y_root - wmGD.preMoveY;
- if (diffY < 0) diffY = -diffY;
- if ((diffX >= wmGD.moveThreshold) || (diffY >= wmGD.moveThreshold))
- {
- /*
- * The move threshold has been exceeded; start the config action.
- */
- wmGD.clickData.clickPending = False;
- wmGD.clickData.doubleClickPending = False;
- wmGD.preMove = False;
- if (wmGD.configAction == MOVE_CLIENT)
- {
- HandleClientFrameMove (pCD, (XEvent *) motionEvent);
- }
- else if (wmGD.configAction == RESIZE_CLIENT)
- {
- HandleClientFrameResize (pCD, (XEvent *) motionEvent);
- }
- }
- }
- } /* END OF FUNCTION HandleCMotionNotify */
- /*************************************<->*************************************
- *
- * HandleCEnterNotify (pCD, enterEvent)
- *
- *
- * Description:
- * -----------
- * This function does window management actions associated with an enter
- * window event on the client window.
- *
- *
- * Inputs:
- * ------
- * pCD = pointer to the client data for the window/icon that was entered
- *
- * enterEvent = pointer to the enter event
- *
- *************************************<->***********************************/
- void HandleCEnterNotify (ClientData *pCD, XEnterWindowEvent *enterEvent)
- {
- XEvent report;
- Boolean MatchFound;
- Window enterWindow;
- /*
- * If a client is being configured don't change the keyboard input
- * focus. The input focus is "fixed" after the configuration has been
- * completed.
- */
- if (pCD->clientState == MINIMIZED_STATE)
- {
- enterWindow = ICON_FRAME_WIN(pCD);
- }
- else
- {
- enterWindow = pCD->clientFrameWin;
- }
- MatchFound = XCheckTypedWindowEvent(DISPLAY, enterWindow,
- LeaveNotify, &report);
- /*
- * NOTE: Handle focus change for when user clicks button in the
- * process of moving focus the matching event will be NotifyGrab.
- *
- * IF (((no_match) ||
- * (another window has focus and button grabbed)) &&
- * pointer_mode)
- */
- if ((enterEvent->detail != NotifyInferior) &&
- (((!MatchFound || (report.xcrossing.detail == NotifyInferior)) &&
- ((enterEvent->mode == NotifyNormal) ||
- (enterEvent->mode == NotifyUngrab)) &&
- !wmGD.menuActive) ||
- (wmGD.keyboardFocus &&
- (wmGD.keyboardFocus->clientFrameWin != enterWindow) &&
- (enterEvent->mode == NotifyGrab))) &&
- ((wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_POINTER) ||
- (wmGD.colormapFocusPolicy == CMAP_FOCUS_POINTER)))
- {
- /*
- * Make sure that EnterNotify is applicable; don't do anything if
- * the window is minimized (not currently visible) or the event is
- * associated with an icon in the icon box.
- */
- if (!(((enterEvent->window == pCD->clientFrameWin) &&
- (pCD->clientState == MINIMIZED_STATE)) ||
- (((enterEvent->window == ICON_FRAME_WIN(pCD)) &&
- P_ICON_BOX(pCD)) ||
- (enterEvent->window == pCD->pSD->activeIconTextWin))))
- {
- if (wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_POINTER)
- {
- /*
- * Set the focus only if the window does not currently have
- * or if another window is in the process of getting the
- * focus (this check avoids redundant focus setting).
- */
- if ((pCD != wmGD.keyboardFocus) ||
- (pCD != wmGD.nextKeyboardFocus))
- {
- Do_Focus_Key (pCD, enterEvent->time, ALWAYS_SET_FOCUS);
- /* Does the event need to be replayed for modalized windows ? */
- if ( wmGD.replayEnterEvent )
- /* Yes, save the event. */
- memcpy( &wmGD.savedEnterEvent, enterEvent,
- sizeof( XEnterWindowEvent ) );
- /*
- * The original code counted on getting a focus out event as a result
- * of setting the input focus in Do_Focus_key. That would cause
- * SetkeyboardFocus to get called. Unfortunately, you cannot depend on
- * getting a focus out. You may have already had focus yourself.
- *
- * This bug can be produced by:
- * * bring up a menu and leave it posted
- * * move to a different window and click
- * * the menu comes unposted, the new window has input focus, but no
- * client active decorations are changed.
- */
- }
- }
- if (wmGD.colormapFocusPolicy == CMAP_FOCUS_POINTER)
- {
- SetColormapFocus (ACTIVE_PSD, pCD);
- }
- }
- }
- } /* END OF FUNCTION HandleCEnterNotify */
- /*************************************<->*************************************
- *
- * HandleCLeaveNotify (pCD, leaveEvent)
- *
- *
- * Description:
- * -----------
- * This function does window management actions associated with an leave
- * window event on the client window.
- *
- *
- * Inputs:
- * ------
- * pCD = pointer to the client data for the window/icon that was leaveed
- *
- * leaveEvent = pointer to the leave event
- *
- *************************************<->***********************************/
- void HandleCLeaveNotify (ClientData *pCD, XLeaveWindowEvent *leaveEvent)
- {
- XEvent report;
- Window leaveWindow;
- if (pCD->clientState == MINIMIZED_STATE)
- {
- leaveWindow = ICON_FRAME_WIN(pCD);
- }
- else
- {
- leaveWindow = pCD->clientFrameWin;
- }
- /*
- * Don't remove enterEvents when user double clicks on an icon in
- * an iconbox. Otherwise the window that gets normalized will get
- * matching enter events and not get the focus.
- */
- if (P_ICON_BOX(pCD) &&
- (P_ICON_BOX(pCD)->pCD_iconBox != wmGD.keyboardFocus) &&
- (P_ICON_BOX(pCD)->pCD_iconBox != wmGD.nextKeyboardFocus))
- {
- XCheckTypedWindowEvent(DISPLAY, leaveWindow, EnterNotify, &report);
- }
- } /* END OF FUNCTION HandleCLeaveNotify */
- /*************************************<->*************************************
- *
- * HandleCFocusIn (pCD, focusChangeEvent)
- *
- *
- * Description:
- * -----------
- * This function does window management actions associated with a focus
- * in event.
- *
- *
- * Inputs:
- * ------
- * pCD = pointer to the client data for the window/icon that was entered
- *
- * enterEvent = pointer to the focus in event
- *
- *
- * Outputs:
- * -------
- * RETURN = True if event is to be dispatched by the toolkit
- *
- *************************************<->***********************************/
- Boolean HandleCFocusIn (ClientData *pCD, XFocusChangeEvent *focusChangeEvent)
- {
- Boolean setupNextFocus;
- Boolean doXtDispatchEvent = False;
- /*
- * Ignore the event if it is for a window that is no longer viewable.
- * This is the case for a client window FocusIn event that is being
- * processed for a window that has been minimized.
- */
- if ((focusChangeEvent->window == ICON_FRAME_WIN(pCD)) &&
- P_ICON_BOX(pCD))
- {
- doXtDispatchEvent = True;
- }
- else if (((focusChangeEvent->mode == NotifyNormal) ||
- (focusChangeEvent->mode == NotifyWhileGrabbed)) &&
- !((focusChangeEvent->window == pCD->clientBaseWin) &&
- (pCD->clientState == MINIMIZED_STATE)) &&
- !((focusChangeEvent->window == ICON_FRAME_WIN(pCD)) &&
- (pCD->clientState != MINIMIZED_STATE)))
- {
- setupNextFocus = (wmGD.keyboardFocus == wmGD.nextKeyboardFocus);
- if (wmGD.keyboardFocus != pCD)
- {
- if ((focusChangeEvent->detail == NotifyNonlinear) ||
- (focusChangeEvent->detail == NotifyNonlinearVirtual))
- {
- SetKeyboardFocus (pCD, REFRESH_LAST_FOCUS);
- if (setupNextFocus)
- {
- wmGD.nextKeyboardFocus = wmGD.keyboardFocus;
- }
- }
- /* Re: CR 4896 */
- /* this part added to try and fix the %#$!@!!&* focus bug. */
- /* this seems to solve most of the problem. This still leaves */
- /* times when clicking on an icon toggles the focus back to the */
- /* the previous focus window. */
- /* Another patch was added to WmEvent.c to fix that problem. */
- else
- {
- SetKeyboardFocus (pCD, REFRESH_LAST_FOCUS);
- if (setupNextFocus) wmGD.nextKeyboardFocus = wmGD.keyboardFocus;
- }
- }
- else if ((focusChangeEvent->detail == NotifyInferior) &&
- (wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_EXPLICIT))
- {
- /*
- * The client window was withdrawn (unmapped or destroyed).
- * Reset the focus.
- * !!! pointer focus !!!
- */
- if (wmGD.autoKeyFocus)
- {
- /* !!! fix this up to handle transient windows !!! */
- AutoResetKeyFocus (wmGD.keyboardFocus, GetTimestamp ());
- }
- else
- {
- Do_Focus_Key ((ClientData *) NULL, GetTimestamp (),
- ALWAYS_SET_FOCUS);
- }
- }
- }
- pCD->focusAutoRaiseDisabled = False;
- return (doXtDispatchEvent);
- } /* END OF FUNCTION HandleCFocusIn */
- /*************************************<->*************************************
- *
- * HandleCFocusOut (pCD, focusChangeEvent)
- *
- *
- * Description:
- * -----------
- * This function does window management actions associated with a focus
- * out event that applies to a client window.
- *
- *
- * Inputs:
- * ------
- * pCD = pointer to the client data for the window/icon that was entered
- *
- * enterEvent = pointer to the focus out event
- *
- *
- * Outputs:
- * -------
- * RETURN = True if event is to be dispatched by the toolkit
- *
- *************************************<->***********************************/
- Boolean HandleCFocusOut (ClientData *pCD, XFocusChangeEvent *focusChangeEvent)
- {
- Boolean doXtDispatchEvent = False;
- long focusFlags = REFRESH_LAST_FOCUS ;
- pCD->focusAutoRaiseDisabled = False;
- /*
- * Ignore the event if it is for a window that is no longer viewable.
- * This is the case for a client window FocusOut event that is being
- * processed for a window that has been minimized. Also, ignore focus
- * out events for clients that aren't on the current screen.
- */
- if (((focusChangeEvent->window == ICON_FRAME_WIN(pCD)) &&
- P_ICON_BOX(pCD)) ||
- (SCREEN_FOR_CLIENT(pCD) != ACTIVE_SCREEN))
- {
- doXtDispatchEvent = True;
- }
- else if ((wmGD.keyboardFocus == pCD) &&
- (focusChangeEvent->mode == NotifyNormal) &&
- ((focusChangeEvent->detail == NotifyNonlinear) ||
- (focusChangeEvent->detail == NotifyNonlinearVirtual)) &&
- !((focusChangeEvent->window == pCD->clientBaseWin) &&
- (pCD->clientState == MINIMIZED_STATE)) &&
- !((focusChangeEvent->window == ICON_FRAME_WIN(pCD)) &&
- (pCD->clientState != MINIMIZED_STATE)))
- {
- /*
- * The keyboard focus was shifted to another window, maybe on
- * another screen. Clear the focus indication and reset focus
- * handling for the client window.
- */
- /*
- * use SCREEN_SWITCH_FOCUS in SetKeyboardFocus to
- * not call SetColormapFocus if we are moveing
- * to another screen
- */
- if (SCREEN_FOR_CLIENT(pCD) != ACTIVE_SCREEN)
- {
- focusFlags |= SCREEN_SWITCH_FOCUS;
- }
- SetKeyboardFocus ((ClientData *) NULL, focusFlags);
- if (wmGD.nextKeyboardFocus == pCD)
- {
- wmGD.nextKeyboardFocus = NULL;
- }
- }
- return (doXtDispatchEvent);
- } /* END OF FUNCTION HandleCFocusOut */
- /*************************************<->*************************************
- *
- * HandleCConfigureRequest (pCD, configureRequest)
- *
- *
- * Description:
- * -----------
- * This functions handles ConfigureRequest events that are for client windows.
- *
- *
- * Inputs:
- * ------
- * pCD = pointer to client data
- *
- * configureRequest = a pointer to a ConfigureRequest event
- *
- *************************************<->***********************************/
- void HandleCConfigureRequest (ClientData *pCD, XConfigureRequestEvent *configureRequest)
- {
- unsigned int mask = configureRequest->value_mask;
- int stackMode = configureRequest->detail;
- unsigned int changeMask;
- ClientData *pcdLeader;
- ClientData *pcdSibling;
- ClientListEntry *pStackEntry;
- /*
- * Call ProcessNewConfiguration to handle window moving and resizing.
- * Send ConfigureNotify event (based on ICCCM conventions).
- * Then process the request for stacking.
- */
- if ((configureRequest->window == pCD->client) &&
- (mask & (CWX | CWY | CWWidth | CWHeight | CWBorderWidth)))
- {
- if (pCD->maxConfig) {
- ProcessNewConfiguration (pCD,
- (mask & CWX) ? configureRequest->x : pCD->maxX,
- (mask & CWY) ? configureRequest->y : pCD->maxY,
- (unsigned int) ((mask & CWWidth) ?
- configureRequest->width : pCD->maxWidth),
- (unsigned int) ((mask & CWHeight) ?
- configureRequest->height : pCD->maxHeight),
- True /*client request*/);
- }
- else {
- int xOff, yOff;
- /* CDExc21094 - ProcessNewConfiguration() offsets the */
- /* x and y positions passed in; in order to keep them */
- /* the same, we offset them in the opposite direction. */
- if (wmGD.positionIsFrame)
- {
- xOff = pCD->clientOffset.x;
- yOff = pCD->clientOffset.y;
- }
- else
- {
- xOff = yOff = 0;
- }
- ProcessNewConfiguration (pCD,
- (mask & CWX) ? configureRequest->x : pCD->clientX - xOff,
- (mask & CWY) ? configureRequest->y : pCD->clientY - yOff,
- (unsigned int) ((mask & CWWidth) ?
- configureRequest->width : pCD->clientWidth),
- (unsigned int) ((mask & CWHeight) ?
- configureRequest->height : pCD->clientHeight),
- True /*client request*/);
- }
- }
- if (mask & CWStackMode)
- {
- changeMask = mask & (CWSibling | CWStackMode);
- if (changeMask & CWSibling)
- {
- if (XFindContext (DISPLAY, configureRequest->above,
- wmGD.windowContextType, (caddr_t *)&pcdSibling))
- {
- changeMask &= ~CWSibling;
- }
- else
- {
- /*
- * For client requests only primary windows can be
- * restacked relative to one another.
- */
- pcdLeader = FindTransientTreeLeader (pCD);
- pcdSibling = FindTransientTreeLeader (pcdSibling);
- if (pcdLeader == pcdSibling)
- {
- changeMask &= ~CWSibling;
- }
- else
- {
- pStackEntry = &pcdSibling->clientEntry;
- if ((stackMode == Above) || (stackMode == TopIf))
- {
- /* lower the window to just above the sibling */
- Do_Lower (pcdLeader, pStackEntry, STACK_NORMAL);
- }
- else if ((stackMode == Below) || (stackMode == BottomIf))
- {
- /* raise the window to just below the sibling */
- Do_Raise (pcdLeader, pStackEntry, STACK_NORMAL);
- }
- else if (stackMode == Opposite)
- {
- F_Raise_Lower (NULL, pCD, (XEvent *)configureRequest);
- }
- }
- }
- }
- if (!(changeMask & CWSibling))
- {
- if ((stackMode == Above) || (stackMode == TopIf))
- {
- Do_Raise (pCD, (ClientListEntry *) NULL, STACK_NORMAL);
- }
- else if ((stackMode == Below) || (stackMode == BottomIf))
- {
- Do_Lower (pCD, (ClientListEntry *) NULL, STACK_NORMAL);
- }
- else if (stackMode == Opposite)
- {
- F_Raise_Lower (NULL, pCD, (XEvent *) configureRequest);
- }
- }
- /* !!! should a synthetic ConfigureNotify be sent? !!! */
- if ((configureRequest->window == pCD->client) &&
- !(mask & (CWX | CWY | CWWidth | CWHeight | CWBorderWidth)))
- {
- SendConfigureNotify (pCD);
- }
- }
- } /* END OF FUNCTION HandleCConfigureRequest */
- /*************************************<->*************************************
- *
- * HandleCColormapNotify (pCD, colorEvent)
- *
- *
- * Description:
- * -----------
- * This function does window management actions associated with a colormap
- * notify event on the client window.
- *
- *
- * Inputs:
- * ------
- * pCD = pointer to client data
- *
- * colorEvent = a ColormapNotify event
- *
- *************************************<->***********************************/
- void HandleCColormapNotify (ClientData *pCD, XColormapEvent *colorEvent)
- {
- int i;
- #ifndef IBM_169380
- ClientData **cmap_window_data;
- #endif
- Boolean newClientColormap = False;
- /*
- * The colormap of the top-level client window or one of its subwindows
- * has been changed.
- */
- if (colorEvent->new)
- {
- /*
- * The colormap has been changed.
- */
- /*
- * !!! when the server ColormapNotify problem is fixed !!!
- * !!! use the colormap id from the event !!!
- */
- if (WmGetWindowAttributes (colorEvent->window))
- {
- colorEvent->colormap = wmGD.windowAttributes.colormap;
- }
- else
- {
- return;
- }
- /*
- * !!! remove the above code when the problem is fixed !!!
- */
- /*
- * Identify the colormap that the window manager has associated
- * with the window.
- */
- #ifndef IBM_169380
- if ((pCD->clientCmapCount == 0) && (colorEvent->window == pCD->client))
- #endif
- if (pCD->clientCmapCount == 0)
- {
- /* no subwindow colormaps; change top-level window colormap */
- #ifdef IBM_169380
- if (colorEvent->window == pCD->client)
- {
- #endif
- if (colorEvent->colormap == None)
- {
- /* use the workspace colormap */
- pCD->clientColormap =
- ACTIVE_PSD->workspaceColormap;
- }
- else
- {
- pCD->clientColormap = colorEvent->colormap;
- }
- newClientColormap = True;
- #ifdef IBM_169380
- }
- #endif
- }
- #ifndef IBM_169380
- if (!XFindContext (DISPLAY, colorEvent->window,
- wmGD.cmapWindowContextType, (caddr_t *)&cmap_window_data))
- {
- /*
- * The WM_COLORMAP_WINDOWS property of a toplevel window may
- * specify colorEvent->window. If so, we must update the
- * colormap information it holds in clientCmapList.
- */
- ClientData *any_pCD;
- int j;
- for (j = 0; cmap_window_data[j] != NULL; j++)
- {
- any_pCD = cmap_window_data[j];
- for (i = 0; i < any_pCD->clientCmapCount; i++)
- {
- if (any_pCD->cmapWindows[i] == colorEvent->window)
- {
- if (colorEvent->colormap == None)
- {
- /* use the workspace colormap */
- any_pCD->clientCmapList[i] =
- ACTIVE_PSD->workspaceColormap;
- }
- else
- {
- any_pCD->clientCmapList[i] = colorEvent->colormap;
- }
- if (i == any_pCD->clientCmapIndex)
- {
- any_pCD->clientColormap =
- any_pCD->clientCmapList[i];
- if (any_pCD == pCD)
- {
- newClientColormap = True;
- }
- }
- break;
- }
- }
- }
- }
- #else
- else
- {
- /* there are subwindow colormaps */
- for (i = 0; i < pCD->clientCmapCount; i++)
- {
- if (pCD->cmapWindows[i] == colorEvent->window)
- {
- if (colorEvent->colormap == None)
- {
- /* use the workspace colormap */
- pCD->clientCmapList[i] =
- ACTIVE_PSD->workspaceColormap;
- }
- else
- {
- pCD->clientCmapList[i] = colorEvent->colormap;
- }
- if (i == pCD->clientCmapIndex)
- {
- newClientColormap = True;
- pCD->clientColormap = pCD->clientCmapList[i];
- }
- break;
- }
- }
- }
- #endif /* IBM_169380 */
- if ((ACTIVE_PSD->colormapFocus == pCD) && newClientColormap &&
- ((pCD->clientState == NORMAL_STATE) ||
- (pCD->clientState == MAXIMIZED_STATE)))
- {
- /*
- * The client window has the colormap focus, install the
- * colormap.
- */
- WmInstallColormap (ACTIVE_PSD, pCD->clientColormap);
- }
- }
- } /* END OF FUNCTION HandleCColormapNotify */
- /*************************************<->*************************************
- *
- * HandleClientMessage (pCD, clientEvent)
- *
- *
- * Description:
- * -----------
- * This function handles client message events that are sent to the root
- * window. The window manager action that is taken depends on the
- * message_type of the event.
- *
- *
- * Inputs:
- * ------
- * pCD = pointer to client data
- *
- * clientEvent = pointer to a client message event on the root window
- *
- *************************************<->***********************************/
- void HandleClientMessage (ClientData *pCD, XClientMessageEvent *clientEvent)
- {
- unsigned int newState = WITHDRAWN_STATE;
- /*
- * Process the client message event based on the message_type.
- */
- if (clientEvent->message_type == wmGD.xa_WM_CHANGE_STATE)
- {
- if ((clientEvent->data.l[0] == IconicState) &&
- (pCD->clientFunctions & MWM_FUNC_MINIMIZE))
- {
- newState = MINIMIZED_STATE;
- }
- else if (clientEvent->data.l[0] == NormalState)
- {
- newState = NORMAL_STATE;
- }
- if (!ClientInWorkspace (ACTIVE_WS, pCD))
- {
- newState |= UNSEEN_STATE;
- }
- SetClientState (pCD, newState, GetTimestamp ());
- }
- else if (clientEvent->message_type == wmGD.xa__NET_WM_FULLSCREEN_MONITORS)
- {
- ProcessNetWmFullscreenMonitors (pCD,
- clientEvent->data.l[0], clientEvent->data.l[1],
- clientEvent->data.l[2], clientEvent->data.l[3]);
- if (pCD->fullscreenAuto)
- XDeleteProperty (DISPLAY, pCD->client, clientEvent->message_type);
- else
- XChangeProperty (DISPLAY, pCD->client, clientEvent->message_type,
- XA_CARDINAL, 32, PropModeReplace,
- (unsigned char *) clientEvent->data.l, 4);
- }
- else if (clientEvent->message_type == wmGD.xa__NET_WM_STATE)
- {
- ProcessNetWmState (pCD, clientEvent->data.l[0], clientEvent->data.l[1],
- clientEvent->data.l[2]);
- }
- } /* END OF FUNCTION HandleClientMessage */
- /*************************************<->*************************************
- *
- * HandleCShapeNotify (pCD, shapeEvent)
- *
- *
- * Description:
- * -----------
- * Handle a shape notify event on a client window. Keeps track of
- * the shaped state of the client window and calls
- * SetFrameShape() to reshape the frame accordingly.
- *
- * Inputs:
- * ------
- * shapeEvent = pointer to a shape notify in event on the client window.
- *
- *************************************<->***********************************/
- void
- HandleCShapeNotify (ClientData *pCD, XShapeEvent *shapeEvent)
- {
- if (pCD)
- {
- if (shapeEvent->kind != ShapeBounding)
- {
- return;
- }
-
- pCD->wShaped = shapeEvent->shaped;
- SetFrameShape (pCD);
- }
- } /* END OF FUNCTION HandleCShapeNotify */
- /*************************************<->*************************************
- *
- * GetParentWindow (window)
- *
- *
- * Description:
- * -----------
- * This function identifies the parent window of the specified window.
- *
- *
- * Inputs:
- * ------
- * window = find the parent of this window
- *
- * Outputs:
- * -------
- * Return = return the window id of the parent of the specified window
- *
- *************************************<->***********************************/
- Window GetParentWindow (Window window)
- {
- Window root;
- Window parent;
- Window *children;
- unsigned int nchildren;
- if (XQueryTree (DISPLAY, window, &root, &parent, &children, &nchildren))
- {
- if (nchildren)
- {
- XFree ((char *)children);
- }
- }
- else
- {
- parent = (Window)0L;
- }
- return (parent);
- } /* END OF FUNCTION GetParentWindow */
- /*************************************<->*************************************
- *
- * DetermineActiveScreen (pEvent)
- *
- *
- * Description:
- * -----------
- * This function determines the currently active screen
- *
- *
- * Inputs:
- * ------
- * pEvent = pointer to an event structure
- *
- * Outputs:
- * -------
- * ACTIVE_PSD = set to point to the screen data for the currently
- * active scree;
- * wmGD.queryScreen = set to False if we're sure about the ACTIVE_PSD
- * setting
- *
- *************************************<->***********************************/
- void DetermineActiveScreen (XEvent *pEvent)
- {
- WmScreenData *pSD;
- switch (pEvent->type)
- {
- case NoExpose:
- case GraphicsExpose:
- break; /* ignore these events */
- default:
- /*
- * Get the screen that the event occurred on.
- */
- pSD = GetScreenForWindow (pEvent->xany.window);
- if (pSD)
- {
- /*
- * Set the ACTIVE_PSD to the event's screen to
- * make sure the event gets handled correctly.
- */
- SetActiveScreen (pSD);
- }
- break;
- }
- } /* END OF FUNCTION DetermineActiveScreen */
- /*************************************<->*************************************
- *
- * GetScreenForWindow (win)
- *
- *
- * Description:
- * -----------
- * This function determines the screen for a window
- *
- *
- * Inputs:
- * ------
- * win = window id
- *
- * Outputs:
- * -------
- * value of function = pointer to screen data (pSD) or NULL on failure
- *
- *************************************<->***********************************/
- WmScreenData * GetScreenForWindow (Window win)
- {
- XWindowAttributes attribs;
- WmScreenData *pSD = NULL;
- /*
- * Get the screen that the event occurred on.
- */
- if (XGetWindowAttributes (DISPLAY, win, &attribs))
- {
- if (!XFindContext (DISPLAY, attribs.root, wmGD.screenContextType,
- (caddr_t *)&pSD))
- {
- if (pSD && !pSD->screenTopLevelW)
- {
- pSD = NULL;
- }
- }
- }
- return (pSD);
- } /* END OF FUNCTION GetScreenForWindow */
|