add initialize values for the display_policy interface
[platform/core/api/efl-util.git] / src / efl_util.c
index 170f0dc..0e0ca0c 100644 (file)
@@ -189,7 +189,8 @@ static Efl_Util_Data _eflutil =
       NULL, NULL,
       { NULL, NULL, NULL }, /* tizen_policy protocol */
       { NULL, NULL, NULL, NULL, NULL, 0 }, /* screenshooter protocol */
-      { NULL, -1 } /* tizen_input_device_manager protocol */
+      { NULL, -1 }, /* tizen_input_device_manager protocol */
+      { NULL, NULL } /* display_policy protocol */
    },
    {
       { NULL, 0 }, /* handler for notification level */
@@ -1261,6 +1262,7 @@ efl_util_get_window_brightness(Evas_Object *window, int *brightness)
 struct _efl_util_inputgen_h
 {
    unsigned int init_type;
+   char name[32];
 };
 
 static void
@@ -1387,6 +1389,73 @@ out:
    return NULL;
 }
 
+API efl_util_inputgen_h
+efl_util_input_initialize_generator_with_name(unsigned int dev_type, const char *name)
+{
+   int ret = EFL_UTIL_ERROR_NONE;
+   efl_util_inputgen_h inputgen_h = NULL;
+   unsigned int clas = 0x0;
+
+   if (!dev_type ||
+        dev_type & ~(EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN
+                    | EFL_UTIL_INPUT_DEVTYPE_KEYBOARD
+                    | EFL_UTIL_INPUT_DEVTYPE_POINTER))
+     {
+        set_last_result(EFL_UTIL_ERROR_NO_SUCH_DEVICE);
+        goto out;
+     }
+
+   inputgen_h = (efl_util_inputgen_h)calloc(1, sizeof(struct _efl_util_inputgen_h));
+   if (!inputgen_h)
+     {
+        set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
+        goto out;
+     }
+
+   inputgen_h->init_type |= dev_type;
+   strncpy(inputgen_h->name, name, 31);
+
+   ret = _wl_init();
+   if (ret == (int)EINA_FALSE)
+     {
+        set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
+        goto out;
+     }
+
+   if (dev_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
+     clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
+   if (dev_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
+     clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
+   if (dev_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
+     clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
+
+   while (!_eflutil.wl.devmgr.devicemgr)
+     wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
+
+   tizen_input_device_manager_init_generator_with_name(_eflutil.wl.devmgr.devicemgr, clas, inputgen_h->name);
+
+   while (_eflutil.wl.devmgr.request_notified == -1)
+     wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
+
+   ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
+   _eflutil.wl.devmgr.request_notified = -1;
+
+   set_last_result(ret);
+   if (ret != TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)
+     goto out;
+
+   return inputgen_h;
+
+out:
+   if (inputgen_h)
+     {
+        free(inputgen_h);
+        inputgen_h = NULL;
+     }
+   return NULL;
+}
+
+
 API int
 efl_util_input_deinitialize_generator(efl_util_inputgen_h inputgen_h)
 {