[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 5db4ec20fe: Fix tab-bar resizing under 'auto-resize-tab-bars' = '
From: |
Eli Zaretskii |
Subject: |
master 5db4ec20fe: Fix tab-bar resizing under 'auto-resize-tab-bars' = 'grow-only' |
Date: |
Sun, 17 Jul 2022 05:34:52 -0400 (EDT) |
branch: master
commit 5db4ec20fe4b428e15aa53208c9a9bfb037c0f30
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>
Fix tab-bar resizing under 'auto-resize-tab-bars' = 'grow-only'
* src/xdisp.c (redisplay_tab_bar): Compute the desired height of
the tab-bar before iterating over the tab-bar string, to detect
the required resizing earlier. Default 'change_p' to 'false'.
* lisp/tab-bar.el (tab-bar--update-tab-bar-lines): Support
'auto-resize-tab-bars' set to 'grow-only'.
---
lisp/tab-bar.el | 4 +++-
src/xdisp.c | 50 ++++++++++++++++++++++++++++++--------------------
2 files changed, 33 insertions(+), 21 deletions(-)
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index c769dbabce..1a3f35891e 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -200,7 +200,9 @@ a list of frames to update."
(t frames))))
;; Loop over all frames and update `tab-bar-lines'
(dolist (frame frame-lst)
- (unless (frame-parameter frame 'tab-bar-lines-keep-state)
+ (unless (or (frame-parameter frame 'tab-bar-lines-keep-state)
+ (and (eq auto-resize-tab-bars 'grow-only)
+ (> (frame-parameter frame 'tab-bar-lines) 1)))
(set-frame-parameter frame 'tab-bar-lines
(tab-bar--tab-bar-lines-for-frame frame)))))
;; Update `default-frame-alist'
diff --git a/src/xdisp.c b/src/xdisp.c
index 842277039d..c0ef15f218 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -14054,15 +14054,41 @@ redisplay_tab_bar (struct frame *f)
return false;
}
+ /* Build a string that represents the contents of the tab-bar. */
+ build_desired_tab_bar_string (f);
+
+ int new_nrows;
+ int new_height = tab_bar_height (f, &new_nrows, true);
+
+ if (f->n_tab_bar_rows == 0)
+ {
+ f->n_tab_bar_rows = new_nrows;
+ if (new_height != WINDOW_PIXEL_HEIGHT (w))
+ frame_default_tab_bar_height = new_height;
+ }
+
+ /* If new_height or new_nrows indicate that we need to enlarge the
+ tab-bar window, we can return right away. */
+ if (new_nrows > f->n_tab_bar_rows
+ || (EQ (Vauto_resize_tab_bars, Qgrow_only)
+ && !f->minimize_tab_bar_window_p
+ && new_height > WINDOW_PIXEL_HEIGHT (w)))
+ {
+ if (FRAME_TERMINAL (f)->change_tab_bar_height_hook)
+ FRAME_TERMINAL (f)->change_tab_bar_height_hook (f, new_height);
+ if (new_nrows != f->n_tab_bar_rows)
+ f->n_tab_bar_rows = new_nrows;
+ clear_glyph_matrix (w->desired_matrix);
+ f->fonts_changed = true;
+ return true;
+ }
+
/* Set up an iterator for the tab-bar window. */
init_iterator (&it, w, -1, -1, w->desired_matrix->rows, TAB_BAR_FACE_ID);
it.first_visible_x = 0;
it.last_visible_x = WINDOW_PIXEL_WIDTH (w);
row = it.glyph_row;
row->reversed_p = false;
-
- /* Build a string that represents the contents of the tab-bar. */
- build_desired_tab_bar_string (f);
reseat_to_string (&it, NULL, f->desired_tab_bar_string, 0, 0, 0,
STRING_MULTIBYTE (f->desired_tab_bar_string));
/* FIXME: This should be controlled by a user option. But it
@@ -14074,22 +14100,6 @@ redisplay_tab_bar (struct frame *f)
do. */
it.paragraph_embedding = L2R;
- if (f->n_tab_bar_rows == 0)
- {
- int new_height = tab_bar_height (f, &f->n_tab_bar_rows, true);
-
- if (new_height != WINDOW_PIXEL_HEIGHT (w))
- {
- if (FRAME_TERMINAL (f)->change_tab_bar_height_hook)
- FRAME_TERMINAL (f)->change_tab_bar_height_hook (f, new_height);
- frame_default_tab_bar_height = new_height;
- /* Always do that now. */
- clear_glyph_matrix (w->desired_matrix);
- f->fonts_changed = true;
- return true;
- }
- }
-
/* Display as many lines as needed to display all tab-bar items. */
if (f->n_tab_bar_rows > 0)
@@ -14135,7 +14145,7 @@ redisplay_tab_bar (struct frame *f)
if (!NILP (Vauto_resize_tab_bars))
{
- bool change_height_p = true;
+ bool change_height_p = false;
/* If we couldn't display everything, change the tab-bar's
height if there is room for more. */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 5db4ec20fe: Fix tab-bar resizing under 'auto-resize-tab-bars' = 'grow-only',
Eli Zaretskii <=