summaryrefslogtreecommitdiff
path: root/src/xterm.c
diff options
context:
space:
mode:
authorMartin Rudalics <rudalics@gmx.at>2015-10-13 12:11:43 +0200
committerMartin Rudalics <rudalics@gmx.at>2015-10-13 12:11:43 +0200
commitd4fe840df0b5fdb3aed538fae2ced143a471f60a (patch)
tree13ff9d7115616a99af7e0257277a1ca6edf31f72 /src/xterm.c
parente53e1a0426539aa3f2902632fdd8025da8f710f2 (diff)
downloademacs-d4fe840df0b5fdb3aed538fae2ced143a471f60a.tar.gz
Allow setting frame pixel sizes from frame parameters (Bug#21415)
Also fix some misfeatures in frame (re-)sizing code, add more debugging information and remove some dead code. * lisp/frame.el (frame-notice-user-settings, make-frame): Change parameter names when setting `frame-size-history'. (frame--size-history): New function. * src/frame.c (frame_inhibit_resize): If frame has not been made yet, return t if inhibit_horizontal_resize or inhibit_vertical_resize bit have been set. (adjust_frame_size): Simplify. (make_frame): Initialize inhibit_horizontal_resize, inhibit_vertical_resize, tool_bar_redisplayed, tool_bar_resized. (Fframe_after_make_frame): Reset inhibit_horizontal_resize and inhibit_vertical_resize slots. (x_set_frame_parameters): Handle `text-pixels' specification for width and height parameters. Don't consider new_height or new_width changes. Call adjust_frame_size instead of Fset_frame_size. (x_figure_window_size): Two new arguments x_width and y_width returning frame's figures width and height. Calculate tool bar height before frame sizes so SET_FRAME_HEIGHT can pick it up. Handle `text-pixels' specification for width and height parameters. (Qtext_pixels, Qx_set_frame_parameters, Qset_frame_size) (Qx_set_window_size_1, Qx_set_window_size_2) (Qx_set_window_size_3, Qx_set_menu_bar_lines) (Qupdate_frame_menubar, Qfree_frame_menubar_1) (Qfree_frame_menubar_2): New symbols. * src/frame.h (structure frame): New booleans tool_bar_redisplayed, tool_bar_resized, inhibit_horizontal_resize, inhibit_vertical_resize. (x_figure_window_size): Update external declaration. * src/gtkutil.c (xg_frame_set_char_size): Set size hints before calling gtk_window_resize. (update_frame_tool_bar): Make inhibiting of frame resizing more discriminative. Set tool_bar_resized bit. * src/nsfns.m (x_set_tool_bar_lines): Make inhibiting of frame resizing more discriminative. Call adjust_frame_size instead of x_set_window_size. (Fx_create_frame): Handle x_width and x_height if set by x_figure_window_size. * src/nsterm.m (x_set_window_size): For GNUSTEP build don't subtract 3 from tool bar height. (x_set_window_size): Add frame_size_history_add call. (x_new_font): Call adjust_frame_size instead of x_set_window_size. * src/w32fns.c (x_change_tool_bar_height): Reset tool_bar_redisplayed and tool_bar_resized bits when adding tool bar. Make inhibiting of frame resizing more discriminative. (w32_wnd_proc): Remove dead code in WM_WINDOWPOSCHANGING case. (Fx_create_frame): Handle x_width and x_height if set by x_figure_window_size. Set size hints before adjusting frame size. (x_create_tip_frame): Adjust x_figure_window_size call. * src/w32term.c (x_set_window_size): Add frame_size_history_add call. * src/widget.c (set_frame_size): Remove dead code. Add frame_size_history_add call. When frame_resize_pixelwise is t use FRAME_PIXEL_WIDTH and FRAME_PIXEL_HEIGHT instead of pixel_width and pixel_height. (update_various_frame_slots): Remove dead code. (EmacsFrameResize): Add more information in frame_size_history_add call. (EmacsFrameQueryGeometry): Round only when frame_resize_pixelwise is not set. * src/xdisp.c (redisplay_tool_bar): Set tool_bar_redisplayed bits. * src/xfns.c (x_set_menu_bar_lines): Change argument name. (x_change_tool_bar_height): Reset tool_bar_redisplayed and tool_bar_resized bits when adding tool bar. Make inhibiting of frame resizing more discriminative. (Fx_create_frame): Handle x_width and x_height if set by x_figure_window_size. Set size hints before adjusting frame size. (x_create_tip_frame): Adjust x_figure_window_size call. * src/xmenu.c (update_frame_menubar): Don't handle Lucid specially. (set_frame_menubar): On Lucid never add core-border-width to avoid that adding XtNinternalBorderWidth adds it again. (free_frame_menubar): Handle frame_inhibit_resize true for Motif. * src/xterm.c (x_new_font): In non-toolkit case handle size change of menu bar. (x_set_window_size_1): Fix calls to frame_size_history_add. (x_wm_set_size_hint): Remove dead code. Set size_hints.min_width and size_hints.min_height to base_width and base_height.
Diffstat (limited to 'src/xterm.c')
-rw-r--r--src/xterm.c52
1 files changed, 30 insertions, 22 deletions
diff --git a/src/xterm.c b/src/xterm.c
index dd57a548393..fdf0eee689f 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -9579,6 +9579,10 @@ x_new_font (struct frame *f, Lisp_Object font_object, int fontset)
{
struct font *font = XFONT_OBJECT (font_object);
int unit, font_ascent, font_descent;
+#ifndef USE_X_TOOLKIT
+ int old_menu_bar_height = FRAME_MENU_BAR_HEIGHT (f);
+ Lisp_Object fullscreen;
+#endif
if (fontset < 0)
fontset = fontset_from_font (font_object);
@@ -9615,9 +9619,25 @@ x_new_font (struct frame *f, Lisp_Object font_object, int fontset)
doing it because it's done in Fx_show_tip, and it leads to
problems because the tip frame has no widget. */
if (NILP (tip_frame) || XFRAME (tip_frame) != f)
+ {
adjust_frame_size (f, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f),
FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), 3,
false, Qfont);
+#ifndef USE_X_TOOLKIT
+ if (FRAME_MENU_BAR_HEIGHT (f) != old_menu_bar_height
+ && !f->after_make_frame
+ && (EQ (frame_inhibit_implied_resize, Qt)
+ || (CONSP (frame_inhibit_implied_resize)
+ && NILP (Fmemq (Qfont, frame_inhibit_implied_resize))))
+ && (NILP (fullscreen = get_frame_param (f, Qfullscreen))
+ || EQ (fullscreen, Qfullwidth)))
+ /* If the menu bar height changes, try to keep text height
+ constant. */
+ adjust_frame_size
+ (f, -1, FRAME_TEXT_HEIGHT (f) + FRAME_MENU_BAR_HEIGHT (f)
+ - old_menu_bar_height, 1, false, Qfont);
+#endif /* USE_X_TOOLKIT */
+ }
}
#ifdef HAVE_X_I18N
@@ -10549,7 +10569,7 @@ x_set_window_size_1 (struct frame *f, bool change_gravity,
if (EQ (fullscreen, Qfullwidth) && width == FRAME_TEXT_WIDTH (f))
{
frame_size_history_add
- (f, Qxg_frame_set_char_size_1, width, height,
+ (f, Qx_set_window_size_1, width, height,
list2 (make_number (old_height),
make_number (pixelheight + FRAME_MENUBAR_HEIGHT (f))));
@@ -10559,7 +10579,7 @@ x_set_window_size_1 (struct frame *f, bool change_gravity,
else if (EQ (fullscreen, Qfullheight) && height == FRAME_TEXT_HEIGHT (f))
{
frame_size_history_add
- (f, Qxg_frame_set_char_size_2, width, height,
+ (f, Qx_set_window_size_2, width, height,
list2 (make_number (old_width), make_number (pixelwidth)));
XResizeWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
@@ -10569,10 +10589,11 @@ x_set_window_size_1 (struct frame *f, bool change_gravity,
else
{
frame_size_history_add
- (f, Qxg_frame_set_char_size_3, width, height,
- list2 (make_number (pixelwidth + FRAME_TOOLBAR_WIDTH (f)),
+ (f, Qx_set_window_size_3, width, height,
+ list3 (make_number (pixelwidth + FRAME_TOOLBAR_WIDTH (f)),
make_number (pixelheight + FRAME_TOOLBAR_HEIGHT (f)
- + FRAME_MENUBAR_HEIGHT (f))));
+ + FRAME_MENUBAR_HEIGHT (f)),
+ make_number (FRAME_MENUBAR_HEIGHT (f))));
XResizeWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
pixelwidth, pixelheight + FRAME_MENUBAR_HEIGHT (f));
@@ -11342,8 +11363,8 @@ x_wm_set_size_hint (struct frame *f, long flags, bool user_position)
size_hints.x = f->left_pos;
size_hints.y = f->top_pos;
- size_hints.height = FRAME_PIXEL_HEIGHT (f);
size_hints.width = FRAME_PIXEL_WIDTH (f);
+ size_hints.height = FRAME_PIXEL_HEIGHT (f);
size_hints.width_inc = frame_resize_pixelwise ? 1 : FRAME_COLUMN_WIDTH (f);
size_hints.height_inc = frame_resize_pixelwise ? 1 : FRAME_LINE_HEIGHT (f);
@@ -11356,34 +11377,21 @@ x_wm_set_size_hint (struct frame *f, long flags, bool user_position)
/* Calculate the base and minimum sizes. */
{
int base_width, base_height;
- int min_rows = 0, min_cols = 0;
base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0);
base_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 0);
- if (frame_resize_pixelwise)
- /* Needed to prevent a bad protocol error crash when making the
- frame size very small. */
- {
- min_cols = 2 * min_cols;
- min_rows = 2 * min_rows;
- }
-
/* The window manager uses the base width hints to calculate the
current number of rows and columns in the frame while
resizing; min_width and min_height aren't useful for this
purpose, since they might not give the dimensions for a
- zero-row, zero-column frame.
-
- We use the base_width and base_height members if we have
- them; otherwise, we set the min_width and min_height members
- to the size for a zero x zero frame. */
+ zero-row, zero-column frame. */
size_hints.flags |= PBaseSize;
size_hints.base_width = base_width;
size_hints.base_height = base_height + FRAME_MENUBAR_HEIGHT (f);
- size_hints.min_width = base_width + min_cols * FRAME_COLUMN_WIDTH (f);
- size_hints.min_height = base_height + min_rows * FRAME_LINE_HEIGHT (f);
+ size_hints.min_width = base_width;
+ size_hints.min_height = base_height;
}
/* If we don't need the old flags, we don't need the old hint at all. */