5 static Eina_List *_ptrs = NULL;
6 static Eina_Bool _initted = EINA_FALSE;
9 static Eina_Bool override = EINA_FALSE;
11 /* move the cursor image with the calcaultion of the hot spot */
13 _e_pointer_position_update(E_Pointer *ptr)
17 int cursor_w, cursor_h;
20 if (!ptr->o_ptr) return;
22 ec = e_comp_object_client_get(ptr->o_ptr);
23 EINA_SAFETY_ON_NULL_RETURN(ec);
25 rotation = ptr->rotation;
27 evas_object_geometry_get(ec->frame, NULL, NULL, &cursor_w, &cursor_h);
32 nx = ptr->x - ptr->hot.x;
33 ny = ptr->y - ptr->hot.y;
36 nx = ptr->x - ptr->hot.y;
37 ny = ptr->y + ptr->hot.x - cursor_w;
40 nx = ptr->x + ptr->hot.x - cursor_w;
41 ny = ptr->y + ptr->hot.y - cursor_h;
44 nx = ptr->x + ptr->hot.y - cursor_h;
45 ny = ptr->y - ptr->hot.x;
48 nx = ptr->x - ptr->hot.x;
49 ny = ptr->y - ptr->hot.y;
54 e_comp_object_hwc_update_set(ptr->o_ptr, EINA_TRUE);
56 evas_object_move(ptr->o_ptr, nx, ny);
60 _e_pointer_object_rotation(E_Pointer *ptr)
67 EINA_SAFETY_ON_NULL_RETURN(ptr);
68 if (!ptr->o_ptr) return;
70 ec = e_comp_object_client_get(ptr->o_ptr);
71 EINA_SAFETY_ON_NULL_RETURN(ec);
73 rotation = ptr->rotation;
75 evas_object_geometry_get(ec->frame, &x, &y, &w, &h);
77 if ((rotation == 0) || (rotation % 90 != 0) || (rotation / 90 > 3))
79 evas_object_map_set(ec->frame, NULL);
80 evas_object_map_enable_set(ec->frame, EINA_FALSE);
84 map = evas_map_new(4);
85 evas_map_util_points_populate_from_object_full(map, ec->frame, 0);
86 evas_map_util_points_color_set(map, 255, 255, 255, 255);
90 else if (rotation == 270)
92 evas_map_util_rotate(map, rotation, x + (w/2), y + (h/2));
93 evas_map_util_object_move_sync_set(map, EINA_TRUE);
95 evas_object_map_set(ec->frame, map);
96 evas_object_map_enable_set(ec->frame, map ? EINA_TRUE : EINA_FALSE);
102 _e_pointer_hwc_rotation(E_Pointer *ptr)
106 if (!ptr->o_ptr) return;
108 ec = e_comp_object_client_get(ptr->o_ptr);
109 EINA_SAFETY_ON_NULL_RETURN(ec);
111 // TODO: roatation cursor buffer with pixman
114 // TODO: transform the cursor position with hot spot...!!!!!!
116 _e_pointer_rotation_apply(E_Pointer *ptr)
118 EINA_SAFETY_ON_NULL_RETURN(ptr);
121 _e_pointer_hwc_rotation(ptr);
123 _e_pointer_object_rotation(ptr);
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 if (ptr->o_ptr != obj)
201 ptr->hwc = EINA_FALSE;
203 /* hide cursor object */
204 evas_object_hide(ptr->o_ptr);
206 ptr->device = E_POINTER_NONE;
208 /* Current if e_pointer set rotation, it can't' use hwc.
209 if it can use hwc, comp override will be removed. */
210 if (ptr->rotation !=0 && override)
212 e_comp_override_del();
213 override = EINA_FALSE;
217 /* update the hot spot of the cursor */
221 /* if obj is not null, set the obj to ptr->o_ptr */
224 ec = e_comp_object_client_get(obj);
225 if (ec && e_pixmap_usable_get(ec->pixmap))
228 ec->visible = EINA_TRUE;
229 evas_object_geometry_set(ec->frame, ec->x, ec->y, ec->w, ec->h);
230 ec->comp_data->mapped = EINA_TRUE;
231 ec->override = 0; /* do not ignore the cursor_ec to set the image object */
233 if (e_comp_is_on_overlay(ec))
234 ptr->hwc = EINA_TRUE;
239 /* move the pointer to the current position */
240 _e_pointer_position_update(ptr);
242 /* apply the cursor obj rotation */
243 _e_pointer_rotation_apply(ptr);
245 /* Current if e_pointer set rotation, it can't' use hwc.
246 if it can use hwc, comp override will be removed. */
247 switch(ptr->rotation)
254 e_comp_override_add();
255 override = EINA_TRUE;
260 /* show cursor object */
261 evas_object_show(obj);
266 e_pointer_touch_move(E_Pointer *ptr, int x, int y)
268 EINA_SAFETY_ON_NULL_RETURN(ptr);
270 if (!e_config->show_cursor) return;
272 /* save the current position */
276 if (ptr->device != E_POINTER_TOUCH) ptr->device = E_POINTER_TOUCH;
278 _e_pointer_position_update(ptr);
282 e_pointer_mouse_move(E_Pointer *ptr, int x, int y)
284 EINA_SAFETY_ON_NULL_RETURN(ptr);
286 if (!e_config->show_cursor) return;
288 /* save the current position */
292 if (ptr->device != E_POINTER_MOUSE) ptr->device = E_POINTER_MOUSE;
294 _e_pointer_position_update(ptr);
298 e_pointer_hide(E_Pointer *ptr)
300 EINA_SAFETY_ON_NULL_RETURN(ptr);
301 if (!ptr->o_ptr) return;
302 if (!evas_object_visible_get(ptr->o_ptr)) return;
304 evas_object_hide(ptr->o_ptr);
306 /* Current if e_pointer set rotation, it can't' use hwc.
307 if it can use hwc, comp override will be removed. */
308 if (ptr->rotation !=0 && override)
310 e_comp_override_del();
311 override = EINA_FALSE;
316 e_pointer_is_hidden(E_Pointer *ptr)
318 EINA_SAFETY_ON_NULL_RETURN_VAL(ptr, EINA_TRUE);
320 if (!e_config->show_cursor) return EINA_TRUE;
321 if (ptr->o_ptr && evas_object_visible_get(ptr->o_ptr)) return EINA_FALSE;
327 e_pointer_rotation_set(E_Pointer *ptr, int rotation)
330 Ecore_Drm_Device *dev;
332 if (ptr->rotation == rotation) return;
334 ptr->rotation = rotation;
336 _e_pointer_position_update(ptr);
337 _e_pointer_rotation_apply(ptr);
339 EINA_LIST_FOREACH(ecore_drm_devices_get(), l, dev)
340 ecore_drm_device_pointer_rotation_set(dev, rotation);
342 /* ptr->rotation shouldn't include the screen rotation value */
343 if (e_comp->e_comp_screen->rotation > 0)
344 rotation = (e_comp->e_comp_screen->rotation + rotation) % 360;
346 /* Current if e_pointer set rotation, it can't' use hwc.
347 if it can use hwc, comp override will be removed. */
348 if ((!ptr->o_ptr) || (ptr->o_ptr && !evas_object_visible_get(ptr->o_ptr))) return;
355 e_comp_override_del();
356 override = EINA_FALSE;
364 e_comp_override_add();
365 override = EINA_TRUE;
372 e_pointer_position_get(E_Pointer *ptr, int *x, int *y)
374 EINA_SAFETY_ON_NULL_RETURN(ptr);
376 if (!e_config->show_cursor) return;
377 if (!ptr->o_ptr) return;
378 if (!evas_object_visible_get(ptr->o_ptr)) return;
385 e_pointer_hwc_set(E_Pointer *ptr, Eina_Bool set)
387 EINA_SAFETY_ON_FALSE_RETURN_VAL(ptr, EINA_FALSE);
388 EINA_SAFETY_ON_FALSE_RETURN_VAL(ptr->o_ptr, EINA_FALSE);
390 if (ptr->hwc == set) return EINA_TRUE;
396 e_comp_object_hwc_update_set(ptr->o_ptr, EINA_TRUE);
400 _e_pointer_position_update(ptr);
401 _e_pointer_rotation_apply(ptr);
408 e_pointer_get(E_Client *ec)
412 E_Client *ptr_ec = NULL;
414 if ((!ec) || (e_object_is_del(E_OBJECT(ec)))) return NULL;
416 EINA_LIST_FOREACH(_ptrs, l, ptr)
420 ptr_ec = e_comp_object_client_get(ptr->o_ptr);