From fb2b5c67725454f3136ded042fb00a929bc492ad Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 19 Oct 2017 14:45:18 -0400 Subject: [PATCH] handle weight hints on sandbox gadget popup surfaces --- src/runner.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/runner.c b/src/runner.c index ee14166..2a24be2 100644 --- a/src/runner.c +++ b/src/runner.c @@ -533,9 +533,15 @@ static void popup_added(void *data, Evas_Object *obj EINA_UNUSED, void *event_info) { Instance *inst = data; - Evas_Object *bx; + Evas_Object *bx, *tb, *r; + E_Zone *zone; + double w, h; if (!efl_wl_surface_extract(event_info)) return; + zone = e_zone_current_get(); + evas_object_size_hint_weight_get(event_info, &w, &h); + w = E_CLAMP(w, 0, 0.5); + h = E_CLAMP(h, 0, 0.5); inst->extracted = eina_list_append(inst->extracted, event_info); inst->ctxpopup = elm_ctxpopup_add(inst->box); @@ -543,13 +549,29 @@ popup_added(void *data, Evas_Object *obj EINA_UNUSED, void *event_info) evas_object_smart_callback_add(inst->ctxpopup, "dismissed", popup_dismissed, inst); evas_object_event_callback_add(event_info, EVAS_CALLBACK_DEL, popup_hide, inst); + tb = elm_table_add(inst->ctxpopup); + evas_object_show(tb); + bx = elm_box_add(inst->ctxpopup); + elm_table_pack(tb, bx, 0, 0, 1, 1); + if (w > 0) + { + r = evas_object_rectangle_add(e_comp->evas); + evas_object_size_hint_min_set(r, w * zone->w, 0); + elm_table_pack(tb, bx, 0, 1, 2, 1); + } + if (h > 0) + { + r = evas_object_rectangle_add(e_comp->evas); + evas_object_size_hint_min_set(r, 0, h * zone->h); + elm_table_pack(tb, bx, 1, 0, 1, 2); + } elm_box_homogeneous_set(bx, 1); evas_object_show(bx); elm_box_pack_end(bx, event_info); evas_object_data_set(bx, "extracted", event_info); evas_object_event_callback_add(bx, EVAS_CALLBACK_DEL, popup_del, inst); - elm_object_content_set(inst->ctxpopup, bx); + elm_object_content_set(inst->ctxpopup, tb); e_gadget_util_ctxpopup_place(inst->box, inst->ctxpopup, NULL); evas_object_show(inst->ctxpopup);