4 static Eina_List *_ptrs = NULL;
5 static Eina_Bool _initted = EINA_FALSE;
8 _e_pointer_map_transform(int width, int height, uint32_t transform,
9 int sx, int sy, int *dx, int *dy)
13 case WL_OUTPUT_TRANSFORM_NORMAL:
17 case WL_OUTPUT_TRANSFORM_90:
18 *dx = height - sy, *dy = sx;
20 case WL_OUTPUT_TRANSFORM_180:
21 *dx = width - sx, *dy = height - sy;
23 case WL_OUTPUT_TRANSFORM_270:
24 *dx = sy, *dy = width - sx;
30 _e_pointer_rotation_apply(E_Pointer *ptr)
33 int x1, y1, x2, y2, dx, dy;
34 int32_t width, height;
35 int cursor_w, cursor_h;
37 int rot_x, rot_y, x, y;
43 EINA_SAFETY_ON_NULL_RETURN(ptr);
44 if (!ptr->o_ptr) return;
46 ec = e_comp_object_client_get(ptr->o_ptr);
47 EINA_SAFETY_ON_NULL_RETURN(ec);
51 rotation = ptr->rotation;
53 evas_object_geometry_get(ec->frame, NULL, NULL, &cursor_w, &cursor_h);
55 if ((rotation == 0) || (rotation % 90 != 0) || (rotation / 90 > 3))
57 evas_object_map_set(ec->frame, NULL);
58 evas_object_map_enable_set(ec->frame, EINA_FALSE);
59 evas_object_move(ec->frame, x, y);
65 awh = ((double)zone_w / (double)zone_h);
66 ahw = ((double)zone_h / (double)zone_w);
77 rot_y = ahw * (zone_w - x);
78 transform = WL_OUTPUT_TRANSFORM_90;
85 transform = WL_OUTPUT_TRANSFORM_180;
88 rot_x = awh * (zone_h - y);
90 transform = WL_OUTPUT_TRANSFORM_270;
95 transform = WL_OUTPUT_TRANSFORM_NORMAL;
99 if (ptr->device == E_POINTER_MOUSE)
101 ec->client.x = rot_x, ec->client.y = rot_y;
102 ec->x = rot_x, ec->y = rot_y;
107 map = evas_map_new(4);
108 evas_map_util_points_populate_from_geometry(map,
117 _e_pointer_map_transform(width, height, transform,
119 evas_map_point_image_uv_set(map, 0, dx, dy);
121 _e_pointer_map_transform(width, height, transform,
123 evas_map_point_image_uv_set(map, 1, dx, dy);
125 _e_pointer_map_transform(width, height, transform,
127 evas_map_point_image_uv_set(map, 2, dx, dy);
129 _e_pointer_map_transform(width, height, transform,
131 evas_map_point_image_uv_set(map, 3, dx, dy);
133 evas_object_map_set(ec->frame, map);
134 evas_object_map_enable_set(ec->frame, map ? EINA_TRUE : EINA_FALSE);
140 _e_pointer_cb_free(E_Pointer *ptr)
142 _ptrs = eina_list_remove(_ptrs, ptr);
150 _initted = EINA_TRUE;
155 e_pointer_shutdown(void)
157 _initted = EINA_FALSE;
162 e_pointer_canvas_new(Ecore_Evas *ee, Eina_Bool filled)
164 E_Pointer *ptr = NULL;
166 EINA_SAFETY_ON_FALSE_RETURN_VAL(ee, NULL);
167 if (!_initted) return NULL;
169 /* allocate space for new pointer */
170 if (!(ptr = E_OBJECT_ALLOC(E_Pointer, E_POINTER_TYPE, _e_pointer_cb_free)))
173 /* set default pointer properties */
174 ptr->canvas = EINA_TRUE;
175 ptr->w = ptr->h = e_config->cursor_size;
176 ptr->e_cursor = e_config->use_e_cursor;
179 ptr->evas = ecore_evas_get(ee);
181 /* append this pointer to the list */
182 _ptrs = eina_list_append(_ptrs, ptr);
188 e_pointer_object_set(E_Pointer *ptr, Evas_Object *obj, int x, int y)
192 EINA_SAFETY_ON_NULL_RETURN(ptr);
194 /* don't show cursor if in hidden mode */
195 if ((!e_config->show_cursor) || (!e_comp_wl->ptr.enabled))
201 /* hide and unset the existed ptr->o_ptr */
204 ec = e_comp_object_client_get(ptr->o_ptr);
208 ec->visible = EINA_FALSE;
209 ec->comp_data->mapped = EINA_FALSE;
210 ec->override = 1; /* ignore the previous cursor_ec */
213 /* hide cursor object */
214 evas_object_hide(ptr->o_ptr);
216 ptr->device = E_POINTER_NONE;
219 /* if obj is not null, set the obj to ptr->o_ptr */
222 ec = e_comp_object_client_get(obj);
226 ec->visible = EINA_TRUE;
227 ec->comp_data->mapped = EINA_TRUE;
228 ec->override = 0; /* do not ignore the cursor_ec to set the image object */
231 /* apply the cursor obj rotation */
232 _e_pointer_rotation_apply(ptr);
234 /* move the pointer to the current position */
235 evas_object_move(obj, ptr->x, ptr->y);
237 /* show cursor object */
238 evas_object_show(obj);
244 e_pointer_touch_move(E_Pointer *ptr, int x, int y)
246 EINA_SAFETY_ON_NULL_RETURN(ptr);
248 if (!e_config->show_cursor) return;
249 if (!ptr->o_ptr) return;
250 if (!evas_object_visible_get(ptr->o_ptr)) return;
252 /* save the current position */
256 if (ptr->device != E_POINTER_TOUCH) ptr->device = E_POINTER_TOUCH;
258 _e_pointer_rotation_apply(ptr);
259 evas_object_move(ptr->o_ptr, ptr->x, ptr->y);
263 e_pointer_mouse_move(E_Pointer *ptr, int x, int y)
265 EINA_SAFETY_ON_NULL_RETURN(ptr);
267 if (!e_config->show_cursor) return;
268 if (!ptr->o_ptr) return;
269 if (!evas_object_visible_get(ptr->o_ptr)) return;
271 /* save the current position */
275 if (ptr->device != E_POINTER_MOUSE) ptr->device = E_POINTER_MOUSE;
277 _e_pointer_rotation_apply(ptr);
278 evas_object_move(ptr->o_ptr, ptr->x, ptr->y);
282 e_pointer_hide(E_Pointer *ptr)
284 EINA_SAFETY_ON_NULL_RETURN(ptr);
285 if (ptr->o_ptr) return;
287 evas_object_hide(ptr->o_ptr);
291 e_pointer_is_hidden(E_Pointer *ptr)
293 EINA_SAFETY_ON_NULL_RETURN_VAL(ptr, EINA_TRUE);
295 if (!e_config->show_cursor) return EINA_TRUE;
296 if (ptr->o_ptr && evas_object_visible_get(ptr->o_ptr)) return EINA_FALSE;
302 e_pointer_rotation_set(E_Pointer *ptr, int rotation)
304 ptr->rotation = rotation;
306 _e_pointer_rotation_apply(ptr);
307 evas_object_move(ptr->o_ptr, ptr->x, ptr->y);
311 e_pointer_position_get(E_Pointer *ptr, int *x, int *y)
313 EINA_SAFETY_ON_NULL_RETURN(ptr);
315 if (!e_config->show_cursor) return;
316 if (!ptr->o_ptr) return;
317 if (!evas_object_visible_get(ptr->o_ptr)) return;