Skip to content

Commit

Permalink
fix: properly detach window delegate, check full screen enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
ychin committed Jan 7, 2025
1 parent 7bc03be commit 8ceeca7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
20 changes: 11 additions & 9 deletions src/MacVim/MMFullScreenWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ - (void)enterFullScreen
{
ASLogDebug(@"Enter full-screen now");

// Detach the window delegate right now to prevent any stray resizing etc
// leading to undesired messages
NSWindowController *winController = [target windowController];
id delegate = [target delegate];
[winController setWindow:nil];
[target setDelegate:nil];

// Hide Dock and menu bar when going to full screen. Only do so if the current screen
// has a menu bar and dock.
if ([self screenHasDockAndMenu]) {
Expand All @@ -162,13 +169,6 @@ - (void)enterFullScreen
// this call so set the frame again just in case.
[self setFrame:[[target screen] frame] display:NO];

// fool delegate
id delegate = [target delegate];
[target setDelegate:nil];

// make target's window controller believe that it's now controlling us
[[target windowController] setWindow:self];

oldTabBarStyle = [[view tabBarControl] styleName];

NSString *style =
Expand All @@ -181,7 +181,7 @@ - (void)enterFullScreen
[view removeFromSuperviewWithoutNeedingDisplay];
[[self contentView] addSubview:view];
[self setInitialFirstResponder:[view textView]];

// NOTE: Calling setTitle:nil causes an exception to be raised (and it is
// possible that 'target' has no title when we get here).
if ([target title]) {
Expand All @@ -196,8 +196,10 @@ - (void)enterFullScreen

[self setOpaque:[target isOpaque]];

// reassign target's window controller to believe that it's now controlling us
// don't set this sooner, so we don't get an additional
// focus gained message
// focus gained message
[winController setWindow:self];
[self setDelegate:delegate];

// Store view dimension used before entering full-screen, then resize the
Expand Down
7 changes: 4 additions & 3 deletions src/MacVim/MMWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1328,9 +1328,7 @@ - (void)windowDidResize:(id)sender
// Calling setFrameSizeKeepGUISize: instead of setFrameSize: prevents a
// degenerate case where frameSizeMayHaveChanged: ends up resizing the window
// *again* causing windowDidResize: to be called.
if (fullScreenWindow == nil) {
[vimView setFrameSizeKeepGUISize:[self contentSize]];
} else {
if (fullScreenEnabled && fullScreenWindow != nil) {
// Non-native full screen mode is more complicated and needs to
// re-layout the Vim view to properly account for the menu bar / notch,
// and misc fuopt configuration.
Expand All @@ -1342,6 +1340,9 @@ - (void)windowDidResize:(id)sender
[vimView setFrameOrigin:desiredFrame.origin];
[vimView setFrameSizeKeepGUISize:desiredFrame.size];
}
else {
[vimView setFrameSizeKeepGUISize:[self contentSize]];
}
}

- (void)windowDidChangeBackingProperties:(NSNotification *)notification
Expand Down

0 comments on commit 8ceeca7

Please sign in to comment.