mirror of https://github.com/snes9xgit/snes9x.git
Mac: Fix pause fade after closing and reopening window
This commit is contained in:
parent
a4b207cbaa
commit
09dc8f19c0
|
@ -124,7 +124,10 @@ extern bool8 pressedKeys[MAC_MAX_PLAYERS][kNumButtons];
|
||||||
extern bool8 pressedGamepadButtons[MAC_MAX_PLAYERS][kNumButtons];
|
extern bool8 pressedGamepadButtons[MAC_MAX_PLAYERS][kNumButtons];
|
||||||
extern pthread_mutex_t keyLock;
|
extern pthread_mutex_t keyLock;
|
||||||
|
|
||||||
extern MTKView *s9xView;
|
@interface S9xView: MTKView
|
||||||
|
- (void)updatePauseOverlay;
|
||||||
|
@end
|
||||||
|
extern S9xView *s9xView;
|
||||||
|
|
||||||
void AdjustMenus (void);
|
void AdjustMenus (void);
|
||||||
void UpdateMenuCommandStatus (Boolean);
|
void UpdateMenuCommandStatus (Boolean);
|
||||||
|
|
|
@ -219,7 +219,7 @@ bool8 pressedRawKeyboardButtons[MAC_NUM_KEYCODES] = { 0 };
|
||||||
bool8 heldFunctionButtons[kNumFunctionButtons] = { 0 };
|
bool8 heldFunctionButtons[kNumFunctionButtons] = { 0 };
|
||||||
pthread_mutex_t keyLock;
|
pthread_mutex_t keyLock;
|
||||||
|
|
||||||
MTKView *s9xView;
|
S9xView *s9xView;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -348,6 +348,8 @@ static inline void EmulationLoop (void)
|
||||||
|
|
||||||
pauseEmulation = false;
|
pauseEmulation = false;
|
||||||
frameAdvance = false;
|
frameAdvance = false;
|
||||||
|
[s9xView updatePauseOverlay];
|
||||||
|
|
||||||
|
|
||||||
if (macQTRecord)
|
if (macQTRecord)
|
||||||
{
|
{
|
||||||
|
@ -2218,6 +2220,7 @@ static void ProcessInput (void)
|
||||||
|
|
||||||
case ToggleEmulationPause:
|
case ToggleEmulationPause:
|
||||||
pauseEmulation = !pauseEmulation;
|
pauseEmulation = !pauseEmulation;
|
||||||
|
[s9xView updatePauseOverlay];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AdvanceFrame:
|
case AdvanceFrame:
|
||||||
|
@ -2239,6 +2242,7 @@ static void ProcessInput (void)
|
||||||
if (ISpKeyIsPressed(keys, gamepadButtons, kISpEsc))
|
if (ISpKeyIsPressed(keys, gamepadButtons, kISpEsc))
|
||||||
{
|
{
|
||||||
pauseEmulation = true;
|
pauseEmulation = true;
|
||||||
|
[s9xView updatePauseOverlay];
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^
|
dispatch_async(dispatch_get_main_queue(), ^
|
||||||
{
|
{
|
||||||
|
@ -2796,9 +2800,6 @@ void QuitWithFatalError ( NSString *message)
|
||||||
[NSApp terminate:nil];
|
[NSApp terminate:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
@interface S9xView : MTKView
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation S9xView
|
@implementation S9xView
|
||||||
|
|
||||||
+ (void)initialize
|
+ (void)initialize
|
||||||
|
@ -2929,15 +2930,18 @@ void QuitWithFatalError ( NSString *message)
|
||||||
- (void)mouseDown:(NSEvent *)event
|
- (void)mouseDown:(NSEvent *)event
|
||||||
{
|
{
|
||||||
pauseEmulation = true;
|
pauseEmulation = true;
|
||||||
[self setNeedsDisplay:YES];
|
[s9xView updatePauseOverlay];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)drawRect:(NSRect)dirtyRect
|
- (void)updatePauseOverlay
|
||||||
{
|
{
|
||||||
self.subviews[0].hidden = !pauseEmulation;
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
CGFloat scaleFactor = MAX(self.window.backingScaleFactor, 1.0);
|
NSLog(@"%d", pauseEmulation);
|
||||||
glScreenW = self.frame.size.width * scaleFactor;
|
self.subviews[0].hidden = !pauseEmulation;
|
||||||
glScreenH = self.frame.size.height * scaleFactor;
|
CGFloat scaleFactor = MAX(self.window.backingScaleFactor, 1.0);
|
||||||
|
glScreenW = self.frame.size.width * scaleFactor;
|
||||||
|
glScreenH = self.frame.size.height * scaleFactor;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setFrame:(NSRect)frame
|
- (void)setFrame:(NSRect)frame
|
||||||
|
@ -3032,7 +3036,7 @@ void QuitWithFatalError ( NSString *message)
|
||||||
- (void)pause
|
- (void)pause
|
||||||
{
|
{
|
||||||
pauseEmulation = true;
|
pauseEmulation = true;
|
||||||
[s9xView setNeedsDisplay:YES];
|
[s9xView updatePauseOverlay];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)quit
|
- (void)quit
|
||||||
|
@ -3044,6 +3048,7 @@ void QuitWithFatalError ( NSString *message)
|
||||||
- (void)resume
|
- (void)resume
|
||||||
{
|
{
|
||||||
pauseEmulation = false;
|
pauseEmulation = false;
|
||||||
|
[s9xView updatePauseOverlay];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray<S9xJoypad *> *)listJoypads
|
- (NSArray<S9xJoypad *> *)listJoypads
|
||||||
|
|
|
@ -63,6 +63,7 @@ typedef struct
|
||||||
{
|
{
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
CAMetalLayer *metalLayer = nil;
|
CAMetalLayer *metalLayer = nil;
|
||||||
|
|
Loading…
Reference in New Issue