annotate src/ExternalShell.c @ 44:8d2a9b52c682 r19-15prefinal

Import from CVS: tag r19-15prefinal
author cvs
date Mon, 13 Aug 2007 08:55:10 +0200
parents 376386a54a3c
children 966663fcf606
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* External shell widget.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1993, 1994 Sun Microsystems, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 This library is free software; you can redistribute it and/or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 modify it under the terms of the GNU Library General Public
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 License as published by the Free Software Foundation; either
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 version 2 of the License, or (at your option) any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 This library is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 Library General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 You should have received a copy of the GNU Library General Public
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 License along with this library; if not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 /* Synched up with: Not in FSF. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 /* Written by Ben Wing, September 1993. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 /* This is a special Shell that is designed to use an externally-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 provided window created by someone else (possibly another process).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 That other window should have an associated widget of class
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ExternalClient. The two widgets communicate with each other using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ClientMessage events and properties on the external window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 Ideally this feature should be independent of Emacs. Unfortunately
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 there are lots and lots of specifics that need to be dealt with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 for this to work properly, and some of them can't conveniently
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 be handled within the widget's methods. Some day the code may
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 be rewritten so that the embedded-widget feature can be used by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 any application, with appropriate entry points that are called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 at specific points within the application.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 This feature is similar to the OLE (Object Linking & Embedding)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 feature provided by MS Windows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 #ifdef emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 #include <config.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 #ifndef EXTERNAL_WIDGET
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ERROR! This ought not be getting compiled if EXTERNAL_WIDGET is undefined
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 #endif /* emacs */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 #include <stdio.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 #include <string.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 #include <X11/StringDefs.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 #include "xintrinsicp.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 #include <X11/Shell.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 #include <X11/ShellP.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 #include <X11/Vendor.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 #include <X11/VendorP.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 #include "ExternalShellP.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 #include "extw-Xt.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 #ifdef emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 extern void emacs_Xt_handle_focus_event (XEvent *event);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 /* Communication between this shell and the client widget:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 Communication is through ClientMessage events with message_type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 EXTW_NOTIFY and format 32. Both the shell and the client widget
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 communicate with each other by sending the message to the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 window (the "external window" below), and the data.l[0] value is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 used to determine who sent the message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 The data is formatted as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 data.l[0] = who sent this message: external_shell_send (0) or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 external_client_send (1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 data.l[1] = message type (see enum en_extw_notify below)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 data.l[2-4] = data associated with this message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 EventHandler() handles messages from the other side.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 extw_send_notify_3() sends a message to the other side.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 extw_send_geometry_value() is used when an XtWidgetGeometry structure
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 needs to be sent. This is too much data to fit into a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ClientMessage, so the data is stored in a property and then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 extw_send_notify_3() is called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 extw_get_geometry_value() receives an XtWidgetGeometry structure from a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 property.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 extw_wait_for_response() is used when a response to a sent message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 is expected. It looks for a matching event within a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 particular timeout.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 The particular message types are as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 1) extw_notify_init (event_window, event_mask)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 This is sent from the shell to the client after the shell realizes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 its EmacsFrame widget on the client's "external window". This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 tells the client that it should start passing along events of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 types specified in event_mask. event_window specifies the window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 of the EmacsFrame widget, which is a child of the client's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 external window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 extw_notify_init (client_type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 When the client receives an extw_notify_init message from the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 shell, it sends back a message of the same sort specifying the type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 of the toolkit used by the client (Motif, generic Xt, or Xlib).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 2) extw_notify_end ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 This is sent from the shell to the client when the shell's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 EmacsFrame widget is destroyed, and tells the client to stop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 passing events along.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 3) extw_notify_qg (result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 This is sent from the client to the shell when a QueryGeometry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 request is received on the client. The XtWidgetGeometry structure
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 specified in the QueryGeometry request is passed on in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 EXTW_QUERY_GEOMETRY property (of type EXTW_WIDGET_GEOMETRY) on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 external window. result is unused.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 In response, the shell passes the QueryGeometry request down the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 widget tree, and when a response is received, sends a message of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 type extw_notify_qg back to the client, with result specifying the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 GeometryResult value. If this value is XtGeometryAlmost, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 returned XtWidgetGeometry structure is stored into the same property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 as above. [BPW is there a possible race condition here?]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 4) extw_notify_gm (result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 A very similar procedure to that for extw_notify_qg is followed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 when the shell's RootGeometryManager method is called, indicating
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 that a child widget wishes to change the shell's geometry. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 XtWidgetGeometry structure is stored in the EXTW_GEOMETRY_MANAGER
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 property.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 5) extw_notify_focus_in (), extw_notify_focus_out ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 These are sent from the client to the shell when the client gains
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 or loses the keyboard focus. It is done this way because Xt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 maintains its own concept of keyboard focus and only the client
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 knows this information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 #define NOTIFY(w, type, l0, l1, l2) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 extw_send_notify_3(XtDisplay((Widget)(w)),\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (w)->externalShell.external_window, type, l0, l1, l2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 static void ExternalShellInitialize (Widget req, Widget new, ArgList args,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 Cardinal *num_args);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 static void ExternalShellRealize (Widget wid, Mask *vmask, XSetWindowAttributes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 *attr);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 static void ExternalShellDestroy (Widget w);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 static void ChangeManaged (Widget wid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 static XtGeometryResult ExternalShellRootGeometryManager (Widget gw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 XtWidgetGeometry *request, XtWidgetGeometry *reply);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 static void EventHandler (Widget wid, XtPointer closure, XEvent *event,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 Boolean *continue_to_dispatch);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 #ifndef DEFAULT_WM_TIMEOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 # define DEFAULT_WM_TIMEOUT 5000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 void ExternalShellUnrealize (Widget w);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 static XtResource resources[] = {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 #define offset(field) XtOffset(ExternalShellWidget, externalShell.field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 { XtNwindow, XtCWindow, XtRWindow, sizeof (Window),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 offset (external_window), XtRImmediate, (XtPointer)0},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 { XtNclientTimeout, XtCClientTimeout, XtRInt, sizeof(int),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 offset(client_timeout), XtRImmediate,(XtPointer)DEFAULT_WM_TIMEOUT},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 { XtNdeadClient, XtCDeadClient, XtRBoolean, sizeof(Boolean),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 offset(dead_client), XtRImmediate, (XtPointer)False},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 static CompositeClassExtensionRec compositeClassExtRec = {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 NULL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 NULLQUARK,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 XtCompositeExtensionVersion,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 sizeof(CompositeClassExtensionRec),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 TRUE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 static ShellClassExtensionRec shellClassExtRec = {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 NULL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 NULLQUARK,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 XtShellExtensionVersion,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 sizeof(ShellClassExtensionRec),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ExternalShellRootGeometryManager
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 ExternalShellClassRec externalShellClassRec = {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 { /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 * core_class fields
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 /* superclass */ (WidgetClass) &shellClassRec,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 /* class_name */ "ExternalShell",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 /* size */ sizeof(ExternalShellRec),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 /* Class Initializer */ NULL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 /* class_part_initialize*/ NULL, /* XtInheritClassPartInitialize, */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 /* Class init'ed ? */ FALSE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 /* initialize */ ExternalShellInitialize,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 /* initialize_notify */ NULL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 /* realize */ ExternalShellRealize,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 /* actions */ NULL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 /* num_actions */ 0,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 /* resources */ resources,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 /* resource_count */ XtNumber (resources),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 /* xrm_class */ NULLQUARK,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 /* compress_motion */ FALSE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 /* compress_exposure */ TRUE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 /* compress_enterleave*/ FALSE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 /* visible_interest */ TRUE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 /* destroy */ ExternalShellDestroy, /* XtInheritDestroy, */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 /* resize */ XtInheritResize,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 /* expose */ NULL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 /* set_values */ NULL, /* XtInheritSetValues, */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 /* set_values_hook */ NULL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 /* set_values_almost */ XtInheritSetValuesAlmost,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 /* get_values_hook */ NULL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 /* accept_focus */ NULL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 /* intrinsics version */ XtVersion,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 /* callback offsets */ NULL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 /* tm_table */ NULL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 /* query_geometry */ NULL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 /* display_accelerator*/ NULL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 /* extension */ NULL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 },{ /* Composite */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 /* geometry_manager */ XtInheritGeometryManager,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 /* change_managed */ ChangeManaged, /* XtInheritChangeManaged */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 /* insert_child */ XtInheritInsertChild,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 /* delete_child */ XtInheritDeleteChild,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 /* extension */ (XtPointer)&compositeClassExtRec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 },{ /* Shell */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 /* extension */ (XtPointer)&shellClassExtRec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 },{ /* ExternalShell */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 WidgetClass externalShellWidgetClass = (WidgetClass) &externalShellClassRec;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 ExternalShellInitialize (Widget req, Widget new, ArgList args,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 Cardinal *num_args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 XtAddEventHandler(new, 0,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 TRUE, EventHandler, (XtPointer) NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 extw_initialize_atoms(XtDisplay(req));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 extw_which_side = extw_shell_send;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 static Widget
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 find_managed_child (CompositeWidget w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 Widget *childP = w->composite.children;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 for (i = w->composite.num_children; i; i--, childP++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 if (XtIsWidget(*childP) && XtIsManaged(*childP))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 return *childP;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 return NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 #ifndef XtCXtToolkitError
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 # define XtCXtToolkitError "XtToolkitError"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 static void EventHandler(wid, closure, event, continue_to_dispatch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 Widget wid;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 XtPointer closure; /* unused */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 XEvent *event;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 Boolean *continue_to_dispatch; /* unused */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 ExternalShellWidget w = (ExternalShellWidget) wid;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 if(w->core.window != event->xany.window) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 XtAppErrorMsg(XtWidgetToApplicationContext(wid),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 "invalidWindow","eventHandler",XtCXtToolkitError,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 "Event with wrong window",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (String *)NULL, (Cardinal *)NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 if (event->type == ClientMessage &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 event->xclient.data.l[0] == extw_client_send &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 event->xclient.message_type == a_EXTW_NOTIFY)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 switch (event->xclient.data.l[1]) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 case extw_notify_gm:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 /* client is alive again. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 w->externalShell.dead_client = False;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 case extw_notify_qg: {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 XtWidgetGeometry xwg, xwg_return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 XtGeometryResult result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 Widget child = find_managed_child((CompositeWidget) w);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 if (child) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 extw_get_geometry_value(XtDisplay(wid), XtWindow(wid),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 a_EXTW_QUERY_GEOMETRY, &xwg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 result = XtQueryGeometry(child, &xwg, &xwg_return);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 } else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 result = XtGeometryYes;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 extw_send_geometry_value(XtDisplay(wid), XtWindow(wid),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 a_EXTW_QUERY_GEOMETRY, extw_notify_qg,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 result == XtGeometryAlmost ? &xwg_return :
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 NULL, result);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 case extw_notify_focus_in: {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 XFocusChangeEvent evnt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 evnt.type = FocusIn;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 evnt.serial = LastKnownRequestProcessed (XtDisplay (wid));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 evnt.send_event = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 evnt.display = XtDisplay (wid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 evnt.window = XtWindow (wid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 evnt.mode = NotifyNormal;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 evnt.detail = NotifyAncestor;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 #ifdef emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 emacs_Xt_handle_focus_event ((XEvent *) &evnt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 XtDispatchEvent ((XEvent *) &evnt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 case extw_notify_focus_out: {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 XFocusChangeEvent evnt;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 evnt.type = FocusOut;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 evnt.serial = LastKnownRequestProcessed (XtDisplay (wid));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 evnt.send_event = True;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 evnt.display = XtDisplay (wid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 evnt.window = XtWindow (wid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 evnt.mode = NotifyNormal;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 evnt.detail = NotifyAncestor;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 #ifdef emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 emacs_Xt_handle_focus_event ((XEvent *) &evnt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 XtDispatchEvent ((XEvent *) &evnt);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 case extw_notify_end:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 /* frame should be destroyed. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 /* Lifted almost entirely from GetGeometry() in Shell.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 GetGeometry (Widget W, Widget child)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 ExternalShellWidget w = (ExternalShellWidget)W;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 int x, y, win_gravity = -1, flag;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 XSizeHints hints;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 Window win = w->externalShell.external_window;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 Window dummy_root;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 unsigned int dummy_bd_width, dummy_depth, width, height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 /* determine the existing size of the window. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 XGetGeometry(XtDisplay(W), win, &dummy_root, &x, &y, &width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 &height, &dummy_bd_width, &dummy_depth);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 w->core.width = width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 w->core.height = height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 if(w->shell.geometry != NULL) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 char def_geom[64];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 int width, height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 x = w->core.x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 y = w->core.y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 width = w->core.width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 height = w->core.height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 hints.flags = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 sprintf( def_geom, "%dx%d+%d+%d", width, height, x, y );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 flag = XWMGeometry( XtDisplay(W),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 XScreenNumberOfScreen(XtScreen(W)),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 w->shell.geometry, def_geom,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (unsigned int)w->core.border_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 &hints, &x, &y, &width, &height,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 &win_gravity
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 if (flag) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 if (flag & XValue) w->core.x = (Position)x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 if (flag & YValue) w->core.y = (Position)y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 if (flag & WidthValue) w->core.width = (Dimension)width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 if (flag & HeightValue) w->core.height = (Dimension)height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 else {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 String params[2];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 Cardinal num_params = 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 params[0] = XtName(W);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 params[1] = w->shell.geometry;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 XtAppWarningMsg(XtWidgetToApplicationContext(W),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 "badGeometry", "shellRealize", XtCXtToolkitError,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 "Shell widget \"%s\" has an invalid geometry specification: \"%s\"",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 params, &num_params);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 flag = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 w->shell.client_specified |= _XtShellGeometryParsed;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 /* Lifted almost entirely from Realize() in Shell.c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 static void ExternalShellRealize (Widget wid, Mask *vmask,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 XSetWindowAttributes *attr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 ExternalShellWidget w = (ExternalShellWidget) wid;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 Mask mask = *vmask;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 Window win = w->externalShell.external_window;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 if (!win) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 Cardinal count = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 XtErrorMsg("invalidWindow","shellRealize", XtCXtToolkitError,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 "No external window specified for ExternalShell widget %s",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 &wid->core.name, &count);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 if (! (w->shell.client_specified & _XtShellGeometryParsed)) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 /* we'll get here only if there was no child the first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 time we were realized. If the shell was Unrealized
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 and then re-Realized, we probably don't want to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 re-evaluate the defaults anyway.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 GetGeometry(wid, (Widget)NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 else if (w->core.background_pixmap == XtUnspecifiedPixmap) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 /* I attempt to inherit my child's background to avoid screen flash
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 * if there is latency between when I get resized and when my child
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 * is resized. Background=None is not satisfactory, as I want the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 * user to get immediate feedback on the new dimensions (most
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 * particularly in the case of a non-reparenting wm). It is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 * especially important to have the server clear any old cruft
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 * from the display when I am resized larger.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 Widget *childP = w->composite.children;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 for (i = w->composite.num_children; i; i--, childP++) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 if (XtIsWidget(*childP) && XtIsManaged(*childP)) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 if ((*childP)->core.background_pixmap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 != XtUnspecifiedPixmap) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 mask &= ~(CWBackPixel);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 mask |= CWBackPixmap;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 attr->background_pixmap =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 w->core.background_pixmap =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (*childP)->core.background_pixmap;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 } else {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 attr->background_pixel =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 w->core.background_pixel =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (*childP)->core.background_pixel;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 if(w->shell.save_under) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 mask |= CWSaveUnder;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 attr->save_under = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 if(w->shell.override_redirect) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 mask |= CWOverrideRedirect;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 attr->override_redirect = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 if (wid->core.width == 0 || wid->core.height == 0) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 Cardinal count = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 XtErrorMsg("invalidDimension", "shellRealize", XtCXtToolkitError,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 "Shell widget %s has zero width and/or height",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 &wid->core.name, &count);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 wid->core.window = win;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 XChangeWindowAttributes(XtDisplay(wid), wid->core.window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 mask, attr);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 static void ExternalShellDestroy(wid)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 Widget wid;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 ExternalShellWidget w = (ExternalShellWidget)wid;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 if (XtIsRealized(wid))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 ExternalShellUnrealize(wid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 NOTIFY(w, extw_notify_end, 0, 0, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 /* Invoke matching routine from superclass, but first override its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 geometry opinions with our own routine */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 static void ChangeManaged(wid)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 Widget wid;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 if (!XtIsRealized (wid))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 GetGeometry(wid, (Widget)NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (*((ShellClassRec*)externalShellClassRec.core_class.superclass)->
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 composite_class.change_managed)(wid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 /* Based on RootGeometryManager() in Shell.c */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 static XtGeometryResult ExternalShellRootGeometryManager(gw, request, reply)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 Widget gw;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 XtWidgetGeometry *request, *reply;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 ExternalShellWidget w = (ExternalShellWidget)gw;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 unsigned int mask = request->request_mode;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 XEvent event;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 int oldx, oldy, oldwidth, oldheight, oldborder_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 unsigned long request_num;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 XtWidgetGeometry req = *request; /* don't modify caller's structure */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 oldx = w->core.x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 oldy = w->core.y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 oldwidth = w->core.width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 oldheight = w->core.height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 oldborder_width = w->core.border_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 #define PutBackGeometry() \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 { w->core.x = oldx; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 w->core.y = oldy; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 w->core.width = oldwidth; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 w->core.height = oldheight; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 w->core.border_width = oldborder_width; }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 if (mask & CWX) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 if (w->core.x == request->x) mask &= ~CWX;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 w->core.x = request->x;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 if (mask & CWY) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 if (w->core.y == request->y) mask &= ~CWY;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 else w->core.y = request->y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 if (mask & CWBorderWidth) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 if (w->core.border_width == request->border_width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 mask &= ~CWBorderWidth;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 else w->core.border_width = request->border_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 if (mask & CWWidth) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 if (w->core.width == request->width) mask &= ~CWWidth;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 else w->core.width = request->width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 if (mask & CWHeight) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 if (w->core.height == request->height) mask &= ~CWHeight;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 else w->core.height = request->height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 if (!XtIsRealized((Widget)w)) return XtGeometryYes;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 req.sibling = None;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 req.request_mode = mask & ~CWSibling;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 request_num = NextRequest(XtDisplay(w));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 extw_send_geometry_value(XtDisplay(w), XtWindow(w),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 a_EXTW_GEOMETRY_MANAGER,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 extw_notify_gm, &req, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 if (w->externalShell.dead_client == TRUE) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 /* The client is sick. Refuse the request.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 * If the client recovers and decides to honor the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 * request, it will be handled by Shell's EventHandler().
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 PutBackGeometry();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 return XtGeometryNo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 if (extw_wait_for_response(gw, &event, request_num, extw_notify_gm,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 w->externalShell.client_timeout)) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 XtGeometryResult result = (XtGeometryResult) event.xclient.data.l[2];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 if (result != XtGeometryYes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 PutBackGeometry();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 if (result == XtGeometryAlmost) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 extw_get_geometry_value(XtDisplay(w), XtWindow(w),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 a_EXTW_GEOMETRY_MANAGER, reply);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 } else {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 w->externalShell.dead_client = TRUE; /* timed out; must be broken */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 PutBackGeometry();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 return XtGeometryNo;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 #undef PutBackGeometry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 hack_event_masks_1 (Display *display, Window w, int this_window_propagate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 Window root, parent, *children;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 unsigned int nchildren;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 if (!XQueryTree (display, w, &root, &parent, &children, &nchildren))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 for (i=0; i<nchildren; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 hack_event_masks_1 (display, children[i], 1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 if (children)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 XFree (children);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 XWindowAttributes xwa;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 XSetWindowAttributes xswa;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 if (XGetWindowAttributes (display, w, &xwa)) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 xswa.event_mask = xwa.your_event_mask & ~KeyPressMask;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 if (this_window_propagate)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 xswa.do_not_propagate_mask = xwa.do_not_propagate_mask & ~KeyPressMask;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 XChangeWindowAttributes (display, w, CWEventMask, &xswa);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 /* fix all event masks on all subwindows of the specified window so that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 all key presses in any subwindow filter up to the specified window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 We have to do this cruftiness with external widgets so that we don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 step on Motif's concept of keyboard focus. (Due to the nature of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 Xt and Motif, X's idea of who gets the keyboard events may not jive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 with Xt's idea of same, and Xt redirects the events to the proper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 window. This occurs on the client side and we have no knowledge
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 of it, so we have to rely on a SendEvent from the client side to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 receive our keyboard events.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 hack_event_masks (Display *display, Window w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 hack_event_masks_1 (display, w, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 /* external entry points */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 Bool
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 ExternalShellReady (Widget w, Window win, long event_mask)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 ExternalShellWidget ew = (ExternalShellWidget) w;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 XEvent event;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 unsigned long request_num;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 request_num = NextRequest(XtDisplay(w));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 NOTIFY(ew, extw_notify_init, (long) win, event_mask, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 if (extw_wait_for_response(w, &event, request_num, extw_notify_init,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 ew->externalShell.client_timeout))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 /* Xt/Xm extw's have more elaborate focus needs than mere
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 Xlib ones.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 Rather independently, they *don't* need the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 ConfigureNotify event, having fixed up the window size in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 ChangeManaged, above, but Xlib extw's do need this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 ew->externalShell.client_type = event.xclient.data.l[2];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 if (ew->externalShell.client_type != EXTW_TYPE_XLIB)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 hack_event_masks (XtDisplay (w), XtWindow (w));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 XConfigureEvent ev;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 XWindowAttributes xwa;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 ev.type = ConfigureNotify;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 ev.display = XtDisplay (w);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 ev.event = ev.window = XtWindow (w);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 XGetWindowAttributes (ev.display, ev.window, &xwa);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 ev.x = xwa.x; ev.y = xwa.y;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 ev.width = xwa.width; ev.height = xwa.height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 ev.border_width = xwa.border_width;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 ev.above = None;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 ev.override_redirect = xwa.override_redirect;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 XtDispatchEvent ((XEvent *) &ev);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 return TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 return FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 ExternalShellSetFocus (Widget wid)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 ExternalShellWidget w = (ExternalShellWidget) wid;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 NOTIFY(w, extw_notify_set_focus, 0, 0, 0);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 extern void _XtUnregisterWindow (Window, Widget);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 ExternalShellUnrealize (Widget w)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 #if (XT_REVISION > 5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 XtUnregisterDrawable (XtDisplay (w), w->core.window);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 extern void _XtUnregisterWindow (Window, Widget);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 _XtUnregisterWindow (w->core.window, w);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 w->core.window = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 }