>From 70dbd0c9db782d15e0036f27db13a5ed8d9bba0b Mon Sep 17 00:00:00 2001 From: Alan Third Date: Sun, 12 Sep 2021 12:42:11 +0100 Subject: [PATCH v2] Fix incorrectly appearing toolbar on NS (bug#50534) * src/nsterm.h (FRAME_TOOLBAR_P): Work out whether the frame should have a toolbar or not. * src/nsterm.m (ns_update_begin): ([EmacsView windowDidEnterFullScreen]): ([EmacsView windowDidExitFullScreen]): Use new FRAME_TOOLBAR_P instead of the apparently unreliable FRAME_EXTERNAL_TOOL_BAR. * src/nsmenu.m (update_frame_tool_bar): Use new FRAME_TOOLBAR_P. --- src/nsmenu.m | 4 ++-- src/nsterm.h | 3 +++ src/nsterm.m | 6 +++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/nsmenu.m b/src/nsmenu.m index 0d0b2f60c9..08d4fb830e 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m @@ -1090,10 +1090,10 @@ - (void)menu:(NSMenu *)menu willHighlightItem:(NSMenuItem *)item #undef TOOLPROP } - if ([toolbar isVisible] != FRAME_EXTERNAL_TOOL_BAR (f)) + if ([toolbar isVisible] != FRAME_TOOLBAR_P (f)) { f->output_data.ns->in_animation = 1; - [toolbar setVisible: FRAME_EXTERNAL_TOOL_BAR (f)]; + [toolbar setVisible: FRAME_TOOLBAR_P (f)]; f->output_data.ns->in_animation = 0; } diff --git a/src/nsterm.h b/src/nsterm.h index 8640b97d8a..4739fe6d1c 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -1044,6 +1044,9 @@ #define FIRST_CHAR_POSITION(f) \ (! (FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f)) ? 0 \ : FRAME_SCROLL_BAR_COLS (f)) +#define FRAME_TOOLBAR_P(f) (FRAME_EXTERNAL_TOOL_BAR (f) \ + && FRAME_TOOL_BAR_LINES (f) > 0) + extern struct ns_display_info *ns_term_init (Lisp_Object display_name); extern void ns_term_shutdown (int sig); diff --git a/src/nsterm.m b/src/nsterm.m index f8b8c1e574..9f129be29c 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -1038,7 +1038,7 @@ static NSRect constrain_frame_rect(NSRect frameRect, bool isFullscreen) if ([view isFullscreen] && [view fsIsNative]) { // Fix reappearing tool bar in fullscreen for Mac OS X 10.7 - BOOL tbar_visible = FRAME_EXTERNAL_TOOL_BAR (f) ? YES : NO; + BOOL tbar_visible = FRAME_TOOLBAR_P (f); NSToolbar *toolbar = [[FRAME_NS_VIEW (f) window] toolbar]; if (! tbar_visible != ! [toolbar isVisible]) [toolbar setVisible: tbar_visible]; @@ -7328,7 +7328,7 @@ - (void)windowDidEnterFullScreen /* provided for direct calls */ } else { - BOOL tbar_visible = FRAME_EXTERNAL_TOOL_BAR (emacsframe) ? YES : NO; + BOOL tbar_visible = FRAME_TOOLBAR_P (emacsframe); #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 \ && MAC_OS_X_VERSION_MIN_REQUIRED <= 1070 unsigned val = (unsigned)[NSApp presentationOptions]; @@ -7387,7 +7387,7 @@ - (void)windowDidExitFullScreen /* provided for direct calls */ #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 [self updateCollectionBehavior]; #endif - if (FRAME_EXTERNAL_TOOL_BAR (emacsframe)) + if (FRAME_TOOLBAR_P (emacsframe)) { [[[self window] toolbar] setVisible:YES]; update_frame_tool_bar (emacsframe); -- 2.30.2