/*DO NOTHING*/
}
-static void
+void
+_tizen_pre_rotation_set(struct wl_egl_window *win, int angle)
+{
+ wl_egl_window_rotation rot;
+ if (!win) return;
+
+ SDL_Log("%s with angle %d",__FUNCTION__, angle);
+ switch (angle) {
+ case 270:
+ rot = ROTATION_270;
+ break;
+ case 180:
+ rot = ROTATION_180;
+ break;
+ case 90:
+ rot = ROTATION_90;
+ break;
+ case 0:
+ rot = ROTATION_0;
+ break;
+ default:
+ rot = ROTATION_0;
+ break;
+ }
+
+ SDL_SetError("call wl_egl_win_set_rotation with rot %d",rot);
+ wl_egl_window_set_rotation(win, rot);
+}
+
+void
_tizen_window_orientaiton_hint_callback(void *userdata, const char *name, const char *oldValue, const char *newValue)
{
char *p_str = NULL;
SDL_WindowData *wind = (SDL_WindowData*)userdata;
Ecore_Wl_Window *window = wind->window;
- if (wind->rotation_supported == 0)
- {
+ if (wind->rotation_supported == 0) {
return;
}
if (j > 0) {
if (j == 1) {
ecore_wl_window_rotation_preferred_rotation_set(window,wind->rotation);
+ SDL_Log("SDL %s: support pre_rotation %d", __FUNCTION__,wind->support_pre_rotation);
+ if (wind->support_pre_rotation) {
+ SDL_Log("SDL %s: set pre rotation %d", __FUNCTION__,wind->rotation);
+ _tizen_pre_rotation_set(wind->egl_window, wind->rotation);
+ }
}
ecore_wl_window_rotation_available_rotations_set(window, (const int*)checked, j);
}
}
-static void
+void
_tizen_window_orientation_add_hint(void *data)
{
SDL_WindowData *wind = (SDL_WindowData*)data;
SDL_SetError("failed to create a window surface");
return -1;
}
+
+ //Support PreRotation
+ wind->support_pre_rotation = 0;
+ SDL_Log("SDL %s: call wl_egl_window_get_capabilities()", __FUNCTION__);
+ if (wl_egl_window_get_capabilities(wind->egl_window) == WL_EGL_WINDOW_CAPABILITY_ROTATION_SUPPORTED ) {
+ wind->support_pre_rotation = 1;
+ SDL_Log("Can support PreRotation");
+ }
+ else {
+ SDL_Log("can not support PreRotation !!!!!!!!!!!!!!");
+ }
}
#endif
}
void
-_tizen_setwindowsize(SDL_Window *window, int update_egl)
+_tizen_egl_window_resize(SDL_Window *window)
{
SDL_WindowData *wind = window->driverdata;
- if (!wind->window)
- {
+ if (!wind->egl_window) {
return;
}
// TODO : consider to rotation status.
#if SDL_VIDEO_OPENGL_EGL
- if ((window->flags & SDL_WINDOW_OPENGL) && (update_egl == 1)) {
+ if (window->flags & SDL_WINDOW_OPENGL) {
int aw, ah, dx = 0, dy = 0;
if ((wind->rotation == 90) || (wind->rotation == 270))
wl_egl_window_resize(wind->egl_window, window->w, window->h, dx, dy);
}
#endif
+
+}
+
+void
+_tizen_setwindowsize(SDL_Window *window)
+{
+ SDL_WindowData *wind = window->driverdata;
+ if (!wind->window) {
+ return;
+ }
ecore_wl_window_update_size(wind->window, window->w, window->h);
}
void
Tizen_SetWindowSize(_THIS, SDL_Window *window)
{
- _tizen_setwindowsize(window, 1);
+ _tizen_setwindowsize(window);
+ _tizen_egl_window_resize(window);
}
void
tmp_h = window->w;
}
- if (w) {
- *w = tmp_w;
- }
- if (h) {
- *h = tmp_h;
- }
+ if (w) *w = tmp_w;
+ if (h) *h = tmp_h;
}
-
void
Tizen_SetWindowPosition(_THIS, SDL_Window * window)
{
return (SDL_Window*)eina_hash_find(data->windows, &id);
}
-static Eina_Bool
+Eina_Bool
_tizen_cb_event_window_visibility_change(void *data, int type, void *event)
{
_THIS = data;
return ECORE_CALLBACK_PASS_ON;
}
-static Eina_Bool
+Eina_Bool
_tizen_cb_window_configure(void *data, int type EINA_UNUSED, void *event)
{
_THIS = data;
window->w = nw;
window->h = nh;
- _tizen_setwindowsize(window, 0);
+ _tizen_setwindowsize(window);
}
return ECORE_CALLBACK_PASS_ON;
}
-static Eina_Bool
+
+void
+_tizen_send_rotation_event(SDL_Window *window, unsigned int angle)
+{
+ SDL_Event event;
+ SDL_WindowData *wind;
+ wind = window->driverdata;
+
+ SDL_memset(&event, 0, sizeof(event));
+ event.type = SDL_ROTATEEVENT;
+ event.user.code = 0;
+ if (wind->support_pre_rotation)
+ event.user.data1 = (void*)0;
+ else
+ event.user.data1 = (void*)angle;
+ event.user.data2 = (void*)-1;
+
+ SDL_PushEvent(&event);
+ return;
+}
+
+Eina_Bool
_tizen_cb_event_window_rotate(void *data, int type EINA_UNUSED, void *event)
{
_THIS = data;
/* set ecore_wayland window rotation */
wind->rotation = ev->angle;
ecore_wl_window_rotation_set(ew, ev->angle);
- _tizen_setwindowsize(window, 1);
- if (wind->rotation == 0 || wind->rotation == 180)
- SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SIZE_CHANGED, window->w, window->h);
- else if (wind->rotation == 90 || wind->rotation == 270)
- SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SIZE_CHANGED, window->h, window->w);
+
+ // support prerotation
+ /* set ecore_wayland window rotation */
+ _tizen_setwindowsize(window);
+
+ if(!wind->support_pre_rotation) {
+ _tizen_egl_window_resize(window);
+ }
+ else {
+ _tizen_pre_rotation_set(wind->egl_window, (int)ev->angle);
+ }
+
+ // Send Rotation Event
+ _tizen_send_rotation_event(window, ev->angle);
+
+ if (wind->rotation == 0 || wind->rotation == 180)
+ SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SIZE_CHANGED, window->w, window->h);
+ else if (wind->rotation == 90 || wind->rotation == 270)
+ SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SIZE_CHANGED, window->h, window->w);
}
wind->received_rotation = 1;
{
if(*hint != '\0')
{
- SDL_IndicatorProcessEvent(_this->current_glwin, wind->rotation);
+ if (!wind->support_pre_rotation)
+ SDL_IndicatorProcessEvent(_this->current_glwin, wind->rotation);
+ else
+ SDL_IndicatorProcessEvent(_this->current_glwin, 0);
}
}