Fix svace issue
[platform/upstream/SDL.git] / src / video / tizen / SDL_tizenwindow.c
1 /*
2   Simple DirectMedia Layer
3   Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
4   Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
5
6   This software is provided 'as-is', without any express or implied
7   warranty.  In no event will the authors be held liable for any damages
8   arising from the use of this software.
9
10   Permission is granted to anyone to use this software for any purpose,
11   including commercial applications, and to alter it and redistribute it
12   freely, subject to the following restrictions:
13
14   1. The origin of this software must not be misrepresented; you must not
15      claim that you wrote the original software. If you use this software
16      in a product, an acknowledgment in the product documentation would be
17      appreciated but is not required.
18   2. Altered source versions must be plainly marked as such, and must not be
19      misrepresented as being the original software.
20   3. This notice may not be removed or altered from any source distribution.
21 */
22
23 #include "../../SDL_internal.h"
24
25 #if SDL_VIDEO_DRIVER_TIZEN
26
27 #include "SDL_log.h"
28 #include "SDL_hints.h"
29 #include "SDL_loadso.h"
30
31 #include "SDL_tizenvideo.h"
32 #include "SDL_tizentouch.h"
33 #include "SDL_tizenkeyboard.h"
34 #include "SDL_tizenmouse.h"
35 #include "SDL_tizenevents_c.h"
36
37 #include "SDL_tizenwindow.h"
38 #include "SDL_tizenopengles.h"
39
40 #include "../../events/SDL_mouse_c.h"
41 #include "../../joystick/tizen/SDL_sysjoystick_c.h"
42
43 #include "../SDL_egl_c.h"
44 #include "../SDL_sysvideo.h"
45 #include "../../events/SDL_windowevents_c.h"
46
47 #include <Ecore_Ipc.h>
48 #include <Ecore_Wl2.h>
49 #include <unistd.h>
50 #include <string.h>
51
52 /*SDL indicator*/
53 Ecore_Ipc_Server *ipc = NULL;
54
55 #define IPC_HEAD(_type) \
56    Ecore_Ipc_Event_Client_##_type *e = event; \
57    if (ecore_ipc_client_server_get(e->client) != ipc) \
58      return ECORE_CALLBACK_PASS_ON
59
60 void _tizen_quickpanel_on(SDL_WindowData *wind)
61 {
62     SDL_Log("[SDL]Quick panel on");
63     ecore_wl2_window_indicator_state_set(wind->window, ECORE_WL2_INDICATOR_STATE_ON);
64     ecore_wl2_indicator_visible_type_set(wind->window, ECORE_WL2_INDICATOR_VISIBLE_TYPE_SHOWN);
65 }
66
67 void _tizen_quickpanel_off(SDL_WindowData *wind)
68 {
69     SDL_Log("[SDL]Quick panel off");
70     ecore_wl2_window_indicator_state_set(wind->window, ECORE_WL2_INDICATOR_STATE_OFF);
71     ecore_wl2_indicator_visible_type_set(wind->window, ECORE_WL2_INDICATOR_VISIBLE_TYPE_HIDDEN);
72 }
73
74 void Tizen_ExecuteIndicatorProcess(SDL_WindowData *wind)
75 {
76     SDL_VideoData* videoData = SDL_GetVideoDevice()->driverdata;
77     if(!videoData) return;
78
79     SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Tizen Indicator is not supported");
80 }
81
82 void
83 Tizen_TerminateIndicatorProcess(SDL_WindowData *wind)
84 {
85     if(!wind) return;
86
87     SDL_VideoData* videoData = SDL_GetVideoDevice()->driverdata;
88     if(videoData->indicator_on)
89     {
90         _tizen_ecore_ipc_client_send(OP_TERMINATE, 0, 0, 0);
91         _tizen_quickpanel_off(wind);
92     }
93 }
94
95 void
96 Tizen_chk_indicator(SDL_Window *window)
97 {
98     SDL_WindowData *wind = window->driverdata;
99     int screen_w, screen_h;
100     int rotation = wind->rotation % 360;
101     Ecore_Wl2_Display *wl2_display = ecore_wl2_connected_display_get(NULL);
102
103     if(rotation % 180 == 0)
104         ecore_wl2_display_screen_size_get(wl2_display, &screen_w, &screen_h);
105     else
106         ecore_wl2_display_screen_size_get(wl2_display, &screen_h, &screen_w);
107
108     if(window->w == screen_w && window->h == screen_h && window->x == 0 && window->y == 0 && !(window->flags & SDL_WINDOW_BORDERLESS))
109     {
110         SDL_VideoData* videoData = SDL_GetVideoDevice()->driverdata;
111         if(!videoData->indicator_on)
112         {
113             wind->support_indicator = SDL_TRUE;
114             Tizen_ExecuteIndicatorProcess(wind);
115         }
116     }
117     else
118     {
119         wind->support_indicator = SDL_FALSE;
120         Tizen_TerminateIndicatorProcess(wind);
121     }
122 }
123
124 void
125 _tizen_ecore_ipc_client_send(int major, int minor, int ref, int ref_to)
126 {
127     Eina_List *ipc_clients = ecore_ipc_server_clients_get(ipc);
128     Eina_List *l;
129     Ecore_Ipc_Client *cl;
130     EINA_LIST_FOREACH(ipc_clients, l, cl)
131     ecore_ipc_client_send(cl, major, minor, ref, ref_to, 0, NULL, 0);
132 }
133
134 static Eina_Bool
135 _cb_client_add(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
136 {
137     IPC_HEAD(Add);
138
139     SDL_Log("[SDL]_cb_client_add");
140
141     SDL_VideoData* videoData = SDL_GetVideoDevice()->driverdata;
142     videoData->indicator_on = SDL_TRUE;
143
144     SDL_Window * window = SDL_GetVideoDevice()->windows;
145     SDL_WindowData *wind = window->driverdata;
146
147     int window_w, window_h;
148     Ecore_Wl2_Display *wl2_display = ecore_wl2_connected_display_get(NULL);
149
150     ecore_wl2_display_screen_size_get(wl2_display, &window_w, &window_h);
151
152     _tizen_ecore_ipc_client_send(OP_INDICATOR_SHOW, wind->rotation, wind->g_res_id, videoData->indicator_mode);
153
154     return ECORE_CALLBACK_DONE;
155 }
156
157 static Eina_Bool
158 _cb_client_del(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
159 {
160     IPC_HEAD(Del);
161     SDL_Log("[SDL]_cb_client_del");
162     Eina_List *ipc_clients = ecore_ipc_server_clients_get(ipc);
163     Eina_List *l;
164     Ecore_Ipc_Client *cl;
165     EINA_LIST_FOREACH(ipc_clients, l, cl)
166     {
167         ecore_ipc_client_del(cl);
168     }
169
170     SDL_VideoData* videoData = SDL_GetVideoDevice()->driverdata;
171     videoData->indicator_on = SDL_FALSE;
172
173     return ECORE_CALLBACK_DONE;
174 }
175
176 static Eina_Bool
177 _cb_client_data(void *data, int type EINA_UNUSED, void *event)
178 {
179     IPC_HEAD(Data);
180
181     Ecore_Ipc_Event_Server_Data* epcEvent = (Ecore_Ipc_Event_Server_Data*)event;
182     SDL_Log("[SDL]_cb_client_data: %d -> %d", epcEvent->major, epcEvent->minor);
183
184     SDL_VideoData* videoData = SDL_GetVideoDevice()->driverdata;
185     SDL_Window * window = (SDL_Window*)eina_hash_find(videoData->windows, &videoData->indicator_parent_id);
186     if (!window)
187     {
188         SDL_Log("window is null");
189         return ECORE_CALLBACK_PASS_ON;
190     }
191
192     switch(epcEvent->major)
193     {
194     case OP_INDICATOR_INIT:
195         videoData->indicator_height = epcEvent->minor;
196         _tizen_quickpanel_on(window->driverdata);
197     break;
198     case OP_INDICATOR_SHOW:
199         videoData->indicator_visible = SDL_TRUE;
200     break;
201     case OP_INDICATOR_HIDE:
202         if(epcEvent->minor == 1)
203         {
204             _tizen_quickpanel_off(window->driverdata);
205         }
206         else if(epcEvent->minor == 2)
207         {
208             videoData->indicator_visible = SDL_FALSE;
209         }
210     break;
211     case OP_TERMINATE:
212         videoData->indicator_on = SDL_FALSE;
213         videoData->indicator_visible = SDL_FALSE;
214     break;
215     }
216
217     return ECORE_CALLBACK_DONE;
218 }
219
220 int
221 _tizen_init_ecore_ipc()
222 {
223
224     if(!ipc)
225     {
226         if(!ecore_ipc_init())
227             SDL_Log("[SDL]Fail ecore_ipc");
228
229         ipc = ecore_ipc_server_add(ECORE_IPC_LOCAL_USER, "sdl_indicator", 0, NULL);
230
231         if(!ipc)
232             ecore_ipc_shutdown();
233
234         ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_ADD, _cb_client_add, NULL);
235         ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DEL, _cb_client_del, NULL);
236         ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DATA, _cb_client_data, NULL);
237     }
238     return 0;
239 }
240
241 SDL_bool
242 Tizen_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info)
243 {
244     SDL_WindowData *wmdata = (SDL_WindowData *)window->driverdata;
245     info->info.tizen.egl_display = NULL;
246     info->info.tizen.egl_surface = NULL;
247 #if SDL_VIDEO_OPENGL_EGL
248     if (_this->egl_data)
249     {
250        info->info.tizen.egl_display = (void*)_this->egl_data->egl_display;
251     }
252     info->info.tizen.egl_surface = (void*)wmdata->egl_surface;
253 #endif
254     info->subsystem = SDL_SYSWM_TIZEN;
255     return SDL_TRUE;
256 }
257
258 int
259 Tizen_SetWindowHitTest(SDL_Window *window, SDL_bool enabled)
260 {
261     return 0;  /* just succeed, the real work is done elsewhere. */
262 }
263
264 void
265 Tizen_SetWindowTitle(_THIS, SDL_Window * window)
266 {
267     SDL_WindowData *wind = window->driverdata;
268     ecore_wl2_window_title_set(wind->window, window->title);
269 }
270
271 void
272 Tizen_ShowWindow(_THIS, SDL_Window *window)
273 {
274     SDL_WindowData *wind = window->driverdata;
275     ecore_wl2_window_show(wind->window);
276 }
277
278
279 void
280 Tizen_HideWindow(_THIS, SDL_Window *window)
281 {
282     SDL_WindowData *wind = window->driverdata;
283     ecore_wl2_window_hide(wind->window);
284 }
285
286 void
287 Tizen_RaiseWindow(_THIS, SDL_Window *window)
288 {
289     SDL_WindowData *wind = window->driverdata;
290     ecore_wl2_window_iconified_set(wind->window, SDL_FALSE);
291     ecore_wl2_window_raise(wind->window);
292 }
293
294 void
295 Tizen_SetWindowFullscreen(_THIS, SDL_Window *window,
296                           SDL_VideoDisplay *_display, SDL_bool fullscreen)
297 {
298     SDL_WindowData *wind = window->driverdata;
299     if(!wind) return;
300
301     int screen_w, screen_h;
302     int rotation = (wind->output_rotation + wind->rotation) % 360;
303     Ecore_Wl2_Display *wl2_display = ecore_wl2_connected_display_get(NULL);
304
305     if(rotation == 90 || rotation == 270)
306         ecore_wl2_display_screen_size_get(wl2_display, &screen_h, &screen_w);
307     else
308         ecore_wl2_display_screen_size_get(wl2_display, &screen_w, &screen_h);
309
310     _tizen_set_window_size(window, screen_w, screen_h);
311     Tizen_SetWindowSize(_this, window);
312
313     window->fullscreen_mode.w = screen_w;
314     window->fullscreen_mode.h = screen_h;
315 }
316
317 void
318 _tizen_set_window_size(SDL_Window * window, int w, int h)
319 {
320     if(!window)
321     {
322         SDL_SetError("Invalid window");
323         return;
324     }
325
326     SDL_VideoDevice *_this = SDL_GetVideoDevice();
327     if (!_this) {
328         SDL_SetError("Video subsystem has not been initialized");
329         return;
330     }
331
332     if (window->magic != &_this->window_magic) {
333         return;
334     }
335
336     if (w <= 0) {
337         SDL_InvalidParamError("w");
338         return;
339     }
340     if (h <= 0) {
341         SDL_InvalidParamError("h");
342         return;
343     }
344
345     /* Make sure we don't exceed any window size limits */
346     if (window->min_w && w < window->min_w)
347     {
348         w = window->min_w;
349     }
350     if (window->max_w && w > window->max_w)
351     {
352         w = window->max_w;
353     }
354     if (window->min_h && h < window->min_h)
355     {
356         h = window->min_h;
357     }
358     if (window->max_h && h > window->max_h)
359     {
360         h = window->max_h;
361     }
362
363     if(window->flags & SDL_WINDOW_FULLSCREEN)
364     {
365         window->fullscreen_mode.w = w;
366         window->fullscreen_mode.h = h;
367     }
368
369     window->windowed.w = w;
370     window->windowed.h = h;
371
372     window->w = w;
373     window->h = h;
374 }
375
376 void
377 _tizen_send_rotation_event(SDL_Window *window, unsigned int angle)
378 {
379     SDL_Event event;
380     SDL_WindowData *wind;
381     wind = window->driverdata;
382
383     SDL_memset(&event, 0, sizeof(event));
384     event.type = SDL_ROTATEEVENT;
385     event.user.code = 0;
386     if (wind->support_pre_rotation)
387         event.user.data1 = (void*)0;
388     else
389         event.user.data1 = (void*)angle;
390     event.user.data2 = (void*)-1;
391
392     SDL_PushEvent(&event);
393     return;
394 }
395
396 int
397 _tizen_get_rotation_idx(int rotation)
398 {
399     return ((rotation % 360) / 90);
400 }
401
402 void
403 _tizen_rotation_do(SDL_Window *window, SDL_WindowData* wind, int rotation)
404 {
405     int window_w, window_h;
406     if(wind->rotation == 0 || wind->rotation == 180)
407         ecore_wl2_window_geometry_get(wind->window, 0, 0, &window_w, &window_h);
408     else
409         ecore_wl2_window_geometry_get(wind->window, 0, 0, &window_h, &window_w);
410
411     _tizen_set_window_size(window, window_w, window_h);
412
413 #if SDL_VIDEO_OPENGL_EGL
414     if (window->flags & SDL_WINDOW_OPENGL)
415     {
416         if(wind->support_pre_rotation)
417         {
418             wl_egl_window_tizen_set_rotation(wind->egl_window, 360 - rotation);
419             wl_egl_window_tizen_set_buffer_transform(wind->egl_window, _tizen_get_rotation_idx(rotation));
420             wl_egl_window_tizen_set_window_transform(wind->egl_window, _tizen_get_rotation_idx(wind->rotation));
421         }
422         else
423         {
424             wl_egl_window_resize(wind->egl_window, window_w, window_h, 0, 0);
425             wl_egl_window_tizen_set_buffer_transform(wind->egl_window, _tizen_get_rotation_idx((360 - wind->rotation)));
426             wl_egl_window_tizen_set_window_transform(wind->egl_window, _tizen_get_rotation_idx(0));
427         }
428     }
429 #endif
430     _tizen_send_rotation_event(window, 0);
431     SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SIZE_CHANGED, window->w, window->h);
432
433 }
434
435 void
436 Tizen_rotate_update(SDL_Window *window)
437 {
438     SDL_WindowData *wind = window->driverdata;
439     if(!wind) return;
440
441     int screen_rotation;
442     if (ecore_wl2_window_ignore_output_transform_get(wind->window))
443     {
444         screen_rotation = 0;
445     }
446     else
447     {
448         Ecore_Wl2_Output *output = ecore_wl2_window_output_find(wind->window);
449         screen_rotation = ecore_wl2_output_transform_get(output) * 90;
450     }
451
452     //Set Screen Rotation
453     wind->output_rotation = screen_rotation;
454
455     ecore_wl2_window_rotation_set(wind->window, wind->rotation);
456
457     int rotation = (wind->output_rotation + wind->rotation) % 360;
458     _tizen_rotation_do(window, wind, rotation);
459 }
460
461 SDL_Window*
462 Tizen_FindWindow(_THIS, Ecore_Wl2_Window *ewin)
463 {
464     SDL_VideoData *data = _this->driverdata;
465     int id;
466
467     id = ecore_wl2_window_id_get(ewin);
468     return (SDL_Window*)eina_hash_find(data->windows, &id);
469 }
470
471 void
472 _tizen_window_orientaiton_hint_callback(void *userdata, const char *name, const char *oldValue, const char *newValue)
473 {
474     char *p_str = NULL;
475     char orientation_type[4][20] = {"Portrait","LandscapeLeft","PortraitUpsideDown","LandscapeRight"};
476     int checked[4] = {0,};
477     int i;
478     unsigned int j = 0;
479     SDL_WindowData *wind = (SDL_WindowData*)userdata;
480     Ecore_Wl2_Window *window = wind->window;
481
482     if (wind->rotation_supported == 0)
483         return;
484
485     SDL_assert(SDL_strncmp(name, SDL_HINT_ORIENTATIONS, SDL_strlen(SDL_HINT_ORIENTATIONS)) == 0);
486
487     if ((oldValue == NULL) && (newValue == NULL))
488         return;
489
490     for (i=0;i<4;i++) {
491         p_str = SDL_strstr(newValue, orientation_type[i]);
492         if (p_str) {
493             if (p_str == newValue) {
494                 int rot = 0;
495                 if (i == 0) rot = 0;
496                 else if (i == 1) rot = 90;
497                 else if (i == 2) rot = 180;
498                 else if (i == 3) rot = 270;
499                 wind->rotation = rot;
500             }
501
502             if (i == 0) {
503                 checked[j] = 0;
504             }
505             else if (i == 1) {
506                 checked[j] = 90;
507             }
508             else if (i == 2) {
509                 checked[j] = 180;
510             }
511             else if (i == 3) {
512                 checked[j] = 270;
513             }
514             j++;
515         }
516     }
517
518     if (j > 0) {
519         if (j == 1) {
520             ecore_wl2_window_preferred_rotation_set(window, wind->rotation);
521         }else {
522             ecore_wl2_window_available_rotations_set(window, (const int*)checked, j);
523         }
524     }
525
526     SDL_Window *sdl_window = Tizen_FindWindow(SDL_GetVideoDevice(), window);
527     if (!sdl_window)
528     {
529         SDL_Log("Rotate error: sdl_window is null");
530         return;
531     }
532
533     Tizen_rotate_update(sdl_window);
534 }
535
536 void
537 _tizen_window_orientation_add_hint(void *data)
538 {
539     SDL_WindowData *wind = (SDL_WindowData*)data;
540     if (wind->rotation_supported == 0)
541         return;
542
543     SDL_AddHintCallback(SDL_HINT_ORIENTATIONS, _tizen_window_orientaiton_hint_callback, data);
544 }
545
546 static Eina_Bool
547 _tizen_cb_output_transform(void *data, int type EINA_UNUSED, void *event)
548 {
549     SDL_Window * window = SDL_GetVideoDevice()->windows;
550     SDL_WindowData *wind = window->driverdata;
551
552     if(!wind) return ECORE_CALLBACK_PASS_ON;
553
554     Ecore_Wl2_Event_Output_Transform *ev = event;
555     Ecore_Wl2_Output *output;
556
557     output = ecore_wl2_window_output_find(wind->window);
558     if (output != ev->output) return ECORE_CALLBACK_PASS_ON;
559
560     wind->received_rotation = TIZEN_ROTATION_RECEIVED_SCREEN_ROTATION;
561
562
563    return ECORE_CALLBACK_PASS_ON;
564 }
565
566 static Eina_Bool
567 _tizen_cb_ignore_output_transform(void *data, int type EINA_UNUSED, void *event EINA_UNUSED)
568 {
569     SDL_Window * window = SDL_GetVideoDevice()->windows;
570     SDL_WindowData *wind = window->driverdata;
571
572     if(!wind) return ECORE_CALLBACK_PASS_ON;
573
574     wind->received_rotation = TIZEN_ROTATION_RECEIVED_SCREEN_ROTATION;
575
576    return ECORE_CALLBACK_PASS_ON;
577 }
578
579 void
580 _tizen_output_transform_register(SDL_WindowData *wind)
581 {
582     if(!wind) return;
583
584     Ecore_Wl2_Output *output = ecore_wl2_window_output_find(wind->window);
585     wind->output_rotation = ecore_wl2_output_transform_get(output) * 90;
586
587     ecore_event_handler_add(ECORE_WL2_EVENT_OUTPUT_TRANSFORM,
588                              _tizen_cb_output_transform, NULL);
589     ecore_event_handler_add(ECORE_WL2_EVENT_IGNORE_OUTPUT_TRANSFORM,
590                              _tizen_cb_ignore_output_transform, NULL);
591 }
592
593 void
594 _tizen_indicator_opacity_hint_callback(void *userdata, const char *name, const char *oldValue, const char *newValue)
595 {
596     SDL_VideoData *data = (SDL_VideoData *)userdata;
597
598     if ((oldValue == NULL) && (newValue == NULL))
599         return;
600
601     SDL_assert(SDL_strncmp(name, SDL_HINT_TIZEN_INDICATOR_OPACITY, SDL_strlen(SDL_HINT_TIZEN_INDICATOR_OPACITY)) == 0);
602     char indicator_type[4][20] = {"opaque","translucent","transparent","bg_transparent"};
603     for (int i=0;i<4;i++) {
604         if(SDL_strncmp(newValue, indicator_type[i], SDL_strlen(indicator_type[i])) == 0)
605         {
606             data->indicator_mode = i+1;
607             break;
608         }
609     }
610 }
611
612 unsigned int
613 SDL_Tizen_GetSupportedAuxiliaryHintCount(SDL_Window *window)
614 {
615     SDL_WindowData *wind = NULL;
616     Ecore_Wl2_Window *ecore_window = NULL;
617     Eina_List* hints = NULL;
618
619     if (!window || !window->driverdata) {
620         return 0;
621     }
622
623     wind = (SDL_WindowData *) window->driverdata;
624     ecore_window = wind->window;
625     if (!ecore_window) {
626         SDL_Log("AddAuxiliaryHint: ecore_window is null");
627         return 0;
628     }
629
630     hints = ecore_wl2_window_aux_hints_supported_get(ecore_window);
631     int count = 0;
632     if (hints) {
633         Eina_List* l = NULL;
634         for (l = hints; l; l = eina_list_next(l)) {
635             count++;
636         }
637     }
638     return count;
639 }
640
641 const char*
642 SDL_Tizen_GetSupportedAuxiliaryHint(SDL_Window *window, unsigned int index)
643 {
644     SDL_WindowData *wind = NULL;
645     Ecore_Wl2_Window *ecore_window = NULL;
646     Eina_List* hints = NULL;
647
648     if (!window || !window->driverdata) {
649         return NULL;
650     }
651
652     wind = (SDL_WindowData *) window->driverdata;
653     ecore_window = wind->window;
654     if (!ecore_window) {
655         SDL_Log("AddAuxiliaryHint: ecore_window is null");
656         return NULL;
657     }
658
659     hints = ecore_wl2_window_aux_hints_supported_get(ecore_window);
660
661     if (hints) {
662         Eina_List* l = NULL;
663         char* supported_hint = NULL;
664         int i = 0;
665         for (l = hints, (supported_hint = (char*)(eina_list_data_get(l))); l; l = eina_list_next(l), (supported_hint = (char*)(eina_list_data_get(l)))) {
666             if (i == index) {
667                 return supported_hint;
668             }
669             i++;
670         }
671     }
672     return NULL;
673 }
674
675 Ecore_Wl2_Window*
676 SDL_Tizen_GetNativeWindow(SDL_Window *window)
677 {
678     SDL_WindowData *wind = NULL;
679     Ecore_Wl2_Window *ecore_window = NULL;
680
681     if (!window || !window->driverdata) {
682         return NULL;
683     }
684
685     wind = (SDL_WindowData *) window->driverdata;
686     if (wind->window) {
687         ecore_window = wind->window;
688     }
689
690     return ecore_window;
691 }
692
693 unsigned int
694 SDL_Tizen_AddAuxiliaryHint(SDL_Window *window, const char *hint, const char *value)
695 {
696     SDL_WindowData *wind = NULL;
697     Ecore_Wl2_Window *ecore_window = NULL;
698     Eina_List* hints = NULL;
699     SDL_bool supported = SDL_FALSE;
700
701     if (!window || !window->driverdata) {
702         return 0;
703     }
704
705     wind = (SDL_WindowData *) window->driverdata;
706     ecore_window = wind->window;
707     if (!ecore_window) {
708         SDL_Log("AddAuxiliaryHint: ecore_window is null");
709         return 0;
710     }
711
712     hints = ecore_wl2_window_aux_hints_supported_get(ecore_window);
713     if (hints) {
714         Eina_List* l = NULL;
715         char* supported_hint = NULL;
716         for (l = hints, (supported_hint = (char*)(eina_list_data_get(l))); l; l = eina_list_next(l),
717             (supported_hint = (char*)(eina_list_data_get(l)))) {
718             if (!SDL_strncmp(supported_hint, hint, strlen(hint))) {
719                  supported = SDL_TRUE;
720                  break;
721             }
722
723         }
724     }
725
726     if (!supported) {
727         SDL_Log("AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint);
728         return 0;
729     }
730
731     unsigned int new_id = 1;
732     if ((wind->auxiliaryHints).auxHintHeader) {
733         AuxiliaryHint* auxiliaryHint = (wind->auxiliaryHints).auxHintHeader;
734         AuxiliaryHint* nextAuxiliaryHint = auxiliaryHint->next;
735         while (auxiliaryHint) {
736             if (!SDL_strncmp(auxiliaryHint->hint, hint, strlen(hint))) {
737                 auxiliaryHint->value = value;
738                 SDL_Log("AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", auxiliaryHint->hint, auxiliaryHint->value, auxiliaryHint->id);
739                 return auxiliaryHint->id;
740             }
741             auxiliaryHint = nextAuxiliaryHint;
742             nextAuxiliaryHint = NULL;
743             if(auxiliaryHint) {
744                 nextAuxiliaryHint = auxiliaryHint->next;
745             }
746             new_id++;
747         }
748     }
749
750     // Add the hint
751     AuxiliaryHint* newAuxiliaryHint = (AuxiliaryHint *)SDL_calloc(1, sizeof(AuxiliaryHint));
752     if (!newAuxiliaryHint) {
753         SDL_Log("AddAuxiliaryHint: Fail calloc");
754         return 0;
755     }
756
757     newAuxiliaryHint->id = new_id;
758     newAuxiliaryHint->hint = hint;
759     newAuxiliaryHint->value = value;
760     newAuxiliaryHint->next = NULL;
761     if (new_id != 1) {
762         newAuxiliaryHint->next = (wind->auxiliaryHints).auxHintHeader;
763     }
764
765     (wind->auxiliaryHints).auxHintHeader = newAuxiliaryHint;
766     (wind->auxiliaryHints).size++;
767     ecore_wl2_window_aux_hint_add(ecore_window, (int)new_id, hint, value);
768     SDL_Log("AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint, value, new_id);
769
770     return new_id;
771 }
772
773 SDL_bool
774 SDL_Tizen_RemoveAuxiliaryHint(SDL_Window *window, unsigned int id)
775 {
776     SDL_WindowData *wind = NULL;
777     Ecore_Wl2_Window *ecore_window = NULL;
778
779     if (!window || !window->driverdata) {
780         return SDL_FALSE;
781     }
782
783     wind = (SDL_WindowData *) window->driverdata;
784     ecore_window = wind->window;
785
786     if (!ecore_window) {
787         SDL_Log("RemoveAuxiliaryHint: ecore_window is null");
788         return SDL_FALSE;
789     }
790
791     if (id == 0) {
792       SDL_Log( "RemoveAuxiliaryHint: Invalid id [%d]\n", id );
793       return SDL_FALSE;
794     }
795
796     if ((wind->auxiliaryHints).auxHintHeader) {
797         AuxiliaryHint* auxiliaryHint = (wind->auxiliaryHints).auxHintHeader;
798         AuxiliaryHint* prevAuxiliaryHint = NULL;
799         AuxiliaryHint* nextAuxiliaryHint = auxiliaryHint->next;
800         while (auxiliaryHint) {
801             if (auxiliaryHint->id == id) {
802                 SDL_Log("RemoveAuxiliaryHint: id = %d, hint = %s\n", id, auxiliaryHint->hint);
803                 ecore_wl2_window_aux_hint_del(ecore_window, (int)id);
804                 if (auxiliaryHint == (wind->auxiliaryHints).auxHintHeader) {
805                     (wind->auxiliaryHints).auxHintHeader = auxiliaryHint->next;
806                 } else {
807                     prevAuxiliaryHint->next = nextAuxiliaryHint;
808                 }
809                 SDL_free(auxiliaryHint);
810                 (wind->auxiliaryHints).size--;
811                 return SDL_TRUE;
812             }
813             prevAuxiliaryHint = auxiliaryHint;
814             auxiliaryHint = nextAuxiliaryHint;
815             nextAuxiliaryHint = NULL;
816             if(auxiliaryHint) {
817                 nextAuxiliaryHint = auxiliaryHint->next;
818             }
819         }
820     }
821     return SDL_FALSE;
822 }
823
824 SDL_bool
825 SDL_Tizen_SetAuxiliaryHint(SDL_Window *window, unsigned int id, const char *value)
826 {
827     SDL_WindowData *wind = NULL;
828     Ecore_Wl2_Window *ecore_window = NULL;
829
830     if (!window || !window->driverdata) {
831         return SDL_FALSE;
832     }
833
834     wind = (SDL_WindowData *) window->driverdata;
835     ecore_window = wind->window;
836
837     if (!ecore_window) {
838         return SDL_FALSE;
839     }
840
841     if (id == 0) {
842       SDL_Log( "RemoveAuxiliaryHint: Invalid id [%d]\n", id );
843       return SDL_FALSE;
844     }
845
846     if ((wind->auxiliaryHints).auxHintHeader) {
847         AuxiliaryHint* auxiliaryHint = (wind->auxiliaryHints).auxHintHeader;
848         AuxiliaryHint* nextAuxiliaryHint = auxiliaryHint->next;
849         while (auxiliaryHint) {
850             if (auxiliaryHint->id == id) {
851                 ecore_wl2_window_aux_hint_change(ecore_window, (int)id, value);
852                 auxiliaryHint->value = value;
853                 SDL_Log("SetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, auxiliaryHint->hint, auxiliaryHint->value);
854                 return SDL_TRUE;
855             }
856             auxiliaryHint = nextAuxiliaryHint;
857             nextAuxiliaryHint = NULL;
858             if(auxiliaryHint) {
859                 nextAuxiliaryHint = auxiliaryHint->next;
860             }
861         }
862     }
863     return SDL_FALSE;
864 }
865
866 const char*
867 SDL_Tizen_GetAuxiliaryHintValue(SDL_Window *window, unsigned int id)
868 {
869     SDL_WindowData *wind = NULL;
870     if (!window || !window->driverdata) {
871         return NULL;
872     }
873
874     wind = (SDL_WindowData *) window->driverdata;
875     if (id == 0) {
876       SDL_Log( "GetAuxiliaryHintValue: Invalid id [%d]\n", id );
877       return NULL;
878     }
879
880     if ((wind->auxiliaryHints).auxHintHeader) {
881         AuxiliaryHint* auxiliaryHint = (wind->auxiliaryHints).auxHintHeader;
882         while (auxiliaryHint) {
883             if (auxiliaryHint->id == id) {
884                 SDL_Log("GetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, auxiliaryHint->hint, auxiliaryHint->value);
885                 return auxiliaryHint->value;
886             }
887             auxiliaryHint = auxiliaryHint->next;
888         }
889     }
890     return NULL;
891 }
892
893 unsigned int
894 SDL_Tizen_GetAuxiliaryHintId(SDL_Window *window, const char *hint)
895 {
896     SDL_WindowData *wind = NULL;
897     if (!window || !window->driverdata) {
898         return 0;
899     }
900
901     wind = (SDL_WindowData *) window->driverdata;
902
903     if (hint == NULL || (wind->auxiliaryHints).size <= 0) {
904       SDL_Log( "GetAuxiliaryHintId: auxiliaryHints size is 0]\n");
905       return 0;
906     }
907
908     if ((wind->auxiliaryHints).auxHintHeader) {
909         AuxiliaryHint* auxiliaryHint = (wind->auxiliaryHints).auxHintHeader;
910         for (unsigned int i = 0; i < (wind->auxiliaryHints).size; i++) {
911             if (auxiliaryHint->hint == hint) {
912                 SDL_Log("GetAuxiliaryHintId: hint = %s, id = %d\n", hint, auxiliaryHint->id);
913                 return auxiliaryHint->id;
914             }
915             auxiliaryHint = auxiliaryHint->next;
916         }
917     }
918     SDL_Log("GetAuxiliaryHintId: Invalid hint! [%s]\n", hint);
919
920     return 0;
921 }
922
923 SDL_bool
924 SDL_Tizen_GetWindowAcceptFocus(SDL_Window * window)
925 {
926     SDL_WindowData *data = NULL;
927
928     if (!window || !window->driverdata) {
929         return SDL_FALSE;
930     }
931
932     data = (SDL_WindowData *) window->driverdata;
933     if (!data->window) {
934         return SDL_FALSE;
935     }
936
937     return !ecore_wl2_window_focus_skip_get(data->window);
938 }
939
940 SDL_bool
941 SDL_Tizen_SetWindowAcceptFocus(SDL_Window * window, SDL_bool accept)
942 {
943     SDL_WindowData *data = NULL;
944
945     if (!window || !window->driverdata) {
946         return SDL_FALSE;
947     }
948
949     data = (SDL_WindowData *) window->driverdata;
950     if (!data->window) {
951         return SDL_FALSE;
952     }
953
954     ecore_wl2_window_focus_skip_set(data->window, !accept);
955     return SDL_TRUE;
956 }
957
958 int
959 Tizen_CreateWindow(_THIS, SDL_Window *window)
960 {
961     SDL_VideoData *data = _this->driverdata;
962     SDL_WindowData *wind;
963     Ecore_Wl2_Global *global;
964     Eina_Iterator *globals;
965     Ecore_Wl2_Display *wl2_display = ecore_wl2_connected_display_get(NULL);
966     Ecore_Wl2_Window *parent_wl2_window = NULL;
967
968     wind = calloc(1, sizeof * wind);
969     if (!wind) {
970         return SDL_OutOfMemory();
971     }
972     (wind->auxiliaryHints).size = 0;
973     (wind->auxiliaryHints).auxHintHeader = NULL;
974     window->driverdata = wind;
975     window->flags |= SDL_WINDOW_INPUT_FOCUS;    /* always has input focus */
976
977 #if SDL_VIDEO_OPENGL_EGL
978     if (window->flags & SDL_WINDOW_OPENGL) {
979         SDL_GL_LoadLibrary(NULL);
980     }
981 #endif
982
983 #if SDL_VIDEO_VULKAN
984     if (window->flags & SDL_WINDOW_VULKAN) {
985         if (!_this->Vulkan_GetInstanceExtensions) {
986             SDL_SetError("No Vulkan support in video driver");
987         }
988
989         if (_this->Vulkan_LoadLibrary(_this, NULL) < 0) {
990             SDL_SetError("Fail to load Vulkan Library");
991         }
992     }
993 #endif
994
995     if (window->x == SDL_WINDOWPOS_UNDEFINED) {
996         window->x = 0;
997     }
998     if (window->y == SDL_WINDOWPOS_UNDEFINED) {
999         window->y = 0;
1000     }
1001
1002     if (!(globals = ecore_wl2_display_globals_get(wl2_display)))
1003       {
1004          SDL_LogError(SDL_LOG_CATEGORY_ASSERT, "Failed to get wayland globals");
1005          return -1;
1006       }
1007
1008     if(window->next)
1009     {
1010         parent_wl2_window = ((SDL_WindowData *)(window->next->driverdata))->window;
1011     }
1012     wind->window = ecore_wl2_window_new(wl2_display, parent_wl2_window,
1013                                        window->x, window->y, window->w, window->h);
1014     if (!wind->window) {
1015         SDL_LogError(SDL_LOG_CATEGORY_ASSERT, "Failed to create wayland window");
1016         if(globals) {
1017             eina_iterator_free(globals);
1018         }
1019         return -1;
1020     }
1021     ecore_wl2_window_position_set(wind->window, window->x, window->y);
1022     _tizen_output_transform_register(wind);
1023 #if 0
1024     wind->wl2_surface = ecore_wl2_surface_create(wind->window, EINA_FALSE);
1025     if (!wind->wl2_surface) {
1026         SDL_LogError(SDL_LOG_CATEGORY_ASSERT, "Failed to create wayland window surface");
1027         return -1;
1028     }
1029 #endif
1030     wind->surface = ecore_wl2_window_surface_get(wind->window);
1031     if (!wind->surface) {
1032         SDL_LogError(SDL_LOG_CATEGORY_ASSERT, "Failed to create wayland window surface");
1033         if(globals) {
1034             eina_iterator_free(globals);
1035         }
1036         return -1;
1037     }
1038
1039     ecore_wl2_window_type_set(wind->window, ECORE_WL2_WINDOW_TYPE_UTILITY);
1040
1041     wind->rotation = 0;
1042     wind->rotation_supported = 0;
1043     wind->received_rotation = TIZEN_ROTATION_RECEIVED_NONE;
1044
1045 #if SDL_VIDEO_OPENGL_EGL
1046     if (window->flags & SDL_WINDOW_OPENGL) {
1047
1048         if(wind->output_rotation == 90 || wind->output_rotation == 270)
1049             wind->egl_window = wl_egl_window_create(wind->surface, window->h, window->w);
1050         else
1051             wind->egl_window = wl_egl_window_create(wind->surface, window->w, window->h);
1052
1053         /* Create the GLES window surface */
1054         wind->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) wind->egl_window);
1055         if (wind->egl_surface == EGL_NO_SURFACE) {
1056             SDL_LogError(SDL_LOG_CATEGORY_ASSERT, "failed to create a window surface");
1057             if(globals) {
1058                 eina_iterator_free(globals);
1059             }
1060             return -1;
1061         }
1062
1063         if (!_this->gl_config.alpha_size) {
1064             ecore_wl2_window_opaque_region_set(wind->window, window->x, window->y, window->w, window->h);
1065         }
1066         else {
1067             wl_surface_set_opaque_region(wind->surface, NULL);
1068         }
1069
1070         //Support PreRotation
1071         wind->support_pre_rotation = 0;
1072         if (wl_egl_window_tizen_get_capabilities(wind->egl_window) == WL_EGL_WINDOW_TIZEN_CAPABILITY_ROTATION_SUPPORTED ) {
1073             wind->support_pre_rotation = 1;
1074         }
1075         else
1076         {
1077             wl_egl_window_resize(wind->egl_window, window->w, window->h, 0, 0);
1078         }
1079
1080
1081     }
1082 #endif
1083
1084     wind->id = ecore_wl2_window_id_get(wind->window);
1085     eina_hash_add(data->windows, &wind->id, window);
1086
1087     Tizen_InitKeyboard(_this);
1088     SDL_SetMouseFocus(window);
1089
1090     EINA_ITERATOR_FOREACH(globals, global) {
1091          if (!strcmp(global->interface, "tizen_policy_ext")) {
1092               wind->rotation_supported = 1;
1093               break;
1094            }
1095       }
1096     eina_iterator_free(globals);
1097     // Add orientaiton hint cb
1098     _tizen_window_orientation_add_hint((void*)wind);
1099     SDL_AddHintCallback(SDL_HINT_TIZEN_INDICATOR_OPACITY, _tizen_indicator_opacity_hint_callback, data);
1100
1101     Tizen_rotate_update(window);
1102
1103     return 0;
1104 }
1105
1106 void
1107 Tizen_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
1108 {
1109     if(!bordered)
1110     {
1111         SDL_WindowData *wind = window->driverdata;
1112         wind->support_indicator = SDL_FALSE;
1113         Tizen_TerminateIndicatorProcess(window->driverdata);
1114     }
1115 }
1116
1117 void
1118 Tizen_SetWindowSize(_THIS, SDL_Window *window)
1119 {
1120     SDL_WindowData *wind = window->driverdata;
1121     if (!wind->egl_window)
1122         return;
1123
1124 // TODO : consider to rotation status.
1125 #if SDL_VIDEO_OPENGL_EGL
1126     if (window->flags & SDL_WINDOW_OPENGL)
1127     {
1128         int rotation = (wind->output_rotation + wind->rotation) % 360;
1129         if(rotation == 90 || rotation == 270)
1130         {
1131             ecore_wl2_window_geometry_set(wind->window, window->y, window->x, window->h, window->w);
1132             wl_egl_window_resize(wind->egl_window, window->h, window->w, 0, 0);
1133         }
1134         else
1135         {
1136             ecore_wl2_window_geometry_set(wind->window, window->x, window->y, window->w, window->h);
1137             wl_egl_window_resize(wind->egl_window, window->w, window->h, 0, 0);
1138         }
1139     }
1140     SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SIZE_CHANGED, window->w, window->h);
1141 #endif
1142 }
1143
1144 void
1145 Tizen_GetWindowSize(_THIS, SDL_Window *window, int *w, int *h)
1146 {
1147     SDL_WindowData *wind = window->driverdata;
1148     if (!wind->window) {
1149         return;
1150     }
1151
1152     if (w) *w = window->w;
1153     if (h) *h = window->h;
1154 }
1155
1156 void
1157 Tizen_SetWindowPosition(_THIS, SDL_Window * window)
1158 {
1159     SDL_WindowData *wind = window->driverdata;
1160     if (!wind->window) {
1161         return;
1162     }
1163
1164     // TODO : consider to rotation status.
1165     ecore_wl2_window_position_set(wind->window, window->x, window->y);
1166 }
1167
1168 void
1169 Tizen_DestroyWindow(_THIS, SDL_Window *window)
1170 {
1171     SDL_VideoData *data = _this->driverdata;
1172     SDL_WindowData *wind = window->driverdata;
1173
1174     if (data) {
1175         AuxiliaryHint* auxiliaryHint = (wind->auxiliaryHints).auxHintHeader;
1176         if (auxiliaryHint) {
1177             AuxiliaryHint* nextAuxiliaryHints = auxiliaryHint->next;
1178             while (auxiliaryHint) {
1179                 SDL_free(auxiliaryHint);
1180                 auxiliaryHint = nextAuxiliaryHints;
1181                 nextAuxiliaryHints = NULL;
1182                 if (auxiliaryHint) {
1183                     nextAuxiliaryHints = auxiliaryHint->next;
1184                 }
1185             }
1186         }
1187         eina_hash_del(data->windows, &wind->id, window);
1188 #if SDL_VIDEO_OPENGL_EGL
1189     if (window->flags & SDL_WINDOW_OPENGL) {
1190         SDL_EGL_DestroySurface(_this, wind->egl_surface);
1191         wl_egl_window_destroy(wind->egl_window);
1192     }
1193 #endif
1194         ecore_wl2_window_free(wind->window);
1195         SDL_free(wind);
1196     }
1197
1198     window->driverdata = NULL;
1199 }
1200
1201 int
1202 Tizen_SetWindowOpacity(_THIS, SDL_Window * window, float opacity)
1203 {
1204     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
1205     if (opacity < 1.0f) {
1206         ecore_wl2_window_alpha_set(data->window, true);
1207     } else {
1208         ecore_wl2_window_alpha_set(data->window, false);
1209     }
1210     return 0;
1211 }
1212
1213 Eina_Bool
1214 _tizen_cb_event_window_visibility_change(void *data, int type, void *event)
1215 {
1216     _THIS = data;
1217     Ecore_Wl2_Event_Window_Visibility_Change *ev;
1218     Ecore_Wl2_Window *ew;
1219     SDL_Window *window;
1220
1221     Ecore_Wl2_Display *wl2_display = ecore_wl2_connected_display_get(NULL);
1222
1223
1224     ev = event;
1225     ew = ecore_wl2_display_window_find(wl2_display, ev->win);
1226     window = Tizen_FindWindow(_this, ew);
1227     if (!window) {
1228         return ECORE_CALLBACK_PASS_ON;
1229     }
1230
1231     SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SHOWN, 0, 0);
1232     SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESTORED, 0, 0);
1233     return ECORE_CALLBACK_PASS_ON;
1234 }
1235
1236 Eina_Bool
1237 _tizen_cb_window_configure(void *data, int type EINA_UNUSED, void *event)
1238 {
1239    _THIS = data;
1240    Ecore_Wl2_Window *ew;
1241    SDL_Window *window;
1242    SDL_WindowData *wind;
1243    Ecore_Wl2_Event_Window_Configure *ev;
1244
1245    Ecore_Wl2_Display *wl2_display = ecore_wl2_connected_display_get(NULL);
1246
1247    ev = event;
1248    ew = ecore_wl2_display_window_find(wl2_display, ev->win);
1249    window = Tizen_FindWindow(_this, ew);
1250    if (!window) {
1251        return ECORE_CALLBACK_PASS_ON;
1252    }
1253
1254    wind = window->driverdata;
1255    if (!wind) {
1256        return ECORE_CALLBACK_PASS_ON;
1257    }
1258
1259    if (wind->rotation_supported == 0){
1260       return ECORE_CALLBACK_PASS_ON;
1261    }
1262
1263    return ECORE_CALLBACK_PASS_ON;
1264 }
1265
1266 Eina_Bool
1267 _tizen_cb_event_window_rotate(void *data, int type EINA_UNUSED, void *event)
1268 {
1269     _THIS = data;
1270     Ecore_Wl2_Event_Window_Rotation *ev;
1271     Ecore_Wl2_Window *ew;
1272     SDL_Window *window;
1273     SDL_WindowData *wind;
1274
1275     Ecore_Wl2_Display *wl2_display = ecore_wl2_connected_display_get(NULL);
1276
1277     ev = event;
1278     if (!ev) {
1279         return ECORE_CALLBACK_PASS_ON;
1280     }
1281
1282     ew = ecore_wl2_display_window_find(wl2_display, ev->win);
1283     window = Tizen_FindWindow(_this, ew);
1284     if (!window) {
1285         return ECORE_CALLBACK_PASS_ON;
1286     }
1287
1288     wind = window->driverdata;
1289     if (!wind) {
1290         return ECORE_CALLBACK_PASS_ON;
1291     }
1292
1293     /* set ecore_wl2 window rotation */
1294     wind->rotation = ev->angle;
1295     wind->received_rotation = TIZEN_ROTATION_RECEIVED_WINDOW_ROATION;
1296
1297     return ECORE_CALLBACK_PASS_ON;
1298 }
1299
1300 static Eina_Bool _tizen_cb_event_window_show(void *data, int type, void *event)
1301 {
1302     Ecore_Wl2_Event_Window_Show *e;
1303     uint32_t g_res_id = 0;
1304
1305     e = event;
1306     if (e->data[0] > 0)
1307         g_res_id = e->data[0];
1308
1309     if(g_res_id!=0)
1310     {
1311         SDL_VideoData *this = SDL_GetVideoDevice()->driverdata;
1312         SDL_Window * window = (SDL_Window*)eina_hash_find(this->windows, &e->win);
1313         if (!window)
1314         {
1315             SDL_Log("window is null");
1316             return ECORE_CALLBACK_PASS_ON;
1317         }
1318         SDL_WindowData *wind = window->driverdata;
1319         if (!wind)
1320         {
1321             SDL_Log("window->driverdata is null");
1322             return ECORE_CALLBACK_PASS_ON;
1323         }
1324         wind->g_res_id = g_res_id;
1325         SDL_Log("[SDL] SDL Window Resource ID %d", g_res_id);
1326     }
1327
1328     return ECORE_CALLBACK_PASS_ON;
1329 }
1330
1331 int
1332 Tizen_InitWindow(_THIS)
1333 {
1334     SDL_VideoData *data = _this->driverdata;
1335
1336     data->windows = eina_hash_int32_new(NULL);
1337
1338     ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_VISIBILITY_CHANGE,
1339                         _tizen_cb_event_window_visibility_change,_this);
1340     ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ROTATE,
1341                         _tizen_cb_event_window_rotate,_this);
1342     ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE,
1343                         _tizen_cb_window_configure,_this);
1344     ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_SHOW,
1345                         _tizen_cb_event_window_show, _this);
1346
1347     ecore_event_handler_add(ECORE_EVENT_KEY_UP,
1348                         _tizen_cb_event_keyup_change,_this);
1349     ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
1350                         _tizen_cb_event_keydown_change,_this);
1351
1352     ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN,
1353                         _tizen_cb_event_mousedown_change,_this);
1354     ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP,
1355                         _tizen_cb_event_mouseup_change,_this);
1356     ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE,
1357                         _tizen_cb_event_mousemove_change,_this);
1358     ecore_event_handler_add(ECORE_EVENT_MOUSE_IN,
1359                         _tizen_cb_event_mouse_in,_this);
1360     ecore_event_handler_add(ECORE_EVENT_MOUSE_OUT,
1361                         _tizen_cb_event_mouse_out,_this);
1362
1363     ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_IN,
1364                         _tizen_cb_event_focus_in,_this);
1365     ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_OUT,
1366                         _tizen_cb_event_focus_out,_this);
1367
1368     ecore_event_handler_add(ECORE_EVENT_JOYSTICK,
1369                         _tizen_cb_event_joystick_change,_this);
1370
1371     return 0;
1372 }
1373
1374 void
1375 Tizen_DeinitWindow(_THIS)
1376 {
1377     SDL_VideoData *data = _this->driverdata;
1378
1379     eina_hash_free(data->windows);
1380 }
1381 #endif /* SDL_VIDEO_DRIVER_TIZEN */
1382
1383 /* vi: set ts=4 sw=4 expandtab: */