More work on themeable cursor.

SVN revision: 16261
This commit is contained in:
sebastid 2005-08-21 23:37:28 +00:00 committed by sebastid
parent c9d59d2da3
commit 5519da900c
7 changed files with 194 additions and 70 deletions

View File

@ -5,41 +5,119 @@ images {
group { group {
name: "pointer/enlightenment/default"; name: "pointer/enlightenment/default";
min: 22 32;
max: 22 32;
parts { parts {
part { part {
name: "default"; name: "pointer";
type: IMAGE; type: IMAGE;
mouse_events: 0; mouse_events: 0;
description { description {
state: "default" 0.0; state: "default" 0.0;
min: 22 32; rel1 {
max: 22 32; relative: 0.0 0.0;
offset: 0 0;
}
rel2 {
relative: 0.68750 1.0;
offset: -1 -1;
}
image { image {
normal: "pointer.png"; normal: "pointer.png";
} }
} }
}
}
}
group {
name: "pointer/enlightenment/mono";
min: 16 24;
max: 16 24;
parts {
part {
name: "mono";
type: IMAGE;
mouse_events: 0;
description { description {
state: "default" 0.0; state: "test" 0.0;
min: 16 24; aspect: 0.75 1.0;
max: 16 24; rel1 {
relative: 0.0 0.0;
offset: 8 8;
}
rel2 {
relative: 0.0 0.0;
offset: 24 32;
}
image { image {
normal: "pointer_mono.png"; normal: "pointer_mono.png";
} }
} }
} }
part {
name: "hotspot";
type: SWALLOW;
mouse_events: 0;
description {
state: "default" 0.0;
visible: 0;
rel1 {
relative: 0.0 0.0;
offset: 1 2;
}
rel2 {
relative: 0.0 0.0;
offset: 2 3;
}
}
description {
state: "test" 0.0;
visible: 0;
rel1 {
relative: 0.0 0.0;
offset: 8 8;
}
rel2 {
relative: 0.0 0.0;
offset: 9 9;
}
}
}
}
programs {
program {
name: "test_hot";
signal: "test";
source: "";
action: STATE_SET "test" 0.0;
target: "hotspot";
}
program {
name: "test_pointer";
signal: "test";
source: "";
action: STATE_SET "test" 0.0;
target: "pointer";
}
}
}
group {
name: "pointer/enlightenment/mono";
parts {
part {
name: "pointer";
type: IMAGE;
mouse_events: 0;
description {
state: "default" 0.0;
aspect: 0.75 1.0;
image {
normal: "pointer_mono.png";
}
}
}
part {
name: "hotspot";
type: SWALLOW;
mouse_events: 0;
description {
state: "default" 0.0;
visible: 0;
rel1 {
relative: 0.0 0.0;
offset: 0 0;
}
rel2 {
relative: 0.0 0.0;
offset: 1 1;
}
}
}
} }
} }

View File

@ -298,6 +298,7 @@ e_config_init(void)
E_CONFIG_VAL(D, T, resize_info_follows, INT); /**/ E_CONFIG_VAL(D, T, resize_info_follows, INT); /**/
E_CONFIG_VAL(D, T, focus_last_focused_per_desktop, INT); /**/ E_CONFIG_VAL(D, T, focus_last_focused_per_desktop, INT); /**/
E_CONFIG_VAL(D, T, focus_revert_on_hide_or_close, INT); /**/ E_CONFIG_VAL(D, T, focus_revert_on_hide_or_close, INT); /**/
E_CONFIG_VAL(D, T, cursor_size, INT); /**/
e_config = e_config_domain_load("e", _e_config_edd); e_config = e_config_domain_load("e", _e_config_edd);
if (e_config) if (e_config)
@ -403,6 +404,7 @@ e_config_init(void)
e_config->resize_info_follows = 1; e_config->resize_info_follows = 1;
e_config->focus_last_focused_per_desktop = 1; e_config->focus_last_focused_per_desktop = 1;
e_config->focus_revert_on_hide_or_close = 1; e_config->focus_revert_on_hide_or_close = 1;
e_config->cursor_size = 32;
{ {
E_Config_Module *em; E_Config_Module *em;
@ -959,6 +961,7 @@ e_config_init(void)
E_CONFIG_LIMIT(e_config->resize_info_follows, 0, 1); E_CONFIG_LIMIT(e_config->resize_info_follows, 0, 1);
E_CONFIG_LIMIT(e_config->focus_last_focused_per_desktop, 0, 1); E_CONFIG_LIMIT(e_config->focus_last_focused_per_desktop, 0, 1);
E_CONFIG_LIMIT(e_config->focus_revert_on_hide_or_close, 0, 1); E_CONFIG_LIMIT(e_config->focus_revert_on_hide_or_close, 0, 1);
E_CONFIG_LIMIT(e_config->cursor_size, 0, 1024);
/* apply lang config - exception because config is loaded after intl setup */ /* apply lang config - exception because config is loaded after intl setup */

View File

@ -48,7 +48,7 @@ typedef Eet_Data_Descriptor E_Config_DD;
* defaults for e to work - started at 100 when we introduced this config * defaults for e to work - started at 100 when we introduced this config
* versioning feature * versioning feature
*/ */
#define E_CONFIG_FILE_VERSION 121 #define E_CONFIG_FILE_VERSION 122
#define E_EVAS_ENGINE_DEFAULT 0 #define E_EVAS_ENGINE_DEFAULT 0
#define E_EVAS_ENGINE_SOFTWARE_X11 1 #define E_EVAS_ENGINE_SOFTWARE_X11 1
@ -142,6 +142,7 @@ struct _E_Config
int resize_info_follows; int resize_info_follows;
int focus_last_focused_per_desktop; int focus_last_focused_per_desktop;
int focus_revert_on_hide_or_close; int focus_revert_on_hide_or_close;
int cursor_size;
}; };
struct _E_Config_Module struct _E_Config_Module

View File

@ -4589,6 +4589,51 @@ break;
#endif #endif
#undef HDL #undef HDL
/****************************************************************************/
#define HDL E_IPC_OP_CURSOR_SIZE_SET
#if (TYPE == E_REMOTE_OPTIONS)
OP("-cursor-size-set", 1, "Set the E cursor size", 0, HDL)
#elif (TYPE == E_REMOTE_OUT)
REQ_INT(atoi(params[0]), HDL);
#elif (TYPE == E_WM_IN)
START_INT(val, HDL);
e_config->cursor_size = val;
/* TODO: Update cursor size on screen! */
E_CONFIG_LIMIT(e_config->cursor_size, 0, 1024);
SAVE;
END_INT;
#elif (TYPE == E_REMOTE_IN)
#endif
#undef HDL
/****************************************************************************/
#define HDL E_IPC_OP_CURSOR_SIZE_GET
#if (TYPE == E_REMOTE_OPTIONS)
OP("-cursor-size-get", 0, "Get the E cursor size", 1, HDL)
#elif (TYPE == E_REMOTE_OUT)
REQ_NULL(HDL);
#elif (TYPE == E_WM_IN)
SEND_INT(e_config->cursor_size, E_IPC_OP_CURSOR_SIZE_GET_REPLY, HDL);
#elif (TYPE == E_REMOTE_IN)
#endif
#undef HDL
/****************************************************************************/
#define HDL E_IPC_OP_CURSOR_SIZE_GET_REPLY
#if (TYPE == E_REMOTE_OPTIONS)
#elif (TYPE == E_REMOTE_OUT)
#elif (TYPE == E_WM_IN)
#elif (TYPE == E_REMOTE_IN)
START_INT(val, HDL);
printf("REPLY: %d\n", val);
END_INT;
#endif
#undef HDL
/****************************************************************************/
#if 0 #if 0
} }
#endif #endif

View File

@ -222,3 +222,6 @@
#define E_IPC_OP_DESKTOP_NAME_DEL 222 #define E_IPC_OP_DESKTOP_NAME_DEL 222
#define E_IPC_OP_DESKTOP_NAME_LIST 223 #define E_IPC_OP_DESKTOP_NAME_LIST 223
#define E_IPC_OP_DESKTOP_NAME_LIST_REPLY 224 #define E_IPC_OP_DESKTOP_NAME_LIST_REPLY 224
#define E_IPC_OP_CURSOR_SIZE_SET 225
#define E_IPC_OP_CURSOR_SIZE_GET 226
#define E_IPC_OP_CURSOR_SIZE_GET_REPLY 227

View File

@ -5,6 +5,7 @@
static Evas_List *_e_pointers = NULL; static Evas_List *_e_pointers = NULL;
static void _e_pointer_cb_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info);
static void _e_pointer_free(E_Pointer *p); static void _e_pointer_free(E_Pointer *p);
/* externally accessible functions */ /* externally accessible functions */
@ -13,8 +14,8 @@ e_pointer_window_set(Ecore_X_Window win)
{ {
Evas_Engine_Info_Buffer *einfo; Evas_Engine_Info_Buffer *einfo;
E_Pointer *p; E_Pointer *p;
Evas_Object *o;
int rmethod; int rmethod;
Evas_Coord w, h;
rmethod = evas_render_method_lookup("buffer"); rmethod = evas_render_method_lookup("buffer");
if (!rmethod) return NULL; if (!rmethod) return NULL;
@ -24,8 +25,8 @@ e_pointer_window_set(Ecore_X_Window win)
p->win = win; p->win = win;
p->w = 10; p->w = e_config->cursor_size;
p->h = 10; p->h = e_config->cursor_size;
/* create evas */ /* create evas */
p->evas = evas_new(); p->evas = evas_new();
@ -49,16 +50,17 @@ e_pointer_window_set(Ecore_X_Window win)
} }
/* set the pointer edje */ /* set the pointer edje */
p->evas_object = edje_object_add(p->evas); o = edje_object_add(p->evas);
p->pointer_object = o;
if (ecore_x_cursor_color_supported_get()) if (ecore_x_cursor_color_supported_get())
{ {
if (!e_theme_edje_object_set(p->evas_object, if (!e_theme_edje_object_set(o,
"base/theme/pointer", "base/theme/pointer",
"pointer/enlightenment/default")) "pointer/enlightenment/default"))
{ {
/* error */ /* error */
printf("ERROR: No default theme for pointer!\n"); printf("ERROR: No default theme for pointer!\n");
if (!e_theme_edje_object_set(p->evas_object, if (!e_theme_edje_object_set(o,
"base/theme/pointer", "base/theme/pointer",
"pointer/enlightenment/mono")) "pointer/enlightenment/mono"))
{ {
@ -69,7 +71,7 @@ e_pointer_window_set(Ecore_X_Window win)
} }
else else
{ {
if (!e_theme_edje_object_set(p->evas_object, if (!e_theme_edje_object_set(o,
"base/theme/pointer", "base/theme/pointer",
"pointer/enlightenment/mono")) "pointer/enlightenment/mono"))
{ {
@ -77,42 +79,19 @@ e_pointer_window_set(Ecore_X_Window win)
printf("ERROR: No mono theme for pointer!\n"); printf("ERROR: No mono theme for pointer!\n");
} }
} }
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;
/* resize evas */ /* Create the hotspot object */
evas_output_size_set(p->evas, p->w, p->h); o = evas_object_rectangle_add(p->evas);
evas_output_viewport_set(p->evas, 0, 0, p->w, p->h); p->hot_object = o;
evas_damage_rectangle_add(p->evas, 0, 0, p->w, p->h); evas_object_event_callback_add(o,
EVAS_CALLBACK_MOVE,
free(p->pixels); _e_pointer_cb_move, p);
p->pixels = calloc(p->w * p->h, sizeof(int)); edje_object_part_swallow(p->pointer_object, "hotspot", o);
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);
}
/* init edje */ /* init edje */
evas_object_move(p->evas_object, 0, 0); evas_object_move(p->pointer_object, 0, 0);
evas_object_resize(p->evas_object, p->w, p->h); evas_object_resize(p->pointer_object, p->w, p->h);
evas_object_show(p->evas_object); evas_object_show(p->pointer_object);
_e_pointers = evas_list_append(_e_pointers, p); _e_pointers = evas_list_append(_e_pointers, p);
return p; return p;
@ -133,20 +112,29 @@ e_pointer_idler_before(void)
if (updates) if (updates)
{ {
Ecore_X_Cursor cur; Ecore_X_Cursor cur;
Evas_Coord w, h;
evas_render_updates_free(updates); cur = ecore_x_cursor_new(p->win, p->pixels, p->w, p->h, p->hot.x, p->hot.y);
/* 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_window_cursor_set(p->win, cur);
ecore_x_cursor_free(cur); ecore_x_cursor_free(cur);
evas_render_updates_free(updates);
} }
} }
} }
/* local subsystem functions */ /* local subsystem functions */
static void
_e_pointer_cb_move(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
{
E_Pointer *p;
Evas_Coord x, y;
p = data;
evas_object_geometry_get(p->hot_object, &x, &y, NULL, NULL);
p->hot.x = x;
p->hot.y = y;
}
static void static void
_e_pointer_free(E_Pointer *p) _e_pointer_free(E_Pointer *p)
{ {
@ -154,7 +142,8 @@ _e_pointer_free(E_Pointer *p)
_e_pointers = evas_list_remove(_e_pointers, p); _e_pointers = evas_list_remove(_e_pointers, p);
/* create evas */ /* create evas */
if (p->evas_object) evas_object_del(p->evas_object); if (p->pointer_object) evas_object_del(p->pointer_object);
if (p->hot_object) evas_object_del(p->hot_object);
if (p->evas) evas_free(p->evas); if (p->evas) evas_free(p->evas);
free(p->pixels); free(p->pixels);

View File

@ -16,12 +16,17 @@ struct _E_Pointer
E_Object e_obj_inherit; E_Object e_obj_inherit;
Evas *evas; Evas *evas;
Evas_Object *evas_object; Evas_Object *pointer_object;
Evas_Object *hot_object;
int *pixels; int *pixels;
Ecore_X_Window win; Ecore_X_Window win;
int w, h; int w, h;
struct {
int x, y;
} hot;
}; };
EAPI E_Pointer *e_pointer_window_set(Ecore_X_Window win); EAPI E_Pointer *e_pointer_window_set(Ecore_X_Window win);