annotate src/ExternalClient.c @ 611:38db05db9cb5

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