123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053 |
- /*
- * CDE - Common Desktop Environment
- *
- * Copyright (c) 1993-2012, The Open Group. All rights reserved.
- *
- * These libraries and programs are free software; you can
- * redistribute them and/or modify them under the terms of the GNU
- * Lesser General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * These libraries and programs are distributed in the hope that
- * they will be useful, but WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with these libraries and programs; if not, write
- * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
- * Floor, Boston, MA 02110-1301 USA
- */
- /*
- * (c) Copyright 1989, 1990, 1991, 1992, 1993 OPEN SOFTWARE FOUNDATION, INC.
- * ALL RIGHTS RESERVED
- */
- /*
- * Motif Release 1.2.3
- */
- /*
- * (c) Copyright 1987, 1988, 1989, 1990 HEWLETT-PACKARD COMPANY */
- /*
- * Included Files:
- */
- #include "WmGlobal.h"
- #include "WmICCC.h"
- /*
- * include extern functions
- */
- #include "WmError.h"
- #include "WmFunction.h"
- #include "WmKeyFocus.h"
- #include "WmMenu.h"
- #include "WmWinInfo.h"
- #include "WmEvent.h"
- #include "WmPanelP.h"
- /*
- * Function Declarations:
- */
- #include "WmProtocol.h"
- static Boolean wmq_convert (Widget w, Atom *pSelection, Atom *pTarget,
- Atom *pType_return, XtPointer *pValue_return, unsigned long *pLength_return,
- int *pFormat_return);
- static Boolean wmq_convert_all_clients (Widget w, int screen,
- Atom *pType_return, XtPointer *pValue_return, unsigned long *pLength_return,
- int *pFormat_return);
- static void wmq_list_subtree (ClientData *pCD);
- static void wmq_add_xid (XID win);
- static void wmq_done (Widget w, Atom *pSelection, Atom *pTarget);
- static void wmq_lose (Widget w, Atom *pSelection);
- static void wmq_bump_xids(void);
- /*
- * Global Variables:
- */
- Atom *xa_WM_QUERY = NULL;
- Atom xa_WM_POINTER_WINDOW;
- Atom xa_WM_CLIENT_WINDOW;
- Atom xa_WM_ALL_CLIENTS;
- XID *pXids = NULL;
- int numXids = -1;
- int curXids = 0;
- /*************************************<->*************************************
- *
- * SetupWmICCC ()
- *
- *
- * Description:
- * -----------
- * This function sets up the window manager handling of the inter-client
- * communications conventions.
- *
- *
- * Outputs:
- * -------
- * (wmGD) = Atoms id's are setup.
- *
- *************************************<->***********************************/
- void SetupWmICCC (void)
- {
- enum {
- XA_WM_STATE, XA_WM_PROTOCOLS, XA_WM_CHANGE_STATE,
- XA_WM_SAVE_YOURSELF, XA_WM_DELETE_WINDOW,
- XA_WM_COLORMAP_WINDOWS, XA_WM_TAKE_FOCUS, XA_MWM_HINTS,
- XA_MWM_MENU, XA_MWM_MESSAGES, XA_MOTIF_WM_OFFSET,
- XA_MOTIF_WM_CLIENT_WINDOW, XA_MOTIF_WM_POINTER_WINDOW,
- XA_MOTIF_WM_ALL_CLIENTS,
- XA_COMPOUND_TEXT, NUM_ATOMS };
- static char *atom_names[] = {
- _XA_WM_STATE, _XA_WM_PROTOCOLS, _XA_WM_CHANGE_STATE,
- _XA_WM_SAVE_YOURSELF, _XA_WM_DELETE_WINDOW,
- _XA_WM_COLORMAP_WINDOWS, _XA_WM_TAKE_FOCUS, _XA_MWM_HINTS,
- _XA_MWM_MENU, _XA_MWM_MESSAGES, _XA_MOTIF_WM_OFFSET,
- # ifdef _XA_MOTIF_WM_CLIENT_WINDOW
- _XA_MOTIF_WM_CLIENT_WINDOW, _XA_MOTIF_WM_POINTER_WINDOW,
- _XA_MOTIF_WM_ALL_CLIENTS,
- # else
- "_MOTIF_WM_CLIENT_WINDOW", "_MOTIF_WM_POINTER_WINDOW",
- "_MOTIF_WM_ALL_CLIENTS",
- # endif
- "COMPOUND_TEXT"
- };
- XIconSize sizeList;
- int scr;
- Atom atoms[XtNumber(atom_names) + 1];
- /*
- * Make atoms that are required by the ICCC and mwm. The atom for
- * _MOTIF_WM_INFO is intern'ed in ProcessMotifWmInfo.
- */
- XInternAtoms(DISPLAY, atom_names, XtNumber(atom_names), False, atoms);
- wmGD.xa_WM_STATE = atoms[XA_WM_STATE];
- wmGD.xa_WM_PROTOCOLS = atoms[XA_WM_PROTOCOLS];
- wmGD.xa_WM_CHANGE_STATE = atoms[XA_WM_CHANGE_STATE];
- wmGD.xa_WM_SAVE_YOURSELF = atoms[XA_WM_SAVE_YOURSELF];
- wmGD.xa_WM_DELETE_WINDOW = atoms[XA_WM_DELETE_WINDOW];
- wmGD.xa_WM_COLORMAP_WINDOWS = atoms[XA_WM_COLORMAP_WINDOWS];
- wmGD.xa_WM_TAKE_FOCUS = atoms[XA_WM_TAKE_FOCUS];
- wmGD.xa_MWM_HINTS = atoms[XA_MWM_HINTS];
- wmGD.xa_MWM_MENU = atoms[XA_MWM_MENU];
- wmGD.xa_MWM_MESSAGES = atoms[XA_MWM_MESSAGES];
- wmGD.xa_MWM_OFFSET = atoms[XA_MOTIF_WM_OFFSET];
- wmGD.xa_COMPOUND_TEXT = atoms[XA_COMPOUND_TEXT];
- if (!(xa_WM_QUERY = (Atom *) XtMalloc (wmGD.numScreens * (sizeof (Atom)))))
- {
- Warning (((char *)GETMESSAGE(56, 2, "Insufficient memory to XInternAtom _MOTIF_WM_QUERY_nn")));
- }
- for (scr = 0; scr < wmGD.numScreens; scr++)
- {
- if (wmGD.Screens[scr].managed)
- {
- char wm_query_scr[32];
- sprintf(wm_query_scr, "_MOTIF_WM_QUERY_%d",
- wmGD.Screens[scr].screen);
- xa_WM_QUERY[scr] = XInternAtom(DISPLAY, wm_query_scr, False);
- }
- else
- {
- xa_WM_QUERY[scr] = 0;
- }
- }
- xa_WM_CLIENT_WINDOW = atoms[XA_MOTIF_WM_CLIENT_WINDOW];
- xa_WM_POINTER_WINDOW = atoms[XA_MOTIF_WM_POINTER_WINDOW];
- xa_WM_ALL_CLIENTS = atoms[XA_MOTIF_WM_ALL_CLIENTS];
- /*
- * Setup the icon size property on the root window.
- */
- sizeList.width_inc = 1;
- sizeList.height_inc = 1;
- for (scr = 0; scr < wmGD.numScreens; scr++)
- {
- if (wmGD.Screens[scr].managed)
- {
- sizeList.min_width = wmGD.Screens[scr].iconImageMinimum.width;
- sizeList.min_height = wmGD.Screens[scr].iconImageMinimum.height;
- sizeList.max_width = wmGD.Screens[scr].iconImageMaximum.width;
- sizeList.max_height = wmGD.Screens[scr].iconImageMaximum.height;
- XSetIconSizes (DISPLAY, wmGD.Screens[scr].rootWindow,
- &sizeList, 1);
- }
- }
- /*
- * Assert ownership of the WM_QUERY selection
- */
- for (scr = 0; scr < wmGD.numScreens; scr++)
- {
- if (wmGD.Screens[scr].managed)
- {
- if (!XtOwnSelection(wmGD.topLevelW,
- xa_WM_QUERY[scr],
- GetTimestamp(),
- wmq_convert,
- wmq_lose,
- wmq_done))
- {
- Warning (((char *)GETMESSAGE(56, 3, "Failed to own _MOTIF_WM_QUERY_nn selection")));
- }
- }
- }
- } /* END OF FUNCTION SetupWmICCC */
- /*************************************<->*************************************
- *
- * SendConfigureNotify (pCD)
- *
- *
- * Description:
- * -----------
- * This function is used to send a synthetic ConfigureNotify event when
- * a client window is reconfigured in certain ways (e.g., the window is
- * moved without being resized).
- *
- *
- * Inputs:
- * ------
- * pCD = pointer to client data (window id and client size data)
- *
- *************************************<->***********************************/
- void SendConfigureNotify (ClientData *pCD)
- {
- XConfigureEvent notifyEvent;
- /*
- * Send a synthetic ConfigureNotify message:
- */
- notifyEvent.type = ConfigureNotify;
- notifyEvent.display = DISPLAY;
- notifyEvent.event = pCD->client;
- notifyEvent.window = pCD->client;
- if (pCD->pECD)
- {
- int rootX, rootY;
- Window wChild;
- WmFpEmbeddedClientData *pECD = (WmFpEmbeddedClientData *)pCD->pECD;
- /*
- * The front panel uses clientX, clientY for position in
- * front panel. Translate to root coords for client's
- * information.
- */
- XTranslateCoordinates (DISPLAY, pECD->winParent,
- ROOT_FOR_CLIENT(pCD), pCD->clientX, pCD->clientY,
- &rootX, &rootY, &wChild);
- notifyEvent.x = rootX;
- notifyEvent.y = rootY;
- notifyEvent.width = pCD->clientWidth;
- notifyEvent.height = pCD->clientHeight;
- }
- else
- if (pCD->maxConfig)
- {
- notifyEvent.x = pCD->maxX;
- notifyEvent.y = pCD->maxY;
- notifyEvent.width = pCD->maxWidth;
- notifyEvent.height = pCD->maxHeight;
- }
- else
- {
- notifyEvent.x = pCD->clientX;
- notifyEvent.y = pCD->clientY;
- notifyEvent.width = pCD->clientWidth;
- notifyEvent.height = pCD->clientHeight;
- }
- notifyEvent.border_width = 0;
- notifyEvent.above = None;
- notifyEvent.override_redirect = False;
- XSendEvent (DISPLAY, pCD->client, False, StructureNotifyMask,
- (XEvent *)¬ifyEvent);
- } /* END OF FUNCTION SendConfigureNotify */
- /*************************************<->*************************************
- *
- * SendClientOffsetMessage (pCD)
- *
- *
- * Description:
- * -----------
- * This function is used to send a client message containing the offset
- * between the window position reported to the user and the actual
- * window position of the client over the root.
- *
- * This can be used by clients that map and unmap windows to help them
- * work with the window manager to place the window in the same location
- * when remapped.
- *
- * Inputs:
- * ------
- * pCD = pointer to client data (frame geometry info)
- *
- *************************************<->***********************************/
- void SendClientOffsetMessage (ClientData *pCD)
- {
- long borderWidth = (long)pCD->xBorderWidth;
- long offsetX = pCD->clientOffset.x;
- long offsetY = pCD->clientOffset.y;
-
- XClientMessageEvent clientMsgEvent;
- clientMsgEvent.type = ClientMessage;
- clientMsgEvent.window = pCD->client;
- clientMsgEvent.message_type = wmGD.xa_MWM_MESSAGES;
- clientMsgEvent.format = 32;
- clientMsgEvent.data.l[0] = wmGD.xa_MWM_OFFSET;
- /*
- * Use window gravity to allow the user to specify the window
- * position on the screen without having to know the dimensions
- * of the decoration that mwm is adding.
- */
-
- switch (pCD->windowGravity)
- {
- case NorthWestGravity:
- default:
- {
- clientMsgEvent.data.l[1] = offsetX;
- clientMsgEvent.data.l[2] = offsetY;
- break;
- }
-
- case NorthGravity:
- {
- clientMsgEvent.data.l[1] = borderWidth;
- clientMsgEvent.data.l[2] = offsetY;
- break;
- }
-
- case NorthEastGravity:
- {
- clientMsgEvent.data.l[1] = -(offsetX - (2 * borderWidth));
- clientMsgEvent.data.l[2] = offsetY;
- break;
- }
-
- case EastGravity:
- {
- clientMsgEvent.data.l[1] = -(offsetX - (2 * borderWidth));
- clientMsgEvent.data.l[2] = borderWidth + (offsetY - offsetX)/2;
- break;
- }
-
- case SouthEastGravity:
- {
- clientMsgEvent.data.l[1] = -(offsetX - (2 * borderWidth));
- clientMsgEvent.data.l[2] = -(offsetX - (2 * borderWidth));
- break;
- }
-
- case SouthGravity:
- {
- clientMsgEvent.data.l[1] = borderWidth;
- clientMsgEvent.data.l[2] = -(offsetX - (2 * borderWidth));
- break;
- }
-
- case SouthWestGravity:
- {
- clientMsgEvent.data.l[1] = offsetX;
- clientMsgEvent.data.l[2] = -(offsetX - (2 * borderWidth));
- break;
- }
-
- case WestGravity:
- {
- clientMsgEvent.data.l[1] = offsetX;
- clientMsgEvent.data.l[2] = borderWidth + (offsetY - offsetX)/2;
- break;
- }
-
- case CenterGravity:
- {
- clientMsgEvent.data.l[2] = (offsetY - offsetX)/2;
- break;
- }
- }
- XSendEvent (DISPLAY, pCD->client, False, NoEventMask,
- (XEvent *)&clientMsgEvent);
- } /* END OF FUNCTION SendClientOffsetMessage */
- /*************************************<->*************************************
- *
- * SendClientMsg (window, type, data0, time, pData, dataLen)
- *
- *
- * Description:
- * -----------
- * This function is used to send a client message event that to a client
- * window. The message may be sent as part of a protocol arranged for by
- * the client with the WM_PROTOCOLS property.
- *
- *
- * Inputs:
- * ------
- * window = destination window for the client message event
- *
- * type = client message type
- *
- * data0 = data0 value in the client message
- *
- * time = timestamp to be used in the event
- *
- * pData = pointer to data to be used in the event
- *
- * dataLen = len of data (in 32 bit units)
- *
- *************************************<->***********************************/
- void SendClientMsg (Window window, long type, long data0, Time time, long *pData, int dataLen)
- {
- XClientMessageEvent clientMsgEvent;
- int i;
- clientMsgEvent.type = ClientMessage;
- clientMsgEvent.window = window;
- clientMsgEvent.message_type = type;
- clientMsgEvent.format = 32;
- clientMsgEvent.data.l[0] = data0;
- clientMsgEvent.data.l[1] = (long)time;
- if (pData)
- {
- /*
- * Fill in the rest of the ClientMessage event (that holds up to
- * 5 words of data).
- */
- if (dataLen > 3)
- {
- dataLen = 3;
- }
- for (i = 2; i < (2 + dataLen); i++)
- {
- clientMsgEvent.data.l[i] = pData[i];
- }
- }
-
-
- XSendEvent (DISPLAY, window, False, NoEventMask,
- (XEvent *)&clientMsgEvent);
- XFlush(DISPLAY);
- } /* END OF FUNCTION SendClientMsg */
- /*************************************<->*************************************
- *
- * AddWmTimer (timerType, timerInterval, pCD)
- *
- *
- * Description:
- * -----------
- * This function sets a window manager timer of the specified type.
- *
- *
- * Inputs:
- * ------
- * timerType = type of timer to be set
- *
- * timerInterval = length of timeout in ms
- *
- * pCD = pointer to client data associated with the timer
- *
- * return = True if timer could be set
- *
- *************************************<->***********************************/
- Boolean AddWmTimer (unsigned int timerType, unsigned long timerInterval, ClientData *pCD)
- {
- WmTimer *pWmTimer;
- if (!(pWmTimer = (WmTimer *)XtMalloc (sizeof (WmTimer))))
- {
- Warning (((char *)GETMESSAGE(56, 1, "Insufficient memory for window manager data")));
- return (False);
- }
- /* !!! handle for XtAppAddTimeOut error !!! */
- pWmTimer->timerId = XtAppAddTimeOut (wmGD.mwmAppContext,
- timerInterval, (XtTimerCallbackProc)TimeoutProc, (caddr_t)pCD);
- pWmTimer->timerCD = pCD;
- pWmTimer->timerType = timerType;
- pWmTimer->nextWmTimer = wmGD.wmTimers;
- wmGD.wmTimers = pWmTimer;
- return(True);
- } /* END OF FUNCTION AddWmTimer */
- /*************************************<->*************************************
- *
- * DeleteClientWmTimers (pCD)
- *
- *
- * Description:
- * -----------
- * This function deletes all window manager timers that are associated with
- * the specified client window.
- *
- *
- * Inputs:
- * ------
- * pCD = pointer to client data for client whose timers are to be deleted
- *
- * wmGD = (wmTimers)
- *
- *************************************<->***********************************/
- void DeleteClientWmTimers (ClientData *pCD)
- {
- WmTimer *pPrevTimer;
- WmTimer *pWmTimer;
- WmTimer *pRemoveTimer;
- pPrevTimer = NULL;
- pWmTimer = wmGD.wmTimers;
- while (pWmTimer)
- {
- if (pWmTimer->timerCD == pCD)
- {
- if (pPrevTimer)
- {
- pPrevTimer->nextWmTimer = pWmTimer->nextWmTimer;
- }
- else
- {
- wmGD.wmTimers = pWmTimer->nextWmTimer;
- }
- pRemoveTimer = pWmTimer;
- pWmTimer = pWmTimer->nextWmTimer;
- XtRemoveTimeOut (pRemoveTimer->timerId);
- XtFree ((char *)pRemoveTimer);
- }
- else
- {
- pPrevTimer = pWmTimer;
- pWmTimer = pWmTimer->nextWmTimer;
- }
- }
- } /* END OF FUNCTION DeleteClientWmTimers */
- /*************************************<->*************************************
- *
- * TimeoutProc (client_data, id)
- *
- *
- * Description:
- * -----------
- * This function is an Xtk timeout handler. It is used to handle various
- * window manager timers (i.e. WM_SAVE_YOURSELF quit timeout).
- *
- *
- * Inputs:
- * ------
- * client_data = pointer to window manager client data
- *
- * id = Xtk timer id
- *
- *************************************<->***********************************/
- void TimeoutProc (caddr_t client_data, XtIntervalId *id)
- {
- WmTimer *pPrevTimer;
- WmTimer *pWmTimer;
-
- /*
- * Find out if the timer still needs to be serviced.
- */
- pPrevTimer = NULL;
- pWmTimer = wmGD.wmTimers;
- while (pWmTimer)
- {
- if (pWmTimer->timerId == *id)
- {
- break;
- }
- pPrevTimer = pWmTimer;
- pWmTimer = pWmTimer->nextWmTimer;
- }
- if (pWmTimer)
- {
- /*
- * Do the timer related action.
- */
- switch (pWmTimer->timerType)
- {
- case TIMER_QUIT:
- {
- XKillClient (DISPLAY, pWmTimer->timerCD->client);
- break;
- }
- case TIMER_RAISE:
- {
- Boolean sameScreen;
- if ((wmGD.keyboardFocus == pWmTimer->timerCD) &&
- (pWmTimer->timerCD->focusPriority ==
- (PSD_FOR_CLIENT(pWmTimer->timerCD))->focusPriority) &&
- (wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_POINTER) &&
- (pWmTimer->timerCD == GetClientUnderPointer(&sameScreen)))
- {
- Do_Raise (pWmTimer->timerCD, (ClientListEntry *)NULL, STACK_NORMAL);
- }
- break;
- }
- }
- /*
- * Remove the timer from the wm timer list.
- */
- if (pPrevTimer)
- {
- pPrevTimer->nextWmTimer = pWmTimer->nextWmTimer;
- }
- else
- {
- wmGD.wmTimers = pWmTimer->nextWmTimer;
- }
- XtFree ((char *)pWmTimer);
- }
- /*
- * Free up the timer.
- */
- XtRemoveTimeOut (*id);
- } /* END OF FUNCTION TimeoutProc */
- /*************************************<->*************************************
- *
- * Boolean wmq_convert (w, pSelection, pTarget, pType_return,
- * pValue_return, pLength_return, pFormat_return)
- *
- *
- * Description:
- * -----------
- * This function converts WM_QUERY selections
- *
- * Inputs:
- * ------
- * w - widget
- * pSelection - pointer to selection type (atom)
- * pTarget - pointer to requested target type (atom)
- *
- * Outputs:
- * ------
- * pType_return - pointer to type of data returned (atom)
- * pValue_return - pointer to pointer to data returned
- * pLength_return - ptr to length of data returned
- * pFormat_return - ptr to format of data returned
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- static Boolean
- wmq_convert (
- Widget w,
- Atom *pSelection,
- Atom *pTarget,
- Atom *pType_return,
- XtPointer *pValue_return,
- unsigned long *pLength_return,
- int *pFormat_return
- )
- {
- Boolean wm_query_found = False;
- int scr;
- for (scr = 0; scr < wmGD.numScreens; scr++)
- {
- if (wmGD.Screens[scr].managed)
- {
- if (*pSelection == xa_WM_QUERY[scr])
- {
- wm_query_found = True;
- break;
- }
- }
- }
- if (wm_query_found)
- {
- if (*pTarget == xa_WM_POINTER_WINDOW)
- {
- return (False);
- }
- else if (*pTarget == xa_WM_CLIENT_WINDOW)
- {
- return (False);
- }
- else if (*pTarget == xa_WM_ALL_CLIENTS)
- {
- return (wmq_convert_all_clients (w, scr, pType_return,
- pValue_return, pLength_return,
- pFormat_return));
- }
- }
- return (wm_query_found);
- } /* END OF FUNCTION wmq_convert */
- /*************************************<->*************************************
- *
- * Boolean wmq_convert_all_clients (w, screen, pType_return,
- * pValue_return, pLength_return, pFormat_return)
- *
- *
- * Description:
- * -----------
- * This function converts the WM_QUERY selection target WM_ALL_CLIENTS
- *
- * Inputs:
- * ------
- * w - widget
- * screen - screen number
- *
- * Outputs:
- * ------
- * pType_return - pointer to type of data returned (atom)
- * pValue_return - pointer to pointer to data returned
- * pLength_return - ptr to length of data returned
- * pFormat_return - ptr to format of data returned
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- static Boolean
- wmq_convert_all_clients (
- Widget w,
- int screen,
- Atom *pType_return,
- XtPointer *pValue_return,
- unsigned long *pLength_return,
- int *pFormat_return
- )
- {
- WmScreenData *pSD = NULL;
- ClientListEntry *pEntry;
- ClientData *pCD;
- /*
- * Start with empty client list
- */
- curXids = 0;
- /*
- * Get all clients on the specified screen
- */
- if (wmGD.Screens[screen].managed)
- {
- pSD = &wmGD.Screens[screen];
-
- /*
- * Traverse the client list for this screen and
- * add to the list of window IDs
- */
- pEntry = pSD->clientList;
-
- while (pEntry)
- {
- /*
- * Filter out entries for icons
- */
- if (pEntry->type != MINIMIZED_STATE)
- {
- pCD = pEntry->pCD;
- if (pCD->transientChildren)
- {
- wmq_list_subtree(pCD->transientChildren);
- }
- wmq_add_xid ((XID) pCD->client);
- }
- pEntry = pEntry->nextSibling;
- }
- }
- *pType_return = XA_WINDOW;
- *pValue_return = (XtPointer) pXids;
- *pLength_return = curXids;
- *pFormat_return = 32;
- return (True);
- } /* END OF FUNCTION wmq_convert_all_clients */
- /*************************************<->*************************************
- *
- * void wmq_list_subtree (pCD)
- *
- *
- * Description:
- * -----------
- * This function adds the windows in a transient subtree to the
- * global window list
- *
- * Inputs:
- * ------
- * pCD - client data for "leftmost" child of a subtree
- *
- * Outputs:
- * ------
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- static void
- wmq_list_subtree (
- ClientData *pCD
- )
- {
- /*
- * Do children first
- */
- if (pCD->transientChildren)
- {
- wmq_list_subtree(pCD->transientChildren);
- }
- /*
- * Do me
- */
- wmq_add_xid ((XID) pCD->client);
- /*
- * Do siblings
- */
- if (pCD->transientSiblings)
- {
- wmq_list_subtree(pCD->transientSiblings);
- }
-
- } /* END OF FUNCTION wmq_list_subtree */
- /*************************************<->*************************************
- *
- * void wmq_add_xid (win)
- *
- *
- * Description:
- * -----------
- * This function adds an xid to the list
- *
- * Inputs:
- * ------
- * win - xid to add
- *
- * Outputs:
- * ------
- *
- * Comments:
- * --------
- *
- *************************************<->***********************************/
- static void
- wmq_add_xid (
- XID win
- )
- {
- if (curXids >= numXids)
- {
- wmq_bump_xids();
- }
- if (curXids < numXids)
- {
- pXids[curXids++] = win;
- }
- } /* END OF FUNCTION wmq_add_xid */
- /*************************************<->*************************************
- *
- * void wmq_lose (w, pSelection)
- *
- *
- * Description:
- * -----------
- * This function is called when we lose the WM_QUERY selection
- *
- * Inputs:
- * ------
- * w - widget
- * pSelection - pointer to selection type (atom)
- *
- * Outputs:
- * ------
- *
- * Comments:
- * --------
- * This shouldn't happen!
- *
- *************************************<->***********************************/
- static void
- wmq_lose (
- Widget w,
- Atom *pSelection
- )
- {
- Warning (((char *)GETMESSAGE(56, 4, "Lost _MOTIF_WM_QUERY_nn selection")));
- } /* END OF FUNCTION wmq_lose */
- /*************************************<->*************************************
- *
- * void wmq_done (w, pSelection, pTarget)
- *
- *
- * Description:
- * -----------
- * This function is called when selection conversion is done.
- *
- * Inputs:
- * ------
- * w - widget
- * pSelection - pointer to selection type (atom)
- * pTarget - pointer to requested target type (atom)
- *
- * Outputs:
- * ------
- *
- * Comments:
- * --------
- * This is here to prevent Xt from freeing our buffers.
- *
- *************************************<->***********************************/
- static void
- wmq_done (
- Widget w,
- Atom *pSelection,
- Atom *pTarget
- )
- {
- } /* END OF FUNCTION wmq_done */
- /*************************************<->*************************************
- *
- * static void wmq_bump_xids ()
- *
- *
- * Description:
- * -----------
- * This function allocates more xids in our local buffer
- *
- * Inputs:
- * ------
- * w - widget
- * pSelection - pointer to selection type (atom)
- * pTarget - pointer to requested target type (atom)
- *
- * Outputs:
- * ------
- *
- * Comments:
- * --------
- * This is here to prevent Xt from freeing our buffers.
- *
- *************************************<->***********************************/
- static void
- wmq_bump_xids ( void )
- {
- XID *px;
- if (pXids)
- {
- if (!(px = (XID *)
- XtRealloc ((char *) pXids, (numXids + 32) * (sizeof (XID)))))
- {
- Warning (((char *)GETMESSAGE(56, 5, "Insufficient memory to convert _MOTIF_WM_QUERY_nn selection")));
- }
- else
- {
- pXids = px;
- numXids += 32;
- }
- }
- else
- {
- if (!(pXids = (XID *)
- XtMalloc (32 * (sizeof (XID)))))
- {
- Warning (((char *)GETMESSAGE(56, 5, "Insufficient memory to convert _MOTIF_WM_QUERY_nn selection")));
- }
- else
- {
- numXids = 32;
- }
- }
- }
|