[SDL_tizen] implement multiple window feature. 03/96603/3
authorDaeKwang Ryu <dkdk.ryu@samsung.com>
Fri, 28 Oct 2016 01:33:24 +0000 (10:33 +0900)
committerDaeKwang Ryu <dkdk.ryu@samsung.com>
Thu, 17 Nov 2016 06:03:09 +0000 (15:03 +0900)
Multiple window feature is one of SDL2 main features.

Change-Id: I76dcc05ca9754d46d7e39e3c18cac85fcccf247b

src/video/tizen/SDL_tizenevents.c
src/video/tizen/SDL_tizenevents_c.h
src/video/tizen/SDL_tizenkeyboard.c
src/video/tizen/SDL_tizenmouse.c
src/video/tizen/SDL_tizenmouse.h
src/video/tizen/SDL_tizenwindow.c
src/video/tizen/SDL_tizenwindow.h

index 9ae0dc3..9b84368 100755 (executable)
@@ -85,7 +85,28 @@ _tizen_cb_event_keydown_change(void *data, int type, void *event)
     return ECORE_CALLBACK_PASS_ON;
 }
 
+Eina_Bool
+_tizen_cb_event_focus_in(void *data, int type EINA_UNUSED, void *event)
+{
+    SDL_VideoDevice *_this = SDL_GetVideoDevice();
+    Ecore_Wl_Event_Focus_In *ev;
+    Ecore_Wl_Window *ew;
+    SDL_Window *window;
+
+    ev = event;
+    ew = ecore_wl_window_find(ev->win);
+    window = Tizen_FindWindow(_this, ew);
+
+    SDL_SetKeyboardFocus(window);
+    return ECORE_CALLBACK_PASS_ON;
+}
 
+Eina_Bool
+_tizen_cb_event_focus_out(void *data, int type EINA_UNUSED, void *event)
+{
+    SDL_SetKeyboardFocus(NULL);
+    return ECORE_CALLBACK_PASS_ON;
+}
 #endif /* SDL_VIDEO_DRIVER_TIZEN */
 
 /* vi: set ts=4 sw=4 expandtab: */
index 9f98f91..f98c7d3 100755 (executable)
@@ -35,6 +35,9 @@ extern Eina_Bool _tizen_cb_event_keyup_change(void *data, int type, void *event)
 
 extern Eina_Bool _tizen_cb_event_keydown_change(void *data, int type, void *event);
 
+extern Eina_Bool _tizen_cb_event_focus_in(void *data, int type EINA_UNUSED, void *event);
+
+extern Eina_Bool _tizen_cb_event_focus_out(void *data, int type EINA_UNUSED, void *event);
 
 #endif /* _SDL_tizenevents_h */
 
index 3af43bf..6e7f90a 100755 (executable)
@@ -106,6 +106,8 @@ void Tizen_FiniKeyboard(void)
 void
 Tizen_StartTextInput(_THIS)
 {
+    SDL_Window *window;
+
     if (!_this) {
         SDL_SetError("Video subsystem must be initialized");
         return;
@@ -114,7 +116,8 @@ Tizen_StartTextInput(_THIS)
     if(tizen_keyboard.imf_context == NULL)
       Tizen_InitKeyboard(_this);
 
-    Tizen_ShowScreenKeyboard(_this, NULL);
+    window = SDL_GetKeyboardFocus();
+    Tizen_ShowScreenKeyboard(_this, window);
 }
 
 
@@ -143,11 +146,13 @@ Tizen_HasScreenKeyboardSupport(_THIS)
 void
 Tizen_ShowScreenKeyboard(_THIS, SDL_Window * window)
 {
+    SDL_WindowData *wind = window->driverdata;
     if (!tizen_keyboard.imf_context)
           return;
 
     ecore_imf_context_focus_in(tizen_keyboard.imf_context);
     ecore_imf_context_input_panel_show(tizen_keyboard.imf_context);
+    ecore_imf_context_client_window_set(tizen_keyboard.imf_context, (void*)wind->id);
 }
 
 void
index 3ce0a99..fae9019 100755 (executable)
@@ -257,50 +257,56 @@ _tizen_cb_event_mousedown_change(void *data, int type, void *event)
     if (!event) return ECORE_CALLBACK_PASS_ON;
 
     Ecore_Event_Mouse_Button *e = event;
+    Ecore_Wl_Window *ew;
+    SDL_Window *window;
+
+    ew = ecore_wl_window_find(e->window);
+    window = Tizen_FindWindow(_this, ew);
+
     SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "mouse down (%d x %d)",e->x,e->y);
-    if(_this->current_glwin->indicator_type == 0)
+    if(window->indicator_type == 0)
     {
-        if(e->x > _this->current_glwin->x && e->x <  _this->current_glwin->x + _this->current_glwin->w &&
-            e->y > _this->current_glwin->y && e->y < _this->current_glwin->y + 52)
+        if(e->x > window->x && e->x <  window->x + window->w &&
+            e->y > window->y && e->y < window->y + 52)
         {
             ModelMatrixLoadIdentity(&mMatrix);
-            _this->current_glwin->indicator_show = SDL_TRUE;
-            _this->current_glwin->last_indicator_showtime = SDL_GetTicks();
+            window->indicator_show = SDL_TRUE;
+            window->last_indicator_showtime = SDL_GetTicks();
         }
     }
-    else if(_this->current_glwin->indicator_type == 1)
+    else if(window->indicator_type == 1)
     {
-        if(e->x > _this->current_glwin->x && e->x <  _this->current_glwin->x + 52 &&
-            e->y > _this->current_glwin->y && e->y < _this->current_glwin->y + _this->current_glwin->h)
+        if(e->x > window->x && e->x <  window->x + 52 &&
+            e->y > window->y && e->y < window->y + window->h)
         {
             ModelMatrixLoadIdentity(&mMatrix);
-            _this->current_glwin->indicator_show = SDL_TRUE;
-            _this->current_glwin->last_indicator_showtime = SDL_GetTicks();
+            window->indicator_show = SDL_TRUE;
+            window->last_indicator_showtime = SDL_GetTicks();
         }
     }
-    else if(_this->current_glwin->indicator_type == 2)
+    else if(window->indicator_type == 2)
     {
-        if(e->x > _this->current_glwin->x && e->x <  _this->current_glwin->x + _this->current_glwin->w  &&
-            e->y > _this->current_glwin->y + _this->current_glwin->h -52 && e->y < _this->current_glwin->y + _this->current_glwin->h)
+        if(e->x > window->x && e->x <  window->x + window->w  &&
+            e->y > window->y + window->h -52 && e->y < window->y + window->h)
         {
             ModelMatrixLoadIdentity(&mMatrix);
-            _this->current_glwin->indicator_show = SDL_TRUE;
-            _this->current_glwin->last_indicator_showtime = SDL_GetTicks();
+            window->indicator_show = SDL_TRUE;
+            window->last_indicator_showtime = SDL_GetTicks();
         }
     }
-    else if(_this->current_glwin->indicator_type == 3)
+    else if(window->indicator_type == 3)
     {
-        if(e->x > _this->current_glwin->x + _this->current_glwin->w -52 && e->x <  _this->current_glwin->x + _this->current_glwin->w  &&
-            e->y > _this->current_glwin->y && e->y < _this->current_glwin->y + _this->current_glwin->h)
+        if(e->x > window->x + window->w -52 && e->x <  window->x + window->w  &&
+            e->y > window->y && e->y < window->y + window->h)
         {
             ModelMatrixLoadIdentity(&mMatrix);
-            _this->current_glwin->indicator_show = SDL_TRUE;
-            _this->current_glwin->last_indicator_showtime = SDL_GetTicks();
+            window->indicator_show = SDL_TRUE;
+            window->last_indicator_showtime = SDL_GetTicks();
         }
     }
 
-    SDL_SendMouseMotion(_this->current_glwin, 0, 0,  e->x, e->y);
-    SDL_SendMouseButton(_this->current_glwin, 0, SDL_PRESSED, SDL_BUTTON_LEFT);
+    SDL_SendMouseMotion(window, 0, 0,  e->x, e->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);
 
@@ -314,9 +320,15 @@ _tizen_cb_event_mouseup_change(void *data, int type, void *event)
     if (!event) return ECORE_CALLBACK_PASS_ON;
 
     Ecore_Event_Mouse_Button *e = event;
+    Ecore_Wl_Window *ew;
+    SDL_Window *window;
+
+    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(_this->current_glwin, 0, 0,  e->x, e->y);
-    SDL_SendMouseButton(_this->current_glwin, 0, SDL_RELEASED, SDL_BUTTON_LEFT);
+    SDL_SendMouseMotion(window, 0, 0,  e->x, e->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);
 
@@ -331,14 +343,40 @@ _tizen_cb_event_mousemove_change(void *data, int type, void *event)
     if (!event) return ECORE_CALLBACK_PASS_ON;
 
     Ecore_Event_Mouse_Move *e = event;
+    Ecore_Wl_Window *ew;
+    SDL_Window *window;
+
+    ew = ecore_wl_window_find(e->window);
+    window = Tizen_FindWindow(_this, ew);
+
     //SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "mouse move (%d x %d)",e->x,e->y);
-    SDL_SendMouseMotion(_this->current_glwin, 0, 0,  e->x, e->y);
+    SDL_SendMouseMotion(window, 0, 0,  e->x, e->y);
 
     Tizen_OnTouch(_this,1,e->multi.device,ACTION_POINTER_MOVE,e->x,e->y,1.0f);
 
     return ECORE_CALLBACK_PASS_ON;
 }
 
+Eina_Bool
+_tizen_cb_event_mouse_in(void *data, int type EINA_UNUSED, void *event)
+{
+    SDL_VideoDevice *_this = SDL_GetVideoDevice();
+    Ecore_Wl_Event_Mouse_In *ev;
+    Ecore_Wl_Window *ew;
+    SDL_Window *window;
+
+    ev = event;
+    ew = ecore_wl_window_find(ev->window);
+    window = Tizen_FindWindow(_this, ew);
 
+    SDL_SetMouseFocus(window);
+    return ECORE_CALLBACK_PASS_ON;
+}
 
+Eina_Bool
+_tizen_cb_event_mouse_out(void *data, int type EINA_UNUSED, void *event)
+{
+    SDL_SetMouseFocus(NULL);
+    return ECORE_CALLBACK_PASS_ON;
+}
 
index 91a0a5e..17b18c0 100755 (executable)
@@ -34,5 +34,6 @@ extern void Tizen_FiniMouse(void);
 extern Eina_Bool _tizen_cb_event_mouseup_change(void *data, int type, void *event);
 extern Eina_Bool _tizen_cb_event_mousedown_change(void *data, int type, void *event);
 extern Eina_Bool _tizen_cb_event_mousemove_change(void *data, int type, void *event);
-
+extern Eina_Bool _tizen_cb_event_mouse_in(void *data, int type, void *event);
+extern Eina_Bool _tizen_cb_event_mouse_out(void *data, int type, void *event);
 
index e578327..39f66a9 100755 (executable)
@@ -325,8 +325,8 @@ Tizen_DestroyWindow(_THIS, SDL_Window *window)
     window->driverdata = NULL;
 }
 
-static SDL_Window*
-_tizen_find_window(_THIS, Ecore_Wl_Window *ewin)
+SDL_Window*
+Tizen_FindWindow(_THIS, Ecore_Wl_Window *ewin)
 {
     SDL_VideoData *data = _this->driverdata;
     int id;
@@ -345,7 +345,7 @@ _tizen_cb_event_window_visibility_change(void *data, int type, void *event)
 
     ev = event;
     ew = ecore_wl_window_find(ev->win);
-    window = _tizen_find_window(_this, ew);
+    window = Tizen_FindWindow(_this, ew);
 
     SDL_Log( "visibility window: %p, ecore_wl_window: %p\n", window, ew);
 
@@ -365,7 +365,7 @@ _tizen_cb_window_configure(void *data, int type EINA_UNUSED, void *event)
    int nx = 0, ny = 0, nw = 0, nh = 0;
    ev = event;
    ew = ecore_wl_window_find(ev->win);
-   window = _tizen_find_window(_this, ew);
+   window = Tizen_FindWindow(_this, ew);
    wind = window->driverdata;
 
    if (wind->rotation_supported == 0){
@@ -405,7 +405,7 @@ _tizen_cb_event_window_rotate(void *data, int type EINA_UNUSED, void *event)
     }
 
     ew = ecore_wl_window_find(ev->win);
-    window = _tizen_find_window(_this, ew);
+    window = Tizen_FindWindow(_this, ew);
     wind = window->driverdata;
 
     if (wind->rotation != ev->angle) {
@@ -447,6 +447,15 @@ Tizen_InitWindow(_THIS)
                         _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);
+
     return 0;
 }
 
index 08d5baa..19c6e0e 100755 (executable)
@@ -44,6 +44,8 @@ typedef struct {
     int received_rotation;
 } SDL_WindowData;
 
+
+extern SDL_Window* Tizen_FindWindow(_THIS, Ecore_Wl_Window *ewin);
 extern void Tizen_ShowWindow(_THIS, SDL_Window *window);
 extern void Tizen_SetWindowFullscreen(_THIS, SDL_Window *window,
                                       SDL_VideoDisplay *_display,