(Cocoa GL) Refactor set_video_mode some more

This commit is contained in:
Twinaphex 2015-04-26 03:01:15 +02:00
parent 550ab997ee
commit ada0955642

View File

@ -256,28 +256,35 @@ static void cocoagl_gfx_ctx_show_mouse(void *data, bool state)
#endif
}
static bool cocoagl_gfx_ctx_set_video_mode(void *data, unsigned width, unsigned height, bool fullscreen)
static bool cocoagl_gfx_ctx_set_video_mode(void *data,
unsigned width, unsigned height, bool fullscreen)
{
#if defined(HAVE_COCOA)
static bool has_went_fullscreen = false;
CocoaView *g_view = (CocoaView*)nsview_get_ptr();
/* TODO: Screen mode support. */
if (fullscreen && !has_went_fullscreen)
if (fullscreen)
{
[g_view enterFullScreenMode:get_chosen_screen() withOptions:nil];
cocoagl_gfx_ctx_show_mouse(data, false);
if (!has_went_fullscreen)
{
[g_view enterFullScreenMode:get_chosen_screen() withOptions:nil];
cocoagl_gfx_ctx_show_mouse(data, false);
}
}
else if (!fullscreen && has_went_fullscreen)
else
{
[g_view exitFullScreenModeWithOptions:nil];
[[g_view window] makeFirstResponder:g_view];
cocoagl_gfx_ctx_show_mouse(data, true);
if (has_went_fullscreen)
{
[g_view exitFullScreenModeWithOptions:nil];
[[g_view window] makeFirstResponder:g_view];
cocoagl_gfx_ctx_show_mouse(data, true);
}
[[g_view window] setContentSize:NSMakeSize(width, height)];
}
has_went_fullscreen = fullscreen;
if (!has_went_fullscreen)
[[g_view window] setContentSize:NSMakeSize(width, height)];
#endif
(void)data;