summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Dilly <bdilly@profusion.mobi>2016-12-02 17:50:43 -0200
committerBruno Dilly <bdilly@profusion.mobi>2016-12-19 14:58:35 -0200
commit0ab6567b3e5ef63e97c97db01497619b7ea57f8d (patch)
tree00604248212822a5cf7fc09ab5e3e6edbd2f2f4d
parent7ef5f6c3a0a6893552a7f13aa2777e3b9480e343 (diff)
edje: accept optional seat parameter on FOCUS_OBJECT
If not provided, FOCUS_OBJECT action will keep acting over default seat. Also include a usage on edje-multiseat test (actually no example was exercising this action).
-rw-r--r--src/bin/edje/edje_cc_handlers.c11
-rw-r--r--src/examples/edje/edje-multiseat.c56
-rw-r--r--src/examples/edje/multiseat.edc62
-rw-r--r--src/lib/edje/edje_program.c28
4 files changed, 142 insertions, 15 deletions
diff --git a/src/bin/edje/edje_cc_handlers.c b/src/bin/edje/edje_cc_handlers.c
index 1d4b30ba0d..9428e45746 100644
--- a/src/bin/edje/edje_cc_handlers.c
+++ b/src/bin/edje/edje_cc_handlers.c
@@ -14094,7 +14094,7 @@ st_collections_group_programs_program_in(void)
14094 @li DRAG_VAL_STEP 1.0 0.0 14094 @li DRAG_VAL_STEP 1.0 0.0
14095 @li DRAG_VAL_PAGE 0.0 0.0 14095 @li DRAG_VAL_PAGE 0.0 0.0
14096 @li FOCUS_SET ("seat") 14096 @li FOCUS_SET ("seat")
14097 @li FOCUS_OBJECT 14097 @li FOCUS_OBJECT ("seat")
14098 @li PARAM_COPY "src_part" "src_param" "dst_part" "dst_param" 14098 @li PARAM_COPY "src_part" "src_param" "dst_part" "dst_param"
14099 @li PARAM_SET "part" "param" "value" 14099 @li PARAM_SET "part" "param" "value"
14100 @li PLAY_SAMPLE "sample name" speed (channel) 14100 @li PLAY_SAMPLE "sample name" speed (channel)
@@ -14111,7 +14111,7 @@ st_collections_group_programs_program_in(void)
14111 @li PHYSICS_ROT_SET 0.707 0 0 0.707 14111 @li PHYSICS_ROT_SET 0.707 0 0 0.707
14112 14112
14113 Only one action can be specified per program. 14113 Only one action can be specified per program.
14114 14114
14115 PLAY_SAMPLE (optional) channel can be one of: 14115 PLAY_SAMPLE (optional) channel can be one of:
14116 @li EFFECT/FX 14116 @li EFFECT/FX
14117 @li BACKGROUND/BG 14117 @li BACKGROUND/BG
@@ -14169,9 +14169,10 @@ st_collections_group_programs_program_action(void)
14169 else 14169 else
14170 ep->value = parse_float_range(2, 0.0, 1.0); 14170 ep->value = parse_float_range(2, 0.0, 1.0);
14171 } 14171 }
14172 else if (ep->action == EDJE_ACTION_TYPE_FOCUS_SET) 14172 else if ((ep->action == EDJE_ACTION_TYPE_FOCUS_SET) ||
14173 (ep->action == EDJE_ACTION_TYPE_FOCUS_OBJECT))
14173 { 14174 {
14174 if (get_arg_count() == 1) 14175 if (get_arg_count() == 1)
14175 ep->seat = NULL; 14176 ep->seat = NULL;
14176 else 14177 else
14177 ep->seat = parse_str(1); 14178 ep->seat = parse_str(1);
@@ -14317,7 +14318,6 @@ st_collections_group_programs_program_action(void)
14317 * completeness */ 14318 * completeness */
14318 break; 14319 break;
14319 case EDJE_ACTION_TYPE_ACTION_STOP: 14320 case EDJE_ACTION_TYPE_ACTION_STOP:
14320 case EDJE_ACTION_TYPE_FOCUS_OBJECT:
14321 case EDJE_ACTION_TYPE_PHYSICS_FORCES_CLEAR: 14321 case EDJE_ACTION_TYPE_PHYSICS_FORCES_CLEAR:
14322 case EDJE_ACTION_TYPE_PHYSICS_STOP: 14322 case EDJE_ACTION_TYPE_PHYSICS_STOP:
14323 check_arg_count(1); 14323 check_arg_count(1);
@@ -14342,6 +14342,7 @@ st_collections_group_programs_program_action(void)
14342 check_min_arg_count(2); 14342 check_min_arg_count(2);
14343 break; 14343 break;
14344 case EDJE_ACTION_TYPE_FOCUS_SET: 14344 case EDJE_ACTION_TYPE_FOCUS_SET:
14345 case EDJE_ACTION_TYPE_FOCUS_OBJECT:
14345 check_min_arg_count(1); 14346 check_min_arg_count(1);
14346 break; 14347 break;
14347 default: 14348 default:
diff --git a/src/examples/edje/edje-multiseat.c b/src/examples/edje/edje-multiseat.c
index 4fbc77c842..620724492b 100644
--- a/src/examples/edje/edje-multiseat.c
+++ b/src/examples/edje/edje-multiseat.c
@@ -54,6 +54,52 @@ _on_canvas_resize(Ecore_Evas *ee)
54} 54}
55 55
56static void 56static void
57_on_rect_focus_in(void *data, const Efl_Event *event)
58{
59 Evas_Object *rect, *edje_obj;
60 Efl_Input_Device *seat;
61 Eina_Stringshare *name;
62 Efl_Input_Focus *ev;
63
64 edje_obj = data;
65 rect = event->object;
66 ev = event->info;
67 seat = efl_input_device_get(ev);
68 name = edje_obj_seat_name_get(edje_obj, seat);
69
70 printf("Seat %s (%s) focused the rect object\n",
71 efl_input_device_name_get(seat), name);
72
73 if (!strcmp(name, "seat1"))
74 evas_object_color_set(rect, 200, 0, 0, 255);
75 else if (!strcmp(name, "seat2"))
76 evas_object_color_set(rect, 0, 200, 0, 255);
77 else
78 printf("Unexpected seat %s - no color change\n", name);
79}
80
81static void
82_on_rect_focus_out(void *data, const Efl_Event *event)
83{
84 Evas_Object *rect, *edje_obj;
85 Efl_Input_Device *seat;
86 Eina_Stringshare *name;
87 Efl_Input_Focus *ev;
88
89 edje_obj = data;
90 rect = event->object;
91 ev = event->info;
92 seat = efl_input_device_get(ev);
93 name = edje_obj_seat_name_get(edje_obj, seat);
94
95 printf("Seat %s (%s) unfocused the rect object\n",
96 efl_input_device_name_get(seat), name);
97 evas_object_color_set(rect, 200, 200, 200, 255);
98
99 efl_canvas_object_seat_focus_add(edje_obj, seat);
100}
101
102static void
57_on_key_down(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *o, void *event_info) 103_on_key_down(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *o, void *event_info)
58{ 104{
59 Evas_Event_Key_Down *ev = event_info; 105 Evas_Event_Key_Down *ev = event_info;
@@ -127,7 +173,7 @@ main(int argc EINA_UNUSED, char *argv[] EINA_UNUSED)
127{ 173{
128 const char *edje_file = PACKAGE_DATA_DIR"/multiseat.edj"; 174 const char *edje_file = PACKAGE_DATA_DIR"/multiseat.edj";
129 const Eina_List *devices, *l; 175 const Eina_List *devices, *l;
130 Evas_Object *edje_obj, *bg; 176 Evas_Object *edje_obj, *bg, *rect;
131 Efl_Input_Device *dev; 177 Efl_Input_Device *dev;
132 Ecore_Evas *ee; 178 Ecore_Evas *ee;
133 Evas *evas; 179 Evas *evas;
@@ -174,6 +220,14 @@ main(int argc EINA_UNUSED, char *argv[] EINA_UNUSED)
174 edje_object_part_text_cursor_end_set(edje_obj, "example/text2", 220 edje_object_part_text_cursor_end_set(edje_obj, "example/text2",
175 EDJE_CURSOR_MAIN); 221 EDJE_CURSOR_MAIN);
176 222
223 rect = evas_object_rectangle_add(evas);
224 evas_object_color_set(rect, 200, 200, 200, 255);
225 edje_object_part_swallow(edje_obj, "example/swallow", rect);
226 efl_event_callback_add(rect, EFL_EVENT_FOCUS_IN,
227 _on_rect_focus_in, edje_obj);
228 efl_event_callback_add(rect, EFL_EVENT_FOCUS_OUT,
229 _on_rect_focus_out, edje_obj);
230
177 devices = evas_device_list(evas, NULL); 231 devices = evas_device_list(evas, NULL);
178 EINA_LIST_FOREACH(devices, l, dev) 232 EINA_LIST_FOREACH(devices, l, dev)
179 { 233 {
diff --git a/src/examples/edje/multiseat.edc b/src/examples/edje/multiseat.edc
index aa16309d2f..ce1779bf1c 100644
--- a/src/examples/edje/multiseat.edc
+++ b/src/examples/edje/multiseat.edc
@@ -247,7 +247,7 @@ collections {
247 mouse_events: 1; 247 mouse_events: 1;
248 description { 248 description {
249 state: "default" 0.0; 249 state: "default" 0.0;
250 rel1.relative: 0.3 0.65; 250 rel1.relative: 0.45 0.65;
251 rel2.relative: 0.9 0.9; 251 rel2.relative: 0.9 0.9;
252 color: 200 200 200 255; 252 color: 200 200 200 255;
253 } 253 }
@@ -305,7 +305,7 @@ collections {
305 rel2.to: "button_left_over"; 305 rel2.to: "button_left_over";
306 text { 306 text {
307 text: "Seat 1 over"; 307 text: "Seat 1 over";
308 size: 12; 308 size: 10;
309 font: "sans"; 309 font: "sans";
310 min: 1 1; 310 min: 1 1;
311 } 311 }
@@ -346,7 +346,7 @@ collections {
346 rel2.to: "button_left_focus"; 346 rel2.to: "button_left_focus";
347 text { 347 text {
348 text: "Seat 1 focus"; 348 text: "Seat 1 focus";
349 size: 12; 349 size: 10;
350 font: "sans"; 350 font: "sans";
351 min: 1 1; 351 min: 1 1;
352 } 352 }
@@ -387,7 +387,7 @@ collections {
387 rel2.to: "button_right_over"; 387 rel2.to: "button_right_over";
388 text { 388 text {
389 text: "Seat 2 over"; 389 text: "Seat 2 over";
390 size: 12; 390 size: 10;
391 font: "sans"; 391 font: "sans";
392 min: 1 1; 392 min: 1 1;
393 } 393 }
@@ -428,12 +428,34 @@ collections {
428 rel2.to: "button_right_focus"; 428 rel2.to: "button_right_focus";
429 text { 429 text {
430 text: "Seat 2 focus"; 430 text: "Seat 2 focus";
431 size: 12; 431 size: 10;
432 font: "sans"; 432 font: "sans";
433 min: 1 1; 433 min: 1 1;
434 } 434 }
435 } 435 }
436 } 436 }
437
438 part {
439 name: "unfocus_area";
440 type: RECT;
441 mouse_events: 1;
442 repeat_events: 1;
443 description {
444 state: "default" 0.0;
445 color: 255 255 255 0;
446 }
447 }
448
449 part {
450 name: "example/swallow";
451 type: SWALLOW;
452 mouse_events: 1;
453 description {
454 state: "default" 0.0;
455 rel1.relative: 0.3 0.65;
456 rel2.relative: 0.4 0.9;
457 }
458 }
437 } 459 }
438 460
439 programs { 461 programs {
@@ -668,6 +690,36 @@ collections {
668 action: STATE_SET "default" 0.0; 690 action: STATE_SET "default" 0.0;
669 target: "example/knob2"; 691 target: "example/knob2";
670 } 692 }
693
694 program {
695 name: "rect,focus,s1";
696 signal: "mouse,clicked,1,seat1";
697 source: "example/swallow";
698 action: FOCUS_OBJECT "seat1";
699 target: "example/swallow";
700 }
701
702 program {
703 name: "rect,unfocus,s1";
704 signal: "mouse,clicked,1,seat1";
705 source: "unfocus_area";
706 action: FOCUS_OBJECT "seat1";
707 }
708
709 program {
710 name: "rect,focus,s2";
711 signal: "mouse,clicked,1,seat2";
712 source: "example/swallow";
713 action: FOCUS_OBJECT "seat2";
714 target: "example/swallow";
715 }
716
717 program {
718 name: "rect,unfocus,s2";
719 signal: "mouse,clicked,1,seat2";
720 source: "unfocus_area";
721 action: FOCUS_OBJECT "seat2";
722 }
671 } 723 }
672 } 724 }
673 725
diff --git a/src/lib/edje/edje_program.c b/src/lib/edje/edje_program.c
index 3cc0d2d873..a2df439e87 100644
--- a/src/lib/edje/edje_program.c
+++ b/src/lib/edje/edje_program.c
@@ -1032,11 +1032,29 @@ low_mem_current:
1032 break; 1032 break;
1033 1033
1034 case EDJE_ACTION_TYPE_FOCUS_OBJECT: 1034 case EDJE_ACTION_TYPE_FOCUS_OBJECT:
1035 {
1036 Efl_Input_Device *seat = NULL;
1037
1038 if (pr->seat)
1039 {
1040 Eina_Stringshare *seat_name;
1041
1042 seat_name = eina_stringshare_add(pr->seat);
1043 seat = _edje_seat_get(ed, seat_name);
1044 eina_stringshare_del(seat_name);
1045 }
1046 if (!seat)
1047 {
1048 Evas *e;
1049
1050 e = evas_object_evas_get(ed->obj);
1051 seat = evas_canvas_default_device_get(e, EFL_INPUT_DEVICE_CLASS_SEAT);
1052 }
1035 if (!pr->targets) 1053 if (!pr->targets)
1036 { 1054 {
1037 Evas_Object *focused; 1055 Evas_Object *focused;
1038 1056
1039 focused = evas_focus_get(evas_object_evas_get(ed->obj)); 1057 focused = evas_seat_focus_get(evas_object_evas_get(ed->obj), seat);
1040 if (focused) 1058 if (focused)
1041 { 1059 {
1042 unsigned int i; 1060 unsigned int i;
@@ -1050,7 +1068,7 @@ low_mem_current:
1050 (rp->typedata.swallow)) && 1068 (rp->typedata.swallow)) &&
1051 (rp->typedata.swallow->swallowed_object == focused)) 1069 (rp->typedata.swallow->swallowed_object == focused))
1052 { 1070 {
1053 evas_object_focus_set(focused, EINA_FALSE); 1071 evas_object_seat_focus_del(focused, seat);
1054 break; 1072 break;
1055 } 1073 }
1056 } 1074 }
@@ -1067,11 +1085,13 @@ low_mem_current:
1067 ((rp->type == EDJE_RP_TYPE_SWALLOW) && 1085 ((rp->type == EDJE_RP_TYPE_SWALLOW) &&
1068 (rp->typedata.swallow)) && 1086 (rp->typedata.swallow)) &&
1069 (rp->typedata.swallow->swallowed_object)) 1087 (rp->typedata.swallow->swallowed_object))
1070 evas_object_focus_set(rp->typedata.swallow->swallowed_object, EINA_TRUE); 1088 evas_object_seat_focus_add(
1089 rp->typedata.swallow->swallowed_object, seat);
1071 } 1090 }
1072 } 1091 }
1073 } 1092 }
1074 break; 1093 }
1094 break;
1075 1095
1076 case EDJE_ACTION_TYPE_SOUND_SAMPLE: 1096 case EDJE_ACTION_TYPE_SOUND_SAMPLE:
1077 if (_edje_block_break(ed)) 1097 if (_edje_block_break(ed))