2 Simple DirectMedia Layer
3 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
4 Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
6 Contact: Sangjin Lee <lsj119@samsung.com>
8 This software is provided 'as-is', without any express or implied
9 warranty. In no event will the authors be held liable for any damages
10 arising from the use of this software.
12 Permission is granted to anyone to use this software for any purpose,
13 including commercial applications, and to alter it and redistribute it
14 freely, subject to the following restrictions:
16 1. The origin of this software must not be misrepresented; you must not
17 claim that you wrote the original software. If you use this software
18 in a product, an acknowledgment in the product documentation would be
19 appreciated but is not required.
20 2. Altered source versions must be plainly marked as such, and must not be
21 misrepresented as being the original software.
22 3. This notice may not be removed or altered from any source distribution.
25 #include "../../SDL_internal.h"
27 #if SDL_VIDEO_DRIVER_TIZEN && SDL_VIDEO_OPENGL_EGL
29 #include "../SDL_sysvideo.h"
30 #include "../../events/SDL_windowevents_c.h"
31 #include "../SDL_egl_c.h"
32 #include "SDL_tizenwindow.h"
33 #include "SDL_tizenvideo.h"
34 #include "SDL_tizentouch.h"
36 #include <wayland-egl.h>
39 Tizen_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info)
46 Tizen_SetWindowHitTest(SDL_Window *window, SDL_bool enabled)
49 return 0; /* just succeed, the real work is done elsewhere. */
53 Tizen_ShowWindow(_THIS, SDL_Window *window)
56 SDL_WindowData *wind = window->driverdata;
58 ecore_wl_window_show(wind->window);
62 Tizen_SetWindowFullscreen(_THIS, SDL_Window *window,
63 SDL_VideoDisplay *_display, SDL_bool fullscreen)
70 Tizen_CreateWindow(_THIS, SDL_Window *window)
73 SDL_VideoData *data = _this->driverdata;
76 wind = calloc(1, sizeof * wind);
78 return SDL_OutOfMemory();
80 window->driverdata = wind;
82 if (!(window->flags & SDL_WINDOW_OPENGL)) {
83 SDL_GL_LoadLibrary(NULL);
84 window->flags |= SDL_WINDOW_OPENGL;
87 if (window->x == SDL_WINDOWPOS_UNDEFINED) {
90 if (window->y == SDL_WINDOWPOS_UNDEFINED) {
94 wind->window = ecore_wl_window_new(NULL,
95 window->x, window->y, window->w, window->h,
96 ECORE_WL_WINDOW_BUFFER_TYPE_SHM);
97 ecore_wl_window_surface_create(wind->window);
99 wind->egl_window = wl_egl_window_create(ecore_wl_window_surface_get(wind->window), window->w, window->h);
101 /* Create the GLES window surface */
102 wind->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) wind->egl_window);
103 if (wind->egl_surface == EGL_NO_SURFACE) {
104 return SDL_SetError("failed to create a window surface");
107 wind->id = ecore_wl_window_id_get(wind->window);
108 eina_hash_add(data->windows, &wind->id, window);
114 Tizen_SetWindowSize(_THIS, SDL_Window *window)
117 SDL_WindowData *wind = window->driverdata;
119 wl_egl_window_resize(wind->egl_window, window->w, window->h, 0, 0);
123 Tizen_DestroyWindow(_THIS, SDL_Window *window)
126 SDL_VideoData *data = _this->driverdata;
127 SDL_WindowData *wind = window->driverdata;
130 eina_hash_del(data->windows, &wind->id, window);
132 SDL_EGL_DestroySurface(_this, wind->egl_surface);
133 wl_egl_window_destroy(wind->egl_window);
134 ecore_wl_window_free(wind->window);
139 window->driverdata = NULL;
143 __tizen_find_window(_THIS, Ecore_Wl_Window *ewin)
145 SDL_VideoData *data = _this->driverdata;
148 id = ecore_wl_window_id_get(ewin);
149 return (SDL_Window*)eina_hash_find(data->windows, &id);
153 __tizen_cb_window_visibility_change(void *data, int type, void *event)
156 Ecore_Wl_Event_Window_Visibility_Change *ev;
161 ew = ecore_wl_window_find(ev->win);
162 window = __tizen_find_window(_this, ew);
164 printf("SAMPLE EV : visibility window:%p, ecore_wl_window:%p\n", window, ew);
166 return ECORE_CALLBACK_PASS_ON;
170 Tizen_InitWindow(_THIS)
173 SDL_VideoData *data = _this->driverdata;
175 data->windows = eina_hash_int32_new(NULL);
177 ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_VISIBILITY_CHANGE,
178 __tizen_cb_window_visibility_change, _this);
184 Tizen_DeinitWindow(_THIS)
187 SDL_VideoData *data = _this->driverdata;
189 eina_hash_free(data->windows);
191 #endif /* SDL_VIDEO_DRIVER_TIZEN && SDL_VIDEO_OPENGL_EGL */
193 /* vi: set ts=4 sw=4 expandtab: */