Mac: Fix redraw issues on dual monitor setups when closing and reopening the window
This commit is contained in:
parent
09dc8f19c0
commit
bdd7db354d
@ -52,13 +52,6 @@ static NSWindowFrameAutosaveName const kMainWindowIdentifier = @"s9xMainWindow";
|
|||||||
window.frameAutosaveName = kMainWindowIdentifier;
|
window.frameAutosaveName = kMainWindowIdentifier;
|
||||||
window.releasedWhenClosed = NO;
|
window.releasedWhenClosed = NO;
|
||||||
|
|
||||||
[window.contentView addSubview:s9xView];
|
|
||||||
[s9xView.topAnchor constraintEqualToAnchor:window.contentView.topAnchor].active = YES;
|
|
||||||
[s9xView.bottomAnchor constraintEqualToAnchor:window.contentView.bottomAnchor].active = YES;
|
|
||||||
[s9xView.centerXAnchor constraintEqualToAnchor:window.contentView.centerXAnchor].active = YES;
|
|
||||||
[s9xView.leftAnchor constraintGreaterThanOrEqualToAnchor:window.contentView.leftAnchor].active = YES;
|
|
||||||
[s9xView.rightAnchor constraintLessThanOrEqualToAnchor:window.contentView.rightAnchor].active = YES;
|
|
||||||
|
|
||||||
if ( ![window setFrameUsingName:kMainWindowIdentifier] )
|
if ( ![window setFrameUsingName:kMainWindowIdentifier] )
|
||||||
{
|
{
|
||||||
[window center];
|
[window center];
|
||||||
@ -456,8 +449,18 @@ static NSWindowFrameAutosaveName const kMainWindowIdentifier = @"s9xMainWindow";
|
|||||||
{
|
{
|
||||||
if ([self.s9xEngine loadROM:url])
|
if ([self.s9xEngine loadROM:url])
|
||||||
{
|
{
|
||||||
|
[self.s9xEngine recreateS9xView];
|
||||||
|
|
||||||
[self.window makeKeyAndOrderFront:self];
|
NSWindow *window = self.window;
|
||||||
|
[window.contentView addSubview:s9xView];
|
||||||
|
[s9xView.topAnchor constraintEqualToAnchor:window.contentView.topAnchor].active = YES;
|
||||||
|
[s9xView.bottomAnchor constraintEqualToAnchor:window.contentView.bottomAnchor].active = YES;
|
||||||
|
[s9xView.centerXAnchor constraintEqualToAnchor:window.contentView.centerXAnchor].active = YES;
|
||||||
|
[s9xView.leftAnchor constraintGreaterThanOrEqualToAnchor:window.contentView.leftAnchor].active = YES;
|
||||||
|
[s9xView.rightAnchor constraintLessThanOrEqualToAnchor:window.contentView.rightAnchor].active = YES;
|
||||||
|
|
||||||
|
|
||||||
|
[window makeKeyAndOrderFront:self];
|
||||||
[NSDocumentController.sharedDocumentController noteNewRecentDocumentURL:url];
|
[NSDocumentController.sharedDocumentController noteNewRecentDocumentURL:url];
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
@ -164,6 +164,8 @@ extern id<S9xInputDelegate> inputDelegate;
|
|||||||
|
|
||||||
@property (nonatomic, weak) id<S9xInputDelegate> inputDelegate;
|
@property (nonatomic, weak) id<S9xInputDelegate> inputDelegate;
|
||||||
|
|
||||||
|
- (void)recreateS9xView;
|
||||||
|
|
||||||
- (void)start;
|
- (void)start;
|
||||||
- (void)stop;
|
- (void)stop;
|
||||||
|
|
||||||
|
@ -2976,15 +2976,7 @@ void QuitWithFatalError ( NSString *message)
|
|||||||
if (self = [super init])
|
if (self = [super init])
|
||||||
{
|
{
|
||||||
Initialize();
|
Initialize();
|
||||||
|
[self recreateS9xView];
|
||||||
CGRect frame = NSMakeRect(0, 0, SNES_WIDTH * 2, SNES_HEIGHT * 2);
|
|
||||||
s9xView = [[S9xView alloc] initWithFrame:frame];
|
|
||||||
s9xView.translatesAutoresizingMaskIntoConstraints = NO;
|
|
||||||
s9xView.autoresizingMask = NSViewWidthSizable|NSViewHeightSizable;
|
|
||||||
[s9xView addConstraint:[NSLayoutConstraint constraintWithItem:s9xView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:s9xView attribute:NSLayoutAttributeWidth multiplier:(CGFloat)SNES_HEIGHT/(CGFloat)SNES_WIDTH constant:0.0]];
|
|
||||||
[s9xView addConstraint:[NSLayoutConstraint constraintWithItem:s9xView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationGreaterThanOrEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:SNES_WIDTH * 2.0]];
|
|
||||||
[s9xView addConstraint:[NSLayoutConstraint constraintWithItem:s9xView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationGreaterThanOrEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:SNES_HEIGHT * 2.0]];
|
|
||||||
s9xView.device = MTLCreateSystemDefaultDevice();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
@ -2995,6 +2987,21 @@ void QuitWithFatalError ( NSString *message)
|
|||||||
Deinitialize();
|
Deinitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)recreateS9xView
|
||||||
|
{
|
||||||
|
[s9xView removeFromSuperview];
|
||||||
|
S9xDeinitDisplay();
|
||||||
|
CGRect frame = NSMakeRect(0, 0, SNES_WIDTH * 2, SNES_HEIGHT * 2);
|
||||||
|
s9xView = [[S9xView alloc] initWithFrame:frame];
|
||||||
|
s9xView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||||
|
s9xView.autoresizingMask = NSViewWidthSizable|NSViewHeightSizable;
|
||||||
|
[s9xView addConstraint:[NSLayoutConstraint constraintWithItem:s9xView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:s9xView attribute:NSLayoutAttributeWidth multiplier:(CGFloat)SNES_HEIGHT/(CGFloat)SNES_WIDTH constant:0.0]];
|
||||||
|
[s9xView addConstraint:[NSLayoutConstraint constraintWithItem:s9xView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationGreaterThanOrEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:SNES_WIDTH * 2.0]];
|
||||||
|
[s9xView addConstraint:[NSLayoutConstraint constraintWithItem:s9xView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationGreaterThanOrEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:SNES_HEIGHT * 2.0]];
|
||||||
|
s9xView.device = MTLCreateSystemDefaultDevice();
|
||||||
|
S9xInitDisplay(NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
- (void)start
|
- (void)start
|
||||||
{
|
{
|
||||||
#ifdef DEBUGGER
|
#ifdef DEBUGGER
|
||||||
|
Loading…
Reference in New Issue
Block a user