From: Dmitry Antipov Date: Thu, 24 Jul 2014 05:49:14 +0000 (+0400) Subject: Fix error reported by Angelo Graziosi in X-Git-Tag: emacs-25.0.90~2636^3~49 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d6a393dd19e89519e96025168c4bf06a2d93f23d;p=emacs.git Fix error reported by Angelo Graziosi in and complete previous change. * frame.c (adjust_frame_height): New function. (Fset_frame_height, Fset_frame_size): Use it. (x_set_frame_parameters): Take frame top margin into account. --- diff --git a/src/ChangeLog b/src/ChangeLog index 51d77283ffd..f5ef9cedf28 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2014-07-24 Dmitry Antipov + + Fix error reported by Angelo Graziosi in + + and complete previous change. + * frame.c (adjust_frame_height): New function. + (Fset_frame_height, Fset_frame_size): Use it. + (x_set_frame_parameters): Take frame top margin into account. + 2014-07-23 Dmitry Antipov * frame.c (Fset_frame_height): Take frame top margin into account. diff --git a/src/frame.c b/src/frame.c index e68a3db24ea..80046bee788 100644 --- a/src/frame.c +++ b/src/frame.c @@ -2565,7 +2565,21 @@ DEFUN ("frame-bottom-divider-width", Fbottom_divider_width, Sbottom_divider_widt { return make_number (FRAME_BOTTOM_DIVIDER_WIDTH (decode_any_frame (frame))); } - + +/* For requested height in *HEIGHTP, calculate new height of frame F in + character units and return true if actual height should be changed. */ + +static bool +adjust_frame_height (struct frame *f, int *heightp) +{ + if (FRAME_LINES (f) - FRAME_TOP_MARGIN (f) != *heightp) + { + *heightp += FRAME_TOP_MARGIN (f); + return 1; + } + return 0; +} + DEFUN ("set-frame-height", Fset_frame_height, Sset_frame_height, 2, 4, 0, doc: /* Specify that the frame FRAME has HEIGHT text lines. Optional third arg PRETEND non-nil means that redisplay should use @@ -2584,9 +2598,10 @@ FRAME should be HEIGHT pixels high. */) { if (NILP (pixelwise)) { - if (FRAME_LINES (f) - FRAME_TOP_MARGIN (f) != XINT (height)) - x_set_window_size (f, 1, FRAME_COLS (f), - XINT (height) + FRAME_TOP_MARGIN (f), 0); + int h = XINT (height); + + if (adjust_frame_height (f, &h)) + x_set_window_size (f, 1, FRAME_COLS (f), h, 0); do_pending_window_change (0); } @@ -2653,15 +2668,17 @@ Optional argument PIXELWISE non-nil means to measure in pixels. */) #ifdef HAVE_WINDOW_SYSTEM if (FRAME_WINDOW_P (f)) { + int h = XINT (height); + if (!NILP (pixelwise) ? (XINT (width) != FRAME_TEXT_WIDTH (f) - || XINT (height) != FRAME_TEXT_HEIGHT (f) + || h != FRAME_TEXT_HEIGHT (f) || f->new_height || f->new_width) - : (XINT (width) != FRAME_COLS (f) - || XINT (height) != FRAME_LINES (f) + : (adjust_frame_height (f, &h) + || XINT (width) != FRAME_COLS (f) || f->new_height || f->new_width)) { - x_set_window_size (f, 1, XINT (width), XINT (height), + x_set_window_size (f, 1, XINT (width), h, NILP (pixelwise) ? 0 : 1); do_pending_window_change (0); } @@ -2865,7 +2882,9 @@ x_set_frame_parameters (struct frame *f, Lisp_Object alist) else if (EQ (prop, Qheight) && RANGED_INTEGERP (0, val, INT_MAX)) { height_change = 1; - height = XFASTINT (val) * FRAME_LINE_HEIGHT (f); + /* Add menu and tool bar lines to correctly resize F pixelwise. */ + height + = (XFASTINT (val) + FRAME_TOP_MARGIN (f)) * FRAME_LINE_HEIGHT (f); } else if (EQ (prop, Qtop)) top = val;