Last pending patch on my disk :)
I quickly looked inside etk and see that it was not using
ecore_evas_cursor_set with framebuffer engine, because it wanted to set a
icon from an edje file. And in fact if we want to set an edje object as a
cursor we can't. Even if the code permit it.
So I propose to add ecore_evas_object_cursor_set to directly set any
evas_object as a cursor and modify ecore_evas_cursor_set to build itself the
evas_object_image. As a border effect, it reduce per ecore_evas engine
specific code.
This patch break ecore_evas_cursor_get API, but no real apps are using
it
inside e17 cvs.
Cedric
diff -Nrau -X exclude.cvs e17-clean/libs/ecore/src/lib/ecore_evas/ecore_evas.c e17-dev/libs/ecore/src/lib/ecore_evas/ecore_evas.c
--- e17-clean/libs/ecore/src/lib/ecore_evas/ecore_evas.c 2007-08-22 17:48:14.000000000 +0200
+++ e17-dev/libs/ecore/src/lib/ecore_evas/ecore_evas.c 2007-08-23 14:46:32.000000000 +0200
@@ -1262,20 +1262,60 @@
EAPI void
ecore_evas_cursor_set(Ecore_Evas *ee, const char *file, int layer, int hot_x, int hot_y)
{
+ Evas_Object *obj = NULL;
+
+ if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
+ {
+ ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
+ "ecore_evas_cursor_set");
+ return;
+ }
+
+ if (file)
+ {
+ int x, y;
+
+ obj = evas_object_image_add(ee->evas);
+ evas_object_image_file_set(obj, file, NULL);
+ evas_object_image_size_get(obj, &x, &y);
+ evas_object_resize(obj, x, y);
+ evas_object_image_fill_set(obj, 0, 0, x, y);
+ }
+
+ IFC(ee, fn_object_cursor_set) (ee, obj, layer, hot_x, hot_y);
+ IFE;
+}
+
+/**
+ * Set the cursor of an Ecore_Evas
+ * @param ee The Ecore_Evas
+ * @param obj The Evas_Object for the cursor
+ * @param layer
+ * @param hot_x The x coordinate of the cursor's hot spot
+ * @param hot_y The y coordinate of the cursor's hot spot
+ *
+ * This function makes the mouse cursor over @p ee be the image specified by
+ * @p file. The actual point within the image that the mouse is at is specified
+ * by @p hot_x and @p hot_y, which are coordinates with respect to the top left
+ * corner of the cursor image.
+ */
+EAPI void
+ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y)
+{
if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
{
ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
"ecore_evas_cursor_set");
return;
}
- IFC(ee, fn_cursor_set) (ee, file, layer, hot_x, hot_y);
+ IFC(ee, fn_object_cursor_set) (ee, obj, layer, hot_x, hot_y);
IFE;
}
/**
* Get information about an Ecore_Evas' cursor
* @param ee The Ecore_Evas to set
- * @param file A pointer to a string to place the cursor file name in.
+ * @param obj A pointer to an Evas_Object to place the cursor Evas_Object.
* @param layer A pointer to an int to place the cursor's layer in..
* @param hot_x A pointer to an int to place the cursor's hot_x coordinate in.
* @param hot_y A pointer to an int to place the cursor's hot_y coordinate in.
@@ -1283,7 +1323,7 @@
* This function queries information about an Ecore_Evas' cursor.
*/
EAPI void
-ecore_evas_cursor_get(Ecore_Evas *ee, char **file, int *layer, int *hot_x, int *hot_y)
+ecore_evas_cursor_get(Ecore_Evas *ee, Evas_Object **obj, int *layer, int *hot_x, int *hot_y)
{
if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
{
@@ -1291,7 +1331,7 @@
"ecore_evas_cursor_get");
return;
}
- if (file) *file = ee->prop.cursor.file;
+ if (obj) *obj = ee->prop.cursor.object;
if (layer) *layer = ee->prop.cursor.layer;
if (hot_x) *hot_x = ee->prop.cursor.hot.x;
if (hot_y) *hot_y = ee->prop.cursor.hot.y;
@@ -1814,7 +1854,6 @@
if (ee->prop.title) free(ee->prop.title);
if (ee->prop.name) free(ee->prop.name);
if (ee->prop.clas) free(ee->prop.clas);
- if (ee->prop.cursor.file) free(ee->prop.cursor.file);
if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
if (ee->evas) evas_free(ee->evas);
ee->data = NULL;
@@ -1823,7 +1862,6 @@
ee->prop.title = NULL;
ee->prop.name = NULL;
ee->prop.clas = NULL;
- ee->prop.cursor.file = NULL;
ee->prop.cursor.object = NULL;
ee->evas = NULL;
if (ee->engine.idle_flush_timer)
diff -Nrau -X exclude.cvs e17-clean/libs/ecore/src/lib/ecore_evas/ecore_evas_directfb.c e17-dev/libs/ecore/src/lib/ecore_evas/ecore_evas_directfb.c
--- e17-clean/libs/ecore/src/lib/ecore_evas/ecore_evas_directfb.c 2007-06-20 13:46:54.000000000 +0200
+++ e17-dev/libs/ecore/src/lib/ecore_evas/ecore_evas_directfb.c 2007-08-23 14:48:36.000000000 +0200
@@ -416,42 +416,40 @@
ecore_directfb_window_shaped_set(ee->engine.directfb.window, 1);
else
ecore_directfb_window_shaped_set(ee->engine.directfb.window, 0);
-
}
static void
-_ecore_evas_directfb_cursor_set(Ecore_Evas *ee, const char *file, int layer __UNUSED__, int hot_x, int hot_y)
+_ecore_evas_directfb_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y)
{
- int x, y;
-
- if (!file)
+ int x, y;
+
+ if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
+
+ if (obj == NULL)
{
- if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
- if (ee->prop.cursor.file) free(ee->prop.cursor.file);
ee->prop.cursor.object = NULL;
- ee->prop.cursor.file = NULL;
ee->prop.cursor.layer = 0;
ee->prop.cursor.hot.x = 0;
ee->prop.cursor.hot.y = 0;
+
ecore_directfb_window_cursor_show(ee->engine.directfb.window, 1);
- return;
-
+
+ return;
}
- ecore_directfb_window_cursor_show(ee->engine.directfb.window, 0);
- if (!ee->prop.cursor.object) ee->prop.cursor.object = evas_object_image_add(ee->evas);
- if (ee->prop.cursor.file) free(ee->prop.cursor.file);
- ee->prop.cursor.file = strdup(file);
+
+ ee->prop.cursor.object = obj;
ee->prop.cursor.layer = layer;
ee->prop.cursor.hot.x = hot_x;
ee->prop.cursor.hot.y = hot_y;
+
+ ecore_directfb_window_cursor_show(ee->engine.directfb.window, 0);
+
evas_pointer_output_xy_get(ee->evas, &x, &y);
evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
evas_object_color_set(ee->prop.cursor.object, 255, 255, 255, 255);
- evas_object_move(ee->prop.cursor.object,x - ee->prop.cursor.hot.x,y - ee->prop.cursor.hot.y);
- evas_object_image_file_set(ee->prop.cursor.object, ee->prop.cursor.file, NULL);
- evas_object_image_size_get(ee->prop.cursor.object, &x, &y);
- evas_object_resize(ee->prop.cursor.object, x, y);
- evas_object_image_fill_set(ee->prop.cursor.object, 0, 0, x, y);
+ evas_object_move(ee->prop.cursor.object,
+ x - ee->prop.cursor.hot.x,
+ y - ee->prop.cursor.hot.y);
evas_object_pass_events_set(ee->prop.cursor.object, 1);
if (evas_pointer_inside_get(ee->evas))
evas_object_show(ee->prop.cursor.object);
@@ -537,7 +535,7 @@
NULL, /* size max */
NULL, /* size base */
NULL, /* size step */
- _ecore_evas_directfb_cursor_set, /* cursor set */
+ _ecore_evas_directfb_object_cursor_set, /* set cursor to an evas object */
NULL, /* layer set */
_ecore_evas_directfb_focus_set, /* focus */
NULL, /* iconified */
diff -Nrau -X exclude.cvs e17-clean/libs/ecore/src/lib/ecore_evas/ecore_evas_fb.c e17-dev/libs/ecore/src/lib/ecore_evas/ecore_evas_fb.c
--- e17-clean/libs/ecore/src/lib/ecore_evas/ecore_evas_fb.c 2007-08-06 16:51:03.000000000 +0200
+++ e17-dev/libs/ecore/src/lib/ecore_evas/ecore_evas_fb.c 2007-08-23 14:50:48.000000000 +0200
@@ -408,37 +408,33 @@
}
static void
-_ecore_evas_cursor_set(Ecore_Evas *ee, const char *file, int layer, int hot_x, int hot_y)
+_ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y)
{
- int x, y;
-
- if (!file)
+ int x, y;
+
+ if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
+
+ if (obj == NULL)
{
- if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
- if (ee->prop.cursor.file) free(ee->prop.cursor.file);
ee->prop.cursor.object = NULL;
- ee->prop.cursor.file = NULL;
ee->prop.cursor.layer = 0;
ee->prop.cursor.hot.x = 0;
ee->prop.cursor.hot.y = 0;
+
return;
}
- if (!ee->prop.cursor.object) ee->prop.cursor.object = evas_object_image_add(ee->evas);
- if (ee->prop.cursor.file) free(ee->prop.cursor.file);
- ee->prop.cursor.file = strdup(file);
+
+ ee->prop.cursor.object = obj;
ee->prop.cursor.layer = layer;
ee->prop.cursor.hot.x = hot_x;
ee->prop.cursor.hot.y = hot_y;
+
evas_pointer_output_xy_get(ee->evas, &x, &y);
evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
evas_object_color_set(ee->prop.cursor.object, 255, 255, 255, 255);
- evas_object_move(ee->prop.cursor.object,
- x - ee->prop.cursor.hot.x,
- y - ee->prop.cursor.hot.y);
- evas_object_image_file_set(ee->prop.cursor.object, ee->prop.cursor.file, NULL);
- evas_object_image_size_get(ee->prop.cursor.object, &x, &y);
- evas_object_resize(ee->prop.cursor.object, x, y);
- evas_object_image_fill_set(ee->prop.cursor.object, 0, 0, x, y);
+ evas_object_move(ee->prop.cursor.object,
+ x - ee->prop.cursor.hot.x,
+ y - ee->prop.cursor.hot.y);
evas_object_pass_events_set(ee->prop.cursor.object, 1);
if (evas_pointer_inside_get(ee->evas))
evas_object_show(ee->prop.cursor.object);
@@ -551,7 +547,7 @@
NULL,
NULL,
NULL,
- _ecore_evas_cursor_set,
+ _ecore_evas_object_cursor_set,
NULL,
NULL,
NULL,
diff -Nrau -X exclude.cvs e17-clean/libs/ecore/src/lib/ecore_evas/Ecore_Evas.h e17-dev/libs/ecore/src/lib/ecore_evas/Ecore_Evas.h
--- e17-clean/libs/ecore/src/lib/ecore_evas/Ecore_Evas.h 2007-07-16 20:17:59.000000000 +0200
+++ e17-dev/libs/ecore/src/lib/ecore_evas/Ecore_Evas.h 2007-08-23 14:31:16.000000000 +0200
@@ -178,7 +178,8 @@
EAPI void ecore_evas_size_step_set(Ecore_Evas *ee, int w, int h);
EAPI void ecore_evas_size_step_get(Ecore_Evas *ee, int *w, int *h);
EAPI void ecore_evas_cursor_set(Ecore_Evas *ee, const char *file, int layer, int hot_x, int hot_y);
-EAPI void ecore_evas_cursor_get(Ecore_Evas *ee, char **file, int *layer, int *hot_x, int *hot_y);
+EAPI void ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y);
+EAPI void ecore_evas_cursor_get(Ecore_Evas *ee, Evas_Object **obj, int *layer, int *hot_x, int *hot_y);
EAPI void ecore_evas_layer_set(Ecore_Evas *ee, int layer);
EAPI int ecore_evas_layer_get(Ecore_Evas *ee);
EAPI void ecore_evas_focus_set(Ecore_Evas *ee, int on);
diff -Nrau -X exclude.cvs e17-clean/libs/ecore/src/lib/ecore_evas/ecore_evas_private.h e17-dev/libs/ecore/src/lib/ecore_evas/ecore_evas_private.h
--- e17-clean/libs/ecore/src/lib/ecore_evas/ecore_evas_private.h 2007-07-04 15:00:23.000000000 +0200
+++ e17-dev/libs/ecore/src/lib/ecore_evas/ecore_evas_private.h 2007-08-23 14:51:03.000000000 +0200
@@ -101,7 +101,7 @@
void (*fn_size_max_set) (Ecore_Evas *ee, int w, int h);
void (*fn_size_base_set) (Ecore_Evas *ee, int w, int h);
void (*fn_size_step_set) (Ecore_Evas *ee, int w, int h);
- void (*fn_cursor_set) (Ecore_Evas *ee, const char *file, int layer, int hot_x, int hot_y);
+ void (*fn_object_cursor_set) (Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y);
void (*fn_layer_set) (Ecore_Evas *ee, int layer);
void (*fn_focus_set) (Ecore_Evas *ee, int on);
void (*fn_iconified_set) (Ecore_Evas *ee, int on);
@@ -207,7 +207,6 @@
step;
struct {
Evas_Object *object;
- char *file;
int layer;
struct {
int x, y;
diff -Nrau -X exclude.cvs e17-clean/libs/ecore/src/lib/ecore_evas/ecore_evas_sdl.c e17-dev/libs/ecore/src/lib/ecore_evas/ecore_evas_sdl.c
--- e17-clean/libs/ecore/src/lib/ecore_evas/ecore_evas_sdl.c 2007-07-16 09:23:11.000000000 +0200
+++ e17-dev/libs/ecore/src/lib/ecore_evas/ecore_evas_sdl.c 2007-09-15 17:14:25.000000000 +0200
@@ -335,37 +335,33 @@
}
static void
-_ecore_evas_cursor_set(Ecore_Evas *ee, const char *file, int layer, int hot_x, int hot_y)
+_ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y)
{
- int x, y;
+ int x, y;
- if (!file)
+ if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
+
+ if (obj == NULL)
{
- if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
- if (ee->prop.cursor.file) free(ee->prop.cursor.file);
ee->prop.cursor.object = NULL;
- ee->prop.cursor.file = NULL;
ee->prop.cursor.layer = 0;
ee->prop.cursor.hot.x = 0;
ee->prop.cursor.hot.y = 0;
+
return;
}
- if (!ee->prop.cursor.object) ee->prop.cursor.object = evas_object_image_add(ee->evas);
- if (ee->prop.cursor.file) free(ee->prop.cursor.file);
- ee->prop.cursor.file = strdup(file);
+
+ ee->prop.cursor.object = obj;
ee->prop.cursor.layer = layer;
ee->prop.cursor.hot.x = hot_x;
ee->prop.cursor.hot.y = hot_y;
+
evas_pointer_output_xy_get(ee->evas, &x, &y);
evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
evas_object_color_set(ee->prop.cursor.object, 255, 255, 255, 255);
evas_object_move(ee->prop.cursor.object,
- x - ee->prop.cursor.hot.x,
- y - ee->prop.cursor.hot.y);
- evas_object_image_file_set(ee->prop.cursor.object, ee->prop.cursor.file, NULL);
- evas_object_image_size_get(ee->prop.cursor.object, &x, &y);
- evas_object_resize(ee->prop.cursor.object, x, y);
- evas_object_image_fill_set(ee->prop.cursor.object, 0, 0, x, y);
+ x - ee->prop.cursor.hot.x,
+ y - ee->prop.cursor.hot.y);
evas_object_pass_events_set(ee->prop.cursor.object, 1);
if (evas_pointer_inside_get(ee->evas))
evas_object_show(ee->prop.cursor.object);
@@ -404,7 +400,7 @@
NULL,
NULL,
NULL,
- _ecore_evas_cursor_set,
+ _ecore_evas_object_cursor_set,
NULL,
NULL,
NULL,
@@ -430,7 +426,6 @@
name = ecore_evas_sdl_default;
rmethod = evas_render_method_lookup("software_sdl");
- fprintf(stderr, "rmethod: %i\n", rmethod);
if (!rmethod) return NULL;
if (!ecore_sdl_init(name)) return NULL;
diff -Nrau -X exclude.cvs e17-clean/libs/ecore/src/lib/ecore_evas/ecore_evas_x.c e17-dev/libs/ecore/src/lib/ecore_evas/ecore_evas_x.c
--- e17-clean/libs/ecore/src/lib/ecore_evas/ecore_evas_x.c 2007-08-22 17:48:14.000000000 +0200
+++ e17-dev/libs/ecore/src/lib/ecore_evas/ecore_evas_x.c 2007-08-23 14:47:05.000000000 +0200
@@ -2086,39 +2086,37 @@
}
static void
-_ecore_evas_x_cursor_set(Ecore_Evas *ee, const char *file, int layer, int hot_x, int hot_y)
+_ecore_evas_x_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y)
{
- int x, y;
+ int x, y;
- if (!file)
+ if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
+
+ if (obj == NULL)
{
- if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
- if (ee->prop.cursor.file) free(ee->prop.cursor.file);
ee->prop.cursor.object = NULL;
- ee->prop.cursor.file = NULL;
ee->prop.cursor.layer = 0;
ee->prop.cursor.hot.x = 0;
ee->prop.cursor.hot.y = 0;
+
ecore_x_window_cursor_show(ee->engine.x.win, 1);
- return;
+
+ return ;
}
- ecore_x_window_cursor_show(ee->engine.x.win, 0);
- if (!ee->prop.cursor.object) ee->prop.cursor.object = evas_object_image_add(ee->evas);
- if (ee->prop.cursor.file) free(ee->prop.cursor.file);
- ee->prop.cursor.file = strdup(file);
+
+ ee->prop.cursor.object = obj;
ee->prop.cursor.layer = layer;
ee->prop.cursor.hot.x = hot_x;
ee->prop.cursor.hot.y = hot_y;
+
+ ecore_x_window_cursor_show(ee->engine.x.win, 0);
+
evas_pointer_output_xy_get(ee->evas, &x, &y);
evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
evas_object_color_set(ee->prop.cursor.object, 255, 255, 255, 255);
evas_object_move(ee->prop.cursor.object,
x - ee->prop.cursor.hot.x,
y - ee->prop.cursor.hot.y);
- evas_object_image_file_set(ee->prop.cursor.object, ee->prop.cursor.file, NULL);
- evas_object_image_size_get(ee->prop.cursor.object, &x, &y);
- evas_object_resize(ee->prop.cursor.object, x, y);
- evas_object_image_fill_set(ee->prop.cursor.object, 0, 0, x, y);
evas_object_pass_events_set(ee->prop.cursor.object, 1);
if (evas_pointer_inside_get(ee->evas))
evas_object_show(ee->prop.cursor.object);
@@ -2489,7 +2487,7 @@
_ecore_evas_x_size_max_set,
_ecore_evas_x_size_base_set,
_ecore_evas_x_size_step_set,
- _ecore_evas_x_cursor_set,
+ _ecore_evas_x_object_cursor_set,
_ecore_evas_x_layer_set,
_ecore_evas_x_focus_set,
_ecore_evas_x_iconified_set,
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel