[SDL_Tizen] Add Pause/Resume Event for tizen port 41/74941/2
authorWonsik, Jung <sidein@samsung.com>
Thu, 16 Jun 2016 06:31:01 +0000 (15:31 +0900)
committerWonsik, Jung <sidein@samsung.com>
Thu, 16 Jun 2016 06:41:26 +0000 (15:41 +0900)
1. Modification Tizen Core for Tizen App Core
2. Fix the bug of Tizen log
3. Add Pause/Resume Event for tizen port

Change-Id: I114166fc450cb66cf29cc5ef223c5b83ca33424c

cmake/sdlchecks.cmake
configure
configure.in
packaging/SDL2.spec
src/SDL_log.c
src/core/tizen/SDL_tizen.c
src/events/SDL_events.c
src/main/tizen/SDL_tizen_main.c
src/video/tizen/SDL_tizenevents.c
src/video/tizen/SDL_tizenmouse.c
src/video/tizen/SDL_tizenwindow.c

index 4bb96b2..478913c 100644 (file)
@@ -594,7 +594,7 @@ endmacro()
 
 macro(CheckTizen)
   if(VIDEO_TIZEN)
-    pkg_check_modules(TIZEN wayland-client wayland-egl ecore ecore-wayland evas eina appcore-efl dlog)
+    pkg_check_modules(TIZEN wayland-client wayland-egl ecore ecore-wayland evas eina capi-appfw-application capi-appfw-application dlog)
     if(TIZEN_FOUND)
       link_directories(
           ${TIZEN_LIBRARY_DIRS}
@@ -618,7 +618,8 @@ macro(CheckTizen)
           FindLibraryAndSONAME(ecore-wayland)
           FindLibraryAndSONAME(evas)
           FindLibraryAndSONAME(eina)
-          FindLibraryAndSONAME(appcore-efl)
+          FindLibraryAndSONAME(capi-appfw-application)
+          FindLibraryAndSONAME(capi-system-system-settings)
           FindLibraryAndSONAME(dlog)
           set(SDL_VIDEO_DRIVER_TIZEN_DYNAMIC "\"${WAYLAND_CLIENT_LIB_SONAME}\"")
           set(SDL_VIDEO_DRIVER_TIZEN_DYNAMIC_EGL "\"${WAYLAND_EGL_LIB_SONAME}\"")
index 962c52f..20ee1b5 100755 (executable)
--- a/configure
+++ b/configure
@@ -18941,9 +18941,9 @@ $as_echo_n "checking for Tizen support... " >&6; }
         if  test x$PKG_CONFIG != xno && \
             test x$video_opengl_egl = xyes && \
             test x$video_opengles_v2 = xyes; then
-            if $PKG_CONFIG --exists wayland-client wayland-egl ecore ecore-wayland evas eina appcore-efl ecore-input dlog; then
-                TIZEN_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl ecore ecore-wayland evas eina appcore-efl ecore-input dlog`
-                TIZEN_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl ecore ecore-wayland evas eina appcore-efl ecore-input dlog`
+            if $PKG_CONFIG --exists wayland-client wayland-egl ecore ecore-wayland evas eina capi-appfw-application capi-system-system-settings ecore-input dlog; then
+                TIZEN_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl ecore ecore-wayland evas eina capi-appfw-application capi-system-system-settings ecore-input dlog`
+                TIZEN_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl ecore ecore-wayland evas eina capi-appfw-application capi-system-system-settings ecore-input dlog`
                 video_tizen=yes
             fi
         fi
@@ -18956,11 +18956,12 @@ $as_echo "#define SDL_VIDEO_DRIVER_TIZEN 1" >>confdefs.h
 
             SOURCES="$SOURCES $srcdir/src/video/tizen/*.c"
             SOURCES="$SOURCES $srcdir/src/core/tizen/*.c"
-
             SDLMAIN_SOURCES="$srcdir/src/main/tizen/*.c"
-            EXTRA_CFLAGS="$EXTRA_CFLAGS $TIZEN_CFLAGS -DTIZEN"
 
-            EXTRA_CFLAGS="$EXTRA_CFLAGS $TIZEN_CFLAGS"
+            SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
+            SDL_LIBS="-lSDL2main $SDL_LIBS"
+
+            EXTRA_CFLAGS="$EXTRA_CFLAGS $TIZEN_CFLAGS -DTIZEN"
             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $TIZEN_LIBS"
             SUMMARY_video="${SUMMARY_video} tizen"
             have_video=yes
index 53782ab..eef0f7c 100644 (file)
@@ -1269,9 +1269,9 @@ CheckTizen()
         if  test x$PKG_CONFIG != xno && \
             test x$video_opengl_egl = xyes && \
             test x$video_opengles_v2 = xyes; then
-            if $PKG_CONFIG --exists wayland-client wayland-egl ecore ecore-wayland evas eina appcore-efl ecore-input dlog; then
-                TIZEN_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl ecore ecore-wayland evas eina appcore-efl ecore-input dlog`
-                TIZEN_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl ecore ecore-wayland evas eina appcore-efl ecore-input dlog`
+            if $PKG_CONFIG --exists wayland-client wayland-egl ecore ecore-wayland evas eina capi-appfw-application capi-system-system-settings ecore-input dlog; then
+                TIZEN_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl ecore ecore-wayland evas eina capi-appfw-application capi-system-system-settings ecore-input dlog`
+                TIZEN_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl ecore ecore-wayland evas eina capi-appfw-application capi-system-system-settings ecore-input dlog`
                 video_tizen=yes
             fi
         fi
@@ -1281,11 +1281,12 @@ CheckTizen()
             AC_DEFINE(SDL_VIDEO_DRIVER_TIZEN, 1, [ ])
             SOURCES="$SOURCES $srcdir/src/video/tizen/*.c"
             SOURCES="$SOURCES $srcdir/src/core/tizen/*.c"
-
             SDLMAIN_SOURCES="$srcdir/src/main/tizen/*.c"
-            EXTRA_CFLAGS="$EXTRA_CFLAGS $TIZEN_CFLAGS -DTIZEN"
 
-            EXTRA_CFLAGS="$EXTRA_CFLAGS $TIZEN_CFLAGS"
+            SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
+            SDL_LIBS="-lSDL2main $SDL_LIBS"
+
+            EXTRA_CFLAGS="$EXTRA_CFLAGS $TIZEN_CFLAGS -DTIZEN"
             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $TIZEN_LIBS"
             SUMMARY_video="${SUMMARY_video} tizen"
             have_video=yes
index e150d2b..9ab2793 100644 (file)
@@ -45,7 +45,8 @@ BuildRequires:  autoconf
 BuildRequires:  pkgconfig(ecore)
 BuildRequires:  pkgconfig(evas)
 BuildRequires:  pkgconfig(ecore-wayland)
-BuildRequires:  pkgconfig(appcore-efl)
+BuildRequires:  pkgconfig(capi-appfw-application)
+BuildRequires:  pkgconfig(capi-system-system-settings)
 BuildRequires:  pkgconfig(dlog)
 
 %description
index b651000..25c9e8a 100644 (file)
 
 #if defined(__TIZEN__)
 #include <dlog/dlog.h>
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
 #define LOG_TAG "SDL_LOG"
+#define _SECURE_LOG
 #endif
 
 #define DEFAULT_PRIORITY                SDL_LOG_PRIORITY_CRITICAL
@@ -442,17 +446,17 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
         fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message);
         fclose (pFile);
     }
+#elif defined(__TIZEN__)
+    {
+        SDL_PrintDlog(priority, "%s: %s", SDL_priority_prefixes[priority], message);
+    }
 #endif
 #if HAVE_STDIO_H
-#if defined(__TIZEN__)
-    SDL_PrintDlog(priority, "%s: %s", SDL_priority_prefixes[priority], message);
-#else
     fprintf(stderr, "%s: %s\n", SDL_priority_prefixes[priority], message);
 #endif
 #if __NACL__
     fflush(stderr);
 #endif
-#endif
 }
 
 void
index abb7269..a503dfe 100644 (file)
 
 #if __TIZEN__
 #include "SDL_tizen.h"
-#include <appcore-efl.h>
-
-typedef enum {
-    APP_STATE_NOT_RUNNING,
-    APP_STATE_CREATING,
-    APP_STATE_RUNNING,
-} app_state_e;
-
-struct ui_app_context {
-    char *package;
-    char *app_name;
-    app_state_e state;
-    void *callback;
-    void *data;
-};
+#include "SDL_log.h"
+#include "SDL_events.h"
+#include <app_internal.h>
+#include <app_extension.h>
+#include <system_settings.h>
+
+static int tizen_appcore_initialized = 0;
+static appcore_context_h appcore_handle = NULL;
+static ui_app_lifecycle_callback_s event_callback = {0,};
+static app_event_handler_h handlers[5] = {NULL, };
 
 /* TODO  ::
  * Impplementation of serveral app core callback function for SDL Application and App Core
  * */
 
-static int
-_tizen_app_create(void *data)
+static bool
+_tizen_sdl_create(void *data)
+{
+    SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "SDL_AppCore CreateCB");
+    return true;
+}
+
+static void
+_tizen_sdl_terminate(void *data)
+{
+    SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "SDL_AppCore TermincateCB");
+    SDL_SendQuit();
+    SDL_SendAppEvent(SDL_APP_TERMINATING);
+    return;
+}
+
+static void
+_tizen_sdl_pause (void *data)
+{
+    SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "SDL_AppCore PauseCB");
+    SDL_SendAppEvent(SDL_APP_WILLENTERBACKGROUND);
+    SDL_SendAppEvent(SDL_APP_DIDENTERBACKGROUND);
+    return;
+}
+
+static void
+_tizen_sdl_resume(void *data)
+{
+    SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "SDL_AppCore ResumeCB");
+    SDL_SendAppEvent(SDL_APP_WILLENTERFOREGROUND);
+    SDL_SendAppEvent(SDL_APP_DIDENTERFOREGROUND);
+    return;
+}
+
+static void
+_tizen_sdl_control(app_control_h app_control, void *data)
+{
+    SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "SDL_AppCore ControlCB");
+    return;
+}
+
+static void
+_tizen_app_lang_changed(app_event_info_h event_info, void *user_data)
 {
-    fprintf(stderr,"%s:%d\n",__FUNCTION__, __LINE__);
-    return 0;
+    /*APP_EVENT_LANGUAGE_CHANGED*/
+    char *locale = NULL;
+    SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "Language changedCB");
+    system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
+    free(locale);
+    return;
 }
 
-static int
-_tizen_app_terminate(void *data)
+static void
+_tizen_app_orient_changed(app_event_info_h event_info, void *user_data)
 {
-    fprintf(stderr,"%s:%d\n",__FUNCTION__, __LINE__);
-    return 0;
+    /*APP_EVENT_DEVICE_ORIENTATION_CHANGED*/
+    SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "orient changedCB");
+    return;
 }
 
-static int
-_tizen_app_pause (void *data)
+static void
+_tizen_app_region_changed(app_event_info_h event_info, void *user_data)
 {
-    fprintf(stderr,"%s:%d\n",__FUNCTION__, __LINE__);
-    return 0;
+    /*APP_EVENT_REGION_FORMAT_CHANGED*/
+    SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "region changedCB");
 }
 
-static int
-_tizen_app_resume(void *data)
+static void
+_tizen_app_low_battery(app_event_info_h event_info, void *user_data)
 {
-    fprintf(stderr,"%s:%d\n",__FUNCTION__, __LINE__);
-    return 0;
+    /*APP_EVENT_LOW_BATTERY*/
+    SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "low battery CB");
 }
 
-static int
-_tizen_app_reset(bundle *bun, void *data)
+static void
+_tizen_app_low_memory(app_event_info_h event_info, void *user_data)
 {
-    fprintf(stderr,"%s:%d\n",__FUNCTION__, __LINE__);
-    return 0;
+    /*APP_EVENT_LOW_MEMORY*/
+    SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "low memory CB");
+    SDL_SendAppEvent(SDL_APP_LOWMEMORY);
 }
 
 int
 SDL_tizen_app_init(int argc, char *argv[])
 {
-    struct ui_app_context app_context = {
-        .package = NULL,
-        .app_name = NULL,
-        .state = APP_STATE_NOT_RUNNING,
-        .callback = NULL,
-        .data = NULL,
-    };
-
-    struct appcore_ops appcore_context = {
-        .data = &app_context,
-        .create = _tizen_app_create,
-        .terminate = _tizen_app_terminate,
-        .pause = _tizen_app_pause,
-        .resume = _tizen_app_resume,
-        .reset = _tizen_app_reset,
-    };
-
-    if (argc < 1 || argv == NULL)
+    SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "SDL Tizen App initialize");
+    if (tizen_appcore_initialized)
     {
-        fprintf(stderr,"%s: APP_ERROR_INVALID_PARAMETER",__FUNCTION__);
+        SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "Already initialized!");
         return 0;
     }
-
-    if (app_context.state != APP_STATE_NOT_RUNNING)
+    tizen_appcore_initialized = 1;
+    if (argc < 1 || argv == NULL)
     {
-        fprintf(stderr,"%s: APP_STATE_NOT_RUNNING\n",__FUNCTION__);
+        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "APP_ERROR_INVALID_PARAMETER");
         return 0;
     }
 
-    /* TODO  ::
-     * At first, check the necessary calling app_get_id()/app_get_package_app_name() while app_init.
-     * If necessary, help these functions can be export.
-     * After that, determine the implementation of them.
-     * */
-#if 0
-    if (app_get_id(&(app_context.package)) != 0)
-    {
-        fprintf(stderr,"%s: APP_ERROR_INVALID_CONTEXT",__FUNCTION__);
-        return 0;
-    }
+    event_callback.create = _tizen_sdl_create;
+    event_callback.terminate = _tizen_sdl_terminate;
+    event_callback.pause = _tizen_sdl_pause;
+    event_callback.resume = _tizen_sdl_resume;
+    event_callback.app_control = _tizen_sdl_control;
 
-    if (app_get_package_app_name(app_context.package, &(app_context.app_name)) != 0)
-    {
-        free(app_context.package);
-        fprintf(stderr,"%s: APP_ERROR_INVALID_CONTEXT",__FUNCTION__);
-        return 0;
-    }
-#endif
-    return appcore_efl_init(app_context.app_name, &argc, &argv, &appcore_context);
+    ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, _tizen_app_low_battery, NULL);
+    ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, _tizen_app_low_memory, NULL);
+    ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, _tizen_app_orient_changed, NULL);
+    ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, _tizen_app_lang_changed, NULL);
+    ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, _tizen_app_region_changed, NULL);
+
+    return ui_app_init(argc, argv, &event_callback, NULL, &appcore_handle);
 }
 
 void
 SDL_tizen_app_exit(void)
 {
-    appcore_efl_fini();
+    ui_app_fini(appcore_handle);
 }
 #endif
index ffd1038..e6c39fc 100644 (file)
@@ -395,7 +395,6 @@ void
 SDL_PumpEvents(void)
 {
     SDL_VideoDevice *_this = SDL_GetVideoDevice();
-
     /* Get events from the video subsystem */
     if (_this) {
         _this->PumpEvents(_this);
@@ -406,7 +405,6 @@ SDL_PumpEvents(void)
         SDL_JoystickUpdate();
     }
 #endif
-
     SDL_SendPendingQuit();  /* in case we had a signal handler fire, etc. */
 }
 
@@ -431,7 +429,6 @@ SDL_WaitEventTimeout(SDL_Event * event, int timeout)
 
     if (timeout > 0)
         expiration = SDL_GetTicks() + timeout;
-
     for (;;) {
         SDL_PumpEvents();
         switch (SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT)) {
index 8c8157b..ade8afb 100644 (file)
@@ -8,7 +8,6 @@
 #include <stdio.h>
 #include "SDL.h"
 #include "SDL_main.h"
-//#include "../../core/tizen/SDL_tizen.h"
 
 #ifdef main
 #undef main
@@ -16,7 +15,6 @@
 
 int main(int argc, char *argv[])
 {
-    printf("Start MAIN!!!!!!\n");
     SDL_tizen_app_init(argc, argv);
     SDL_SetMainReady();
     (void)SDL_main(argc, argv);
index 7b200cb..cd28dfa 100644 (file)
@@ -34,6 +34,7 @@
 #include "SDL_tizenvideo.h"
 #include "SDL_tizenevents_c.h"
 #include "SDL_tizenwindow.h"
+#include "SDL_log.h"
 
 void
 Tizen_PumpEvents(_THIS)
@@ -44,11 +45,10 @@ Tizen_PumpEvents(_THIS)
 Eina_Bool
 __tizen_cb_event_keyup_change(void *data, int type, void *event)
 {
-    printf("SAMPLE EV :key up\n");
-
     if (!event) return ECORE_CALLBACK_PASS_ON;
 
     Ecore_Event_Key * e = event;
+    SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "key up: %d",e->keycode);
     SDL_SendKeyboardKey(SDL_RELEASED, e->keycode);
 
     return ECORE_CALLBACK_PASS_ON;
@@ -57,11 +57,10 @@ __tizen_cb_event_keyup_change(void *data, int type, void *event)
 Eina_Bool
 __tizen_cb_event_keydown_change(void *data, int type, void *event)
 {
-    printf("SAMPLE EV :key down\n");
-
     if (!event) return ECORE_CALLBACK_PASS_ON;
 
     Ecore_Event_Key * e = event;
+    SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "key down: %d",e->keycode);
     SDL_SendKeyboardKey(SDL_PRESSED, e->keycode);
 
     return ECORE_CALLBACK_PASS_ON;
index 733462c..b0dbb50 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "../../SDL_internal.h"
 #include "SDL_tizenmouse.h"
+#include "SDL_log.h"
 
 
 Eina_Bool
@@ -29,10 +30,10 @@ __tizen_cb_event_mousedown_change(void *data, int type, void *event)
 {
     SDL_VideoDevice *_this = SDL_GetVideoDevice();
 
-    printf("SAMPLE EV :mouse down\n");
     if (!event) return ECORE_CALLBACK_PASS_ON;
 
     Ecore_Event_Mouse_Button *e = event;
+    SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "mouse down (%d x %d)",e->x,e->y);
     SDL_SendMouseMotion(_this->current_glwin, 0, 0,  e->x, e->y);
     SDL_SendMouseButton(_this->current_glwin, 0, SDL_PRESSED, SDL_BUTTON_LEFT);
     return ECORE_CALLBACK_PASS_ON;
@@ -46,6 +47,7 @@ __tizen_cb_event_mouseup_change(void *data, int type, void *event)
     if (!event) return ECORE_CALLBACK_PASS_ON;
 
     Ecore_Event_Mouse_Button *e = event;
+    SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "mouse up (%d x %d)",e->x,e->y);
     SDL_SendMouseMotion(_this->current_glwin, 0, 0,  e->x, e->y);
     SDL_SendMouseButton(_this->current_glwin, 0, SDL_RELEASED, SDL_BUTTON_LEFT);
     return ECORE_CALLBACK_PASS_ON;
@@ -60,6 +62,7 @@ __tizen_cb_event_mousemove_change(void *data, int type, void *event)
     if (!event) return ECORE_CALLBACK_PASS_ON;
 
     Ecore_Event_Mouse_Move *e = event;
+    //SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "mouse move (%d x %d)",e->x,e->y);
     SDL_SendMouseMotion(_this->current_glwin, 0, 0,  e->x, e->y);
 
     return ECORE_CALLBACK_PASS_ON;
index 6bf6f99..b4af35b 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "SDL_tizenmouse.h"
 #include "SDL_tizenevents_c.h"
+#include "SDL_log.h"
 
 #include <wayland-egl.h>
 
@@ -162,8 +163,11 @@ __tizen_cb_window_visibility_change(void *data, int type, void *event)
     ew = ecore_wl_window_find(ev->win);
     window = __tizen_find_window(_this, ew);
 
-    printf("SAMPLE EV : visibility window:%p, ecore_wl_window:%p\n", window, ew);
-    
+    SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "visibility window: %p, ecore_wl_window: %p\n", window, ew);
+
+    SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SHOWN, 0, 0);
+    SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESTORED, 0, 0);
+
     return ECORE_CALLBACK_PASS_ON;
 }