From 5ae00e6525528abc919b190608ca6450a0e11eb9 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 27 Apr 2015 15:39:43 -0400 Subject: [PATCH] redo drop handlers to take an E_Object and Evas_Object temp change to fix crashing when closing fwins with ctrl+w --- src/bin/e_dnd.c | 19 ++++++++++--------- src/bin/e_dnd.h | 3 ++- src/bin/e_fm.c | 29 ++++++++++++++++++++++++++--- src/bin/e_fm.h | 1 + src/bin/e_gadcon.c | 2 +- src/bin/e_import_dialog.c | 2 +- src/bin/e_widget_fsel.c | 6 +++--- src/bin/e_widget_fsel.h | 2 +- src/modules/fileman/e_fwin.c | 4 ++-- src/modules/fileman/e_fwin_nav.c | 2 +- src/modules/ibar/e_mod_main.c | 2 +- src/modules/ibox/e_mod_main.c | 2 +- src/modules/pager/e_mod_main.c | 2 +- src/modules/pager_plain/e_mod_main.c | 2 +- src/modules/shot/e_mod_main.c | 2 +- 15 files changed, 53 insertions(+), 27 deletions(-) diff --git a/src/bin/e_dnd.c b/src/bin/e_dnd.c index b28696c..1e94552 100644 --- a/src/bin/e_dnd.c +++ b/src/bin/e_dnd.c @@ -439,7 +439,7 @@ e_drop_xds_update(Eina_Bool enable, const char *value) } EAPI E_Drop_Handler * -e_drop_handler_add(E_Object *obj, +e_drop_handler_add(E_Object *obj, Evas_Object *win, void *data, void (*enter_cb)(void *data, const char *type, void *event), void (*move_cb)(void *data, const char *type, void *event), @@ -467,6 +467,7 @@ e_drop_handler_add(E_Object *obj, handler->h = h; handler->obj = obj; + handler->win = win; handler->entered = 0; _drop_handlers = eina_list_append(_drop_handlers, handler); @@ -667,11 +668,11 @@ _e_drag_coords_update(const E_Drop_Handler *h, int *dx, int *dy) *dx = 0; *dy = 0; - if (e_obj_is_win(h->obj)) + if (h->win) { E_Client *ec; - ec = e_win_client_get((void*)h->obj); + ec = e_win_client_get(h->win); px = ec->x; py = ec->y; } @@ -725,8 +726,8 @@ _e_drag_win_get(const E_Drop_Handler *h, int xdnd) { Ecore_X_Window hwin = 0; - if (e_obj_is_win(h->obj)) - return elm_win_window_id_get((Evas_Object*)h->obj); + if (h->win) + return elm_win_window_id_get(h->win); if (h->obj) { E_Gadcon *gc = NULL; @@ -776,9 +777,9 @@ _e_drag_win_show(E_Drop_Handler *h) { E_Shelf *shelf; + if (h->win) return; if (h->obj) { - if (e_obj_is_win(h->obj)) return; switch (h->obj->type) { case E_GADCON_TYPE: @@ -803,9 +804,9 @@ _e_drag_win_hide(E_Drop_Handler *h) { E_Shelf *shelf; + if (h->win) return; if (h->obj) { - if (e_obj_is_win(h->obj)) return; switch (h->obj->type) { case E_GADCON_TYPE: @@ -833,8 +834,8 @@ _e_dnd_object_layer_get(E_Drop_Handler *h) if (h->base) return evas_object_layer_get(h->base); if (!obj) return 0; - if (e_obj_is_win(obj)) - obj = (E_Object*)e_win_client_get((Evas_Object*)obj); + if (h->win) + obj = (E_Object*)e_win_client_get(h->win); switch (obj->type) { case E_GADCON_CLIENT_TYPE: diff --git a/src/bin/e_dnd.h b/src/bin/e_dnd.h index bd90f12..d03791d 100644 --- a/src/bin/e_dnd.h +++ b/src/bin/e_dnd.h @@ -66,6 +66,7 @@ struct _E_Drop_Handler } cb; E_Object *obj; + Evas_Object *win; Evas_Object *base; int x, y, w, h; @@ -132,7 +133,7 @@ EAPI int e_drag_xdnd_start(E_Drag *drag, int x, int y); EAPI void e_drop_xds_update(Eina_Bool enable, const char *value); EAPI void e_drop_handler_xds_set(E_Drop_Handler *handler, Eina_Bool (*cb)(void *data, const char *type)); -EAPI E_Drop_Handler *e_drop_handler_add(E_Object *obj, +EAPI E_Drop_Handler *e_drop_handler_add(E_Object *obj, Evas_Object *win, void *data, void (*enter_cb)(void *data, const char *type, void *event), void (*move_cb)(void *data, const char *type, void *event), diff --git a/src/bin/e_fm.c b/src/bin/e_fm.c index 469def7..a222533 100644 --- a/src/bin/e_fm.c +++ b/src/bin/e_fm.c @@ -146,6 +146,7 @@ struct _E_Fm2_Smart_Data int busy_count; E_Object *eobj; + Evas_Object *win; E_Drop_Handler *drop_handler; E_Fm2_Icon *drop_icon; Ecore_Animator *dnd_scroller; @@ -1624,8 +1625,30 @@ e_fm2_window_object_set(Evas_Object *obj, E_Object *eobj) EFM_SMART_CHECK(); sd->eobj = eobj; + sd->win = NULL; if (sd->drop_handler) e_drop_handler_del(sd->drop_handler); - sd->drop_handler = e_drop_handler_add(sd->eobj, + sd->drop_handler = e_drop_handler_add(sd->eobj, NULL, + sd, + _e_fm2_cb_dnd_enter, + _e_fm2_cb_dnd_move, + _e_fm2_cb_dnd_leave, + _e_fm2_cb_dnd_selection_notify, + drop, 3, + sd->x, sd->y, sd->w, sd->h); + e_drop_handler_responsive_set(sd->drop_handler); + e_drop_handler_xds_set(sd->drop_handler, _e_fm2_cb_dnd_drop); +} + +EAPI void +e_fm2_window_set(Evas_Object *obj, Evas_Object *win) +{ + const char *drop[] = {"text/uri-list", "text/x-moz-url", "XdndDirectSave0"}; + + EFM_SMART_CHECK(); + sd->win = win; + sd->eobj = NULL; + if (sd->drop_handler) e_drop_handler_del(sd->drop_handler); + sd->drop_handler = e_drop_handler_add(NULL, win, sd, _e_fm2_cb_dnd_enter, _e_fm2_cb_dnd_move, @@ -7321,7 +7344,7 @@ _e_fm2_cb_icon_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA { if (ev->button == 1) { - if ((ic->sd->eobj)) + if ((ic->sd->eobj || ic->sd->win)) { ic->drag.x = ev->output.x - ic->x - ic->sd->x + ic->sd->pos.x; ic->drag.y = ev->output.y - ic->y - ic->sd->y + ic->sd->pos.y; @@ -7554,7 +7577,7 @@ _e_fm2_cb_icon_mouse_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA ic->drag.start = ic->drag.dnd = ic->drag.src = EINA_FALSE; return; } - if ((ic->drag.start) && (ic->sd->eobj)) + if ((ic->drag.start) && (ic->sd->eobj || ic->sd->win)) { int dx, dy; diff --git a/src/bin/e_fm.h b/src/bin/e_fm.h index faf91ed..9637f70 100644 --- a/src/bin/e_fm.h +++ b/src/bin/e_fm.h @@ -181,6 +181,7 @@ EAPI void e_fm2_view_flags_set(Evas_Object *obj, E_Fm2_View_Flags fl EAPI E_Fm2_View_Flags e_fm2_view_flags_get(Evas_Object *obj); EAPI E_Object *e_fm2_window_object_get(Evas_Object *obj); EAPI void e_fm2_window_object_set(Evas_Object *obj, E_Object *eobj); +EAPI void e_fm2_window_set(Evas_Object *obj, Evas_Object *win); EAPI void e_fm2_icons_update(Evas_Object *obj); EAPI void e_fm2_pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y); diff --git a/src/bin/e_gadcon.c b/src/bin/e_gadcon.c index 2f9fb05..f57cab0 100644 --- a/src/bin/e_gadcon.c +++ b/src/bin/e_gadcon.c @@ -427,7 +427,7 @@ e_gadcon_drop_handler_add(E_Gadcon *gc, E_Gadcon_DND_Cb enter, E_Gadcon_DND_Cb l E_OBJECT_TYPE_CHECK(gc, E_GADCON_TYPE); if (gc->drop_handler) return; gc->drop_handler = - e_drop_handler_add(E_OBJECT(gc), gc, + e_drop_handler_add(E_OBJECT(gc), NULL, gc, _e_gadcon_cb_dnd_enter, _e_gadcon_cb_dnd_move, _e_gadcon_cb_dnd_leave, _e_gadcon_cb_dnd_drop, drop_types, 1, x, y, w, h); diff --git a/src/bin/e_import_dialog.c b/src/bin/e_import_dialog.c index 057e7cf..5bbebed 100644 --- a/src/bin/e_import_dialog.c +++ b/src/bin/e_import_dialog.c @@ -188,7 +188,7 @@ e_import_dialog_show(Evas_Object *parent EINA_UNUSED, const char *dev, const cha */ ofm = e_widget_fsel_add(evas, fdev, fpath, NULL, NULL, (void *)_fsel_cb_ok, id, NULL, NULL, 1); - e_widget_fsel_window_object_set(ofm, E_OBJECT(dia->win)); + e_widget_fsel_window_set(ofm, dia->win); id->fsel_obj = ofm; e_widget_size_min_get(ofm, &w, &h); e_dialog_content_set(dia, ofm, w, h); diff --git a/src/bin/e_widget_fsel.c b/src/bin/e_widget_fsel.c index e9ef5a0..7e5417a 100644 --- a/src/bin/e_widget_fsel.c +++ b/src/bin/e_widget_fsel.c @@ -532,14 +532,14 @@ e_widget_fsel_selection_path_get(Evas_Object *obj) } EAPI void -e_widget_fsel_window_object_set(Evas_Object *obj, E_Object *eobj) +e_widget_fsel_window_set(Evas_Object *obj, Evas_Object *win) { E_Widget_Data *wd; if (!obj) return; if (!(wd = e_widget_data_get(obj))) return; - e_fm2_window_object_set(wd->o_favorites_fm, eobj); - e_fm2_window_object_set(wd->o_files_fm, eobj); + e_fm2_window_set(wd->o_favorites_fm, win); + e_fm2_window_set(wd->o_files_fm, win); } EAPI Eina_Bool diff --git a/src/bin/e_widget_fsel.h b/src/bin/e_widget_fsel.h index eeee04b..1531e73 100644 --- a/src/bin/e_widget_fsel.h +++ b/src/bin/e_widget_fsel.h @@ -8,7 +8,7 @@ EAPI Evas_Object *e_widget_fsel_add(Evas *evas, const char *dev, const char *pat void (*chg_func) (void *data, Evas_Object *obj), void *chg_data, int preview); EAPI void e_widget_fsel_path_get(Evas_Object *obj, const char **dev, const char **path); EAPI const char *e_widget_fsel_selection_path_get(Evas_Object *obj); -EAPI void e_widget_fsel_window_object_set(Evas_Object *obj, E_Object *eobj); +EAPI void e_widget_fsel_window_set(Evas_Object *obj, Evas_Object *win); EAPI Eina_Bool e_widget_fsel_typebuf_visible_get(Evas_Object *obj); #endif #endif diff --git a/src/modules/fileman/e_fwin.c b/src/modules/fileman/e_fwin.c index b9ccdc8..12138c7 100644 --- a/src/modules/fileman/e_fwin.c +++ b/src/modules/fileman/e_fwin.c @@ -1003,7 +1003,7 @@ _e_fwin_page_favorites_add(E_Fwin_Page *page) "e/fileman/default/scrollframe"); evas_object_propagate_events_set(page->flist, 0); e_widget_can_focus_set(o, EINA_FALSE); - e_fm2_window_object_set(page->flist, E_OBJECT(page->fwin->win)); + e_fm2_window_set(page->flist, page->fwin->win); e_widget_scrollframe_focus_object_set(o, page->flist); page->flist_frame = o; @@ -1054,7 +1054,7 @@ _e_fwin_page_create(E_Fwin *fwin) evas_object_smart_callback_add(o, "icon_mouse_in", (Evas_Smart_Cb)_e_fwin_icon_mouse_in, fwin); evas_object_smart_callback_add(o, "icon_mouse_out", (Evas_Smart_Cb)_e_fwin_icon_mouse_out, fwin); e_fm2_icon_menu_start_extend_callback_set(o, _e_fwin_cb_menu_extend_start, page); - e_fm2_window_object_set(o, E_OBJECT(fwin->win)); + e_fm2_window_set(o, fwin->win); evas_object_focus_set(o, 1); _e_fwin_config_set(page); diff --git a/src/modules/fileman/e_fwin_nav.c b/src/modules/fileman/e_fwin_nav.c index 0c93c6b..ea6a243 100644 --- a/src/modules/fileman/e_fwin_nav.c +++ b/src/modules/fileman/e_fwin_nav.c @@ -376,7 +376,7 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style) edje_object_message_signal_process(inst->o_base); evas_object_geometry_get(inst->o_scroll, &x, &y, &w, &h); - inst->dnd_handler = e_drop_handler_add(E_OBJECT(inst->gcc), + inst->dnd_handler = e_drop_handler_add(E_OBJECT(inst->gcc), NULL, inst, _box_button_cb_dnd_enter, _box_button_cb_dnd_move, diff --git a/src/modules/ibar/e_mod_main.c b/src/modules/ibar/e_mod_main.c index 313e259..c17c529 100644 --- a/src/modules/ibar/e_mod_main.c +++ b/src/modules/ibar/e_mod_main.c @@ -273,7 +273,7 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style) evas_object_geometry_get(b->o_box, &x, &y, &w, &h); inst->drop_handler = - e_drop_handler_add(E_OBJECT(inst->gcc), inst, + e_drop_handler_add(E_OBJECT(inst->gcc), NULL, inst, _ibar_inst_cb_enter, _ibar_inst_cb_move, _ibar_inst_cb_leave, _ibar_inst_cb_drop, drop, 3, x, y, w, h); diff --git a/src/modules/ibox/e_mod_main.c b/src/modules/ibox/e_mod_main.c index 603bd2f..23c7849 100644 --- a/src/modules/ibox/e_mod_main.c +++ b/src/modules/ibox/e_mod_main.c @@ -199,7 +199,7 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style) evas_object_geometry_get(o, &x, &y, &w, &h); inst->drop_handler = - e_drop_handler_add(E_OBJECT(inst->gcc), inst, + e_drop_handler_add(E_OBJECT(inst->gcc), NULL, inst, _ibox_inst_cb_enter, _ibox_inst_cb_move, _ibox_inst_cb_leave, _ibox_inst_cb_drop, drop, 1, x, y, w, h); diff --git a/src/modules/pager/e_mod_main.c b/src/modules/pager/e_mod_main.c index 530d5bb..b9e3779 100644 --- a/src/modules/pager/e_mod_main.c +++ b/src/modules/pager/e_mod_main.c @@ -224,7 +224,7 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style) evas_object_geometry_get(o, &x, &y, &w, &h); p->drop_handler = - e_drop_handler_add(E_OBJECT(inst->gcc), p, + e_drop_handler_add(E_OBJECT(inst->gcc), NULL, p, _pager_drop_cb_enter, _pager_drop_cb_move, _pager_drop_cb_leave, _pager_drop_cb_drop, drop, 3, x, y, w, h); diff --git a/src/modules/pager_plain/e_mod_main.c b/src/modules/pager_plain/e_mod_main.c index 26be22c..4805afa 100644 --- a/src/modules/pager_plain/e_mod_main.c +++ b/src/modules/pager_plain/e_mod_main.c @@ -215,7 +215,7 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style) evas_object_geometry_get(o, &x, &y, &w, &h); p->drop_handler = - e_drop_handler_add(E_OBJECT(inst->gcc), p, + e_drop_handler_add(E_OBJECT(inst->gcc), NULL, p, _pager_drop_cb_enter, _pager_drop_cb_move, _pager_drop_cb_leave, _pager_drop_cb_drop, drop, 3, x, y, w, h); diff --git a/src/modules/shot/e_mod_main.c b/src/modules/shot/e_mod_main.c index ad8b742..4f97ed9 100644 --- a/src/modules/shot/e_mod_main.c +++ b/src/modules/shot/e_mod_main.c @@ -266,7 +266,7 @@ _win_save_cb(void *data EINA_UNUSED, void *data2 EINA_UNUSED) NULL, NULL, NULL, NULL, 1); e_object_del_attach_func_set(E_OBJECT(dia), _file_select_del_cb); - e_widget_fsel_window_object_set(o, E_OBJECT(dia->win)); + e_widget_fsel_window_set(o, dia->win); o_fsel = o; evas_object_show(o); e_widget_size_min_get(o, &mw, &mh); -- 2.7.4