]> git.eshelyaron.com Git - emacs.git/commitdiff
On tty frames restrict number of menu bar lines (Bug#77015)
authorMartin Rudalics <rudalics@gmx.at>
Wed, 19 Mar 2025 08:36:42 +0000 (09:36 +0100)
committerEshel Yaron <me@eshelyaron.com>
Thu, 20 Mar 2025 10:51:29 +0000 (12:51 +0200)
* src/frame.c (set_menu_bar_lines): Make sure tty frames get
only 0 or 1 menu bar line (Bug#77015).

(cherry picked from commit fa1cfcada0939e33d69696df6448b75b33ab656d)

src/frame.c

index e49bdca5c5be69f44cb3ae46cfa4a4063c61aa59..693b743bf23bc32f19a5f5772322f78eeb5f5314 100644 (file)
@@ -210,22 +210,34 @@ set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
   int olines = FRAME_MENU_BAR_LINES (f);
   int nlines = TYPE_RANGED_FIXNUMP (int, value) ? XFIXNUM (value) : 0;
 
-  /* Menu bars on child frames don't work on all platforms, which is
-     the reason why prepare_menu_bar does not update_menu_bar for
-     child frames (info from Martin Rudalics).  This could be
-     implemented in ttys, but it's probably not worth it.  */
-  if (is_tty_child_frame (f))
+  if (is_tty_frame (f))
     {
-      FRAME_MENU_BAR_LINES (f) = 0;
-      FRAME_MENU_BAR_HEIGHT (f) = 0;
-      return;
-    }
+      /* Menu bars on child frames don't work on all platforms, which is
+        the reason why prepare_menu_bar does not update_menu_bar for
+        child frames (info from Martin Rudalics).  This could be
+        implemented in ttys, but it's probably not worth it.  */
+      if (FRAME_PARENT_FRAME (f))
+       FRAME_MENU_BAR_LINES (f) = FRAME_MENU_BAR_HEIGHT (f) = 0;
+      else
+       {
+         /* Make only 0 or 1 menu bar line (Bug#77015).  */
+         FRAME_MENU_BAR_LINES (f) = FRAME_MENU_BAR_HEIGHT (f)
+           = nlines > 0 ? 1 : 0;
 
+         if (FRAME_MENU_BAR_LINES (f) != olines)
+           {
+             windows_or_buffers_changed = 14;
+             change_frame_size
+               (f, FRAME_PIXEL_WIDTH (f), FRAME_PIXEL_HEIGHT (f),
+                false, true, false);
+           }
+       }
+    }
   /* Right now, menu bars don't work properly in minibuf-only frames;
      most of the commands try to apply themselves to the minibuffer
      frame itself, and get an error because you can't switch buffers
      in or split the minibuffer window.  */
-  if (!FRAME_MINIBUF_ONLY_P (f) && nlines != olines)
+  else if (!FRAME_MINIBUF_ONLY_P (f) && nlines != olines)
     {
       windows_or_buffers_changed = 14;
       FRAME_MENU_BAR_LINES (f) = FRAME_MENU_BAR_HEIGHT (f) = nlines;