mirror of
https://github.com/libretro/RetroArch
synced 2025-02-27 00:40:20 +00:00
(OSX) Update gfx_context:
Now resizes window when asked Displays proper title in window No longen prints Cocoa warning at start up Now supports the pause_nonactive feature
This commit is contained in:
parent
d031d38e49
commit
20001489ac
@ -33,6 +33,7 @@ static UIView* g_pause_indicator_view;
|
|||||||
|
|
||||||
#include "apple_input.h"
|
#include "apple_input.h"
|
||||||
|
|
||||||
|
static bool g_has_went_fullscreen;
|
||||||
static RAGameView* g_instance;
|
static RAGameView* g_instance;
|
||||||
static NSOpenGLContext* g_context;
|
static NSOpenGLContext* g_context;
|
||||||
static NSOpenGLPixelFormat* g_format;
|
static NSOpenGLPixelFormat* g_format;
|
||||||
@ -312,10 +313,38 @@ void *apple_get_proc_address(const char *symbol_name)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void apple_update_window_title(void)
|
||||||
|
{
|
||||||
|
static char buf[128];
|
||||||
|
bool got_text = gfx_get_fps(buf, sizeof(buf), false);
|
||||||
|
#ifdef OSX
|
||||||
|
static const char* const text = buf; // < Can't access buf directly in the block
|
||||||
|
|
||||||
|
if (got_text)
|
||||||
|
{
|
||||||
|
// NOTE: This could go bad if buf is updated again before this completes.
|
||||||
|
// If it poses a problem it should be changed to dispatch_sync.
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^
|
||||||
|
{
|
||||||
|
g_view.window.title = @(text);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
bool apple_game_view_has_focus(void)
|
||||||
|
{
|
||||||
|
#ifdef OSX
|
||||||
|
return [NSApp isActive];
|
||||||
|
#else
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
bool apple_set_video_mode(unsigned width, unsigned height, bool fullscreen)
|
bool apple_set_video_mode(unsigned width, unsigned height, bool fullscreen)
|
||||||
{
|
{
|
||||||
__block bool result = true;
|
__block bool result = true;
|
||||||
|
|
||||||
#ifdef OSX
|
#ifdef OSX
|
||||||
dispatch_sync(dispatch_get_main_queue(),
|
dispatch_sync(dispatch_get_main_queue(),
|
||||||
^{
|
^{
|
||||||
@ -323,12 +352,24 @@ bool apple_set_video_mode(unsigned width, unsigned height, bool fullscreen)
|
|||||||
// TODO: Sceen mode support
|
// TODO: Sceen mode support
|
||||||
|
|
||||||
if (fullscreen)
|
if (fullscreen)
|
||||||
result = [g_view enterFullScreenMode:[NSScreen mainScreen] withOptions:nil];
|
{
|
||||||
|
if (!g_has_went_fullscreen)
|
||||||
|
result = [g_view enterFullScreenMode:[NSScreen mainScreen] withOptions:nil];
|
||||||
|
g_has_went_fullscreen = true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[g_view exitFullScreenModeWithOptions:nil];
|
if (g_has_went_fullscreen)
|
||||||
[g_view.window makeFirstResponder:g_view];
|
{
|
||||||
|
[g_view exitFullScreenModeWithOptions:nil];
|
||||||
|
[g_view.window makeFirstResponder:g_view];
|
||||||
|
}
|
||||||
|
g_has_went_fullscreen = false;
|
||||||
|
|
||||||
|
[g_view.window setContentSize:NSMakeSize(width, height)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_has_went_fullscreen = fullscreen;
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -23,13 +23,15 @@ char* ios_get_rarch_system_directory();
|
|||||||
// These functions should only be called as arguments to dispatch_sync
|
// These functions should only be called as arguments to dispatch_sync
|
||||||
void apple_rarch_exited (void* result);
|
void apple_rarch_exited (void* result);
|
||||||
|
|
||||||
// These functions must only be called in gfx/context/ioseagl_ctx.c
|
// These functions must only be called in gfx/context/apple_gl_context.c
|
||||||
bool apple_init_game_view(void);
|
bool apple_init_game_view(void);
|
||||||
void apple_destroy_game_view(void);
|
void apple_destroy_game_view(void);
|
||||||
bool apple_set_video_mode(unsigned width, unsigned height, bool fullscreen);
|
bool apple_set_video_mode(unsigned width, unsigned height, bool fullscreen);
|
||||||
void apple_flip_game_view(void);
|
void apple_flip_game_view(void);
|
||||||
void apple_set_game_view_sync(unsigned interval);
|
void apple_set_game_view_sync(unsigned interval);
|
||||||
void apple_get_game_view_size(unsigned *width, unsigned *height);
|
void apple_get_game_view_size(unsigned *width, unsigned *height);
|
||||||
|
void apple_update_window_title(void);
|
||||||
|
bool apple_game_view_has_focus(void);
|
||||||
void *apple_get_proc_address(const char *symbol_name);
|
void *apple_get_proc_address(const char *symbol_name);
|
||||||
|
|
||||||
#ifdef IOS
|
#ifdef IOS
|
||||||
|
@ -38,19 +38,6 @@ static bool gfx_ctx_bind_api(enum gfx_ctx_api api, unsigned major, unsigned mino
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool gfx_ctx_set_video_mode(
|
|
||||||
unsigned width, unsigned height,
|
|
||||||
bool fullscreen)
|
|
||||||
{
|
|
||||||
return apple_set_video_mode(width, height, fullscreen);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void gfx_ctx_update_window_title(void)
|
|
||||||
{
|
|
||||||
char buf[128];
|
|
||||||
gfx_get_fps(buf, sizeof(buf), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void gfx_ctx_check_window(bool *quit,
|
static void gfx_ctx_check_window(bool *quit,
|
||||||
bool *resize, unsigned *width, unsigned *height, unsigned frame_count)
|
bool *resize, unsigned *width, unsigned *height, unsigned frame_count)
|
||||||
{
|
{
|
||||||
@ -74,16 +61,6 @@ static void gfx_ctx_set_resize(unsigned width, unsigned height)
|
|||||||
(void)height;
|
(void)height;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool gfx_ctx_has_focus(void)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void gfx_ctx_swap_buffers(void)
|
|
||||||
{
|
|
||||||
apple_flip_game_view();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void gfx_ctx_input_driver(const input_driver_t **input, void **input_data)
|
static void gfx_ctx_input_driver(const input_driver_t **input, void **input_data)
|
||||||
{
|
{
|
||||||
*input = NULL;
|
*input = NULL;
|
||||||
@ -102,13 +79,13 @@ const gfx_ctx_driver_t gfx_ctx_apple = {
|
|||||||
apple_destroy_game_view,
|
apple_destroy_game_view,
|
||||||
gfx_ctx_bind_api,
|
gfx_ctx_bind_api,
|
||||||
apple_set_game_view_sync,
|
apple_set_game_view_sync,
|
||||||
gfx_ctx_set_video_mode,
|
apple_set_video_mode,
|
||||||
apple_get_game_view_size,
|
apple_get_game_view_size,
|
||||||
NULL,
|
NULL,
|
||||||
gfx_ctx_update_window_title,
|
apple_update_window_title,
|
||||||
gfx_ctx_check_window,
|
gfx_ctx_check_window,
|
||||||
gfx_ctx_set_resize,
|
gfx_ctx_set_resize,
|
||||||
gfx_ctx_has_focus,
|
apple_game_view_has_focus,
|
||||||
apple_flip_game_view,
|
apple_flip_game_view,
|
||||||
gfx_ctx_input_driver,
|
gfx_ctx_input_driver,
|
||||||
gfx_ctx_get_proc_address,
|
gfx_ctx_get_proc_address,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user