From b0b35d64dc0a8d3bfcc642279fc6266434fc6c3d Mon Sep 17 00:00:00 2001 From: "huiyu.eun" Date: Wed, 5 Jul 2017 15:12:50 +0900 Subject: [PATCH] [SDL_Tizen] Improve indicator functions - Send Resume/Pause event to indicator - When touch the indicator space and occurs rotate event, show indicator to display Signed-off-by: huiyu.eun Change-Id: I8223be30f38b7c701c12d9b157883ef78b96a785 --- src/core/tizen/SDL_tizen.c | 7 ++ src/video/tizen/SDL_tizenmouse.c | 19 ++++ src/video/tizen/SDL_tizenopengles.c | 16 +++- src/video/tizen/SDL_tizenvideo.h | 4 + src/video/tizen/SDL_tizenwindow.c | 168 ++++++++++++++++++++++++++++++------ src/video/tizen/SDL_tizenwindow.h | 10 ++- 6 files changed, 190 insertions(+), 34 deletions(-) diff --git a/src/core/tizen/SDL_tizen.c b/src/core/tizen/SDL_tizen.c index 749ef9f..6b561bc 100644 --- a/src/core/tizen/SDL_tizen.c +++ b/src/core/tizen/SDL_tizen.c @@ -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" @@ -59,6 +60,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 +72,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; } diff --git a/src/video/tizen/SDL_tizenmouse.c b/src/video/tizen/SDL_tizenmouse.c index 21c416d..bb196c4 100755 --- a/src/video/tizen/SDL_tizenmouse.c +++ b/src/video/tizen/SDL_tizenmouse.c @@ -286,6 +286,17 @@ _tizen_cb_event_mousedown_change(void *data, int type, void *event) int x = 0, y = 0; _tizen_get_mouseXY(window, (int)e->x, (int)e->y, &x, &y); + SDL_VideoData* videoData = SDL_GetVideoDevice()->driverdata; + SDL_WindowData *wind = window->driverdata; + if(x >= 0 && x <= window->w && y >= 0 && y <= videoData->indicator_height) + { + if(!videoData->indicator_visible && wind->support_indicator) + { + videoData->indicator_parent_id = wind->id; + _tizen_ecore_ipc_client_send(OP_INDICATOR_SHOW, wind->rotation, wind->g_res_id, 0); + } + } + SDL_SendMouseMotion(window, 0, 0, x, y); SDL_SendMouseButton(window, 0, SDL_PRESSED, SDL_BUTTON_LEFT); @@ -307,6 +318,14 @@ _tizen_cb_event_mouseup_change(void *data, int type, void *event) ew = ecore_wl_window_find(e->window); window = Tizen_FindWindow(_this, ew); + SDL_VideoData* videoData = SDL_GetVideoDevice()->driverdata; + SDL_WindowData *wind = window->driverdata; + + if(videoData->indicator_on && wind->support_indicator && videoData->indicator_visible) + { + _tizen_quickpanel_on(window->driverdata); + } + int x = 0, y = 0; _tizen_get_mouseXY(window, (int)e->x, (int)e->y, &x, &y); SDL_SendMouseMotion(window, 0, 0, x, y); diff --git a/src/video/tizen/SDL_tizenopengles.c b/src/video/tizen/SDL_tizenopengles.c index 5452cad..31e13e8 100755 --- a/src/video/tizen/SDL_tizenopengles.c +++ b/src/video/tizen/SDL_tizenopengles.c @@ -64,11 +64,19 @@ void Tizen_GLES_SwapWindow(_THIS, SDL_Window *window) { SDL_EGL_SwapBuffers(_this, ((SDL_WindowData *) window->driverdata)->egl_surface); - SDL_WindowData* wdata = (SDL_WindowData*)window->driverdata; - if (wdata->received_rotation == 1) { + SDL_WindowData* wind = (SDL_WindowData*)window->driverdata; + if (wind->received_rotation == 1) { Tizen_rotate_update(window); - ecore_wl_window_rotation_change_done_send(wdata->window); - wdata->received_rotation = 0; + ecore_wl_window_rotation_change_done_send(wind->window); + wind->received_rotation = 0; + + SDL_VideoData* videoData = SDL_GetVideoDevice()->driverdata; + if(videoData->indicator_on && wind->support_indicator) + { + videoData->indicator_parent_id = wind->id; + _tizen_ecore_ipc_client_send(OP_INDICATOR_SHOW, wind->rotation, wind->g_res_id, 0); + _tizen_quickpanel_on(window->driverdata); + } } } diff --git a/src/video/tizen/SDL_tizenvideo.h b/src/video/tizen/SDL_tizenvideo.h index 17df465..699c168 100755 --- a/src/video/tizen/SDL_tizenvideo.h +++ b/src/video/tizen/SDL_tizenvideo.h @@ -43,7 +43,11 @@ typedef struct { Tizen_Prerotation_Data tizen_pre_rotation_data; int indicator_mode; + int indicator_height; + int indicator_parent_id; + SDL_bool indicator_on; + SDL_bool indicator_visible; } SDL_VideoData; /* Initialization/Query functions */ diff --git a/src/video/tizen/SDL_tizenwindow.c b/src/video/tizen/SDL_tizenwindow.c index cdc5f96..fcc9089 100755 --- a/src/video/tizen/SDL_tizenwindow.c +++ b/src/video/tizen/SDL_tizenwindow.c @@ -70,8 +70,26 @@ Ecore_Ipc_Server *ipc = NULL; if (ecore_ipc_client_server_get(e->client) != ipc) \ return ECORE_CALLBACK_PASS_ON -void Tizen_ExecuteIndicatorProcess() +void _tizen_quickpanel_on(SDL_WindowData *wind) { + SDL_Log("[SDL]Quick panel on"); + ecore_wl_window_indicator_state_set(wind->window, ECORE_WL_INDICATOR_STATE_ON); + ecore_wl_indicator_visible_type_set(wind->window, ECORE_WL_INDICATOR_VISIBLE_TYPE_SHOWN); +} + +void _tizen_quickpanel_off(SDL_WindowData *wind) +{ + SDL_Log("[SDL]Quick panel off"); + ecore_wl_window_indicator_state_set(wind->window, ECORE_WL_INDICATOR_STATE_OFF); + ecore_wl_indicator_visible_type_set(wind->window, ECORE_WL_INDICATOR_VISIBLE_TYPE_HIDDEN); +} + +void Tizen_ExecuteIndicatorProcess(SDL_WindowData *wind) +{ + SDL_VideoData* videoData = SDL_GetVideoDevice()->driverdata; + if(!videoData) return; + + _tizen_init_ecore_ipc(); unsigned int childPID = fork(); if(childPID == 0) @@ -87,14 +105,72 @@ void Tizen_ExecuteIndicatorProcess() else if(childPID == -1) { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "[SDL] Failed fork"); + videoData->indicator_on = SDL_FALSE; + videoData->indicator_visible = SDL_FALSE; } else { SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "[SDL] parent process : %d", getpid()); + videoData->indicator_on = SDL_TRUE; + videoData->indicator_visible = SDL_TRUE; + videoData->indicator_parent_id = wind->id; + } +} + +void +Tizen_TerminateIndicatorProcess(SDL_WindowData *wind) +{ + if(!wind) return; + + SDL_VideoData* videoData = SDL_GetVideoDevice()->driverdata; + if(videoData->indicator_on) + { + _tizen_ecore_ipc_client_send(OP_TERMINATE, 0, 0, 0); + _tizen_quickpanel_off(wind); } } -void _tizen_ecore_ipc_client_send(int major, int minor, int ref, int ref_to) +SDL_bool +Tizen_SupportIndicator(SDL_Window *window) +{ + SDL_VideoData* videoData = SDL_GetVideoDevice()->driverdata; + return (!(window->flags & SDL_WINDOW_BORDERLESS) && !videoData->indicator_on); +} + +void +Tizen_chk_indicator(SDL_Window *window) +{ + SDL_WindowData *wind = window->driverdata; + int screen_w, screen_h; + + int rotation = (wind->output_rotation + wind->rotation) % 360; + if(rotation==90 || rotation==270) + ecore_wl_screen_size_get(&screen_h, &screen_w); + else + ecore_wl_screen_size_get(&screen_w, &screen_h); + + if(window->w == screen_w && window->h == screen_h && window->x ==0 && window->y == 0) + { + if(Tizen_SupportIndicator(window)) + { + wind->support_indicator = SDL_TRUE; + Tizen_ExecuteIndicatorProcess(wind); + } + else + { + wind->support_indicator = SDL_FALSE; + Tizen_TerminateIndicatorProcess(wind); + } + } + else + { + wind->support_indicator = SDL_FALSE; + Tizen_TerminateIndicatorProcess(wind); + } +} + +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; @@ -103,7 +179,8 @@ void _tizen_ecore_ipc_client_send(int major, int minor, int ref, int ref_to) 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) +static Eina_Bool +_cb_client_add(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) { IPC_HEAD(Add); @@ -123,7 +200,8 @@ static Eina_Bool _cb_client_add(void *data EINA_UNUSED, int type EINA_UNUSED, vo return ECORE_CALLBACK_DONE; } -static Eina_Bool _cb_client_del(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) +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"); @@ -141,16 +219,46 @@ static Eina_Bool _cb_client_del(void *data EINA_UNUSED, int type EINA_UNUSED, vo return ECORE_CALLBACK_DONE; } -static Eina_Bool _cb_client_data(void *data, int type EINA_UNUSED, void *event) +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); + + SDL_VideoData* videoData = SDL_GetVideoDevice()->driverdata; + SDL_Window * window = (SDL_Window*)eina_hash_find(videoData->windows, &videoData->indicator_parent_id); + switch(epcEvent->major) + { + case OP_INDICATOR_INIT: + videoData->indicator_height = epcEvent->minor; + _tizen_quickpanel_on(window->driverdata); + break; + case OP_INDICATOR_SHOW: + videoData->indicator_visible = SDL_TRUE; + break; + case OP_INDICATOR_HIDE: + if(epcEvent->minor == 1) + { + _tizen_quickpanel_off(window->driverdata); + } + else if(epcEvent->minor == 2) + { + videoData->indicator_visible = SDL_FALSE; + } + break; + case OP_TERMINATE: + videoData->indicator_on = SDL_FALSE; + videoData->indicator_visible = SDL_FALSE; + break; + } + return ECORE_CALLBACK_DONE; } -int _tizen_init_ecore_ipc() +int +_tizen_init_ecore_ipc() { if(!ipc) @@ -261,17 +369,12 @@ Tizen_SetWindowTitle(_THIS, SDL_Window * window) void Tizen_ShowWindow(_THIS, SDL_Window *window) { - SDL_VideoData* videoData = SDL_GetVideoDevice()->driverdata; - - if(!(window->flags & SDL_WINDOW_BORDERLESS) && !videoData->indicator_on) - { - Tizen_ExecuteIndicatorProcess(); - } - SDL_WindowData *wind = window->driverdata; ecore_wl_window_show(wind->window); + Tizen_chk_indicator(window); } + void Tizen_HideWindow(_THIS, SDL_Window *window) { @@ -305,6 +408,7 @@ Tizen_SetWindowFullscreen(_THIS, SDL_Window *window, window->fullscreen_mode.w = screen_w; window->fullscreen_mode.h = screen_h; + Tizen_chk_indicator(window); } void @@ -461,6 +565,16 @@ Tizen_rotate_update(SDL_Window *window) _tizen_rotation_do(window, wind, rotation); } +SDL_Window* +Tizen_FindWindow(_THIS, Ecore_Wl_Window *ewin) +{ + SDL_VideoData *data = _this->driverdata; + int id; + + id = ecore_wl_window_id_get(ewin); + return (SDL_Window*)eina_hash_find(data->windows, &id); +} + void _tizen_window_orientaiton_hint_callback(void *userdata, const char *name, const char *oldValue, const char *newValue) { @@ -728,9 +842,16 @@ Tizen_CreateWindow(_THIS, SDL_Window *window) void Tizen_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered) { - SDL_VideoData* videoData = SDL_GetVideoDevice()->driverdata; - if(!videoData->indicator_on) - Tizen_ExecuteIndicatorProcess(); + if(!bordered) + { + SDL_WindowData *wind = window->driverdata; + wind->support_indicator = SDL_FALSE; + Tizen_TerminateIndicatorProcess(window->driverdata); + } + else + { + Tizen_chk_indicator(window); + } } void @@ -758,7 +879,7 @@ Tizen_SetWindowSize(_THIS, SDL_Window *window) } SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SIZE_CHANGED, window->w, window->h); #endif - + Tizen_chk_indicator(window); } void @@ -782,7 +903,8 @@ Tizen_SetWindowPosition(_THIS, SDL_Window * window) } // TODO : consider to rotation status. - ecore_wl_window_position_set(wind->window, window->x, window->y); + ecore_wl_window_position_set(wind->window, window->x, window->y); + Tizen_chk_indicator(window); } void @@ -806,16 +928,6 @@ Tizen_DestroyWindow(_THIS, SDL_Window *window) window->driverdata = NULL; } -SDL_Window* -Tizen_FindWindow(_THIS, Ecore_Wl_Window *ewin) -{ - SDL_VideoData *data = _this->driverdata; - int id; - - id = ecore_wl_window_id_get(ewin); - return (SDL_Window*)eina_hash_find(data->windows, &id); -} - Eina_Bool _tizen_cb_event_window_visibility_change(void *data, int type, void *event) { diff --git a/src/video/tizen/SDL_tizenwindow.h b/src/video/tizen/SDL_tizenwindow.h index fa9a798..1b5fff1 100755 --- a/src/video/tizen/SDL_tizenwindow.h +++ b/src/video/tizen/SDL_tizenwindow.h @@ -47,6 +47,7 @@ typedef struct { int received_rotation; SDL_bool support_pre_rotation; + SDL_bool support_indicator; } SDL_WindowData; @@ -95,14 +96,19 @@ extern void _tizen_ecore_ipc_client_send(int major, int minor, int ref, int ref_ extern void _tizen_set_window_size(SDL_Window * window, int w, int h); enum { - OP_INDICATOR_SHOW=1, + OP_INDICATOR_INIT = 1, + OP_INDICATOR_SHOW, OP_INDICATOR_HIDE, OP_RESUME, OP_PAUSE, OP_TERMINATE }; -extern void Tizen_ExecuteIndicatorProcess(); +extern void Tizen_ExecuteIndicatorProcess(SDL_WindowData *wind); +extern void _tizen_ecore_ipc_client_send(int major, int minor, int ref, int ref_to); + +extern void _tizen_quickpanel_on(SDL_WindowData *wind); +extern void _tizen_quickpanel_off(SDL_WindowData *wind); #endif /* _SDL_tizenwindow_h */ -- 2.7.4