From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Third Newsgroups: gmane.emacs.bugs Subject: bug#50534: 28.0.50; Toolbar shows despite tool-bar-mode being disabled on macOS Date: Sun, 26 Sep 2021 11:56:35 +0100 Message-ID: References: <16F124DC-AFCD-41D6-B039-CB1BD715FBFE@korins.ky> <34066D3F-0684-43B4-9460-44EC98806E28@korins.ky> <8F5214BE-6F8B-46EE-9E02-537226186EE9@korins.ky> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="QW0AcBjenulB4WSu" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16007"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= To: "Kirill A. Korinsky" , 50534@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Sep 26 17:50:21 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mUWQ0-00040c-Uy for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 26 Sep 2021 17:50:21 +0200 Original-Received: from localhost ([::1]:53460 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mUWPz-0005LF-2h for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 26 Sep 2021 11:50:19 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mUWPi-0005L6-8s for bug-gnu-emacs@gnu.org; Sun, 26 Sep 2021 11:50:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55239) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mUWPi-0002xz-0g for bug-gnu-emacs@gnu.org; Sun, 26 Sep 2021 11:50:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mUWPh-0005o0-Re for bug-gnu-emacs@gnu.org; Sun, 26 Sep 2021 11:50:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Third Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 26 Sep 2021 15:50:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50534 X-GNU-PR-Package: emacs Original-Received: via spool by 50534-submit@debbugs.gnu.org id=B50534.163267138922295 (code B ref 50534); Sun, 26 Sep 2021 15:50:01 +0000 Original-Received: (at 50534) by debbugs.gnu.org; 26 Sep 2021 15:49:49 +0000 Original-Received: from localhost ([127.0.0.1]:38552 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mUWPV-0005nW-6J for submit@debbugs.gnu.org; Sun, 26 Sep 2021 11:49:49 -0400 Original-Received: from outbound.soverin.net ([116.202.126.228]:36353) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mUWPS-0005nE-FS for 50534@debbugs.gnu.org; Sun, 26 Sep 2021 11:49:47 -0400 Original-Received: from smtp.soverin.net (unknown [10.10.3.24]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by outbound.soverin.net (Postfix) with ESMTPS id 61C8752; Sun, 26 Sep 2021 15:49:39 +0000 (UTC) Original-Received: from smtp.soverin.net (smtp.soverin.net [159.69.232.138]) by soverin.net DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=idiocy.org; s=soverin; t=1632671378; bh=fqB9QruGXSUwU8zasr4J/3YHAZM0oKpJcewFlB0Eu/A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=P+nP4wZO/UtHomm7v7Vwln8p+xOR5UUusr8TZKxOaf1H+k+XS45WzStB84zE/9dm3 tOXzok66Xk+UbZ6/2eV+nHCEE8/U5cD9UunFI+WEoCGs1B3Rf0hnmaC9x/nlQswU6a X+aZWXPMi6DGlbucwSwRGpIZXeKbgu5b1SxLZ5M5YHqbDDFiUycwBcBKGxVvV1x0TN pab7knJG0QcjIt6V8CM29O06aWRm0eoOTE/kSCwMOf49Zj0TGiCs8ID7zMkPHI1gs5 XkvyoMabCJhtxfqb4G+fEj+XKeXzm3NU2HA2PiH+8qh1HVr+YS46SWwzeFZQdYKiiZ icDSAiH1Kdwwg== Original-Received: from alan by faroe.holly.idiocy.org with local (Exim 4.95-RC2) (envelope-from ) id 1mURpj-000HzC-B2; Sun, 26 Sep 2021 11:56:35 +0100 Mail-Followup-To: Alan Third , "Kirill A. Korinsky" , 50534@debbugs.gnu.org, Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Content-Disposition: inline In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:215605 Archived-At: --QW0AcBjenulB4WSu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Sep 17, 2021 at 06:26:54PM +0100, Alan Third wrote: > On Tue, Sep 14, 2021 at 03:35:57PM +0100, Alan Third wrote: > > On Tue, Sep 14, 2021 at 04:17:15PM +0200, Kirill A. Korinsky wrote: > > > Hey, > > > > > > I can't broke the nuclear option anymore. > > > > > > Seems it fixing everything. > > > > Thanks, I'll push it to master. > > This last patch breaks toolbar display on my Mac. > > I think probably the best option is to change the toolbar handling so > it actually just removes the toolbar when we don't want to display it. > I really don't understand why the NS port goes to great lengths to > hide it. If we remove it then it can never be displayed when it > shouldn't be, and if it's attached to the window then it should always > be displayed, so we don't have to concern ourselves with making sure > the settings match after the window is resized or whatever. Can you please try the attached patch and check that the toolbar is behaving as expected. It seems to work correctly here everywhere (except in GNUstep we sometimes get an extra tall toolbar, but I doubt anyone cares too much about that), but I think it may have removed the animation when the toolbar is attached to the frame. If anyone is really upset about the animation (and I'm not even sure it IS gone) then we probably just need to create the toolbar as invisible and attach it then mark it visible, but only do that on Cocoa as it breaks the toolbar on frame creation in GNUstep. -- Alan Third --QW0AcBjenulB4WSu Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-Fix-NS-toolbar-again-bug-50534.patch" >From 2cf79c5636eb6fd5c7d082db2b0fdef1f168f404 Mon Sep 17 00:00:00 2001 From: Alan Third Date: Sun, 26 Sep 2021 11:12:48 +0100 Subject: [PATCH] Fix NS toolbar again (bug#50534) * src/nsmenu.m (free_frame_tool_bar): Remove toolbar. (update_frame_tool_bar_1): New function. (update_frame_tool_bar): Move most of the functionality to update_frame_tool_bar_1. * src/nsterm.h: Definitions of functions and methods. * src/nsterm.m (ns_update_begin): ([EmacsView windowDidEnterFullScreen]): ([EmacsView windowDidExitFullScreen]): We no longer need to reset the toolbar visibility as that's done when we create the new fullscreen window. ([EmacsWindow initWithEmacsFrame:fullscreen:screen:]): Move the check for undecorated frames into createToolbar:. ([EmacsWindow createToolbar:]): Check whether a toolbar should be created, and run the toolbar update immediately. --- src/nsmenu.m | 35 +++++++++++++++++++++++------------ src/nsterm.h | 5 +++++ src/nsterm.m | 28 ++++++---------------------- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/nsmenu.m b/src/nsmenu.m index f0c5bb24e6..9b78643d56 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m @@ -995,25 +995,24 @@ - (void)menu:(NSMenu *)menu willHighlightItem:(NSMenuItem *)item /* Note: This triggers an animation, which calls windowDidResize repeatedly. */ f->output_data.ns->in_animation = 1; - [[[view window] toolbar] setVisible: NO]; + [[[view window] toolbar] setVisible:NO]; f->output_data.ns->in_animation = 0; + [[view window] setToolbar:nil]; + unblock_input (); } void -update_frame_tool_bar (struct frame *f) +update_frame_tool_bar_1 (struct frame *f, EmacsToolbar *toolbar) /* -------------------------------------------------------------------------- Update toolbar contents. -------------------------------------------------------------------------- */ { int i, k = 0; - NSWindow *window = [FRAME_NS_VIEW (f) window]; - EmacsToolbar *toolbar = (EmacsToolbar *)[window toolbar]; NSTRACE ("update_frame_tool_bar"); - if (window == nil || toolbar == nil) return; block_input (); #ifdef NS_IMPL_COCOA @@ -1094,13 +1093,6 @@ - (void)menu:(NSMenu *)menu willHighlightItem:(NSMenuItem *)item #undef TOOLPROP } - if (![toolbar isVisible] != !FRAME_EXTERNAL_TOOL_BAR (f)) - { - f->output_data.ns->in_animation = 1; - [toolbar setVisible: FRAME_EXTERNAL_TOOL_BAR (f)]; - f->output_data.ns->in_animation = 0; - } - #ifdef NS_IMPL_COCOA if ([toolbar changed]) { @@ -1124,9 +1116,28 @@ - (void)menu:(NSMenu *)menu willHighlightItem:(NSMenuItem *)item [newDict release]; } #endif + + [toolbar setVisible:YES]; unblock_input (); } +void +update_frame_tool_bar (struct frame *f) +{ + EmacsWindow *window = (EmacsWindow *)[FRAME_NS_VIEW (f) window]; + EmacsToolbar *toolbar = (EmacsToolbar *)[window toolbar]; + + if (!toolbar) + { + [window createToolbar:f]; + return; + } + + if (window == nil || toolbar == nil) return; + + update_frame_tool_bar_1 (f, toolbar); +} + /* ========================================================================== diff --git a/src/nsterm.h b/src/nsterm.h index 6d4ea77121..1bedf78bcb 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -418,6 +418,7 @@ #define NSTRACE_UNSILENCE() - (instancetype)initWithEmacsFrame:(struct frame *)f; - (instancetype)initWithEmacsFrame:(struct frame *)f fullscreen:(BOOL)fullscreen screen:(NSScreen *)screen; +- (void)createToolbar:(struct frame *)f; - (void)setParentChildRelationships; - (NSInteger)borderWidth; - (BOOL)restackWindow:(NSWindow *)win above:(BOOL)above; @@ -1148,6 +1149,10 @@ ns_query_color (void *col, Emacs_Color *color_def, bool setPixel); /* in nsmenu */ extern void update_frame_tool_bar (struct frame *f); +#ifdef __OBJC__ +extern void update_frame_tool_bar_1 (struct frame *f, EmacsToolbar *toolbar); +#endif + extern void free_frame_tool_bar (struct frame *f); extern Lisp_Object find_and_return_menu_selection (struct frame *f, bool keymaps, diff --git a/src/nsterm.m b/src/nsterm.m index 4ef20e4c2b..3363fac475 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -1021,15 +1021,6 @@ static NSRect constrain_frame_rect(NSRect frameRect, bool isFullscreen) ns_update_auto_hide_menu_bar (); - NSToolbar *toolbar = [[FRAME_NS_VIEW (f) window] toolbar]; - if (toolbar) - { - /* Ensure the toolbars visibility is set correctly. */ - BOOL tbar_visible = FRAME_EXTERNAL_TOOL_BAR (f) ? YES : NO; - if (! tbar_visible != ! [toolbar isVisible]) - [toolbar setVisible: tbar_visible]; - } - ns_updating_frame = f; [view lockFocus]; } @@ -7401,7 +7392,6 @@ - (void)windowDidEnterFullScreen /* provided for direct calls */ } else { - BOOL tbar_visible = FRAME_EXTERNAL_TOOL_BAR (emacsframe) ? YES : NO; #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 \ && MAC_OS_X_VERSION_MIN_REQUIRED <= 1070 unsigned val = (unsigned)[NSApp presentationOptions]; @@ -7419,7 +7409,6 @@ - (void)windowDidEnterFullScreen /* provided for direct calls */ [NSApp setPresentationOptions: options]; } #endif - [[[self window]toolbar] setVisible:tbar_visible]; } } @@ -7460,14 +7449,6 @@ - (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)) - { - [[[self window] toolbar] setVisible:YES]; - update_frame_tool_bar (emacsframe); - [[self window] display]; - } - else - [[[self window] toolbar] setVisible:NO]; if (next_maximized != -1) [[self window] performZoom:self]; @@ -8298,8 +8279,7 @@ - (instancetype) initWithEmacsFrame:(struct frame *)f [self setOpaque:NO]; /* toolbar support */ - if (! FRAME_UNDECORATED (f)) - [self createToolbar:f]; + [self createToolbar:f]; /* macOS Sierra automatically enables tabbed windows. We can't allow this to be enabled until it's available on a Free system. @@ -8316,13 +8296,17 @@ - (instancetype) initWithEmacsFrame:(struct frame *)f - (void)createToolbar: (struct frame *)f { + if (FRAME_UNDECORATED (f) || !FRAME_EXTERNAL_TOOL_BAR (f)) + return; + EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f); EmacsToolbar *toolbar = [[EmacsToolbar alloc] initForView:view withIdentifier:[NSString stringWithLispString:f->name]]; - [toolbar setVisible:NO]; + [self setToolbar:toolbar]; + update_frame_tool_bar_1 (f, toolbar); #ifdef NS_IMPL_COCOA { -- 2.33.0 --QW0AcBjenulB4WSu--