Common:AGL: Support making temporary contexts from the main thread

- Don't crash when making contexts from the main thread
- Don't focus the window when making a context
This commit is contained in:
TellowKrinkle 2023-06-10 02:35:29 -05:00
parent 7752e247f7
commit 28ed1f8be1
1 changed files with 9 additions and 4 deletions

View File

@ -38,9 +38,7 @@ static bool AttachContextToView(NSOpenGLContext* context, NSView* view, u32* wid
(void)UpdateCachedDimensions(view, width, height);
[window makeFirstResponder:view];
[context setView:view];
[window makeKeyAndOrderFront:nil];
return true;
}
@ -101,9 +99,16 @@ bool GLContextAGL::Initialize(const WindowSystemInfo& wsi, bool stereo, bool cor
m_opengl_mode = Mode::OpenGL;
__block bool success;
dispatch_sync(dispatch_get_main_queue(), ^{
if ([NSThread isMainThread])
{
success = AttachContextToView(m_context, m_view, &m_backbuffer_width, &m_backbuffer_height);
});
}
else
{
dispatch_sync(dispatch_get_main_queue(), ^{
success = AttachContextToView(m_context, m_view, &m_backbuffer_width, &m_backbuffer_height);
});
}
if (!success)
{