summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Third <alan@idiocy.org>2021-06-12 12:52:15 +0100
committerAlan Third <alan@idiocy.org>2021-07-31 11:13:05 +0100
commit0b5cf4850990ff7b32264d2a174843fe72203cd0 (patch)
treecdf5ca231a514f42eef6b5811a82c7310560edc4
parent1ba02d85a964e1b2c6a9735cd3decdc524e06dc1 (diff)
downloademacs-0b5cf4850990ff7b32264d2a174843fe72203cd0.tar.gz
emacs-0b5cf4850990ff7b32264d2a174843fe72203cd0.tar.bz2
emacs-0b5cf4850990ff7b32264d2a174843fe72203cd0.zip
Move NS port toolbar handling to the window
* src/nsmenu.m (free_frame_tool_bar): (update_frame_tool_bar): Remove wait_for_tool_bar and get the toolbar from the window. * src/nsterm.h (EmacsView): Remove toolbar and wait_for_tool_bar. * src/nsterm.m (ns_update_begin): ([EmacsView windowDidEnterFullScreen]): ([EmacsView windowDidExitFullScreen]): Get the toolbar from the window, not the view. ([EmacsView dealloc]): Remove toolbar from view. ([EmacsView createToolbar:]): Move method to EmacsWindow. ([EmacsView initFrameFromEmacs:]): Don't create toolbar here any more. ([EmacsView toolbar]): Remove method. ([EmacsWindow initWithEmacsFrame:fullscreen:screen:]): Create toolbar here. ([EmacsWindow createToolbar:]): Moved from EmacsView. ([EmacsWindow dealloc]): Make sure we clean up the toolbar after closing the window.
-rw-r--r--src/nsmenu.m16
-rw-r--r--src/nsterm.h4
-rw-r--r--src/nsterm.m84
3 files changed, 42 insertions, 62 deletions
diff --git a/src/nsmenu.m b/src/nsmenu.m
index 1b03fe91a8b..673c0423d04 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -991,12 +991,11 @@ free_frame_tool_bar (struct frame *f)
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 ();
@@ -1009,12 +1008,12 @@ update_frame_tool_bar (struct frame *f)
-------------------------------------------------------------------------- */
{
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
@@ -1120,13 +1119,6 @@ update_frame_tool_bar (struct frame *f)
[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 ();
}
diff --git a/src/nsterm.h b/src/nsterm.h
index 40206cc4ded..f7ab8236b4c 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -453,9 +453,7 @@ typedef id instancetype;
@public
struct frame *emacsframe;
int scrollbarsNeedingUpdate;
- EmacsToolbar *toolbar;
NSRect ns_userRect;
- BOOL wait_for_tool_bar;
}
/* AppKit-side interface */
@@ -469,9 +467,7 @@ typedef id instancetype;
/* Emacs-side interface */
- (instancetype) initFrameFromEmacs: (struct frame *) f;
-- (void) createToolbar: (struct frame *)f;
- (void) setWindowClosing: (BOOL)closing;
-- (EmacsToolbar *) toolbar;
- (void) deleteWorkingText;
- (void) handleFS;
- (void) setFSValue: (int)value;
diff --git a/src/nsterm.m b/src/nsterm.m
index b8b306e685a..ba334d5fe90 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -1026,7 +1026,7 @@ ns_update_begin (struct frame *f)
{
// 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];
}
@@ -1745,9 +1745,6 @@ ns_set_undecorated (struct frame *f, Lisp_Object new_value, Lisp_Object old_valu
newWindow = [[EmacsWindow alloc] initWithEmacsFrame:f];
- if (!FRAME_UNDECORATED (f))
- [view createToolbar: f];
-
if ([oldWindow isKeyWindow])
[newWindow makeKeyAndOrderFront:NSApp];
@@ -6074,7 +6071,6 @@ not_in_argv (NSString *arg)
name:NSViewFrameDidChangeNotification
object:nil];
- [toolbar release];
if (fs_state == FULLSCREEN_BOTH)
[nonfs_window release];
[super dealloc];
@@ -7155,34 +7151,6 @@ not_in_argv (NSString *arg)
}
-- (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:]");
@@ -7234,10 +7202,6 @@ not_in_argv (NSString *arg)
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
@@ -7517,7 +7481,7 @@ not_in_argv (NSString *arg)
[NSApp setPresentationOptions: options];
}
#endif
- [toolbar setVisible:tbar_visible];
+ [[[self window]toolbar] setVisible:tbar_visible];
}
}
@@ -7560,12 +7524,12 @@ not_in_argv (NSString *arg)
#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];
@@ -7864,12 +7828,6 @@ not_in_argv (NSString *arg)
}
-- (EmacsToolbar *)toolbar
-{
- return toolbar;
-}
-
-
/* This gets called on toolbar button click. */
- (instancetype)toolbarClicked: (id)item
{
@@ -8421,6 +8379,10 @@ not_in_argv (NSString *arg)
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. */
@@ -8434,6 +8396,36 @@ not_in_argv (NSString *arg)
}
+- (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]);