entered into RCS
[bpt/emacs.git] / src / widget.c
index 4c39f1f..df146b6 100644 (file)
@@ -167,14 +167,9 @@ get_default_char_pixel_size (ew, pixel_width, pixel_height)
      int* pixel_width;
      int* pixel_height;
 {
-/*
-  *pixel_width = XTextWidth (ew->emacs_frame.font, "n", 1);
-  *pixel_height =
-    ew->emacs_frame.font->ascent + ew->emacs_frame.font->descent;
-*/
   struct frame* f = ew->emacs_frame.frame;
   *pixel_width = FONT_WIDTH (f->display.x->font);
-  *pixel_height = FONT_HEIGHT (f->display.x->font);
+  *pixel_height = f->display.x->line_height;
 }
 
 static void
@@ -312,10 +307,12 @@ set_frame_size (ew)
   Widget wmshell = get_wm_shell ((Widget) ew);
   Widget app_shell = XtParent ((Widget) wmshell);
   
-  
   if (! XtIsSubclass (wmshell, shellWidgetClass)) abort ();
   if (! XtIsSubclass (app_shell, shellWidgetClass)) abort ();
 
+  /* We don't need this for the momment. The geometry is computed in 
+     xfns.c.  */
+#if 0
   /* If the EmacsFrame doesn't have a geometry but the shell does,
      treat that as the geometry of the frame.  (Is this bogus?
      I'm not sure.) */
@@ -418,7 +415,7 @@ set_frame_size (ew)
          flags |= (app_flags & (WidthValue | HeightValue));
        }
     }
-
+#endif /* 0 */
   {
     struct frame* frame = ew->emacs_frame.frame;
     Dimension pixel_width, pixel_height;
@@ -436,7 +433,7 @@ set_frame_size (ew)
     ew->core.width = pixel_width;
     ew->core.height = pixel_height;
 
-
+#if 0 /* xfns.c takes care of this now.  */
     /* If a position was specified, assign it to the shell widget.
        (Else WM won't do anything with it.)
      */
@@ -473,6 +470,7 @@ set_frame_size (ew)
     /* Also assign the iconic status of the frame to the Shell, so that
        the WM sees it. */
     XtVaSetValues (wmshell, XtNiconic, ew->emacs_frame.iconic, 0);
+#endif /* 0 */
   }
 }
 
@@ -866,30 +864,6 @@ EmacsFrameQueryGeometry (widget, request, result)
   return result->request_mode ? XtGeometryAlmost : XtGeometryYes;
 }
 
-#if 0
-/* I don't know why this is necessary; Matthieu said he had to do
-   it to make the focus handlers work??
- */
-static void
-key_press (w, event, params, n_params)
-     Widget w;
-     XEvent* event;
-     String *params;
-     Cardinal *n_params;
-{
-}
-
-static void
-emacs_frame_focus_handler (w, event, params, n_params)
-     Widget w;
-     XEvent *event;
-     String *params;
-     Cardinal *n_params;
-{
-  emacs_Xt_focus_event_handler (event, 0);
-}
-#endif
-
 /* Special entrypoints */
 void
 EmacsFrameSetCharSize (widget, columns, rows)
@@ -900,20 +874,43 @@ EmacsFrameSetCharSize (widget, columns, rows)
   EmacsFrame ew = (EmacsFrame) widget;
   Dimension pixel_width, pixel_height, granted_width, granted_height;
   XtGeometryResult result;
+  struct frame *f = ew->emacs_frame.frame;
+  Arg al[2];
+  int ac = 0;
+  
   if (columns < 3) columns = 3;  /* no way buddy */
   if (rows < 3) rows = 3;
 
+  check_frame_size (f, &rows, &columns);
+  f->display.x->vertical_scroll_bar_extra
+    = (FRAME_HAS_VERTICAL_SCROLL_BARS (f)
+       ? VERTICAL_SCROLL_BAR_PIXEL_WIDTH (f)
+       : 0);
   char_to_pixel_size (ew, columns, rows, &pixel_width, &pixel_height);
-  result = XtMakeResizeRequest ((Widget)ew,
-                               pixel_width, pixel_height,
-                               &granted_width, &granted_height);
-  if (result == XtGeometryAlmost)
-    XtMakeResizeRequest ((Widget) ew, granted_width, granted_height,
-                        NULL, NULL);
-  /* damn Paned widget won't ever change its width.  Force it. */
-  if (ew->core.width != pixel_width)
+
+  /* Recompute the entire geometry management.  */
+  if (ew->core.width != pixel_width || ew->core.height != pixel_height)
     {
-      XtVaSetValues (XtParent ((Widget) ew), XtNwidth, pixel_width, 0);
-      XtVaSetValues ((Widget) ew, XtNwidth, pixel_width, 0);
+      int hdelta = pixel_height - ew->core.height;
+      int column_widget_height = f->display.x->column_widget->core.height;
+      XawPanedSetRefigureMode (f->display.x->column_widget, False);
+
+      ac = 0;
+      XtSetArg (al[ac], XtNheight, pixel_height); ac++;
+      XtSetArg (al[ac], XtNwidth, pixel_width); ac++;
+      XtSetValues ((Widget) ew, al, ac);
+      ac = 0;
+      XtSetArg (al[ac], XtNheight, column_widget_height + hdelta); ac++;
+      XtSetArg (al[ac], XtNwidth, pixel_width); ac++;
+      XtSetValues (f->display.x->column_widget, al, ac);
+
+      XawPanedSetRefigureMode (f->display.x->column_widget, True);
     }
+
+  /* We've set {FRAME,PIXEL}_{WIDTH,HEIGHT} to the values we hope to
+     receive in the ConfigureNotify event; if we get what we asked
+     for, then the event won't cause the screen to become garbaged, so
+     we have to make sure to do it here.  */
+  SET_FRAME_GARBAGED (f);
 }