seoz pushed a commit to branch master.

http://git.enlightenment.org/core/elementary.git/commit/?id=2cc50b3613435429c6642be1235dee0ec7244c53

commit 2cc50b3613435429c6642be1235dee0ec7244c53
Author: Daniel Juyung Seo <[email protected]>
Date:   Thu Mar 20 23:50:46 2014 +0900

    focus: Added optional focus feature - focus movement by mouse_in.
    
    Focus is moved by mouse click by default. This patch makes moving focus
    by mouse_in optionally by configuration and API. Widget item focus
    movement is not applied yet. Need to do that as well.
    
    - configuration: "focus_move_policy"
    - API: elm_config_focus_move_policy_set/get
    - enum
      ELM_FOCUS_MOVE_POLICY_CLICK
      ELM_FOCUS_MOVE_POLICY_IN
    
    @feature
---
 config/default/base.src  |  1 +
 config/mobile/base.src   |  1 +
 config/standard/base.src |  1 +
 src/lib/elm_config.c     | 16 ++++++++++++++++
 src/lib/elm_config.h     | 39 +++++++++++++++++++++++++++++++++++++++
 src/lib/elm_priv.h       |  1 +
 src/lib/elm_widget.c     | 16 +++++++++++++++-
 7 files changed, 74 insertions(+), 1 deletion(-)

diff --git a/config/default/base.src b/config/default/base.src
index 1f274e1..c786049 100644
--- a/config/default/base.src
+++ b/config/default/base.src
@@ -45,6 +45,7 @@ group "Elm_Config" struct {
   value "focus_highlight_enable" uchar: 0;
   value "focus_highlight_animate" uchar: 0;
   value "focus_highlight_clip_disable" uchar: 0;
+  value "focus_move_policy" uchar: 0;
   value "toolbar_shrink_mode" int: 3;
   value "fileselector_expand_enable" uchar: 0;
   value "inwin_dialogs_enable" uchar: 1;
diff --git a/config/mobile/base.src b/config/mobile/base.src
index 9fa7520..60a1521 100644
--- a/config/mobile/base.src
+++ b/config/mobile/base.src
@@ -45,6 +45,7 @@ group "Elm_Config" struct {
   value "focus_highlight_enable" uchar: 0;
   value "focus_highlight_animate" uchar: 0;
   value "focus_highlight_clip_disable" uchar: 0;
+  value "focus_move_policy" uchar: 0;
   value "toolbar_shrink_mode" int: 3;
   value "fileselector_expand_enable" uchar: 0;
   value "inwin_dialogs_enable" uchar: 1;
diff --git a/config/standard/base.src b/config/standard/base.src
index e09e857..838d958 100644
--- a/config/standard/base.src
+++ b/config/standard/base.src
@@ -45,6 +45,7 @@ group "Elm_Config" struct {
   value "focus_highlight_enable" uchar: 0;
   value "focus_highlight_animate" uchar: 0;
   value "focus_highlight_clip_disable" uchar: 1;
+  value "focus_move_policy" uchar: 0;
   value "toolbar_shrink_mode" int: 3;
   value "fileselector_expand_enable" uchar: 1;
   value "fileselector_double_tap_navigation_enable" uchar: 1;
diff --git a/src/lib/elm_config.c b/src/lib/elm_config.c
index dea64ce..754a9b9 100644
--- a/src/lib/elm_config.c
+++ b/src/lib/elm_config.c
@@ -505,6 +505,7 @@ _desc_init(void)
    ELM_CONFIG_VAL(D, T, focus_highlight_enable, T_UCHAR);
    ELM_CONFIG_VAL(D, T, focus_highlight_animate, T_UCHAR);
    ELM_CONFIG_VAL(D, T, focus_highlight_clip_disable, T_UCHAR);
+   ELM_CONFIG_VAL(D, T, focus_move_policy, T_UCHAR);
    ELM_CONFIG_VAL(D, T, toolbar_shrink_mode, T_INT);
    ELM_CONFIG_VAL(D, T, fileselector_expand_enable, T_UCHAR);
    ELM_CONFIG_VAL(D, T, fileselector_double_tap_navigation_enable, T_UCHAR);
@@ -1504,6 +1505,7 @@ _config_load(void)
    _elm_config->focus_highlight_enable = EINA_FALSE;
    _elm_config->focus_highlight_animate = EINA_TRUE;
    _elm_config->focus_highlight_clip_disable = EINA_FALSE;
+   _elm_config->focus_move_policy = ELM_FOCUS_MOVE_POLICY_CLICK;
    _elm_config->toolbar_shrink_mode = 2;
    _elm_config->fileselector_expand_enable = EINA_FALSE;
    _elm_config->fileselector_double_tap_navigation_enable = EINA_FALSE;
@@ -2032,6 +2034,9 @@ _env_get(void)
    s = getenv("ELM_FOCUS_HIGHLIGHT_CLIP_DISABLE");
    if (s) _elm_config->focus_highlight_clip_disable = !!atoi(s);
 
+   s = getenv("ELM_FOCUS_MOVE_POLICY");
+   if (s) _elm_config->focus_move_policy = !!atoi(s);
+
    s = getenv("ELM_TOOLBAR_SHRINK_MODE");
    if (s) _elm_config->toolbar_shrink_mode = atoi(s);
 
@@ -2555,6 +2560,17 @@ elm_config_focus_highlight_clip_disabled_set(Eina_Bool 
disable)
    _elm_config->focus_highlight_clip_disable = !!disable;
 }
 
+EAPI Elm_Focus_Move_Policy
+elm_config_focus_move_policy_get(void)
+{
+   return _elm_config->focus_move_policy;
+}
+
+EAPI void
+elm_config_focus_move_policy_set(Elm_Focus_Move_Policy policy)
+{
+   _elm_config->focus_move_policy = policy;
+}
 
 EAPI Eina_Bool
 elm_config_scroll_bounce_enabled_get(void)
diff --git a/src/lib/elm_config.h b/src/lib/elm_config.h
index bd5a8b5..e1494e0 100644
--- a/src/lib/elm_config.h
+++ b/src/lib/elm_config.h
@@ -1239,6 +1239,45 @@ EAPI Eina_Bool 
elm_config_focus_highlight_clip_disabled_get(void);
 EAPI void elm_config_focus_highlight_clip_disabled_set(Eina_Bool disable);
 
 /**
+ * Focus Movement Policy
+ *
+ * @since 1.10
+ * @ingroup Focus
+ */
+typedef enum
+{
+   ELM_FOCUS_MOVE_POLICY_CLICK,
+   ELM_FOCUS_MOVE_POLICY_IN
+} Elm_Focus_Move_Policy;
+
+/**
+ * Get the focus movement policy
+ *
+ * @return The focus movement policy
+ *
+ * Get how the focus is moved to another object. It can be @c
+ * ELM_FOCUS_MOVE_POLICY_CLICK or @c ELM_FOCUS_MOVE_POLICY_IN. The first means
+ * elementary focus is moved on elementary object click. The second means
+ * elementary focus is moved on elementary object mouse in.
+ *
+ * @see elm_config_focus_move_policy_set()
+ * @since 1.10
+ * @ingroup Focus
+ */
+EAPI Elm_Focus_Move_Policy elm_config_focus_move_policy_get(void);
+
+/**
+ * Set elementary focus movement policy
+ *
+ * @param policy A policy to apply for the focus movement
+ *
+ * @see elm_config_focus_move_policy_get()
+ * @since 1.10
+ * @ingroup Focus
+ */
+EAPI void elm_config_focus_move_policy_set(Elm_Focus_Move_Policy policy);
+
+/**
  * Get the system mirrored mode. This determines the default mirrored mode
  * of widgets.
  *
diff --git a/src/lib/elm_priv.h b/src/lib/elm_priv.h
index 85e421c..f977cbc 100644
--- a/src/lib/elm_priv.h
+++ b/src/lib/elm_priv.h
@@ -224,6 +224,7 @@ struct _Elm_Config
    unsigned char focus_highlight_enable;
    unsigned char focus_highlight_animate;
    unsigned char focus_highlight_clip_disable; /**< This shows disabled status 
of focus highlight clip feature. This value is false by default so the focus 
highlight is clipped. */
+   unsigned char focus_move_policy; /**< This show how the elementary focus is 
moved to another object. Focus can be moved by click or mouse_in. */
    int           toolbar_shrink_mode;
    unsigned char fileselector_expand_enable;
    unsigned char fileselector_double_tap_navigation_enable;
diff --git a/src/lib/elm_widget.c b/src/lib/elm_widget.c
index 973b113..4249d75 100644
--- a/src/lib/elm_widget.c
+++ b/src/lib/elm_widget.c
@@ -250,11 +250,23 @@ _obj_mouse_up(void *data,
               void *event_info EINA_UNUSED)
 {
    ELM_WIDGET_DATA_GET(data, sd);
-   if (sd->still_in)
+   if (sd->still_in &&
+       (_elm_config->focus_move_policy == ELM_FOCUS_MOVE_POLICY_CLICK))
      elm_widget_focus_mouse_up_handle(obj);
+
    sd->still_in = EINA_FALSE;
 }
 
+static void
+_obj_mouse_in(void *data EINA_UNUSED,
+              Evas *e EINA_UNUSED,
+              Evas_Object *obj,
+              void *event_info EINA_UNUSED)
+{
+   if (_elm_config->focus_move_policy == ELM_FOCUS_MOVE_POLICY_IN)
+     elm_widget_focus_mouse_up_handle(obj);
+}
+
 EOLIAN static void
 _elm_widget_evas_smart_add(Eo *obj, Elm_Widget_Smart_Data *priv)
 {
@@ -271,6 +283,8 @@ _elm_widget_evas_smart_add(Eo *obj, Elm_Widget_Smart_Data 
*priv)
                                   _obj_mouse_move, obj);
    evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_UP,
                                   _obj_mouse_up, obj);
+   evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_IN,
+                                  _obj_mouse_in, obj);
    /* just a helper for inheriting classes */
    if (priv->resize_obj)
      {

-- 


Reply via email to