diff options
Diffstat (limited to 'c_src')
-rw-r--r-- | c_src/esdl2.h | 1 | ||||
-rw-r--r-- | c_src/sdl_window.c | 25 |
2 files changed, 26 insertions, 0 deletions
diff --git a/c_src/esdl2.h b/c_src/esdl2.h index c7deb41..c64352e 100644 --- a/c_src/esdl2.h +++ b/c_src/esdl2.h @@ -152,6 +152,7 @@ F(create_window, 6) \ F(create_window_and_renderer, 3) \ F(get_window_brightness, 1) \ + F(get_window_display_index, 1) \ // Generated declarations for the NIF. diff --git a/c_src/sdl_window.c b/c_src/sdl_window.c index bc8221b..98c6aaf 100644 --- a/c_src/sdl_window.c +++ b/c_src/sdl_window.c @@ -126,3 +126,28 @@ NIF_FUNCTION(get_window_brightness) return nif_thread_call(env, thread_get_window_brightness, 1, NIF_RES_GET(Window, window_res)); } + +// get_window_display_index + +NIF_CALL_HANDLER(thread_get_window_display_index) +{ + int i = SDL_GetWindowDisplayIndex(args[0]); + + if (i < 0) + return sdl_error_tuple(env); + + return enif_make_tuple2(env, + atom_ok, + enif_make_int(env, i) + ); +} + +NIF_FUNCTION(get_window_display_index) +{ + void* window_res; + + BADARG_IF(!enif_get_resource(env, argv[0], res_Window, &window_res)); + + return nif_thread_call(env, thread_get_window_display_index, 1, + NIF_RES_GET(Window, window_res)); +} |