annotate src/ExternalShell.c @ 5680:8a2ac78cb97d

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