1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-27 07:37:33 +00:00

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.
This commit is contained in:
Alan Third 2021-09-26 11:12:48 +01:00
parent 3d2d7e8ea2
commit 86bf8afa45
3 changed files with 34 additions and 34 deletions

View File

@ -995,25 +995,24 @@ - (void)menu:(NSMenu *)menu willHighlightItem:(NSMenuItem *)item
/* Note: This triggers an animation, which calls windowDidResize /* Note: This triggers an animation, which calls windowDidResize
repeatedly. */ repeatedly. */
f->output_data.ns->in_animation = 1; f->output_data.ns->in_animation = 1;
[[[view window] toolbar] setVisible: NO]; [[[view window] toolbar] setVisible:NO];
f->output_data.ns->in_animation = 0; f->output_data.ns->in_animation = 0;
[[view window] setToolbar:nil];
unblock_input (); unblock_input ();
} }
void void
update_frame_tool_bar (struct frame *f) update_frame_tool_bar_1 (struct frame *f, EmacsToolbar *toolbar)
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
Update toolbar contents. Update toolbar contents.
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
{ {
int i, k = 0; int i, k = 0;
NSWindow *window = [FRAME_NS_VIEW (f) window];
EmacsToolbar *toolbar = (EmacsToolbar *)[window toolbar];
NSTRACE ("update_frame_tool_bar"); NSTRACE ("update_frame_tool_bar");
if (window == nil || toolbar == nil) return;
block_input (); block_input ();
#ifdef NS_IMPL_COCOA #ifdef NS_IMPL_COCOA
@ -1094,13 +1093,6 @@ - (void)menu:(NSMenu *)menu willHighlightItem:(NSMenuItem *)item
#undef TOOLPROP #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 #ifdef NS_IMPL_COCOA
if ([toolbar changed]) if ([toolbar changed])
{ {
@ -1124,9 +1116,28 @@ - (void)menu:(NSMenu *)menu willHighlightItem:(NSMenuItem *)item
[newDict release]; [newDict release];
} }
#endif #endif
[toolbar setVisible:YES];
unblock_input (); 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);
}
/* ========================================================================== /* ==========================================================================

View File

@ -418,6 +418,7 @@ typedef id instancetype;
- (instancetype)initWithEmacsFrame:(struct frame *)f; - (instancetype)initWithEmacsFrame:(struct frame *)f;
- (instancetype)initWithEmacsFrame:(struct frame *)f fullscreen:(BOOL)fullscreen screen:(NSScreen *)screen; - (instancetype)initWithEmacsFrame:(struct frame *)f fullscreen:(BOOL)fullscreen screen:(NSScreen *)screen;
- (void)createToolbar:(struct frame *)f;
- (void)setParentChildRelationships; - (void)setParentChildRelationships;
- (NSInteger)borderWidth; - (NSInteger)borderWidth;
- (BOOL)restackWindow:(NSWindow *)win above:(BOOL)above; - (BOOL)restackWindow:(NSWindow *)win above:(BOOL)above;
@ -1148,6 +1149,10 @@ extern void ns_init_locale (void);
/* in nsmenu */ /* in nsmenu */
extern void update_frame_tool_bar (struct frame *f); 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 void free_frame_tool_bar (struct frame *f);
extern Lisp_Object find_and_return_menu_selection (struct frame *f, extern Lisp_Object find_and_return_menu_selection (struct frame *f,
bool keymaps, bool keymaps,

View File

@ -1021,15 +1021,6 @@ static NSRect constrain_frame_rect(NSRect frameRect, bool isFullscreen)
ns_update_auto_hide_menu_bar (); 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; ns_updating_frame = f;
[view lockFocus]; [view lockFocus];
} }
@ -7401,7 +7392,6 @@ - (void)windowDidEnterFullScreen /* provided for direct calls */
} }
else else
{ {
BOOL tbar_visible = FRAME_EXTERNAL_TOOL_BAR (emacsframe) ? YES : NO;
#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 \ #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 \
&& MAC_OS_X_VERSION_MIN_REQUIRED <= 1070 && MAC_OS_X_VERSION_MIN_REQUIRED <= 1070
unsigned val = (unsigned)[NSApp presentationOptions]; unsigned val = (unsigned)[NSApp presentationOptions];
@ -7419,7 +7409,6 @@ - (void)windowDidEnterFullScreen /* provided for direct calls */
[NSApp setPresentationOptions: options]; [NSApp setPresentationOptions: options];
} }
#endif #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 #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
[self updateCollectionBehavior]; [self updateCollectionBehavior];
#endif #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) if (next_maximized != -1)
[[self window] performZoom:self]; [[self window] performZoom:self];
@ -8298,8 +8279,7 @@ - (instancetype) initWithEmacsFrame:(struct frame *)f
[self setOpaque:NO]; [self setOpaque:NO];
/* toolbar support */ /* toolbar support */
if (! FRAME_UNDECORATED (f)) [self createToolbar:f];
[self createToolbar:f];
/* macOS Sierra automatically enables tabbed windows. We can't /* macOS Sierra automatically enables tabbed windows. We can't
allow this to be enabled until it's available on a Free system. 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 - (void)createToolbar: (struct frame *)f
{ {
if (FRAME_UNDECORATED (f) || !FRAME_EXTERNAL_TOOL_BAR (f))
return;
EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f); EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f);
EmacsToolbar *toolbar = [[EmacsToolbar alloc] EmacsToolbar *toolbar = [[EmacsToolbar alloc]
initForView:view initForView:view
withIdentifier:[NSString stringWithLispString:f->name]]; withIdentifier:[NSString stringWithLispString:f->name]];
[toolbar setVisible:NO];
[self setToolbar:toolbar]; [self setToolbar:toolbar];
update_frame_tool_bar_1 (f, toolbar);
#ifdef NS_IMPL_COCOA #ifdef NS_IMPL_COCOA
{ {