/* Given a character size, this returns the minimum number of pixels necessary to display that many characters, taking into account the internal border width, and the size of the line terminator glyphs (assuming the line terminators take up exactly one character position.) Therefore the result is not necessarily a multiple of anything in particular. */ static void char_to_pixel_size (EmacsScreen ew, int char_width, int char_height, Dimension* pixel_width, Dimension* pixel_height) { int cpw; int cph; get_default_char_pixel_size (ew, &cpw, &cph); *pixel_width = (char_width - 1) * cpw + 2 * ew->emacs_screen.internal_border_width + max (cpw, (int) max (XPIXMAP (glyph_to_pixmap (continuer_glyph))->width, XPIXMAP (glyph_to_pixmap (truncator_glyph))->width)); *pixel_height = char_height * cph + 2 * ew->emacs_screen.internal_border_width; }
static void update_wm_hints (EmacsFrame ew) { Widget wmshell = get_wm_shell ((Widget) ew); int cw; int ch; Dimension rounded_width; Dimension rounded_height; int char_width; int char_height; int base_width; int base_height; int min_rows = 0, min_cols = 0; /* This happens when the frame is just created. */ if (! wmshell) return; pixel_to_char_size (ew, ew->core.width, ew->core.height, &char_width, &char_height); char_to_pixel_size (ew, char_width, char_height, &rounded_width, &rounded_height); get_default_char_pixel_size (ew, &cw, &ch); base_width = (wmshell->core.width - ew->core.width + (rounded_width - (char_width * cw))); base_height = (wmshell->core.height - ew->core.height + (rounded_height - (char_height * ch))); /* This is kind of sleazy, but I can't see how else to tell it to make it mark the WM_SIZE_HINTS size as user specified. */ /* ((WMShellWidget) wmshell)->wm.size_hints.flags |= USSize;*/ XtVaSetValues (wmshell, XtNbaseWidth, (XtArgVal) base_width, XtNbaseHeight, (XtArgVal) base_height, XtNwidthInc, (XtArgVal) (frame_resize_pixelwise ? 1 : cw), XtNheightInc, (XtArgVal) (frame_resize_pixelwise ? 1 : ch), XtNminWidth, (XtArgVal) (base_width + min_cols * cw), XtNminHeight, (XtArgVal) (base_height + min_rows * ch), NULL); }
/* This takes the size in pixels of the text area, and returns the number of characters that will fit there, taking into account the internal border width, and the pixel width of the line terminator glyphs (which always count as one "character" wide, even if they are not the same size as the default character size of the default font.) Therefore the result is not necessarily a multiple of anything in particular. */ static void pixel_to_char_size (EmacsScreen ew, Dimension pixel_width, Dimension pixel_height, int* char_width, int* char_height) { int cpw; int cph; int egw; get_default_char_pixel_size (ew, &cpw, &cph); egw = max (cpw, (int) max (XPIXMAP (glyph_to_pixmap (continuer_glyph))->width, XPIXMAP (glyph_to_pixmap (truncator_glyph))->width)); *char_width = 1 + (int)((pixel_width - egw) - 2 * ew->emacs_screen.internal_border_width) / cpw; *char_height = (int)(pixel_height - 2 * ew->emacs_screen.internal_border_width) / cph; }