XEmacs 21.2.28 "Hermes".
[chise/xemacs-chise.git.1] / src / EmacsManager.c
index 2d02f8d..800801e 100644 (file)
@@ -37,12 +37,15 @@ Boston, MA 02111-1307, USA.  */
 
 static XtResource resources[] = {
 #define offset(field) XtOffset(EmacsManagerWidget, emacs_manager.field)
-  { XtNresizeCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
-      offset(resize_callback), XtRImmediate, (XtPointer) 0 },
-  { XtNqueryGeometryCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
-      offset(query_geometry_callback), XtRImmediate, (XtPointer) 0 },
-  { XtNuserData, XtCUserData, XtRPointer, sizeof(XtPointer),
-      offset(user_data), XtRImmediate, (XtPointer) 0 },
+  { XtNresizeCallback, XtCCallback,
+    XtRCallback, sizeof (XtCallbackList),
+    offset(resize_callback), XtRImmediate, (XtPointer) 0 },
+  { XtNqueryGeometryCallback, XtCCallback,
+    XtRCallback, sizeof (XtCallbackList),
+    offset(query_geometry_callback), XtRImmediate, (XtPointer) 0 },
+  { XtNuserData, XtCUserData,
+    XtRPointer, sizeof (XtPointer),
+    offset(user_data), XtRImmediate, (XtPointer) 0 },
 };
 
 /****************************************************************
@@ -71,7 +74,7 @@ EmacsManagerClassRec emacsManagerClassRec = {
     /* superclass         */    (WidgetClass) &compositeClassRec,
 #endif
     /* class_name         */    "EmacsManager",
-    /* widget_size        */    sizeof(EmacsManagerRec),
+    /* widget_size        */    sizeof (EmacsManagerRec),
     /* class_initialize   */    ClassInitialize,
     /* class_part_init    */   NULL,
     /* class_inited       */   FALSE,
@@ -147,17 +150,17 @@ QueryGeometry (Widget w, XtWidgetGeometry *request, XtWidgetGeometry *reply)
 {
   EmacsManagerWidget emw = (EmacsManagerWidget) w;
   EmacsManagerQueryGeometryStruct struc;
-  int mask = request->request_mode & (CWWidth | CWHeight);
+  int request_mode = request->request_mode;
 
-  struc.request_mode = mask;
-  if (mask & CWWidth)  struc.proposed_width  = request->width;
-  if (mask & CWHeight) struc.proposed_height = request->height;
+  struc.request_mode = request_mode;
+  struc.proposed_width  = (request_mode & CWWidth)  ? request->width  : 0;
+  struc.proposed_height = (request_mode & CWHeight) ? request->height : 0;
   XtCallCallbackList (w, emw->emacs_manager.query_geometry_callback, &struc);
   reply->request_mode = CWWidth | CWHeight;
   reply->width  = struc.proposed_width;
   reply->height = struc.proposed_height;
-  if (((mask & CWWidth)  && (request->width  != reply->width)) ||
-      ((mask & CWHeight) && (request->height != reply->height)))
+  if (((request_mode & CWWidth)  && (request->width  != reply->width)) ||
+      ((request_mode & CWHeight) && (request->height != reply->height)))
     return XtGeometryAlmost;
   return XtGeometryYes;
 }
@@ -177,23 +180,21 @@ static XtGeometryResult
 GeometryManager (Widget w, XtWidgetGeometry *request, XtWidgetGeometry *reply)
 {
   /* Sure, any changes are fine. */
-#define COPY(field, mask) \
-  if (request->request_mode & mask) w->core.field = request->field
 
+#ifdef LWLIB_MENUBARS_MOTIF
   /* The Motif menubar will merrily request a new size every time a
      child is added or deleted.  Blow it off because it doesn't know
      what it's talking about. */
-#ifdef LWLIB_MENUBARS_MOTIF
-  if (!(XtClass (w) == xmRowColumnWidgetClass))
+  if (XtClass (w) != xmRowColumnWidgetClass)
 #endif /* LWLIB_MENUBARS_MOTIF */
     {
-      COPY (width, CWWidth);
-      COPY (height, CWHeight);
+      if (request->request_mode & CWWidth)  w->core.width  = request->width;
+      if (request->request_mode & CWHeight) w->core.height = request->height;
     }
-  COPY (border_width, CWBorderWidth);
-  COPY (x, CWX);
-  COPY (y, CWY);
-#undef COPY
+  if (request->request_mode & CWBorderWidth)
+    w->core.border_width = request->border_width;
+  if (request->request_mode & CWX) w->core.x = request->x;
+  if (request->request_mode & CWY) w->core.y = request->y;
 
   return XtGeometryYes;
 }
@@ -203,13 +204,13 @@ ChangeManaged (Widget w)
 {
   if (!XtIsRealized (w))
     {
-      XtWidgetGeometry req, repl;
+      XtWidgetGeometry request, reply;
 
       /* find out how big we'd like to be ... */
 
-      req.request_mode = 0;
-      XtQueryGeometry (w, &req, &repl);
-      EmacsManagerChangeSize (w, repl.width, repl.height);
+      request.request_mode = 0;
+      XtQueryGeometry (w, &request, &reply);
+      EmacsManagerChangeSize (w, reply.width, reply.height);
     }
 }