diff options
author | Loïc Hoguin <[email protected]> | 2017-12-20 20:03:16 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2017-12-20 20:03:16 +0100 |
commit | b0950785e72d9d59c6fd816c01d203ecb083c663 (patch) | |
tree | 38cfae31a019ffe7b90d60dea2f6f01c3830e4b3 /c_src/sdl_window.c | |
parent | e4f6a3c1f1032f83b25210dea21bbacf4552f8f0 (diff) | |
download | esdl2-b0950785e72d9d59c6fd816c01d203ecb083c663.tar.gz esdl2-b0950785e72d9d59c6fd816c01d203ecb083c663.tar.bz2 esdl2-b0950785e72d9d59c6fd816c01d203ecb083c663.zip |
Add the sdl_mouse module implementing half of sdl_mouse.h
The latter half will be part of sdl_cursor.
This depends on some changes to nif_helper. The sdl_gl part of
the code is probably slithly broken now, the dependency on the
window is gone. This will be resolved later on.
Diffstat (limited to 'c_src/sdl_window.c')
-rw-r--r-- | c_src/sdl_window.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/c_src/sdl_window.c b/c_src/sdl_window.c index ef3647b..c286da0 100644 --- a/c_src/sdl_window.c +++ b/c_src/sdl_window.c @@ -14,9 +14,13 @@ #include "esdl2.h" +// @todo These operations should probably occur in the thread. void dtor_Window(ErlNifEnv* env, void* obj) { - SDL_DestroyWindow(NIF_RES_GET(Window, obj)); + SDL_Window* window = NIF_RES_GET(Window, obj); + + SDL_DestroyWindow(window); + esdl2_windows_remove(window); } #define WINDOW_FLAGS(F) \ @@ -33,7 +37,8 @@ void dtor_Window(ErlNifEnv* env, void* obj) F(input_focus, SDL_WINDOW_INPUT_FOCUS) \ F(mouse_focus, SDL_WINDOW_MOUSE_FOCUS) \ F(foreign, SDL_WINDOW_FOREIGN) \ - F(allow_high_dpi, SDL_WINDOW_ALLOW_HIGHDPI) + F(allow_high_dpi, SDL_WINDOW_ALLOW_HIGHDPI) \ + F(mouse_capture, SDL_WINDOW_MOUSE_CAPTURE) static NIF_LIST_TO_FLAGS_FUNCTION(list_to_window_flags, Uint32, WINDOW_FLAGS) static NIF_FLAGS_TO_LIST_FUNCTION(window_flags_to_list, Uint32, WINDOW_FLAGS) @@ -56,6 +61,7 @@ static NIF_ATOM_TO_ENUM_FUNCTION(atom_to_window_fullscreen, Uint32, WINDOW_FULLS NIF_CALL_HANDLER(thread_create_window) { SDL_Window* window; + obj_Window* res; ERL_NIF_TERM term; window = SDL_CreateWindow(args[0], (long)args[1], (long)args[2], (long)args[3], (long)args[4], (long)args[5]); @@ -65,7 +71,9 @@ NIF_CALL_HANDLER(thread_create_window) if (!window) return sdl_error_tuple(env); - NIF_RES_TO_TERM(Window, window, term); + NIF_RES_TO_PTR_AND_TERM(Window, window, res, term); + + esdl2_windows_insert(window, res); return enif_make_tuple2(env, atom_ok, |