Skip to content

Commit

Permalink
Add better logging for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
ychin committed Jan 7, 2025
1 parent 21191f3 commit bf22e63
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
6 changes: 6 additions & 0 deletions src/MacVim/MMFullScreenWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,12 @@ - (NSRect)getDesiredFrame;
windowFrame.size.width -= (viewOffset.left + viewOffset.right);
NSSize desiredFrameSize = windowFrame.size;

NSLog(@"getDesiredFrame state:%d windowFrame: %@ nonFuVimViewSize: %@",
state,
NSStringFromRect(windowFrame),
NSStringFromSize(nonFuVimViewSize)
);

if (!(options & FUOPT_MAXVERT))
desiredFrameSize.height = MIN(desiredFrameSize.height, nonFuVimViewSize.height);
if (!(options & FUOPT_MAXHORZ))
Expand Down
9 changes: 8 additions & 1 deletion src/MacVim/MMVimView.m
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,7 @@ - (void)frameSizeMayHaveChanged:(BOOL)keepGUISize
// Give all superfluous space to the text view. It might be smaller or
// larger than it wants to be, but this is needed during live resizing.
NSRect textViewRect = [self textViewRectForVimViewSize:[self frame].size];
NSRect oldTextFrame = [textView frame];
[textView setFrame:textViewRect];

// Immediately place the scrollbars instead of deferring till later here.
Expand Down Expand Up @@ -955,7 +956,13 @@ - (void)frameSizeMayHaveChanged:(BOOL)keepGUISize


os_log(OS_LOG_DEFAULT, "frameSizeMayHaveChanged constrained[0] <= 0: %d", constrained[0]);
NSLog(@"textView frame : %@", NSStringFromRect([textView frame]));
NSLog(@"textView (keepGUI %d) text_frame: %@ -> %@ self_frame: %@ resolution: %@",
keepGUISize,
NSStringFromRect(oldTextFrame),
NSStringFromRect([textView frame]),
NSStringFromRect([self frame]),
NSStringFromRect([NSScreen mainScreen].frame)
);
if (constrained[0] <= 0) {
NSLog(@"Stack trace : %@",[NSThread callStackSymbols]);
}
Expand Down
8 changes: 8 additions & 0 deletions src/MacVim/MMWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,7 @@ - (void)processInputQueueDidFinish
NSSize frameSize;
if (fullScreenWindow) {
// Non-native full screen mode.
NSLog(@"getDesiredFrame (processInputQueueDidFinish)");
NSRect desiredFrame = [fullScreenWindow getDesiredFrame];
frameSize = desiredFrame.size;
[vimView setFrameOrigin:desiredFrame.origin]; // This will get set back to normal in MMFullScreenWindow::leaveFullScreen.
Expand Down Expand Up @@ -1013,6 +1014,8 @@ - (void)enterFullScreen:(int)fuoptions backgroundColor:(NSColor *)back
[fullScreenWindow setRepresentedFilename:
[decoratedWindow representedFilename]];

NSLog(@"enterFullScreen: presented: %d", windowPresented);

// NOTE: Do not enter full-screen until the window has been presented
// since we don't actually know which screen to use before then. (The
// custom full-screen can appear on any screen, as opposed to native
Expand Down Expand Up @@ -1315,6 +1318,8 @@ - (void)windowDidResize:(id)sender
&& fullScreenEnabled)
return;

NSLog(@"windowDidResize: %@", NSStringFromRect([self window].frame));

// NOTE: Since we have no control over when the window may resize (Cocoa
// may resize automatically) we simply set the view to fill the entire
// window. The vim view takes care of notifying Vim if the number of
Expand All @@ -1329,6 +1334,9 @@ - (void)windowDidResize:(id)sender
// re-layout the Vim view to properly account for the menu bar / notch,
// and misc fuopt configuration.
// This code is similar to what's done in processInputQueueDidFinish.
NSLog(@"getDesiredFrame (windowDidResize)");
NSLog(@"Stack trace : %@",[NSThread callStackSymbols]);

NSRect desiredFrame = [fullScreenWindow getDesiredFrame];
[vimView setFrameOrigin:desiredFrame.origin];
[vimView setFrameSizeKeepGUISize:desiredFrame.size];
Expand Down
8 changes: 4 additions & 4 deletions src/MacVim/MacVimTests/MacVimTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -886,16 +886,16 @@ - (void) testFullScreenNonNativeOptions {
[self sendStringToVim:@":set lines=10\n" withMods:0];
[self sendStringToVim:@":set columns=30\n" withMods:0];
[self sendStringToVim:@":set fuoptions=\n" withMods:0];
os_log(OS_LOG_DEFAULT, "testFullScreenNonNativeOptions: maxRows: %d, maxColumns: %d", textView.maxRows, textView.maxColumns);
os_log(OS_LOG_DEFAULT, "testFullScreenNonNativeOptions 1: maxRows: %d, maxColumns: %d", textView.maxRows, textView.maxColumns);
[self waitForVimProcess];
[self waitForEventHandlingAndVimProcess]; // test test
[self waitForEventHandlingAndVimProcess]; // test test
os_log(OS_LOG_DEFAULT, "testFullScreenNonNativeOptions: maxRows: %d, maxColumns: %d", textView.maxRows, textView.maxColumns);
os_log(OS_LOG_DEFAULT, "testFullScreenNonNativeOptions 2: maxRows: %d, maxColumns: %d", textView.maxRows, textView.maxColumns);

[self sendStringToVim:@":set fu\n" withMods:0];
os_log(OS_LOG_DEFAULT, "testFullScreenNonNativeOptions: maxRows: %d, maxColumns: %d", textView.maxRows, textView.maxColumns);
os_log(OS_LOG_DEFAULT, "testFullScreenNonNativeOptions 3: maxRows: %d, maxColumns: %d", textView.maxRows, textView.maxColumns);
[self waitForEventHandlingAndVimProcess];
os_log(OS_LOG_DEFAULT, "testFullScreenNonNativeOptions: maxRows: %d, maxColumns: %d", textView.maxRows, textView.maxColumns);
os_log(OS_LOG_DEFAULT, "testFullScreenNonNativeOptions 4: maxRows: %d, maxColumns: %d", textView.maxRows, textView.maxColumns);
[self waitForEventHandlingAndVimProcess];
XCTAssertEqual(textView.maxRows, 10);
XCTAssertEqual(textView.maxColumns, 30);
Expand Down

0 comments on commit bf22e63

Please sign in to comment.