comparison man/external-widget.texi @ 863:42375619fa45

[xemacs-hg @ 2002-06-04 06:03:59 by andyp] merge 21.4 windows changes, minimally tested
author andyp
date Tue, 04 Jun 2002 06:05:53 +0000
parents da44ff90109f
children 03ab78e48ef6
comparison
equal deleted inserted replaced
862:278c743f1578 863:42375619fa45
17 17
18 @menu 18 @menu
19 * Using an External Client Widget:: 19 * Using an External Client Widget::
20 * External Client Widget Resource Settings:: 20 * External Client Widget Resource Settings::
21 * Motif-Specific Info About the External Client Widget:: 21 * Motif-Specific Info About the External Client Widget::
22 * Example Program Using the External Client Widget:: 22 * External Client Widget Internals::
23 @end menu 23 @end menu
24 24
25 25
26 @node Using an External Client Widget, External Client Widget Resource Settings, Top, Top 26 @node Using an External Client Widget, External Client Widget Resource Settings, Top, Top
27 @chapter Using an External Client Widget 27 @chapter Using an External Client Widget
111 Note that the requests that are made between the client and the shell 111 Note that the requests that are made between the client and the shell
112 are primarily for handling query-geometry and geometry-manager requests 112 are primarily for handling query-geometry and geometry-manager requests
113 made by parent or child widgets. 113 made by parent or child widgets.
114 114
115 115
116 @node Motif-Specific Info About the External Client Widget, Example Program Using the External Client Widget, External Client Widget Resource Settings, Top 116 @node Motif-Specific Info About the External Client Widget, External Client Widget Internals, External Client Widget Resource Settings, Top
117 @chapter Motif-Specific Info About the External Client Widget 117 @chapter Motif-Specific Info About the External Client Widget
118 118
119 By default, the external client widget has navigation type 119 By default, the external client widget has navigation type
120 @samp{XmTAB_GROUP}. 120 @samp{XmTAB_GROUP}.
121 121
125 but functions like a normal @key{TAB} in Emacs. This follows the 125 but functions like a normal @key{TAB} in Emacs. This follows the
126 semantics of the Motif text widget. The traversal keystrokes 126 semantics of the Motif text widget. The traversal keystrokes
127 @kbd{Ctrl-@key{TAB}} and @kbd{Shift-@key{TAB}} are silently filtered by 127 @kbd{Ctrl-@key{TAB}} and @kbd{Shift-@key{TAB}} are silently filtered by
128 the external client widget and are not seen by Emacs. 128 the external client widget and are not seen by Emacs.
129 129
130 130 @node External Client Widget Internals, , Motif-Specific Info About the External Client Widget, Top
131 @node Example Program Using the External Client Widget, , Motif-Specific Info About the External Client Widget, Top 131 @chapter External Client Widget Internals
132 @chapter Example Program Using the External Client Widget 132
133 133 The following text is lifted verbatim from Ben Wing's comments in
134 This is a very simple program. It has some issues with exiting. 134 @file{ExternalShell.c}.
135 Be careful to destroy the Emacs frame in the client window before 135
136 exiting the client program. 136 This is a special Shell that is designed to use an externally-
137 137 provided window created by someone else (possibly another process).
138 @example 138 That other window should have an associated widget of class
139 /* 139 ExternalClient. The two widgets communicate with each other using
140 XEmacsInside.c 140 ClientMessage events and properties on the external window.
141 141
142 Copyright (C) 2002 Free Software Foundation 142 Ideally this feature should be independent of Emacs. Unfortunately
143 143 there are lots and lots of specifics that need to be dealt with
144 This program is part of XEmacs. XEmacs is free software. See the 144 for this to work properly, and some of them can't conveniently
145 file COPYING that came with XEmacs for conditions on redistribution. 145 be handled within the widget's methods. Some day the code may
146 146 be rewritten so that the embedded-widget feature can be used by
147 This is an example of the XEmacs external widget facility. 147 any application, with appropriate entry points that are called
148 148 at specific points within the application.
149 It uses libextcli-Xt.a to interface to the X Toolkit Intrinsics. 149
150 150 This feature is similar to the OLE (Object Linking & Embedding)
151 Compile with 151 feature provided by MS Windows.
152 152
153 gcc -I/path/to/XEmacs/source/src -L/path/to/XEmacs/build/src -static \ 153 Communication between this shell and the client widget:
154 -lextcli_Xt -lXt -lX11 -lSM -lICE \ 154
155 -o XEmacsInside XEmacsInside.c 155 Communication is through ClientMessage events with message_type
156 156 EXTW_NOTIFY and format 32. Both the shell and the client widget
157 Run it with the resource "*input: True" and a reasonable geometry spec. 157 communicate with each other by sending the message to the same
158 It pops up a window, and prints a Lisp form on stdout. Eval the form 158 window (the "external window" below), and the data.l[0] value is
159 in an XEmacs configured with --external-widget. 159 used to determine who sent the message.
160 160
161 Written by Stephen J. Turnbull <stephen@@xemacs.org> 161 The data is formatted as follows:
162 162
163 Based on simple_text.c from _The Motif Programming Manual_ by Heller 163 data.l[0] = who sent this message: external_shell_send (0) or
164 and Ferguson, O'Reilly. 164 external_client_send (1)
165 */ 165 data.l[1] = message type (see enum en_extw_notify below)
166 166 data.l[2-4] = data associated with this message
167 #include <stdio.h> 167
168 168 EventHandler() handles messages from the other side.
169 #include <X11/Intrinsic.h> 169
170 #include <X11/StringDefs.h> 170 extw_send_notify_3() sends a message to the other side.
171 #include <X11/Shell.h> 171
172 172 extw_send_geometry_value() is used when an XtWidgetGeometry structure
173 #include "ExternalClient.h" 173 needs to be sent. This is too much data to fit into a
174 174 ClientMessage, so the data is stored in a property and then
175 main (int argc, char *argv[]) 175 extw_send_notify_3() is called.
176 @{ 176
177 Widget toplevel, emacs; 177 extw_get_geometry_value() receives an XtWidgetGeometry structure from a
178 XtAppContext app; 178 property.
179 179
180 XtSetLanguageProc (NULL, NULL, NULL); 180 extw_wait_for_response() is used when a response to a sent message
181 181 is expected. It looks for a matching event within a
182 toplevel = XtVaOpenApplication (&app, "Demo", 182 particular timeout.
183 NULL, 0, &argc, argv, 183
184 NULL, sessionShellWidgetClass, 184 The particular message types are as follows:
185 NULL); 185
186 186 1) extw_notify_init (event_window, event_mask)
187 emacs = XtVaCreateManagedWidget ("externalWidget", externalClientWidgetClass, 187
188 toplevel, 188 This is sent from the shell to the client after the shell realizes
189 NULL); 189 its EmacsFrame widget on the client's "external window". This
190 190 tells the client that it should start passing along events of the
191 XtRealizeWidget (toplevel); 191 types specified in event_mask. event_window specifies the window
192 192 of the EmacsFrame widget, which is a child of the client's
193 printf ("(make-frame '(window-id \"%d\"))\n", XtWindow(emacs)); 193 external window.
194 194
195 XtAppMainLoop (app); 195 extw_notify_init (client_type)
196 @} 196
197 197 When the client receives an extw_notify_init message from the
198 /* This function doesn't belong here but somehow it's not getting resolved 198 shell, it sends back a message of the same sort specifying the type
199 from the library. */ 199 of the toolkit used by the client (Motif, generic Xt, or Xlib).
200 void 200
201 fatal (char *msg) 201 2) extw_notify_end ()
202 @{ 202
203 fprintf (stderr, "%s", msg); 203 This is sent from the shell to the client when the shell's
204 exit (1); 204 EmacsFrame widget is destroyed, and tells the client to stop
205 @} 205 passing events along.
206 @end example 206
207 207 3) extw_notify_qg (result)
208
209 This is sent from the client to the shell when a QueryGeometry
210 request is received on the client. The XtWidgetGeometry structure
211 specified in the QueryGeometry request is passed on in the
212 EXTW_QUERY_GEOMETRY property (of type EXTW_WIDGET_GEOMETRY) on the
213 external window. result is unused.
214
215 In response, the shell passes the QueryGeometry request down the
216 widget tree, and when a response is received, sends a message of
217 type extw_notify_qg back to the client, with result specifying the
218 GeometryResult value. If this value is XtGeometryAlmost, the
219 returned XtWidgetGeometry structure is stored into the same property
220 as above. [BPW is there a possible race condition here?]
221
222 4) extw_notify_gm (result)
223
224 A very similar procedure to that for extw_notify_qg is followed
225 when the shell's RootGeometryManager method is called, indicating
226 that a child widget wishes to change the shell's geometry. The
227 XtWidgetGeometry structure is stored in the EXTW_GEOMETRY_MANAGER
228 property.
229
230 5) extw_notify_focus_in (), extw_notify_focus_out ()
231
232 These are sent from the client to the shell when the client gains
233 or loses the keyboard focus. It is done this way because Xt
234 maintains its own concept of keyboard focus and only the client
235 knows this information.
208 236
209 @summarycontents 237 @summarycontents
210 @contents 238 @contents
211 @bye 239 @bye