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-14 18:17:28 -0200
commit9a9620864b3aa3d6ee60effa3ec9887a23bf1d1b (patch)
treea6ce1a4d0c1fe9a34fa9a0d3e5a14f59088f7e98
parent1e323e06955056e8fc2c78f90472a18058605ffd (diff)
downloadefl-9a9620864b3aa3d6ee60effa3ec9887a23bf1d1b.tar.gz
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)
@li DRAG_VAL_STEP 1.0 0.0
@li DRAG_VAL_PAGE 0.0 0.0
@li FOCUS_SET ("seat")
- @li FOCUS_OBJECT
+ @li FOCUS_OBJECT ("seat")
@li PARAM_COPY "src_part" "src_param" "dst_part" "dst_param"
@li PARAM_SET "part" "param" "value"
@li PLAY_SAMPLE "sample name" speed (channel)
@@ -14111,7 +14111,7 @@ st_collections_group_programs_program_in(void)
@li PHYSICS_ROT_SET 0.707 0 0 0.707
Only one action can be specified per program.
-
+
PLAY_SAMPLE (optional) channel can be one of:
@li EFFECT/FX
@li BACKGROUND/BG
@@ -14169,9 +14169,10 @@ st_collections_group_programs_program_action(void)
else
ep->value = parse_float_range(2, 0.0, 1.0);
}
- else if (ep->action == EDJE_ACTION_TYPE_FOCUS_SET)
+ else if ((ep->action == EDJE_ACTION_TYPE_FOCUS_SET) ||
+ (ep->action == EDJE_ACTION_TYPE_FOCUS_OBJECT))
{
- if (get_arg_count() == 1)
+ if (get_arg_count() == 1)
ep->seat = NULL;
else
ep->seat = parse_str(1);
@@ -14317,7 +14318,6 @@ st_collections_group_programs_program_action(void)
* completeness */
break;
case EDJE_ACTION_TYPE_ACTION_STOP:
- case EDJE_ACTION_TYPE_FOCUS_OBJECT:
case EDJE_ACTION_TYPE_PHYSICS_FORCES_CLEAR:
case EDJE_ACTION_TYPE_PHYSICS_STOP:
check_arg_count(1);
@@ -14342,6 +14342,7 @@ st_collections_group_programs_program_action(void)
check_min_arg_count(2);
break;
case EDJE_ACTION_TYPE_FOCUS_SET:
+ case EDJE_ACTION_TYPE_FOCUS_OBJECT:
check_min_arg_count(1);
break;
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)
}
static void
+_on_rect_focus_in(void *data, const Efl_Event *event)
+{
+ Evas_Object *rect, *edje_obj;
+ Efl_Input_Device *seat;
+ Eina_Stringshare *name;
+ Efl_Input_Focus *ev;
+
+ edje_obj = data;
+ rect = event->object;
+ ev = event->info;
+ seat = efl_input_device_get(ev);
+ name = edje_obj_seat_name_get(edje_obj, seat);
+
+ printf("Seat %s (%s) focused the rect object\n",
+ efl_input_device_name_get(seat), name);
+
+ if (!strcmp(name, "seat1"))
+ evas_object_color_set(rect, 200, 0, 0, 255);
+ else if (!strcmp(name, "seat2"))
+ evas_object_color_set(rect, 0, 200, 0, 255);
+ else
+ printf("Unexpected seat %s - no color change\n", name);
+}
+
+static void
+_on_rect_focus_out(void *data, const Efl_Event *event)
+{
+ Evas_Object *rect, *edje_obj;
+ Efl_Input_Device *seat;
+ Eina_Stringshare *name;
+ Efl_Input_Focus *ev;
+
+ edje_obj = data;
+ rect = event->object;
+ ev = event->info;
+ seat = efl_input_device_get(ev);
+ name = edje_obj_seat_name_get(edje_obj, seat);
+
+ printf("Seat %s (%s) unfocused the rect object\n",
+ efl_input_device_name_get(seat), name);
+ evas_object_color_set(rect, 200, 200, 200, 255);
+
+ efl_canvas_object_seat_focus_add(edje_obj, seat);
+}
+
+static void
_on_key_down(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *o, void *event_info)
{
Evas_Event_Key_Down *ev = event_info;
@@ -127,7 +173,7 @@ main(int argc EINA_UNUSED, char *argv[] EINA_UNUSED)
{
const char *edje_file = PACKAGE_DATA_DIR"/multiseat.edj";
const Eina_List *devices, *l;
- Evas_Object *edje_obj, *bg;
+ Evas_Object *edje_obj, *bg, *rect;
Efl_Input_Device *dev;
Ecore_Evas *ee;
Evas *evas;
@@ -174,6 +220,14 @@ main(int argc EINA_UNUSED, char *argv[] EINA_UNUSED)
edje_object_part_text_cursor_end_set(edje_obj, "example/text2",
EDJE_CURSOR_MAIN);
+ rect = evas_object_rectangle_add(evas);
+ evas_object_color_set(rect, 200, 200, 200, 255);
+ edje_object_part_swallow(edje_obj, "example/swallow", rect);
+ efl_event_callback_add(rect, EFL_EVENT_FOCUS_IN,
+ _on_rect_focus_in, edje_obj);
+ efl_event_callback_add(rect, EFL_EVENT_FOCUS_OUT,
+ _on_rect_focus_out, edje_obj);
+
devices = evas_device_list(evas, NULL);
EINA_LIST_FOREACH(devices, l, dev)
{
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 {
mouse_events: 1;
description {
state: "default" 0.0;
- rel1.relative: 0.3 0.65;
+ rel1.relative: 0.45 0.65;
rel2.relative: 0.9 0.9;
color: 200 200 200 255;
}
@@ -305,7 +305,7 @@ collections {
rel2.to: "button_left_over";
text {
text: "Seat 1 over";
- size: 12;
+ size: 10;
font: "sans";
min: 1 1;
}
@@ -346,7 +346,7 @@ collections {
rel2.to: "button_left_focus";
text {
text: "Seat 1 focus";
- size: 12;
+ size: 10;
font: "sans";
min: 1 1;
}
@@ -387,7 +387,7 @@ collections {
rel2.to: "button_right_over";
text {
text: "Seat 2 over";
- size: 12;
+ size: 10;
font: "sans";
min: 1 1;
}
@@ -428,12 +428,34 @@ collections {
rel2.to: "button_right_focus";
text {
text: "Seat 2 focus";
- size: 12;
+ size: 10;
font: "sans";
min: 1 1;
}
}
}
+
+ part {
+ name: "unfocus_area";
+ type: RECT;
+ mouse_events: 1;
+ repeat_events: 1;
+ description {
+ state: "default" 0.0;
+ color: 255 255 255 0;
+ }
+ }
+
+ part {
+ name: "example/swallow";
+ type: SWALLOW;
+ mouse_events: 1;
+ description {
+ state: "default" 0.0;
+ rel1.relative: 0.3 0.65;
+ rel2.relative: 0.4 0.9;
+ }
+ }
}
programs {
@@ -668,6 +690,36 @@ collections {
action: STATE_SET "default" 0.0;
target: "example/knob2";
}
+
+ program {
+ name: "rect,focus,s1";
+ signal: "mouse,clicked,1,seat1";
+ source: "example/swallow";
+ action: FOCUS_OBJECT "seat1";
+ target: "example/swallow";
+ }
+
+ program {
+ name: "rect,unfocus,s1";
+ signal: "mouse,clicked,1,seat1";
+ source: "unfocus_area";
+ action: FOCUS_OBJECT "seat1";
+ }
+
+ program {
+ name: "rect,focus,s2";
+ signal: "mouse,clicked,1,seat2";
+ source: "example/swallow";
+ action: FOCUS_OBJECT "seat2";
+ target: "example/swallow";
+ }
+
+ program {
+ name: "rect,unfocus,s2";
+ signal: "mouse,clicked,1,seat2";
+ source: "unfocus_area";
+ action: FOCUS_OBJECT "seat2";
+ }
}
}
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:
break;
case EDJE_ACTION_TYPE_FOCUS_OBJECT:
+ {
+ Efl_Input_Device *seat = NULL;
+
+ if (pr->seat)
+ {
+ Eina_Stringshare *seat_name;
+
+ seat_name = eina_stringshare_add(pr->seat);
+ seat = _edje_seat_get(ed, seat_name);
+ eina_stringshare_del(seat_name);
+ }
+ if (!seat)
+ {
+ Evas *e;
+
+ e = evas_object_evas_get(ed->obj);
+ seat = evas_canvas_default_device_get(e, EFL_INPUT_DEVICE_CLASS_SEAT);
+ }
if (!pr->targets)
{
Evas_Object *focused;
- focused = evas_focus_get(evas_object_evas_get(ed->obj));
+ focused = evas_seat_focus_get(evas_object_evas_get(ed->obj), seat);
if (focused)
{
unsigned int i;
@@ -1050,7 +1068,7 @@ low_mem_current:
(rp->typedata.swallow)) &&
(rp->typedata.swallow->swallowed_object == focused))
{
- evas_object_focus_set(focused, EINA_FALSE);
+ evas_object_seat_focus_del(focused, seat);
break;
}
}
@@ -1067,11 +1085,13 @@ low_mem_current:
((rp->type == EDJE_RP_TYPE_SWALLOW) &&
(rp->typedata.swallow)) &&
(rp->typedata.swallow->swallowed_object))
- evas_object_focus_set(rp->typedata.swallow->swallowed_object, EINA_TRUE);
+ evas_object_seat_focus_add(
+ rp->typedata.swallow->swallowed_object, seat);
}
}
}
- break;
+ }
+ break;
case EDJE_ACTION_TYPE_SOUND_SAMPLE:
if (_edje_block_break(ed))