aboutsummaryrefslogtreecommitdiffstats
path: root/c_src
diff options
context:
space:
mode:
Diffstat (limited to 'c_src')
-rw-r--r--c_src/esdl2.h1
-rw-r--r--c_src/sdl_window.c24
2 files changed, 25 insertions, 0 deletions
diff --git a/c_src/esdl2.h b/c_src/esdl2.h
index cab3a1a..3a69b8f 100644
--- a/c_src/esdl2.h
+++ b/c_src/esdl2.h
@@ -168,6 +168,7 @@
F(get_window_id, 1) \
F(get_window_maximum_size, 1) \
F(get_window_minimum_size, 1) \
+ F(get_window_position, 1) \
// Generated declarations for the NIF.
diff --git a/c_src/sdl_window.c b/c_src/sdl_window.c
index 242763e..9ddd3f4 100644
--- a/c_src/sdl_window.c
+++ b/c_src/sdl_window.c
@@ -278,3 +278,27 @@ NIF_FUNCTION(get_window_minimum_size)
return nif_thread_call(env, thread_get_window_minimum_size, 1,
NIF_RES_GET(Window, window_res));
}
+
+// get_window_position
+
+NIF_CALL_HANDLER(thread_get_window_position)
+{
+ int x, y;
+
+ SDL_GetWindowPosition(args[0], &x, &y);
+
+ return enif_make_tuple2(env,
+ enif_make_int(env, x),
+ enif_make_int(env, y)
+ );
+}
+
+NIF_FUNCTION(get_window_position)
+{
+ void* window_res;
+
+ BADARG_IF(!enif_get_resource(env, argv[0], res_Window, &window_res));
+
+ return nif_thread_call(env, thread_get_window_position, 1,
+ NIF_RES_GET(Window, window_res));
+}