From: huiyu.eun Date: Mon, 5 Dec 2016 15:54:20 +0000 (+0900) Subject: [SDL_Tizen] Fix prerotation issue X-Git-Tag: accepted/tizen/3.0/ivi/20161207.070057~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=503c69f5cee7ae32b6714cfb7841cca2fac0c305;p=platform%2Fupstream%2FSDL.git [SDL_Tizen] Fix prerotation issue [Problem] 1. When had rotated device, screen flicker. 2. There is area that can't touch screen in 90 or 270 degree. 3. Changed coordinate based on screen rotated. Change-Id: I58fda15b37962ba6e2ca3b726672d3a6a7cb2416 Signed-off-by: huiyu.eun --- diff --git a/src/video/tizen/SDL_tizenmouse.c b/src/video/tizen/SDL_tizenmouse.c index f31fe31..9d6fccf 100755 --- a/src/video/tizen/SDL_tizenmouse.c +++ b/src/video/tizen/SDL_tizenmouse.c @@ -230,8 +230,7 @@ Tizen_FiniMouse(void) /* This effectively assumes that nobody else touches SDL_Mouse which is effectively a singleton */ SDL_Mouse *mouse = SDL_GetMouse(); - /* Free the current cursor if not the same pointer as - * the default cursor */ + /* Free the current cursor if not the same pointer as the default cursor */ if (mouse->def_cursor != mouse->cur_cursor) Tizen_FreeCursor (mouse->cur_cursor); @@ -252,16 +251,34 @@ ModelMatrix mMatrix; SDL_bool isTouchIndicator(SDL_Window *window, int rot, int x, int y) { - if(rot==0 && x > window->x && x < window->x + window->w && y > window->y && y < window->y + 52) + if(x > window->x && x < window->x + window->w && y > window->y && y < window->y + 52) return SDL_TRUE; - if(rot==90 && x > window->x && x < window->x + 52 && y > window->y && y < window->y + window->h) - return SDL_TRUE; + return SDL_FALSE; +} - if(rot==270 && x > window->x + window->w -52 && x < window->x + window->w && y > window->y && y < window->y + window->h) - return SDL_TRUE; +void _tizen_get_mouseXY(SDL_Window* window, int x, int y, int* retX, int* retY) +{ + SDL_WindowData *wind = window->driverdata; + if(!wind->support_pre_rotation || wind->rotation==0) + { + *retX = x; + *retY = y; + return; + }; - return SDL_FALSE; + switch (wind->rotation) + { + case 90: + *retX = window->w-y; + *retY = x; + break; + case 270: + *retX = y; + *retY = window->h-x; + break; + } + return; } Eina_Bool @@ -280,8 +297,10 @@ _tizen_cb_event_mousedown_change(void *data, int type, void *event) window = Tizen_FindWindow(_this, ew); wind = window->driverdata; - SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "mouse down (%d x %d)",e->x,e->y); - if(isTouchIndicator(window, wind->rotation, e->x, e->y)) + int x, y; + _tizen_get_mouseXY(window, (int)e->x, (int)e->y, &x, &y); + SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "mouse down (%d x %d)", x, y); + if(isTouchIndicator(window, wind->rotation, x, y)) { ModelMatrixTranslateInit(&mMatrix); wind->indicator_show = SDL_TRUE; @@ -289,10 +308,10 @@ _tizen_cb_event_mousedown_change(void *data, int type, void *event) _tizen_indicator_event_filter(); } - SDL_SendMouseMotion(window, 0, 0, e->x, e->y); + SDL_SendMouseMotion(window, 0, 0, x, y); SDL_SendMouseButton(window, 0, SDL_PRESSED, SDL_BUTTON_LEFT); - Tizen_OnTouch(_this,1,e->multi.device,ACTION_POINTER_DOWN,e->x,e->y,1.0f); + Tizen_OnTouch(_this, 1, e->multi.device, ACTION_POINTER_DOWN, x, y, 1.0f); return ECORE_CALLBACK_PASS_ON; } @@ -310,11 +329,13 @@ _tizen_cb_event_mouseup_change(void *data, int type, void *event) ew = ecore_wl_window_find(e->window); window = Tizen_FindWindow(_this, ew); - SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "mouse up (%d x %d)",e->x,e->y); - SDL_SendMouseMotion(window, 0, 0, e->x, e->y); + int x, y; + _tizen_get_mouseXY(window, (int)e->x, (int)e->y, &x, &y); + SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "mouse up (%d x %d)", x, y); + SDL_SendMouseMotion(window, 0, 0, x, y); SDL_SendMouseButton(window, 0, SDL_RELEASED, SDL_BUTTON_LEFT); - Tizen_OnTouch(_this,1,e->multi.device,ACTION_POINTER_UP,e->x,e->y,1.0f); + Tizen_OnTouch(_this,1,e->multi.device,ACTION_POINTER_UP, x, y, 1.0f); return ECORE_CALLBACK_PASS_ON; } @@ -333,10 +354,12 @@ _tizen_cb_event_mousemove_change(void *data, int type, void *event) ew = ecore_wl_window_find(e->window); window = Tizen_FindWindow(_this, ew); + int x, y; + _tizen_get_mouseXY(window, (int)e->x, (int)e->y, &x, &y); //SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "mouse move (%d x %d)",e->x,e->y); - SDL_SendMouseMotion(window, 0, 0, e->x, e->y); + SDL_SendMouseMotion(window, 0, 0, x, y); - Tizen_OnTouch(_this,1,e->multi.device,ACTION_POINTER_MOVE,e->x,e->y,1.0f); + Tizen_OnTouch(_this,1,e->multi.device,ACTION_POINTER_MOVE, x, y, 1.0f); return ECORE_CALLBACK_PASS_ON; } diff --git a/src/video/tizen/SDL_tizenwindow.c b/src/video/tizen/SDL_tizenwindow.c index ea0a432..d314de0 100755 --- a/src/video/tizen/SDL_tizenwindow.c +++ b/src/video/tizen/SDL_tizenwindow.c @@ -245,7 +245,7 @@ Tizen_CreateWindow(_THIS, SDL_Window *window) SDL_Log("Can support PreRotation"); } else { - SDL_Log("can not support PreRotation !!!!!!!!!!!!!!"); + SDL_Log("can not support PreRotation !!"); } } #endif @@ -288,17 +288,10 @@ _tizen_egl_window_resize(SDL_Window *window) // TODO : consider to rotation status. #if SDL_VIDEO_OPENGL_EGL if (window->flags & SDL_WINDOW_OPENGL) { - int aw, ah, dx = 0, dy = 0; - - if ((wind->rotation == 90) || (wind->rotation == 270)) - wl_egl_window_get_attached_size(wind->egl_window, &ah, &aw); - else - wl_egl_window_get_attached_size(wind->egl_window, &aw, &ah); - - SDL_Log("SDL %s:wl_egl_window_get_attached_size:rot(%i)%ix%i",__FUNCTION__,wind->rotation,aw,ah); - // TODO : if window size is not FULL, we need the code about Non FullSize Window. - wl_egl_window_resize(wind->egl_window, window->w, window->h, dx, dy); + int aw, ah; + wl_egl_window_get_attached_size(wind->egl_window, &aw, &ah); + wl_egl_window_resize(wind->egl_window, aw, ah, 0, 0); } #endif @@ -311,39 +304,27 @@ _tizen_setwindowsize(SDL_Window *window) if (!wind->window) { return; } - - if ((wind->rotation == 0) || (wind->rotation == 180)) - ecore_wl_window_update_size(wind->window, window->w, window->h); - else - ecore_wl_window_update_size(wind->window, window->h, window->w); + ecore_wl_window_update_size(wind->window, window->w, window->h); } void Tizen_SetWindowSize(_THIS, SDL_Window *window) { SDL_Log("[SDL_Size] Tizen_SetWindowSize"); - _tizen_setwindowsize(window); - _tizen_egl_window_resize(window); +// _tizen_setwindowsize(window); +// _tizen_egl_window_resize(window); } void Tizen_GetWindowSize(_THIS, SDL_Window *window, int *w, int *h) { SDL_WindowData *wind = window->driverdata; - int tmp_w, tmp_h; if (!wind->window) { return; } - tmp_w = window->w; - tmp_h = window->h; - if (wind->rotation == 90 || wind->rotation == 270) { - tmp_w = window->h; - tmp_h = window->w; - } - - if (w) *w = tmp_w; - if (h) *h = tmp_h; + if (w) *w = window->w; + if (h) *h = window->h; } void @@ -486,29 +467,24 @@ _tizen_cb_event_window_rotate(void *data, int type EINA_UNUSED, void *event) wind->rotation = ev->angle; ecore_wl_window_rotation_set(ew, ev->angle); - // support prerotation - /* set ecore_wayland window rotation */ - _tizen_setwindowsize(window); + if(wind->support_pre_rotation) { + _tizen_pre_rotation_set(wind->egl_window, (int)ev->angle); + + int aw, ah; + wl_egl_window_get_attached_size(wind->egl_window, &aw, &ah); + wl_egl_window_resize(wind->egl_window, aw, ah, 0, 0); + + if(wind->rotation == 90 || wind->rotation == 270) + SDL_SetWindowSize(window, ah, aw); + else + SDL_SetWindowSize(window, aw, ah);//->call wl_egl_window_resize() + + SDL_Log("[SDL_Size] * _tizen_cb_event_window_rotate aw ah : %d, %d", window->w, window->h); + } - SDL_Log("[SDL_Size] * _tizen_cb_event_window_rotate : %d, %d", window->w, window->h); // Send Rotation Event _tizen_send_rotation_event(window, ev->angle); - - int retW = window->w; - int retH = window->h; - if(!wind->support_pre_rotation) { - _tizen_egl_window_resize(window); - } - else { - if ((wind->rotation == 90) || (wind->rotation == 270)) { - retW = window->h; - retH = window->w; - } - wl_egl_window_resize(wind->egl_window, retW, retH, 0, 0); - } - ecore_wl_window_rotation_geometry_set(wind->window, wind->rotation, 0, 0,retW, retH); - _tizen_pre_rotation_set(wind->egl_window, (int)ev->angle); - SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SIZE_CHANGED, retW, retH); + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SIZE_CHANGED, window->w, window->h); } wind->received_rotation = 1;