efl_util.c add wl_seat
[platform/core/api/efl-util.git] / src / efl_util.c
index b031ba0..902b0db 100644 (file)
@@ -216,7 +216,10 @@ typedef struct _Efl_Util_Data
          Eina_List *devices;
          Eina_List *wait_devices;
          struct wl_event_source *wait_timer;
+         int max_touch_count;
+         int request_touch_count;
       } devmgr;
+      struct wl_seat *seat;
       struct
       {
          unsigned int id;
@@ -253,7 +256,8 @@ static Efl_Util_Data _eflutil =
       NULL, NULL, NULL,
       { 0, NULL, NULL, NULL }, /* tizen_policy protocol */
       { NULL, NULL, NULL, NULL, NULL, 0 }, /* screenshooter protocol */
-      { NULL, -1, NULL, NULL, NULL }, /* tizen_input_device_manager protocol */
+      { NULL, -1, NULL, NULL, NULL, 0, 0 }, /* tizen_input_device_manager protocol */
+      NULL, /* wl_seat protocol */
       { 0, NULL, NULL } /* display_policy protocol */
    },
 };
@@ -531,6 +535,22 @@ static const struct tizen_screenshooter_listener tz_screenshooter_listener =
 };
 
 static void
+_cb_seat_capabilities(void *data, struct wl_seat *seat, enum wl_seat_capability caps)
+{
+}
+
+static void
+_cb_seat_name(void *data, struct wl_seat *seat EINA_UNUSED, const char *name)
+{
+}
+
+static const struct wl_seat_listener _seat_listener =
+{
+   _cb_seat_capabilities,
+   _cb_seat_name,
+};
+
+static void
 _cb_wl_reg_global(void *data,
                   struct wl_registry *reg,
                   unsigned int id,
@@ -565,6 +585,11 @@ _cb_wl_reg_global(void *data,
         output->output = wl_registry_bind(reg, id, &wl_output_interface, version);
         wl_output_add_listener(output->output, &output_listener, output);
      }
+   else if(strcmp(interface, "wl_seat") == 0)
+     {
+        _eflutil.wl.seat = wl_registry_bind(reg, id, &wl_seat_interface, version);
+        wl_seat_add_listener(_eflutil.wl.seat, &_seat_listener, NULL);
+     }
    else if (strcmp(interface, "tizen_input_device_manager") == 0)
      {
         _eflutil.wl.devmgr.devicemgr = wl_registry_bind(reg, id, &tizen_input_device_manager_interface, version);
@@ -1402,10 +1427,10 @@ static void
 _cb_max_touch_count(void *data EINA_UNUSED,
                     struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
                     uint32_t serial EINA_UNUSED,
-                    int32_t max_count EINA_UNUSED,
+                    int32_t max_count,
                     struct wl_seat *seat EINA_UNUSED)
 {
-   ;
+   _eflutil.wl.devmgr.max_touch_count = max_count;
 }
 
 static efl_util_error_e
@@ -1421,6 +1446,8 @@ _efl_util_input_convert_input_generator_error(int ret)
            return EFL_UTIL_ERROR_OUT_OF_MEMORY;
         case TIZEN_INPUT_DEVICE_MANAGER_ERROR_INVALID_PARAMETER:
            return EFL_UTIL_ERROR_INVALID_PARAMETER;
+        case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NOT_ALLOWED:
+           return EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE;
         default :
            return EFL_UTIL_ERROR_NONE;
      }
@@ -1718,6 +1745,39 @@ out:
 }
 
 API int
+efl_util_input_set_touch_count(int max_count)
+{
+   int ret = EFL_UTIL_ERROR_NONE;
+
+   ret = _wl_init();
+   if (ret == (int)EINA_FALSE)
+     {
+        return EFL_UTIL_ERROR_INVALID_PARAMETER;
+     }
+
+   while (!_eflutil.wl.devmgr.devicemgr)
+     wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
+
+   if (_eflutil.wl.devmgr.max_touch_count >= max_count)
+     return EFL_UTIL_ERROR_NONE;
+
+   tizen_input_device_manager_set_touch_count(_eflutil.wl.devmgr.devicemgr, max_count);
+
+   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;
+
+   if (ret == EFL_UTIL_ERROR_NONE)
+     {
+        _eflutil.wl.devmgr.request_touch_count = max_count;
+     }
+
+   return ret;
+}
+
+API int
 efl_util_input_deinitialize_generator(efl_util_inputgen_h inputgen_h)
 {
    int ret = EFL_UTIL_ERROR_NONE;
@@ -1785,6 +1845,9 @@ efl_util_input_generate_touch(efl_util_inputgen_h inputgen_h, int idx,
    EINA_SAFETY_ON_FALSE_RETURN_VAL((x > 0 && y > 0), EFL_UTIL_ERROR_INVALID_PARAMETER);
    EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
 
+   if (idx >= _eflutil.wl.devmgr.max_touch_count)
+     return EFL_UTIL_ERROR_INVALID_PARAMETER;
+
    EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
 
    switch(touch_type)