annotate src/ExternalShell.c @ 744:8ae895c67ce7

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