comparison src/EmacsManager.c @ 398:74fd4e045ea6 r21-2-29

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