NSTRACE ("free_frame_tool_bar");
block_input ();
- view->wait_for_tool_bar = NO;
/* Note: This triggers an animation, which calls windowDidResize
repeatedly. */
f->output_data.ns->in_animation = 1;
- [[view toolbar] setVisible: NO];
+ [[[view window] toolbar] setVisible: NO];
f->output_data.ns->in_animation = 0;
unblock_input ();
-------------------------------------------------------------------------- */
{
int i, k = 0;
- EmacsView *view = FRAME_NS_VIEW (f);
- EmacsToolbar *toolbar = [view toolbar];
+ NSWindow *window = [FRAME_NS_VIEW (f) window];
+ EmacsToolbar *toolbar = (EmacsToolbar *)[window toolbar];
NSTRACE ("update_frame_tool_bar");
- if (view == nil || toolbar == nil) return;
+ if (window == nil || toolbar == nil) return;
block_input ();
#ifdef NS_IMPL_COCOA
[newDict release];
}
#endif
-
- if (view->wait_for_tool_bar && FRAME_TOOLBAR_HEIGHT (f) > 0)
- {
- view->wait_for_tool_bar = NO;
- [view setNeedsDisplay: YES];
- }
-
unblock_input ();
}
{
// Fix reappearing tool bar in fullscreen for Mac OS X 10.7
BOOL tbar_visible = FRAME_EXTERNAL_TOOL_BAR (f) ? YES : NO;
- NSToolbar *toolbar = [FRAME_NS_VIEW (f) toolbar];
+ NSToolbar *toolbar = [[FRAME_NS_VIEW (f) window] toolbar];
if (! tbar_visible != ! [toolbar isVisible])
[toolbar setVisible: tbar_visible];
}
newWindow = [[EmacsWindow alloc] initWithEmacsFrame:f];
- if (!FRAME_UNDECORATED (f))
- [view createToolbar: f];
-
if ([oldWindow isKeyWindow])
[newWindow makeKeyAndOrderFront:NSApp];
name:NSViewFrameDidChangeNotification
object:nil];
- [toolbar release];
if (fs_state == FULLSCREEN_BOTH)
[nonfs_window release];
[super dealloc];
}
-- (void)createToolbar: (struct frame *)f
-{
- EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f);
- NSWindow *window = [view window];
-
- toolbar = [[EmacsToolbar alloc] initForView: self withIdentifier:
- [NSString stringWithFormat: @"Emacs Frame %d",
- ns_window_num]];
- [toolbar setVisible: NO];
- [window setToolbar: toolbar];
-
- /* Don't set frame garbaged until tool bar is up to date?
- This avoids an extra clear and redraw (flicker) at frame creation. */
- if (FRAME_EXTERNAL_TOOL_BAR (f)) wait_for_tool_bar = YES;
- else wait_for_tool_bar = NO;
-
-
-#ifdef NS_IMPL_COCOA
- {
- NSButton *toggleButton;
- toggleButton = [window standardWindowButton: NSWindowToolbarButton];
- [toggleButton setTarget: self];
- [toggleButton setAction: @selector (toggleToolbar: )];
- }
-#endif
-}
-
-
- (instancetype) initFrameFromEmacs: (struct frame *)f
{
NSTRACE ("[EmacsView initFrameFromEmacs:]");
if (ns_drag_types)
[self registerForDraggedTypes: ns_drag_types];
- /* toolbar support */
- if (! FRAME_UNDECORATED (f))
- [self createToolbar: f];
-
#if !defined (NS_IMPL_COCOA) \
|| MAC_OS_X_VERSION_MIN_REQUIRED <= 1090
#if MAC_OS_X_VERSION_MAX_ALLOWED > 1090
[NSApp setPresentationOptions: options];
}
#endif
- [toolbar setVisible:tbar_visible];
+ [[[self window]toolbar] setVisible:tbar_visible];
}
}
#endif
if (FRAME_EXTERNAL_TOOL_BAR (emacsframe))
{
- [toolbar setVisible:YES];
+ [[[self window] toolbar] setVisible:YES];
update_frame_tool_bar (emacsframe);
[[self window] display];
}
else
- [toolbar setVisible:NO];
+ [[[self window] toolbar] setVisible:NO];
if (next_maximized != -1)
[[self window] performZoom:self];
}
-- (EmacsToolbar *)toolbar
-{
- return toolbar;
-}
-
-
/* This gets called on toolbar button click. */
- (instancetype)toolbarClicked: (id)item
{
if ([col alphaComponent] != (EmacsCGFloat) 1.0)
[self setOpaque:NO];
+ /* toolbar support */
+ if (! FRAME_UNDECORATED (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.
Currently it only happens by accident and is buggy anyway. */
}
+- (void)createToolbar: (struct frame *)f
+{
+ EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f);
+
+ EmacsToolbar *toolbar = [[EmacsToolbar alloc]
+ initForView:view
+ withIdentifier:[NSString stringWithLispString:f->name]];
+ [self setToolbar:toolbar];
+
+ update_frame_tool_bar (f);
+
+#ifdef NS_IMPL_COCOA
+ {
+ NSButton *toggleButton;
+ toggleButton = [self standardWindowButton:NSWindowToolbarButton];
+ [toggleButton setTarget:view];
+ [toggleButton setAction:@selector (toggleToolbar:)];
+ }
+#endif
+}
+
+- (void)dealloc
+{
+ NSTRACE ("[EmacsWindow dealloc]");
+
+ /* We need to release the toolbar ourselves. */
+ [[self toolbar] release];
+ [super dealloc];
+}
+
- (NSInteger) borderWidth
{
return NSWidth ([self frame]) - NSWidth ([[self contentView] frame]);