-
-/* If *HEIGHT or *WIDTH are too small a size for FRAME, set them to the
- minimum allowable size. PIXELWISE means interpret these as pixel
- sizes. */
-
-void
-check_frame_size (struct frame *frame, int *width, int *height, bool pixelwise)
-{
- /* For height, we have to see:
- how many windows the frame has at minimum (one or two),
- and whether it has a menu bar or other special stuff at the top. */
- if (pixelwise)
- {
- int min_height = MIN_SAFE_WINDOW_HEIGHT * FRAME_LINE_HEIGHT (frame);
- int min_width = MIN_SAFE_WINDOW_WIDTH * FRAME_COLUMN_WIDTH (frame);
-
- if (!FRAME_MINIBUF_ONLY_P (frame) && FRAME_HAS_MINIBUF_P (frame))
- min_height = 2 * min_height;
-
- min_height += FRAME_TOP_MARGIN_HEIGHT (frame);
- min_height += FRAME_INTERNAL_BORDER_WIDTH (frame);
-
- if (*height < min_height)
- *height = min_height;
- if (*width < min_width)
- *width = min_width;
- }
- else
- {
- int min_height
- = ((FRAME_MINIBUF_ONLY_P (frame) || ! FRAME_HAS_MINIBUF_P (frame))
- ? MIN_SAFE_WINDOW_HEIGHT
- : 2 * MIN_SAFE_WINDOW_HEIGHT);
-
- if (FRAME_TOP_MARGIN (frame) > 0)
- min_height += FRAME_TOP_MARGIN (frame);
-
- if (*height < min_height)
- *height = min_height;
- if (*width < MIN_SAFE_WINDOW_WIDTH)
- *width = MIN_SAFE_WINDOW_WIDTH;
- }
-}
-
-/* Adjust the margins of window W if text area is too small.
- Return 1 if window width is ok after adjustment; 0 if window
- is still too narrow. */
-
-static int
-adjust_window_margins (struct window *w)
-{
- int box_width = (WINDOW_PIXEL_WIDTH (w)
- - WINDOW_FRINGES_WIDTH (w)
- - WINDOW_SCROLL_BAR_AREA_WIDTH (w));
- int margin_width = WINDOW_MARGINS_WIDTH (w);
-
- if (box_width - margin_width >= MIN_SAFE_WINDOW_PIXEL_WIDTH (w))
- return 1;
-
- if (margin_width < 0 || box_width < MIN_SAFE_WINDOW_PIXEL_WIDTH (w))
- return 0;
- else
- /* Window's text area is too narrow, but reducing the window
- margins will fix that. */
- {
- int unit = WINDOW_FRAME_COLUMN_WIDTH (w);
-
- margin_width = box_width - MIN_SAFE_WINDOW_PIXEL_WIDTH (w);
-
- if (WINDOW_RIGHT_MARGIN_WIDTH (w) > 0)
- {
- if (WINDOW_LEFT_MARGIN_WIDTH (w) > 0)
- w->left_margin_cols = w->right_margin_cols =
- margin_width / (2 * unit);
- else
- w->right_margin_cols = margin_width / unit;
- }
- else
- w->left_margin_cols = margin_width / unit;
-
- return 1;
- }
-}