From: Martin Rudalics Date: Mon, 12 Jan 2015 07:18:00 +0000 (+0100) Subject: Adjust frame heights to real height of tool bar. X-Git-Tag: emacs-25.0.90~2603^2~26 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=fb35f1f715da1a931204894b132d7fb6eee0f361;p=emacs.git Adjust frame heights to real height of tool bar. * frame.el (frame-notice-user-settings): Remove code dealing with frame-initial-frame-tool-bar-height. Turn off `tool-bar-mode' only if `window-system-frame-alist' or `default-frame-alist' ask for it. (make-frame): Update frame-adjust-size-history if needed. * dispnew.c (change_frame_size_1): Pass Qchange_frame_size to adjust_frame_size. * frame.c (frame_default_tool_bar_height): New variable. (adjust_frame_size): Possibly add requested adjustment to Vframe_adjust_size_history. (make_frame): Initialize tool_bar_redisplayed_once slot. (Fset_frame_height, Fset_frame_width, Fset_frame_size): Clarify doc-string. Call adjust_frame_size unconditionally (the frame's text size may remain unaltered but the pixel size may change). (x_figure_window_size): If frame_default_tool_bar_height was set, use it instead of calculating the tool bar height from DEFAULT_TOOL_BAR_IMAGE_HEIGHT. Don't set Vframe_initial_frame_tool_bar_height. (Qchange_frame_size, Qxg_frame_set_char_size) (Qset_window_configuration, Qx_create_frame_1) (Qx_create_frame_2): New symbols. (Vframe_initial_frame_tool_bar_height): Remove. (Vframe_adjust_size_history): New history variable for debugging frame size adjustments. * frame.h (struct frame): New boolean slot tool_bar_redisplayed_once. (frame_default_tool_bar_height): Extern. * gtkutil.c (xg_frame_set_char_size): Pass Qxg_frame_set_char_size to adjust_frame_size. * nsfns.m (Fx_create_frame): Pass Pass Qx_create_frame_1 and Qx_create_frame_2 to adjust_frame_size. * w32fns.c (x_change_tool_bar_height): Call adjust_frame_size with inhibit 1 when we have not redisplayed the tool bar yet. (Fx_create_frame): Pass Pass Qx_create_frame_1 and Qx_create_frame_2 to adjust_frame_size. * w32menu.c (set_frame_menubar): Simplify adjust_frame_size call. * window.c (Fset_window_configuration): Pass Qset_window_configuration to adjust_frame_size. * xdisp.c (redisplay_tool_bar): Assign new height to frame_default_tool_bar_height. (redisplay_internal): If we haven't redisplayed this frame's tool bar, call redisplay_tool_bar early so we can adjust the frame size accordingly. * xfns.c (x_change_tool_bar_height): Call adjust_frame_size with inhibit 1 when we have not redisplayed the tool bar yet. (Fx_create_frame): Pass Pass Qx_create_frame_1 and Qx_create_frame_2 to adjust_frame_size. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 6a478537532..a55849ac1d3 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,11 @@ +2015-01-12 Martin Rudalics + + * frame.el (frame-notice-user-settings): Remove code dealing with + frame-initial-frame-tool-bar-height. Turn off `tool-bar-mode' + only if `window-system-frame-alist' or `default-frame-alist' ask + for it. + (make-frame): Update frame-adjust-size-history if needed. + 2015-01-12 Paul Eggert Have 'make' output better GEN names diff --git a/lisp/frame.el b/lisp/frame.el index 8b927309f0a..1d5bbf2317e 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -275,23 +275,22 @@ there (in decreasing order of priority)." ;; by the lines added in x-create-frame for the tool-bar and ;; switch `tool-bar-mode' off. (when (display-graphic-p) - (let ((tool-bar-lines - (or (assq 'tool-bar-lines initial-frame-alist) - (assq 'tool-bar-lines window-system-frame-alist) - (assq 'tool-bar-lines default-frame-alist)))) - ;; Shrink frame by its initial tool bar height iff either zero - ;; tool bar lines have been requested in one of the frame's - ;; alists or tool bar mode has been turned off explicitly in - ;; the user's init file. - (when (and tool-bar-lines - (> frame-initial-frame-tool-bar-height 0) - (or (not tool-bar-mode) - (null (cdr tool-bar-lines)) - (eq 0 (cdr tool-bar-lines)))) - (set-frame-height - frame-initial-frame (- (frame-text-height frame-initial-frame) - frame-initial-frame-tool-bar-height) - nil t) + (let* ((init-lines + (assq 'tool-bar-lines initial-frame-alist)) + (other-lines + (or (assq 'tool-bar-lines window-system-frame-alist) + (assq 'tool-bar-lines default-frame-alist))) + (lines (or init-lines other-lines)) + (height (tool-bar-height frame-initial-frame t))) + ;; Adjust frame top if either zero (nil) tool bar lines have + ;; been requested in the most relevant of the frame's alists + ;; or tool bar mode has been explicitly turned off in the + ;; user's init file. + (when (and (> height 0) + (or (and lines + (or (null (cdr lines)) + (eq 0 (cdr lines)))) + (not tool-bar-mode))) (let* ((initial-top (cdr (assq 'top frame-initial-geometry-arguments))) (top (frame-parameter frame-initial-frame 'top))) @@ -299,15 +298,19 @@ there (in decreasing order of priority)." (let ((adjusted-top (cond ((and (consp top) (eq '+ (car top))) - (list '+ (+ (cadr top) - frame-initial-frame-tool-bar-height))) + (list '+ (+ (cadr top) height))) ((and (consp top) (eq '- (car top))) - (list '- (- (cadr top) - frame-initial-frame-tool-bar-height))) - (t (+ top frame-initial-frame-tool-bar-height))))) + (list '- (- (cadr top) height))) + (t (+ top height))))) (modify-frame-parameters frame-initial-frame `((top . ,adjusted-top)))))) - (tool-bar-mode -1)))) + ;; Reset `tool-bar-mode' when zero tool bar lines have been + ;; requested for the window-system or default frame alists. + (when (and tool-bar-mode + (and other-lines + (or (null (cdr other-lines)) + (eq 0 (cdr other-lines))))) + (tool-bar-mode -1))))) ;; The initial frame we create above always has a minibuffer. ;; If the user wants to remove it, or make it a minibuffer-only @@ -682,6 +685,9 @@ the new frame according to its own rules." (push p params))) ;; Now make the frame. (run-hooks 'before-make-frame-hook) + +;; (setq frame-adjust-size-history '(t)) + (setq frame (funcall (gui-method frame-creation-function w) params)) (normal-erase-is-backspace-setup-frame frame) @@ -690,6 +696,12 @@ the new frame according to its own rules." (unless (assq param parameters) ;Overridden by explicit parameters. (let ((val (frame-parameter oldframe param))) (when val (set-frame-parameter frame param val))))) + + (when (eq (car frame-adjust-size-history) t) + (setq frame-adjust-size-history + (cons t (cons (list "Frame made") + (cdr frame-adjust-size-history))))) + (run-hook-with-args 'after-make-frame-functions frame) frame)) diff --git a/src/ChangeLog b/src/ChangeLog index 75e9ad51835..ea6274f11f1 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,49 @@ +2015-01-12 Martin Rudalics + + * dispnew.c (change_frame_size_1): Pass Qchange_frame_size to + adjust_frame_size. + * frame.c (frame_default_tool_bar_height): New variable. + (adjust_frame_size): Possibly add requested adjustment to + Vframe_adjust_size_history. + (make_frame): Initialize tool_bar_redisplayed_once slot. + (Fset_frame_height, Fset_frame_width, Fset_frame_size): Clarify + doc-string. Call adjust_frame_size unconditionally (the frame's + text size may remain unaltered but the pixel size may change). + (x_figure_window_size): If frame_default_tool_bar_height was + set, use it instead of calculating the tool bar height from + DEFAULT_TOOL_BAR_IMAGE_HEIGHT. Don't set + Vframe_initial_frame_tool_bar_height. + (Qchange_frame_size, Qxg_frame_set_char_size) + (Qset_window_configuration, Qx_create_frame_1) + (Qx_create_frame_2): New symbols. + (Vframe_initial_frame_tool_bar_height): Remove. + (Vframe_adjust_size_history): New history variable for debugging + frame size adjustments. + * frame.h (struct frame): New boolean slot + tool_bar_redisplayed_once. + (frame_default_tool_bar_height): Extern. + * gtkutil.c (xg_frame_set_char_size): Pass Qxg_frame_set_char_size + to adjust_frame_size. + * nsfns.m (Fx_create_frame): Pass Pass Qx_create_frame_1 and + Qx_create_frame_2 to adjust_frame_size. + * w32fns.c (x_change_tool_bar_height): Call adjust_frame_size with + inhibit 1 when we have not redisplayed the tool bar yet. + (Fx_create_frame): Pass Pass Qx_create_frame_1 and + Qx_create_frame_2 to adjust_frame_size. + * w32menu.c (set_frame_menubar): Simplify adjust_frame_size + call. + * window.c (Fset_window_configuration): Pass + Qset_window_configuration to adjust_frame_size. + * xdisp.c (redisplay_tool_bar): Assign new height to + frame_default_tool_bar_height. + (redisplay_internal): If we haven't redisplayed this frame's + tool bar, call redisplay_tool_bar early so we can adjust the + frame size accordingly. + * xfns.c (x_change_tool_bar_height): Call adjust_frame_size with + inhibit 1 when we have not redisplayed the tool bar yet. + (Fx_create_frame): Pass Pass Qx_create_frame_1 and + Qx_create_frame_2 to adjust_frame_size. + 2015-01-12 Paul Eggert Have 'make' output better GEN names diff --git a/src/dispnew.c b/src/dispnew.c index cefcd0809a0..a643d58e492 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -5523,7 +5523,8 @@ change_frame_size_1 (struct frame *f, int new_width, int new_height, /* Adjust frame size but make sure x_set_window_size does not get called. */ - adjust_frame_size (f, new_width, new_height, 5, pretend, Qnil); + adjust_frame_size (f, new_width, new_height, 5, pretend, + Qchange_frame_size); } } diff --git a/src/frame.c b/src/frame.c index 3d2ffbf624f..0eb51bd786c 100644 --- a/src/frame.c +++ b/src/frame.c @@ -67,6 +67,9 @@ static struct frame *last_nonminibuf_frame; /* False means there are no visible garbaged frames. */ bool frame_garbaged; +/* The default tool bar height for future frames. */ +int frame_default_tool_bar_height; + #ifdef HAVE_WINDOW_SYSTEM static void x_report_frame_params (struct frame *, Lisp_Object *); #endif @@ -358,6 +361,20 @@ adjust_frame_size (struct frame *f, int new_width, int new_height, int inhibit, Lisp_Object frame; XSETFRAME (frame, f); + + /* `make-frame' initializes Vframe_adjust_size_history to (Qt) and + strips its car when exiting. Just in case make sure its size never + exceeds 100. */ + if (!NILP (Fconsp (Vframe_adjust_size_history)) + && EQ (Fcar (Vframe_adjust_size_history), Qt) + && XFASTINT (Fsafe_length (Vframe_adjust_size_history)) <= 100) + Vframe_adjust_size_history = + Fcons (Qt, Fcons (list5 (make_number (0), + make_number (new_text_width), + make_number (new_text_height), + make_number (inhibit), parameter), + Fcdr (Vframe_adjust_size_history))); + /* The following two values are calculated from the old window body sizes and any "new" settings for scroll bars, dividers, fringes and margins (though the latter should have been processed already). */ @@ -425,6 +442,17 @@ adjust_frame_size (struct frame *f, int new_width, int new_height, int inhibit, else if (inhibit_vertical) new_text_height = old_text_height; + if (!NILP (Fconsp (Vframe_adjust_size_history)) + && EQ (Fcar (Vframe_adjust_size_history), Qt) + && XFASTINT (Fsafe_length (Vframe_adjust_size_history)) <= 100) + Vframe_adjust_size_history = + Fcons (Qt, Fcons (list5 (make_number (1), + make_number (new_text_width), + make_number (new_text_height), + make_number (new_cols), + make_number (new_lines)), + Fcdr (Vframe_adjust_size_history))); + x_set_window_size (f, 0, new_text_width, new_text_height, 1); f->resized_p = true; @@ -496,6 +524,17 @@ adjust_frame_size (struct frame *f, int new_width, int new_height, int inhibit, SET_FRAME_COLS (f, new_cols); SET_FRAME_LINES (f, new_lines); + if (!NILP (Fconsp (Vframe_adjust_size_history)) + && EQ (Fcar (Vframe_adjust_size_history), Qt) + && XFASTINT (Fsafe_length (Vframe_adjust_size_history)) <= 100) + Vframe_adjust_size_history = + Fcons (Qt, Fcons (list5 (make_number (2), + make_number (new_text_width), + make_number (new_text_height), + make_number (new_cols), + make_number (new_lines)), + Fcdr (Vframe_adjust_size_history))); + { struct window *w = XWINDOW (FRAME_SELECTED_WINDOW (f)); int text_area_x, text_area_y, text_area_width, text_area_height; @@ -554,6 +593,7 @@ make_frame (bool mini_p) f->garbaged = true; f->can_x_set_window_size = false; f->can_run_window_configuration_change_hook = false; + f->tool_bar_redisplayed_once = false; f->column_width = 1; /* !FRAME_WINDOW_P value. */ f->line_height = 1; /* !FRAME_WINDOW_P value. */ #ifdef HAVE_WINDOW_SYSTEM @@ -2808,7 +2848,7 @@ DEFUN ("frame-bottom-divider-width", Fbottom_divider_width, Sbottom_divider_widt } DEFUN ("set-frame-height", Fset_frame_height, Sset_frame_height, 2, 4, 0, - doc: /* Set height of frame FRAME to HEIGHT lines. + doc: /* Set text height of frame FRAME to HEIGHT lines. Optional third arg PRETEND non-nil means that redisplay should use HEIGHT lines but that the idea of the actual height of the frame should not be changed. @@ -2827,14 +2867,13 @@ multiple of the default frame font height. */) pixel_height = (!NILP (pixelwise) ? XINT (height) : XINT (height) * FRAME_LINE_HEIGHT (f)); - if (pixel_height != FRAME_TEXT_HEIGHT (f)) - adjust_frame_size (f, -1, pixel_height, 1, !NILP (pretend), Qheight); + adjust_frame_size (f, -1, pixel_height, 1, !NILP (pretend), Qheight); return Qnil; } DEFUN ("set-frame-width", Fset_frame_width, Sset_frame_width, 2, 4, 0, - doc: /* Set width of frame FRAME to WIDTH columns. + doc: /* Set text width of frame FRAME to WIDTH columns. Optional third arg PRETEND non-nil means that redisplay should use WIDTH columns but that the idea of the actual width of the frame should not be changed. @@ -2853,14 +2892,13 @@ multiple of the default frame font width. */) pixel_width = (!NILP (pixelwise) ? XINT (width) : XINT (width) * FRAME_COLUMN_WIDTH (f)); - if (pixel_width != FRAME_TEXT_WIDTH (f)) - adjust_frame_size (f, pixel_width, -1, 1, !NILP (pretend), Qwidth); + adjust_frame_size (f, pixel_width, -1, 1, !NILP (pretend), Qwidth); return Qnil; } DEFUN ("set-frame-size", Fset_frame_size, Sset_frame_size, 3, 4, 0, - doc: /* Set size of FRAME to WIDTH by HEIGHT, measured in characters. + doc: /* Set text size of FRAME to WIDTH by HEIGHT, measured in characters. Optional argument PIXELWISE non-nil means to measure in pixels. Note: When `frame-resize-pixelwise' is nil, some window managers may refuse to honor a WIDTH that is not an integer multiple of the default frame font @@ -2880,10 +2918,7 @@ font height. */) pixel_height = (!NILP (pixelwise) ? XINT (height) : XINT (height) * FRAME_LINE_HEIGHT (f)); - - if (pixel_width != FRAME_TEXT_WIDTH (f) - || pixel_height != FRAME_TEXT_HEIGHT (f)) - adjust_frame_size (f, pixel_width, pixel_height, 1, 0, Qsize); + adjust_frame_size (f, pixel_width, pixel_height, 1, 0, Qsize); return Qnil; } @@ -4492,23 +4527,27 @@ x_figure_window_size (struct frame *f, Lisp_Object parms, bool toolbar_p) frames without having to guess how tall the tool bar will get. */ if (toolbar_p && FRAME_TOOL_BAR_LINES (f)) { - int margin, relief; + if (frame_default_tool_bar_height) + FRAME_TOOL_BAR_HEIGHT (f) = frame_default_tool_bar_height; + else + { + int margin, relief; - relief = (tool_bar_button_relief >= 0 - ? tool_bar_button_relief - : DEFAULT_TOOL_BAR_BUTTON_RELIEF); + relief = (tool_bar_button_relief >= 0 + ? tool_bar_button_relief + : DEFAULT_TOOL_BAR_BUTTON_RELIEF); - if (RANGED_INTEGERP (1, Vtool_bar_button_margin, INT_MAX)) - margin = XFASTINT (Vtool_bar_button_margin); - else if (CONSP (Vtool_bar_button_margin) - && RANGED_INTEGERP (1, XCDR (Vtool_bar_button_margin), INT_MAX)) - margin = XFASTINT (XCDR (Vtool_bar_button_margin)); - else - margin = 0; + if (RANGED_INTEGERP (1, Vtool_bar_button_margin, INT_MAX)) + margin = XFASTINT (Vtool_bar_button_margin); + else if (CONSP (Vtool_bar_button_margin) + && RANGED_INTEGERP (1, XCDR (Vtool_bar_button_margin), INT_MAX)) + margin = XFASTINT (XCDR (Vtool_bar_button_margin)); + else + margin = 0; - FRAME_TOOL_BAR_HEIGHT (f) - = DEFAULT_TOOL_BAR_IMAGE_HEIGHT + 2 * margin + 2 * relief; - Vframe_initial_frame_tool_bar_height = make_number (FRAME_TOOL_BAR_HEIGHT (f)); + FRAME_TOOL_BAR_HEIGHT (f) + = DEFAULT_TOOL_BAR_IMAGE_HEIGHT + 2 * margin + 2 * relief; + } } top = x_get_arg (dpyinfo, parms, Qtop, 0, 0, RES_TYPE_NUMBER); @@ -4779,6 +4818,11 @@ syms_of_frame (void) DEFSYM (Qtool_bar_external, "tool-bar-external"); DEFSYM (Qtool_bar_size, "tool-bar-size"); DEFSYM (Qframe_inner_size, "frame-inner-size"); + DEFSYM (Qchange_frame_size, "change-frame-size"); + DEFSYM (Qxg_frame_set_char_size, "xg-frame-set-char-size"); + DEFSYM (Qset_window_configuration, "set-window-configuration"); + DEFSYM (Qx_create_frame_1, "x-create-frame-1"); + DEFSYM (Qx_create_frame_2, "x-create-frame-2"); #ifdef HAVE_NS DEFSYM (Qns_parse_geometry, "ns-parse-geometry"); @@ -4968,10 +5012,6 @@ or call the function `tool-bar-mode'. */); Vtool_bar_mode = Qnil; #endif - DEFVAR_LISP ("frame-initial-frame-tool-bar-height", Vframe_initial_frame_tool_bar_height, - doc: /* Height of tool bar of initial frame. */); - Vframe_initial_frame_tool_bar_height = make_number (0); - DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame, doc: /* Minibufferless frames use this frame's minibuffer. Emacs cannot create minibufferless frames unless this is set to an @@ -5050,6 +5090,10 @@ even if this option is non-nil. */); frame_inhibit_implied_resize = Qt; #endif + DEFVAR_LISP ("frame-adjust-size-history", Vframe_adjust_size_history, + doc: /* History of frame size adjustments. */); + Vframe_adjust_size_history = Qnil; + staticpro (&Vframe_list); defsubr (&Sframep); diff --git a/src/frame.h b/src/frame.h index d1ed4d4a67e..cb0044cfe23 100644 --- a/src/frame.h +++ b/src/frame.h @@ -336,6 +336,10 @@ struct frame for this frame. */ bool_bf can_run_window_configuration_change_hook : 1; + /* True means tool bar has been redisplayed at least once in current + session. */ + bool_bf tool_bar_redisplayed_once : 1; + /* Bitfield area ends here. */ /* Number of lines (rounded up) of tool bar. REMOVE THIS */ @@ -1096,6 +1100,8 @@ SET_FRAME_VISIBLE (struct frame *f, int v) extern Lisp_Object selected_frame; +extern int frame_default_tool_bar_height; + extern struct frame *decode_window_system_frame (Lisp_Object); extern struct frame *decode_live_frame (Lisp_Object); extern struct frame *decode_any_frame (Lisp_Object); diff --git a/src/gtkutil.c b/src/gtkutil.c index bedac8451e2..694278a2b4c 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -954,7 +954,7 @@ xg_frame_set_char_size (struct frame *f, int width, int height) x_wait_for_event (f, ConfigureNotify); } else - adjust_frame_size (f, -1, -1, 5, 0, Qnil); + adjust_frame_size (f, -1, -1, 5, 0, Qxg_frame_set_char_size); } /* Handle height/width changes (i.e. add/remove/move menu/toolbar). diff --git a/src/nsfns.m b/src/nsfns.m index 828ee88e635..cc2e49641e8 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -1251,7 +1251,8 @@ This function is an internal primitive--use `make-frame' instead. */) /* Read comment about this code in corresponding place in xfns.c. */ adjust_frame_size (f, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f), - FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), 5, 1, Qnil); + FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), 5, 1, + Qx_create_frame_1); /* The resources controlling the menu-bar and tool-bar are processed specially at startup, and reflected in the mode @@ -1325,7 +1326,8 @@ This function is an internal primitive--use `make-frame' instead. */) /* Allow x_set_window_size, now. */ f->can_x_set_window_size = true; - adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), 0, 1, Qnil); + adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), 0, 1, + Qx_create_frame_2); if (! f->output_data.ns->explicit_parent) { diff --git a/src/w32fns.c b/src/w32fns.c index 789a91a3c96..3b8346a07fd 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -1744,8 +1744,11 @@ x_change_tool_bar_height (struct frame *f, int height) /* Recalculate toolbar height. */ f->n_tool_bar_rows = 0; - adjust_frame_size (f, -1, -1, (old_height == 0 || height == 0) ? 2 : 4, 0, - Qtool_bar_lines); + adjust_frame_size (f, -1, -1, + (!f->tool_bar_redisplayed_once ? 1 + : (old_height == 0 || height == 0) ? 2 + : 4), + 0, Qtool_bar_lines); /* adjust_frame_size might not have done anything, garbage frame here. */ @@ -4617,7 +4620,8 @@ This function is an internal primitive--use `make-frame' instead. */) had one frame line vs one toolbar line which left us with a zero root window height which was obviously wrong as well ... */ adjust_frame_size (f, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f), - FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), 5, 1, Qnil); + FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), 5, 1, + Qx_create_frame_1); /* The X resources controlling the menu-bar and tool-bar are processed specially at startup, and reflected in the mode @@ -4685,7 +4689,8 @@ This function is an internal primitive--use `make-frame' instead. */) /* Allow x_set_window_size, now. */ f->can_x_set_window_size = true; - adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), 0, 1, Qnil); + adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), 0, 1, + Qx_create_frame_2); /* Tell the server what size and position, etc, we want, and how badly we want them. This should be done after we have the menu diff --git a/src/w32menu.c b/src/w32menu.c index 7a946d2dc75..a65e399ba5b 100644 --- a/src/w32menu.c +++ b/src/w32menu.c @@ -501,8 +501,7 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p) /* Force the window size to be recomputed so that the frame's text area remains the same, if menubar has just been created. */ if (old_widget == NULL) - adjust_frame_size (f, FRAME_TEXT_WIDTH (f), - FRAME_TEXT_HEIGHT (f), 2, 0, Qmenu_bar_lines); + adjust_frame_size (f, -1, -1, 2, 0, Qmenu_bar_lines); } unblock_input (); diff --git a/src/window.c b/src/window.c index 1d2221fd9b2..5ae95f27d64 100644 --- a/src/window.c +++ b/src/window.c @@ -6421,7 +6421,7 @@ the return value is nil. Otherwise the value is t. */) /* Allow x_set_window_size again and apply frame size changes if needed. */ f->can_x_set_window_size = true; - adjust_frame_size (f, -1, -1, 1, 0, Qnil); + adjust_frame_size (f, -1, -1, 1, 0, Qset_window_configuration); adjust_frame_glyphs (f); unblock_input (); diff --git a/src/xdisp.c b/src/xdisp.c index 31702ed4135..f006f8e0b94 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -12352,6 +12352,7 @@ redisplay_tool_bar (struct frame *f) if (new_height != WINDOW_PIXEL_HEIGHT (w)) { x_change_tool_bar_height (f, new_height); + frame_default_tool_bar_height = new_height; /* Always do that now. */ clear_glyph_matrix (w->desired_matrix); f->fonts_changed = 1; @@ -12446,6 +12447,7 @@ redisplay_tool_bar (struct frame *f) if (change_height_p) { x_change_tool_bar_height (f, new_height); + frame_default_tool_bar_height = new_height; clear_glyph_matrix (w->desired_matrix); f->n_tool_bar_rows = nrows; f->fonts_changed = 1; @@ -13775,6 +13777,17 @@ redisplay_internal (void) retry_frame: +#if defined (HAVE_WINDOW_SYSTEM) && !defined (USE_GTK) && !defined (HAVE_NS) + /* Redisplay internal tool bar if this is the first time so we + can adjust the frame height right now, if necessary. */ + if (!f->tool_bar_redisplayed_once) + { + if (redisplay_tool_bar (f)) + adjust_frame_glyphs (f); + f->tool_bar_redisplayed_once = true; + } +#endif + if (FRAME_WINDOW_P (f) || FRAME_TERMCAP_P (f) || f == sf) { bool gcscrollbars diff --git a/src/xfns.c b/src/xfns.c index 4a417526dcd..936c769a2de 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -1130,8 +1130,11 @@ x_change_tool_bar_height (struct frame *f, int height) /* Recalculate toolbar height. */ f->n_tool_bar_rows = 0; - adjust_frame_size (f, -1, -1, (old_height == 0 || height == 0) ? 2 : 4, 0, - Qtool_bar_lines); + adjust_frame_size (f, -1, -1, + (!f->tool_bar_redisplayed_once ? 1 + : (old_height == 0 || height == 0) ? 2 + : 4), + 0, Qtool_bar_lines); /* adjust_frame_size might not have done anything, garbage frame here. */ @@ -3160,7 +3163,8 @@ This function is an internal primitive--use `make-frame' instead. */) had one frame line vs one toolbar line which left us with a zero root window height which was obviously wrong as well ... */ adjust_frame_size (f, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f), - FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), 5, 1, Qnil); + FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), 5, 1, + Qx_create_frame_1); /* Set the menu-bar-lines and tool-bar-lines parameters. We don't look up the X resources controlling the menu-bar and tool-bar @@ -3234,7 +3238,8 @@ This function is an internal primitive--use `make-frame' instead. */) /* Consider frame official, now. */ f->can_x_set_window_size = true; - adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), 0, 1, Qnil); + adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), 0, 1, + Qx_create_frame_2); #if defined (USE_X_TOOLKIT) || defined (USE_GTK) /* Create the menu bar. */