aboutsummaryrefslogtreecommitdiffstats
path: root/c_src/sdl_window.c
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2014-04-03 11:59:33 +0200
committerLoïc Hoguin <[email protected]>2014-04-03 11:59:33 +0200
commit6ef934fb5db12cf4f0042aafdcda15a9f3831e5f (patch)
tree09e205bf6a5f7d80cfa2f9d0cb80de6e2997cedb /c_src/sdl_window.c
parent5d3facb328b4b10c13847f60fac461be4b249f5e (diff)
downloadesdl2-6ef934fb5db12cf4f0042aafdcda15a9f3831e5f.tar.gz
esdl2-6ef934fb5db12cf4f0042aafdcda15a9f3831e5f.tar.bz2
esdl2-6ef934fb5db12cf4f0042aafdcda15a9f3831e5f.zip
Add sdl_window:get_display_index/1
Diffstat (limited to 'c_src/sdl_window.c')
-rw-r--r--c_src/sdl_window.c25
1 files changed, 25 insertions, 0 deletions
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));
+}