From 3c6246509591b086e82ba463f22db24796acbc31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Thu, 3 Apr 2014 12:25:33 +0200 Subject: Add sdl_window:get_flags/1 --- c_src/esdl2.h | 11 +++++++++++ c_src/sdl_window.c | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+) (limited to 'c_src') diff --git a/c_src/esdl2.h b/c_src/esdl2.h index c64352e..17c3565 100644 --- a/c_src/esdl2.h +++ b/c_src/esdl2.h @@ -20,6 +20,8 @@ // List of atoms used by this NIF. #define NIF_ATOMS(A) \ + A(allow_high_dpi) \ + A(borderless) \ A(button) \ A(caps) \ A(charged) \ @@ -33,8 +35,13 @@ A(false) \ A(focus_gained) \ A(focus_lost) \ + A(foreign) \ + A(fullscreen) \ + A(fullscreen_desktop) \ A(h) \ A(hidden) \ + A(input_focus) \ + A(input_grabbed) \ A(key_down) \ A(key_up) \ A(leave) \ @@ -50,6 +57,7 @@ A(mod) \ A(mode) \ A(mouse_down) \ + A(mouse_focus) \ A(mouse_motion) \ A(mouse_up) \ A(mouse_wheel) \ @@ -57,8 +65,10 @@ A(no_battery) \ A(num) \ A(on_battery) \ + A(opengl) \ A(quit) \ A(repeat) \ + A(resizable) \ A(resized) \ A(restored) \ A(right) \ @@ -153,6 +163,7 @@ F(create_window_and_renderer, 3) \ F(get_window_brightness, 1) \ F(get_window_display_index, 1) \ + F(get_window_flags, 1) \ // Generated declarations for the NIF. diff --git a/c_src/sdl_window.c b/c_src/sdl_window.c index 98c6aaf..a899656 100644 --- a/c_src/sdl_window.c +++ b/c_src/sdl_window.c @@ -36,6 +36,7 @@ void dtor_Window(ErlNifEnv* env, void* obj) F(allow_high_dpi, SDL_WINDOW_ALLOW_HIGHDPI) NIF_LIST_TO_FLAGS_FUNCTION(list_to_window_flags, Uint32, WINDOW_FLAGS) +NIF_FLAGS_TO_LIST_FUNCTION(window_flags_to_list, Uint32, WINDOW_FLAGS) // create_window @@ -151,3 +152,20 @@ NIF_FUNCTION(get_window_display_index) return nif_thread_call(env, thread_get_window_display_index, 1, NIF_RES_GET(Window, window_res)); } + +// get_window_flags + +NIF_CALL_HANDLER(thread_get_window_flags) +{ + return window_flags_to_list(env, SDL_GetWindowFlags(args[0])); +} + +NIF_FUNCTION(get_window_flags) +{ + void* window_res; + + BADARG_IF(!enif_get_resource(env, argv[0], res_Window, &window_res)); + + return nif_thread_call(env, thread_get_window_flags, 1, + NIF_RES_GET(Window, window_res)); +} -- cgit v1.2.3