Merge branch 'master' of ssh://git.code.sf.net/p/cdesktopenv/code
[oweals/cde.git] / cde / programs / dtwm / WmProtocol.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* 
24  * (c) Copyright 1989, 1990, 1991, 1992, 1993 OPEN SOFTWARE FOUNDATION, INC. 
25  * ALL RIGHTS RESERVED 
26 */ 
27 /* 
28  * Motif Release 1.2.3
29 */ 
30 #ifdef REV_INFO
31 #ifndef lint
32 static char rcsid[] = "$TOG: WmProtocol.c /main/8 1997/06/18 17:31:34 samborn $"
33 #endif
34 #endif
35 /*
36  * (c) Copyright 1987, 1988, 1989, 1990 HEWLETT-PACKARD COMPANY */
37
38 /*
39  * Included Files:
40  */
41
42 #include "WmGlobal.h"
43 #include "WmICCC.h"
44
45 /*
46  * include extern functions
47  */
48
49 #include "WmError.h"
50 #include "WmFunction.h"
51 #include "WmKeyFocus.h"
52 #include "WmMenu.h"
53 #include "WmWinInfo.h"
54 #ifndef NO_WMQUERY 
55 #include "WmEvent.h"
56 #endif /* NO_WMQUERY */
57 #ifdef PANELIST
58 #include "WmPanelP.h"
59 #endif /* PANELIST */
60
61 #if ((!defined(WSM)) || defined(MWM_QATS_PROTOCOL))
62 # include "WmCmd.h"
63 # include "WmDebug.h"
64 #endif /* !defined(WSM) || defined(MWM_QATS_PROTOCOL) */
65
66 /*
67  * Function Declarations:
68  */
69
70 #include "WmProtocol.h"
71 #ifndef NO_WMQUERY
72 static Boolean wmq_convert (Widget w, Atom *pSelection, Atom *pTarget, 
73     Atom *pType_return, XtPointer *pValue_return, unsigned long *pLength_return,
74     int *pFormat_return);
75 static Boolean wmq_convert_all_clients (Widget w, int screen,
76     Atom *pType_return, XtPointer *pValue_return, unsigned long *pLength_return,
77     int *pFormat_return);
78 static void wmq_list_subtree (ClientData *pCD);
79 static void wmq_add_xid (XID win);
80 static void wmq_done (Widget w, Atom *pSelection, Atom *pTarget);
81 static void wmq_lose (Widget w, Atom *pSelection);
82 static void wmq_bump_xids(void);
83 #endif /* NO_WMQUERY */
84
85 #if ((!defined(WSM)) || defined(MWM_QATS_PROTOCOL))
86 static void    OwnWMSelections      (Time timestamp);
87 static Boolean WMiConvert           (Widget, Atom, Atom,
88                                      XtPointer, unsigned long, int, Atom *,
89                                      XtPointer *, unsigned long *, int *);
90 static void    WMiConvertCB         (Widget, XtPointer, XtPointer);
91 #endif /* !defined(WSM) || defined(MWM_QATS_PROTOCOL) */
92
93 /*
94  * Global Variables:
95  */
96 #ifndef NO_WMQUERY
97 Atom *xa_WM_QUERY = NULL;
98 Atom xa_WM_POINTER_WINDOW;
99 Atom xa_WM_CLIENT_WINDOW;
100 Atom xa_WM_ALL_CLIENTS;
101 XID *pXids = NULL;
102 int numXids = -1;
103 int curXids = 0;
104 #endif /* NO_WMQUERY */
105
106
107 \f
108 /*************************************<->*************************************
109  *
110  *  SetupWmICCC ()
111  *
112  *
113  *  Description:
114  *  -----------
115  *  This function sets up the window manager handling of the inter-client
116  *  communications conventions.
117  *
118  *
119  *  Outputs:
120  *  -------
121  *  (wmGD) = Atoms id's are setup.
122  *
123  *************************************<->***********************************/
124
125 void SetupWmICCC (void)
126 {
127     enum { 
128 #if ((!defined(WSM)) || defined(MWM_QATS_PROTOCOL))
129            XA_TARGETS, XA_MULTIPLE, XA_TIMESTAMP, 
130 #endif
131            XA_WM_STATE, XA_WM_PROTOCOLS, XA_WM_CHANGE_STATE,
132            XA_WM_SAVE_YOURSELF, XA_WM_DELETE_WINDOW,
133            XA_WM_COLORMAP_WINDOWS, XA_WM_TAKE_FOCUS, XA_MWM_HINTS,
134            XA_MWM_MENU, XA_MWM_MESSAGES, XA_MOTIF_WM_OFFSET,
135 #if ((!defined(WSM)) || defined(MWM_QATS_PROTOCOL) || !defined(NO_WMQUERY))
136            XA_MOTIF_WM_CLIENT_WINDOW, XA_MOTIF_WM_POINTER_WINDOW,
137            XA_MOTIF_WM_ALL_CLIENTS,
138 #endif
139 #if ((!defined(WSM)) || defined(MWM_QATS_PROTOCOL))
140            XA_MOTIF_WM_DEFINE_COMMAND, XA_MOTIF_WM_INCLUDE_COMMAND,
141            XA_MOTIF_WM_REMOVE_COMMAND, XA_MOTIF_WM_ENABLE_COMMAND,
142            XA_MOTIF_WM_DISABLE_COMMAND, XA_MOTIF_WM_RENAME_COMMAND,
143            XA_MOTIF_WM_INVOKE_COMMAND, XA_MOTIF_WM_REQUEST_COMMAND,
144            XA_MOTIF_WM_WINDOW_FLAGS, XA_MOTIF_WM_AUTOMATION, 
145 #endif
146            XA_COMPOUND_TEXT, NUM_ATOMS };
147
148     static char *atom_names[] = {
149 #if ((!defined(WSM)) || defined(MWM_QATS_PROTOCOL))
150            _XA_TARGETS, _XA_MULTIPLE, _XA_TIMESTAMP, 
151 #endif
152            _XA_WM_STATE, _XA_WM_PROTOCOLS, _XA_WM_CHANGE_STATE,
153            _XA_WM_SAVE_YOURSELF, _XA_WM_DELETE_WINDOW,
154            _XA_WM_COLORMAP_WINDOWS, _XA_WM_TAKE_FOCUS, _XA_MWM_HINTS,
155            _XA_MWM_MENU, _XA_MWM_MESSAGES, _XA_MOTIF_WM_OFFSET,
156 #if ((!defined(WSM)) || defined(MWM_QATS_PROTOCOL) || !defined(NO_WMQUERY))
157 # ifdef _XA_MOTIF_WM_CLIENT_WINDOW
158            _XA_MOTIF_WM_CLIENT_WINDOW, _XA_MOTIF_WM_POINTER_WINDOW,
159            _XA_MOTIF_WM_ALL_CLIENTS, 
160 # else
161            "_MOTIF_WM_CLIENT_WINDOW", "_MOTIF_WM_POINTER_WINDOW",
162            "_MOTIF_WM_ALL_CLIENTS"
163 # endif
164 #endif
165 #if ((!defined(WSM)) || defined(MWM_QATS_PROTOCOL))
166            _XA_MOTIF_WM_DEFINE_COMMAND, _XA_MOTIF_WM_INCLUDE_COMMAND,
167            _XA_MOTIF_WM_REMOVE_COMMAND, _XA_MOTIF_WM_ENABLE_COMMAND,
168            _XA_MOTIF_WM_DISABLE_COMMAND, _XA_MOTIF_WM_RENAME_COMMAND,
169            _XA_MOTIF_WM_INVOKE_COMMAND, _XA_MOTIF_WM_REQUEST_COMMAND,
170            _XA_MOTIF_WM_WINDOW_FLAGS, _XA_MOTIF_WM_AUTOMATION, 
171 #endif
172            "COMPOUND_TEXT"
173     };
174
175     XIconSize sizeList;
176     int scr;
177     Atom atoms[XtNumber(atom_names)];
178
179     /*
180      * Make atoms that are required by the ICCC and mwm.  The atom for
181      * _MOTIF_WM_INFO is intern'ed in ProcessMotifWmInfo.
182      */
183     XInternAtoms(DISPLAY, atom_names, XtNumber(atom_names), False, atoms);
184
185
186 #if ((!defined(WSM)) || defined(MWM_QATS_PROTOCOL))
187     wmGD.xa_TARGETS                     = atoms[XA_TARGETS];
188
189     wmGD.xa_MULTIPLE                    = atoms[XA_MULTIPLE];
190     wmGD.xa_TIMESTAMP                   = atoms[XA_TIMESTAMP];
191 #endif /* !defined(WSM) || defined(MWM_QATS_PROTOCOL) */
192
193     wmGD.xa_WM_STATE                    = atoms[XA_WM_STATE];
194     wmGD.xa_WM_PROTOCOLS                = atoms[XA_WM_PROTOCOLS];
195     wmGD.xa_WM_CHANGE_STATE             = atoms[XA_WM_CHANGE_STATE];
196     wmGD.xa_WM_SAVE_YOURSELF            = atoms[XA_WM_SAVE_YOURSELF];
197     wmGD.xa_WM_DELETE_WINDOW            = atoms[XA_WM_DELETE_WINDOW];
198     wmGD.xa_WM_COLORMAP_WINDOWS         = atoms[XA_WM_COLORMAP_WINDOWS];
199     wmGD.xa_WM_TAKE_FOCUS               = atoms[XA_WM_TAKE_FOCUS];
200     wmGD.xa_MWM_HINTS                   = atoms[XA_MWM_HINTS];
201     wmGD.xa_MWM_MENU                    = atoms[XA_MWM_MENU];
202     wmGD.xa_MWM_MESSAGES                = atoms[XA_MWM_MESSAGES];
203     wmGD.xa_MWM_OFFSET                  = atoms[XA_MOTIF_WM_OFFSET];
204
205 #if ((!defined(WSM)) || defined(MWM_QATS_PROTOCOL))
206     /* wm query targets */
207     wmGD._MOTIF_WM_CLIENT_WINDOW  = atoms[XA_MOTIF_WM_CLIENT_WINDOW];
208     wmGD._MOTIF_WM_POINTER_WINDOW = atoms[XA_MOTIF_WM_POINTER_WINDOW];
209     wmGD._MOTIF_WM_ALL_CLIENTS    = atoms[XA_MOTIF_WM_ALL_CLIENTS];
210
211     /* intern atoms for Client-Commmand Interface protocol. */
212     wmGD._MOTIF_WM_DEFINE_COMMAND = atoms[XA_MOTIF_WM_DEFINE_COMMAND];
213     wmGD._MOTIF_WM_INCLUDE_COMMAND= atoms[XA_MOTIF_WM_INCLUDE_COMMAND];
214     wmGD._MOTIF_WM_REMOVE_COMMAND = atoms[XA_MOTIF_WM_REMOVE_COMMAND];
215     wmGD._MOTIF_WM_ENABLE_COMMAND = atoms[XA_MOTIF_WM_ENABLE_COMMAND];
216     wmGD._MOTIF_WM_DISABLE_COMMAND= atoms[XA_MOTIF_WM_DISABLE_COMMAND];
217     wmGD._MOTIF_WM_RENAME_COMMAND = atoms[XA_MOTIF_WM_RENAME_COMMAND];
218     wmGD._MOTIF_WM_INVOKE_COMMAND = atoms[XA_MOTIF_WM_INVOKE_COMMAND];
219     wmGD._MOTIF_WM_REQUEST_COMMAND= atoms[XA_MOTIF_WM_REQUEST_COMMAND];
220     wmGD._MOTIF_WM_WINDOW_FLAGS   = atoms[XA_MOTIF_WM_WINDOW_FLAGS];
221
222     wmGD._MOTIF_WM_AUTOMATION     = atoms[XA_MOTIF_WM_AUTOMATION];
223 #endif /* !defined(WSM) || defined(MWM_QATS_PROTOCOL) */
224
225
226 #if ((!defined(WSM)) || defined(MWM_QATS_PROTOCOL))
227     /*
228      * Assert ownership of the WINDOW_MANAGER selection
229      * on each screen that the window manager controls.
230      * these use the format WM_Si.
231      */
232     OwnWMSelections(GetTimestamp());
233 #endif /* !defined(WSM) || defined(MWM_QATS_PROTOCOL) */
234
235     wmGD.xa_COMPOUND_TEXT = atoms[XA_COMPOUND_TEXT];
236
237 #ifndef NO_WMQUERY
238     if (!(xa_WM_QUERY = (Atom *) XtMalloc (wmGD.numScreens * (sizeof (Atom)))))
239     {
240         Warning (((char *)GETMESSAGE(56, 2, "Insufficient memory to XInternAtom _MOTIF_WM_QUERY_nn")));
241     }
242
243     for (scr = 0; scr < wmGD.numScreens; scr++)
244     {
245         if (wmGD.Screens[scr].managed)
246         {
247           char wm_query_scr[32];
248
249           sprintf(wm_query_scr, "_MOTIF_WM_QUERY_%d",
250                                         wmGD.Screens[scr].screen);
251           xa_WM_QUERY[scr] = XInternAtom(DISPLAY, wm_query_scr, False);
252         }
253         else
254         {
255           xa_WM_QUERY[scr] = 0;
256         }
257     }
258     xa_WM_CLIENT_WINDOW  = atoms[XA_MOTIF_WM_CLIENT_WINDOW];
259     xa_WM_POINTER_WINDOW = atoms[XA_MOTIF_WM_POINTER_WINDOW];
260     xa_WM_ALL_CLIENTS    = atoms[XA_MOTIF_WM_ALL_CLIENTS];
261 #endif /* NO_WMQUERY */
262
263
264     /*
265      * Setup the icon size property on the root window.
266      */
267
268     sizeList.width_inc = 1;
269     sizeList.height_inc = 1;
270
271     for (scr = 0; scr < wmGD.numScreens; scr++)
272     {
273         if (wmGD.Screens[scr].managed)
274         {
275             sizeList.min_width = wmGD.Screens[scr].iconImageMinimum.width;
276             sizeList.min_height = wmGD.Screens[scr].iconImageMinimum.height;
277             sizeList.max_width = wmGD.Screens[scr].iconImageMaximum.width;
278             sizeList.max_height = wmGD.Screens[scr].iconImageMaximum.height;
279
280             XSetIconSizes (DISPLAY, wmGD.Screens[scr].rootWindow, 
281                 &sizeList, 1);
282         }
283     }
284
285 #ifndef NO_WMQUERY
286     /*
287      * Assert ownership of the WM_QUERY selection
288      */
289     for (scr = 0; scr < wmGD.numScreens; scr++)
290     {
291         if (wmGD.Screens[scr].managed)
292         {
293             if (!XtOwnSelection(wmGD.topLevelW,
294                                 xa_WM_QUERY[scr],
295                                 GetTimestamp(),
296                                 wmq_convert,
297                                 wmq_lose,
298                                 wmq_done))
299               {
300                  Warning (((char *)GETMESSAGE(56, 3, "Failed to own _MOTIF_WM_QUERY_nn selection")));
301               }
302         }
303     }
304 #endif /* NO_WMQUERY */
305
306
307 } /* END OF FUNCTION SetupWmICCC */
308
309
310 \f
311 /*************************************<->*************************************
312  *
313  *  SendConfigureNotify (pCD)
314  *
315  *
316  *  Description:
317  *  -----------
318  *  This function is used to send a synthetic ConfigureNotify event when
319  *  a client window is reconfigured in certain ways (e.g., the window is
320  *  moved without being resized).
321  *
322  *
323  *  Inputs:
324  *  ------
325  *  pCD = pointer to client data (window id and client size data)
326  *
327  *************************************<->***********************************/
328
329 void SendConfigureNotify (ClientData *pCD)
330 {
331     XConfigureEvent notifyEvent;
332
333
334     /*
335      * Send a synthetic ConfigureNotify message:
336      */
337
338     notifyEvent.type = ConfigureNotify;
339     notifyEvent.display = DISPLAY;
340     notifyEvent.event = pCD->client;
341     notifyEvent.window = pCD->client;
342 #ifdef PANELIST
343     if (pCD->pECD)
344     {
345         int rootX, rootY;
346         Window wChild;
347         WmFpEmbeddedClientData *pECD = (WmFpEmbeddedClientData *)pCD->pECD;
348
349         /*
350          * The front panel uses clientX, clientY for position in
351          * front panel. Translate to root coords for client's
352          * information.
353          */
354
355         XTranslateCoordinates (DISPLAY, pECD->winParent,
356             ROOT_FOR_CLIENT(pCD), pCD->clientX, pCD->clientY, 
357             &rootX, &rootY, &wChild);
358
359         notifyEvent.x = rootX;
360         notifyEvent.y = rootY;
361         notifyEvent.width = pCD->clientWidth;
362         notifyEvent.height = pCD->clientHeight;
363     }
364     else
365 #else /* PANELIST */
366 #endif /* PANELIST */
367     if (pCD->maxConfig)
368     {
369         notifyEvent.x = pCD->maxX;
370         notifyEvent.y = pCD->maxY;
371         notifyEvent.width = pCD->maxWidth;
372         notifyEvent.height = pCD->maxHeight;
373     }
374     else
375     {
376         notifyEvent.x = pCD->clientX;
377         notifyEvent.y = pCD->clientY;
378         notifyEvent.width = pCD->clientWidth;
379         notifyEvent.height = pCD->clientHeight;
380     }
381     notifyEvent.border_width = 0;
382     notifyEvent.above = None;
383     notifyEvent.override_redirect = False;
384
385     XSendEvent (DISPLAY, pCD->client, False, StructureNotifyMask,
386         (XEvent *)&notifyEvent);
387
388
389 } /* END OF FUNCTION SendConfigureNotify */
390
391
392 \f
393 /*************************************<->*************************************
394  *
395  *  SendClientOffsetMessage (pCD)
396  *
397  *
398  *  Description:
399  *  -----------
400  *  This function is used to send a client message containing the offset
401  *  between the window position reported to the user and the actual
402  *  window position of the client over the root.
403  *
404  *  This can be used by clients that map and unmap windows to help them
405  *  work with the window manager to place the window in the same location
406  *  when remapped. 
407  *
408  *  Inputs:
409  *  ------
410  *  pCD = pointer to client data (frame geometry info)
411  *
412  *************************************<->***********************************/
413
414 void SendClientOffsetMessage (ClientData *pCD)
415 {
416     long borderWidth = (long)pCD->xBorderWidth;
417     long offsetX = pCD->clientOffset.x;
418     long offsetY = pCD->clientOffset.y;
419       
420     XClientMessageEvent clientMsgEvent;
421
422     clientMsgEvent.type = ClientMessage;
423     clientMsgEvent.window = pCD->client;
424     clientMsgEvent.message_type = wmGD.xa_MWM_MESSAGES;
425     clientMsgEvent.format = 32;
426     clientMsgEvent.data.l[0] = wmGD.xa_MWM_OFFSET;
427
428     /*
429      * Use window gravity to allow the user to specify the window
430      * position on the screen  without having to know the dimensions
431      * of the decoration that mwm is adding.
432      */
433     
434     switch (pCD->windowGravity)
435     {
436       case NorthWestGravity:
437       default:
438         {
439             clientMsgEvent.data.l[1] = offsetX;
440             clientMsgEvent.data.l[2] = offsetY;
441             break;
442         }
443         
444       case NorthGravity:
445         {
446             clientMsgEvent.data.l[1] = borderWidth;
447             clientMsgEvent.data.l[2] = offsetY;
448             break;
449         }
450         
451       case NorthEastGravity:
452         {
453             clientMsgEvent.data.l[1] = -(offsetX - (2 * borderWidth));
454             clientMsgEvent.data.l[2] = offsetY;
455             break;
456         }
457         
458       case EastGravity:
459         {
460             clientMsgEvent.data.l[1] = -(offsetX - (2 * borderWidth));
461             clientMsgEvent.data.l[2] = borderWidth + (offsetY - offsetX)/2;
462             break;
463         }
464         
465       case SouthEastGravity:
466         {
467             clientMsgEvent.data.l[1] = -(offsetX - (2 * borderWidth));
468             clientMsgEvent.data.l[2] = -(offsetX - (2 * borderWidth));
469             break;
470         }
471         
472       case SouthGravity:
473         {
474             clientMsgEvent.data.l[1] = borderWidth;
475             clientMsgEvent.data.l[2] = -(offsetX - (2 * borderWidth));
476             break;
477         }
478         
479       case SouthWestGravity:
480         {
481             clientMsgEvent.data.l[1] = offsetX;
482             clientMsgEvent.data.l[2] = -(offsetX - (2 * borderWidth));
483             break;
484         }
485         
486       case WestGravity:
487         {
488             clientMsgEvent.data.l[1] = offsetX;
489             clientMsgEvent.data.l[2] = borderWidth + (offsetY - offsetX)/2;
490             break;
491         }
492         
493       case CenterGravity:
494         {
495             clientMsgEvent.data.l[2] = (offsetY - offsetX)/2;
496             break;
497         }
498     }
499
500     XSendEvent (DISPLAY, pCD->client, False, NoEventMask,
501         (XEvent *)&clientMsgEvent);
502
503
504 } /* END OF FUNCTION SendClientOffsetMessage */
505
506 \f
507 /*************************************<->*************************************
508  *
509  *  SendClientMsg (window, type, data0, time, pData, dataLen)
510  *
511  *
512  *  Description:
513  *  -----------
514  *  This function is used to send a client message event that to a client
515  *  window.  The message may be sent as part of a protocol arranged for by
516  *  the client with the WM_PROTOCOLS property.
517  *
518  *
519  *  Inputs:
520  *  ------
521  *  window = destination window for the client message event
522  *
523  *  type = client message type
524  *
525  *  data0 = data0 value in the client message
526  *
527  *  time = timestamp to be used in the event
528  *
529  *  pData = pointer to data to be used in the event
530  *
531  *  dataLen = len of data (in 32 bit units)
532  *
533  *************************************<->***********************************/
534
535 void SendClientMsg (Window window, long type, long data0, Time time, long *pData, int dataLen)
536 {
537     XClientMessageEvent clientMsgEvent;
538     int i;
539
540
541     clientMsgEvent.type = ClientMessage;
542     clientMsgEvent.window = window;
543     clientMsgEvent.message_type = type;
544     clientMsgEvent.format = 32;
545     clientMsgEvent.data.l[0] = data0;
546     clientMsgEvent.data.l[1] = (long)time;
547     if (pData)
548     {
549         /*
550          * Fill in the rest of the ClientMessage event (that holds up to
551          * 5 words of data).
552          */
553
554         if (dataLen > 3)
555         {
556             dataLen = 3;
557         }
558         for (i = 2; i < (2 + dataLen); i++)
559         {
560             clientMsgEvent.data.l[i] = pData[i];
561         }
562     }
563     
564     
565     XSendEvent (DISPLAY, window, False, NoEventMask,
566         (XEvent *)&clientMsgEvent);
567     XFlush(DISPLAY);
568
569
570 } /* END OF FUNCTION SendClientMsg */
571
572
573 \f
574 /*************************************<->*************************************
575  *
576  *  AddWmTimer (timerType, timerInterval, pCD)
577  *
578  *
579  *  Description:
580  *  -----------
581  *  This function sets a window manager timer of the specified type.
582  *
583  *
584  *  Inputs:
585  *  ------
586  *  timerType = type of timer to be set
587  *
588  *  timerInterval = length of timeout in ms
589  *
590  *  pCD = pointer to client data associated with the timer
591  *
592  *  return = True if timer could be set
593  *
594  *************************************<->***********************************/
595
596 Boolean AddWmTimer (unsigned int timerType, unsigned long timerInterval, ClientData *pCD)
597 {
598     WmTimer *pWmTimer;
599
600
601     if (!(pWmTimer = (WmTimer *)XtMalloc (sizeof (WmTimer))))
602     {
603         Warning (((char *)GETMESSAGE(56, 1, "Insufficient memory for window manager data")));
604         return (False);
605     }
606
607     /* !!! handle for XtAppAddTimeOut error !!! */
608     pWmTimer->timerId = XtAppAddTimeOut (wmGD.mwmAppContext, 
609                             timerInterval, (XtTimerCallbackProc)TimeoutProc, (caddr_t)pCD);
610     pWmTimer->timerCD = pCD;
611     pWmTimer->timerType = timerType;
612     pWmTimer->nextWmTimer = wmGD.wmTimers;
613     wmGD.wmTimers = pWmTimer;
614
615     return(True);
616
617 } /* END OF FUNCTION AddWmTimer */
618
619
620 \f
621 /*************************************<->*************************************
622  *
623  *  DeleteClientWmTimers (pCD)
624  *
625  *
626  *  Description:
627  *  -----------
628  *  This function deletes all window manager timers that are associated with
629  *  the specified client window.
630  *
631  *
632  *  Inputs:
633  *  ------
634  *  pCD = pointer to client data for client whose timers are to be deleted
635  *
636  *  wmGD = (wmTimers)
637  *
638  *************************************<->***********************************/
639
640 void DeleteClientWmTimers (ClientData *pCD)
641 {
642     WmTimer *pPrevTimer;
643     WmTimer *pWmTimer;
644     WmTimer *pRemoveTimer;
645
646
647     pPrevTimer = NULL;
648     pWmTimer = wmGD.wmTimers;
649     while (pWmTimer)
650     {
651         if (pWmTimer->timerCD == pCD)
652         {
653             if (pPrevTimer)
654             {
655                 pPrevTimer->nextWmTimer = pWmTimer->nextWmTimer;
656             }
657             else
658             {
659                 wmGD.wmTimers = pWmTimer->nextWmTimer;
660             }
661             pRemoveTimer = pWmTimer;
662             pWmTimer = pWmTimer->nextWmTimer;
663             XtRemoveTimeOut (pRemoveTimer->timerId);
664             XtFree ((char *)pRemoveTimer);
665         }
666         else
667         {
668             pPrevTimer = pWmTimer;
669             pWmTimer = pWmTimer->nextWmTimer;
670         }
671     }
672
673
674 } /* END OF FUNCTION DeleteClientWmTimers */
675
676
677 \f
678 /*************************************<->*************************************
679  *
680  *  TimeoutProc (client_data, id)
681  *
682  *
683  *  Description:
684  *  -----------
685  *  This function is an Xtk timeout handler.  It is used to handle various
686  *  window manager timers (i.e. WM_SAVE_YOURSELF quit timeout).
687  *
688  *
689  *  Inputs:
690  *  ------
691  *  client_data = pointer to window manager client data
692  *
693  *  id = Xtk timer id
694  *
695  *************************************<->***********************************/
696
697 void TimeoutProc (caddr_t client_data, XtIntervalId *id)
698 {
699     WmTimer *pPrevTimer;
700     WmTimer *pWmTimer;
701
702     
703     /*
704      * Find out if the timer still needs to be serviced.
705      */
706
707     pPrevTimer = NULL;
708     pWmTimer = wmGD.wmTimers;
709     while (pWmTimer)
710     {
711         if (pWmTimer->timerId == *id)
712         {
713             break;
714         }
715         pPrevTimer = pWmTimer;
716         pWmTimer = pWmTimer->nextWmTimer;
717     }
718
719     if (pWmTimer)
720     {
721         /*
722          * Do the timer related action.
723          */
724
725         switch (pWmTimer->timerType)
726         {
727             case TIMER_QUIT:
728             {
729                 XKillClient (DISPLAY, pWmTimer->timerCD->client);
730                 break;
731             }
732
733             case TIMER_RAISE:
734             {
735                 Boolean sameScreen;
736
737                 if ((wmGD.keyboardFocus == pWmTimer->timerCD) &&
738                     (pWmTimer->timerCD->focusPriority == 
739                         (PSD_FOR_CLIENT(pWmTimer->timerCD))->focusPriority) &&
740                     (wmGD.keyboardFocusPolicy == KEYBOARD_FOCUS_POINTER) &&
741                     (pWmTimer->timerCD == GetClientUnderPointer(&sameScreen)))
742                 {
743                     Do_Raise (pWmTimer->timerCD, (ClientListEntry *)NULL, STACK_NORMAL);
744                 }
745                 break;
746             }
747         }
748
749
750         /*
751          * Remove the timer from the wm timer list.
752          */
753
754         if (pPrevTimer)
755         {
756             pPrevTimer->nextWmTimer = pWmTimer->nextWmTimer;
757         }
758         else
759         {
760             wmGD.wmTimers = pWmTimer->nextWmTimer;
761         }
762         XtFree ((char *)pWmTimer);
763     }
764
765     /*
766      * Free up the timer.
767      */
768
769     XtRemoveTimeOut (*id);
770
771
772 } /* END OF FUNCTION TimeoutProc */
773
774
775 #ifndef NO_WMQUERY 
776 \f
777 /*************************************<->*************************************
778  *
779  *  Boolean wmq_convert (w, pSelection, pTarget, pType_return, 
780  *      pValue_return, pLength_return, pFormat_return)
781  *
782  *
783  *  Description:
784  *  -----------
785  *  This function converts WM_QUERY selections
786  *
787  *  Inputs:
788  *  ------
789  *  w - widget
790  *  pSelection - pointer to selection type (atom)
791  *  pTarget - pointer to requested target type (atom)
792  *
793  *  Outputs:
794  *  ------
795  *  pType_return - pointer to type of data returned (atom)
796  *  pValue_return - pointer to pointer to data returned
797  *  pLength_return - ptr to length of data returned
798  *  pFormat_return - ptr to format of data returned
799  *
800  *  Comments:
801  *  --------
802  *
803  *************************************<->***********************************/
804 static Boolean
805 wmq_convert (
806     Widget w,
807     Atom *pSelection,
808     Atom *pTarget,
809     Atom *pType_return,
810     XtPointer *pValue_return,
811     unsigned long *pLength_return,
812     int *pFormat_return
813     )
814 {
815
816     Boolean wm_query_found = False;
817     int scr;
818
819
820     for (scr = 0; scr < wmGD.numScreens; scr++)
821     {
822         if (wmGD.Screens[scr].managed)
823         {
824             if (*pSelection == xa_WM_QUERY[scr])
825             {
826                 wm_query_found = True;
827                 break;
828             }
829         }
830     }
831
832     if (wm_query_found)
833     {
834         if (*pTarget == xa_WM_POINTER_WINDOW)
835         {
836             return (False);
837         }
838         else if (*pTarget == xa_WM_CLIENT_WINDOW)
839         {
840             return (False);
841         }
842         else if (*pTarget == xa_WM_ALL_CLIENTS)
843         {
844             return (wmq_convert_all_clients (w, scr, pType_return,
845                         pValue_return, pLength_return,
846                         pFormat_return));
847         }
848     }
849
850     return (wm_query_found);
851 } /* END OF FUNCTION wmq_convert */
852
853 \f
854 /*************************************<->*************************************
855  *
856  *  Boolean wmq_convert_all_clients (w, screen, pType_return, 
857  *      pValue_return, pLength_return, pFormat_return)
858  *
859  *
860  *  Description:
861  *  -----------
862  *  This function converts the WM_QUERY selection target WM_ALL_CLIENTS
863  *
864  *  Inputs:
865  *  ------
866  *  w - widget
867  *  screen - screen number
868  *
869  *  Outputs:
870  *  ------
871  *  pType_return - pointer to type of data returned (atom)
872  *  pValue_return - pointer to pointer to data returned
873  *  pLength_return - ptr to length of data returned
874  *  pFormat_return - ptr to format of data returned
875  *
876  *  Comments:
877  *  --------
878  *
879  *************************************<->***********************************/
880 static Boolean
881 wmq_convert_all_clients (
882     Widget w,
883     int screen,
884     Atom *pType_return,
885     XtPointer *pValue_return,
886     unsigned long *pLength_return,
887     int *pFormat_return
888     )
889 {
890     WmScreenData *pSD = NULL;
891     ClientListEntry *pEntry;
892     ClientData *pCD;
893
894     /*
895      * Start with empty client list
896      */
897     curXids = 0;
898
899     /*
900      * Get all clients on the specified screen
901      */
902
903     if (wmGD.Screens[screen].managed) 
904     {
905         pSD = &wmGD.Screens[screen];
906           
907         /*
908          * Traverse the client list for this screen and
909          * add to the list of window IDs 
910          */
911         pEntry = pSD->clientList;
912           
913         while (pEntry)
914         {
915             /* 
916              * Filter out entries for icons
917              */
918             if (pEntry->type != MINIMIZED_STATE)
919             {
920                 pCD = pEntry->pCD;
921                 if (pCD->transientChildren)
922                 {
923                     wmq_list_subtree(pCD->transientChildren);
924                 }
925                 wmq_add_xid ((XID) pCD->client);
926             }
927             pEntry = pEntry->nextSibling;
928         }
929     }
930
931     *pType_return = XA_WINDOW;
932     *pValue_return = (XtPointer) pXids;
933     *pLength_return = curXids;
934     *pFormat_return = 32;
935     return (True);
936
937 } /* END OF FUNCTION wmq_convert_all_clients */
938
939 \f
940 /*************************************<->*************************************
941  *
942  *  void wmq_list_subtree (pCD)
943  *
944  *
945  *  Description:
946  *  -----------
947  *  This function adds the windows in a transient subtree to the 
948  *  global window list
949  *
950  *  Inputs:
951  *  ------
952  *  pCD - client data for "leftmost" child of a subtree
953  *
954  *  Outputs:
955  *  ------
956  *
957  *  Comments:
958  *  --------
959  *
960  *************************************<->***********************************/
961 static void
962 wmq_list_subtree (
963     ClientData *pCD
964     )
965 {
966
967     /*
968      * Do children first
969      */
970     if (pCD->transientChildren)
971     {
972         wmq_list_subtree(pCD->transientChildren);
973     }
974
975     /*
976      * Do me
977      */
978     wmq_add_xid ((XID) pCD->client);
979
980     /*
981      * Do siblings
982      */
983     if (pCD->transientSiblings)
984     {
985         wmq_list_subtree(pCD->transientSiblings);
986     }
987         
988 } /* END OF FUNCTION wmq_list_subtree */
989
990
991 \f
992 /*************************************<->*************************************
993  *
994  *  void wmq_add_xid (win)
995  *
996  *
997  *  Description:
998  *  -----------
999  *  This function adds an xid to the list
1000  *
1001  *  Inputs:
1002  *  ------
1003  *  win - xid to add
1004  *
1005  *  Outputs:
1006  *  ------
1007  *
1008  *  Comments:
1009  *  --------
1010  *
1011  *************************************<->***********************************/
1012 static void
1013 wmq_add_xid (
1014     XID win
1015     )
1016 {
1017     if (curXids >= numXids)
1018     {
1019         wmq_bump_xids();
1020     }
1021
1022     if (curXids < numXids)
1023     {
1024         pXids[curXids++] = win;
1025     }
1026
1027 } /* END OF FUNCTION wmq_add_xid */
1028
1029
1030 \f
1031 /*************************************<->*************************************
1032  *
1033  *  void wmq_lose (w, pSelection)
1034  *
1035  *
1036  *  Description:
1037  *  -----------
1038  *  This function is called when we lose the WM_QUERY selection
1039  *
1040  *  Inputs:
1041  *  ------
1042  *  w - widget
1043  *  pSelection - pointer to selection type (atom)
1044  *
1045  *  Outputs:
1046  *  ------
1047  *
1048  *  Comments:
1049  *  --------
1050  *  This shouldn't happen!
1051  *
1052  *************************************<->***********************************/
1053 static void
1054 wmq_lose (
1055     Widget w,
1056     Atom *pSelection
1057     )
1058 {
1059   Warning (((char *)GETMESSAGE(56, 4, "Lost _MOTIF_WM_QUERY_nn selection")));
1060 } /* END OF FUNCTION wmq_lose */
1061
1062
1063 \f
1064 /*************************************<->*************************************
1065  *
1066  *  void wmq_done (w, pSelection, pTarget)
1067  *
1068  *
1069  *  Description:
1070  *  -----------
1071  *  This function is called when selection conversion is done.
1072  *
1073  *  Inputs:
1074  *  ------
1075  *  w - widget
1076  *  pSelection - pointer to selection type (atom)
1077  *  pTarget - pointer to requested target type (atom)
1078  *
1079  *  Outputs:
1080  *  ------
1081  *
1082  *  Comments:
1083  *  --------
1084  *  This is here to prevent Xt from freeing our buffers.
1085  *
1086  *************************************<->***********************************/
1087 static void
1088 wmq_done (
1089     Widget w,
1090     Atom *pSelection,
1091     Atom *pTarget
1092     )
1093 {
1094 } /* END OF FUNCTION wmq_done */
1095
1096
1097 \f
1098 /*************************************<->*************************************
1099  *
1100  *  static void wmq_bump_xids ()
1101  *
1102  *
1103  *  Description:
1104  *  -----------
1105  *  This function allocates more xids in our local buffer 
1106  *
1107  *  Inputs:
1108  *  ------
1109  *  w - widget
1110  *  pSelection - pointer to selection type (atom)
1111  *  pTarget - pointer to requested target type (atom)
1112  *
1113  *  Outputs:
1114  *  ------
1115  *
1116  *  Comments:
1117  *  --------
1118  *  This is here to prevent Xt from freeing our buffers.
1119  *
1120  *************************************<->***********************************/
1121 static void
1122 wmq_bump_xids ( void )
1123 {
1124     XID *px;
1125
1126     if (pXids)
1127     {
1128         if (!(px = (XID *) 
1129           XtRealloc ((char *) pXids, (numXids + 32) * (sizeof (XID)))))
1130         {
1131           Warning (((char *)GETMESSAGE(56, 5, "Insufficient memory to convert _MOTIF_WM_QUERY_nn selection")));
1132         }
1133         else
1134         {
1135             pXids = px;
1136             numXids += 32;
1137         }
1138     }
1139     else
1140     {
1141         if (!(pXids = (XID *) 
1142           XtMalloc (32 * (sizeof (XID)))))
1143         {
1144           Warning (((char *)GETMESSAGE(56, 5, "Insufficient memory to convert _MOTIF_WM_QUERY_nn selection")));
1145         }
1146         else
1147         {
1148             numXids = 32;
1149         }
1150     }
1151 }
1152
1153 #endif /* NO_WMQUERY */
1154
1155
1156 \f
1157 #if ((!defined(WSM)) || defined(MWM_QATS_PROTOCOL))
1158 /*************************************<->*************************************
1159  *
1160  *  static void OwnWMSelections ()
1161  *
1162  *
1163  *  Description:
1164  *  -----------
1165  *  Get the selection ownership for each managed screen.  The selection mwm
1166  *  will own is WM_Si.
1167  *
1168  *  Inputs:
1169  *  ------
1170  *  
1171  *  
1172  *  
1173  *
1174  *  Outputs:
1175  *  ------
1176  *
1177  *  Comments:
1178  *  --------
1179  *  
1180  *
1181  *************************************<->***********************************/
1182 static void
1183 OwnWMSelections ( Time timestamp )
1184 {
1185   int scr;
1186   
1187   
1188   wmGD.xa_WM = (Atom *) XtMalloc (wmGD.numScreens * (sizeof (Atom)));
1189   
1190   for (scr = 0; scr < wmGD.numScreens; scr++)
1191     {
1192       if (wmGD.Screens[scr].managed)
1193         {
1194           char wm_scr[8];
1195           
1196           sprintf(wm_scr, "WM_S%d", DefaultScreen(DISPLAY));
1197           wmGD.xa_WM[scr] = XInternAtom (DISPLAY, wm_scr, False);
1198           
1199 #ifdef MWM_WSM
1200           /*
1201            * This registers the callback to be invoked when a request
1202            * is made against a WSM Protocol target.  The request
1203            * callback is stored by the WSM Protocol code and is
1204            * invoked in the convert routine (WMiConvert) below.
1205            * See WSMProcessProtoTargets().
1206            */
1207
1208           WSMRegisterRequestCallback(DISPLAY, scr, HandleWsmConvertRequest,
1209                                      NULL);
1210 #endif
1211
1212           /*
1213            * Own the selection through UTM.  This sets-up a convert function
1214            * that is invoked when a convert request is made on this selection.
1215            * The convert function is specified in the drawing area's
1216            * XmNconvertCallback resource.
1217            */
1218
1219           XtAddCallback(wmGD.Screens[scr].utmShell, XmNconvertCallback,
1220                         WMiConvertCB, NULL);
1221
1222           if (! XmeNamedSource(wmGD.Screens[scr].utmShell,
1223                                wmGD.xa_WM[scr], timestamp))
1224             {
1225               Warning (((char *)GETMESSAGE(56, 6,
1226                                            "Failed to own WM_nn selection")));
1227             }
1228           else
1229             {
1230               PRINT("Owning selection %s\n", wm_scr);
1231             }
1232         }
1233     }
1234 }
1235
1236
1237
1238 \f
1239 /*************************************<->*************************************
1240  *
1241  *  Boolean WMiConvert ( )
1242  *
1243  *
1244  *  Description:
1245  *  -----------
1246  *  This function converts WM_Si selections using the new param selections
1247  *
1248  *************************************<->***********************************/
1249
1250 /*ARGSUSED*/
1251 static Boolean
1252 WMiConvert (
1253      Widget         w,
1254      Atom           selection,
1255      Atom           target,
1256      XtPointer      input,
1257      unsigned long  inputLen,
1258      int            inputFmt,
1259      Atom          *outputType,
1260      XtPointer     *output,
1261      unsigned long *outputLen,
1262      int           *outputFmt)
1263 {
1264   int      scr;
1265   Boolean  found = False;
1266
1267   
1268   /* set up some defaults. selection code doesn't like garbage! */
1269   *outputLen = 0;
1270   *output    = NULL;
1271   *outputFmt = 8;
1272
1273   scr = XScreenNumberOfScreen(XtScreen(w));
1274   if (!wmGD.Screens[scr].managed)
1275     {
1276       Warning (((char *)GETMESSAGE(56, 7,
1277                 "Got convert request from unmanaged screen")));
1278       found = False;
1279     }
1280   
1281   else {
1282     if (target == wmGD.xa_TARGETS) {
1283       Atom *targs       = (Atom *)XtMalloc((unsigned) (28 * sizeof(Atom)));
1284       int   targetCount = 0;
1285       
1286       *output = (XtPointer) targs;
1287       
1288       /* required targets */
1289       *targs++ = wmGD.xa_TARGETS;                               targetCount++;
1290       *targs++ = wmGD.xa_MULTIPLE;                              targetCount++;
1291       *targs++ = wmGD.xa_TIMESTAMP;                             targetCount++;
1292
1293 #ifdef MWM_WSM
1294       /* other targets */
1295       *targs++ = _WSMReqTypeToTarget(DISPLAY, WSM_CONNECT);     targetCount++;
1296       *targs++ = _WSMReqTypeToTarget(DISPLAY, WSM_EXTENSIONS);  targetCount++;
1297       *targs++ = _WSMReqTypeToTarget(DISPLAY, WSM_CONFIG_FMT);  targetCount++;
1298       *targs++ = _WSMReqTypeToTarget(DISPLAY, WSM_GET_STATE);   targetCount++;
1299       *targs++ = _WSMReqTypeToTarget(DISPLAY, WSM_SET_STATE);   targetCount++;
1300       *targs++ = _WSMReqTypeToTarget(DISPLAY, WSM_REG_WINDOW);  targetCount++;
1301 #endif
1302       
1303       /* menu command interface support */
1304       *targs++ = wmGD._MOTIF_WM_DEFINE_COMMAND;                 targetCount++;
1305       *targs++ = wmGD._MOTIF_WM_INCLUDE_COMMAND;                targetCount++;
1306       *targs++ = wmGD._MOTIF_WM_REMOVE_COMMAND;                 targetCount++;
1307       *targs++ = wmGD._MOTIF_WM_ENABLE_COMMAND;                 targetCount++;
1308       *targs++ = wmGD._MOTIF_WM_DISABLE_COMMAND;                targetCount++;
1309       *targs++ = wmGD._MOTIF_WM_RENAME_COMMAND;                 targetCount++;
1310       *targs++ = wmGD._MOTIF_WM_INVOKE_COMMAND;                 targetCount++;
1311       *targs++ = wmGD._MOTIF_WM_REQUEST_COMMAND;                targetCount++;
1312       *targs++ = wmGD._MOTIF_WM_WINDOW_FLAGS;                   targetCount++;
1313
1314 #ifdef MWM_WSM
1315       /* virtual screen support */
1316       *targs++ = wmGD._MOTIF_WM_PAN;                            targetCount++;
1317       *targs++ = wmGD._MOTIF_WM_GOTO;                           targetCount++;
1318 #endif
1319
1320       /* automation support */
1321
1322       *targs++ = wmGD._MOTIF_WM_AUTOMATION;                      targetCount++;
1323       
1324       *outputType   = XA_ATOM;
1325       *outputLen = (targetCount * sizeof(Atom)) >> 2;
1326       *outputFmt = 32;
1327       
1328       found = True;
1329     }
1330
1331 #ifdef MWM_WSM    
1332     /* virtual screen support */
1333     else if (target == wmGD._MOTIF_WM_PAN)
1334       {
1335         int     dx, dy;
1336         Boolean config;
1337
1338         dx     = (int) UnpackCARD32(&input);
1339         dy     = (int) UnpackCARD32(&input);
1340         config = (Boolean) UnpackCARD8(&input);
1341
1342         PanRoot(dx, dy, config);
1343
1344         /*
1345          * Update the root property
1346          */
1347
1348         SetPanPosition (ACTIVE_PSD->panDx, ACTIVE_PSD->panDy);
1349         
1350         found = True;
1351       }
1352     else if (target == wmGD._MOTIF_WM_GOTO)
1353       {
1354         int  x, y;
1355
1356         x = (int) UnpackCARD32(&input);
1357         y = (int) UnpackCARD32(&input);
1358
1359         PanRoot(x - ACTIVE_PSD->panDx, y - ACTIVE_PSD->panDy, 1);
1360
1361         found = True;
1362       }
1363     
1364     /*
1365      * Handle the workspace manager protocol targets...
1366      */
1367     
1368     else if (WSMIsKnownTarget(w, target))
1369       {
1370         /*
1371          * Unpack data send in request and invoke CB specified
1372          * in WSMRegisterRequestCallback.
1373          */
1374         found = WSMProcessProtoTarget
1375                         (w, target,
1376                          input, inputLen, inputFmt,
1377                          outputType, output, outputLen, outputFmt);
1378       }
1379 #endif /* MWM_WSM */
1380     
1381     /*
1382      *  Handle client-command interface targets.
1383      */
1384     
1385     else if (target == wmGD._MOTIF_WM_DEFINE_COMMAND)
1386       {
1387         PRINT("Convert request made for _MOTIF_WM_DEFINE_COMMAND.\n");
1388         DefineCommand(w, target, (MessageData)input, inputLen, inputFmt);
1389         PRINT("Returning from _MOTIF_WM_DEFINE_COMMAND.\n");
1390         
1391         found = True;
1392       }
1393     else if (target == wmGD._MOTIF_WM_INCLUDE_COMMAND)
1394       {
1395         PRINT("Convert request made for _MOTIF_WM_INCLUDE_COMMAND.\n");
1396         IncludeCommand(w, target, (MessageData)input, inputLen, inputFmt);
1397         PRINT("Returning from _MOTIF_WM_INCLUDE_COMMAND.\n");
1398         
1399         found = True;
1400       }
1401     else if (target == wmGD._MOTIF_WM_REMOVE_COMMAND)
1402       {
1403         PRINT("Convert request made for _MOTIF_WM_REMOVE_COMMAND.\n");
1404         RemoveCommand(w, target, (MessageData)input, inputLen, inputFmt);
1405         
1406         found = True;
1407       }
1408     else if (target == wmGD._MOTIF_WM_ENABLE_COMMAND)
1409       {
1410         PRINT("Convert request made for _MOTIF_WM_ENABLE_COMMAND.\n");
1411         EnableCommand(w, target, (MessageData)input, inputLen, inputFmt);
1412         
1413         found = True;
1414       }
1415     else if (target == wmGD._MOTIF_WM_DISABLE_COMMAND)
1416       {
1417         PRINT("Convert request made for _MOTIF_WM_DISABLE_COMMAND.\n");
1418         DisableCommand(w, target, (MessageData)input, inputLen, inputFmt);
1419         
1420         found = True;
1421       }
1422     else if (target == wmGD._MOTIF_WM_RENAME_COMMAND)
1423       {
1424         PRINT("Convert request made for _MOTIF_WM_RENAME_COMMAND.\n");
1425         RenameCommand(w, target, (MessageData)input, inputLen, inputFmt);
1426         
1427         found = True;
1428       }
1429     else if (target == wmGD._MOTIF_WM_INVOKE_COMMAND)
1430       {
1431         /* Shouldn't get here! */
1432       }
1433     else if (target == wmGD._MOTIF_WM_REQUEST_COMMAND)
1434       {
1435       }
1436     else if (target == wmGD._MOTIF_WM_WINDOW_FLAGS)
1437       {
1438       }
1439     
1440     else if (target == wmGD._MOTIF_WM_AUTOMATION)
1441       {
1442         /*
1443          * This function needs to pack the necessary info into the
1444          * output data variable to send back to the requesting
1445          */
1446
1447         GetAutomationData(input,outputType,output,outputLen,outputFmt);
1448         found = True;
1449       }
1450
1451     else
1452       Warning (((char *)GETMESSAGE(56, 8,
1453                 "Conversion request made for unknown target type")));
1454   }
1455   
1456   
1457   return (found);
1458 }
1459
1460
1461
1462 \f
1463 /*************************************<->*************************************
1464  *
1465  *  void WMiConvertCB ( )
1466  *
1467  *
1468  *  Description:
1469  *  -----------
1470  *  This function is invoked by UTM to handle the convert request
1471  *  made by a requesting application.
1472  *
1473  *
1474  *  Comments:
1475  *  --------
1476  *  This function is set-up as a callback on a drawing area kept on each
1477  *  screen.  This is done in WmInitWs.c
1478  *
1479  *************************************<->***********************************/
1480
1481 /*ARGSUSED*/
1482 static void
1483 WMiConvertCB (
1484      Widget    w,
1485      XtPointer clientData,
1486      XtPointer callData)
1487 {
1488   XmConvertCallbackStruct *cnv = (XmConvertCallbackStruct *)callData;
1489   Atom _MOTIF_LOSE_SELECTION =
1490     XInternAtom(DISPLAY, "_MOTIF_LOSE_SELECTION", False);
1491   int scr = XScreenNumberOfScreen(XtScreen(w));
1492   
1493
1494   /* Check to make sure we're dealing with the right selection.
1495    */
1496   if (cnv->selection != wmGD.xa_WM[scr])
1497     {
1498       Warning (((char *)GETMESSAGE(56, 9,
1499                 "Conversion request received for unknown selection")));
1500       return;
1501     }
1502
1503   if (cnv->target == _MOTIF_LOSE_SELECTION)
1504     {
1505       /* Done with the conversion - free any data used. */
1506     }
1507
1508   /* Handle a conversion request with parameter data.
1509    */
1510   else
1511     {
1512       WMiConvert (w, cnv->selection, cnv->target,
1513                   cnv->parm, cnv->parm_length, cnv->parm_format,
1514                   &(cnv->type), &(cnv->value), &(cnv->length), &(cnv->format));
1515     }
1516 }
1517 #endif /* !defined(WSM) || defined(MWM_QATS_PROTOCOL) */