summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2017-10-20 16:04:22 -0400
committerMike Blumenkrantz <zmike@osg.samsung.com>2017-10-20 16:04:22 -0400
commite46924b357e297e3048ac571ad37d04e7cda957f (patch)
treea0b4ee96f87477d1c631407ea4d4c7d77c2be9a7
parent528e25e0bb92542ec140e3082d8338528aa5a7a8 (diff)
fix sandbox gadget popup size hints
-rw-r--r--src/runner.c62
1 files changed, 37 insertions, 25 deletions
diff --git a/src/runner.c b/src/runner.c
index 2a24be2..a805724 100644
--- a/src/runner.c
+++ b/src/runner.c
@@ -530,18 +530,44 @@ popup_hide(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *
530} 530}
531 531
532static void 532static void
533popup_added(void *data, Evas_Object *obj EINA_UNUSED, void *event_info) 533popup_hints_update(Evas_Object *obj)
534{ 534{
535 Instance *inst = data;
536 Evas_Object *bx, *tb, *r;
537 E_Zone *zone;
538 double w, h; 535 double w, h;
536 E_Zone *zone = e_comp_object_util_zone_get(obj);
539 537
540 if (!efl_wl_surface_extract(event_info)) return; 538 evas_object_size_hint_weight_get(obj, &w, &h);
541 zone = e_zone_current_get();
542 evas_object_size_hint_weight_get(event_info, &w, &h);
543 w = E_CLAMP(w, 0, 0.5); 539 w = E_CLAMP(w, 0, 0.5);
544 h = E_CLAMP(h, 0, 0.5); 540 h = E_CLAMP(h, 0, 0.5);
541
542 if ((w > 0) && (h > 0))
543 {
544 evas_object_size_hint_min_set(obj, w * zone->w, h * zone->h);
545 evas_object_size_hint_max_set(obj, w * zone->w, h * zone->h);
546 }
547 if ((!EINA_DBL_NONZERO(w)) && (!EINA_DBL_NONZERO(h)))
548 {
549 int ww, hh;
550 evas_object_geometry_get(obj, NULL, NULL, &ww, &hh);
551 evas_object_size_hint_min_set(obj, ww, hh);
552 }
553 E_WEIGHT(obj, 0, 0);
554}
555
556static void
557popup_hints(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
558{
559 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, popup_hints, data);
560 popup_hints_update(obj);
561 evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, popup_hints, data);
562}
563
564static void
565popup_added(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
566{
567 Instance *inst = data;
568 Evas_Object *bx;
569
570 if (!efl_wl_surface_extract(event_info)) return;
545 inst->extracted = eina_list_append(inst->extracted, event_info); 571 inst->extracted = eina_list_append(inst->extracted, event_info);
546 572
547 inst->ctxpopup = elm_ctxpopup_add(inst->box); 573 inst->ctxpopup = elm_ctxpopup_add(inst->box);
@@ -549,29 +575,15 @@ popup_added(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
549 evas_object_smart_callback_add(inst->ctxpopup, "dismissed", popup_dismissed, inst); 575 evas_object_smart_callback_add(inst->ctxpopup, "dismissed", popup_dismissed, inst);
550 evas_object_event_callback_add(event_info, EVAS_CALLBACK_DEL, popup_hide, inst); 576 evas_object_event_callback_add(event_info, EVAS_CALLBACK_DEL, popup_hide, inst);
551 577
552 tb = elm_table_add(inst->ctxpopup);
553 evas_object_show(tb);
554
555 bx = elm_box_add(inst->ctxpopup); 578 bx = elm_box_add(inst->ctxpopup);
556 elm_table_pack(tb, bx, 0, 0, 1, 1); 579 popup_hints_update(event_info);
557 if (w > 0) 580 E_FILL(event_info);
558 { 581 evas_object_event_callback_add(event_info, EVAS_CALLBACK_CHANGED_SIZE_HINTS, popup_hints, inst);
559 r = evas_object_rectangle_add(e_comp->evas);
560 evas_object_size_hint_min_set(r, w * zone->w, 0);
561 elm_table_pack(tb, bx, 0, 1, 2, 1);
562 }
563 if (h > 0)
564 {
565 r = evas_object_rectangle_add(e_comp->evas);
566 evas_object_size_hint_min_set(r, 0, h * zone->h);
567 elm_table_pack(tb, bx, 1, 0, 1, 2);
568 }
569 elm_box_homogeneous_set(bx, 1);
570 evas_object_show(bx); 582 evas_object_show(bx);
571 elm_box_pack_end(bx, event_info); 583 elm_box_pack_end(bx, event_info);
572 evas_object_data_set(bx, "extracted", event_info); 584 evas_object_data_set(bx, "extracted", event_info);
573 evas_object_event_callback_add(bx, EVAS_CALLBACK_DEL, popup_del, inst); 585 evas_object_event_callback_add(bx, EVAS_CALLBACK_DEL, popup_del, inst);
574 elm_object_content_set(inst->ctxpopup, tb); 586 elm_object_content_set(inst->ctxpopup, bx);
575 587
576 e_gadget_util_ctxpopup_place(inst->box, inst->ctxpopup, NULL); 588 e_gadget_util_ctxpopup_place(inst->box, inst->ctxpopup, NULL);
577 evas_object_show(inst->ctxpopup); 589 evas_object_show(inst->ctxpopup);