unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Bastian Beranek <bastian.beischer@gmail.com>
To: Juri Linkov <juri@linkov.net>
Cc: 46299@debbugs.gnu.org
Subject: bug#46299: 28.0.50; Value of tab-bar-show not respected in new frames.
Date: Tue, 16 Feb 2021 11:59:14 +0100	[thread overview]
Message-ID: <87im6sffct.fsf@gmail.com> (raw)
In-Reply-To: <878s7pdlsi.fsf@gmail.com> (Bastian Beranek's message of "Mon, 15 Feb 2021 23:10:53 +0100")

[-- Attachment #1: Type: text/plain, Size: 1781 bytes --]

Bastian Beranek <bastian.beischer@gmail.com> writes:

> But how to go back? It seems that tab-bar-show should go back to "1" (in
> order to make it a real toggle, i.e. it undoes itself). However, that
> means that after the second toggle-frame-tab-bar the tab-bar will either
> be shown or not, depending on the number of tabs opened at that specific
> time. We have to consider that the user created or closed tabs in
> between, so that means that there will be situations in which
> toggle-frame-tab-bar does not really seem to do anything... For example:
>
> - 1 tab (tab bar hidden)
> - create tab -> 2 tabs (tab bar shown)
> - toggle-frame-tab-bar (tab bar hidden)
> - close tab (tab bar hidden)
> - toggle-frame-tab-bar (tab bar still hidden, because only 1 tab)

I think what we could do is:

a) always toggle the current visibility: That seems to be a must, it
   would be confusing otherwise.

b) The first time toggle-frame-tab-bar is called, add a notice to the
   frame parameters that prevents tab-bar--update-tab-bar-lines from
   changing that frames tab-bar visibility. This means that after the
   toggle the tab-bar visibility keeps its state until
   toggle-frame-tab-bar is called again.

c) When it is called a second time toggle-frame-tab-bar sets the new
   frame parameter to nil and flips the visibility again (see a).

d) Then the tab-bar--update-tab-bar-lines logic will be active again,
   but only after a new tab is created or closed on that frame.

This prevents the problem listed in my last mail, in the last step the
tab-bar will be shown after toggling (although tab-bar-show is 1 and
there is only one tab), but then once you create more tabs or close tabs
it will revert to the usual behavior.

Is this acceptable?

Proposed patch is attached.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-behavior-of-toggle-frame-tab-bar-bug-46299.patch --]
[-- Type: text/x-patch, Size: 1725 bytes --]

From 5f158962c1bc63c10ebaa49357a16e45664d5579 Mon Sep 17 00:00:00 2001
From: Bastian Beranek <bastian.beischer@rwth-aachen.de>
Date: Tue, 16 Feb 2021 11:35:35 +0100
Subject: [PATCH] Fix behavior of toggle-frame-tab-bar (bug #46299)

* lisp/tab-bar.el (toggle-frame-tab-bar): Add frame attribute to
protect tab bar state from changing.
(tab-bar--update-tab-bar-lines): Check for new attribute
---
 lisp/tab-bar.el | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 4e47ae2c10..2fa34385f1 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -161,7 +161,8 @@ tab-bar--update-tab-bar-lines
                          (t frames))))
     ;; Loop over all frames and update default-frame-alist
     (dolist (frame frame-lst)
-      (set-frame-parameter frame 'tab-bar-lines (tab-bar--tab-bar-lines-for-frame frame))))
+      (unless (frame-parameter frame 'tab-bar-lines-keep-state)
+        (set-frame-parameter frame 'tab-bar-lines (tab-bar--tab-bar-lines-for-frame frame)))))
   (when (eq frames t)
     (setq default-frame-alist
           (cons (cons 'tab-bar-lines (if (and tab-bar-mode (eq tab-bar-show t)) 1 0))
@@ -233,7 +234,9 @@ toggle-frame-tab-bar
   (add-hook 'after-make-frame-functions 'toggle-frame-tab-bar)"
   (interactive)
   (set-frame-parameter frame 'tab-bar-lines
-                       (if (> (frame-parameter frame 'tab-bar-lines) 0) 0 1)))
+                       (if (> (frame-parameter frame 'tab-bar-lines) 0) 0 1))
+  (set-frame-parameter frame 'tab-bar-lines-keep-state
+                       (not (frame-parameter nil 'tab-bar-lines-keep-state))))
 
 (defvar tab-bar-map (make-sparse-keymap)
   "Keymap for the tab bar.
-- 
2.30.1


  parent reply	other threads:[~2021-02-16 10:59 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-04 16:14 bug#46299: 28.0.50; Value of tab-bar-show not respected in new frames Bastian Beischer
2021-02-05  8:54 ` Juri Linkov
2021-02-05 10:10   ` Bastian Beranek
2021-02-05 14:11     ` Bastian Beranek
2021-02-06 12:16       ` Bastian Beranek
2021-02-07 19:05         ` Juri Linkov
2021-02-07 23:03           ` Bastian Beranek
2021-02-08 17:50             ` Bastian Beranek
2021-02-08 18:19               ` Juri Linkov
2021-02-08 19:04                 ` Bastian Beranek
2021-02-09  8:00                   ` martin rudalics
2021-02-09  8:15                     ` Bastian Beranek
2021-02-09  8:58                       ` martin rudalics
2021-02-09  9:23                         ` Bastian Beranek
2021-02-09  9:45                           ` martin rudalics
2021-02-09 11:44                             ` Bastian Beranek
2021-02-09 17:32                               ` martin rudalics
2021-02-09 18:06                               ` Juri Linkov
2021-02-09 18:46                                 ` Bastian Beranek
2021-02-09 19:08                                   ` Eli Zaretskii
2021-02-09 19:01                                 ` Eli Zaretskii
2021-02-10 18:24                               ` Juri Linkov
2021-02-11 12:14                                 ` Bastian Beranek
2021-02-11 17:34                                   ` Bastian Beranek
2021-02-12  9:31                                   ` Juri Linkov
2021-02-12 10:24                                     ` Bastian Beranek
2021-02-12 14:47                                       ` Bastian Beranek
2021-02-12 19:23                                         ` Bastian Beranek
2021-02-13 18:23                                           ` Juri Linkov
2021-02-13 19:02                                             ` Bastian Beranek
2021-02-13 19:46                                               ` Juri Linkov
2021-02-14 18:44                                                 ` Juri Linkov
2021-02-15 10:05                                                   ` Bastian Beranek
2021-02-15 15:26                                                   ` Eli Zaretskii
2021-02-15 15:32                                                     ` Bastian Beranek
2021-02-15 15:53                                                       ` Eli Zaretskii
2021-02-16 10:40                                                         ` Bastian Beranek
2021-02-14 13:08                                             ` Bastian Beranek
2021-02-14 18:50                                               ` Juri Linkov
2021-02-14 19:28                                                 ` Juri Linkov
2021-02-15  8:16                                                 ` martin rudalics
2021-02-15  9:07                                                   ` Juri Linkov
2021-02-15 10:08                                                     ` martin rudalics
2021-02-15 10:12                                                   ` Bastian Beranek
2021-02-15 10:09                                                 ` Bastian Beranek
2021-02-15 17:01                                                   ` Juri Linkov
2021-02-15 22:10                                                     ` Bastian Beranek
2021-02-16  2:08                                                       ` bug#46299: [External] : " Drew Adams
2021-02-16 10:59                                                       ` Bastian Beranek [this message]
2021-02-16 15:31                                                         ` Bastian Beranek
2021-02-16 17:28                                                           ` Juri Linkov
2021-02-24 18:46                                                             ` Juri Linkov
2021-02-10 18:20                       ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87im6sffct.fsf@gmail.com \
    --to=bastian.beischer@gmail.com \
    --cc=46299@debbugs.gnu.org \
    --cc=juri@linkov.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).