summaryrefslogtreecommitdiff
path: root/src/lib/edje
diff options
context:
space:
mode:
authorBruno Dilly <bdilly@profusion.mobi>2016-12-14 02:55:59 -0200
committerBruno Dilly <bdilly@profusion.mobi>2016-12-21 23:03:33 -0200
commitd57d17723e255883dda22b96b61ea5e7cd5f23f8 (patch)
treef2e0f6ba0785ec3de6236b7e7d30a16c3ab6f5ef /src/lib/edje
parent18f41e12bcc413b74003b5300bcef069837d02c5 (diff)
edje: refactor _edje_program_run for FOCUS_SET action
Improve code readability and avoid code repetition.
Diffstat (limited to 'src/lib/edje')
-rw-r--r--src/lib/edje/edje_program.c80
1 files changed, 34 insertions, 46 deletions
diff --git a/src/lib/edje/edje_program.c b/src/lib/edje/edje_program.c
index 695f57ccd8..df74b334ec 100644
--- a/src/lib/edje/edje_program.c
+++ b/src/lib/edje/edje_program.c
@@ -641,6 +641,38 @@ _edje_seat_name_emit(Edje *ed, const char *name, const char *sig, const char *sr
641 _edje_emit_full(ed, buf, src, NULL, NULL); 641 _edje_emit_full(ed, buf, src, NULL, NULL);
642} 642}
643 643
644static void
645_edje_part_focus_set(Edje *ed, const char *seat_name, Edje_Real_Part *rp)
646{
647 Edje_Real_Part *focused_part;
648 Eina_Stringshare *sname;
649 Efl_Input_Device *seat;
650 Evas *e;
651
652 if (seat_name)
653 sname = eina_stringshare_add(seat_name);
654 else /* Use default seat name */
655 {
656 e = evas_object_evas_get(ed->obj);
657 seat = evas_canvas_default_device_get(e, EFL_INPUT_DEVICE_CLASS_SEAT);
658 sname = eina_stringshare_ref(_edje_seat_name_get(ed, seat));
659 }
660
661 focused_part = _edje_focused_part_get(ed, sname);
662
663 if (focused_part != rp)
664 {
665 if (focused_part)
666 _edje_seat_name_emit(ed, sname, "focus,part,out",
667 focused_part->part->name);
668 _edje_focused_part_set(ed, sname, rp);
669 if (rp)
670 _edje_seat_name_emit(ed, sname, "focus,part,in", rp->part->name);
671 }
672
673 eina_stringshare_del(sname);
674}
675
644void 676void
645_edje_program_run(Edje *ed, Edje_Program *pr, Eina_Bool force, const char *ssig, const char *ssrc) 677_edje_program_run(Edje *ed, Edje_Program *pr, Eina_Bool force, const char *ssig, const char *ssrc)
646{ 678{
@@ -970,35 +1002,8 @@ low_mem_current:
970 1002
971 case EDJE_ACTION_TYPE_FOCUS_SET: 1003 case EDJE_ACTION_TYPE_FOCUS_SET:
972 { 1004 {
973 Edje_Real_Part *focused_part;
974 Eina_Stringshare *seat_name;
975 Eina_Bool unref_name = EINA_FALSE;
976
977 if (pr->seat)
978 {
979 seat_name = eina_stringshare_add(pr->seat);
980 unref_name = EINA_TRUE;
981 }
982 else /* Use default seat name */
983 {
984 Efl_Input_Device *seat;
985 Evas *e;
986
987 e = evas_object_evas_get(ed->obj);
988 seat = evas_canvas_default_device_get(e, EFL_INPUT_DEVICE_CLASS_SEAT);
989 seat_name = _edje_seat_name_get(ed, seat);
990 if (!seat_name)
991 break;
992 }
993
994 if (!pr->targets) 1005 if (!pr->targets)
995 { 1006 _edje_part_focus_set(ed, pr->seat, NULL);
996 focused_part = _edje_focused_part_get(ed, seat_name);
997 if (focused_part)
998 _edje_seat_name_emit(ed, seat_name, "focus,part,out",
999 focused_part->part->name);
1000 _edje_focused_part_set(ed, seat_name, NULL);
1001 }
1002 else 1007 else
1003 { 1008 {
1004 EINA_LIST_FOREACH(pr->targets, l, pt) 1009 EINA_LIST_FOREACH(pr->targets, l, pt)
@@ -1007,27 +1012,10 @@ low_mem_current:
1007 { 1012 {
1008 rp = ed->table_parts[pt->id % ed->table_parts_size]; 1013 rp = ed->table_parts[pt->id % ed->table_parts_size];
1009 if (rp) 1014 if (rp)
1010 { 1015 _edje_part_focus_set(ed, pr->seat, rp);
1011 focused_part = _edje_focused_part_get(ed,
1012 seat_name);
1013 if (focused_part != rp)
1014 {
1015 if (focused_part)
1016 _edje_seat_name_emit(ed, seat_name,
1017 "focus,part,out",
1018 focused_part->part->name);
1019 _edje_focused_part_set(ed, seat_name, rp);
1020 _edje_seat_name_emit(ed, seat_name,
1021 "focus,part,in",
1022 rp->part->name);
1023 }
1024 }
1025 } 1016 }
1026 } 1017 }
1027 } 1018 }
1028
1029 if (unref_name)
1030 eina_stringshare_del(seat_name);
1031 } 1019 }
1032 break; 1020 break;
1033 1021