Enlightenment CVS committal Author : dj2 Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/lib Modified Files: ewl_attach.c Log Message: - that shoudln't have gone in =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_attach.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -3 -r1.7 -r1.8 --- ewl_attach.c 10 Oct 2005 23:42:20 -0000 1.7 +++ ewl_attach.c 10 Oct 2005 23:51:41 -0000 1.8 @@ -12,7 +12,6 @@ Ewl_Widget *box; Ewl_Attach *attach; - Ewl_Widget *parent; Evas_Coord x; Evas_Coord y; @@ -21,13 +20,11 @@ }; static void ewl_attach_parent_setup(Ewl_Widget *w); - +static void ewl_attach_cb_parent_destroy(Ewl_Widget *w, void *ev, void *data); static void ewl_attach_attach_type_setup(Ewl_Widget *w, Ewl_Attach *attach); -static void ewl_attach_tooltip_setup(Ewl_Widget *w, Ewl_Attach *attach); -static void ewl_attach_tooltip_attach(Ewl_Widget *w, Ewl_Attach *attach, - int cur_x, int cur_y); -static void ewl_attach_tooltip_detach(void); +static void ewl_attach_tooltip_attach(Ewl_Widget *w, Ewl_Attach *attach); +static void ewl_attach_tooltip_detach(Ewl_Attach *attach); static void ewl_attach_cb_tooltip_win_destroy(Ewl_Widget *w, void *ev, void *data); @@ -237,7 +234,7 @@ switch (attach->type) { case EWL_ATTACH_TYPE_TOOLTIP: - ewl_attach_tooltip_setup(w, attach); + ewl_attach_tooltip_attach(w, attach); break; case EWL_ATTACH_TYPE_COLOR: @@ -264,7 +261,7 @@ Ewl_Attach *tmp; tmp = EWL_ATTACH(list->list); - if (tmp && (tmp->type == type)) + if (tmp->type == type) { ewl_attach_free(tmp); list->len --; @@ -281,7 +278,8 @@ for (i = 0; i < list->len; i++) { tmp = EWL_ATTACH(list->list[i]); - if (tmp && (tmp->type == type)) + + if (tmp->type == type) { ewl_attach_free(tmp); list->len --; @@ -381,14 +379,6 @@ DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("attach", attach); - if (ewl_attach_tooltip - && (ewl_attach_tooltip->attach == attach)) - { - ecore_timer_del(ewl_attach_tooltip->attach); - ewl_attach_tooltip->attach = NULL; - } - - /* XXX should we clean up _WIDGET in here? */ if ((attach->type == EWL_ATTACH_DATA_TYPE_TEXT) @@ -407,100 +397,85 @@ DCHECK_PARAM_PTR("w", w); w->attach = ewl_attach_list_new(); + ewl_callback_append(w, EWL_CALLBACK_DESTROY, ewl_attach_cb_parent_destroy, NULL); DLEAVE_FUNCTION(DLEVEL_STABLE); } static void -ewl_attach_tooltip_setup(Ewl_Widget *w, Ewl_Attach *attach) +ewl_attach_cb_parent_destroy(Ewl_Widget *w, void *ev, void *data) { DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR("attach", attach); + DCHECK_PARAM_PTR("w", w); - ewl_callback_append(w, EWL_CALLBACK_MOUSE_MOVE, - ewl_attach_cb_tooltip_mouse_move, attach); - ewl_callback_append(w, EWL_CALLBACK_MOUSE_DOWN, - ewl_attach_cb_tooltip_mouse_down, attach); - ewl_callback_append(w, EWL_CALLBACK_FOCUS_OUT, - ewl_attach_cb_tooltip_focus_out, attach); + if (w->attach) + ewl_attach_list_free(w->attach); + + w->attach = NULL; DLEAVE_FUNCTION(DLEVEL_STABLE); } static void -ewl_attach_tooltip_attach(Ewl_Widget *w, Ewl_Attach *attach, int cur_x, int cur_y) +ewl_attach_tooltip_attach(Ewl_Widget *w, Ewl_Attach *attach) { DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR("w", w); DCHECK_PARAM_PTR("attach", attach); - /* if we are the same widget then short circute */ - if (ewl_attach_tooltip && (ewl_attach_tooltip->parent == w)) - { - ewl_attach_tooltip->x = cur_x + 15; - ewl_attach_tooltip->y = cur_y + 15; - - if (ewl_attach_tooltip->timer) - ecore_timer_del(ewl_attach_tooltip->timer); - - ewl_attach_tooltip->timer = ecore_timer_add(1.0, ewl_attach_cb_tooltip_timer, w); - DRETURN(DLEVEL_STABLE); - } - - ewl_attach_tooltip_detach(); - if (!ewl_attach_tooltip) - { ewl_attach_tooltip = NEW(Ewl_Attach_Tooltip, 1); - } ewl_attach_tooltip->attach = attach; - ewl_attach_tooltip->parent = w; - /* XXX the 15 should come from the theme (offset off of the cursor) */ - /* XXX the 1.0 shoudl come from the theme (delay before firing timer) */ - ewl_attach_tooltip->x = cur_x + 15; - ewl_attach_tooltip->y = cur_y + 15; - - ewl_attach_tooltip->timer = ecore_timer_add(1.0, ewl_attach_cb_tooltip_timer, w); + ewl_callback_append(w, EWL_CALLBACK_MOUSE_MOVE, + ewl_attach_cb_tooltip_mouse_move, attach); + ewl_callback_append(w, EWL_CALLBACK_MOUSE_DOWN, + ewl_attach_cb_tooltip_mouse_down, attach); + ewl_callback_append(w, EWL_CALLBACK_FOCUS_OUT, + ewl_attach_cb_tooltip_focus_out, attach); DLEAVE_FUNCTION(DLEVEL_STABLE); } static void -ewl_attach_tooltip_detach(void) +ewl_attach_tooltip_detach(Ewl_Attach *attach) { DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("attach", attach); - if (!ewl_attach_tooltip) + /* make sure the display attach is our attach */ + if (ewl_attach_tooltip->attach != attach) { DRETURN(DLEVEL_STABLE); } - if (ewl_attach_tooltip->timer) - ecore_timer_del(ewl_attach_tooltip->timer); - - ewl_attach_tooltip->timer = NULL; - ewl_attach_tooltip->x = 0; - ewl_attach_tooltip->y = 0; + if (ewl_attach_tooltip) + { + if (ewl_attach_tooltip->timer) + ecore_timer_del(ewl_attach_tooltip->timer); - /* hide window if needed */ - if (ewl_attach_tooltip->win && (VISIBLE(ewl_attach_tooltip->win))) - ewl_widget_hide(ewl_attach_tooltip->win); + ewl_attach_tooltip->timer = NULL; + ewl_attach_tooltip->x = 0; + ewl_attach_tooltip->y = 0; + + /* hide window if needed */ + if (ewl_attach_tooltip->win && (VISIBLE(ewl_attach_tooltip->win))) + ewl_widget_hide(ewl_attach_tooltip->win); - /* cleanup the display window */ - if (ewl_attach_tooltip->box) - { - if (ewl_attach_tooltip->attach->data_type == EWL_ATTACH_DATA_TYPE_TEXT) + /* cleanup the display window */ + if (ewl_attach_tooltip->box) { - ewl_widget_destroy(ewl_attach_tooltip->box); - ewl_attach_tooltip->box = NULL; + if (attach->data_type == EWL_ATTACH_DATA_TYPE_TEXT) + { + ewl_widget_destroy(ewl_attach_tooltip->box); + ewl_attach_tooltip->box = NULL; + } + else + ewl_container_child_remove(EWL_CONTAINER(ewl_attach_tooltip->box), + EWL_WIDGET(attach->data)); } - else - ewl_container_child_remove(EWL_CONTAINER(ewl_attach_tooltip->box), - EWL_WIDGET(ewl_attach_tooltip->attach->data)); + ewl_attach_tooltip->attach = NULL; } - ewl_attach_tooltip->attach = NULL; DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -509,7 +484,9 @@ ewl_attach_cb_tooltip_mouse_move(Ewl_Widget *w, void *ev, void *data) { Ewl_Attach *attach; + Ewl_Embed *emb; Ewl_Event_Mouse_Move *e; + int x, y; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("ev", ev); @@ -517,7 +494,25 @@ e = ev; attach = data; - ewl_attach_tooltip_attach(w, attach, e->x, e->y); + + if (!ewl_attach_tooltip) + ewl_attach_tooltip = NEW(Ewl_Attach_Tooltip, 1); + + ewl_attach_tooltip_detach(attach); + + emb = ewl_embed_widget_find(w); + ewl_window_position_get(EWL_WINDOW(emb), &x, &y); + + /* XXX the 15 should come from the theme (offset off of the cursor) */ + /* XXX the 1.0 shoudl come from the theme (delay before firing timer) */ + ewl_attach_tooltip->attach = attach; + ewl_attach_tooltip->x = e->x + 15; + ewl_attach_tooltip->y = e->y + 15; +#if 0 + ewl_attach_tooltip->x = x + CURRENT_X(w) + e->x + 15; + ewl_attach_tooltip->y = y + CURRENT_Y(w) + e->y + 15; +#endif + ewl_attach_tooltip->timer = ecore_timer_add(1.0, ewl_attach_cb_tooltip_timer, w); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -525,10 +520,13 @@ static void ewl_attach_cb_tooltip_mouse_down(Ewl_Widget *w __UNUSED__, void *ev __UNUSED__, void *data) { + Ewl_Attach *attach; + DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("data", data); - ewl_attach_tooltip_detach(); + attach = data; + ewl_attach_tooltip_detach(attach); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -537,10 +535,13 @@ ewl_attach_cb_tooltip_focus_out(Ewl_Widget *w __UNUSED__, void *ev __UNUSED__, void *data) { + Ewl_Attach *attach; + DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("data", data); - ewl_attach_tooltip_detach(); + attach = data; + ewl_attach_tooltip_detach(attach); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -548,23 +549,37 @@ static int ewl_attach_cb_tooltip_timer(void *data) { + Ewl_Widget *w; Ewl_Embed *emb; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET("data", data, FALSE); -DRETURN_INT(FALSE, DLEVEL_STABLE); + w = data; + emb = ewl_embed_widget_find(w); - if (!ewl_attach_tooltip->attach) + /* XXX i think there is a race condition with the detach code? + * ie, we get the focus_out (or something) stuck in the event queue + * and then we get the timer trigger in the event queue. the focus + * out is processed, then the trigger is processed ... blam ->attach + * is null */ + if (!(ewl_attach_tooltip->attach)) { DRETURN_INT(FALSE, DLEVEL_STABLE); } - emb = ewl_embed_widget_find(EWL_WIDGET(data)); - if (!(ewl_attach_tooltip->win)) { ewl_attach_tooltip->embed = EWL_WIDGET(emb); +#if 0 + ewl_attach_tooltip->win = ewl_window_new(); + ewl_window_title_set(EWL_WINDOW(ewl_attach_tooltip->win), "Tooltip"); + ewl_window_name_set(EWL_WINDOW(ewl_attach_tooltip->win), "Tooltip"); + ewl_window_class_set(EWL_WINDOW(ewl_attach_tooltip->win), "Tooltip"); + ewl_window_transient_for(EWL_WINDOW(emb), EWL_WINDOW(ewl_attach_tooltip->win)); + ewl_window_borderless_set(EWL_WINDOW(ewl_attach_tooltip->win)); + ewl_window_raise(EWL_WINDOW(ewl_attach_tooltip->win)); +#endif /* XXX this should really be in it's own window */ ewl_attach_tooltip->win = ewl_hbox_new(); ------------------------------------------------------- This SF.Net email is sponsored by: Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs