annotate src/ExternalShell.c @ 2196:4c063404364a

[xemacs-hg @ 2004-07-31 21:50:24 by viteno] Update xemacs_extra_name.
author viteno
date Sat, 31 Jul 2004 21:50:24 +0000
parents 8de911beca70
children 04bc9d2f42c7
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);
2108
8de911beca70 [xemacs-hg @ 2004-06-02 09:16:14 by didierv]
didierv
parents: 877
diff changeset
161 static XtGeometryResult
8de911beca70 [xemacs-hg @ 2004-06-02 09:16:14 by didierv]
didierv
parents: 877
diff changeset
162 ExternalShellRootGeometryManager (Widget gw, XtWidgetGeometry *request,
8de911beca70 [xemacs-hg @ 2004-06-02 09:16:14 by didierv]
didierv
parents: 877
diff changeset
163 XtWidgetGeometry *reply);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 static void EventHandler (Widget wid, XtPointer closure, XEvent *event,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 Boolean *continue_to_dispatch);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 #ifndef DEFAULT_WM_TIMEOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 # define DEFAULT_WM_TIMEOUT 5000
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 void ExternalShellUnrealize (Widget w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 static XtResource resources[] = {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 #define offset(field) XtOffset(ExternalShellWidget, externalShell.field)
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
175 { XtNwindow, XtCWindow,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
176 XtRWindow, sizeof (Window),
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
177 offset (external_window), XtRImmediate, (XtPointer)0 },
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
178 { XtNclientTimeout, XtCClientTimeout,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
179 XtRInt, sizeof (int),
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
180 offset(client_timeout), XtRImmediate,(XtPointer)DEFAULT_WM_TIMEOUT },
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
181 { XtNdeadClient, XtCDeadClient,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
182 XtRBoolean, sizeof (Boolean),
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
183 offset(dead_client), XtRImmediate, (XtPointer)False },
428
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 static CompositeClassExtensionRec compositeClassExtRec = {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 NULLQUARK,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 XtCompositeExtensionVersion,
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
190 sizeof (CompositeClassExtensionRec),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 TRUE,
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 static ShellClassExtensionRec shellClassExtRec = {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 NULLQUARK,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 XtShellExtensionVersion,
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
198 sizeof (ShellClassExtensionRec),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 ExternalShellRootGeometryManager
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 ExternalShellClassRec externalShellClassRec = {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 { /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 * core_class fields
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 /* superclass */ (WidgetClass) &shellClassRec,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 /* class_name */ "ExternalShell",
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
208 /* size */ sizeof (ExternalShellRec),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 /* Class Initializer */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 /* class_part_initialize*/ NULL, /* XtInheritClassPartInitialize, */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 /* Class init'ed ? */ FALSE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 /* initialize */ ExternalShellInitialize,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 /* initialize_notify */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 /* realize */ ExternalShellRealize,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 /* actions */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 /* num_actions */ 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 /* resources */ resources,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 /* resource_count */ XtNumber (resources),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 /* xrm_class */ NULLQUARK,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 /* compress_motion */ FALSE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 /* compress_exposure */ TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 /* compress_enterleave*/ FALSE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 /* visible_interest */ TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 /* destroy */ ExternalShellDestroy, /* XtInheritDestroy, */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 /* resize */ XtInheritResize,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 /* expose */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 /* set_values */ NULL, /* XtInheritSetValues, */
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
228 /* set_values_hook */ NULL,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
229 /* set_values_almost */ XtInheritSetValuesAlmost,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
230 /* get_values_hook */ NULL,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 /* accept_focus */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 /* intrinsics version */ XtVersion,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 /* callback offsets */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 /* tm_table */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 /* query_geometry */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 /* display_accelerator*/ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 /* extension */ NULL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 },{ /* Composite */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 /* geometry_manager */ XtInheritGeometryManager,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 /* change_managed */ ChangeManaged, /* XtInheritChangeManaged */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 /* insert_child */ XtInheritInsertChild,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 /* delete_child */ XtInheritDeleteChild,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 /* extension */ (XtPointer)&compositeClassExtRec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 },{ /* Shell */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 /* extension */ (XtPointer)&shellClassExtRec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 },{ /* ExternalShell */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 0
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 WidgetClass externalShellWidgetClass = (WidgetClass) &externalShellClassRec;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 ExternalShellInitialize (Widget req, Widget new, ArgList args,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 Cardinal *num_args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 XtAddEventHandler(new, 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 TRUE, EventHandler, (XtPointer) NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 extw_initialize_atoms(XtDisplay(req));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 extw_which_side = extw_shell_send;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 static Widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 find_managed_child (CompositeWidget w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 Widget *childP = w->composite.children;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 for (i = w->composite.num_children; i; i--, childP++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 if (XtIsWidget(*childP) && XtIsManaged(*childP))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 return *childP;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 return NULL;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 #ifndef XtCXtToolkitError
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 # define XtCXtToolkitError "XtToolkitError"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278
2108
8de911beca70 [xemacs-hg @ 2004-06-02 09:16:14 by didierv]
didierv
parents: 877
diff changeset
279 static void EventHandler (Widget wid, XtPointer closure /* unused */,
8de911beca70 [xemacs-hg @ 2004-06-02 09:16:14 by didierv]
didierv
parents: 877
diff changeset
280 XEvent *event,
8de911beca70 [xemacs-hg @ 2004-06-02 09:16:14 by didierv]
didierv
parents: 877
diff changeset
281 Boolean *continue_to_dispatch /* unused */)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 ExternalShellWidget w = (ExternalShellWidget) wid;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 if(w->core.window != event->xany.window) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 XtAppErrorMsg(XtWidgetToApplicationContext(wid),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 "invalidWindow","eventHandler",XtCXtToolkitError,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 "Event with wrong window",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 (String *)NULL, (Cardinal *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 if (event->type == ClientMessage &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 event->xclient.data.l[0] == extw_client_send &&
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 event->xclient.message_type == a_EXTW_NOTIFY)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 switch (event->xclient.data.l[1]) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 case extw_notify_gm:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 /* client is alive again. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 w->externalShell.dead_client = False;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 case extw_notify_qg: {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 XtWidgetGeometry xwg, xwg_return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 XtGeometryResult result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 Widget child = find_managed_child((CompositeWidget) w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 if (child) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 extw_get_geometry_value(XtDisplay(wid), XtWindow(wid),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 a_EXTW_QUERY_GEOMETRY, &xwg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 result = XtQueryGeometry(child, &xwg, &xwg_return);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 } else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 result = XtGeometryYes;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 extw_send_geometry_value(XtDisplay(wid), XtWindow(wid),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 a_EXTW_QUERY_GEOMETRY, extw_notify_qg,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 result == XtGeometryAlmost ? &xwg_return :
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 NULL, result);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 case extw_notify_focus_in: {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 XFocusChangeEvent evnt;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
324
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 evnt.type = FocusIn;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 evnt.serial = LastKnownRequestProcessed (XtDisplay (wid));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 evnt.send_event = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 evnt.display = XtDisplay (wid);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 evnt.window = XtWindow (wid);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 evnt.mode = NotifyNormal;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 evnt.detail = NotifyAncestor;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 #ifdef emacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 emacs_Xt_handle_focus_event ((XEvent *) &evnt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 XtDispatchEvent ((XEvent *) &evnt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 }
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
339
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 case extw_notify_focus_out: {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 XFocusChangeEvent evnt;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
342
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 evnt.type = FocusOut;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 evnt.serial = LastKnownRequestProcessed (XtDisplay (wid));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 evnt.send_event = True;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 evnt.display = XtDisplay (wid);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 evnt.window = XtWindow (wid);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 evnt.mode = NotifyNormal;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 evnt.detail = NotifyAncestor;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 #ifdef emacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 emacs_Xt_handle_focus_event ((XEvent *) &evnt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 XtDispatchEvent ((XEvent *) &evnt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 }
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 case extw_notify_end:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 /* frame should be destroyed. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 }
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 /* Lifted almost entirely from GetGeometry() in Shell.c
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 GetGeometry (Widget W, Widget child)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 ExternalShellWidget w = (ExternalShellWidget)W;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 int x, y, win_gravity = -1, flag;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 XSizeHints hints;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 Window win = w->externalShell.external_window;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
373
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 Window dummy_root;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 unsigned int dummy_bd_width, dummy_depth, width, height;
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
377
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 /* determine the existing size of the window. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 XGetGeometry(XtDisplay(W), win, &dummy_root, &x, &y, &width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 &height, &dummy_bd_width, &dummy_depth);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 w->core.width = width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 w->core.height = height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 if(w->shell.geometry != NULL) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 char def_geom[128];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 int width, height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 x = w->core.x;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 y = w->core.y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 width = w->core.width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 height = w->core.height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 hints.flags = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 sprintf( def_geom, "%dx%d+%d+%d", width, height, x, y );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 flag = XWMGeometry( XtDisplay(W),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 XScreenNumberOfScreen(XtScreen(W)),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 w->shell.geometry, def_geom,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 (unsigned int)w->core.border_width,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 &hints, &x, &y, &width, &height,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 &win_gravity
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 if (flag) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 if (flag & XValue) w->core.x = (Position)x;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 if (flag & YValue) w->core.y = (Position)y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 if (flag & WidthValue) w->core.width = (Dimension)width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 if (flag & HeightValue) w->core.height = (Dimension)height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 else {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 String params[2];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 Cardinal num_params = 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 params[0] = XtName(W);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 params[1] = w->shell.geometry;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 XtAppWarningMsg(XtWidgetToApplicationContext(W),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 "badGeometry", "shellRealize", XtCXtToolkitError,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 "Shell widget \"%s\" has an invalid geometry specification: \"%s\"",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 params, &num_params);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 }
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 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 flag = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 w->shell.client_specified |= _XtShellGeometryParsed;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 }
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 /* Lifted almost entirely from Realize() in Shell.c
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 static void ExternalShellRealize (Widget wid, Mask *vmask,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 XSetWindowAttributes *attr)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 ExternalShellWidget w = (ExternalShellWidget) wid;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 Mask mask = *vmask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 Window win = w->externalShell.external_window;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 if (!win) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 Cardinal count = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 XtErrorMsg("invalidWindow","shellRealize", XtCXtToolkitError,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 "No external window specified for ExternalShell widget %s",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 &wid->core.name, &count);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 }
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 if (! (w->shell.client_specified & _XtShellGeometryParsed)) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 /* we'll get here only if there was no child the first
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 time we were realized. If the shell was Unrealized
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 and then re-Realized, we probably don't want to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 re-evaluate the defaults anyway.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 GetGeometry(wid, (Widget)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 else if (w->core.background_pixmap == XtUnspecifiedPixmap) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 /* I attempt to inherit my child's background to avoid screen flash
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 * 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
453 * is resized. Background=None is not satisfactory, as I want the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 * user to get immediate feedback on the new dimensions (most
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 * particularly in the case of a non-reparenting wm). It is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 * especially important to have the server clear any old cruft
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 * from the display when I am resized larger.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 Widget *childP = w->composite.children;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 for (i = w->composite.num_children; i; i--, childP++) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 if (XtIsWidget(*childP) && XtIsManaged(*childP)) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 if ((*childP)->core.background_pixmap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 != XtUnspecifiedPixmap) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 mask &= ~(CWBackPixel);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 mask |= CWBackPixmap;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 attr->background_pixmap =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 w->core.background_pixmap =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 (*childP)->core.background_pixmap;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 } else {
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
471 attr->background_pixel =
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
472 w->core.background_pixel =
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 (*childP)->core.background_pixel;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 }
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 if(w->shell.save_under) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 mask |= CWSaveUnder;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 attr->save_under = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 if(w->shell.override_redirect) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 mask |= CWOverrideRedirect;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 attr->override_redirect = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 if (wid->core.width == 0 || wid->core.height == 0) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 Cardinal count = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 XtErrorMsg("invalidDimension", "shellRealize", XtCXtToolkitError,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 "Shell widget %s has zero width and/or height",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 &wid->core.name, &count);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 wid->core.window = win;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 XChangeWindowAttributes(XtDisplay(wid), wid->core.window,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 mask, attr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497
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
2108
8de911beca70 [xemacs-hg @ 2004-06-02 09:16:14 by didierv]
didierv
parents: 877
diff changeset
500 static void ExternalShellDestroy (Widget wid)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 ExternalShellWidget w = (ExternalShellWidget)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 if (XtIsRealized(wid))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 ExternalShellUnrealize(wid);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 NOTIFY(w, extw_notify_end, 0, 0, 0);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 /* Invoke matching routine from superclass, but first override its
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 geometry opinions with our own routine */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512
2108
8de911beca70 [xemacs-hg @ 2004-06-02 09:16:14 by didierv]
didierv
parents: 877
diff changeset
513 static void ChangeManaged (Widget wid)
428
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 if (!XtIsRealized (wid))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 GetGeometry(wid, (Widget)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 (*((ShellClassRec*)externalShellClassRec.core_class.superclass)->
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 composite_class.change_managed)(wid);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 /* Based on RootGeometryManager() in Shell.c */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522
2108
8de911beca70 [xemacs-hg @ 2004-06-02 09:16:14 by didierv]
didierv
parents: 877
diff changeset
523 static XtGeometryResult
8de911beca70 [xemacs-hg @ 2004-06-02 09:16:14 by didierv]
didierv
parents: 877
diff changeset
524 ExternalShellRootGeometryManager (Widget gw, XtWidgetGeometry *request,
8de911beca70 [xemacs-hg @ 2004-06-02 09:16:14 by didierv]
didierv
parents: 877
diff changeset
525 XtWidgetGeometry *reply)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 ExternalShellWidget w = (ExternalShellWidget)gw;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 unsigned int mask = request->request_mode;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 XEvent event;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 int oldx, oldy, oldwidth, oldheight, oldborder_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 unsigned long request_num;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 XtWidgetGeometry req = *request; /* don't modify caller's structure */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 oldx = w->core.x;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 oldy = w->core.y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 oldwidth = w->core.width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 oldheight = w->core.height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 oldborder_width = w->core.border_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 #define PutBackGeometry() \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 { w->core.x = oldx; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 w->core.y = oldy; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 w->core.width = oldwidth; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 w->core.height = oldheight; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 w->core.border_width = oldborder_width; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 if (mask & CWX) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 if (w->core.x == request->x) mask &= ~CWX;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 w->core.x = request->x;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 if (mask & CWY) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 if (w->core.y == request->y) mask &= ~CWY;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 else w->core.y = request->y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 if (mask & CWBorderWidth) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 if (w->core.border_width == request->border_width)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 mask &= ~CWBorderWidth;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 else w->core.border_width = request->border_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 if (mask & CWWidth) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 if (w->core.width == request->width) mask &= ~CWWidth;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 else w->core.width = request->width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 if (mask & CWHeight) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 if (w->core.height == request->height) mask &= ~CWHeight;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 else w->core.height = request->height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 if (!XtIsRealized((Widget)w)) return XtGeometryYes;
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 req.sibling = None;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 req.request_mode = mask & ~CWSibling;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 request_num = NextRequest(XtDisplay(w));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 extw_send_geometry_value(XtDisplay(w), XtWindow(w),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 a_EXTW_GEOMETRY_MANAGER,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 extw_notify_gm, &req, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 if (w->externalShell.dead_client == TRUE) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 /* The client is sick. Refuse the request.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 * If the client recovers and decides to honor the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 * request, it will be handled by Shell's EventHandler().
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 PutBackGeometry();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 return XtGeometryNo;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 if (extw_wait_for_response(gw, &event, request_num, extw_notify_gm,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 w->externalShell.client_timeout)) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 XtGeometryResult result = (XtGeometryResult) event.xclient.data.l[2];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 if (result != XtGeometryYes)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 PutBackGeometry();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 if (result == XtGeometryAlmost) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 extw_get_geometry_value(XtDisplay(w), XtWindow(w),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 a_EXTW_GEOMETRY_MANAGER, reply);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 } else {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 w->externalShell.dead_client = TRUE; /* timed out; must be broken */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 PutBackGeometry();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 return XtGeometryNo;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 #undef PutBackGeometry
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 hack_event_masks_1 (Display *display, Window w, int this_window_propagate)
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 Window root, parent, *children;
877
e54d47b2d736 [xemacs-hg @ 2002-06-23 09:54:35 by stephent]
stephent
parents: 440
diff changeset
611 unsigned int nchildren, i;
428
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 if (!XQueryTree (display, w, &root, &parent, &children, &nchildren))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 for (i=0; i<nchildren; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 hack_event_masks_1 (display, children[i], 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 if (children)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 XFree (children);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 XWindowAttributes xwa;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 XSetWindowAttributes xswa;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 if (XGetWindowAttributes (display, w, &xwa)) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 xswa.event_mask = xwa.your_event_mask & ~KeyPressMask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 if (this_window_propagate)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 xswa.do_not_propagate_mask = xwa.do_not_propagate_mask & ~KeyPressMask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 XChangeWindowAttributes (display, w, CWEventMask, &xswa);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 /* 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
632 all key presses in any subwindow filter up to the specified window.
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 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
635 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
636 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
637 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
638 window. This occurs on the client side and we have no knowledge
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 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
640 receive our keyboard events.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 hack_event_masks (Display *display, Window w)
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 hack_event_masks_1 (display, w, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 /* external entry points */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 Bool
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 ExternalShellReady (Widget w, Window win, long event_mask)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 ExternalShellWidget ew = (ExternalShellWidget) w;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 XEvent event;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 unsigned long request_num;
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 request_num = NextRequest(XtDisplay(w));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 NOTIFY(ew, extw_notify_init, (long) win, event_mask, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 if (extw_wait_for_response(w, &event, request_num, extw_notify_init,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 ew->externalShell.client_timeout))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 /* Xt/Xm extw's have more elaborate focus needs than mere
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 Xlib ones.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 Rather independently, they *don't* need the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 ConfigureNotify event, having fixed up the window size in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 ChangeManaged, above, but Xlib extw's do need this.
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 ew->externalShell.client_type = event.xclient.data.l[2];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 if (ew->externalShell.client_type != EXTW_TYPE_XLIB)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 hack_event_masks (XtDisplay (w), XtWindow (w));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 else
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 XConfigureEvent ev;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 XWindowAttributes xwa;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 ev.type = ConfigureNotify;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 ev.display = XtDisplay (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 ev.event = ev.window = XtWindow (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 XGetWindowAttributes (ev.display, ev.window, &xwa);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683 ev.x = xwa.x; ev.y = xwa.y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684 ev.width = xwa.width; ev.height = xwa.height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 ev.border_width = xwa.border_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 ev.above = None;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 ev.override_redirect = xwa.override_redirect;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 XtDispatchEvent ((XEvent *) &ev);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 }
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 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 ExternalShellSetFocus (Widget wid)
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 ExternalShellWidget w = (ExternalShellWidget) wid;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 NOTIFY(w, extw_notify_set_focus, 0, 0, 0);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 extern void _XtUnregisterWindow (Window, Widget);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 ExternalShellUnrealize (Widget w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 #if (XT_REVISION > 5)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 XtUnregisterDrawable (XtDisplay (w), w->core.window);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 extern void _XtUnregisterWindow (Window, Widget);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 _XtUnregisterWindow (w->core.window, w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 w->core.window = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 }