2005-02-07 05:51:09 -08:00
|
|
|
/*
|
|
|
|
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
|
|
|
*/
|
2004-11-24 19:37:45 -08:00
|
|
|
#include "e.h"
|
|
|
|
|
2005-08-16 18:35:48 -07:00
|
|
|
static Evas_List *_e_pointers = NULL;
|
|
|
|
|
|
|
|
static void _e_pointer_free(E_Pointer *p);
|
|
|
|
|
2004-11-24 19:37:45 -08:00
|
|
|
/* externally accessible functions */
|
2005-08-16 18:35:48 -07:00
|
|
|
E_Pointer *
|
|
|
|
e_pointer_window_set(Ecore_X_Window win)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2005-08-16 18:35:48 -07:00
|
|
|
Evas_Engine_Info_Buffer *einfo;
|
|
|
|
E_Pointer *p;
|
|
|
|
int rmethod;
|
|
|
|
Evas_Coord w, h;
|
|
|
|
|
|
|
|
rmethod = evas_render_method_lookup("buffer");
|
|
|
|
if (!rmethod) return NULL;
|
|
|
|
|
|
|
|
p = E_OBJECT_ALLOC(E_Pointer, E_POINTER_TYPE, _e_pointer_free);
|
|
|
|
if (!p) return NULL;
|
2005-01-14 11:24:57 -08:00
|
|
|
|
2005-08-16 18:35:48 -07:00
|
|
|
p->win = win;
|
|
|
|
|
|
|
|
p->w = 10;
|
|
|
|
p->h = 10;
|
|
|
|
|
|
|
|
/* create evas */
|
|
|
|
p->evas = evas_new();
|
|
|
|
evas_output_method_set(p->evas, rmethod);
|
|
|
|
evas_output_size_set(p->evas, p->w, p->h);
|
|
|
|
evas_output_viewport_set(p->evas, 0, 0, p->w, p->h);
|
2004-11-24 19:37:45 -08:00
|
|
|
|
2005-08-16 18:35:48 -07:00
|
|
|
p->pixels = calloc(p->w * p->h, sizeof(int));
|
|
|
|
|
|
|
|
einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(p->evas);
|
|
|
|
if (einfo)
|
|
|
|
{
|
|
|
|
einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32;
|
|
|
|
einfo->info.dest_buffer = p->pixels;
|
|
|
|
einfo->info.dest_buffer_row_bytes = p->w * sizeof(int);
|
|
|
|
einfo->info.use_color_key = 0;
|
|
|
|
einfo->info.alpha_threshold = 0;
|
|
|
|
einfo->info.func.new_update_region = NULL;
|
|
|
|
einfo->info.func.free_update_region = NULL;
|
|
|
|
evas_engine_info_set(p->evas, (Evas_Engine_Info *)einfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set the pointer edje */
|
|
|
|
p->evas_object = edje_object_add(p->evas);
|
2005-01-04 06:07:59 -08:00
|
|
|
if (ecore_x_cursor_color_supported_get())
|
2005-05-25 01:08:44 -07:00
|
|
|
{
|
2005-08-16 18:35:48 -07:00
|
|
|
if (!e_theme_edje_object_set(p->evas_object,
|
|
|
|
"base/theme/pointer",
|
|
|
|
"pointer/enlightenment/default"))
|
|
|
|
{
|
|
|
|
/* error */
|
|
|
|
printf("ERROR: No default theme for pointer!\n");
|
|
|
|
if (!e_theme_edje_object_set(p->evas_object,
|
|
|
|
"base/theme/pointer",
|
|
|
|
"pointer/enlightenment/mono"))
|
|
|
|
{
|
|
|
|
/* error */
|
|
|
|
printf("ERROR: No mono theme for pointer!\n");
|
|
|
|
}
|
|
|
|
}
|
2005-05-25 01:08:44 -07:00
|
|
|
}
|
2005-01-04 06:07:59 -08:00
|
|
|
else
|
2005-05-25 01:08:44 -07:00
|
|
|
{
|
2005-08-16 18:35:48 -07:00
|
|
|
if (!e_theme_edje_object_set(p->evas_object,
|
|
|
|
"base/theme/pointer",
|
|
|
|
"pointer/enlightenment/mono"))
|
|
|
|
{
|
|
|
|
/* error */
|
|
|
|
printf("ERROR: No mono theme for pointer!\n");
|
|
|
|
}
|
2005-05-25 01:08:44 -07:00
|
|
|
}
|
2005-08-16 18:35:48 -07:00
|
|
|
edje_object_calc_force(p->evas_object);
|
|
|
|
edje_object_size_min_calc(p->evas_object, &w, &h);
|
|
|
|
if ((w == 0) || (h == 0))
|
|
|
|
{
|
|
|
|
/* error */
|
|
|
|
printf("The size of the pointer is 0!\n");
|
|
|
|
w = h = 10;
|
|
|
|
}
|
|
|
|
p->w = w;
|
|
|
|
p->h = h;
|
2004-11-24 19:37:45 -08:00
|
|
|
|
2005-08-16 18:35:48 -07:00
|
|
|
/* resize evas */
|
|
|
|
evas_output_size_set(p->evas, p->w, p->h);
|
|
|
|
evas_output_viewport_set(p->evas, 0, 0, p->w, p->h);
|
|
|
|
evas_damage_rectangle_add(p->evas, 0, 0, p->w, p->h);
|
2004-11-24 19:37:45 -08:00
|
|
|
|
2005-08-16 18:35:48 -07:00
|
|
|
free(p->pixels);
|
|
|
|
p->pixels = calloc(p->w * p->h, sizeof(int));
|
|
|
|
|
|
|
|
einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(p->evas);
|
|
|
|
if (einfo)
|
2005-05-25 01:08:44 -07:00
|
|
|
{
|
2005-08-16 18:35:48 -07:00
|
|
|
einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32;
|
|
|
|
einfo->info.dest_buffer = p->pixels;
|
|
|
|
einfo->info.dest_buffer_row_bytes = p->w * sizeof(int);
|
|
|
|
einfo->info.use_color_key = 0;
|
|
|
|
einfo->info.alpha_threshold = 0;
|
|
|
|
einfo->info.func.new_update_region = NULL;
|
|
|
|
einfo->info.func.free_update_region = NULL;
|
|
|
|
evas_engine_info_set(p->evas, (Evas_Engine_Info *)einfo);
|
2005-05-25 01:08:44 -07:00
|
|
|
}
|
2005-08-16 18:35:48 -07:00
|
|
|
|
|
|
|
/* init edje */
|
|
|
|
evas_object_move(p->evas_object, 0, 0);
|
|
|
|
evas_object_resize(p->evas_object, p->w, p->h);
|
|
|
|
evas_object_show(p->evas_object);
|
|
|
|
|
|
|
|
_e_pointers = evas_list_append(_e_pointers, p);
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
e_pointer_idler_before(void)
|
|
|
|
{
|
|
|
|
Evas_List *l;
|
|
|
|
|
|
|
|
for (l = _e_pointers; l; l = l->next)
|
2005-05-25 01:08:44 -07:00
|
|
|
{
|
2005-08-16 18:35:48 -07:00
|
|
|
E_Pointer *p;
|
|
|
|
Evas_List *updates;
|
|
|
|
|
|
|
|
p = l->data;
|
|
|
|
updates = evas_render_updates(p->evas);
|
|
|
|
if (updates)
|
|
|
|
{
|
|
|
|
Ecore_X_Cursor cur;
|
|
|
|
Evas_Coord w, h;
|
|
|
|
|
|
|
|
evas_render_updates_free(updates);
|
|
|
|
|
|
|
|
/* TODO: Resize evas if pointer changes */
|
|
|
|
evas_object_geometry_get(p->evas_object, NULL, NULL, &w, &h);
|
|
|
|
cur = ecore_x_cursor_new(p->win, p->pixels, p->w, p->h, 0, 0);
|
|
|
|
ecore_x_window_cursor_set(p->win, cur);
|
|
|
|
ecore_x_cursor_free(cur);
|
|
|
|
}
|
2005-05-25 01:08:44 -07:00
|
|
|
}
|
2005-08-16 18:35:48 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* local subsystem functions */
|
|
|
|
static void
|
|
|
|
_e_pointer_free(E_Pointer *p)
|
|
|
|
{
|
|
|
|
|
|
|
|
_e_pointers = evas_list_remove(_e_pointers, p);
|
|
|
|
|
|
|
|
/* create evas */
|
|
|
|
if (p->evas_object) evas_object_del(p->evas_object);
|
|
|
|
if (p->evas) evas_free(p->evas);
|
|
|
|
|
|
|
|
free(p->pixels);
|
|
|
|
free(p);
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|