e_devicemgr: clipping warp coords to inside of the window 29/227729/4
authorjeon <jhyuni.kang@samsung.com>
Mon, 16 Mar 2020 05:38:07 +0000 (14:38 +0900)
committerJeongHyun Kang <jhyuni.kang@samsung.com>
Fri, 20 Mar 2020 04:03:35 +0000 (04:03 +0000)
Change-Id: I4ad3f284eef937caf5e70da6e6d41983ed9a94b5

src/bin/e_devicemgr_input.c

index b1015461551aa528122df5744d23d7a85418a745..85abab3439a404fd7409cf04be06b6931aeb0521 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)
      {
@@ -54,9 +55,42 @@ 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 (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;