[E-devel] shelf autohide patch
a small update to my last patch to show the shelf again if one disables autohide while the shelf is hidden. Please tell me if something is not ok with this and I'll try to fix it. -- Hannes Janetzek Index: e_shelf.c === RCS file: /var/cvs/e/e17/apps/e/src/bin/e_shelf.c,v retrieving revision 1.56 diff -u -r1.56 e_shelf.c --- e_shelf.c 11 Apr 2007 15:37:04 - 1.56 +++ e_shelf.c 22 Apr 2007 14:06:40 - @@ -19,7 +19,6 @@ static void _e_shelf_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info); static void _e_shelf_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event_info); static void _e_shelf_cb_mouse_in(void *data, Evas *evas, Evas_Object *obj, void *event_info); -static void _e_shelf_cb_mouse_out(void *data, Evas *evas, Evas_Object *obj, void *event_info); static int _e_shelf_cb_id_sort(void *data1, void *data2); static int _e_shelf_cb_hide_timer(void *data); static int _e_shelf_cb_hide_animator(void *data); @@ -142,8 +141,7 @@ evas_object_event_callback_add(es->o_event, EVAS_CALLBACK_MOUSE_DOWN, _e_shelf_cb_mouse_down, es); evas_object_event_callback_add(es->o_event, EVAS_CALLBACK_MOUSE_UP, _e_shelf_cb_mouse_up, es); evas_object_event_callback_add(es->o_event, EVAS_CALLBACK_MOUSE_IN, _e_shelf_cb_mouse_in, es); - evas_object_event_callback_add(es->o_event, EVAS_CALLBACK_MOUSE_OUT, _e_shelf_cb_mouse_out, es); - + es->o_base = edje_object_add(es->evas); es->name = evas_stringshare_add(name); snprintf(buf, sizeof(buf), "e/shelf/%s/base", es->style); @@ -271,36 +269,47 @@ EAPI void e_shelf_toggle(E_Shelf *es, int show) { - E_OBJECT_CHECK(es); - E_OBJECT_TYPE_CHECK(es, E_SHELF_TYPE); - if (show) - { - if (es->hide_timer) - { - ecore_timer_del(es->hide_timer); - es->hide_timer = NULL; - } - if (es->hidden && !es->instant_timer) - { - es->hidden = 0; - edje_object_signal_emit(es->o_base, "e,state,visible", "e"); - if (es->instant_delay >= 0.0) - { - if (!es->instant_timer) - _e_shelf_cb_instant_hide_timer(es); - } - else - { - if(!es->hide_animator) - es->hide_animator = ecore_animator_add(_e_shelf_cb_hide_animator, es); - } - } - } - else if (!show && es->cfg->autohide && !es->hidden) - { - if(!es->hide_timer) - es->hide_timer = ecore_timer_add(es->cfg->hide_timeout, _e_shelf_cb_hide_timer, es); - } + E_OBJECT_CHECK(es); + E_OBJECT_TYPE_CHECK(es, E_SHELF_TYPE); + + if(!es->cfg->autohide && !es->hidden) return; + + if (show) +{ + + if(!es->hide_timer) es->hide_timer = ecore_timer_add(0.1, _e_shelf_cb_hide_timer, es); + + if (es->hidden && !es->instant_timer) + { + es->hidden = 0; + edje_object_signal_emit(es->o_base, "e,state,visible", "e"); + if (es->instant_delay >= 0.0) + { + if (!es->instant_timer) + _e_shelf_cb_instant_hide_timer(es); + } + else + { + if(!es->hide_animator) + es->hide_animator = ecore_animator_add(_e_shelf_cb_hide_animator, es); + } + } +} + else if (!show && es->cfg->autohide && !es->hidden) +{ + es->hidden = 1; + edje_object_signal_emit(es->o_base, "e,state,hidden", "e"); + if (es->instant_delay >= 0.0) + { + if (!es->instant_timer) + es->instant_timer = ecore_timer_add(es->instant_delay, _e_shelf_cb_instant_hide_timer, es); + } + else + { + if (!es->hide_animator) + es->hide_animator = ecore_animator_add(_e_shelf_cb_hide_animator, es); + } +} } EAPI void @@ -1149,25 +1158,6 @@ e_shelf_toggle(es, 1); } -static void -_e_shelf_cb_mouse_out(void *data, Evas *evas, Evas_Object *obj, void *event_info) -{ - Evas_Event_Mouse_Out *ev; - E_Shelf *es; - - es = data; - ev = event_info; - if (es->cfg->autohide) - { - Evas_Coord x, y, w, h; - - evas_object_geometry_get(es->o_base, &x, &y, &w, &h); - if (!E_INSIDE(ev->canvas.x, ev->canvas.y, x, y, w, h)) - e_shelf_toggle(es, 0); - } - edje_object_signal_emit(es->o_base, "e,state,unfocused", "e"); -} - static int _e_shelf_cb_id_sort(void *data1, void *data2) { @@ -1178,28 +1168,36 @@ return (es1->id) > (es2->id); } -static int +static int _e_shelf_cb_hide_timer(void *data) { - E_Shelf *es; + Evas_Coord x, y, w, h, px, py; - es = data; + E_Shelf *es = data; - es->hidden = 1; - edje_object_signal_emit(es->o_base, "e,state,hidden", "e"); - if (es->instant_delay >= 0.0) - { - if (!es->instant_timer) - es->instant_timer = ecore_timer_add(es->instant_delay, _e_shelf_cb_instant_hide_timer, es); - } - else - { - if (!es->hide_animator) - es->hide_animator = ecore_animator_add(_e_shelf_cb_hide_animator, es); - } - es->hide_timer = NULL; - - return 0; + evas_object_geometry_get(es->o_base, &x, &y, &w, &h); + evas_pointer_canvas_xy_get(es->evas, &px, &py); + + if (E_INSIDE(px, py, x, y, w, h)) +{ + es->las
[E-devel] shelf autohide - patch to make sure that the shelf hides on mouseout
Hi, this patch changes the shelfs autohide feature to use polling to detect when then mouse is out of the shelf. There is still one problem left: If a module pops up a menu or if one drags something out of the shelf the shelf doesn't hide. My Idea for this would be to add the functions e_gadcon_client_autohide_freeze and -thaw so that the module can call these before and after a menu is activated. See the comment in the patch where the shelf would test the freeze-state to act according to the state. Regards, Hannes Index: e_shelf.c === RCS file: /var/cvs/e/e17/apps/e/src/bin/e_shelf.c,v retrieving revision 1.56 diff -u -r1.56 e_shelf.c --- e_shelf.c 11 Apr 2007 15:37:04 - 1.56 +++ e_shelf.c 19 Apr 2007 16:40:06 - @@ -19,13 +19,13 @@ static void _e_shelf_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info); static void _e_shelf_cb_mouse_up(void *data, Evas *evas, Evas_Object *obj, void *event_info); static void _e_shelf_cb_mouse_in(void *data, Evas *evas, Evas_Object *obj, void *event_info); -static void _e_shelf_cb_mouse_out(void *data, Evas *evas, Evas_Object *obj, void *event_info); static int _e_shelf_cb_id_sort(void *data1, void *data2); static int _e_shelf_cb_hide_timer(void *data); static int _e_shelf_cb_hide_animator(void *data); static int _e_shelf_cb_instant_hide_timer(void *data); static void _e_shelf_menu_del_hook(void *data); static void _e_shelf_menu_pre_cb(void *data, E_Menu *m); +static int _e_shelf_hide_timer(void *data); static Evas_List *shelves = NULL; @@ -142,8 +142,7 @@ evas_object_event_callback_add(es->o_event, EVAS_CALLBACK_MOUSE_DOWN, _e_shelf_cb_mouse_down, es); evas_object_event_callback_add(es->o_event, EVAS_CALLBACK_MOUSE_UP, _e_shelf_cb_mouse_up, es); evas_object_event_callback_add(es->o_event, EVAS_CALLBACK_MOUSE_IN, _e_shelf_cb_mouse_in, es); - evas_object_event_callback_add(es->o_event, EVAS_CALLBACK_MOUSE_OUT, _e_shelf_cb_mouse_out, es); - + es->o_base = edje_object_add(es->evas); es->name = evas_stringshare_add(name); snprintf(buf, sizeof(buf), "e/shelf/%s/base", es->style); @@ -271,36 +270,47 @@ EAPI void e_shelf_toggle(E_Shelf *es, int show) { - E_OBJECT_CHECK(es); - E_OBJECT_TYPE_CHECK(es, E_SHELF_TYPE); - if (show) - { - if (es->hide_timer) - { - ecore_timer_del(es->hide_timer); - es->hide_timer = NULL; - } - if (es->hidden && !es->instant_timer) - { - es->hidden = 0; - edje_object_signal_emit(es->o_base, "e,state,visible", "e"); - if (es->instant_delay >= 0.0) - { - if (!es->instant_timer) - _e_shelf_cb_instant_hide_timer(es); - } - else - { - if(!es->hide_animator) - es->hide_animator = ecore_animator_add(_e_shelf_cb_hide_animator, es); - } - } - } - else if (!show && es->cfg->autohide && !es->hidden) - { - if(!es->hide_timer) - es->hide_timer = ecore_timer_add(es->cfg->hide_timeout, _e_shelf_cb_hide_timer, es); - } + E_OBJECT_CHECK(es); + E_OBJECT_TYPE_CHECK(es, E_SHELF_TYPE); + + if(!es->cfg->autohide) return; + + if (show) +{ + + if(!es->hide_timer) es->hide_timer = ecore_timer_add(0.1, _e_shelf_hide_timer, es); + + if (es->hidden && !es->instant_timer) + { + es->hidden = 0; + edje_object_signal_emit(es->o_base, "e,state,visible", "e"); + if (es->instant_delay >= 0.0) + { + if (!es->instant_timer) + _e_shelf_cb_instant_hide_timer(es); + } + else + { + if(!es->hide_animator) + es->hide_animator = ecore_animator_add(_e_shelf_cb_hide_animator, es); + } + } +} + else if (!show && es->cfg->autohide && !es->hidden) +{ + es->hidden = 1; + edje_object_signal_emit(es->o_base, "e,state,hidden", "e"); + if (es->instant_delay >= 0.0) + { + if (!es->instant_timer) + es->instant_timer = ecore_timer_add(es->instant_delay, _e_shelf_cb_instant_hide_timer, es); + } + else + { + if (!es->hide_animator) + es->hide_animator = ecore_animator_add(_e_shelf_cb_hide_animator, es); + } +} } EAPI void @@ -1149,25 +1159,6 @@ e_shelf_toggle(es, 1); } -static void -_e_shelf_cb_mouse_out(void *data, Evas *evas, Evas_Object *obj, void *event_info) -{ - Evas_Event_Mouse_Out *ev; - E_Shelf *es; - - es = data; - ev = event_info; - if (es->cfg->autohide) - { - Evas_Coord x, y, w, h; - - evas_object_geometry_get(es->o_base, &x, &y, &w, &h); - if (!E_INSIDE(ev->canvas.x, ev->canvas.y, x, y, w, h)) - e_shelf_toggle(es, 0); - } - edje_object_signal_emit(es->o_base, "e,state,unfocused", "e"); -} - static int _e_shelf_cb_id_sort(void *data1, void *data2) { @@ -1178,28 +1169,39 @@ return (es1->id) > (es2->id); } -static int -_e_shelf_cb_hide_timer(void *data) +static int +_e_shelf_hide_timer(void *data) { - E_Shelf *es; + Evas_Coord x, y, w, h, px, py; - es = data; + E_Shelf *es = data; -