e_comp_object: apply evas_map to cursor when the zone is rotated 25/62325/4
authorDuna Oh <duna.oh@samsung.com>
Tue, 15 Mar 2016 10:56:26 +0000 (19:56 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Tue, 22 Mar 2016 01:44:26 +0000 (18:44 -0700)
Signed-off-by: Duna Oh <duna.oh@samsung.com>
Change-Id: Ic75290b75daafe4893965cc3e08748a8f82c2aff

src/bin/e_client.c
src/bin/e_client.h
src/bin/e_comp_object.c

index 11d613d4d4db76649488b83b9ec83cff1850dbe6..e0541b1dca82dafae70a15ac774eec5034c9f258 100644 (file)
@@ -4911,7 +4911,106 @@ e_client_ping(E_Client *ec)
                                       _e_client_cb_ping_poller, ec);
 }
 
+static void
+_e_client_map_transform(int width, int height, uint32_t transform,
+                         int sx, int sy, int *dx, int *dy)
+{
+   switch (transform)
+     {
+      case WL_OUTPUT_TRANSFORM_NORMAL:
+      default:
+        *dx = sx, *dy = sy;
+        break;
+      case WL_OUTPUT_TRANSFORM_90:
+        *dx = height - sy, *dy = sx;
+        break;
+      case WL_OUTPUT_TRANSFORM_180:
+        *dx = width - sx, *dy = height - sy;
+        break;
+      case WL_OUTPUT_TRANSFORM_270:
+        *dx = sy, *dy = width - sx;
+        break;
+     }
+}
+
 ////////////////////////////////////////////
+E_API void
+e_client_cursor_map_apply(E_Client *ec, int rotation, int x, int y)
+{
+   Evas_Map *map;
+   int x1, y1, x2, y2, dx, dy;
+   int32_t width, height;
+   int cursor_w, cursor_h;
+   uint32_t transform;
+   int rot_x = x, rot_y = y;
+   int zone_w = ec->zone->w;
+   int zone_h = ec->zone->h;
+   double awh = ((double)zone_w / (double)zone_h);
+   double ahw = ((double)zone_h / (double)zone_w);
+
+   evas_object_geometry_get(ec->frame, NULL, NULL, &cursor_w, &cursor_h);
+   width = cursor_w;
+   height = cursor_h;
+
+   switch(rotation)
+     {
+      case 90:
+         rot_x = y * awh;
+         rot_y = ahw * (zone_w - x);
+         transform = WL_OUTPUT_TRANSFORM_90;
+         width = cursor_h;
+         height = cursor_w;
+         break;
+      case 180:
+         rot_x = zone_w - x;
+         rot_y = zone_h - y;
+         transform = WL_OUTPUT_TRANSFORM_180;
+         break;
+      case 270:
+         rot_x = awh * (zone_h - y);
+         rot_y = ahw * x;
+         transform = WL_OUTPUT_TRANSFORM_270;
+         width = cursor_h;
+         height = cursor_w;
+         break;
+      default:
+         transform = WL_OUTPUT_TRANSFORM_NORMAL;
+         break;
+     }
+   ec->client.x = rot_x, ec->client.y = rot_y;
+   ec->x = rot_x, ec->y = rot_y;
+
+   map = evas_map_new(4);
+   evas_map_util_points_populate_from_geometry(map,
+                                               ec->x, ec->y,
+                                               width, height, 0);
+
+   x1 = 0.0;
+   y1 = 0.0;
+   x2 = width;
+   y2 = height;
+
+   _e_client_map_transform(width, height, transform,
+                            x1, y1, &dx, &dy);
+   evas_map_point_image_uv_set(map, 0, dx, dy);
+
+   _e_client_map_transform(width, height, transform,
+                            x2, y1, &dx, &dy);
+   evas_map_point_image_uv_set(map, 1, dx, dy);
+
+   _e_client_map_transform(width, height, transform,
+                            x2, y2, &dx, &dy);
+   evas_map_point_image_uv_set(map, 2, dx, dy);
+
+   _e_client_map_transform(width, height, transform,
+                            x1, y2, &dx, &dy);
+   evas_map_point_image_uv_set(map, 3, dx, dy);
+
+   evas_object_map_set(ec->frame, map);
+   evas_object_map_enable_set(ec->frame, map ? EINA_TRUE : EINA_FALSE);
+
+   evas_map_free(map);
+}
 
 E_API void
 e_client_move_cancel(void)
index 7e9bf14575667b7834b4b0aa2978e79f8cef976c..1a02c5062b9dc3f0b95c8408aa55f2a6473f3a20 100644 (file)
@@ -967,6 +967,7 @@ E_API void      e_client_visibility_calculate(void);
 E_API void e_client_transform_update(E_Client *ec);
 E_API void e_client_transform_apply(E_Client *ec, double degree, double zoom, int cx, int cy);
 E_API void e_client_transform_clear(E_Client *ec);
+E_API void e_client_cursor_map_apply(E_Client *ec, int rotation, int x, int y);
 
 YOLO E_API void e_client_focus_stack_set(Eina_List *l);
 
index 1d8dee5ea68f9d5202a063b93b9eb0f22c6fa678..45c1fc8c1a2fded3adc48fa7834356ebf836c07e 100644 (file)
@@ -977,6 +977,12 @@ _e_comp_intercept_move(void *data, Evas_Object *obj, int x, int y)
 
    if (!e_util_strcmp("wl_pointer-cursor", cw->ec->icccm.window_role))
      {
+        if (cw->ec->zone->rot.curr != 0)
+          {
+             e_client_cursor_map_apply(cw->ec, cw->ec->zone->rot.curr, x, y);
+             return;
+          }
+
         cw->ec->client.x = x, cw->ec->client.y = y;
         cw->ec->x = x, cw->ec->y = y;
         evas_object_move(obj, x, y);