+/* Return the required height of glyph matrices for window W. */
+
+int
+required_matrix_height (w)
+ struct window *w;
+{
+#ifdef HAVE_WINDOW_SYSTEM
+ struct frame *f = XFRAME (w->frame);
+
+ if (FRAME_WINDOW_P (f))
+ {
+ int ch_height = FRAME_SMALLEST_FONT_HEIGHT (f);
+ int window_pixel_height = window_box_height (w) + abs (w->vscroll);
+ return (((window_pixel_height + ch_height - 1)
+ / ch_height)
+ /* One partially visible line at the top and
+ bottom of the window. */
+ + 2
+ /* 2 for header and mode line. */
+ + 2);
+ }
+#endif /* HAVE_WINDOW_SYSTEM */
+
+ return XINT (w->height);
+}
+
+
+/* Return the required width of glyph matrices for window W. */
+
+int
+required_matrix_width (w)
+ struct window *w;
+{
+#ifdef HAVE_WINDOW_SYSTEM
+ struct frame *f = XFRAME (w->frame);
+ if (FRAME_WINDOW_P (f))
+ {
+ int ch_width = FRAME_SMALLEST_CHAR_WIDTH (f);
+ int window_pixel_width = XFLOATINT (w->width) * CANON_X_UNIT (f);
+
+ /* Compute number of glyphs needed in a glyph row. */
+ return (((window_pixel_width + ch_width - 1)
+ / ch_width)
+ /* 2 partially visible columns in the text area. */
+ + 2
+ /* One partially visible column at the right
+ edge of each marginal area. */
+ + 1 + 1);
+ }
+#endif /* HAVE_WINDOW_SYSTEM */
+
+ return XINT (w->width);
+}
+
+