annotate src/ExternalShell.c @ 5167:e374ea766cc1

clean up, rearrange allocation statistics code -------------------- ChangeLog entries follow: -------------------- src/ChangeLog addition: 2010-03-21 Ben Wing <ben@xemacs.org> * alloc.c: * alloc.c (assert_proper_sizing): * alloc.c (c_readonly): * alloc.c (malloced_storage_size): * alloc.c (fixed_type_block_overhead): * alloc.c (lisp_object_storage_size): * alloc.c (inc_lrecord_stats): * alloc.c (dec_lrecord_stats): * alloc.c (pluralize_word): * alloc.c (object_memory_usage_stats): * alloc.c (Fobject_memory_usage): * alloc.c (compute_memusage_stats_length): * alloc.c (disksave_object_finalization_1): * alloc.c (Fgarbage_collect): * mc-alloc.c: * mc-alloc.c (mc_alloced_storage_size): * mc-alloc.h: No functionality change here. Collect the allocations-statistics code that was scattered throughout alloc.c into one place. Add remaining section headings so that all sections have headings clearly identifying the start of the section and its purpose. Expose mc_alloced_storage_size() even when not MEMORY_USAGE_STATS; this fixes build problems and is related to the export of lisp_object_storage_size() and malloced_storage_size() when non-MEMORY_USAGE_STATS in the previous change set.
author Ben Wing <ben@xemacs.org>
date Sun, 21 Mar 2010 04:41:49 -0500
parents facf3239ba30
children 2aa9cd456ae7
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>
2299
a640f9c13696 [xemacs-hg @ 2004-09-22 03:04:35 by james]
james
parents: 2286
diff changeset
59 #include "compiler.h"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 #include "ExternalShellP.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 #include "extw-Xt.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 #ifdef emacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 extern void emacs_Xt_handle_focus_event (XEvent *event);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 /* Communication between this shell and the client widget:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 Communication is through ClientMessage events with message_type
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 EXTW_NOTIFY and format 32. Both the shell and the client widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 communicate with each other by sending the message to the same
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 window (the "external window" below), and the data.l[0] value is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 used to determine who sent the message.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 The data is formatted as follows:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 data.l[0] = who sent this message: external_shell_send (0) or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 external_client_send (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 data.l[1] = message type (see enum en_extw_notify below)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 data.l[2-4] = data associated with this message
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 EventHandler() handles messages from the other side.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 extw_send_notify_3() sends a message to the other side.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 extw_send_geometry_value() is used when an XtWidgetGeometry structure
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 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
88 ClientMessage, so the data is stored in a property and then
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 extw_send_notify_3() is called.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 extw_get_geometry_value() receives an XtWidgetGeometry structure from a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 property.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 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
95 is expected. It looks for a matching event within a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 particular timeout.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 The particular message types are as follows:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 1) extw_notify_init (event_window, event_mask)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 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
103 its EmacsFrame widget on the client's "external window". This
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 tells the client that it should start passing along events of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 types specified in event_mask. event_window specifies the window
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 of the EmacsFrame widget, which is a child of the client's
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 external window.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 extw_notify_init (client_type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 When the client receives an extw_notify_init message from the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 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
113 of the toolkit used by the client (Motif, generic Xt, or Xlib).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 2) extw_notify_end ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 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
118 EmacsFrame widget is destroyed, and tells the client to stop
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 passing events along.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 3) extw_notify_qg (result)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 This is sent from the client to the shell when a QueryGeometry
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 request is received on the client. The XtWidgetGeometry structure
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 specified in the QueryGeometry request is passed on in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 EXTW_QUERY_GEOMETRY property (of type EXTW_WIDGET_GEOMETRY) on the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 external window. result is unused.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 In response, the shell passes the QueryGeometry request down the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 widget tree, and when a response is received, sends a message of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 type extw_notify_qg back to the client, with result specifying the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 GeometryResult value. If this value is XtGeometryAlmost, the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 returned XtWidgetGeometry structure is stored into the same property
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 as above. [BPW is there a possible race condition here?]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 4) extw_notify_gm (result)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 A very similar procedure to that for extw_notify_qg is followed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 when the shell's RootGeometryManager method is called, indicating
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 that a child widget wishes to change the shell's geometry. The
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 XtWidgetGeometry structure is stored in the EXTW_GEOMETRY_MANAGER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 property.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 5) extw_notify_focus_in (), extw_notify_focus_out ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 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
147 or loses the keyboard focus. It is done this way because Xt
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 maintains its own concept of keyboard focus and only the client
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 knows this information.
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 #define NOTIFY(w, type, l0, l1, l2) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 extw_send_notify_3(XtDisplay((Widget)(w)),\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 (w)->externalShell.external_window, type, l0, l1, l2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2299
diff changeset
156 static void ExternalShellInitialize (Widget req, Widget new_, ArgList args,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 Cardinal *num_args);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 static void ExternalShellRealize (Widget wid, Mask *vmask, XSetWindowAttributes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 *attr);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 static void ExternalShellDestroy (Widget w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 static void ChangeManaged (Widget wid);
2108
8de911beca70 [xemacs-hg @ 2004-06-02 09:16:14 by didierv]
didierv
parents: 877
diff changeset
162 static XtGeometryResult
8de911beca70 [xemacs-hg @ 2004-06-02 09:16:14 by didierv]
didierv
parents: 877
diff changeset
163 ExternalShellRootGeometryManager (Widget gw, XtWidgetGeometry *request,
8de911beca70 [xemacs-hg @ 2004-06-02 09:16:14 by didierv]
didierv
parents: 877
diff changeset
164 XtWidgetGeometry *reply);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 static void EventHandler (Widget wid, XtPointer closure, XEvent *event,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 Boolean *continue_to_dispatch);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 #ifndef DEFAULT_WM_TIMEOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 # define DEFAULT_WM_TIMEOUT 5000
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 #endif
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 void ExternalShellUnrealize (Widget w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 static XtResource resources[] = {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 #define offset(field) XtOffset(ExternalShellWidget, externalShell.field)
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
176 { XtNwindow, XtCWindow,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
177 XtRWindow, sizeof (Window),
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
178 offset (external_window), XtRImmediate, (XtPointer)0 },
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
179 { XtNclientTimeout, XtCClientTimeout,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
180 XtRInt, sizeof (int),
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
181 offset(client_timeout), XtRImmediate,(XtPointer)DEFAULT_WM_TIMEOUT },
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
182 { XtNdeadClient, XtCDeadClient,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
183 XtRBoolean, sizeof (Boolean),
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
184 offset(dead_client), XtRImmediate, (XtPointer)False },
428
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 static CompositeClassExtensionRec compositeClassExtRec = {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 NULLQUARK,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 XtCompositeExtensionVersion,
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
191 sizeof (CompositeClassExtensionRec),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 TRUE,
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 static ShellClassExtensionRec shellClassExtRec = {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 NULLQUARK,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 XtShellExtensionVersion,
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
199 sizeof (ShellClassExtensionRec),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 ExternalShellRootGeometryManager
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 ExternalShellClassRec externalShellClassRec = {
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 * core_class fields
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 /* superclass */ (WidgetClass) &shellClassRec,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 /* class_name */ "ExternalShell",
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
209 /* size */ sizeof (ExternalShellRec),
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 /* Class Initializer */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 /* class_part_initialize*/ NULL, /* XtInheritClassPartInitialize, */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 /* Class init'ed ? */ FALSE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 /* initialize */ ExternalShellInitialize,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 /* initialize_notify */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 /* realize */ ExternalShellRealize,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 /* actions */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 /* num_actions */ 0,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 /* resources */ resources,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 /* resource_count */ XtNumber (resources),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 /* xrm_class */ NULLQUARK,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 /* compress_motion */ FALSE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 /* compress_exposure */ TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 /* compress_enterleave*/ FALSE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 /* visible_interest */ TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 /* destroy */ ExternalShellDestroy, /* XtInheritDestroy, */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 /* resize */ XtInheritResize,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 /* expose */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 /* set_values */ NULL, /* XtInheritSetValues, */
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
229 /* set_values_hook */ NULL,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
230 /* set_values_almost */ XtInheritSetValuesAlmost,
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
231 /* get_values_hook */ NULL,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 /* accept_focus */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 /* intrinsics version */ XtVersion,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 /* callback offsets */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 /* tm_table */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 /* query_geometry */ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 /* display_accelerator*/ NULL,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 /* extension */ NULL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 },{ /* Composite */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 /* geometry_manager */ XtInheritGeometryManager,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 /* change_managed */ ChangeManaged, /* XtInheritChangeManaged */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 /* insert_child */ XtInheritInsertChild,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 /* delete_child */ XtInheritDeleteChild,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 /* extension */ (XtPointer)&compositeClassExtRec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 },{ /* Shell */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 /* extension */ (XtPointer)&shellClassExtRec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 },{ /* ExternalShell */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 0
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 WidgetClass externalShellWidgetClass = (WidgetClass) &externalShellClassRec;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 static void
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2299
diff changeset
255 ExternalShellInitialize (Widget req, Widget new_, ArgList UNUSED (args),
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2108
diff changeset
256 Cardinal *UNUSED (num_args))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 {
3025
facf3239ba30 [xemacs-hg @ 2005-10-25 11:16:19 by ben]
ben
parents: 2299
diff changeset
258 XtAddEventHandler(new_, 0,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 TRUE, EventHandler, (XtPointer) NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 extw_initialize_atoms(XtDisplay(req));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 extw_which_side = extw_shell_send;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 static Widget
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 find_managed_child (CompositeWidget w)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 Widget *childP = w->composite.children;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 for (i = w->composite.num_children; i; i--, childP++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 if (XtIsWidget(*childP) && XtIsManaged(*childP))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 return *childP;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 return NULL;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 #ifndef XtCXtToolkitError
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 # define XtCXtToolkitError "XtToolkitError"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2108
diff changeset
280 static void EventHandler (Widget wid, XtPointer UNUSED (closure),
2108
8de911beca70 [xemacs-hg @ 2004-06-02 09:16:14 by didierv]
didierv
parents: 877
diff changeset
281 XEvent *event,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2108
diff changeset
282 Boolean *UNUSED (continue_to_dispatch))
428
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
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2108
diff changeset
368 GetGeometry (Widget W, Widget UNUSED (child))
428
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
2108
8de911beca70 [xemacs-hg @ 2004-06-02 09:16:14 by didierv]
didierv
parents: 877
diff changeset
501 static void ExternalShellDestroy (Widget wid)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 ExternalShellWidget w = (ExternalShellWidget)wid;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 if (XtIsRealized(wid))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 ExternalShellUnrealize(wid);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 NOTIFY(w, extw_notify_end, 0, 0, 0);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 /* Invoke matching routine from superclass, but first override its
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 geometry opinions with our own routine */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513
2108
8de911beca70 [xemacs-hg @ 2004-06-02 09:16:14 by didierv]
didierv
parents: 877
diff changeset
514 static void ChangeManaged (Widget wid)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 if (!XtIsRealized (wid))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 GetGeometry(wid, (Widget)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 (*((ShellClassRec*)externalShellClassRec.core_class.superclass)->
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 composite_class.change_managed)(wid);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 /* Based on RootGeometryManager() in Shell.c */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523
2108
8de911beca70 [xemacs-hg @ 2004-06-02 09:16:14 by didierv]
didierv
parents: 877
diff changeset
524 static XtGeometryResult
8de911beca70 [xemacs-hg @ 2004-06-02 09:16:14 by didierv]
didierv
parents: 877
diff changeset
525 ExternalShellRootGeometryManager (Widget gw, XtWidgetGeometry *request,
8de911beca70 [xemacs-hg @ 2004-06-02 09:16:14 by didierv]
didierv
parents: 877
diff changeset
526 XtWidgetGeometry *reply)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 ExternalShellWidget w = (ExternalShellWidget)gw;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 unsigned int mask = request->request_mode;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 XEvent event;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 int oldx, oldy, oldwidth, oldheight, oldborder_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 unsigned long request_num;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 XtWidgetGeometry req = *request; /* don't modify caller's structure */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 oldx = w->core.x;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 oldy = w->core.y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 oldwidth = w->core.width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 oldheight = w->core.height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 oldborder_width = w->core.border_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 #define PutBackGeometry() \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 { w->core.x = oldx; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 w->core.y = oldy; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 w->core.width = oldwidth; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 w->core.height = oldheight; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 w->core.border_width = oldborder_width; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 if (mask & CWX) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 if (w->core.x == request->x) mask &= ~CWX;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 w->core.x = request->x;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 if (mask & CWY) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 if (w->core.y == request->y) mask &= ~CWY;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 else w->core.y = request->y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 if (mask & CWBorderWidth) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 if (w->core.border_width == request->border_width)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 mask &= ~CWBorderWidth;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 else w->core.border_width = request->border_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 if (mask & CWWidth) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 if (w->core.width == request->width) mask &= ~CWWidth;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 else w->core.width = request->width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 if (mask & CWHeight) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 if (w->core.height == request->height) mask &= ~CWHeight;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 else w->core.height = request->height;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 if (!XtIsRealized((Widget)w)) return XtGeometryYes;
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 req.sibling = None;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 req.request_mode = mask & ~CWSibling;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 request_num = NextRequest(XtDisplay(w));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 extw_send_geometry_value(XtDisplay(w), XtWindow(w),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 a_EXTW_GEOMETRY_MANAGER,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 extw_notify_gm, &req, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 if (w->externalShell.dead_client == TRUE) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 /* The client is sick. Refuse the request.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 * If the client recovers and decides to honor the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 * request, it will be handled by Shell's EventHandler().
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 PutBackGeometry();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 return XtGeometryNo;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 if (extw_wait_for_response(gw, &event, request_num, extw_notify_gm,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 w->externalShell.client_timeout)) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 XtGeometryResult result = (XtGeometryResult) event.xclient.data.l[2];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 if (result != XtGeometryYes)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 PutBackGeometry();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 if (result == XtGeometryAlmost) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 extw_get_geometry_value(XtDisplay(w), XtWindow(w),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 a_EXTW_GEOMETRY_MANAGER, reply);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 } else {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 w->externalShell.dead_client = TRUE; /* timed out; must be broken */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 PutBackGeometry();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 return XtGeometryNo;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 #undef PutBackGeometry
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 hack_event_masks_1 (Display *display, Window w, int this_window_propagate)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 Window root, parent, *children;
877
e54d47b2d736 [xemacs-hg @ 2002-06-23 09:54:35 by stephent]
stephent
parents: 440
diff changeset
612 unsigned int nchildren, i;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 if (!XQueryTree (display, w, &root, &parent, &children, &nchildren))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 for (i=0; i<nchildren; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 hack_event_masks_1 (display, children[i], 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 if (children)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 XFree (children);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 XWindowAttributes xwa;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 XSetWindowAttributes xswa;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 if (XGetWindowAttributes (display, w, &xwa)) {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 xswa.event_mask = xwa.your_event_mask & ~KeyPressMask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 if (this_window_propagate)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 xswa.do_not_propagate_mask = xwa.do_not_propagate_mask & ~KeyPressMask;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 XChangeWindowAttributes (display, w, CWEventMask, &xswa);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 /* 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
633 all key presses in any subwindow filter up to the specified window.
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 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
636 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
637 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
638 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
639 window. This occurs on the client side and we have no knowledge
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 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
641 receive our keyboard events.)
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 hack_event_masks (Display *display, Window w)
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 hack_event_masks_1 (display, w, 0);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 /* external entry points */
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 Bool
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 ExternalShellReady (Widget w, Window win, long event_mask)
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 ExternalShellWidget ew = (ExternalShellWidget) w;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 XEvent event;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 unsigned long request_num;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 request_num = NextRequest(XtDisplay(w));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 NOTIFY(ew, extw_notify_init, (long) win, event_mask, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 if (extw_wait_for_response(w, &event, request_num, extw_notify_init,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 ew->externalShell.client_timeout))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 /* Xt/Xm extw's have more elaborate focus needs than mere
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 Xlib ones.
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 Rather independently, they *don't* need the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 ConfigureNotify event, having fixed up the window size in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 ChangeManaged, above, but Xlib extw's do need this.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 ew->externalShell.client_type = event.xclient.data.l[2];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 if (ew->externalShell.client_type != EXTW_TYPE_XLIB)
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 hack_event_masks (XtDisplay (w), XtWindow (w));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 XConfigureEvent ev;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 XWindowAttributes xwa;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 ev.type = ConfigureNotify;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 ev.display = XtDisplay (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 ev.event = ev.window = XtWindow (w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683 XGetWindowAttributes (ev.display, ev.window, &xwa);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684 ev.x = xwa.x; ev.y = xwa.y;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 ev.width = xwa.width; ev.height = xwa.height;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 ev.border_width = xwa.border_width;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 ev.above = None;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 ev.override_redirect = xwa.override_redirect;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 XtDispatchEvent ((XEvent *) &ev);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 return FALSE;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698 ExternalShellSetFocus (Widget wid)
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 ExternalShellWidget w = (ExternalShellWidget) wid;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 NOTIFY(w, extw_notify_set_focus, 0, 0, 0);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705 extern void _XtUnregisterWindow (Window, Widget);
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 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 ExternalShellUnrealize (Widget w)
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 #if (XT_REVISION > 5)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 XtUnregisterDrawable (XtDisplay (w), w->core.window);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 extern void _XtUnregisterWindow (Window, Widget);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 _XtUnregisterWindow (w->core.window, w);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 w->core.window = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 }