mirror of
https://github.com/libretro/RetroArch
synced 2025-02-06 09:40:06 +00:00
Merge pull request #6990 from stuartcarnie/sgc-metal
fix(Cocoa): Fix blank screen after full screen toggle; window focus
This commit is contained in:
commit
a34e29c037
@ -104,6 +104,16 @@
|
||||
.height = _video.height,
|
||||
.fullscreen = _video.fullscreen,
|
||||
};
|
||||
|
||||
if (mode.width == 0 || mode.height == 0)
|
||||
{
|
||||
// 0 indicates full screen, so we'll use the view's dimensions, which should already be full screen
|
||||
// If this turns out to be the wrong assumption, we can use NSScreen to query the dimensions
|
||||
CGSize size = view.frame.size;
|
||||
mode.width = (unsigned int)size.width;
|
||||
mode.height = (unsigned int)size.height;
|
||||
}
|
||||
|
||||
[apple_platform setVideoMode:mode];
|
||||
|
||||
*input = NULL;
|
||||
@ -213,6 +223,8 @@
|
||||
|
||||
- (void)_updateViewport:(CGSize)size
|
||||
{
|
||||
RARCH_LOG("[Metal]: _updateViewport size %.0fx%.0f\n", size.width, size.height);
|
||||
|
||||
_viewport->full_width = (unsigned int)size.width;
|
||||
_viewport->full_height = (unsigned int)size.height;
|
||||
video_driver_set_size(&_viewport->full_width, &_viewport->full_height);
|
||||
|
@ -55,6 +55,14 @@
|
||||
0538875720DE11D300769232 /* retro_assert.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = retro_assert.h; sourceTree = "<group>"; };
|
||||
0538875820DE11D300769232 /* retro_endianness.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = retro_endianness.h; sourceTree = "<group>"; };
|
||||
0538875920DE11D300769232 /* libretro.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = libretro.h; sourceTree = "<group>"; };
|
||||
0548E2B220F976E10094A083 /* driver.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = driver.c; path = ../../driver.c; sourceTree = "<group>"; };
|
||||
0548E2B320F976E10094A083 /* dynamic.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = dynamic.c; path = ../../dynamic.c; sourceTree = "<group>"; };
|
||||
0548E2B420F976E10094A083 /* dynamic.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = dynamic.h; path = ../../dynamic.h; sourceTree = "<group>"; };
|
||||
0548E2B520F976E20094A083 /* driver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = driver.h; path = ../../driver.h; sourceTree = "<group>"; };
|
||||
0548E2B620F977060094A083 /* playlist.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = playlist.h; path = ../../playlist.h; sourceTree = "<group>"; };
|
||||
0548E2B720F977060094A083 /* performance_counters.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = performance_counters.h; path = ../../performance_counters.h; sourceTree = "<group>"; };
|
||||
0548E2B820F977060094A083 /* performance_counters.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = performance_counters.c; path = ../../performance_counters.c; sourceTree = "<group>"; };
|
||||
0548E2B920F977060094A083 /* playlist.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = playlist.c; path = ../../playlist.c; sourceTree = "<group>"; };
|
||||
055312AB20DE130A00C4D7F4 /* gl_capabilities.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = gl_capabilities.c; sourceTree = "<group>"; };
|
||||
055312AD20DE130A00C4D7F4 /* scaler_int.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = scaler_int.c; sourceTree = "<group>"; };
|
||||
055312AE20DE130A00C4D7F4 /* pixconv.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = pixconv.c; sourceTree = "<group>"; };
|
||||
@ -1070,8 +1078,6 @@
|
||||
05BF821320ED69A500D95B19 /* core */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
05B5F91120ED6AAE009C521F /* retroarch.c */,
|
||||
05B5F91220ED6AAF009C521F /* retroarch.h */,
|
||||
05B5F90F20ED6A03009C521F /* command.c */,
|
||||
05BF821720ED69D100D95B19 /* command.h */,
|
||||
05BF821420ED69D100D95B19 /* config.def.h */,
|
||||
@ -1085,6 +1091,16 @@
|
||||
05BF821B20ED69D100D95B19 /* core_info.h */,
|
||||
05B5F90E20ED6A03009C521F /* core_type.h */,
|
||||
05BF821920ED69D100D95B19 /* core.h */,
|
||||
0548E2B220F976E10094A083 /* driver.c */,
|
||||
0548E2B520F976E20094A083 /* driver.h */,
|
||||
0548E2B320F976E10094A083 /* dynamic.c */,
|
||||
0548E2B420F976E10094A083 /* dynamic.h */,
|
||||
0548E2B820F977060094A083 /* performance_counters.c */,
|
||||
0548E2B720F977060094A083 /* performance_counters.h */,
|
||||
0548E2B920F977060094A083 /* playlist.c */,
|
||||
0548E2B620F977060094A083 /* playlist.h */,
|
||||
05B5F91120ED6AAE009C521F /* retroarch.c */,
|
||||
05B5F91220ED6AAF009C521F /* retroarch.h */,
|
||||
);
|
||||
name = core;
|
||||
sourceTree = "<group>";
|
||||
|
@ -42,6 +42,24 @@
|
||||
#import <MetalKit/MetalKit.h>
|
||||
#endif
|
||||
|
||||
@interface WindowListener : NSResponder<NSWindowDelegate>
|
||||
@end
|
||||
|
||||
@implementation WindowListener
|
||||
|
||||
/* Similarly to SDL, we'll respond to key events by doing nothing so we don't beep.
|
||||
*/
|
||||
- (void)flagsChanged:(NSEvent *)event
|
||||
{}
|
||||
|
||||
- (void)keyDown:(NSEvent *)event
|
||||
{}
|
||||
|
||||
- (void)keyUp:(NSEvent *)event
|
||||
{}
|
||||
|
||||
@end
|
||||
|
||||
id<ApplePlatform> apple_platform;
|
||||
|
||||
#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__)))
|
||||
@ -54,7 +72,7 @@ id<ApplePlatform> apple_platform;
|
||||
apple_view_type_t _vt;
|
||||
NSView* _renderView;
|
||||
id _sleepActivity;
|
||||
|
||||
WindowListener *_listener;
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) NSWindow IBOutlet* window;
|
||||
@ -109,7 +127,7 @@ static void app_terminate(void)
|
||||
case NSEventTypeKeyDown:
|
||||
case NSEventTypeKeyUp:
|
||||
{
|
||||
NSString* ch = (NSString*)event.characters;
|
||||
NSString* ch = event.characters;
|
||||
uint32_t character = 0;
|
||||
uint32_t mod = 0;
|
||||
|
||||
@ -164,13 +182,13 @@ static void app_terminate(void)
|
||||
return;
|
||||
|
||||
/* Relative */
|
||||
apple->mouse_rel_x = event.deltaX;
|
||||
apple->mouse_rel_y = event.deltaY;
|
||||
apple->mouse_rel_x = (int16_t)event.deltaX;
|
||||
apple->mouse_rel_y = (int16_t)event.deltaY;
|
||||
|
||||
/* Absolute */
|
||||
pos = [apple_platform.renderView convertPoint:[event locationInWindow] fromView:nil];
|
||||
apple->touches[0].screen_x = pos.x;
|
||||
apple->touches[0].screen_y = pos.y;
|
||||
apple->touches[0].screen_x = (int16_t)pos.x;
|
||||
apple->touches[0].screen_y = (int16_t)pos.y;
|
||||
|
||||
mouse_pos = [apple_platform.renderView convertPoint:[event locationInWindow] fromView:nil];
|
||||
apple->window_pos_x = (int16_t)mouse_pos.x;
|
||||
@ -245,7 +263,12 @@ static char** waiting_argv;
|
||||
[self.window setCollectionBehavior:NS_WINDOW_COLLECTION_BEHAVIOR_FULLSCREEN_PRIMARY];
|
||||
}
|
||||
#endif
|
||||
|
||||
_listener = [WindowListener new];
|
||||
|
||||
[self.window setAcceptsMouseMovedEvents: YES];
|
||||
[self.window setNextResponder:_listener];
|
||||
self.window.delegate = _listener;
|
||||
|
||||
[[self.window contentView] setAutoresizesSubviews:YES];
|
||||
|
||||
@ -263,6 +286,9 @@ static char** waiting_argv;
|
||||
|
||||
waiting_argc = 0;
|
||||
|
||||
[self.window makeMainWindow];
|
||||
[self.window makeKeyWindow];
|
||||
|
||||
[self performSelectorOnMainThread:@selector(rarch_main) withObject:nil waitUntilDone:NO];
|
||||
}
|
||||
|
||||
@ -271,7 +297,7 @@ static char** waiting_argv;
|
||||
return;
|
||||
}
|
||||
|
||||
RARCH_LOG("[Cocoa] change view type: %d → %d\n", _vt, vt);
|
||||
RARCH_LOG("[Cocoa]: change view type: %d → %d\n", _vt, vt);
|
||||
|
||||
_vt = vt;
|
||||
if (_renderView != nil)
|
||||
@ -279,6 +305,7 @@ static char** waiting_argv;
|
||||
_renderView.wantsLayer = NO;
|
||||
_renderView.layer = nil;
|
||||
[_renderView removeFromSuperview];
|
||||
self.window.contentView = nil;
|
||||
_renderView = nil;
|
||||
}
|
||||
|
||||
@ -309,8 +336,8 @@ static char** waiting_argv;
|
||||
_renderView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
|
||||
_renderView.frame = self.window.contentView.bounds;
|
||||
|
||||
[self.window.contentView addSubview:_renderView];
|
||||
[self.window makeFirstResponder:_renderView];
|
||||
self.window.contentView = _renderView;
|
||||
[self.window.contentView setNextResponder:_listener];
|
||||
}
|
||||
|
||||
- (apple_view_type_t)viewType {
|
||||
|
Loading…
x
Reference in New Issue
Block a user