diff options
author | Loïc Hoguin <[email protected]> | 2014-04-03 11:59:33 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2014-04-03 11:59:33 +0200 |
commit | 6ef934fb5db12cf4f0042aafdcda15a9f3831e5f (patch) | |
tree | 09e205bf6a5f7d80cfa2f9d0cb80de6e2997cedb /c_src | |
parent | 5d3facb328b4b10c13847f60fac461be4b249f5e (diff) | |
download | esdl2-6ef934fb5db12cf4f0042aafdcda15a9f3831e5f.tar.gz esdl2-6ef934fb5db12cf4f0042aafdcda15a9f3831e5f.tar.bz2 esdl2-6ef934fb5db12cf4f0042aafdcda15a9f3831e5f.zip |
Add sdl_window:get_display_index/1
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)); +} |