From f2e7e9af1e1f24763e1b2b74efdc79b0aa276c22 Mon Sep 17 00:00:00 2001 From: Martin Rudalics Date: Thu, 11 Nov 2010 19:13:43 +0100 Subject: [PATCH] Fix a bug in and rewrite resize_frame_windows. * window.c (syms_of_window): Add Qsafe and intern it. (resize_frame_windows): Check whether the actual new size of the root window matches the requested size. Also try one more round with safe minimum sizes. Simplify code. --- src/ChangeLog | 7 ++++++ src/window.c | 67 +++++++++++++++++++++++++++------------------------ 2 files changed, 43 insertions(+), 31 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index f0fec85e73f..1a674850708 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2010-11-11 Martin Rudalics + + * window.c (syms_of_window): Add Qsafe and intern it. + (resize_frame_windows): Check whether the actual new size of the + root window matches the requested size. Also try one more round + with safe minimum sizes. Simplify code. + 2010-11-10 Martin Rudalics * window.c (syms_of_window): New variable diff --git a/src/window.c b/src/window.c index 2f3e617409c..dd2302b003b 100644 --- a/src/window.c +++ b/src/window.c @@ -57,7 +57,7 @@ Lisp_Object Qreplace_buffer_in_windows, Qget_mru_window; Lisp_Object Qrecord_window_buffer; Lisp_Object Qresize_root_window, Qresize_root_window_vertically; Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command; -Lisp_Object Qset, Qabove, Qbelow, Qnest, Qgroup, Qresize; +Lisp_Object Qset, Qsafe, Qabove, Qbelow, Qnest, Qgroup, Qresize; static int displayed_window_lines (struct window *); static struct window *decode_window (Lisp_Object); @@ -3600,55 +3600,57 @@ resize_frame_windows (struct frame *f, int size, int horflag) struct window *r = XWINDOW (root); Lisp_Object mini = f->minibuffer_window; struct window *m; + /* new_size is the new size of the frame's root window. */ + int new_size = (horflag + ? size + : (size + - FRAME_TOP_MARGIN (f) + - ((FRAME_HAS_MINIBUF_P (f) && !FRAME_MINIBUF_ONLY_P (f)) + ? 1 : 0))); XSETFASTINT (r->top_line, FRAME_TOP_MARGIN (f)); - if (NILP (r->vchild) && NILP (r->hchild)) /* For a leaf root window just set the size. */ if (horflag) - XSETFASTINT (r->total_cols, size); + XSETFASTINT (r->total_cols, new_size); else - XSETFASTINT (r->total_lines, - /* Take menubar, toolbar, and minibuffer into account. */ - size - - FRAME_TOP_MARGIN (f) - - ((FRAME_HAS_MINIBUF_P (f) && !FRAME_MINIBUF_ONLY_P (f)) - ? 1 : 0)); + XSETFASTINT (r->total_lines, new_size); else { + /* old_size is the old size of the frame's root window. */ + int old_size = XFASTINT (horflag ? r->total_cols : r->total_lines); Lisp_Object delta; - if (horflag) - XSETINT (delta, size - XINT (r->total_cols)); - else - { - /* Take menubar, toolbar, and minibuffer into account. */ - XSETINT (delta, - size - - FRAME_TOP_MARGIN (f) - - ((FRAME_HAS_MINIBUF_P (f) && !FRAME_MINIBUF_ONLY_P (f)) - ? 1 : 0) - - XINT (r->total_lines)); - - size = size - 1; - } - + XSETINT (delta, new_size - old_size); + /* Try a "normal" resize first. */ resize_root_window (root, delta, horflag ? Qt : Qnil, Qnil); - if (resize_window_check (r, horflag)) + if (resize_window_check (r, horflag) && new_size == XINT (r->new_total)) resize_window_apply (r, horflag); else { + /* Try with "reasonable" minimum sizes next. */ resize_root_window (root, delta, horflag ? Qt : Qnil, Qt); - if (resize_window_check (r, horflag)) + if (resize_window_check (r, horflag) + && new_size == XINT (r->new_total)) resize_window_apply (r, horflag); else { - root = f->selected_window; - Fdelete_other_windows_internal (root, Qnil); - if (horflag) - XSETFASTINT (r->total_cols, size); + /* Finally, try with "safe" minimum sizes. */ + resize_root_window (root, delta, horflag ? Qt : Qnil, Qsafe); + if (resize_window_check (r, horflag) + && new_size == XINT (r->new_total)) + resize_window_apply (r, horflag); else - XSETFASTINT (r->total_lines, size); + { + /* We lost. Delete all windows but the frame's + selected one. */ + root = f->selected_window; + Fdelete_other_windows_internal (root, Qnil); + if (horflag) + XSETFASTINT (XWINDOW (root)->total_cols, new_size); + else + XSETFASTINT (XWINDOW (root)->total_lines, new_size); + } } } } @@ -6473,6 +6475,9 @@ syms_of_window (void) Qset = intern_c_string ("set"); staticpro (&Qset); + Qsafe = intern_c_string ("safe"); + staticpro (&Qsafe); + Qdisplay_buffer = intern_c_string ("display-buffer"); staticpro (&Qdisplay_buffer); -- 2.39.5