woohyun pushed a commit to branch master.
commit 1489c12a91301732cd69e4474e93f0c9d019b8a5
Author: WooHyun Jung <[email protected]>
Date: Fri Mar 8 16:23:34 2013 +0900
Add elm_widget_newest_focus_order_get function for fixing a bug in elm_win.
After elm_win is created, if there is no manual focus setting, only elm_win
should get focus when focus state is changed.
---
ChangeLog | 5 +++
NEWS | 2 ++
src/lib/elm_widget.c | 95 ++++++++++++++++++++++++++++++----------------------
src/lib/elm_widget.h | 15 +++++++++
src/lib/elm_win.c | 7 ++--
5 files changed, 80 insertions(+), 44 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ff4cdcb..f900e10 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1123,3 +1123,8 @@
* Add elm_naviframe_item_pop_cb_set().
* Naviframe works for H/W backkey event.
+
+2013-03-08 WooHyun Jung
+
+ * Add elm_widget_newest_focus_order_get for knowing the last
object(and its focus order) which got focus.
+ * After elm_win is created, if there is no manual focus setting, only
elm_win should get focus when focus state is changed.
diff --git a/NEWS b/NEWS
index 4d949a8..ca97638 100644
--- a/NEWS
+++ b/NEWS
@@ -48,6 +48,7 @@ Additions:
* Add elm_object_item_signal_callback_add(),
elm_object_item_signal_callback_del().
* Add the config ELM_THUMBSCROLL_HOLD_THRESHOLD.
* Add elm_naviframe_item_pop_cb_set().
+ * Add elm_widget_newest_focus_order_get for knowing the last object(and its
focus order) which got focus.
Improvements:
@@ -175,6 +176,7 @@ Fixes:
* Focus highlight should not be shown on (0 ,0).
* Fix elm_conform didn't set size hint when keypad on.
* Fix elm_conform didn't change indicator mode when create.
+ * After elm_win is created, if there is no manual focus setting, only
elm_win should get focus when focus state is changed.
Removals:
diff --git a/src/lib/elm_widget.c b/src/lib/elm_widget.c
index 0d5a2cb..5b3b97c 100644
--- a/src/lib/elm_widget.c
+++ b/src/lib/elm_widget.c
@@ -188,42 +188,6 @@ _elm_widget_smart_add(Eo *obj, void *_pd, va_list *list
EINA_UNUSED)
}
}
-static Evas_Object *
-_newest_focus_order_get(Evas_Object *obj,
- unsigned int *newest_focus_order,
- Eina_Bool can_focus_only)
-{
- const Eina_List *l;
- Evas_Object *child, *ret, *best;
-
- API_ENTRY return NULL;
-
- if (!evas_object_visible_get(obj)
- || (elm_widget_disabled_get(obj))
- || (elm_widget_tree_unfocusable_get(obj)))
- return NULL;
-
- best = NULL;
- if (*newest_focus_order < sd->focus_order)
- {
- *newest_focus_order = sd->focus_order;
- best = obj;
- }
- EINA_LIST_FOREACH(sd->subobjs, l, child)
- {
- ret = _newest_focus_order_get
- (child, newest_focus_order, can_focus_only);
- if (!ret) continue;
- best = ret;
- }
- if (can_focus_only)
- {
- if ((!best) || (!elm_widget_can_focus_get(best)))
- return NULL;
- }
- return best;
-}
-
static void
_if_focused_revert(Evas_Object *obj,
Eina_Bool can_focus_only)
@@ -240,8 +204,8 @@ _if_focused_revert(Evas_Object *obj,
top = elm_widget_top_get(sd->parent_obj);
if (top)
{
- newest = _newest_focus_order_get
- (top, &newest_focus_order, can_focus_only);
+ newest = elm_widget_newest_focus_order_get
+ (top, &newest_focus_order, can_focus_only);
if (newest)
{
elm_object_focus_set(newest, EINA_FALSE);
@@ -2445,7 +2409,6 @@ elm_widget_focus_direction_get(const Evas_Object *obj,
Evas_Object **direction,
double *weight)
{
-
ELM_WIDGET_CHECK(obj) EINA_FALSE;
Eina_Bool ret = EINA_FALSE;
eo_do((Eo *) obj, elm_wdg_focus_direction_get(base, degree, direction,
weight, &ret));
@@ -3079,7 +3042,7 @@ _elm_widget_focus_restore(Eo *obj, void *_pd EINA_UNUSED,
va_list *list EINA_UNU
Evas_Object *newest = NULL;
unsigned int newest_focus_order = 0;
- newest = _newest_focus_order_get(obj, &newest_focus_order, EINA_TRUE);
+ newest = elm_widget_newest_focus_order_get(obj, &newest_focus_order,
EINA_TRUE);
if (newest)
{
elm_object_focus_set(newest, EINA_FALSE);
@@ -4346,6 +4309,56 @@ _elm_widget_focus_order_get(Eo *obj EINA_UNUSED, void
*_pd, va_list *list)
*ret = sd->focus_order;
}
+EAPI Evas_Object *
+elm_widget_newest_focus_order_get(Evas_Object *obj,
+ unsigned int *newest_focus_order,
+ Eina_Bool can_focus_only)
+{
+ ELM_WIDGET_CHECK(obj) NULL;
+ Evas_Object *ret = NULL;
+ eo_do((Eo *) obj, elm_wdg_newest_focus_order_get(newest_focus_order,
can_focus_only, &ret));
+ return ret;
+}
+
+static void
+_elm_widget_newest_focus_order_get(Eo *obj, void *_pd, va_list *list)
+{
+ unsigned int *newest_focus_order = va_arg(*list, unsigned int *);
+ Eina_Bool can_focus_only = va_arg(*list, int);
+ Evas_Object **ret = va_arg(*list, Evas_Object **);
+ Elm_Widget_Smart_Data *sd = _pd;
+ *ret = NULL;
+
+ const Eina_List *l;
+ Evas_Object *child, *cur, *best;
+
+ if (!evas_object_visible_get(obj)
+ || (elm_widget_disabled_get(obj))
+ || (elm_widget_tree_unfocusable_get(obj)))
+ return;
+
+ best = NULL;
+ if (*newest_focus_order < sd->focus_order)
+ {
+ *newest_focus_order = sd->focus_order;
+ best = obj;
+ }
+ EINA_LIST_FOREACH(sd->subobjs, l, child)
+ {
+ cur = elm_widget_newest_focus_order_get
+ (child, newest_focus_order, can_focus_only);
+ if (!cur) continue;
+ best = cur;
+ }
+ if (can_focus_only)
+ {
+ if ((!best) || (!elm_widget_can_focus_get(best)))
+ return;
+ }
+ *ret = best;
+ return;
+}
+
EAPI void
elm_widget_activate(Evas_Object *obj, Elm_Activate act)
{
@@ -5712,6 +5725,7 @@ _class_constructor(Eo_Class *klass)
EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_TREE_UNFOCUSABLE_GET),
_elm_widget_tree_unfocusable_get),
EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_CAN_FOCUS_CHILD_LIST_GET),
_elm_widget_can_focus_child_list_get),
+ EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_NEWEST_FOCUS_ORDER_GET),
_elm_widget_newest_focus_order_get),
EO_OP_FUNC_SENTINEL
};
@@ -5853,6 +5867,7 @@ static const Eo_Op_Description op_desc[] = {
EO_OP_DESCRIPTION(ELM_WIDGET_SUB_ID_TREE_UNFOCUSABLE_GET, "Returns true,
if the object sub-tree is unfocusable"),
EO_OP_DESCRIPTION(ELM_WIDGET_SUB_ID_CAN_FOCUS_CHILD_LIST_GET, "Get the
list of focusable child objects."),
+ EO_OP_DESCRIPTION(ELM_WIDGET_SUB_ID_NEWEST_FOCUS_ORDER_GET, "Get the
newest focused object and its order."),
EO_OP_DESCRIPTION_SENTINEL
};
diff --git a/src/lib/elm_widget.h b/src/lib/elm_widget.h
index f8d0cb0..0847333 100644
--- a/src/lib/elm_widget.h
+++ b/src/lib/elm_widget.h
@@ -633,6 +633,7 @@ EAPI Evas_Object *elm_widget_parent_get(const
Evas_Object *obj);
EAPI Evas_Object *elm_widget_parent2_get(const Evas_Object *obj);
EAPI void elm_widget_parent2_set(Evas_Object *obj, Evas_Object
*parent);
EAPI void elm_widget_focus_steal(Evas_Object *obj);
+EAPI Evas_Object *elm_widget_newest_focus_order_get(Evas_Object *obj,
unsigned int *newest_focus_order, Eina_Bool can_focus_only);
EAPI Evas_Display_Mode elm_widget_display_mode_get(const Evas_Object *obj);
EAPI void elm_widget_display_mode_set(Evas_Object *obj,
Evas_Display_Mode dispmode);
EAPI const Elm_Widget_Smart_Class *elm_widget_smart_class_get(void);
@@ -1153,6 +1154,7 @@ enum
ELM_WIDGET_SUB_ID_TREE_UNFOCUSABLE_GET,
ELM_WIDGET_SUB_ID_CAN_FOCUS_CHILD_LIST_GET,
+ ELM_WIDGET_SUB_ID_NEWEST_FOCUS_ORDER_GET,
#if 0
ELM_WIDGET_SUB_ID_THEME, /* API + virtual*/
ELM_WIDGET_SUB_ID_THEME_SPECIFIC,
@@ -2399,6 +2401,19 @@ typedef void * (*list_data_get_func_type)(const
Eina_List * l);
#define elm_wdg_can_focus_child_list_get(ret)
ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_CAN_FOCUS_CHILD_LIST_GET),
EO_TYPECHECK(Eina_List **, ret)
/**
+ * @def elm_wdg_newest_focus_order_get
+ * @since 1.8
+ *
+ * No description supplied by the EAPI.
+ *
+ * @param[out] newest_focus_order
+ * @param[in] can_focus_only
+ * @param[out] ret
+ *
+ */
+#define elm_wdg_newest_focus_order_get(newest_focus_order, can_focus_only,
ret) ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_NEWEST_FOCUS_ORDER_GET),
EO_TYPECHECK(unsigned int *, newest_focus_order), EO_TYPECHECK(Eina_Bool,
can_focus_only), EO_TYPECHECK(Evas_Object **, ret)
+
+/**
* @def elm_wdg_orientation_set
* @since 1.8
*
diff --git a/src/lib/elm_win.c b/src/lib/elm_win.c
index 786cc6e..4bb366f 100644
--- a/src/lib/elm_win.c
+++ b/src/lib/elm_win.c
@@ -93,7 +93,6 @@ struct _Elm_Win_Smart_Data
} shot;
int resize_location;
int *autodel_clear, rot;
- int show_count;
struct
{
int x, y;
@@ -786,16 +785,17 @@ _elm_win_focus_in(Ecore_Evas *ee)
{
Elm_Win_Smart_Data *sd = _elm_win_associate_get(ee);
Evas_Object *obj;
+ unsigned int order = 0;
EINA_SAFETY_ON_NULL_RETURN(sd);
obj = sd->obj;
_elm_widget_top_win_focused_set(obj, EINA_TRUE);
- if (!elm_widget_focus_order_get(obj))
+ if (!elm_widget_focus_order_get(obj)
+ || (obj == elm_widget_newest_focus_order_get(obj, &order, EINA_TRUE)))
{
elm_widget_focus_steal(obj);
- sd->show_count++;
}
else
elm_widget_focus_restore(obj);
@@ -1210,7 +1210,6 @@ _elm_win_smart_show(Eo *obj, void *_pd, va_list *list
EINA_UNUSED)
TRAP(sd, show);
- if (!sd->show_count) sd->show_count++;
if (sd->shot.info) _shot_handle(sd);
}
--
------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
endpoint security space. For insight on selecting the right partner to
tackle endpoint security challenges, access the full report.
http://p.sf.net/sfu/symantec-dev2dev