aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2014-04-03 13:50:26 +0200
committerLoïc Hoguin <[email protected]>2014-04-03 14:37:15 +0200
commit9e38925e829fd635f6f3339770f3ebdf49ad906f (patch)
tree63d7775ad9e49a57ef587d23674c556a3abdda92
parentba902081dd0386455dedc247a89f645ff9135877 (diff)
downloadesdl2-9e38925e829fd635f6f3339770f3ebdf49ad906f.tar.gz
esdl2-9e38925e829fd635f6f3339770f3ebdf49ad906f.tar.bz2
esdl2-9e38925e829fd635f6f3339770f3ebdf49ad906f.zip
Add sdl_window:get_title/1
-rw-r--r--c_src/esdl2.h1
-rw-r--r--c_src/sdl_window.c17
-rw-r--r--src/esdl2.erl4
-rw-r--r--src/sdl_window.erl5
4 files changed, 27 insertions, 0 deletions
diff --git a/c_src/esdl2.h b/c_src/esdl2.h
index 7aea80f..f165056 100644
--- a/c_src/esdl2.h
+++ b/c_src/esdl2.h
@@ -170,6 +170,7 @@
F(get_window_minimum_size, 1) \
F(get_window_position, 1) \
F(get_window_size, 1) \
+ F(get_window_title, 1) \
// Generated declarations for the NIF.
diff --git a/c_src/sdl_window.c b/c_src/sdl_window.c
index becf4d4..62d6993 100644
--- a/c_src/sdl_window.c
+++ b/c_src/sdl_window.c
@@ -326,3 +326,20 @@ NIF_FUNCTION(get_window_size)
return nif_thread_call(env, thread_get_window_size, 1,
NIF_RES_GET(Window, window_res));
}
+
+// get_window_title
+
+NIF_CALL_HANDLER(thread_get_window_title)
+{
+ return enif_make_string(env, SDL_GetWindowTitle(args[0]), ERL_NIF_LATIN1);
+}
+
+NIF_FUNCTION(get_window_title)
+{
+ void* window_res;
+
+ BADARG_IF(!enif_get_resource(env, argv[0], res_Window, &window_res));
+
+ return nif_thread_call(env, thread_get_window_title, 1,
+ NIF_RES_GET(Window, window_res));
+}
diff --git a/src/esdl2.erl b/src/esdl2.erl
index 352d0e9..9be4e55 100644
--- a/src/esdl2.erl
+++ b/src/esdl2.erl
@@ -82,6 +82,7 @@
-export([get_window_minimum_size/1]).
-export([get_window_position/1]).
-export([get_window_size/1]).
+-export([get_window_title/1]).
%% @todo We probably want to accept an env variable or somthing for the location.
-on_load(on_load/0).
@@ -257,3 +258,6 @@ get_window_position(_) ->
get_window_size(_) ->
erlang:nif_error({not_loaded, ?MODULE}).
+
+get_window_title(_) ->
+ erlang:nif_error({not_loaded, ?MODULE}).
diff --git a/src/sdl_window.erl b/src/sdl_window.erl
index dc265f1..82e2b17 100644
--- a/src/sdl_window.erl
+++ b/src/sdl_window.erl
@@ -25,6 +25,7 @@
-export([get_min_size/1]).
-export([get_pos/1]).
-export([get_size/1]).
+-export([get_title/1]).
create(Title, X, Y, W, H, Flags) ->
esdl2:create_window(Title, X, Y, W, H, Flags),
@@ -72,3 +73,7 @@ get_pos(Window) ->
get_size(Window) ->
esdl2:get_window_size(Window),
receive {'_nif_thread_ret_', Ret} -> Ret end.
+
+get_title(Window) ->
+ esdl2:get_window_title(Window),
+ receive {'_nif_thread_ret_', Ret} -> Ret end.