annotate src/EmacsShell-sub.c @ 64:a01e7a40045c r19-16-pre7

Import from CVS: tag r19-16-pre7
author cvs
date Mon, 13 Aug 2007 08:59:30 +0200
parents 0293115a14e9
children 131b0175ea99
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* Emacs shell widget -- define the two widgets.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1994, 1995 Sun Microsystems, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 /* Synched up with: Not in FSF. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 /* Written by Ben Wing, May, 1994. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 It is rather unfortunate that we have to do this. Blame those
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 short-sighted people who designed the monstrosities known as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 Xt and ICCCM.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 This widget is not actually Emacs-specific; perhaps there could
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 be a better name than "EmacsShell". What it does is work around
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 a limitation in Xt in correctly dealing with the window-manager
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 size hints with applications that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (a) dynamically change their window size
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (b) have a cell size (width-inc and height-inc) other than 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (c) cannot predict in advance exactly what size their shell will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (This is the more common situation, when you have a number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 of widgets, each with their own size ideas)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 This widget assumes that your program contains a fixed "base size"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 plus some number of cells (e.g. character cells). The WMShell
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 resources "widthInc" and "heightInc" specify the size of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 character cell, and the window manager will report the app's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 size in cells rather than in pixels.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 If you use this widget, do not use the WMShell resources
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 "baseWidth", "baseHeight", "minWidth", or "minHeight".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 Instead, use "widthCells" and "heightCells" to specify the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 current size in cells (you must keep this up-to-date),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 and "minWidthCells" and "minHeightCells" to specify the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 minimum size in cells.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 Every time that the program issues a size command, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 "baseWidth", "baseHeight", "minWidth", and "minHeight" fields
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 of the WM_NORMAL_HINTS property will be updated to stay in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 line with the resource values specified above. The calculations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 are done once the desired shell size is known but before the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 window-manager size-change request is issued. (We must do it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 at this time because before then we don't know what size we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 will request, and after the request the deed has already
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 been done.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 After you change the "baseWidth", "baseHeight", "minWidth",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 or "minHeight" resources, you need to call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 EmacsShellUpdateSizeHints() to manually update the size
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 hints, except in the following two circumstances:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (a) you are about to make a geometry request.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (b) you are changing only "baseWidth" and "baseHeight"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 from within a resize procedure. (In this case,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 the size hints are already correct.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 #include <config.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 #include <stdio.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 #include <stdlib.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 #include <X11/StringDefs.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 #include "xintrinsicp.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 #include <X11/Shell.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 #include <X11/ShellP.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 #include <X11/Vendor.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 #include <X11/VendorP.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 #include "EmacsShellP.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 #if defined (DEFINE_TOP_LEVEL_EMACS_SHELL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 #define EMACS_SHELL_WIDGET TopLevelEmacsShellWidget
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 #define SUPERCLASS_WIDGET_CLASS topLevelShellWidgetClass
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 #define SUPERCLASS_CLASS_REC topLevelShellClassRec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 #define EMACS_SHELL_REC TopLevelEmacsShellRec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 #define EMACS_SHELL_CLASS_REC topLevelEmacsShellClassRec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 #define EMACS_SHELL_CLASS_REC_TYPE TopLevelEmacsShellClassRec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 #define EMACS_SHELL_CLASS_NAME "TopLevelEmacsShell"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 #define EMACS_SHELL_WIDGET_CLASS topLevelEmacsShellWidgetClass
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 #define EMACS_SHELL_UPDATE_SIZE_HINTS TopLevelEmacsShellUpdateSizeHints
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 #elif defined (DEFINE_TRANSIENT_EMACS_SHELL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 #define EMACS_SHELL_WIDGET TransientEmacsShellWidget
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 #define SUPERCLASS_WIDGET_CLASS transientShellWidgetClass
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 #define SUPERCLASS_CLASS_REC transientShellClassRec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 #define EMACS_SHELL_REC TransientEmacsShellRec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 #define EMACS_SHELL_CLASS_REC transientEmacsShellClassRec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 #define EMACS_SHELL_CLASS_REC_TYPE TransientEmacsShellClassRec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 #define EMACS_SHELL_CLASS_NAME "TransientEmacsShell"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 #define EMACS_SHELL_WIDGET_CLASS transientEmacsShellWidgetClass
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 #define EMACS_SHELL_UPDATE_SIZE_HINTS TransientEmacsShellUpdateSizeHints
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 Error. Must define either DEFINE_TOP_LEVEL_EMACS_SHELL or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 DEFINE_TRANSIENT_EMACS_SHELL.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 typedef struct {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 XtPointer next_extension;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 XrmQuark record_type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 long version;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 Cardinal record_size;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 } GenericClassExtRec;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 static XtGeometryResult RootGeometryManager (Widget gw,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 XtWidgetGeometry *request, XtWidgetGeometry *reply);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 static void ChangeManaged (Widget w);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 /* snarfed from Shell.c */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 #define BIGSIZE ((Dimension)32767)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 static XtResource resources[] = {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 #define offset(field) XtOffset(EMACS_SHELL_WIDGET, emacs_shell.field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 #define coreoffset(field) XtOffset(EMACS_SHELL_WIDGET, core.field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 #ifdef LWLIB_USES_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 /* *** BOGOSITY^10! *** The Motif VendorShell fucks around with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 the default values for X and Y, for no obvious reason. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 causes Shell to indicate that the defaults of (0,0) were
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 program-specified, instead of letting the WM do what it wants. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 {XtNx, XtCPosition, XtRPosition, sizeof(Position),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 coreoffset (x), XtRImmediate, (XtPointer)BIGSIZE},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 {XtNy, XtCPosition, XtRPosition, sizeof(Position),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 coreoffset (y), XtRImmediate, (XtPointer)BIGSIZE},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 { XtNwidthCells, XtCWidthCells, XtRInt, sizeof(int),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 offset (width_cells), XtRImmediate, (XtPointer)0},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 { XtNheightCells, XtCHeightCells, XtRInt, sizeof(int),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 offset (height_cells), XtRImmediate, (XtPointer)0},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 { XtNminWidthCells, XtCMinWidthCells, XtRInt, sizeof(int),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 offset (min_width_cells), XtRImmediate, (XtPointer)0},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 { XtNminHeightCells, XtCMinHeightCells, XtRInt, sizeof(int),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 offset (min_height_cells), XtRImmediate, (XtPointer)0},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 static CompositeClassExtensionRec compositeClassExtRec = {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 NULL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 NULLQUARK,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 XtCompositeExtensionVersion,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 sizeof(CompositeClassExtensionRec),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 TRUE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 static ShellClassExtensionRec shellClassExtRec = {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 NULL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 NULLQUARK,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 XtShellExtensionVersion,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 sizeof(ShellClassExtensionRec),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 RootGeometryManager
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 EMACS_SHELL_CLASS_REC_TYPE EMACS_SHELL_CLASS_REC = {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 { /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 * core_class fields
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 /* superclass */ (WidgetClass) &SUPERCLASS_CLASS_REC,
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
176 /* class_name */ (String) EMACS_SHELL_CLASS_NAME,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 /* size */ sizeof(EMACS_SHELL_REC),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 /* Class Initializer */ NULL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 /* class_part_initialize*/ NULL, /* XtInheritClassPartInitialize, */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 /* Class init'ed ? */ FALSE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 /* initialize */ NULL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 /* initialize_notify */ NULL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 /* realize */ XtInheritRealize,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 /* actions */ NULL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 /* num_actions */ 0,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 /* resources */ resources,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 /* resource_count */ XtNumber (resources),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 /* xrm_class */ NULLQUARK,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 /* compress_motion */ FALSE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 /* compress_exposure */ TRUE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 /* compress_enterleave*/ FALSE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 /* visible_interest */ TRUE,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 /* destroy */ NULL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 /* resize */ XtInheritResize,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 /* expose */ NULL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 /* set_values */ NULL, /* XtInheritSetValues, */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 /* set_values_hook */ NULL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 /* set_values_almost */ XtInheritSetValuesAlmost,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 /* get_values_hook */ NULL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 /* accept_focus */ NULL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 /* intrinsics version */ XtVersion,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 /* callback offsets */ NULL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 /* tm_table */ NULL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 /* query_geometry */ NULL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 /* display_accelerator*/ NULL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 /* extension */ NULL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 },{ /* Composite */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 /* geometry_manager */ XtInheritGeometryManager,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 /* change_managed */ ChangeManaged,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 /* insert_child */ XtInheritInsertChild,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 /* delete_child */ XtInheritDeleteChild,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 /* extension */ (XtPointer)&compositeClassExtRec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 },{ /* Shell */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 /* extension */ (XtPointer)&shellClassExtRec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 },{ /* WMShell */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 /* extension */ NULL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 },{ /* VendorShell */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 /* extension */ NULL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 },{ /* TopLevelShell or TransientShell */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 /* both have exactly one XtPointer here. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 /* extension */ NULL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 },{ /* EmacsShell */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 WidgetClass EMACS_SHELL_WIDGET_CLASS = (WidgetClass) &EMACS_SHELL_CLASS_REC;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 update_size_hints_internal (EMACS_SHELL_WIDGET w,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 int width, int height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 int base_width, base_height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 int cell_width, cell_height;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 /* time to update them thar size hints */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 cell_width = w->wm.size_hints.width_inc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 cell_height = w->wm.size_hints.height_inc;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 base_width = width - cell_width * w->emacs_shell.width_cells;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 base_height = height - cell_height * w->emacs_shell.height_cells;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 #ifdef DEBUG_GEOMETRY_MANAGEMENT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 /* Very useful info when debugging geometry management problems.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 When it's guaranteed that no more such problems exist, take
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 this stuff out. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 printf ("update_size_hints_internal:\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 printf (" actual pixel size: %d %d\n", width, height);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 printf (" cell size in pixels: %d %d\n", cell_width, cell_height);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 printf (" text area size in cells: %d %d\n", w->emacs_shell.width_cells,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 w->emacs_shell.height_cells);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 printf (" base size set to: %d %d\n", base_width, base_height);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 fflush (stdout);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 XtVaSetValues ((Widget) w,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 XtNbaseWidth, base_width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 XtNbaseHeight, base_height,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 XtNminWidth, base_width +
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 cell_width * w->emacs_shell.min_width_cells,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 XtNminHeight, base_height +
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 cell_height * w->emacs_shell.min_height_cells,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
263 static XtGeometryResult
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
264 SuperClassRootGeometryManager (Widget gw,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
265 XtWidgetGeometry *request,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
266 XtWidgetGeometry *reply)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 ShellWidgetClass swc = (ShellWidgetClass) SUPERCLASS_WIDGET_CLASS;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 ShellClassExtensionRec *scer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 GenericClassExtRec *gcer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 /* find the shell extension record that specifies the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 root geometry manager method */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 for (gcer = (GenericClassExtRec *) swc->shell_class.extension;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 gcer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 gcer = (GenericClassExtRec *) gcer->next_extension)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 if (gcer->record_type == NULLQUARK)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 if (!gcer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 /* call it to actually make the geometry request */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 scer = (ShellClassExtensionRec *) gcer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 return (scer->root_geometry_manager)(gw, request, reply);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
290 static XtGeometryResult
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
291 RootGeometryManager (Widget gw,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
292 XtWidgetGeometry *request,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
293 XtWidgetGeometry *reply)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 EMACS_SHELL_WIDGET w = (EMACS_SHELL_WIDGET) gw;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 /* OK since this file is not dumped */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 static int reentrant = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 XtGeometryResult result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 if (reentrant)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 abort ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 reentrant++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 #ifdef DEBUG_GEOMETRY_MANAGEMENT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 printf ("root_geometry_manager:\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 printf (" current shell size: %d %d\n", w->core.width, w->core.height);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 if (request->request_mode & CWWidth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 printf ("width requested;");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 if (request->request_mode & CWHeight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 printf ("height requested;");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 printf ("\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 printf (" requested shell size: %d %d\n", request->width, request->height);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 /* update the size hints */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 update_size_hints_internal (w,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 request->request_mode & CWWidth ?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 request->width : w->core.width,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 request->request_mode & CWHeight ?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 request->height : w->core.height);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 result = SuperClassRootGeometryManager (gw, request, reply);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 #ifdef DEBUG_GEOMETRY_MANAGEMENT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 printf (" result: %s\n",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 result == XtGeometryYes ? "XtGeometryYes" :
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 result == XtGeometryNo ? "XtGeometryNo" :
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 result == XtGeometryAlmost ? "XtGeometryAlmost" :
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 "XtGeometryDone");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 if (reply->request_mode & CWWidth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 printf ("width returned;");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 if (reply->request_mode & CWHeight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 printf ("height returned;");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 printf ("\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 printf (" resulting shell size: %d %d\n", reply->width, reply->height);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 printf ("----------\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 fflush (stdout);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 reentrant--;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 ChangeManaged (Widget wid)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 EMACS_SHELL_WIDGET w = (EMACS_SHELL_WIDGET) wid;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 /* If not realized, then we're being called from XtRealizeWidget().
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 RootGeometryManager() has not yet been called, and thus our
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 base size is incorrect. We need to set it now or the Shell
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 will mess up geometry specifications with negative positional
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 offsets. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 if (!XtIsRealized (wid))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 Widget child = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 /* the managed child indicates what our size is */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 for (i = 0; i < w->composite.num_children; i++) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 if (XtIsManaged(w->composite.children[i])) {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 child = w->composite.children[i];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 update_size_hints_internal (w, child->core.width, child->core.height);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 /* call the real ChangeManaged */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (((ShellWidgetClass) SUPERCLASS_WIDGET_CLASS)->
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 composite_class.change_managed)(wid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 /******************* external entry points *********************/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 EMACS_SHELL_UPDATE_SIZE_HINTS (Widget gw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 EMACS_SHELL_WIDGET w = (EMACS_SHELL_WIDGET) gw;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 update_size_hints_internal (w, w->core.width, w->core.height);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 }