diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/elm_config.c | 1 | ||||
-rw-r--r-- | src/lib/elm_focus.h | 30 | ||||
-rw-r--r-- | src/lib/elm_main.c | 14 | ||||
-rw-r--r-- | src/lib/elm_priv.h | 1 | ||||
-rw-r--r-- | src/lib/elm_widget.c | 78 | ||||
-rw-r--r-- | src/lib/elm_widget.eo | 12 | ||||
-rw-r--r-- | src/lib/elm_widget.h | 4 | ||||
-rw-r--r-- | src/lib/elm_win.c | 10 |
8 files changed, 150 insertions, 0 deletions
diff --git a/src/lib/elm_config.c b/src/lib/elm_config.c index d957aa995..6bb1363bc 100644 --- a/src/lib/elm_config.c +++ b/src/lib/elm_config.c @@ -3103,6 +3103,7 @@ EAPI void elm_config_focus_move_policy_set(Elm_Focus_Move_Policy policy) { _elm_config->focus_move_policy = policy; + _elm_win_focus_reconfigure(); } EAPI Eina_Bool diff --git a/src/lib/elm_focus.h b/src/lib/elm_focus.h index 4864bdd85..7c114ab15 100644 --- a/src/lib/elm_focus.h +++ b/src/lib/elm_focus.h @@ -370,3 +370,33 @@ EAPI void elm_object_focus_region_show_mode_set(Evas_Objec * @ingroup Elm_Focus */ EAPI Elm_Focus_Region_Show_Mode elm_object_focus_region_show_mode_get(const Evas_Object *obj); + +/** + * Returns the widget's focus movement policy mode setting. + * + * @param obj The widget. + * @return focus movement policy mode setting of the object. + * + * @see elm_object_focus_move_policy_automatic_set + * + * @since 1.18 + * + * @ingroup Focus + */ +EAPI Eina_Bool elm_object_focus_move_policy_automatic_get(const Evas_Object *obj); + +/** + * Sets the widget's focus movement policy mode setting. + * When widget in automatic mode, it follows the system focus movement policy mode + * set by elm_config_focus_move_policy_set(). + * @param obj The widget. + * @param automatic @c EINA_TRUE for auto focus_move_policy mode. @c EINA_FALSE for + * manual. + * + * @see elm_object_focus_move_policy_automatic_get + * + * @since 1.18 + * + * @ingroup Focus + */ +EAPI void elm_object_focus_move_policy_automatic_set(Evas_Object *obj, Eina_Bool automatic); diff --git a/src/lib/elm_main.c b/src/lib/elm_main.c index 0bb4c4d4b..d0bbb7d71 100644 --- a/src/lib/elm_main.c +++ b/src/lib/elm_main.c @@ -1523,6 +1523,20 @@ elm_object_focus_move_policy_get(const Evas_Object *obj) return elm_widget_focus_move_policy_get(obj); } +EAPI Eina_Bool +elm_object_focus_move_policy_automatic_get(const Evas_Object *obj) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE); + return elm_widget_focus_move_policy_automatic_get(obj); +} + +EAPI void +elm_object_focus_move_policy_automatic_set(Evas_Object *obj, Eina_Bool automatic) +{ + EINA_SAFETY_ON_NULL_RETURN(obj); + elm_widget_focus_move_policy_automatic_set(obj, automatic); +} + EAPI void elm_object_scroll_hold_push(Evas_Object *obj) { diff --git a/src/lib/elm_priv.h b/src/lib/elm_priv.h index 91b4285a6..f8a57860d 100644 --- a/src/lib/elm_priv.h +++ b/src/lib/elm_priv.h @@ -386,6 +386,7 @@ void _elm_win_rescale(Elm_Theme *th, Eina_Bool use_theme); void _elm_win_access(Eina_Bool is_access); void _elm_win_translate(void); +void _elm_win_focus_reconfigure(void); Ecore_X_Window _elm_ee_xwin_get(const Ecore_Evas *ee); diff --git a/src/lib/elm_widget.c b/src/lib/elm_widget.c index ac7aeb3e7..b110f323a 100644 --- a/src/lib/elm_widget.c +++ b/src/lib/elm_widget.c @@ -342,6 +342,7 @@ _elm_widget_evas_object_smart_add(Eo *obj, Elm_Widget_Smart_Data *priv) priv->obj = obj; priv->mirrored_auto_mode = EINA_TRUE; /* will follow system locale * settings */ + priv->focus_move_policy_auto_mode = EINA_TRUE; priv->focus_region_show_mode = ELM_FOCUS_REGION_SHOW_WIDGET; elm_widget_can_focus_set(obj, EINA_TRUE); priv->is_mirrored = elm_config_mirrored_get(); @@ -3576,6 +3577,46 @@ _elm_widget_translate(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSE return EINA_TRUE; } +/** + * @internal + * + * Resets the focus_move_policy mode from the system one + * for widgets that are in automatic mode. + * + * @param obj The widget. + * + */ +static void +_elm_widget_focus_move_policy_reload(Evas_Object *obj) +{ + API_ENTRY return; + Elm_Focus_Move_Policy focus_move_policy = elm_config_focus_move_policy_get(); + + if (elm_widget_focus_move_policy_automatic_get(obj) && + (sd->focus_move_policy != focus_move_policy)) + { + sd->focus_move_policy = focus_move_policy; + } +} + +EOLIAN static void +_elm_widget_focus_reconfigure(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED) +{ + const Eina_List *l; + Evas_Object *child; + API_ENTRY return; + + EINA_LIST_FOREACH(sd->subobjs, l, child) + { + if (elm_widget_is(child)) + elm_widget_focus_reconfigure(child); + } + + if (sd->hover_obj) elm_widget_focus_reconfigure(sd->hover_obj); + + _elm_widget_focus_move_policy_reload(obj); +} + EAPI void elm_widget_content_part_set(Evas_Object *obj, const char *part, @@ -4244,6 +4285,43 @@ _elm_widget_focus_move_policy_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd if (sd->focus_move_policy == policy) return; sd->focus_move_policy = policy; } + +/** + * Returns the widget's focus_move_policy mode setting. + * + * @param obj The widget. + * @return focus_move_policy mode setting of the object. + * + **/ +EOLIAN static Eina_Bool +_elm_widget_focus_move_policy_automatic_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd) +{ + return sd->focus_move_policy_auto_mode; +} + +/** + * @internal + * + * Sets the widget's focus_move_policy mode setting. + * When widget in automatic mode, it follows the system focus_move_policy mode set by + * elm_config_focus_move_policy_set(). + * @param obj The widget. + * @param automatic EINA_TRUE for auto focus_move_policy mode. EINA_FALSE for manual. + */ +EOLIAN static void +_elm_widget_focus_move_policy_automatic_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool automatic) +{ + if (sd->focus_move_policy_auto_mode != automatic) + { + sd->focus_move_policy_auto_mode = automatic; + + if (automatic) + { + elm_widget_focus_move_policy_set(obj, elm_config_focus_move_policy_get()); + } + } +} + static void _track_obj_del(void *data, Evas *e, Evas_Object *obj, void *event_info); diff --git a/src/lib/elm_widget.eo b/src/lib/elm_widget.eo index e5db7679d..b618b4dcc 100644 --- a/src/lib/elm_widget.eo +++ b/src/lib/elm_widget.eo @@ -821,6 +821,18 @@ abstract Elm.Widget (Evas.Object_Smart, Elm.Interface_Atspi_Accessible, Elm.Inte policy: Elm.Focus.Move_Policy; [[Object's focus move policy.]] } } + @property focus_move_policy_automatic { + [[Control the widget's focus_move_policy mode setting.]] + set { + } + get { + } + values { + automatic: bool; [[$true to follow system focus move policy change, $false otherwise]] + } + } + focus_reconfigure { + } } implements { class.constructor; diff --git a/src/lib/elm_widget.h b/src/lib/elm_widget.h index f5b8626e5..e0d5b8e0d 100644 --- a/src/lib/elm_widget.h +++ b/src/lib/elm_widget.h @@ -439,6 +439,7 @@ typedef struct _Elm_Widget_Smart_Data Eina_Bool focused : 1; Eina_Bool top_win_focused : 1; Eina_Bool tree_unfocusable : 1; + Eina_Bool focus_move_policy_auto_mode : 1; /* This is TRUE by default */ Eina_Bool highlight_ignore : 1; Eina_Bool highlight_in_theme : 1; Eina_Bool access_highlight_in_theme : 1; @@ -766,8 +767,11 @@ EAPI void elm_widget_focus_highlight_geometry_get(const Evas_Object void _elm_widget_item_highlight_in_theme(Evas_Object *obj, Elm_Object_Item *it); EAPI void elm_widget_focus_move_policy_set(Evas_Object *obj, Elm_Focus_Move_Policy policy); EAPI Elm_Focus_Move_Policy elm_widget_focus_move_policy_get(const Evas_Object *obj); +EAPI Eina_Bool elm_widget_focus_move_policy_automatic_get(const Evas_Object *obj); +EAPI void elm_widget_focus_move_policy_automatic_set(Evas_Object *obj, Eina_Bool automatic); EAPI void elm_widget_focus_region_show_mode_set(Evas_Object *obj, Elm_Focus_Region_Show_Mode mode); EAPI Elm_Focus_Region_Show_Mode elm_widget_focus_region_show_mode_get(const Evas_Object *obj); +EAPI void elm_widget_focus_reconfigure(Evas_Object *obj); /** * Function to operate on a given widget's scrollabe children when necessary. diff --git a/src/lib/elm_win.c b/src/lib/elm_win.c index c7b23daa9..f903154b2 100644 --- a/src/lib/elm_win.c +++ b/src/lib/elm_win.c @@ -2547,6 +2547,16 @@ _elm_win_translate(void) elm_widget_translate(obj); } +void +_elm_win_focus_reconfigure(void) +{ + const Eina_List *l; + Evas_Object *obj; + + EINA_LIST_FOREACH(_elm_win_list, l, obj) + elm_widget_focus_reconfigure(obj); +} + #ifdef HAVE_ELEMENTARY_X static Eina_Bool _elm_win_client_message(void *data, |