#if SDL_VIDEO_DRIVER_TIZEN
-#include "../SDL_sysvideo.h"
-#include "../../events/SDL_windowevents_c.h"
-#include "../SDL_egl_c.h"
-#include "SDL_tizenwindow.h"
+#include "SDL_log.h"
+#include "SDL_hints.h"
+#include "SDL_loadso.h"
+
#include "SDL_tizenvideo.h"
#include "SDL_tizentouch.h"
#include "SDL_tizenkeyboard.h"
-
#include "SDL_tizenmouse.h"
#include "SDL_tizenevents_c.h"
-#include "SDL_log.h"
-#include "SDL_hints.h"
+
+#include "SDL_tizenwindow.h"
+#include "SDL_tizenopengles.h"
+
#include "../../events/SDL_mouse_c.h"
#include "../../joystick/tizen/SDL_sysjoystick_c.h"
-#include <wayland-egl.h>
+
+#include "../SDL_egl_c.h"
+#include "../SDL_vulkan_c.h"
+#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 */
+};
+
+#define LOAD_FUNC(NAME) \
+_this->tizen_pre_rotation_data.NAME = SDL_LoadFunction(_this->tizen_pre_rotation_data.prerotation_dll_handle, #NAME); \
+if (!_this->tizen_pre_rotation_data.NAME) \
+{ \
+ SDL_LogError(SDL_LOG_CATEGORY_ASSERT, "Could not retrieve pre-rotation function " #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 _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)
+ {
+ 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");
+ 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);
+ }
+}
+
+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;
+ 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_VideoData* videoData = SDL_GetVideoDevice()->driverdata;
+ videoData->indicator_on = SDL_TRUE;
+
+ SDL_Window * window = SDL_GetVideoDevice()->windows;
+ SDL_WindowData *wind = window->driverdata;
+
+ int window_w, window_h;
+ ecore_wl_screen_size_get(&window_w, &window_h);
+
+ _tizen_ecore_ipc_client_send(OP_INDICATOR_SHOW, wind->rotation, wind->g_res_id, videoData->indicator_mode);
+
+ 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_VideoData* videoData = SDL_GetVideoDevice()->driverdata;
+ videoData->indicator_on = 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);
+
+ 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()
+{
+
+ 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()
+{
+ static int type = ROTATION_TYPE_PRE_ROTATION;
+ static int checked = 0;
+ char *engine = NULL;
+
+ if (checked) return type;
+
+ engine = getenv("SDL_ROTATION");
+
+ if (engine)
+ {
+ if ((!strcasecmp(engine, "normal")))
+ type = ROTATION_TYPE_NORMAL_ROTATION;
+ else if ((!strcasecmp(engine, "pre_rotation")))
+ type = ROTATION_TYPE_PRE_ROTATION;
+ else
+ type = ROTATION_TYPE_PRE_ROTATION;
+ }
+ checked = 1;
+ return type;
+}
int
-_tizen_PreRotatotion_LoadLibrary(SDL_WindowData *_this, const char *lib_path)
+_tizen_PreRotatotion_LoadLibrary(SDL_VideoData *_this, const char *lib_path)
{
void *lib_dll_handle = NULL;
char *path = NULL;
- if (_this->isLoaded_pre_rotation)
+ if (_this->tizen_pre_rotation_data.prerotation_dll_handle
+ && _this->tizen_pre_rotation_data.wl_egl_window_set_rotation
+ && _this->tizen_pre_rotation_data.wl_egl_window_get_capabilities)
return SDL_TRUE;
- _this->tizen_pre_rotation_data = (struct Tizen_Prerotation_Data *) SDL_calloc(1, sizeof(Tizen_Prerotation_Data));
- if (!_this->tizen_pre_rotation_data) {
- return SDL_OutOfMemory();
- }
+ _this->tizen_pre_rotation_data.prerotation_dll_handle = NULL;
+ _this->tizen_pre_rotation_data.wl_egl_window_set_rotation = NULL;
+ _this->tizen_pre_rotation_data.wl_egl_window_get_capabilities = NULL;
if (!lib_path)
lib_dll_handle = SDL_LoadObject(lib_path);
lib_dll_handle = SDL_LoadObject(path);
}
- _this->tizen_pre_rotation_data->prerotation_dll_handle = lib_dll_handle;
+ _this->tizen_pre_rotation_data.prerotation_dll_handle = lib_dll_handle;
if (lib_dll_handle == NULL)
return SDL_FALSE;
- _this->tizen_pre_rotation_data->wl_egl_window_set_rotation = SDL_LoadFunction(lib_dll_handle, "wl_egl_window_set_rotation");
- if (!_this->tizen_pre_rotation_data->wl_egl_window_set_rotation)
- return SDL_FALSE;
-
- _this->tizen_pre_rotation_data->wl_egl_window_get_capabilities = SDL_LoadFunction(lib_dll_handle, "wl_egl_window_get_capabilities"); \
- if (!_this->tizen_pre_rotation_data->wl_egl_window_get_capabilities)
- return SDL_FALSE;
-
- _this->isLoaded_pre_rotation = 1;
+ LOAD_FUNC(wl_egl_window_set_rotation);
+ LOAD_FUNC(wl_egl_window_get_capabilities);
return SDL_TRUE;
}
}
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;
ecore_wl_window_show(wind->window);
+ Tizen_chk_indicator(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)
{
- /*DO NOTHING*/
+ SDL_WindowData *wind = window->driverdata;
+ if(!wind) return;
+
+ 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);
+
+ _tizen_set_window_size(window, screen_w, screen_h);
+ Tizen_SetWindowSize(_this, window);
+
+ window->fullscreen_mode.w = screen_w;
+ window->fullscreen_mode.h = screen_h;
+ Tizen_chk_indicator(window);
}
void
-_tizen_pre_rotation_set(SDL_WindowData *_this)
+Tizen_pre_rotation_set(SDL_WindowData *wind, int rotation)
{
- wl_egl_window_rotation rot;
- if (!_this->egl_window) return;
+ tizen_wl_egl_window_rotation rot;
+ if (!wind->egl_window) return;
- SDL_Log("%s with angle %d",__FUNCTION__, _this->rotation);
- switch (_this->rotation) {
+ switch (rotation) {
case 90:
- rot = ROTATION_270;
+ rot = TIZEN_ROTATION_270;
break;
case 180:
- rot = ROTATION_180;
+ rot = TIZEN_ROTATION_180;
break;
case 270:
- rot = ROTATION_90;
+ rot = TIZEN_ROTATION_90;
break;
case 0:
- rot = ROTATION_0;
+ rot = TIZEN_ROTATION_0;
break;
default:
- rot = ROTATION_0;
+ rot = TIZEN_ROTATION_0;
break;
}
- SDL_SetError("call wl_egl_win_set_rotation with rot %d",rot);
- _this->tizen_pre_rotation_data->wl_egl_window_set_rotation(_this->egl_window, rot);
+ SDL_VideoData* _this = SDL_GetVideoDevice()->driverdata;
+ _this->tizen_pre_rotation_data.wl_egl_window_set_rotation(wind->egl_window, rot);
+}
+
+void
+_tizen_set_window_size(SDL_Window * window, int w, int h)
+{
+ if(!window)
+ {
+ SDL_SetError("Invalid window");
+ return;
+ }
+
+ SDL_VideoDevice *_this = SDL_GetVideoDevice();
+ if (!_this) {
+ SDL_SetError("Video subsystem has not been initialized");
+ return;
+ }
+
+ if (window->magic != &_this->window_magic) {
+ return;
+ }
+
+ if (w <= 0) {
+ SDL_InvalidParamError("w");
+ return;
+ }
+ if (h <= 0) {
+ SDL_InvalidParamError("h");
+ return;
+ }
+
+ /* Make sure we don't exceed any window size limits */
+ if (window->min_w && w < window->min_w)
+ {
+ w = window->min_w;
+ }
+ if (window->max_w && w > window->max_w)
+ {
+ w = window->max_w;
+ }
+ if (window->min_h && h < window->min_h)
+ {
+ h = window->min_h;
+ }
+ if (window->max_h && h > window->max_h)
+ {
+ h = window->max_h;
+ }
+
+ if(window->flags & SDL_WINDOW_FULLSCREEN)
+ {
+ window->fullscreen_mode.w = w;
+ window->fullscreen_mode.h = h;
+ }
+
+ window->windowed.w = w;
+ window->windowed.h = h;
+
+ window->w = w;
+ window->h = h;
+}
+
+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;
+}
+
+void
+_tizen_rotation_do(SDL_Window *window, SDL_WindowData* wind, int rotation)
+{
+ int window_w, window_h;
+ if(wind->rotation == 0 || wind->rotation == 180)
+ ecore_wl_window_geometry_get(wind->window, 0, 0, &window_w, &window_h);
+ else
+ ecore_wl_window_geometry_get(wind->window, 0, 0, &window_h, &window_w);
+
+ _tizen_set_window_size(window, window_w, window_h);
+
+ if(wind->support_pre_rotation)
+ Tizen_pre_rotation_set(wind, rotation);
+
+ _tizen_send_rotation_event(window, wind->rotation);
+ SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SIZE_CHANGED, window->w, window->h);
+
+}
+
+void
+Tizen_rotate_update(SDL_Window *window)
+{
+ SDL_WindowData *wind = window->driverdata;
+ if(!wind) return;
+
+ int screen_rotation;
+ if (ecore_wl_window_ignore_output_transform_get(wind->window))
+ {
+ screen_rotation = 0;
+ }
+ else
+ {
+ Ecore_Wl_Output *output = ecore_wl_window_output_find(wind->window);
+ screen_rotation = ecore_wl_output_transform_get(output) * 90;
+ }
+
+ //Set Screen Rotation
+ wind->output_rotation = screen_rotation;
+ 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(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
SDL_WindowData *wind = (SDL_WindowData*)userdata;
Ecore_Wl_Window *window = wind->window;
- if (wind->rotation_supported == 0) {
+ if (wind->rotation_supported == 0)
return;
- }
SDL_assert(SDL_strncmp(name, SDL_HINT_ORIENTATIONS, SDL_strlen(SDL_HINT_ORIENTATIONS)) == 0);
- if ((oldValue == NULL) && (newValue == NULL)) {
+ if ((oldValue == NULL) && (newValue == NULL))
return;
- }
for (i=0;i<4;i++) {
p_str = SDL_strstr(newValue, orientation_type[i]);
if (i == 0) {
checked[j] = 0;
- SDL_Log("SDL %s: avaiable rotation: 0", __FUNCTION__);
}
else if (i == 1) {
checked[j] = 90;
- SDL_Log("SDL %s: avaiable rotation: 90", __FUNCTION__);
}
else if (i == 2) {
checked[j] = 180;
- SDL_Log("SDL %s: avaiable rotation: 180", __FUNCTION__);
}
else if (i == 3) {
checked[j] = 270;
- SDL_Log("SDL %s: avaiable rotation: 270", __FUNCTION__);
}
j++;
}
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);
- }
+ ecore_wl_window_rotation_preferred_rotation_set(window, wind->rotation);
+ }else {
+ ecore_wl_window_rotation_available_rotations_set(window, (const int*)checked, j);
}
- ecore_wl_window_rotation_available_rotations_set(window, (const int*)checked, j);
}
+
+ Tizen_rotate_update(Tizen_FindWindow(SDL_GetVideoDevice(), window));
}
void
_tizen_window_orientation_add_hint(void *data)
{
SDL_WindowData *wind = (SDL_WindowData*)data;
- if (wind->rotation_supported == 0) {
+ if (wind->rotation_supported == 0)
return;
- }
SDL_AddHintCallback(SDL_HINT_ORIENTATIONS, _tizen_window_orientaiton_hint_callback, data);
}
+static Eina_Bool
+_tizen_cb_output_transform(void *data, int type EINA_UNUSED, void *event)
+{
+ SDL_Window * window = SDL_GetVideoDevice()->windows;
+ SDL_WindowData *wind = window->driverdata;
+
+ if(!wind) return ECORE_CALLBACK_PASS_ON;
+
+ Ecore_Wl_Event_Output_Transform *ev = event;
+ Ecore_Wl_Output *output;
+
+ output = ecore_wl_window_output_find(wind->window);
+ if (output != ev->output) return ECORE_CALLBACK_PASS_ON;
+
+ wind->received_rotation = 1;
+
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool
+_tizen_cb_ignore_output_transform(void *data, int type EINA_UNUSED, void *event EINA_UNUSED)
+{
+ SDL_Window * window = SDL_GetVideoDevice()->windows;
+ SDL_WindowData *wind = window->driverdata;
+
+ if(!wind) return ECORE_CALLBACK_PASS_ON;
+
+ wind->received_rotation = 1;
+
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+void
+_tizen_output_transform_register(SDL_WindowData *wind)
+{
+ if(!wind) return;
+
+ Ecore_Wl_Output *output = ecore_wl_window_output_find(wind->window);
+ wind->output_rotation = ecore_wl_output_transform_get(output) * 90;
+
+ ecore_event_handler_add(ECORE_WL_EVENT_OUTPUT_TRANSFORM,
+ _tizen_cb_output_transform, NULL);
+ ecore_event_handler_add(ECORE_WL_EVENT_IGNORE_OUTPUT_TRANSFORM,
+ _tizen_cb_ignore_output_transform, NULL);
+}
+
+void
+_tizen_indicator_opacity_hint_callback(void *userdata, const char *name, const char *oldValue, const char *newValue)
+{
+ SDL_VideoData *data = (SDL_VideoData *)userdata;
+
+ if ((oldValue == NULL) && (newValue == NULL))
+ return;
+
+ SDL_assert(SDL_strncmp(name, SDL_HINT_TIZEN_INDICATOR_OPACITY, SDL_strlen(SDL_HINT_TIZEN_INDICATOR_OPACITY)) == 0);
+ char indicator_type[4][20] = {"opaque","translucent","transparent","bg_transparent"};
+ for (int i=0;i<4;i++) {
+ if(SDL_strncmp(newValue, indicator_type[i], SDL_strlen(indicator_type[i])) == 0)
+ {
+ data->indicator_mode = i+1;
+ break;
+ }
+ }
+}
+
int
Tizen_CreateWindow(_THIS, SDL_Window *window)
{
}
#endif
+#if SDL_VIDEO_VULKAN
+ if (window->flags & SDL_WINDOW_VULKAN) {
+ if (!_this->vulkan_GetInstanceExtensions) {
+ SDL_SetError("No Vulkan support in video driver");
+ }
+
+ if (_this->vulkan_LoadLibrary(_this, NULL) < 0) {
+ SDL_SetError("Fail to load Vulkan Library");
+ }
+ }
+#endif
+
if (window->x == SDL_WINDOWPOS_UNDEFINED) {
window->x = 0;
}
if (!(globals = ecore_wl_globals_get()))
{
- SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get wayland globals");
+ SDL_LogError(SDL_LOG_CATEGORY_ASSERT, "Failed to get wayland globals");
return -1;
}
wind->window = ecore_wl_window_new(NULL,
window->x, window->y, window->w, window->h,
ECORE_WL_WINDOW_BUFFER_TYPE_SHM);
+ if (!wind->window) {
+ SDL_LogError(SDL_LOG_CATEGORY_ASSERT, "Failed to create wayland window");
+ return -1;
+ }
+ _tizen_output_transform_register(wind);
+
wind->surface = ecore_wl_window_surface_create(wind->window);
+ if (!wind->surface) {
+ SDL_LogError(SDL_LOG_CATEGORY_ASSERT, "Failed to create wayland window surface");
+ return -1;
+ }
+ ecore_wl_window_type_set(wind->window, ECORE_WL_WINDOW_TYPE_UTILITY);
+
wind->rotation = 0;
wind->rotation_supported = 0;
wind->received_rotation = 0;
- ecore_wl_window_opaque_region_set(wind->window, window->x, window->y, window->w, window->h);
#if SDL_VIDEO_OPENGL_EGL
if (window->flags & SDL_WINDOW_OPENGL) {
- wind->egl_window = wl_egl_window_create(ecore_wl_window_surface_get(wind->window), window->w, window->h);
+
+ if(wind->output_rotation == 90 || wind->output_rotation == 270)
+ wind->egl_window = wl_egl_window_create(wind->surface, window->h, window->w);
+ else
+ wind->egl_window = wl_egl_window_create(wind->surface, window->w, window->h);
/* Create the GLES window surface */
wind->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) wind->egl_window);
if (wind->egl_surface == EGL_NO_SURFACE) {
- SDL_SetError("failed to create a window surface");
+ SDL_LogError(SDL_LOG_CATEGORY_ASSERT, "failed to create a window surface");
return -1;
}
+ if (!_this->gl_config.alpha_size) {
+ ecore_wl_window_opaque_region_set(wind->window, window->x, window->y, window->w, window->h);
+ }
+ else {
+ wl_surface_set_opaque_region(wind->surface, NULL);
+ }
+
//Support PreRotation
wind->support_pre_rotation = 0;
- if (_tizen_PreRotatotion_LoadLibrary(wind, "libwayland-egl.so")) {
- SDL_Log("SDL %s: call wl_egl_window_get_capabilities()", __FUNCTION__);
- if (wind->tizen_pre_rotation_data->wl_egl_window_get_capabilities(wind->egl_window) == WL_EGL_WINDOW_CAPABILITY_ROTATION_SUPPORTED ) {
+ if (_tizen_rotation_type_get() && _tizen_PreRotatotion_LoadLibrary(data, "libwayland-egl.so")) {
+ if (data->tizen_pre_rotation_data.wl_egl_window_get_capabilities(wind->egl_window) == TIZEN_WL_EGL_WINDOW_CAPABILITY_ROTATION_SUPPORTED ) {
wind->support_pre_rotation = 1;
- SDL_Log("Can support PreRotation");
- }
- else {
- SDL_Log("can not support PreRotation !!");
}
}
- else {
- SDL_Log("can not support PreRotation !!");
+ else
+ {
+ wl_egl_window_resize(wind->egl_window, window->w, window->h, 0, 0);
}
+
}
#endif
SDL_SetMouseFocus(window);
if (window->flags & 0x00008000) {
- SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "---------------------------------------");
- SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "[SDL] touch bypass setting is done!\n");
- SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "---------------------------------------");
ecore_wl_window_input_region_set(wind->window, -1, -1, 1, 1);
ecore_wl_window_focus_skip_set(wind->window, EINA_TRUE);
}
EINA_INLIST_FOREACH(globals, global) {
if (!strcmp(global->interface, "tizen_policy_ext")) {
wind->rotation_supported = 1;
- SDL_Log("SDL can support rotation in this device!!!!!!!!!!!");
break;
}
}
// Add orientaiton hint cb
_tizen_window_orientation_add_hint((void*)wind);
+ SDL_AddHintCallback(SDL_HINT_TIZEN_INDICATOR_OPACITY, _tizen_indicator_opacity_hint_callback, data);
+
+ Tizen_rotate_update(window);
+
return 0;
}
void
-_tizen_egl_window_resize(SDL_Window *window)
+Tizen_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
{
- SDL_WindowData *wind = window->driverdata;
- if (!wind->egl_window) {
- return;
+ if(!bordered)
+ {
+ SDL_WindowData *wind = window->driverdata;
+ wind->support_indicator = SDL_FALSE;
+ Tizen_TerminateIndicatorProcess(window->driverdata);
}
-
- // TODO : consider to rotation status.
-#if SDL_VIDEO_OPENGL_EGL
- if (window->flags & SDL_WINDOW_OPENGL) {
- // TODO : if window size is not FULL, we need the code about Non FullSize Window.
- 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);
+ else
+ {
+ Tizen_chk_indicator(window);
}
-#endif
-
}
void
-_tizen_setwindowsize(SDL_Window *window)
+Tizen_SetWindowSize(_THIS, SDL_Window *window)
{
SDL_WindowData *wind = window->driverdata;
- if (!wind->window) {
+ if (!wind->egl_window)
return;
- }
- 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);
+// TODO : consider to rotation status.
+#if SDL_VIDEO_OPENGL_EGL
+ if (window->flags & SDL_WINDOW_OPENGL)
+ {
+ int rotation = (wind->output_rotation + wind->rotation) % 360;
+ if(rotation == 90 || rotation == 270)
+ {
+ ecore_wl_window_update_size(wind->window, window->h, window->w);
+ wl_egl_window_resize(wind->egl_window, window->h, window->w, 0, 0);
+ }
+ else
+ {
+ ecore_wl_window_update_size(wind->window, window->w, window->h);
+ wl_egl_window_resize(wind->egl_window, window->w, window->h, 0, 0);
+ }
+ }
+ SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SIZE_CHANGED, window->w, window->h);
+#endif
+ Tizen_chk_indicator(window);
}
void
}
// 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
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)
{
ew = ecore_wl_window_find(ev->win);
window = Tizen_FindWindow(_this, ew);
- SDL_Log( "visibility window: %p, ecore_wl_window: %p\n", window, ew);
-
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SHOWN, 0, 0);
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESTORED, 0, 0);
return ECORE_CALLBACK_PASS_ON;
SDL_Window *window;
SDL_WindowData *wind;
Ecore_Wl_Event_Window_Configure *ev;
- int nx = 0, ny = 0, nw = 0, nh = 0;
ev = event;
ew = ecore_wl_window_find(ev->win);
window = Tizen_FindWindow(_this, ew);
return ECORE_CALLBACK_PASS_ON;
}
- SDL_Log( "configure notify window: %p, ecore_wl_window: %p\n", window, ew);
-
- ecore_wl_window_geometry_get(ew, &nx, &ny, &nw, &nh);
- if (nw < 1) nw = 1;
- if (nh < 1) nh = 1;
-
- SDL_Log("[SDL_Size] * _tizen_cb_window_configure :: w->w:%d, w->h:%d, nw:%d, nh:%d", window->w, window->h, nw, nh);
- if ((window->x != nx) || (window->y != ny))
- ecore_wl_window_position_set(ew, nx, ny);
-
- if ((window->w != nw) || (window->h != nh)) {
- _tizen_setwindowsize(window);
- }
return ECORE_CALLBACK_PASS_ON;
}
-
-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)
{
if (wind->rotation != ev->angle) {
/* set ecore_wayland window rotation */
wind->rotation = ev->angle;
- ecore_wl_window_rotation_set(ew, ev->angle);
-
- if(wind->support_pre_rotation) {
- _tizen_pre_rotation_set(wind);
+ wind->received_rotation = 1;
+ }
- 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);
+ return ECORE_CALLBACK_PASS_ON;
+}
- if(wind->rotation == 90 || wind->rotation == 270)
- SDL_SetWindowSize(window, ah, aw);
- else
- SDL_SetWindowSize(window, aw, ah);//->call wl_egl_window_resize()
+static Eina_Bool _tizen_cb_event_window_show(void *data, int type, void *event)
+{
+ Ecore_Wl_Event_Window_Show *e;
+ uint32_t g_res_id = 0;
- SDL_Log("[SDL_Size] * _tizen_cb_event_window_rotate aw ah : %d, %d", window->w, window->h);
- }
+ e = event;
+ if (e->data[0] > 0)
+ g_res_id = e->data[0];
- // Send Rotation Event
- _tizen_send_rotation_event(window, ev->angle);
- SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SIZE_CHANGED, window->w, window->h);
+ if(g_res_id!=0)
+ {
+ SDL_VideoData *this = SDL_GetVideoDevice()->driverdata;
+ SDL_Window * window = (SDL_Window*)eina_hash_find(this->windows, &e->win);
+ SDL_WindowData *wind = window->driverdata;
+ wind->g_res_id = g_res_id;
+ SDL_Log("[SDL] SDL Window Resource ID %d", g_res_id);
}
- wind->received_rotation = 1;
- const char* hint = SDL_GetHint(SDL_HINT_ORIENTATIONS);
- if(hint && *hint != '\0')
- SDL_IndicatorProcessEvent(_this->current_glwin, wind->rotation);
-
return ECORE_CALLBACK_PASS_ON;
}
ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_VISIBILITY_CHANGE,
_tizen_cb_event_window_visibility_change,_this);
+ ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_ROTATE,
+ _tizen_cb_event_window_rotate,_this);
+ ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_CONFIGURE,
+ _tizen_cb_window_configure,_this);
+ ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_SHOW,
+ _tizen_cb_event_window_show, _this);
+
ecore_event_handler_add(ECORE_EVENT_KEY_UP,
_tizen_cb_event_keyup_change,_this);
ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
_tizen_cb_event_keydown_change,_this);
+
ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN,
_tizen_cb_event_mousedown_change,_this);
ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP,
_tizen_cb_event_mouseup_change,_this);
ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE,
_tizen_cb_event_mousemove_change,_this);
- ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_ROTATE,
- _tizen_cb_event_window_rotate,_this);
- ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_CONFIGURE,
- _tizen_cb_window_configure,_this);
- ecore_event_handler_add(ECORE_EVENT_JOYSTICK,
- _tizen_cb_event_joystick_change,_this);
- ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_IN,
- _tizen_cb_event_focus_in,_this);
- ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_OUT,
- _tizen_cb_event_focus_out,_this);
ecore_event_handler_add(ECORE_WL_EVENT_MOUSE_IN,
_tizen_cb_event_mouse_in,_this);
ecore_event_handler_add(ECORE_WL_EVENT_MOUSE_OUT,
_tizen_cb_event_mouse_out,_this);
+ ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_IN,
+ _tizen_cb_event_focus_in,_this);
+ ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_OUT,
+ _tizen_cb_event_focus_out,_this);
+
+ ecore_event_handler_add(ECORE_EVENT_JOYSTICK,
+ _tizen_cb_event_joystick_change,_this);
+
return 0;
}