e_comp_wl: get inverse coordinations using evas_map 50/228350/1 accepted/tizen_5.0_unified tizen_5.0 accepted/tizen/5.0/unified/20200324.082343 submit/tizen_5.0/20200324.122036
authorjeon <jhyuni.kang@samsung.com>
Fri, 20 Mar 2020 10:04:41 +0000 (19:04 +0900)
committerjeon <jhyuni.kang@samsung.com>
Fri, 20 Mar 2020 10:04:41 +0000 (19:04 +0900)
Change-Id: Iff4c69df10ad56078d27be9f653d254c57657f6b

src/bin/e_comp_wl.c
src/bin/e_comp_wl.h
src/bin/e_devicemgr_input.c

index 559d44bccab97a4f206e2dfc98c37d9af060222f..5d2cce55d31f35bb2944c3329bf3348a41f1ab57 100644 (file)
@@ -487,6 +487,46 @@ e_comp_wl_map_apply(E_Client *ec)
    e_client_transform_core_update(ec);
 }
 
+EINTERN void
+e_comp_wl_map_inv_coord_get(E_Client *ec, int x, int y, int *mx, int *my)
+{
+   const Evas_Map *map;
+   Evas_Map *map2;
+   int map_c = 0, map_x = 0, map_y = 0;
+   double inv_x = 0.0, inv_y = 0.0;
+
+   EINA_SAFETY_ON_NULL_RETURN(ec);
+
+   map = evas_object_map_get(ec->frame);
+   map_c = evas_map_count_get(map);
+
+   if (!map || map_c <= 0)
+     {
+        *mx = x;
+        *my = y;
+        return;
+     }
+
+   map2 = evas_map_new(map_c);
+
+   evas_map_point_coord_set(map2, 0, ec->x, ec->y, 0);
+   evas_map_point_coord_set(map2, 1, ec->x + ec->w, ec->y, 0);
+   evas_map_point_coord_set(map2, 2, ec->x + ec->w, ec->y + ec->h, 0);
+   evas_map_point_coord_set(map2, 3, ec->x, ec->y + ec->h, 0);
+
+   for (int i = 0; i < map_c; i++)
+     {
+        evas_map_point_coord_get(map, i, &map_x, &map_y, NULL);
+        evas_map_point_image_uv_set(map2, i, map_x, map_y);
+     }
+   evas_map_coords_get(map2, (double)x, (double)y, &inv_x, &inv_y, 0);
+
+   *mx = (int)inv_x;
+   *my = (int)inv_y;
+
+   evas_map_free(map2);
+}
+
 static void
 _e_comp_wl_evas_cb_show(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
 {
@@ -1254,6 +1294,15 @@ _e_comp_wl_evas_cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *o
                                                   ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
                   _e_comp_wl_send_touch_move(ec, 0, ev->cur.canvas.x, ev->cur.canvas.y, ev->timestamp);
                }
+
+             pointer_x = ev->cur.output.x;
+             pointer_y = ev->cur.output.y;
+
+             if (evas_object_map_enable_get(ec->frame))
+               {
+                  e_comp_wl_map_inv_coord_get(ec, pointer_x, pointer_y, &pointer_x, &pointer_y);
+               }
+
              e_pointer_touch_move(e_comp->pointer, ev->cur.output.x, ev->cur.output.y);
           }
         else
@@ -1269,8 +1318,11 @@ _e_comp_wl_evas_cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *o
 
              pointer_x = ev->cur.output.x;
              pointer_y = ev->cur.output.y;
-             if (e_client_transform_core_enable_get(ec))
-               e_client_transform_core_input_inv_rect_transform(ec, pointer_x, pointer_y, &pointer_x, &pointer_y);
+
+             if (evas_object_map_enable_get(ec->frame))
+               {
+                  e_comp_wl_map_inv_coord_get(ec, pointer_x, pointer_y, &pointer_x, &pointer_y);
+               }
 
              e_pointer_mouse_move(e_comp->pointer, pointer_x, pointer_y);
              if (e_config->use_cursor_timer)
@@ -1341,6 +1393,15 @@ _e_comp_wl_evas_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *o
           _e_comp_wl_device_renew_axis(dev_name, evas_device_class_get(dev),
                                         ec, 0, ev->radius_x, ev->radius_y, ev->pressure, ev->angle);
         _e_comp_wl_evas_handle_mouse_button_to_touch(ec, ev->timestamp, ev->canvas.x, ev->canvas.y, EINA_TRUE);
+
+        pointer_x = ev->output.x;
+        pointer_y = ev->output.y;
+
+        if (evas_object_map_enable_get(ec->frame))
+          {
+             e_comp_wl_map_inv_coord_get(ec, pointer_x, pointer_y, &pointer_x, &pointer_y);
+          }
+
         e_pointer_touch_move(e_comp->pointer, ev->output.x, ev->output.y);
         e_comp_wl->touch.pressed |= (1 << 0);
      }
@@ -1356,8 +1417,11 @@ _e_comp_wl_evas_cb_mouse_down(void *data, Evas *evas EINA_UNUSED, Evas_Object *o
                                            WL_POINTER_BUTTON_STATE_PRESSED);
         pointer_x = ev->output.x;
         pointer_y = ev->output.y;
-        if (e_client_transform_core_enable_get(ec))
-          e_client_transform_core_input_inv_rect_transform(ec, pointer_x, pointer_y, &pointer_x, &pointer_y);
+
+        if (evas_object_map_enable_get(ec->frame))
+          {
+             e_comp_wl_map_inv_coord_get(ec, pointer_x, pointer_y, &pointer_x, &pointer_y);
+          }
 
         e_pointer_mouse_move(e_comp->pointer, pointer_x, pointer_y);
         if (e_config->use_cursor_timer)
index b2bc56813a5345603b5e0e329833f64c8a92dcaf..4ce299407f16c8643b3775c9e0137f929bc5ef62 100644 (file)
@@ -599,5 +599,8 @@ E_API extern int E_EVENT_WAYLAND_GLOBAL_ADD;
 EINTERN Eina_Bool e_comp_wl_commit_sync_client_geometry_add(E_Client *ec, E_Client_Demand_Geometry mode, uint32_t serial, int32_t x, int32_t y, int32_t w, int32_t h);
 EINTERN void e_comp_wl_trace_serial_debug(Eina_Bool on);
 EINTERN Eina_Bool e_comp_wl_commit_sync_configure(E_Client *ec);
+
+EINTERN void e_comp_wl_map_inv_coord_get(E_Client *ec, int x, int y, int *mx, int *my);
+
 # endif
 #endif
index 4709005e266ac8eeb42cb3853cbcd470bcf4863b..12ded5aaf889b627302da540aeccdec9a2cd8b28 100644 (file)
@@ -30,8 +30,9 @@ int
 e_devicemgr_input_pointer_warp(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface, wl_fixed_t x, wl_fixed_t y)
 {
    E_Client *ec;
-   int new_x, new_y;
-   int ret;
+   Evas_Map *map;
+   int new_x, new_y, ret;
+   int i, min_x, min_y, max_x, max_y, tmp_x, tmp_y;
 
    if (!(ec = wl_resource_get_user_data(surface)) || !ec->visible)
      {
@@ -53,8 +54,44 @@ e_devicemgr_input_pointer_warp(struct wl_client *client, struct wl_resource *res
 
    new_x = wl_fixed_to_int(x);
    new_y = wl_fixed_to_int(y);
-   if (e_client_transform_core_enable_get(ec))
-     e_client_transform_core_input_inv_rect_transform(ec, wl_fixed_to_int(x), wl_fixed_to_int(y), &new_x, &new_y);
+
+   if (new_x < ec->x) new_x = ec->x;
+   if ((ec->w != 0) && (new_x > ec->x + ec->w - 1)) new_x = ec->x + ec->w - 1;
+
+   if (new_y < ec->y) new_y = ec->y;
+   if ((ec->h != 0) && (new_y > ec->y + ec->h - 1)) new_y = ec->y + ec->h - 1;
+
+   if (evas_object_map_enable_get(ec->frame))
+     {
+        e_comp_wl_map_inv_coord_get(ec, new_x, new_y, &new_x, &new_y);
+
+        map = (Evas_Map *)evas_object_map_get(ec->frame);
+        evas_map_point_coord_get(map, 0, &min_x, &min_y, NULL);
+        max_x = min_x;
+        max_y = min_y;
+
+        for (i = 1; i < evas_map_count_get(map); i++)
+          {
+             evas_map_point_coord_get(map, i, &tmp_x, &tmp_y, NULL);
+
+             if (tmp_x < min_x) min_x = tmp_x;
+             else if (tmp_x > max_x) max_x = tmp_x;
+
+             if (tmp_y < min_y) min_y = tmp_y;
+             else if (tmp_y > max_y) max_y = tmp_y;
+          }
+
+        if (min_x != max_x)
+          {
+             if (new_x < min_x) new_x = min_x;
+             if (new_x > max_x - 1) new_x = max_x - 1;
+          }
+        if (min_y != max_y)
+          {
+             if (new_y < min_y) new_y = min_y;
+             if (new_y > max_y - 1) new_y = max_y - 1;
+          }
+     }
 
    ret = _e_devicemgr_input_pointer_warp(ec->client.x + new_x, ec->client.y + new_y);
    return ret;