[SDL_Tizen] Fix Tizen event arguments
[platform/upstream/SDL.git] / src / core / tizen / SDL_tizen.c
index 9987bd7..8f7eff1 100644 (file)
@@ -31,6 +31,7 @@
 #include "SDL_log.h"
 #include "SDL_events.h"
 #include "../../events/SDL_events_c.h"
+#include "../../video/tizen/SDL_tizenwindow.h"
 
 #include "SDL_tizen.h"
 
@@ -39,6 +40,9 @@ static appcore_context_h appcore_handle = NULL;
 static ui_app_lifecycle_callback_s event_callback = {0,};
 static app_event_handler_h handlers[5] = {NULL, };
 
+static app_control_h event_app_control;
+static SDL_bool app_control_init = 0;
+
 int _tizen_terminate_event_filter(void *userdata, SDL_Event * event);
 int _tizen_aul_status_changed_cb(int status, void *data);
 
@@ -59,6 +63,9 @@ _tizen_sdl_pause (void *data)
     SDL_Log("App Pause");
     SDL_SendAppEvent(SDL_APP_WILLENTERBACKGROUND);
     SDL_SendAppEvent(SDL_APP_DIDENTERBACKGROUND);
+
+    _tizen_ecore_ipc_client_send(OP_PAUSE, 0, 0, 0);
+
     return;
 }
 
@@ -68,6 +75,9 @@ _tizen_sdl_resume(void *data)
     SDL_Log("App Resume");
     SDL_SendAppEvent(SDL_APP_WILLENTERFOREGROUND);
     SDL_SendAppEvent(SDL_APP_DIDENTERFOREGROUND);
+
+    _tizen_ecore_ipc_client_send(OP_RESUME, 0, 0, 0);
+
     return;
 }
 
@@ -80,10 +90,18 @@ _tizen_sdl_control(app_control_h app_control, void *data)
     SDL_memset(&event, 0, sizeof(event));
     event.type = SDL_APP_CONTROL;
     event.user.code = 0;
-    event.user.data1 = (void*)app_control;
+
+    if(app_control_init == 1)
+        app_control_destroy(event_app_control);
+
+    app_control_clone(&event_app_control, app_control);
+    app_control_init = 1;
+
+    event.user.data1 = (void*)event_app_control;
     event.user.data2 = (void*)data;
 
     SDL_PushEvent(&event);
+
     return;
 }
 
@@ -97,7 +115,9 @@ _tizen_app_lang_changed(app_event_info_h event_info, void *user_data)
     SDL_memset(&event, 0, sizeof(event));
     event.type = SDL_APP_LANGUAGE_CHANGED;
     event.user.code = 0;
-    event.user.data1 = (void*)event_info;
+    char* language;
+    app_event_get_language(event_info, &language);
+    event.user.data1 = (void*)language;
     event.user.data2 = (void*)user_data;
 
     SDL_PushEvent(&event);
@@ -132,9 +152,11 @@ _tizen_app_region_changed(app_event_info_h event_info, void *user_data)
 
     SDL_Event event;
     SDL_memset(&event, 0, sizeof(event));
-    event.type = SDL_APP_RIGION_CHANGED;
+    event.type = SDL_APP_REGION_CHANGED;
     event.user.code = 0;
-    event.user.data1 = (void*)event_info;
+    char* region;
+    app_event_get_region_format(event_info, &region);
+    event.user.data1 = (void*)region;
     event.user.data2 = (void*)user_data;
 
     SDL_PushEvent(&event);
@@ -150,7 +172,9 @@ _tizen_app_low_battery(app_event_info_h event_info, void *user_data)
     SDL_memset(&event, 0, sizeof(event));
     event.type = SDL_APP_LOWBATTERY;
     event.user.code = 0;
-    event.user.data1 = (void*)event_info;
+    app_event_low_battery_status_e status;
+    app_event_get_low_battery_status(event_info, &status);
+    event.user.data1 = (void*)status;
     event.user.data2 = (void*)user_data;
 
     SDL_PushEvent(&event);
@@ -246,5 +270,6 @@ SDL_tizen_app_exit(void)
 {
     SDL_Log("call ui_app_fini");
     ui_app_fini(appcore_handle);
+    appcore_handle = NULL;
 }
 #endif