X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fvideo%2Ftizen%2FSDL_tizenwindow.c;h=58c0ce084c64acee2955cefa1ac2ba68d7995b79;hb=74b0bfd1d39c610d960b24d6eaf165551c255947;hp=d34fb4e6f7636b80211bee4b9ff1958c40f1e58d;hpb=7007f850dcd8e7acda3a852e63119b2943fb797b;p=platform%2Fupstream%2FSDL.git diff --git a/src/video/tizen/SDL_tizenwindow.c b/src/video/tizen/SDL_tizenwindow.c index d34fb4e..58c0ce0 100755 --- a/src/video/tizen/SDL_tizenwindow.c +++ b/src/video/tizen/SDL_tizenwindow.c @@ -45,6 +45,10 @@ #include "../SDL_sysvideo.h" #include "../../events/SDL_windowevents_c.h" +#include +#include +#include + 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() { @@ -140,26 +251,39 @@ Tizen_SetWindowHitTest(SDL_Window *window, SDL_bool enabled) } void +Tizen_SetWindowTitle(_THIS, SDL_Window * window) +{ + SDL_WindowData *wind = window->driverdata; + ecore_wl_window_title_set(wind->window, window->title); +} + +void 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); } void +Tizen_HideWindow(_THIS, SDL_Window *window) +{ + SDL_WindowData *wind = window->driverdata; + ecore_wl_window_hide(wind->window); +} + +void +Tizen_RaiseWindow(_THIS, SDL_Window *window) +{ + SDL_WindowData *wind = window->driverdata; + ecore_wl_window_raise(wind->window); +} + +void Tizen_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *_display, SDL_bool fullscreen) { @@ -276,7 +400,8 @@ _tizen_cb_output_transform(void *data, int type EINA_UNUSED, void *event) output = ecore_wl_window_output_find(wind->window); if (output != ev->output) return ECORE_CALLBACK_PASS_ON; - _tizen_rotate_update(wind); + wind->received_rotation = 1; + return ECORE_CALLBACK_PASS_ON; } @@ -289,7 +414,7 @@ _tizen_cb_ignore_output_transform(void *data, int type EINA_UNUSED, void *event if(!wind) return ECORE_CALLBACK_PASS_ON; - _tizen_rotate_update(wind); + wind->received_rotation = 1; return ECORE_CALLBACK_PASS_ON; } @@ -401,9 +526,8 @@ _tizen_rotation_do(SDL_WindowData *wind, int rotation) if(wind->support_pre_rotation) Tizen_pre_rotation_set(wind, rotation); - _tizen_send_rotation_event(window, rotation); + _tizen_send_rotation_event(window, wind->rotation); SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SIZE_CHANGED, window->w, window->h); - wind->received_rotation = 1; } @@ -425,7 +549,10 @@ _tizen_rotate_update(SDL_WindowData *wind) //Set Screen Rotation wind->output_rotation = screen_rotation; - ecore_wl_window_buffer_transform_set(wind->window, wind->output_rotation / 90); + if(wind->support_pre_rotation) + ecore_wl_window_buffer_transform_set(wind->window, wind->output_rotation / 90); + + ecore_wl_window_rotation_set(wind->window, wind->rotation); int rotation = (wind->output_rotation + wind->rotation) % 360; _tizen_rotation_do(wind, rotation); @@ -500,6 +627,7 @@ Tizen_CreateWindow(_THIS, SDL_Window *window) #if SDL_VIDEO_OPENGL_EGL if (window->flags & SDL_WINDOW_OPENGL) { + if(wind->output_rotation == 90 || wind->output_rotation == 270) wind->egl_window = wl_egl_window_create(wind->surface, window->h, window->w); else @@ -526,6 +654,11 @@ Tizen_CreateWindow(_THIS, SDL_Window *window) wind->support_pre_rotation = 1; } } + else + { + wl_egl_window_resize(wind->egl_window, window->w, window->h, 0, 0); + } + } #endif @@ -557,7 +690,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 @@ -728,8 +865,7 @@ _tizen_cb_event_window_rotate(void *data, int type EINA_UNUSED, void *event) if (wind->rotation != ev->angle) { /* set ecore_wayland window rotation */ wind->rotation = ev->angle; - ecore_wl_window_rotation_set(wind->window, wind->rotation); - _tizen_rotate_update(wind); + wind->received_rotation = 1; } return ECORE_CALLBACK_PASS_ON; @@ -769,8 +905,6 @@ Tizen_InitWindow(_THIS) ecore_event_handler_add(ECORE_WL_EVENT_MOUSE_OUT, _tizen_cb_event_mouse_out,_this); - data->current_thread = SDL_GetThreadID(0); - return 0; }