diff options
author | Loïc Hoguin <[email protected]> | 2015-10-16 21:35:55 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2015-10-16 21:35:55 +0200 |
commit | 256c3dbc47130a5e282bb306ceb117359729d151 (patch) | |
tree | da1bd55d3c7f7a946bb5324723db086d8a26656c /c_src | |
parent | c9760250b4c22b1c842421c087a17534c72cbeeb (diff) | |
download | esdl2-256c3dbc47130a5e282bb306ceb117359729d151.tar.gz esdl2-256c3dbc47130a5e282bb306ceb117359729d151.tar.bz2 esdl2-256c3dbc47130a5e282bb306ceb117359729d151.zip |
Steal the main thread on OSX
Should fix issues with events not being handled properly, and
possibly other things. Taken from Erlang's wx, which is proven
to work. The function used is unfortunately undocumented.
Not 100% sure everything is good with just that, it looks good
enough on my VM, but I still have issues probably due to trying
this on a VM.
Diffstat (limited to 'c_src')
-rw-r--r-- | c_src/nif_helpers.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/c_src/nif_helpers.c b/c_src/nif_helpers.c index f655497..0528b35 100644 --- a/c_src/nif_helpers.c +++ b/c_src/nif_helpers.c @@ -168,7 +168,13 @@ void* nif_create_main_thread(char* name) st->mailbox = (nif_thread_mailbox*)enif_alloc(sizeof(nif_thread_mailbox)); TAILQ_INIT(st->mailbox); +#ifdef __DARWIN__ + // On OSX, SDL2 must run in the main thread, otherwise some operations + // will not work properly. For example, input events would not be received. + erl_drv_steal_main_thread(name, &(st->tid), nif_main_thread, st, NULL); +#else enif_thread_create(name, &(st->tid), nif_main_thread, st, NULL); +#endif return (void*)st; } |