5 static Eina_List *_ptrs = NULL;
6 static Eina_Bool _initted = EINA_FALSE;
8 /* move the cursor image with the calcaultion of the hot spot */
10 _e_pointer_position_update(E_Pointer *ptr)
14 nx = ptr->x - ptr->hot.x;
15 ny = ptr->y - ptr->hot.y;
17 evas_object_move(ptr->o_ptr, nx, ny);
21 _e_pointer_map_transform(int width, int height, uint32_t transform,
22 int sx, int sy, int *dx, int *dy)
26 case WL_OUTPUT_TRANSFORM_NORMAL:
30 case WL_OUTPUT_TRANSFORM_90:
31 *dx = height - sy, *dy = sx;
33 case WL_OUTPUT_TRANSFORM_180:
34 *dx = width - sx, *dy = height - sy;
36 case WL_OUTPUT_TRANSFORM_270:
37 *dx = sy, *dy = width - sx;
42 // TODO: transform the cursor position with hot spot...!!!!!!
44 _e_pointer_rotation_apply(E_Pointer *ptr)
47 int x1, y1, x2, y2, dx, dy;
48 int32_t width, height;
49 int cursor_w, cursor_h;
54 EINA_SAFETY_ON_NULL_RETURN(ptr);
55 if (!ptr->o_ptr) return;
57 ec = e_comp_object_client_get(ptr->o_ptr);
58 EINA_SAFETY_ON_NULL_RETURN(ec);
60 rotation = ptr->rotation;
62 evas_object_geometry_get(ec->frame, NULL, NULL, &cursor_w, &cursor_h);
64 if ((rotation == 0) || (rotation % 90 != 0) || (rotation / 90 > 3))
66 evas_object_map_set(ec->frame, NULL);
67 evas_object_map_enable_set(ec->frame, EINA_FALSE);
77 transform = WL_OUTPUT_TRANSFORM_90;
82 transform = WL_OUTPUT_TRANSFORM_180;
85 transform = WL_OUTPUT_TRANSFORM_270;
90 transform = WL_OUTPUT_TRANSFORM_NORMAL;
94 map = evas_map_new(4);
95 evas_map_util_points_populate_from_geometry(map,
104 _e_pointer_map_transform(width, height, transform,
106 evas_map_point_image_uv_set(map, 0, dx, dy);
108 _e_pointer_map_transform(width, height, transform,
110 evas_map_point_image_uv_set(map, 1, dx, dy);
112 _e_pointer_map_transform(width, height, transform,
114 evas_map_point_image_uv_set(map, 2, dx, dy);
116 _e_pointer_map_transform(width, height, transform,
118 evas_map_point_image_uv_set(map, 3, dx, dy);
120 evas_object_map_set(ec->frame, map);
121 evas_object_map_enable_set(ec->frame, map ? EINA_TRUE : EINA_FALSE);
127 _e_pointer_cb_free(E_Pointer *ptr)
129 _ptrs = eina_list_remove(_ptrs, ptr);
137 _initted = EINA_TRUE;
142 e_pointer_shutdown(void)
144 _initted = EINA_FALSE;
149 e_pointer_canvas_new(Ecore_Evas *ee, Eina_Bool filled)
151 E_Pointer *ptr = NULL;
153 EINA_SAFETY_ON_FALSE_RETURN_VAL(ee, NULL);
154 if (!_initted) return NULL;
156 /* allocate space for new pointer */
157 if (!(ptr = E_OBJECT_ALLOC(E_Pointer, E_POINTER_TYPE, _e_pointer_cb_free)))
160 /* set default pointer properties */
161 ptr->canvas = EINA_TRUE;
162 ptr->w = ptr->h = e_config->cursor_size;
163 ptr->e_cursor = e_config->use_e_cursor;
166 ptr->evas = ecore_evas_get(ee);
168 /* append this pointer to the list */
169 _ptrs = eina_list_append(_ptrs, ptr);
175 e_pointer_object_set(E_Pointer *ptr, Evas_Object *obj, int x, int y)
179 EINA_SAFETY_ON_NULL_RETURN(ptr);
181 /* don't show cursor if in hidden mode */
182 if ((!e_config->show_cursor) || (!e_comp_wl->ptr.enabled))
188 /* hide and unset the existed ptr->o_ptr */
191 ec = e_comp_object_client_get(ptr->o_ptr);
192 if ((ec) && (!e_object_is_del(E_OBJECT(ec))))
195 ec->visible = EINA_FALSE;
196 ec->comp_data->mapped = EINA_FALSE;
197 ec->override = 1; /* ignore the previous cursor_ec */
200 /* hide cursor object */
201 evas_object_hide(ptr->o_ptr);
203 ptr->device = E_POINTER_NONE;
206 /* update the hot spot of the cursor */
210 /* if obj is not null, set the obj to ptr->o_ptr */
213 ec = e_comp_object_client_get(obj);
214 if (ec && e_pixmap_usable_get(ec->pixmap))
217 ec->visible = EINA_TRUE;
218 evas_object_geometry_set(ec->frame, ec->x, ec->y, ec->w, ec->h);
219 ec->comp_data->mapped = EINA_TRUE;
220 ec->override = 0; /* do not ignore the cursor_ec to set the image object */
225 /* apply the cursor obj rotation */
226 _e_pointer_rotation_apply(ptr);
228 /* move the pointer to the current position */
229 _e_pointer_position_update(ptr);
231 /* show cursor object */
232 evas_object_show(obj);
237 e_pointer_touch_move(E_Pointer *ptr, int x, int y)
239 EINA_SAFETY_ON_NULL_RETURN(ptr);
241 if (!e_config->show_cursor) return;
242 if (!ptr->o_ptr) return;
243 if (!evas_object_visible_get(ptr->o_ptr)) return;
245 /* save the current position */
249 if (ptr->device != E_POINTER_TOUCH) ptr->device = E_POINTER_TOUCH;
251 _e_pointer_rotation_apply(ptr);
252 _e_pointer_position_update(ptr);
256 e_pointer_mouse_move(E_Pointer *ptr, int x, int y)
258 EINA_SAFETY_ON_NULL_RETURN(ptr);
260 if (!e_config->show_cursor) return;
261 if (!ptr->o_ptr) return;
262 if (!evas_object_visible_get(ptr->o_ptr)) return;
264 /* save the current position */
268 if (ptr->device != E_POINTER_MOUSE) ptr->device = E_POINTER_MOUSE;
270 _e_pointer_rotation_apply(ptr);
271 _e_pointer_position_update(ptr);
275 e_pointer_hide(E_Pointer *ptr)
277 EINA_SAFETY_ON_NULL_RETURN(ptr);
278 if (ptr->o_ptr) return;
280 evas_object_hide(ptr->o_ptr);
284 e_pointer_is_hidden(E_Pointer *ptr)
286 EINA_SAFETY_ON_NULL_RETURN_VAL(ptr, EINA_TRUE);
288 if (!e_config->show_cursor) return EINA_TRUE;
289 if (ptr->o_ptr && evas_object_visible_get(ptr->o_ptr)) return EINA_FALSE;
295 e_pointer_rotation_set(E_Pointer *ptr, int rotation)
298 Ecore_Drm_Device *dev;
300 ptr->rotation = rotation;
302 _e_pointer_rotation_apply(ptr);
303 _e_pointer_position_update(ptr);
305 EINA_LIST_FOREACH(ecore_drm_devices_get(), l, dev)
306 ecore_drm_device_pointer_rotation_set(dev, rotation);
310 e_pointer_position_get(E_Pointer *ptr, int *x, int *y)
312 EINA_SAFETY_ON_NULL_RETURN(ptr);
314 if (!e_config->show_cursor) return;
315 if (!ptr->o_ptr) return;
316 if (!evas_object_visible_get(ptr->o_ptr)) return;