Skip to content

Commit

Permalink
Add some rudimentary sanity check to GlkController adjustContentView
Browse files Browse the repository at this point in the history
Hopefully this helps with #32, but as I still don't have a way to reproduce it,
it is only a shot in the dark.
  • Loading branch information
angstsmurf committed Apr 22, 2021
1 parent dbfffef commit 6cdcfe9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
8 changes: 6 additions & 2 deletions application/GlkController.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@

#define MAXWIN 64

@interface GlkHelperView : NSView {
}
typedef enum kMinimumWindowSize : NSUInteger {
kMinimumWindowWidth = 213,
kMinimumWindowHeight = 107,
} kkMinimumWindowSize;

@interface GlkHelperView : NSView

@property (weak) IBOutlet GlkController *glkctrl;

Expand Down
21 changes: 18 additions & 3 deletions application/GlkController.m
Original file line number Diff line number Diff line change
Expand Up @@ -3740,14 +3740,29 @@ - (void)makeAndPrepareSnapshotWindow {

// Some convenience methods
- (void)adjustContentView {
NSRect frame;
if ((self.window.styleMask & NSFullScreenWindowMask) == NSFullScreenWindowMask ||
NSEqualRects(_borderView.frame, self.window.screen.frame) || (dead && _inFullscreen && windowRestoredBySystem)) {
// We are in fullscreen
_contentView.frame = [self contentFrameForFullscreen];
frame = [self contentFrameForFullscreen];
} else {
// We are not in fullscreen
_contentView.frame = [self contentFrameForWindowed];
}
frame = [self contentFrameForWindowed];
}
if (frame.size.width < kMinimumWindowWidth)
frame.size.width = kMinimumWindowWidth;
if (frame.size.height < kMinimumWindowHeight)
frame.size.width = kMinimumWindowHeight;

NSRect windowframe = self.window.frame;
if (windowframe.size.width < kMinimumWindowWidth)
windowframe.size.width = kMinimumWindowWidth;
if (windowframe.size.height < kMinimumWindowHeight)
windowframe.size.width = kMinimumWindowHeight;
if (!NSEqualRects(self.window.frame, windowframe))
[self.window setFrame:windowframe display:YES];

_contentView.frame = frame;
}

- (NSRect)contentFrameForWindowed {
Expand Down

0 comments on commit 6cdcfe9

Please sign in to comment.