diff options
Diffstat (limited to 'c_src')
-rw-r--r-- | c_src/esdl2.h | 1 | ||||
-rw-r--r-- | c_src/sdl_window.c | 21 |
2 files changed, 22 insertions, 0 deletions
diff --git a/c_src/esdl2.h b/c_src/esdl2.h index 433b262..2a0a231 100644 --- a/c_src/esdl2.h +++ b/c_src/esdl2.h @@ -185,6 +185,7 @@ F(set_window_minimum_size, 3) \ F(set_window_position, 3) \ F(set_window_size, 3) \ + F(set_window_title, 2) \ // Generated declarations for the NIF. diff --git a/c_src/sdl_window.c b/c_src/sdl_window.c index 5719779..065e39a 100644 --- a/c_src/sdl_window.c +++ b/c_src/sdl_window.c @@ -623,3 +623,24 @@ NIF_FUNCTION(set_window_size) return nif_thread_cast(env, thread_set_window_size, 3, NIF_RES_GET(Window, window_res), w, h); } + +// set_window_title + +NIF_CAST_HANDLER(thread_set_window_title) +{ + SDL_SetWindowTitle(args[0], args[1]); + + enif_free(args[1]); +} + +NIF_FUNCTION(set_window_title) +{ + void* window_res; + char* title = (char*)enif_alloc(255); + + BADARG_IF(!enif_get_resource(env, argv[0], res_Window, &window_res)); + BADARG_IF(!enif_get_string(env, argv[1], title, 255, ERL_NIF_LATIN1)); + + return nif_thread_cast(env, thread_set_window_title, 2, + NIF_RES_GET(Window, window_res), title); +} |