aboutsummaryrefslogtreecommitdiffstats
path: root/src/xterm.c
diff options
context:
space:
mode:
authorMartin Rudalics2015-10-13 12:11:43 +0200
committerMartin Rudalics2015-10-13 12:11:43 +0200
commitd4fe840df0b5fdb3aed538fae2ced143a471f60a (patch)
tree13ff9d7115616a99af7e0257277a1ca6edf31f72 /src/xterm.c
parente53e1a0426539aa3f2902632fdd8025da8f710f2 (diff)
downloademacs-d4fe840df0b5fdb3aed538fae2ced143a471f60a.tar.gz
emacs-d4fe840df0b5fdb3aed538fae2ced143a471f60a.zip
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)
9579{ 9579{
9580 struct font *font = XFONT_OBJECT (font_object); 9580 struct font *font = XFONT_OBJECT (font_object);
9581 int unit, font_ascent, font_descent; 9581 int unit, font_ascent, font_descent;
9582#ifndef USE_X_TOOLKIT
9583 int old_menu_bar_height = FRAME_MENU_BAR_HEIGHT (f);
9584 Lisp_Object fullscreen;
9585#endif
9582 9586
9583 if (fontset < 0) 9587 if (fontset < 0)
9584 fontset = fontset_from_font (font_object); 9588 fontset = fontset_from_font (font_object);
@@ -9615,9 +9619,25 @@ x_new_font (struct frame *f, Lisp_Object font_object, int fontset)
9615 doing it because it's done in Fx_show_tip, and it leads to 9619 doing it because it's done in Fx_show_tip, and it leads to
9616 problems because the tip frame has no widget. */ 9620 problems because the tip frame has no widget. */
9617 if (NILP (tip_frame) || XFRAME (tip_frame) != f) 9621 if (NILP (tip_frame) || XFRAME (tip_frame) != f)
9622 {
9618 adjust_frame_size (f, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f), 9623 adjust_frame_size (f, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f),
9619 FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), 3, 9624 FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), 3,
9620 false, Qfont); 9625 false, Qfont);
9626#ifndef USE_X_TOOLKIT
9627 if (FRAME_MENU_BAR_HEIGHT (f) != old_menu_bar_height
9628 && !f->after_make_frame
9629 && (EQ (frame_inhibit_implied_resize, Qt)
9630 || (CONSP (frame_inhibit_implied_resize)
9631 && NILP (Fmemq (Qfont, frame_inhibit_implied_resize))))
9632 && (NILP (fullscreen = get_frame_param (f, Qfullscreen))
9633 || EQ (fullscreen, Qfullwidth)))
9634 /* If the menu bar height changes, try to keep text height
9635 constant. */
9636 adjust_frame_size
9637 (f, -1, FRAME_TEXT_HEIGHT (f) + FRAME_MENU_BAR_HEIGHT (f)
9638 - old_menu_bar_height, 1, false, Qfont);
9639#endif /* USE_X_TOOLKIT */
9640 }
9621 } 9641 }
9622 9642
9623#ifdef HAVE_X_I18N 9643#ifdef HAVE_X_I18N
@@ -10549,7 +10569,7 @@ x_set_window_size_1 (struct frame *f, bool change_gravity,
10549 if (EQ (fullscreen, Qfullwidth) && width == FRAME_TEXT_WIDTH (f)) 10569 if (EQ (fullscreen, Qfullwidth) && width == FRAME_TEXT_WIDTH (f))
10550 { 10570 {
10551 frame_size_history_add 10571 frame_size_history_add
10552 (f, Qxg_frame_set_char_size_1, width, height, 10572 (f, Qx_set_window_size_1, width, height,
10553 list2 (make_number (old_height), 10573 list2 (make_number (old_height),
10554 make_number (pixelheight + FRAME_MENUBAR_HEIGHT (f)))); 10574 make_number (pixelheight + FRAME_MENUBAR_HEIGHT (f))));
10555 10575
@@ -10559,7 +10579,7 @@ x_set_window_size_1 (struct frame *f, bool change_gravity,
10559 else if (EQ (fullscreen, Qfullheight) && height == FRAME_TEXT_HEIGHT (f)) 10579 else if (EQ (fullscreen, Qfullheight) && height == FRAME_TEXT_HEIGHT (f))
10560 { 10580 {
10561 frame_size_history_add 10581 frame_size_history_add
10562 (f, Qxg_frame_set_char_size_2, width, height, 10582 (f, Qx_set_window_size_2, width, height,
10563 list2 (make_number (old_width), make_number (pixelwidth))); 10583 list2 (make_number (old_width), make_number (pixelwidth)));
10564 10584
10565 XResizeWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), 10585 XResizeWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
@@ -10569,10 +10589,11 @@ x_set_window_size_1 (struct frame *f, bool change_gravity,
10569 else 10589 else
10570 { 10590 {
10571 frame_size_history_add 10591 frame_size_history_add
10572 (f, Qxg_frame_set_char_size_3, width, height, 10592 (f, Qx_set_window_size_3, width, height,
10573 list2 (make_number (pixelwidth + FRAME_TOOLBAR_WIDTH (f)), 10593 list3 (make_number (pixelwidth + FRAME_TOOLBAR_WIDTH (f)),
10574 make_number (pixelheight + FRAME_TOOLBAR_HEIGHT (f) 10594 make_number (pixelheight + FRAME_TOOLBAR_HEIGHT (f)
10575 + FRAME_MENUBAR_HEIGHT (f)))); 10595 + FRAME_MENUBAR_HEIGHT (f)),
10596 make_number (FRAME_MENUBAR_HEIGHT (f))));
10576 10597
10577 XResizeWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), 10598 XResizeWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
10578 pixelwidth, pixelheight + FRAME_MENUBAR_HEIGHT (f)); 10599 pixelwidth, pixelheight + FRAME_MENUBAR_HEIGHT (f));
@@ -11342,8 +11363,8 @@ x_wm_set_size_hint (struct frame *f, long flags, bool user_position)
11342 size_hints.x = f->left_pos; 11363 size_hints.x = f->left_pos;
11343 size_hints.y = f->top_pos; 11364 size_hints.y = f->top_pos;
11344 11365
11345 size_hints.height = FRAME_PIXEL_HEIGHT (f);
11346 size_hints.width = FRAME_PIXEL_WIDTH (f); 11366 size_hints.width = FRAME_PIXEL_WIDTH (f);
11367 size_hints.height = FRAME_PIXEL_HEIGHT (f);
11347 11368
11348 size_hints.width_inc = frame_resize_pixelwise ? 1 : FRAME_COLUMN_WIDTH (f); 11369 size_hints.width_inc = frame_resize_pixelwise ? 1 : FRAME_COLUMN_WIDTH (f);
11349 size_hints.height_inc = frame_resize_pixelwise ? 1 : FRAME_LINE_HEIGHT (f); 11370 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)
11356 /* Calculate the base and minimum sizes. */ 11377 /* Calculate the base and minimum sizes. */
11357 { 11378 {
11358 int base_width, base_height; 11379 int base_width, base_height;
11359 int min_rows = 0, min_cols = 0;
11360 11380
11361 base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0); 11381 base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0);
11362 base_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 0); 11382 base_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 0);
11363 11383
11364 if (frame_resize_pixelwise)
11365 /* Needed to prevent a bad protocol error crash when making the
11366 frame size very small. */
11367 {
11368 min_cols = 2 * min_cols;
11369 min_rows = 2 * min_rows;
11370 }
11371
11372 /* The window manager uses the base width hints to calculate the 11384 /* The window manager uses the base width hints to calculate the
11373 current number of rows and columns in the frame while 11385 current number of rows and columns in the frame while
11374 resizing; min_width and min_height aren't useful for this 11386 resizing; min_width and min_height aren't useful for this
11375 purpose, since they might not give the dimensions for a 11387 purpose, since they might not give the dimensions for a
11376 zero-row, zero-column frame. 11388 zero-row, zero-column frame. */
11377
11378 We use the base_width and base_height members if we have
11379 them; otherwise, we set the min_width and min_height members
11380 to the size for a zero x zero frame. */
11381 11389
11382 size_hints.flags |= PBaseSize; 11390 size_hints.flags |= PBaseSize;
11383 size_hints.base_width = base_width; 11391 size_hints.base_width = base_width;
11384 size_hints.base_height = base_height + FRAME_MENUBAR_HEIGHT (f); 11392 size_hints.base_height = base_height + FRAME_MENUBAR_HEIGHT (f);
11385 size_hints.min_width = base_width + min_cols * FRAME_COLUMN_WIDTH (f); 11393 size_hints.min_width = base_width;
11386 size_hints.min_height = base_height + min_rows * FRAME_LINE_HEIGHT (f); 11394 size_hints.min_height = base_height;
11387 } 11395 }
11388 11396
11389 /* If we don't need the old flags, we don't need the old hint at all. */ 11397 /* If we don't need the old flags, we don't need the old hint at all. */