[SDL_Tizen] Add new internal apis for window 08/188708/5
authorhuiyu.eun <huiyu.eun@samsung.com>
Fri, 7 Sep 2018 11:41:47 +0000 (20:41 +0900)
committerhuiyu.eun <huiyu.eun@samsung.com>
Mon, 10 Sep 2018 02:51:33 +0000 (11:51 +0900)
SDL_Tizen_AddAuxiliaryHint
SDL_Tizen_RemoveAuxiliaryHint
SDL_Tizen_SetAuxiliaryHint

SDL_Tizen_GetAuxiliaryHintValue
SDL_Tizen_GetAuxiliaryHintId

SDL_Tizen_SetWindowFocusSkip
SDL_Tizen_GetWindowFocusSkip

Change-Id: Iba73579e273cf21938acb1e2bedefabcc45a86f9
Signed-off-by: huiyu.eun <huiyu.eun@samsung.com>
src/core/tizen/SDL_tizen.h
src/dynapi/SDL_dynapi_overrides.h
src/dynapi/SDL_dynapi_procs.h
src/video/tizen/SDL_tizenvideo.c
src/video/tizen/SDL_tizenvideo.h
src/video/tizen/SDL_tizenwindow.c
src/video/tizen/SDL_tizenwindow.h

index 908b310..e65eb37 100644 (file)
      misrepresented as being the original software.
   3. This notice may not be removed or altered from any source distribution.
 */
-
 #include "../../SDL_internal.h"
 
 #ifndef _SDL_tizen_h
 #define _SDL_tizen_h
 
 #if __TIZEN__
+#define TIZEN_INTERNAL_API __attribute__ ((visibility("default")))
 void SDL_tizen_app_exit(void);
 #endif
 
index 21b221e..6798e6b 100755 (executable)
 #define SDL_WinRTGetDeviceFamily SDL_WinRTGetDeviceFamily_REAL
 #define SDL_log10 SDL_log10_REAL
 #define SDL_log10f SDL_log10f_REAL
-#define SDL_tizen_app_init SDL_tizen_app_init_REAL
+#define SDL_tizen_app_init SDL_tizen_app_init_REAL
\ No newline at end of file
index b16b367..300fe98 100755 (executable)
@@ -708,4 +708,4 @@ SDL_DYNAPI_PROC(SDL_bool,SDL_IsAndroidTV,(void),(),return)
 #endif
 SDL_DYNAPI_PROC(double,SDL_log10,(double a),(a),return)
 SDL_DYNAPI_PROC(float,SDL_log10f,(float a),(a),return)
-SDL_DYNAPI_PROC(int,SDL_tizen_app_init,(int a, char *b[]),(a,b),return)
+SDL_DYNAPI_PROC(int,SDL_tizen_app_init,(int a, char *b[]),(a,b),return)
\ No newline at end of file
index 4f91469..3015d48 100755 (executable)
@@ -131,6 +131,7 @@ Tizen_CreateDevice(int devindex)
     device->SetWindowHitTest = Tizen_SetWindowHitTest;
     device->GetWindowWMInfo = Tizen_GetWindowWMInfo;
     device->SetWindowPosition = Tizen_SetWindowPosition;
+    device->SetWindowOpacity = Tizen_SetWindowOpacity;
 
     /* Text input */
     device->StartTextInput = Tizen_StartTextInput;
index 56b7272..1b19ea9 100755 (executable)
@@ -51,6 +51,7 @@ int Tizen_VideoInit(_THIS);
 void Tizen_GetDisplayModes(_THIS, SDL_VideoDisplay *sdl_display);
 int Tizen_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode);
 void Tizen_VideoQuit(_THIS);
+int Tizen_SetWindowOpacity(_THIS, SDL_Window * window, float opacity);
 
 #endif /* _SDL_tizenvideo_h */
 
index a7fab1d..d8f9fe9 100755 (executable)
@@ -45,7 +45,9 @@
 #include "../../events/SDL_windowevents_c.h"
 
 #include <Ecore_Ipc.h>
+#include <Ecore_Wl2.h>
 #include <unistd.h>
+#include <string.h>
 
 /*SDL indicator*/
 Ecore_Ipc_Server *ipc = NULL;
@@ -621,6 +623,334 @@ _tizen_indicator_opacity_hint_callback(void *userdata, const char *name, const c
     }
 }
 
+unsigned int
+SDL_Tizen_GetSupportedAuxiliaryHintCount(SDL_Window *window)
+{
+    SDL_WindowData *wind = NULL;
+    Ecore_Wl2_Window *ecore_window = NULL;
+    Eina_List* hints = NULL;
+
+    if (!window || !window->driverdata) {
+        return 0;
+    }
+
+    wind = (SDL_WindowData *) window->driverdata;
+    ecore_window = wind->window;
+    if (!ecore_window) {
+        SDL_Log("AddAuxiliaryHint: ecore_window is null");
+        return 0;
+    }
+
+    hints = ecore_wl2_window_aux_hints_supported_get(ecore_window);
+    int count = 0;
+    if (hints) {
+        Eina_List* l = NULL;
+        for (l = hints; l; l = eina_list_next(l)) {
+            count++;
+        }
+    }
+    return count;
+}
+
+const char*
+SDL_Tizen_GetSupportedAuxiliaryHint(SDL_Window *window, unsigned int index)
+{
+    SDL_WindowData *wind = NULL;
+    Ecore_Wl2_Window *ecore_window = NULL;
+    Eina_List* hints = NULL;
+
+    if (!window || !window->driverdata) {
+        return NULL;
+    }
+
+    wind = (SDL_WindowData *) window->driverdata;
+    ecore_window = wind->window;
+    if (!ecore_window) {
+        SDL_Log("AddAuxiliaryHint: ecore_window is null");
+        return NULL;
+    }
+
+    hints = ecore_wl2_window_aux_hints_supported_get(ecore_window);
+
+    if (hints) {
+        Eina_List* l = NULL;
+        char* supported_hint = NULL;
+        int i = 0;
+        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)))) {
+            if (i == index) {
+                return supported_hint;
+            }
+            i++;
+        }
+    }
+    return NULL;
+}
+
+unsigned int
+SDL_Tizen_AddAuxiliaryHint(SDL_Window *window, const char *hint, const char *value)
+{
+    SDL_WindowData *wind = NULL;
+    Ecore_Wl2_Window *ecore_window = NULL;
+    Eina_List* hints = NULL;
+    SDL_bool supported = SDL_FALSE;
+
+    if (!window || !window->driverdata) {
+        return 0;
+    }
+
+    wind = (SDL_WindowData *) window->driverdata;
+    ecore_window = wind->window;
+    if (!ecore_window) {
+        SDL_Log("AddAuxiliaryHint: ecore_window is null");
+        return 0;
+    }
+
+    hints = ecore_wl2_window_aux_hints_supported_get(ecore_window);
+    if (hints) {
+        Eina_List* l = NULL;
+        char* supported_hint = NULL;
+        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)))) {
+            if (!SDL_strncmp(supported_hint, hint, strlen(hint))) {
+                 supported = SDL_TRUE;
+                 break;
+            }
+
+        }
+    }
+
+    if (!supported) {
+        SDL_Log("AddAuxiliaryHint: Not supported auxiliary hint [%s]\n", hint);
+        return 0;
+    }
+
+    unsigned int new_id = 1;
+    if ((wind->auxiliaryHints).auxHintHeader) {
+        AuxiliaryHint* auxiliaryHint = (wind->auxiliaryHints).auxHintHeader;
+        AuxiliaryHint* nextAuxiliaryHint = auxiliaryHint->next;
+        while (auxiliaryHint) {
+            if (!SDL_strncmp(auxiliaryHint->hint, hint, strlen(hint))) {
+                auxiliaryHint->value = value;
+                SDL_Log("AddAuxiliaryHint: Change! hint = %s, value = %s, id = %d\n", auxiliaryHint->hint, auxiliaryHint->value, auxiliaryHint->id);
+                return auxiliaryHint->id;
+            }
+            auxiliaryHint = nextAuxiliaryHint;
+            nextAuxiliaryHint = NULL;
+            if(auxiliaryHint) {
+                nextAuxiliaryHint = auxiliaryHint->next;
+            }
+            new_id++;
+        }
+    }
+
+    // Add the hint
+    AuxiliaryHint* newAuxiliaryHint = (AuxiliaryHint *)SDL_calloc(1, sizeof(AuxiliaryHint));
+    if (!newAuxiliaryHint) {
+        SDL_Log("AddAuxiliaryHint: Fail calloc");
+        return 0;
+    }
+
+    newAuxiliaryHint->id = new_id;
+    newAuxiliaryHint->hint = hint;
+    newAuxiliaryHint->value = value;
+    newAuxiliaryHint->next = NULL;
+    if (new_id != 1) {
+        newAuxiliaryHint->next = (wind->auxiliaryHints).auxHintHeader;
+    }
+
+    (wind->auxiliaryHints).auxHintHeader = newAuxiliaryHint;
+    (wind->auxiliaryHints).size++;
+    ecore_wl2_window_aux_hint_add(ecore_window, (int)new_id, hint, value);
+    SDL_Log("AddAuxiliaryHint: hint = %s, value = %s, id = %d\n", hint, value, new_id);
+
+    return new_id;
+}
+
+SDL_bool
+SDL_Tizen_RemoveAuxiliaryHint(SDL_Window *window, unsigned int id)
+{
+    SDL_WindowData *wind = NULL;
+    Ecore_Wl2_Window *ecore_window = NULL;
+
+    if (!window || !window->driverdata) {
+        return SDL_FALSE;
+    }
+
+    wind = (SDL_WindowData *) window->driverdata;
+    ecore_window = wind->window;
+
+    if (!ecore_window) {
+        SDL_Log("RemoveAuxiliaryHint: ecore_window is null");
+        return SDL_FALSE;
+    }
+
+    if (id == 0) {
+      SDL_Log( "RemoveAuxiliaryHint: Invalid id [%d]\n", id );
+      return SDL_FALSE;
+    }
+
+    if ((wind->auxiliaryHints).auxHintHeader) {
+        AuxiliaryHint* auxiliaryHint = (wind->auxiliaryHints).auxHintHeader;
+        AuxiliaryHint* prevAuxiliaryHint = NULL;
+        AuxiliaryHint* nextAuxiliaryHint = auxiliaryHint->next;
+        while (auxiliaryHint) {
+            if (auxiliaryHint->id == id) {
+                SDL_Log("RemoveAuxiliaryHint: id = %d, hint = %s\n", id, auxiliaryHint->hint);
+                ecore_wl2_window_aux_hint_del(ecore_window, (int)id);
+                if (auxiliaryHint == (wind->auxiliaryHints).auxHintHeader) {
+                    (wind->auxiliaryHints).auxHintHeader = auxiliaryHint->next;
+                } else {
+                    prevAuxiliaryHint->next = nextAuxiliaryHint;
+                }
+                SDL_free(auxiliaryHint);
+                (wind->auxiliaryHints).size--;
+                return SDL_TRUE;
+            }
+            prevAuxiliaryHint = auxiliaryHint;
+            auxiliaryHint = nextAuxiliaryHint;
+            nextAuxiliaryHint = NULL;
+            if(auxiliaryHint) {
+                nextAuxiliaryHint = auxiliaryHint->next;
+            }
+        }
+    }
+    return SDL_FALSE;
+}
+
+SDL_bool
+SDL_Tizen_SetAuxiliaryHint(SDL_Window *window, unsigned int id, const char *value)
+{
+    SDL_WindowData *wind = NULL;
+    Ecore_Wl2_Window *ecore_window = NULL;
+
+    if (!window || !window->driverdata) {
+        return SDL_FALSE;
+    }
+
+    wind = (SDL_WindowData *) window->driverdata;
+    ecore_window = wind->window;
+
+    if (!ecore_window) {
+        return SDL_FALSE;
+    }
+
+    if (id == 0) {
+      SDL_Log( "RemoveAuxiliaryHint: Invalid id [%d]\n", id );
+      return SDL_FALSE;
+    }
+
+    if ((wind->auxiliaryHints).auxHintHeader) {
+        AuxiliaryHint* auxiliaryHint = (wind->auxiliaryHints).auxHintHeader;
+        AuxiliaryHint* nextAuxiliaryHint = auxiliaryHint->next;
+        while (auxiliaryHint) {
+            if (auxiliaryHint->id == id) {
+                ecore_wl2_window_aux_hint_change(ecore_window, (int)id, value);
+                auxiliaryHint->value = value;
+                SDL_Log("SetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, auxiliaryHint->hint, auxiliaryHint->value);
+                return SDL_TRUE;
+            }
+            auxiliaryHint = nextAuxiliaryHint;
+            nextAuxiliaryHint = NULL;
+            if(auxiliaryHint) {
+                nextAuxiliaryHint = auxiliaryHint->next;
+            }
+        }
+    }
+    return SDL_FALSE;
+}
+
+const char*
+SDL_Tizen_GetAuxiliaryHintValue(SDL_Window *window, unsigned int id)
+{
+    SDL_WindowData *wind = NULL;
+    if (!window || !window->driverdata) {
+        return NULL;
+    }
+
+    wind = (SDL_WindowData *) window->driverdata;
+    if (id == 0) {
+      SDL_Log( "GetAuxiliaryHintValue: Invalid id [%d]\n", id );
+      return NULL;
+    }
+
+    if ((wind->auxiliaryHints).auxHintHeader) {
+        AuxiliaryHint* auxiliaryHint = (wind->auxiliaryHints).auxHintHeader;
+        while (auxiliaryHint) {
+            if (auxiliaryHint->id == id) {
+                SDL_Log("GetAuxiliaryHintValue: id = %d, hint = %s, value = %s\n", id, auxiliaryHint->hint, auxiliaryHint->value);
+                return auxiliaryHint->value;
+            }
+            auxiliaryHint = auxiliaryHint->next;
+        }
+    }
+    return NULL;
+}
+
+unsigned int
+SDL_Tizen_GetAuxiliaryHintId(SDL_Window *window, const char *hint)
+{
+    SDL_WindowData *wind = NULL;
+    if (!window || !window->driverdata) {
+        return 0;
+    }
+
+    wind = (SDL_WindowData *) window->driverdata;
+
+    if (hint == NULL || (wind->auxiliaryHints).size <= 0) {
+      SDL_Log( "GetAuxiliaryHintId: auxiliaryHints size is 0]\n");
+      return 0;
+    }
+
+    if ((wind->auxiliaryHints).auxHintHeader) {
+        AuxiliaryHint* auxiliaryHint = (wind->auxiliaryHints).auxHintHeader;
+        for (unsigned int i = 0; i < (wind->auxiliaryHints).size; i++) {
+            if (auxiliaryHint->hint == hint) {
+                SDL_Log("GetAuxiliaryHintId: hint = %s, id = %d\n", hint, auxiliaryHint->id);
+                return auxiliaryHint->id;
+            }
+            auxiliaryHint = auxiliaryHint->next;
+        }
+    }
+    SDL_Log("GetAuxiliaryHintId: Invalid hint! [%s]\n", hint);
+
+    return 0;
+}
+
+SDL_bool
+SDL_Tizen_GetWindowAcceptFocus(SDL_Window * window)
+{
+    SDL_WindowData *data = NULL;
+
+    if (!window || !window->driverdata) {
+        return SDL_FALSE;
+    }
+
+    data = (SDL_WindowData *) window->driverdata;
+    if (!data->window) {
+        return SDL_FALSE;
+    }
+
+    return !ecore_wl2_window_focus_skip_get(data->window);
+}
+
+SDL_bool
+SDL_Tizen_SetWindowAcceptFocus(SDL_Window * window, SDL_bool accept)
+{
+    SDL_WindowData *data = NULL;
+
+    if (!window || !window->driverdata) {
+        return SDL_FALSE;
+    }
+
+    data = (SDL_WindowData *) window->driverdata;
+    if (!data->window) {
+        return SDL_FALSE;
+    }
+
+    ecore_wl2_window_focus_skip_set(data->window, !accept);
+    return SDL_TRUE;
+}
+
 int
 Tizen_CreateWindow(_THIS, SDL_Window *window)
 {
@@ -635,7 +965,8 @@ Tizen_CreateWindow(_THIS, SDL_Window *window)
     if (!wind) {
         return SDL_OutOfMemory();
     }
-
+    (wind->auxiliaryHints).size = 0;
+    (wind->auxiliaryHints).auxHintHeader = NULL;
     window->driverdata = wind;
     window->flags |= SDL_WINDOW_INPUT_FOCUS;    /* always has input focus */
 
@@ -752,11 +1083,6 @@ Tizen_CreateWindow(_THIS, SDL_Window *window)
     Tizen_InitKeyboard(_this);
     SDL_SetMouseFocus(window);
 
-    if (window->flags & 0x00008000) {
-        ecore_wl2_window_input_region_set(wind->window, -1, -1, 1, 1);
-        ecore_wl2_window_focus_skip_set(wind->window, EINA_TRUE);
-    }
-
     EINA_ITERATOR_FOREACH(globals, global) {
          if (!strcmp(global->interface, "tizen_policy_ext")) {
               wind->rotation_supported = 1;
@@ -848,6 +1174,18 @@ Tizen_DestroyWindow(_THIS, SDL_Window *window)
     SDL_WindowData *wind = window->driverdata;
 
     if (data) {
+        AuxiliaryHint* auxiliaryHint = (wind->auxiliaryHints).auxHintHeader;
+        if (auxiliaryHint) {
+            AuxiliaryHint* nextAuxiliaryHints = auxiliaryHint->next;
+            while (auxiliaryHint) {
+                SDL_free(auxiliaryHint);
+                auxiliaryHint = nextAuxiliaryHints;
+                nextAuxiliaryHints = NULL;
+                if (auxiliaryHint) {
+                    nextAuxiliaryHints = auxiliaryHint->next;
+                }
+            }
+        }
         eina_hash_del(data->windows, &wind->id, window);
 #if SDL_VIDEO_OPENGL_EGL
     if (window->flags & SDL_WINDOW_OPENGL) {
@@ -862,6 +1200,18 @@ Tizen_DestroyWindow(_THIS, SDL_Window *window)
     window->driverdata = NULL;
 }
 
+int
+Tizen_SetWindowOpacity(_THIS, SDL_Window * window, float opacity)
+{
+    SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
+    if (opacity < 1.0f) {
+        ecore_wl2_window_alpha_set(data->window, true);
+    } else {
+        ecore_wl2_window_alpha_set(data->window, false);
+    }
+    return 0;
+}
+
 Eina_Bool
 _tizen_cb_event_window_visibility_change(void *data, int type, void *event)
 {
index 29d9cbb..b7cb4a7 100755 (executable)
 
 #include "SDL_syswm.h"
 
+#include "../../core/tizen/SDL_tizen.h"
 #include "SDL_tizenvideo.h"
 #include <Ecore_Input.h>
 #include <wayland-egl.h>
 #include <wayland-egl-tizen.h>
 
+typedef struct AuxiliaryHint{
+    unsigned int id;
+    const char* hint;
+    const char* value;
+    struct AuxiliaryHint* next;
+}AuxiliaryHint;
+
+typedef struct AuxiliaryHints{
+    AuxiliaryHint* auxHintHeader;
+    int size;
+}AuxiliaryHints;
+
 typedef struct {
     uint32_t g_res_id;         /* Wayland window resource id */
     uint32_t id;               /* Ecore wayland window id */
@@ -51,6 +64,7 @@ typedef struct {
     SDL_bool support_pre_rotation;
     SDL_bool support_indicator;
 
+    AuxiliaryHints auxiliaryHints;
 } SDL_WindowData;
 
 enum tizen_rotation_received_type {
@@ -104,6 +118,88 @@ extern void _tizen_ecore_ipc_client_send(int major, int minor, int ref, int ref_
 extern void _tizen_quickpanel_on(SDL_WindowData *wind);
 extern void _tizen_quickpanel_off(SDL_WindowData *wind);
 
+/**
+ *  \brief Gets the count of supported auxiliary hints of the window.
+ *
+ *  \param window SDL_Window
+ *  \return The number of supported auxiliary hints.
+ */
+extern TIZEN_INTERNAL_API unsigned int SDL_Tizen_GetSupportedAuxiliaryHintCount(SDL_Window *window);
+
+/**
+ *  \brief Gets the supported auxiliary hint string of the window.
+ *
+ *  \param window SDL_Window
+ *  \param index The index of the supported auxiliary hint lists.
+ *  \return The auxiliary hint string of the index.
+ */
+extern TIZEN_INTERNAL_API const char* SDL_Tizen_GetSupportedAuxiliaryHint(SDL_Window *window, unsigned int index);
+
+
+/**
+ *  \brief Add a supported auxiliary hint to a given window
+ *
+ *  \param window SDL_Window
+ *  \param hint The auxiliary hint string.
+ *  \param value The value string to be set.
+ *  \return The ID of created auxiliary hint, or 0 on failure.
+ */
+extern TIZEN_INTERNAL_API unsigned int SDL_Tizen_AddAuxiliaryHint(SDL_Window *window, const char *hint, const char *value);
+
+/**
+ *  \brief Remove an auxiliary hint on a given window
+ *
+ *  \param window SDL_Window
+ *  \param id The auxiliary hint ID.
+ *  \return SDL_TRUE on success, SDL_FALSE on failure.
+ */
+extern TIZEN_INTERNAL_API SDL_bool SDL_Tizen_RemoveAuxiliaryHint(SDL_Window *window, unsigned int id);
+
+/**
+ *  \brief Change an auxiliary hint on a given window
+ *
+ *  \param window SDL_Window
+ *  \param id The auxiliary hint ID.
+ *  \param value The value string to be set.
+ *  \return SDL_TRUE on success, SDL_FALSE on failure.
+ */
+extern TIZEN_INTERNAL_API SDL_bool SDL_Tizen_SetAuxiliaryHint(SDL_Window *window, unsigned int id, const char *value);
+
+/**
+ *  \brief Gets a value of the auxiliary hint.
+ *
+ *  \param window SDL_Window
+ *  \param id The auxiliary hint ID
+ *  \return The string value of the auxiliary hint ID, or an empty string if none exists.
+ */
+extern TIZEN_INTERNAL_API const char* SDL_Tizen_GetAuxiliaryHintValue(SDL_Window *window, unsigned int id);
+
+/**
+ *  \brief Gets an ID of the auxiliary hint string.
+ *
+ *  \param window SDL_Window
+ *  \param hint The auxiliary hint string.
+ *  \return The ID of auxiliary hint string, or 0 on failure.
+ */
+extern TIZEN_INTERNAL_API unsigned int SDL_Tizen_GetAuxiliaryHintId(SDL_Window *window, const char *hint);
+
+/**
+ *  \brief Sets whether the window accepts a focus or not.
+ *
+ *  \param window SDL_Window
+ *  \param accept If a focus is accepted or not. The default is true.
+ *  \return SDL_TRUE on success, SDL_FALSE on failure.
+ */
+extern TIZEN_INTERNAL_API SDL_bool SDL_Tizen_SetWindowAcceptFocus(SDL_Window * window, SDL_bool accept);
+
+/**
+ *  \brief Returns whether the window accepts a focus or not.
+ *
+ *  \param window SDL_Window
+ *  \return True if the window accepts a focus, false otherwise.
+ */
+extern TIZEN_INTERNAL_API SDL_bool SDL_Tizen_GetWindowAcceptFocus(SDL_Window * window);
+
 #endif /* _SDL_tizenwindow_h */
 
 /* vi: set ts=4 sw=4 expandtab: */