forked from enlightenment/enlightenment
fixingup of pointer code to fallback a bit simpler - on demand buffer canvas
creation now and deletion - and entry widget displays "entry" cursor :) SVN revision: 24928
This commit is contained in:
parent
28a1a8bf34
commit
90c133e32f
|
@ -15,7 +15,6 @@ struct _E_Pointer_Stack
|
|||
{
|
||||
void *obj;
|
||||
const char *type;
|
||||
unsigned char e_cursor : 1;
|
||||
};
|
||||
|
||||
static Evas_List *_e_pointers = NULL;
|
||||
|
@ -66,7 +65,7 @@ e_pointers_size_set(int size)
|
|||
Evas_Engine_Info_Buffer *einfo;
|
||||
|
||||
p = l->data;
|
||||
if (p->e_cursor)
|
||||
if (p->evas)
|
||||
{
|
||||
p->w = p->h = size;
|
||||
evas_output_size_set(p->evas, p->w, p->h);
|
||||
|
@ -88,12 +87,15 @@ e_pointers_size_set(int size)
|
|||
else
|
||||
{
|
||||
const char *type;
|
||||
|
||||
|
||||
ecore_x_cursor_size_set(e_config->cursor_size * 3 / 4);
|
||||
type = p->type;
|
||||
p->type = NULL;
|
||||
_e_pointer_type_set(p, type);
|
||||
p->type = type;
|
||||
if (type)
|
||||
{
|
||||
p->type = NULL;
|
||||
_e_pointer_type_set(p, type);
|
||||
evas_stringshare_del(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -104,29 +106,19 @@ e_pointer_type_push(E_Pointer *p, void *obj, const char *type)
|
|||
E_Pointer_Stack *stack;
|
||||
|
||||
p->e_cursor = e_config->use_e_cursor;
|
||||
if (p->e_cursor)
|
||||
{
|
||||
if (!p->evas) _e_pointer_canvas_add(p);
|
||||
}
|
||||
|
||||
if (!_e_pointer_type_set(p, type))
|
||||
{
|
||||
p->e_cursor = 0;
|
||||
if (!_e_pointer_type_set(p, type)) return;
|
||||
}
|
||||
|
||||
if (p->type) evas_stringshare_del(p->type);
|
||||
p->type = evas_stringshare_add(type);
|
||||
_e_pointer_type_set(p, type);
|
||||
|
||||
p->obj = obj;
|
||||
|
||||
stack = E_NEW(E_Pointer_Stack, 1);
|
||||
if (stack)
|
||||
{
|
||||
stack->obj = p->obj;
|
||||
stack->type = evas_stringshare_add(p->type);
|
||||
stack->e_cursor = p->e_cursor;
|
||||
stack->obj = p->obj;
|
||||
p->stack = evas_list_prepend(p->stack, stack);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
EAPI void
|
||||
|
@ -150,32 +142,15 @@ e_pointer_type_pop(E_Pointer *p, void *obj, const char *type)
|
|||
|
||||
if (!p->stack)
|
||||
{
|
||||
if (p->e_cursor)
|
||||
{
|
||||
if (p->evas) _e_pointer_canvas_del(p);
|
||||
}
|
||||
if (p->evas) _e_pointer_canvas_del(p);
|
||||
ecore_x_window_cursor_set(p->win, 0);
|
||||
if (p->type) evas_stringshare_del(p->type);
|
||||
p->type = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
stack = p->stack->data;
|
||||
if ((stack->obj == p->obj) &&
|
||||
(!strcmp(stack->type, p->type)))
|
||||
{
|
||||
/* We already use the top pointer */
|
||||
return;
|
||||
}
|
||||
|
||||
p->e_cursor = stack->e_cursor;
|
||||
if (!_e_pointer_type_set(p, stack->type))
|
||||
{
|
||||
p->e_cursor = !p->e_cursor;
|
||||
if (!_e_pointer_type_set(p, stack->type))
|
||||
{
|
||||
printf("BUG: Can't set cursor!\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
_e_pointer_type_set(p, stack->type);
|
||||
|
||||
if (p->type) evas_stringshare_del(p->type);
|
||||
p->type = evas_stringshare_add(stack->type);
|
||||
|
@ -335,31 +310,37 @@ _e_pointer_type_set(E_Pointer *p, const char *type)
|
|||
/* Check if this pointer is already set */
|
||||
if ((p->type) && (!strcmp(p->type, type))) return 1;
|
||||
|
||||
if (p->type) evas_stringshare_del(p->type);
|
||||
p->type = evas_stringshare_add(type);
|
||||
|
||||
if (p->e_cursor)
|
||||
{
|
||||
Evas_Object *o;
|
||||
char cursor[1024];
|
||||
|
||||
if (!p->evas) _e_pointer_canvas_add(p);
|
||||
o = p->pointer_object;
|
||||
if (p->color)
|
||||
{
|
||||
snprintf(cursor, sizeof(cursor), "pointer/enlightenment/%s/color", type);
|
||||
if (!e_theme_edje_object_set(o, "base/theme/pointer", cursor))
|
||||
return 0;
|
||||
goto fallback;
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(cursor, sizeof(cursor), "pointer/enlightenment/%s/mono", type);
|
||||
if (!e_theme_edje_object_set(o, "base/theme/pointer", cursor))
|
||||
return 0;
|
||||
goto fallback;
|
||||
}
|
||||
edje_object_part_swallow(p->pointer_object, "hotspot", p->hot_object);
|
||||
p->hot.update = 1;
|
||||
return;
|
||||
}
|
||||
else
|
||||
fallback:
|
||||
{
|
||||
Ecore_X_Cursor cursor = 0;
|
||||
|
||||
if (p->evas) _e_pointer_canvas_del(p);
|
||||
if (!strcmp(type, "move"))
|
||||
{
|
||||
cursor = ecore_x_cursor_shape_get(ECORE_X_CURSOR_FLEUR);
|
||||
|
@ -422,6 +403,12 @@ _e_pointer_type_set(E_Pointer *p, const char *type)
|
|||
if (!cursor) printf("X Cursor for %s is missing\n", type);
|
||||
ecore_x_window_cursor_set(p->win, cursor);
|
||||
}
|
||||
else if (!strcmp(type, "entry"))
|
||||
{
|
||||
cursor = ecore_x_cursor_shape_get(ECORE_X_CURSOR_XTERM);
|
||||
if (!cursor) printf("X Cursor for %s is missing\n", type);
|
||||
ecore_x_window_cursor_set(p->win, cursor);
|
||||
}
|
||||
else if (!strcmp(type, "default"))
|
||||
{
|
||||
cursor = ecore_x_cursor_shape_get(ECORE_X_CURSOR_LEFT_PTR);
|
||||
|
|
|
@ -442,6 +442,17 @@ e_widget_disabled_get(Evas_Object *obj)
|
|||
return sd->disabled;
|
||||
}
|
||||
|
||||
EAPI E_Pointer *
|
||||
e_widget_pointer_get(Evas_Object *obj)
|
||||
{
|
||||
E_Win *win;
|
||||
API_ENTRY return NULL;
|
||||
|
||||
win = e_win_evas_object_win_get(obj);
|
||||
if (win) return win->pointer;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* local subsystem functions */
|
||||
static void
|
||||
_e_smart_reconfigure(E_Smart_Data *sd)
|
||||
|
@ -450,7 +461,7 @@ _e_smart_reconfigure(E_Smart_Data *sd)
|
|||
{
|
||||
evas_object_move(sd->resize_obj, sd->x, sd->y);
|
||||
evas_object_resize(sd->resize_obj, sd->w, sd->h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -33,6 +33,7 @@ EAPI void e_widget_activate(Evas_Object *obj);
|
|||
EAPI void e_widget_change(Evas_Object *obj);
|
||||
EAPI void e_widget_disabled_set(Evas_Object *obj, int disabled);
|
||||
EAPI int e_widget_disabled_get(Evas_Object *obj);
|
||||
|
||||
EAPI E_Pointer *e_widget_pointer_get(Evas_Object *obj);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -15,6 +15,8 @@ static void _e_wid_del_hook(Evas_Object *obj);
|
|||
static void _e_wid_focus_hook(Evas_Object *obj);
|
||||
static void _e_wid_disable_hook(Evas_Object *obj);
|
||||
static void _e_wid_focus_steal(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
static void _e_wid_in(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
static void _e_wid_out(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
static void _e_wid_changed_cb(void *data, Evas_Object *obj, void *event_info);
|
||||
|
||||
|
||||
|
@ -51,6 +53,8 @@ e_widget_entry_add(Evas *evas, char **text_location)
|
|||
e_widget_sub_object_add(obj, o);
|
||||
e_widget_resize_object_set(obj, o);
|
||||
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _e_wid_focus_steal, obj);
|
||||
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_IN, _e_wid_in, obj);
|
||||
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_OUT, _e_wid_out, obj);
|
||||
|
||||
if ((text_location) && (*text_location))
|
||||
e_entry_text_set(o, *text_location);
|
||||
|
@ -177,6 +181,24 @@ _e_wid_focus_steal(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|||
e_widget_focus_steal(data);
|
||||
}
|
||||
|
||||
static void
|
||||
_e_wid_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
E_Pointer *p;
|
||||
|
||||
p = e_widget_pointer_get(data);
|
||||
if (p) e_pointer_type_push(p, data, "entry");
|
||||
}
|
||||
|
||||
static void
|
||||
_e_wid_out(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
E_Pointer *p;
|
||||
|
||||
p = e_widget_pointer_get(data);
|
||||
if (p) e_pointer_type_pop(p, data, "entry");
|
||||
}
|
||||
|
||||
static void
|
||||
_e_wid_changed_cb(void *data, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
|
|
|
@ -58,7 +58,7 @@ e_win_new(E_Container *con)
|
|||
ecore_evas_title_set(win->ecore_evas, "E");
|
||||
obj = evas_object_rectangle_add(win->evas);
|
||||
evas_object_name_set(obj, "E_Win");
|
||||
evas_object_data_set(obj, "E_Win", obj);
|
||||
evas_object_data_set(obj, "E_Win", win);
|
||||
win->x = 0;
|
||||
win->y = 0;
|
||||
win->w = 1;
|
||||
|
|
Loading…
Reference in New Issue