comparison src/EmacsManager.c @ 412:697ef44129c6 r21-2-14

Import from CVS: tag r21-2-14
author cvs
date Mon, 13 Aug 2007 11:20:41 +0200
parents 74fd4e045ea6
children
comparison
equal deleted inserted replaced
411:12e008d41344 412:697ef44129c6
35 Titan Motif, I require no ritual sacrifices to placate the lesser 35 Titan Motif, I require no ritual sacrifices to placate the lesser
36 daemons of geometry management. */ 36 daemons of geometry management. */
37 37
38 static XtResource resources[] = { 38 static XtResource resources[] = {
39 #define offset(field) XtOffset(EmacsManagerWidget, emacs_manager.field) 39 #define offset(field) XtOffset(EmacsManagerWidget, emacs_manager.field)
40 { XtNresizeCallback, XtCCallback, 40 { XtNresizeCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
41 XtRCallback, sizeof (XtCallbackList), 41 offset(resize_callback), XtRImmediate, (XtPointer) 0 },
42 offset(resize_callback), XtRImmediate, (XtPointer) 0 }, 42 { XtNqueryGeometryCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
43 { XtNqueryGeometryCallback, XtCCallback, 43 offset(query_geometry_callback), XtRImmediate, (XtPointer) 0 },
44 XtRCallback, sizeof (XtCallbackList), 44 { XtNuserData, XtCUserData, XtRPointer, sizeof(XtPointer),
45 offset(query_geometry_callback), XtRImmediate, (XtPointer) 0 }, 45 offset(user_data), XtRImmediate, (XtPointer) 0 },
46 { XtNuserData, XtCUserData,
47 XtRPointer, sizeof (XtPointer),
48 offset(user_data), XtRImmediate, (XtPointer) 0 },
49 }; 46 };
50 47
51 /**************************************************************** 48 /****************************************************************
52 * 49 *
53 * Full class record constant 50 * Full class record constant
72 /* superclass */ (WidgetClass) &xmManagerClassRec, 69 /* superclass */ (WidgetClass) &xmManagerClassRec,
73 #else 70 #else
74 /* superclass */ (WidgetClass) &compositeClassRec, 71 /* superclass */ (WidgetClass) &compositeClassRec,
75 #endif 72 #endif
76 /* class_name */ "EmacsManager", 73 /* class_name */ "EmacsManager",
77 /* widget_size */ sizeof (EmacsManagerRec), 74 /* widget_size */ sizeof(EmacsManagerRec),
78 /* class_initialize */ ClassInitialize, 75 /* class_initialize */ ClassInitialize,
79 /* class_part_init */ NULL, 76 /* class_part_init */ NULL,
80 /* class_inited */ FALSE, 77 /* class_inited */ FALSE,
81 /* initialize */ NULL, 78 /* initialize */ NULL,
82 /* initialize_hook */ NULL, 79 /* initialize_hook */ NULL,
148 static XtGeometryResult 145 static XtGeometryResult
149 QueryGeometry (Widget w, XtWidgetGeometry *request, XtWidgetGeometry *reply) 146 QueryGeometry (Widget w, XtWidgetGeometry *request, XtWidgetGeometry *reply)
150 { 147 {
151 EmacsManagerWidget emw = (EmacsManagerWidget) w; 148 EmacsManagerWidget emw = (EmacsManagerWidget) w;
152 EmacsManagerQueryGeometryStruct struc; 149 EmacsManagerQueryGeometryStruct struc;
153 int request_mode = request->request_mode; 150 int mask = request->request_mode & (CWWidth | CWHeight);
154 151
155 struc.request_mode = request_mode; 152 struc.request_mode = mask;
156 struc.proposed_width = (request_mode & CWWidth) ? request->width : 0; 153 if (mask & CWWidth) struc.proposed_width = request->width;
157 struc.proposed_height = (request_mode & CWHeight) ? request->height : 0; 154 if (mask & CWHeight) struc.proposed_height = request->height;
158 XtCallCallbackList (w, emw->emacs_manager.query_geometry_callback, &struc); 155 XtCallCallbackList (w, emw->emacs_manager.query_geometry_callback, &struc);
159 reply->request_mode = CWWidth | CWHeight; 156 reply->request_mode = CWWidth | CWHeight;
160 reply->width = struc.proposed_width; 157 reply->width = struc.proposed_width;
161 reply->height = struc.proposed_height; 158 reply->height = struc.proposed_height;
162 if (((request_mode & CWWidth) && (request->width != reply->width)) || 159 if (((mask & CWWidth) && (request->width != reply->width)) ||
163 ((request_mode & CWHeight) && (request->height != reply->height))) 160 ((mask & CWHeight) && (request->height != reply->height)))
164 return XtGeometryAlmost; 161 return XtGeometryAlmost;
165 return XtGeometryYes; 162 return XtGeometryYes;
166 } 163 }
167 164
168 static void 165 static void
178 175
179 static XtGeometryResult 176 static XtGeometryResult
180 GeometryManager (Widget w, XtWidgetGeometry *request, XtWidgetGeometry *reply) 177 GeometryManager (Widget w, XtWidgetGeometry *request, XtWidgetGeometry *reply)
181 { 178 {
182 /* Sure, any changes are fine. */ 179 /* Sure, any changes are fine. */
183 180 #define COPY(field, mask) \
184 #ifdef LWLIB_MENUBARS_MOTIF 181 if (request->request_mode & mask) w->core.field = request->field
182
185 /* The Motif menubar will merrily request a new size every time a 183 /* The Motif menubar will merrily request a new size every time a
186 child is added or deleted. Blow it off because it doesn't know 184 child is added or deleted. Blow it off because it doesn't know
187 what it's talking about. */ 185 what it's talking about. */
188 if (XtClass (w) != xmRowColumnWidgetClass) 186 #ifdef LWLIB_MENUBARS_MOTIF
187 if (!(XtClass (w) == xmRowColumnWidgetClass))
189 #endif /* LWLIB_MENUBARS_MOTIF */ 188 #endif /* LWLIB_MENUBARS_MOTIF */
190 { 189 {
191 if (request->request_mode & CWWidth) w->core.width = request->width; 190 COPY (width, CWWidth);
192 if (request->request_mode & CWHeight) w->core.height = request->height; 191 COPY (height, CWHeight);
193 } 192 }
194 if (request->request_mode & CWBorderWidth) 193 COPY (border_width, CWBorderWidth);
195 w->core.border_width = request->border_width; 194 COPY (x, CWX);
196 if (request->request_mode & CWX) w->core.x = request->x; 195 COPY (y, CWY);
197 if (request->request_mode & CWY) w->core.y = request->y; 196 #undef COPY
198 197
199 return XtGeometryYes; 198 return XtGeometryYes;
200 } 199 }
201 200
202 static void 201 static void
203 ChangeManaged (Widget w) 202 ChangeManaged (Widget w)
204 { 203 {
205 if (!XtIsRealized (w)) 204 if (!XtIsRealized (w))
206 { 205 {
207 XtWidgetGeometry request, reply; 206 XtWidgetGeometry req, repl;
208 207
209 /* find out how big we'd like to be ... */ 208 /* find out how big we'd like to be ... */
210 209
211 request.request_mode = 0; 210 req.request_mode = 0;
212 XtQueryGeometry (w, &request, &reply); 211 XtQueryGeometry (w, &req, &repl);
213 EmacsManagerChangeSize (w, reply.width, reply.height); 212 EmacsManagerChangeSize (w, repl.width, repl.height);
214 } 213 }
215 } 214 }
216 215
217 static void 216 static void
218 Realize (Widget w, Mask *valueMask, XSetWindowAttributes *attributes) 217 Realize (Widget w, Mask *valueMask, XSetWindowAttributes *attributes)