428
|
1 /* External client widget.
|
|
2 Copyright (C) 1993, 1994 Sun Microsystems, Inc.
|
|
3
|
|
4 This library is free software; you can redistribute it and/or
|
|
5 modify it under the terms of the GNU Library General Public
|
|
6 License as published by the Free Software Foundation; either
|
|
7 version 2 of the License, or (at your option) any later version.
|
|
8
|
|
9 This library is distributed in the hope that it will be useful,
|
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
12 Library General Public License for more details.
|
|
13
|
|
14 You should have received a copy of the GNU Library General Public
|
|
15 License along with this library; if not, write to
|
|
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
17 Boston, MA 02111-1307, USA. */
|
|
18
|
|
19 /* Synched up with: Not in FSF. */
|
|
20
|
|
21 /* Written by Ben Wing, September 1993. */
|
|
22
|
|
23 #ifdef emacs
|
|
24
|
|
25 #include <config.h>
|
|
26
|
|
27 #ifndef EXTERNAL_WIDGET
|
|
28 ERROR! This ought not be getting compiled if EXTERNAL_WIDGET is undefined
|
|
29 #endif
|
|
30
|
|
31 #endif /* emacs */
|
|
32
|
|
33 #include <stdio.h>
|
|
34 #include <string.h>
|
|
35 #include <stdlib.h>
|
|
36 #ifdef EXTW_USES_MOTIF
|
|
37 # include <Xm/XmP.h>
|
|
38 # include <Xm/PrimitiveP.h>
|
|
39 # include <X11/keysym.h>
|
|
40 #else
|
|
41 # include "xintrinsicp.h"
|
|
42 # include <X11/StringDefs.h>
|
|
43 #endif
|
|
44
|
|
45 #include "ExternalClientP.h"
|
|
46 #include "extw-Xt.h"
|
|
47
|
|
48 #ifdef TOOLTALK
|
442
|
49 #include TT_C_H_FILE
|
428
|
50 #endif
|
|
51
|
|
52 /* This is the client widget, used to communicate with an ExternalShell
|
|
53 widget. */
|
|
54
|
|
55 #define NOTIFY(w, type, l0, l1, l2) \
|
|
56 extw_send_notify_3(XtDisplay((Widget)(w)), XtWindow((Widget)(w)),\
|
|
57 type, l0, l1, l2)
|
|
58
|
|
59 static void externalClientInitialize (Widget req, Widget new, ArgList args,
|
|
60 Cardinal *num_args);
|
|
61 static void externalClientRealize (Widget widget, XtValueMask *mask,
|
|
62 XSetWindowAttributes *attrs);
|
|
63 static void Destroy (Widget w);
|
|
64 static void EventHandler (Widget wid, XtPointer closure, XEvent *event,
|
|
65 Boolean *continue_to_dispatch);
|
|
66 static void MaskableEventHandler (Widget wid, XtPointer closure, XEvent *event,
|
|
67 Boolean *continue_to_dispatch);
|
|
68 static XtGeometryResult QueryGeometry(Widget, XtWidgetGeometry *,
|
|
69 XtWidgetGeometry *);
|
|
70 static void ExternalClientFocusIn (Widget, XEvent *, String *, Cardinal *);
|
|
71 static void ExternalClientFocusOut (Widget, XEvent *, String *, Cardinal *);
|
|
72 static void ExternalClientEnter (Widget, XEvent *, String *, Cardinal *);
|
|
73 static void ExternalClientLeave (Widget, XEvent *, String *, Cardinal *);
|
|
74
|
|
75 static int my_error_handler(Display *display, XErrorEvent *xev);
|
|
76 static int (*error_old_handler)(Display *, XErrorEvent *);
|
|
77
|
|
78 static XtResource resources[] = {
|
|
79 #define offset(field) XtOffset(ExternalClientWidget, externalClient.field)
|
440
|
80 { XtNshellTimeout, XtCShellTimeout,
|
|
81 XtRInt, sizeof (int),
|
|
82 offset(shell_timeout), XtRImmediate,(XtPointer)DEFAULT_WM_TIMEOUT },
|
|
83 { XtNdeadShell, XtCDeadShell,
|
|
84 XtRBoolean, sizeof (Boolean),
|
|
85 offset(dead_shell), XtRImmediate, (XtPointer)False },
|
428
|
86 #ifdef EXTW_USES_MOTIF
|
440
|
87 { XmNnavigationType, XmCNavigationType,
|
|
88 XmRNavigationType, sizeof (XmNavigationType),
|
|
89 XtOffset (ExternalClientWidget, primitive.navigation_type),
|
|
90 XtRImmediate, (XtPointer)XmTAB_GROUP },
|
428
|
91 #endif
|
440
|
92 { XtNemacsProcID, XtCEmacsProcID,
|
|
93 XtRString, sizeof (String),
|
|
94 offset(emacs_procid), XtRImmediate, (XtPointer)NULL },
|
|
95 { XtNshellReadyCallback, XtCCallback,
|
|
96 XtRCallback, sizeof (XtCallbackList),
|
|
97 offset(shell_ready_callback), XtRImmediate, (XtPointer)NULL },
|
|
98 { XtNshellName, XtCShellName,
|
|
99 XtRString, sizeof (String),
|
|
100 offset(shell_name), XtRImmediate, (XtPointer)NULL },
|
|
101 { XtNuseToolTalk, XtCUseToolTalk,
|
|
102 XtRBoolean, sizeof (Boolean),
|
|
103 offset(use_tooltalk), XtRImmediate, (XtPointer)False }
|
428
|
104 };
|
|
105
|
|
106 static XtActionsRec actions[] = {
|
|
107 {"focusIn", ExternalClientFocusIn},
|
|
108 {"focusOut", ExternalClientFocusOut},
|
|
109 {"enter", ExternalClientEnter},
|
|
110 {"leave", ExternalClientLeave},
|
|
111 };
|
|
112
|
|
113 ExternalClientClassRec externalClientClassRec = {
|
|
114 { /*
|
|
115 * core_class fields
|
|
116 */
|
|
117 #ifdef EXTW_USES_MOTIF
|
|
118 /* superclass */ (WidgetClass) &xmPrimitiveClassRec,
|
|
119 #else
|
|
120 /* superclass */ (WidgetClass) &coreClassRec,
|
|
121 #endif
|
|
122 /* class_name */ "ExternalClient",
|
440
|
123 /* size */ sizeof (ExternalClientRec),
|
428
|
124 /* Class Initializer */ NULL,
|
|
125 /* class_part_initialize*/ NULL, /* XtInheritClassPartInitialize, */
|
|
126 /* Class init'ed ? */ FALSE,
|
|
127 /* initialize */ externalClientInitialize,
|
|
128 /* initialize_notify */ NULL,
|
440
|
129 /* realize */ externalClientRealize,
|
428
|
130 /* actions */ actions,
|
|
131 /* num_actions */ XtNumber (actions),
|
|
132 /* resources */ resources,
|
|
133 /* resource_count */ XtNumber (resources),
|
|
134 /* xrm_class */ NULLQUARK,
|
|
135 /* compress_motion */ FALSE,
|
|
136 /* compress_exposure */ TRUE,
|
|
137 /* compress_enterleave*/ FALSE,
|
|
138 /* visible_interest */ TRUE,
|
|
139 /* destroy */ Destroy, /* XtInheritDestroy, */
|
|
140 /* resize */ XtInheritResize,
|
|
141 /* expose */ NULL,
|
|
142 /* set_values */ NULL, /* XtInheritSetValues, */
|
440
|
143 /* set_values_hook */ NULL,
|
|
144 /* set_values_almost */ XtInheritSetValuesAlmost,
|
|
145 /* get_values_hook */ NULL,
|
428
|
146 /* accept_focus */ NULL,
|
|
147 /* intrinsics version */ XtVersion,
|
|
148 /* callback offsets */ NULL,
|
|
149 /* tm_table */ "", /* MUST NOT BE NULL or
|
|
150 XtInheritTranslations in Motif!!!!!
|
|
151 Otherwise keyboard focus translations
|
|
152 will not work. */
|
|
153 /* query_geometry */ QueryGeometry,
|
|
154 /* display_accelerator*/ NULL,
|
|
155 /* extension */ NULL
|
|
156 },
|
|
157 #ifdef EXTW_USES_MOTIF
|
|
158 {
|
|
159 XmInheritBorderHighlight,/* Primitive border_highlight */
|
|
160 XmInheritBorderHighlight,/* Primitive border_unhighlight */
|
|
161 XtInheritTranslations, /* translations */
|
|
162 NULL, /* arm_and_activate */
|
|
163 NULL, /* get resources */
|
|
164 0, /* num get_resources */
|
|
165 NULL, /* extension */
|
|
166 },
|
|
167 #endif
|
|
168 {
|
|
169 0
|
|
170 }
|
|
171 };
|
|
172
|
|
173 WidgetClass externalClientWidgetClass = (WidgetClass) &externalClientClassRec;
|
|
174
|
|
175 static void
|
|
176 externalClientInitialize (Widget req, Widget new, ArgList args,
|
|
177 Cardinal *num_args)
|
|
178 {
|
|
179 ExternalClientWidget ecw = (ExternalClientWidget) new;
|
|
180 static int error_handler_added = 0;
|
|
181
|
|
182 extw_initialize_atoms (XtDisplay (new));
|
|
183 extw_which_side = extw_client_send;
|
|
184
|
|
185 #ifdef EXTW_USES_MOTIF
|
|
186
|
|
187 /* yes I know this is horrible. However, the XmPrimitive class adds
|
|
188 the Tab translation in its initialization routine, so we have to
|
|
189 override it here. This is all the fault of Xt, which doesn't
|
|
190 provide a proper inheritance mechanism for translations.
|
|
191
|
|
192 -- BPW
|
|
193
|
|
194 */
|
440
|
195
|
428
|
196 XtOverrideTranslations (new,
|
|
197 XtParseTranslationTable ("None<Key>Tab:\n"
|
|
198 "<FocusIn>:focusIn()\n"
|
|
199 "<FocusOut>:focusOut()\n"
|
|
200 "<Enter>:enter()\n"
|
|
201 "<Leave>:leave()\n"));
|
|
202
|
|
203 #endif
|
440
|
204
|
428
|
205 XtAddEventHandler (new, 0, TRUE, EventHandler, (XtPointer) NULL);
|
|
206
|
|
207 ecw->externalClient.shell_ready = False;
|
|
208 ecw->externalClient.has_focus = False;
|
|
209
|
|
210 if (!error_handler_added)
|
|
211 {
|
|
212 error_handler_added = 1;
|
|
213 error_old_handler = XSetErrorHandler (my_error_handler);
|
|
214 }
|
|
215 }
|
|
216
|
|
217
|
|
218 #ifdef TOOLTALK
|
|
219 static Tt_callback_action
|
|
220 tt_callback(Tt_message m, Tt_pattern p)
|
|
221 {
|
|
222 ExternalClientWidget ecw = (ExternalClientWidget)tt_message_user (m, 0);
|
440
|
223
|
428
|
224 switch (tt_message_state(m))
|
|
225 {
|
|
226 case TT_FAILED:
|
|
227 /* handle errors here */
|
|
228 break;
|
|
229 case TT_HANDLED:
|
|
230 ecw->externalClient.shell_name = tt_message_arg_val (m, 2);
|
|
231 XtCallCallbackList ((Widget) ecw,
|
|
232 ecw->externalClient.shell_ready_callback, NULL);
|
|
233 break;
|
|
234 }
|
440
|
235
|
428
|
236 tt_message_destroy (m);
|
|
237 return TT_CALLBACK_PROCESSED;
|
|
238 }
|
|
239
|
|
240 static void
|
|
241 send_tooltalk_handshake (ExternalClientWidget ecw, Window win, char *name)
|
|
242 {
|
|
243 Tt_message m = tt_message_create ();
|
|
244
|
|
245 tt_message_op_set (m, "emacs-make-client-screen");
|
|
246 tt_message_scope_set (m, TT_SESSION);
|
|
247 tt_message_class_set (m, TT_REQUEST);
|
|
248 tt_message_arg_add (m, TT_IN, "string", name);
|
|
249 tt_message_iarg_add (m, TT_IN, "int", win);
|
440
|
250 tt_message_arg_add (m, TT_OUT, "string", NULL);
|
428
|
251 tt_message_user_set (m, 0, (void *)ecw);
|
|
252 tt_message_callback_add (m, tt_callback);
|
|
253 if (ecw->externalClient.emacs_procid)
|
|
254 {
|
|
255 tt_message_address_set (m, TT_HANDLER);
|
|
256 tt_message_handler_set (m, ecw->externalClient.emacs_procid);
|
|
257 }
|
|
258 else
|
|
259 tt_message_address_set (m, TT_PROCEDURE);
|
|
260 tt_message_send (m);
|
|
261 }
|
|
262
|
|
263 #endif
|
|
264
|
|
265
|
|
266 static void
|
|
267 externalClientRealize (Widget w, XtValueMask *vm, XSetWindowAttributes *attrs)
|
|
268 {
|
1094
|
269 #ifdef TOOLTALK
|
428
|
270 ExternalClientWidget ecw = (ExternalClientWidget)w;
|
1094
|
271 #endif
|
440
|
272
|
|
273 #ifdef EXTW_USES_MOTIF
|
428
|
274 (*xmPrimitiveWidgetClass->core_class.realize) (w, vm, attrs);
|
|
275 #else
|
|
276 (*coreWidgetClass->core_class.realize) (w, vm, attrs);
|
|
277 #endif
|
|
278
|
|
279 #ifdef TOOLTALK
|
|
280 /* Make sure that the server actually knows about this window id before
|
|
281 * telling Emacs about it.
|
|
282 */
|
|
283 if (ecw->externalClient.use_tooltalk)
|
|
284 {
|
|
285 XSync (XtDisplay (w), False);
|
|
286 send_tooltalk_handshake (ecw, XtWindow (w), XtName (w));
|
|
287 }
|
440
|
288 #endif
|
428
|
289 }
|
|
290
|
|
291
|
|
292 /***********************************************************************/
|
|
293
|
|
294 /* window-to-widget list. */
|
|
295
|
|
296 struct ww_list
|
|
297 {
|
|
298 Window win;
|
|
299 Widget wid;
|
|
300 struct ww_list *next;
|
|
301 };
|
|
302
|
|
303 struct ww_list ww_list[1];
|
|
304
|
|
305 static int
|
|
306 add_ww (Window win, Widget wid)
|
|
307 {
|
|
308 struct ww_list *ww = (struct ww_list *) malloc (sizeof (struct
|
|
309 ww_list));
|
|
310 if (!ww)
|
|
311 return 0;
|
|
312 ww->win = win;
|
|
313 ww->wid = wid;
|
|
314 ww->next = ww_list->next;
|
|
315 ww_list->next = ww;
|
|
316 return 1;
|
|
317 }
|
|
318
|
|
319 static Widget
|
|
320 remove_ww (Window win)
|
|
321 {
|
|
322 struct ww_list *w1, *w2;
|
|
323 Widget wid = 0;
|
440
|
324
|
428
|
325 for (w1=ww_list, w2=w1->next; w2; w1=w2, w2=w2->next)
|
|
326 if (w2->win == win)
|
|
327 {
|
|
328 w1->next = w2->next;
|
|
329 wid = w2->wid;
|
|
330 free (w2);
|
|
331 break;
|
|
332 }
|
|
333 return wid;
|
|
334 }
|
|
335
|
|
336 /***********************************************************************/
|
|
337
|
|
338 /* stolen outright from Intrinsic.c */
|
|
339
|
|
340 static void ComputeWindowAttributes(widget,value_mask,values)
|
|
341 Widget widget;
|
|
342 XtValueMask *value_mask;
|
|
343 XSetWindowAttributes *values;
|
|
344 {
|
|
345 *value_mask = CWEventMask | CWColormap;
|
|
346 (*values).event_mask = XtBuildEventMask(widget);
|
|
347 (*values).colormap = widget->core.colormap;
|
|
348 if (widget->core.background_pixmap != XtUnspecifiedPixmap) {
|
|
349 *value_mask |= CWBackPixmap;
|
|
350 (*values).background_pixmap = widget->core.background_pixmap;
|
|
351 } else {
|
|
352 *value_mask |= CWBackPixel;
|
|
353 (*values).background_pixel = widget->core.background_pixel;
|
|
354 }
|
|
355 if (widget->core.border_pixmap != XtUnspecifiedPixmap) {
|
|
356 *value_mask |= CWBorderPixmap;
|
|
357 (*values).border_pixmap = widget->core.border_pixmap;
|
|
358 } else {
|
|
359 *value_mask |= CWBorderPixel;
|
|
360 (*values).border_pixel = widget->core.border_pixel;
|
|
361 }
|
|
362 if (widget->core.widget_class->core_class.expose == (XtExposeProc) NULL) {
|
|
363 /* Try to avoid redisplay upon resize by making bit_gravity the same
|
|
364 as the default win_gravity */
|
|
365 *value_mask |= CWBitGravity;
|
|
366 (*values).bit_gravity = NorthWestGravity;
|
|
367 }
|
|
368 } /* ComputeWindowAttributes */
|
|
369
|
|
370 static void
|
|
371 end_connection (ExternalClientWidget w)
|
|
372 {
|
|
373 XSetWindowAttributes xswa;
|
|
374 XtValueMask mask;
|
|
375 Widget wid = (Widget) w;
|
440
|
376
|
428
|
377 w->externalClient.shell_ready = False;
|
|
378 XtRemoveEventHandler (wid, w->externalClient.event_mask,
|
|
379 FALSE, MaskableEventHandler, (XtPointer) NULL);
|
|
380 ComputeWindowAttributes (wid, &mask, &xswa);
|
|
381 XChangeWindowAttributes (XtDisplay (wid), XtWindow (wid), mask, &xswa);
|
|
382 XClearArea (XtDisplay (wid), XtWindow (wid), 0, 0, 0, 0, True);
|
|
383 }
|
|
384
|
|
385 static int
|
|
386 my_error_handler (Display *display, XErrorEvent *xev)
|
|
387 {
|
|
388 Widget wid;
|
440
|
389
|
428
|
390 if (xev->error_code != BadWindow)
|
|
391 goto call_old;
|
|
392 wid = remove_ww (xev->resourceid);
|
|
393 if (wid)
|
|
394 {
|
|
395 end_connection ((ExternalClientWidget) wid);
|
|
396 return 0;
|
|
397 }
|
440
|
398
|
428
|
399 call_old:
|
|
400 return error_old_handler (display, xev);
|
|
401 }
|
|
402
|
|
403 static void
|
|
404 MaskableEventHandler (Widget wid, XtPointer closure, XEvent *event,
|
|
405 Boolean *continue_to_dispatch)
|
|
406 /* closure and continue_to_dispatch unused */
|
|
407 {
|
|
408 ExternalClientWidget w = (ExternalClientWidget) wid;
|
440
|
409
|
428
|
410 if (w->externalClient.shell_ready)
|
|
411 {
|
|
412 if (event->type == KeyPress || event->type == KeyRelease ||
|
|
413 event->type == ButtonPress || event->type == ButtonRelease ||
|
|
414 event->type == MotionNotify)
|
|
415 event->xkey.subwindow = 0;
|
|
416 #ifdef EXTW_USES_MOTIF
|
|
417 /* hackkkkkkkkkkkkkk! Suppress CTRL-TAB, SHIFT-TAB, etc. so that
|
|
418 Emacs doesn't attempt to interpret focus-change keystrokes. */
|
|
419 if (event->type == KeyPress &&
|
|
420 XLookupKeysym ((XKeyEvent *) event, 0) == XK_Tab &&
|
|
421 (event->xkey.state & ControlMask ||
|
|
422 event->xkey.state & ShiftMask))
|
|
423 return;
|
|
424 #endif
|
|
425 event->xany.window = w->core.window;
|
|
426 XSendEvent (XtDisplay (wid), w->externalClient.event_window, FALSE, 0,
|
|
427 event);
|
|
428 XSync (XtDisplay (wid), 0); /* make sure that any BadWindow errors
|
|
429 (meaning the server died) get handled
|
|
430 before XSendEvent is called again. */
|
440
|
431
|
428
|
432 }
|
|
433 }
|
|
434
|
|
435 static void
|
|
436 EventHandler (Widget wid, XtPointer closure, XEvent *event,
|
|
437 Boolean *continue_to_dispatch)
|
|
438 /* closure and continue_to_dispatch unused */
|
|
439 {
|
|
440 ExternalClientWidget w = (ExternalClientWidget) wid;
|
440
|
441
|
428
|
442 if (w->core.window != event->xany.window)
|
|
443 {
|
|
444 XtAppErrorMsg (XtWidgetToApplicationContext (wid),
|
|
445 "invalidWindow","eventHandler",XtCXtToolkitError,
|
|
446 "Event with wrong window",
|
|
447 (String *)NULL, (Cardinal *)NULL);
|
|
448 return;
|
|
449 }
|
440
|
450
|
428
|
451 if (event->type == ClientMessage &&
|
|
452 event->xclient.message_type == a_EXTW_NOTIFY &&
|
|
453 event->xclient.data.l[0] == extw_shell_send)
|
|
454 switch (event->xclient.data.l[1])
|
|
455 {
|
440
|
456
|
428
|
457 case extw_notify_qg:
|
|
458 /* shell is alive again. */
|
440
|
459
|
428
|
460 w->externalClient.dead_shell = False;
|
|
461 break;
|
440
|
462
|
428
|
463 case extw_notify_gm:
|
|
464 {
|
|
465 XtWidgetGeometry xwg, xwg_return;
|
|
466 XtGeometryResult result;
|
440
|
467
|
428
|
468 extw_get_geometry_value (XtDisplay (wid), XtWindow (wid),
|
|
469 a_EXTW_GEOMETRY_MANAGER, &xwg);
|
|
470 result = XtMakeGeometryRequest (wid, &xwg, &xwg_return);
|
440
|
471
|
428
|
472 extw_send_geometry_value (XtDisplay (wid), XtWindow (wid),
|
|
473 a_EXTW_GEOMETRY_MANAGER, extw_notify_gm,
|
|
474 result == XtGeometryAlmost ? &xwg_return :
|
|
475 NULL, result);
|
|
476 break;
|
|
477 }
|
440
|
478
|
428
|
479 case extw_notify_init:
|
|
480 w->externalClient.shell_ready = True;
|
|
481 w->externalClient.event_window = event->xclient.data.l[2];
|
|
482 w->externalClient.event_mask = event->xclient.data.l[3];
|
|
483 add_ww (w->externalClient.event_window, (Widget) w);
|
440
|
484
|
428
|
485 XtAddEventHandler (wid, w->externalClient.event_mask,
|
|
486 FALSE, MaskableEventHandler, (XtPointer) NULL);
|
|
487 #ifdef EXTW_USES_MOTIF
|
|
488 NOTIFY (w, extw_notify_init,
|
|
489 EXTW_TYPE_MOTIF,
|
|
490 0, 0);
|
|
491 #else
|
|
492 NOTIFY (w, extw_notify_init,
|
|
493 EXTW_TYPE_XT,
|
|
494 0, 0);
|
|
495 #endif
|
|
496 break;
|
440
|
497
|
428
|
498 case extw_notify_end:
|
|
499 end_connection (w);
|
|
500 remove_ww (w->externalClient.event_window);
|
|
501 break;
|
440
|
502
|
428
|
503 case extw_notify_set_focus:
|
|
504 #ifdef EXTW_USES_MOTIF
|
|
505 XmProcessTraversal (wid, XmTRAVERSE_CURRENT);
|
|
506 #else
|
|
507 XtSetKeyboardFocus (wid, None);
|
|
508 #endif
|
|
509 break;
|
440
|
510
|
428
|
511 }
|
|
512 }
|
|
513
|
|
514 static void Destroy(wid)
|
|
515 Widget wid;
|
|
516 {
|
|
517 ExternalClientWidget w = (ExternalClientWidget)wid;
|
440
|
518
|
428
|
519 NOTIFY(w, extw_notify_end, 0, 0, 0);
|
|
520 }
|
|
521
|
|
522 static XtGeometryResult QueryGeometry(gw, request, reply)
|
|
523 Widget gw;
|
|
524 XtWidgetGeometry *request, *reply;
|
|
525 {
|
|
526 ExternalClientWidget w = (ExternalClientWidget)gw;
|
|
527 XEvent event;
|
|
528 unsigned long request_num;
|
|
529 Display *display = XtDisplay(gw);
|
|
530 XtWidgetGeometry req = *request; /* don't modify caller's structure */
|
440
|
531
|
428
|
532 if (!XtIsRealized((Widget)w) || !w->externalClient.shell_ready)
|
|
533 return XtGeometryYes;
|
440
|
534
|
428
|
535 if (w->externalClient.dead_shell == TRUE)
|
|
536 /* The shell is sick. */
|
|
537 return XtGeometryNo;
|
440
|
538
|
428
|
539 req.sibling = None;
|
|
540 req.request_mode &= ~CWSibling;
|
|
541 request_num = NextRequest(display);
|
|
542 extw_send_geometry_value(XtDisplay(gw), XtWindow(gw), a_EXTW_QUERY_GEOMETRY,
|
|
543 extw_notify_qg, &req, 0);
|
|
544
|
|
545 if (extw_wait_for_response(gw, &event, request_num, extw_notify_qg,
|
|
546 w->externalClient.shell_timeout)) {
|
|
547 XtGeometryResult result = (XtGeometryResult) event.xclient.data.l[0];
|
|
548
|
|
549 if (result == XtGeometryAlmost) {
|
|
550 extw_get_geometry_value(XtDisplay(gw), XtWindow(gw),
|
|
551 a_EXTW_QUERY_GEOMETRY, reply);
|
|
552 }
|
|
553 return result;
|
|
554 } else {
|
|
555 w->externalClient.dead_shell = TRUE; /* timed out; must be broken */
|
|
556 return XtGeometryNo;
|
|
557 }
|
|
558 }
|
|
559
|
|
560 static void ExternalClientFocusIn (Widget w, XEvent *event, String *params,
|
|
561 Cardinal *num_params)
|
|
562 {
|
|
563 ExternalClientWidget ecw = (ExternalClientWidget) w;
|
440
|
564
|
428
|
565 if (event->xfocus.send_event && !ecw->externalClient.has_focus) {
|
|
566 ecw->externalClient.has_focus = True;
|
|
567 NOTIFY(ecw, extw_notify_focus_in, 0, 0, 0);
|
|
568 }
|
|
569 #ifdef EXTW_USES_MOTIF
|
|
570 _XmPrimitiveFocusIn (w, event, params, num_params);
|
|
571 #endif
|
|
572 }
|
|
573
|
|
574 static void ExternalClientFocusOut (Widget w, XEvent *event, String *params,
|
|
575 Cardinal *num_params)
|
|
576 {
|
|
577 ExternalClientWidget ecw = (ExternalClientWidget) w;
|
440
|
578
|
428
|
579 if (event->xfocus.send_event && ecw->externalClient.has_focus) {
|
|
580 ecw->externalClient.has_focus = False;
|
|
581 NOTIFY(ecw, extw_notify_focus_out, 0, 0, 0);
|
|
582 }
|
|
583 #ifdef EXTW_USES_MOTIF
|
|
584 _XmPrimitiveFocusOut(w, event, params, num_params);
|
|
585 #endif
|
|
586 }
|
|
587
|
|
588 static void ExternalClientEnter (Widget w, XEvent *event, String *params,
|
|
589 Cardinal *num_params)
|
|
590 {
|
|
591 ExternalClientWidget ecw = (ExternalClientWidget) w;
|
440
|
592
|
428
|
593 if (
|
|
594 #ifdef EXTW_USES_MOTIF
|
|
595 _XmGetFocusPolicy (w) != XmEXPLICIT &&
|
|
596 #endif
|
|
597 !ecw->externalClient.has_focus &&
|
|
598 event->xcrossing.focus && event->xcrossing.detail != NotifyInferior) {
|
|
599 ecw->externalClient.has_focus = True;
|
|
600 NOTIFY(ecw, extw_notify_focus_in, 0, 0, 0);
|
|
601 }
|
|
602 #ifdef EXTW_USES_MOTIF
|
|
603 _XmPrimitiveEnter (w, event, params, num_params);
|
|
604 #endif
|
|
605 }
|
|
606
|
|
607 static void ExternalClientLeave (Widget w, XEvent *event, String *params,
|
|
608 Cardinal *num_params)
|
|
609 {
|
|
610 ExternalClientWidget ecw = (ExternalClientWidget) w;
|
440
|
611
|
428
|
612 if (
|
|
613 #ifdef EXTW_USES_MOTIF
|
|
614 _XmGetFocusPolicy (w) != XmEXPLICIT &&
|
|
615 #endif
|
|
616 ecw->externalClient.has_focus &&
|
|
617 event->xcrossing.focus && event->xcrossing.detail != NotifyInferior) {
|
|
618 ecw->externalClient.has_focus = False;
|
|
619 NOTIFY(ecw, extw_notify_focus_out, 0, 0, 0);
|
|
620 }
|
|
621 #ifdef EXTW_USES_MOTIF
|
|
622 _XmPrimitiveLeave (w, event, params, num_params);
|
|
623 #endif
|
|
624 }
|