[SDL_Tizen] Execute indicator process 45/133745/2
authorhuiyu.eun <huiyu.eun@samsung.com>
Tue, 13 Jun 2017 08:31:53 +0000 (17:31 +0900)
committerhuiyu.eun <huiyu.eun@samsung.com>
Wed, 14 Jun 2017 07:35:10 +0000 (16:35 +0900)
execute indicator process

Change-Id: Ib09e2c39fe36d99ac6bbab19c1048a5a6f79eaa9
Signed-off-by: huiyu.eun <huiyu.eun@samsung.com>
src/video/tizen/SDL_tizenvideo.c
src/video/tizen/SDL_tizenwindow.c
src/video/tizen/SDL_tizenwindow.h

index a2b87b9..6bb767c 100755 (executable)
@@ -188,6 +188,7 @@ Tizen_VideoQuit(_THIS)
     Tizen_FiniKeyboard();
     Tizen_FiniMouse();
 
+    _tizen_ecore_ipc_client_send(OP_TERMINATE, 0, 0, 0);
     SDL_tizen_app_exit();
     ecore_wl_shutdown();
     free(data);
index c5e566c..cf79c38 100755 (executable)
 #include "../SDL_sysvideo.h"
 #include "../../events/SDL_windowevents_c.h"
 
+#include <Ecore_Ipc.h>
+#include <unistd.h>
+#include <errno.h>
+
 enum {
     ROTATION_TYPE_NORMAL_ROTATION = 0,
     ROTATION_TYPE_PRE_ROTATION,      /* use pre-rotation */
@@ -58,6 +62,113 @@ if (!_this->tizen_pre_rotation_data->NAME) \
     return SDL_FALSE; \
 }
 
+/*SDL indicator*/
+
+
+
+Ecore_Ipc_Server *ipc = NULL;
+
+#define IPC_HEAD(_type) \
+   Ecore_Ipc_Event_Client_##_type *e = event; \
+   if (ecore_ipc_client_server_get(e->client) != ipc) \
+     return ECORE_CALLBACK_PASS_ON
+
+void SDL_ExecuteIndicatorProcess()
+{
+    _tizen_init_ecore_ipc();
+    unsigned int childPID = fork();
+    if(childPID == 0)
+    {
+        SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "[SDL] child process : %d", getpid());
+        int ret = execl("/usr/apps/org.tizen.sdl_indicator/bin/sdl_indicator", "/usr/apps/org.tizen.sdl_indicator/bin/sdl_indicator", NULL);
+        if(ret==-1)
+        {
+            SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "[SDL] Failed indicator process error:%s", strerror(errno));
+            kill(getpid(), SIGKILL);
+        }
+    }
+    else if(childPID==-1)
+    {
+        SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "[SDL] Failed fork");
+    }
+    else
+    {
+        SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "[SDL] parent process : %d", getpid());
+    }
+}
+
+void _tizen_ecore_ipc_client_send(int major, int minor, int ref, int ref_to)
+{
+    Eina_List *ipc_clients = ecore_ipc_server_clients_get(ipc);
+    Eina_List *l;
+    Ecore_Ipc_Client *cl;
+    EINA_LIST_FOREACH(ipc_clients, l, cl)
+    ecore_ipc_client_send(cl, major, minor, ref, ref_to, 0, NULL, 0);
+}
+
+static Eina_Bool _cb_client_add(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
+{
+    IPC_HEAD(Add);
+
+    SDL_Log("[SDL]_cb_client_add");
+    SDL_Window * window = SDL_GetVideoDevice()->windows;
+    SDL_WindowData *wind = window->driverdata;
+    wind->indicator = SDL_TRUE;
+
+    int window_w, window_h;
+    ecore_wl_screen_size_get(&window_w, &window_h);
+    _tizen_ecore_ipc_client_send(OP_RESIZE, wind->rotation, window_w, window_h);
+
+    return ECORE_CALLBACK_DONE;
+}
+
+static Eina_Bool _cb_client_del(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
+{
+    IPC_HEAD(Del);
+    SDL_Log("[SDL]_cb_client_del");
+    Eina_List *ipc_clients = ecore_ipc_server_clients_get(ipc);
+    Eina_List *l;
+    Ecore_Ipc_Client *cl;
+    EINA_LIST_FOREACH(ipc_clients, l, cl)
+    {
+        ecore_ipc_client_del(cl);
+    }
+
+    SDL_Window * window = SDL_GetVideoDevice()->windows;
+    SDL_WindowData *wind = window->driverdata;
+    wind->indicator = SDL_FALSE;
+    return ECORE_CALLBACK_DONE;
+}
+
+static Eina_Bool _cb_client_data(void *data, int type EINA_UNUSED, void *event)
+{
+    IPC_HEAD(Data);
+
+    Ecore_Ipc_Event_Server_Data* epcEvent = (Ecore_Ipc_Event_Server_Data*)event;
+    SDL_Log("[SDL]_cb_client_data: %d -> %d", epcEvent->major, epcEvent->minor);
+    return ECORE_CALLBACK_DONE;
+}
+
+int _tizen_init_ecore_ipc()
+{
+
+    if(!ipc)
+    {
+        if(!ecore_ipc_init())
+            SDL_Log("[SDL]Fail ecore_ipc");
+
+        ipc = ecore_ipc_server_add(ECORE_IPC_LOCAL_USER, "sdl_indicator", 0, NULL);
+
+        if(!ipc)
+            ecore_ipc_shutdown();
+
+        ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_ADD, _cb_client_add, NULL);
+        ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DEL, _cb_client_del, NULL);
+        ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DATA, _cb_client_data, NULL);
+    }
+    return 0;
+}
+
 static int
 _tizen_rotation_type_get()
 {
@@ -144,17 +255,9 @@ Tizen_ShowWindow(_THIS, SDL_Window *window)
 {
     SDL_WindowData *wind = window->driverdata;
 
-    if((window->flags & SDL_WINDOW_FULLSCREEN) || (window->flags & SDL_WINDOW_BORDERLESS))
-    {
-        ecore_wl_window_indicator_state_set(wind->window, ECORE_WL_INDICATOR_STATE_OFF);
-        ecore_wl_window_indicator_opacity_set(wind->window, ECORE_WL_INDICATOR_TRANSPARENT);
-        ecore_wl_indicator_visible_type_set(wind->window, ECORE_WL_INDICATOR_VISIBLE_TYPE_HIDDEN);
-    }
-    else
+    if(!(window->flags & SDL_WINDOW_FULLSCREEN) && !(window->flags & SDL_WINDOW_BORDERLESS) && !wind->indicator)
     {
-        ecore_wl_window_indicator_state_set(wind->window, ECORE_WL_INDICATOR_STATE_ON);
-        ecore_wl_window_indicator_opacity_set(wind->window, ECORE_WL_INDICATOR_OPAQUE);
-        ecore_wl_indicator_visible_type_set(wind->window, ECORE_WL_INDICATOR_VISIBLE_TYPE_SHOWN);
+        SDL_ExecuteIndicatorProcess();
     }
     ecore_wl_window_show(wind->window);
 }
@@ -565,7 +668,11 @@ Tizen_CreateWindow(_THIS, SDL_Window *window)
 void
 Tizen_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
 {
-//Add setting window bordered.
+    SDL_WindowData *wind = window->driverdata;
+    if(!wind->indicator)
+    {
+        SDL_ExecuteIndicatorProcess();
+    }
 }
 
 void
index 6f04f97..9dbe70e 100755 (executable)
@@ -49,6 +49,7 @@ typedef struct {
     int rotation_supported;
     int received_rotation;
     int output_rotation;
+    SDL_bool indicator;
 
     int support_pre_rotation;
     SDL_bool isLoaded_pre_rotation;
@@ -91,6 +92,18 @@ extern void Tizen_DeinitWindow(_THIS);
 
 extern void Tizen_pre_rotation_set(SDL_WindowData *_this, int rotation);
 
+extern int _tizen_init_ecore_ipc();
+extern void _tizen_ecore_ipc_client_send(int major, int minor, int ref, int ref_to);
+
+enum
+{
+    OP_RESIZE=1,
+    OP_RESUME,
+    OP_PAUSE,
+    OP_TERMINATE
+};
+
+extern void SDL_ExecuteIndicatorProcess();
 
 #endif /* _SDL_tizenwindow_h */