diff options
| author | Alan Third | 2021-09-26 11:12:48 +0100 |
|---|---|---|
| committer | Alan Third | 2021-09-27 11:00:30 +0100 |
| commit | 86bf8afa45f8d8fe19c82a9351ca445bc6f0e12e (patch) | |
| tree | f34ed0d181ca604f8b4d98089fa556a344561655 /src | |
| parent | 3d2d7e8ea235a13543ed475836f8f7ea4c88520e (diff) | |
| download | emacs-86bf8afa45f8d8fe19c82a9351ca445bc6f0e12e.tar.gz emacs-86bf8afa45f8d8fe19c82a9351ca445bc6f0e12e.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/nsmenu.m | 35 | ||||
| -rw-r--r-- | src/nsterm.h | 5 | ||||
| -rw-r--r-- | src/nsterm.m | 28 |
3 files changed, 34 insertions, 34 deletions
diff --git a/src/nsmenu.m b/src/nsmenu.m index f0c5bb24e63..9b78643d56a 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m | |||
| @@ -995,25 +995,24 @@ free_frame_tool_bar (struct frame *f) | |||
| 995 | /* Note: This triggers an animation, which calls windowDidResize | 995 | /* Note: This triggers an animation, which calls windowDidResize |
| 996 | repeatedly. */ | 996 | repeatedly. */ |
| 997 | f->output_data.ns->in_animation = 1; | 997 | f->output_data.ns->in_animation = 1; |
| 998 | [[[view window] toolbar] setVisible: NO]; | 998 | [[[view window] toolbar] setVisible:NO]; |
| 999 | f->output_data.ns->in_animation = 0; | 999 | f->output_data.ns->in_animation = 0; |
| 1000 | 1000 | ||
| 1001 | [[view window] setToolbar:nil]; | ||
| 1002 | |||
| 1001 | unblock_input (); | 1003 | unblock_input (); |
| 1002 | } | 1004 | } |
| 1003 | 1005 | ||
| 1004 | void | 1006 | void |
| 1005 | update_frame_tool_bar (struct frame *f) | 1007 | update_frame_tool_bar_1 (struct frame *f, EmacsToolbar *toolbar) |
| 1006 | /* -------------------------------------------------------------------------- | 1008 | /* -------------------------------------------------------------------------- |
| 1007 | Update toolbar contents. | 1009 | Update toolbar contents. |
| 1008 | -------------------------------------------------------------------------- */ | 1010 | -------------------------------------------------------------------------- */ |
| 1009 | { | 1011 | { |
| 1010 | int i, k = 0; | 1012 | int i, k = 0; |
| 1011 | NSWindow *window = [FRAME_NS_VIEW (f) window]; | ||
| 1012 | EmacsToolbar *toolbar = (EmacsToolbar *)[window toolbar]; | ||
| 1013 | 1013 | ||
| 1014 | NSTRACE ("update_frame_tool_bar"); | 1014 | NSTRACE ("update_frame_tool_bar"); |
| 1015 | 1015 | ||
| 1016 | if (window == nil || toolbar == nil) return; | ||
| 1017 | block_input (); | 1016 | block_input (); |
| 1018 | 1017 | ||
| 1019 | #ifdef NS_IMPL_COCOA | 1018 | #ifdef NS_IMPL_COCOA |
| @@ -1094,13 +1093,6 @@ update_frame_tool_bar (struct frame *f) | |||
| 1094 | #undef TOOLPROP | 1093 | #undef TOOLPROP |
| 1095 | } | 1094 | } |
| 1096 | 1095 | ||
| 1097 | if (![toolbar isVisible] != !FRAME_EXTERNAL_TOOL_BAR (f)) | ||
| 1098 | { | ||
| 1099 | f->output_data.ns->in_animation = 1; | ||
| 1100 | [toolbar setVisible: FRAME_EXTERNAL_TOOL_BAR (f)]; | ||
| 1101 | f->output_data.ns->in_animation = 0; | ||
| 1102 | } | ||
| 1103 | |||
| 1104 | #ifdef NS_IMPL_COCOA | 1096 | #ifdef NS_IMPL_COCOA |
| 1105 | if ([toolbar changed]) | 1097 | if ([toolbar changed]) |
| 1106 | { | 1098 | { |
| @@ -1124,9 +1116,28 @@ update_frame_tool_bar (struct frame *f) | |||
| 1124 | [newDict release]; | 1116 | [newDict release]; |
| 1125 | } | 1117 | } |
| 1126 | #endif | 1118 | #endif |
| 1119 | |||
| 1120 | [toolbar setVisible:YES]; | ||
| 1127 | unblock_input (); | 1121 | unblock_input (); |
| 1128 | } | 1122 | } |
| 1129 | 1123 | ||
| 1124 | void | ||
| 1125 | update_frame_tool_bar (struct frame *f) | ||
| 1126 | { | ||
| 1127 | EmacsWindow *window = (EmacsWindow *)[FRAME_NS_VIEW (f) window]; | ||
| 1128 | EmacsToolbar *toolbar = (EmacsToolbar *)[window toolbar]; | ||
| 1129 | |||
| 1130 | if (!toolbar) | ||
| 1131 | { | ||
| 1132 | [window createToolbar:f]; | ||
| 1133 | return; | ||
| 1134 | } | ||
| 1135 | |||
| 1136 | if (window == nil || toolbar == nil) return; | ||
| 1137 | |||
| 1138 | update_frame_tool_bar_1 (f, toolbar); | ||
| 1139 | } | ||
| 1140 | |||
| 1130 | 1141 | ||
| 1131 | /* ========================================================================== | 1142 | /* ========================================================================== |
| 1132 | 1143 | ||
diff --git a/src/nsterm.h b/src/nsterm.h index 6d4ea771212..1bedf78bcb1 100644 --- a/src/nsterm.h +++ b/src/nsterm.h | |||
| @@ -418,6 +418,7 @@ typedef id instancetype; | |||
| 418 | 418 | ||
| 419 | - (instancetype)initWithEmacsFrame:(struct frame *)f; | 419 | - (instancetype)initWithEmacsFrame:(struct frame *)f; |
| 420 | - (instancetype)initWithEmacsFrame:(struct frame *)f fullscreen:(BOOL)fullscreen screen:(NSScreen *)screen; | 420 | - (instancetype)initWithEmacsFrame:(struct frame *)f fullscreen:(BOOL)fullscreen screen:(NSScreen *)screen; |
| 421 | - (void)createToolbar:(struct frame *)f; | ||
| 421 | - (void)setParentChildRelationships; | 422 | - (void)setParentChildRelationships; |
| 422 | - (NSInteger)borderWidth; | 423 | - (NSInteger)borderWidth; |
| 423 | - (BOOL)restackWindow:(NSWindow *)win above:(BOOL)above; | 424 | - (BOOL)restackWindow:(NSWindow *)win above:(BOOL)above; |
| @@ -1148,6 +1149,10 @@ extern void ns_init_locale (void); | |||
| 1148 | 1149 | ||
| 1149 | /* in nsmenu */ | 1150 | /* in nsmenu */ |
| 1150 | extern void update_frame_tool_bar (struct frame *f); | 1151 | extern void update_frame_tool_bar (struct frame *f); |
| 1152 | #ifdef __OBJC__ | ||
| 1153 | extern void update_frame_tool_bar_1 (struct frame *f, EmacsToolbar *toolbar); | ||
| 1154 | #endif | ||
| 1155 | |||
| 1151 | extern void free_frame_tool_bar (struct frame *f); | 1156 | extern void free_frame_tool_bar (struct frame *f); |
| 1152 | extern Lisp_Object find_and_return_menu_selection (struct frame *f, | 1157 | extern Lisp_Object find_and_return_menu_selection (struct frame *f, |
| 1153 | bool keymaps, | 1158 | bool keymaps, |
diff --git a/src/nsterm.m b/src/nsterm.m index 4ef20e4c2b7..3363fac475a 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -1021,15 +1021,6 @@ ns_update_begin (struct frame *f) | |||
| 1021 | 1021 | ||
| 1022 | ns_update_auto_hide_menu_bar (); | 1022 | ns_update_auto_hide_menu_bar (); |
| 1023 | 1023 | ||
| 1024 | NSToolbar *toolbar = [[FRAME_NS_VIEW (f) window] toolbar]; | ||
| 1025 | if (toolbar) | ||
| 1026 | { | ||
| 1027 | /* Ensure the toolbars visibility is set correctly. */ | ||
| 1028 | BOOL tbar_visible = FRAME_EXTERNAL_TOOL_BAR (f) ? YES : NO; | ||
| 1029 | if (! tbar_visible != ! [toolbar isVisible]) | ||
| 1030 | [toolbar setVisible: tbar_visible]; | ||
| 1031 | } | ||
| 1032 | |||
| 1033 | ns_updating_frame = f; | 1024 | ns_updating_frame = f; |
| 1034 | [view lockFocus]; | 1025 | [view lockFocus]; |
| 1035 | } | 1026 | } |
| @@ -7401,7 +7392,6 @@ not_in_argv (NSString *arg) | |||
| 7401 | } | 7392 | } |
| 7402 | else | 7393 | else |
| 7403 | { | 7394 | { |
| 7404 | BOOL tbar_visible = FRAME_EXTERNAL_TOOL_BAR (emacsframe) ? YES : NO; | ||
| 7405 | #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 \ | 7395 | #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 \ |
| 7406 | && MAC_OS_X_VERSION_MIN_REQUIRED <= 1070 | 7396 | && MAC_OS_X_VERSION_MIN_REQUIRED <= 1070 |
| 7407 | unsigned val = (unsigned)[NSApp presentationOptions]; | 7397 | unsigned val = (unsigned)[NSApp presentationOptions]; |
| @@ -7419,7 +7409,6 @@ not_in_argv (NSString *arg) | |||
| 7419 | [NSApp setPresentationOptions: options]; | 7409 | [NSApp setPresentationOptions: options]; |
| 7420 | } | 7410 | } |
| 7421 | #endif | 7411 | #endif |
| 7422 | [[[self window]toolbar] setVisible:tbar_visible]; | ||
| 7423 | } | 7412 | } |
| 7424 | } | 7413 | } |
| 7425 | 7414 | ||
| @@ -7460,14 +7449,6 @@ not_in_argv (NSString *arg) | |||
| 7460 | #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 | 7449 | #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 |
| 7461 | [self updateCollectionBehavior]; | 7450 | [self updateCollectionBehavior]; |
| 7462 | #endif | 7451 | #endif |
| 7463 | if (FRAME_EXTERNAL_TOOL_BAR (emacsframe)) | ||
| 7464 | { | ||
| 7465 | [[[self window] toolbar] setVisible:YES]; | ||
| 7466 | update_frame_tool_bar (emacsframe); | ||
| 7467 | [[self window] display]; | ||
| 7468 | } | ||
| 7469 | else | ||
| 7470 | [[[self window] toolbar] setVisible:NO]; | ||
| 7471 | 7452 | ||
| 7472 | if (next_maximized != -1) | 7453 | if (next_maximized != -1) |
| 7473 | [[self window] performZoom:self]; | 7454 | [[self window] performZoom:self]; |
| @@ -8298,8 +8279,7 @@ not_in_argv (NSString *arg) | |||
| 8298 | [self setOpaque:NO]; | 8279 | [self setOpaque:NO]; |
| 8299 | 8280 | ||
| 8300 | /* toolbar support */ | 8281 | /* toolbar support */ |
| 8301 | if (! FRAME_UNDECORATED (f)) | 8282 | [self createToolbar:f]; |
| 8302 | [self createToolbar:f]; | ||
| 8303 | 8283 | ||
| 8304 | /* macOS Sierra automatically enables tabbed windows. We can't | 8284 | /* macOS Sierra automatically enables tabbed windows. We can't |
| 8305 | allow this to be enabled until it's available on a Free system. | 8285 | allow this to be enabled until it's available on a Free system. |
| @@ -8316,13 +8296,17 @@ not_in_argv (NSString *arg) | |||
| 8316 | 8296 | ||
| 8317 | - (void)createToolbar: (struct frame *)f | 8297 | - (void)createToolbar: (struct frame *)f |
| 8318 | { | 8298 | { |
| 8299 | if (FRAME_UNDECORATED (f) || !FRAME_EXTERNAL_TOOL_BAR (f)) | ||
| 8300 | return; | ||
| 8301 | |||
| 8319 | EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f); | 8302 | EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f); |
| 8320 | 8303 | ||
| 8321 | EmacsToolbar *toolbar = [[EmacsToolbar alloc] | 8304 | EmacsToolbar *toolbar = [[EmacsToolbar alloc] |
| 8322 | initForView:view | 8305 | initForView:view |
| 8323 | withIdentifier:[NSString stringWithLispString:f->name]]; | 8306 | withIdentifier:[NSString stringWithLispString:f->name]]; |
| 8324 | [toolbar setVisible:NO]; | 8307 | |
| 8325 | [self setToolbar:toolbar]; | 8308 | [self setToolbar:toolbar]; |
| 8309 | update_frame_tool_bar_1 (f, toolbar); | ||
| 8326 | 8310 | ||
| 8327 | #ifdef NS_IMPL_COCOA | 8311 | #ifdef NS_IMPL_COCOA |
| 8328 | { | 8312 | { |