From c467dc6e813cf5725e9f45f86e2d6db6e5b5ae8f Mon Sep 17 00:00:00 2001 From: Marcel Hollerbach Date: Fri, 23 Aug 2019 12:03:24 +0200 Subject: [PATCH] efl_ui_item: add keybindings for selecting changes This started as a small commit, when pressing enter -> set the item as selected. However, it was a bit more complex, it seems that there was never config update code to copy bindings into the user profile. Which lead to the fact that you are missing a lot of keyboard related features if you havnt wiped your config in the last 1-2 years. For me keybindings for Efl.Ui.Scroller Tab_Bar Image_Zoomable (Item) have been missing and were never inserted. WHich is a problem for a user just constantly updating. For now i created a function that copies over the bindings from the system config, and they are merged into the user config. Intentional leaving our of keybinding structs for a user-config will result in them beeing merged again on the next config update. If you want to get rid of key bindings as a user you can just keep the empty struct, which is the signal for "i know what i am doing, i do not want to have them". The problem that the system config is partly invalidated (due to moving the key bindings struct to the user config), is fixed due to the fact that the config is reloaded after that. This function should be called everytime someone updates the config in regards of the keybindings. Reviewed-by: Mike Blumenkrantz Differential Revision: https://phab.enlightenment.org/D9723 --- data/elementary/config/default/base.src.in | 25 +++++++++++++- data/elementary/config/mobile/base.src.in | 25 +++++++++++++- data/elementary/config/standard/base.src.in | 25 +++++++++++++- src/lib/elementary/efl_ui_item.c | 15 +++++++++ src/lib/elementary/efl_ui_item.eo | 1 + src/lib/elementary/elm_config.c | 36 +++++++++++++++++++++ src/lib/elementary/elm_priv.h | 2 +- 7 files changed, 125 insertions(+), 4 deletions(-) diff --git a/data/elementary/config/default/base.src.in b/data/elementary/config/default/base.src.in index 79f7a1bb55..c39aeeed70 100644 --- a/data/elementary/config/default/base.src.in +++ b/data/elementary/config/default/base.src.in @@ -1,5 +1,5 @@ group "Elm_Config" struct { - value "config_version" int: 131093; + value "config_version" int: 131094; value "entry_select_allow" uchar: 1; value "engine" string: ""; value "vsync" uchar: 0; @@ -2634,6 +2634,29 @@ group "Elm_Config" struct { } } } + group "Elm_Config_Bindings_Widget" struct { + value "name" string: "Efl.Ui.Item"; + group "key_bindings" list { + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Return"; + value "action" string: "select"; + value "params" string: ""; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Enter"; + value "action" string: "select"; + value "params" string: ""; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "space"; + value "action" string: "select"; + value "params" string: ""; + } + } + } group "Elm_Config_Bindings_Widget" struct { value "name" string: "Efl.Ui.Tab_Bar"; group "key_bindings" list { diff --git a/data/elementary/config/mobile/base.src.in b/data/elementary/config/mobile/base.src.in index 9397150576..520ba90d73 100644 --- a/data/elementary/config/mobile/base.src.in +++ b/data/elementary/config/mobile/base.src.in @@ -1,5 +1,5 @@ group "Elm_Config" struct { - value "config_version" int: 131093; + value "config_version" int: 131094; value "entry_select_allow" uchar: 1; value "engine" string: ""; value "vsync" uchar: 0; @@ -2631,6 +2631,29 @@ group "Elm_Config" struct { } } } + group "Elm_Config_Bindings_Widget" struct { + value "name" string: "Efl.Ui.Item"; + group "key_bindings" list { + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Return"; + value "action" string: "select"; + value "params" string: ""; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Enter"; + value "action" string: "select"; + value "params" string: ""; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "space"; + value "action" string: "select"; + value "params" string: ""; + } + } + } group "Elm_Config_Bindings_Widget" struct { value "name" string: "Efl.Ui.Tab_Bar"; group "key_bindings" list { diff --git a/data/elementary/config/standard/base.src.in b/data/elementary/config/standard/base.src.in index ccfa97b05e..0aa4e8f017 100644 --- a/data/elementary/config/standard/base.src.in +++ b/data/elementary/config/standard/base.src.in @@ -1,5 +1,5 @@ group "Elm_Config" struct { - value "config_version" int: 131093; + value "config_version" int: 131094; value "entry_select_allow" uchar: 1; value "engine" string: ""; value "vsync" uchar: 0; @@ -2628,6 +2628,29 @@ group "Elm_Config" struct { } } } + group "Elm_Config_Bindings_Widget" struct { + value "name" string: "Efl.Ui.Item"; + group "key_bindings" list { + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Return"; + value "action" string: "select"; + value "params" string: ""; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Enter"; + value "action" string: "select"; + value "params" string: ""; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "space"; + value "action" string: "select"; + value "params" string: ""; + } + } + } group "Elm_Config_Bindings_Widget" struct { value "name" string: "Efl.Ui.Tab_Bar"; group "key_bindings" list { diff --git a/src/lib/elementary/efl_ui_item.c b/src/lib/elementary/efl_ui_item.c index 7324ab062a..bd6de1a28a 100644 --- a/src/lib/elementary/efl_ui_item.c +++ b/src/lib/elementary/efl_ui_item.c @@ -12,6 +12,20 @@ #define MY_CLASS_NAME "Efl.Ui.Item" +static Eina_Bool _key_action_select(Evas_Object *obj, const char *params EINA_UNUSED); + +static const Elm_Action key_actions[] = { + {"select", _key_action_select}, + {NULL, NULL} +}; + +static Eina_Bool +_key_action_select(Evas_Object *obj, const char *params EINA_UNUSED) +{ + efl_ui_selectable_selected_set(obj, EINA_TRUE); + return EINA_FALSE; +} + static Efl_Ui_Select_Mode _fetch_state(Eo *obj) { @@ -194,6 +208,7 @@ _efl_ui_item_item_parent_get(const Eo *obj EINA_UNUSED, Efl_Ui_Item_Data *pd) return pd->parent; } +ELM_WIDGET_KEY_DOWN_DEFAULT_IMPLEMENT(efl_ui_item, Efl_Ui_Item_Data) #include "efl_ui_item.eo.c" #include "efl_ui_selectable.eo.c" diff --git a/src/lib/elementary/efl_ui_item.eo b/src/lib/elementary/efl_ui_item.eo index 7dc9060efd..82af0a5fe0 100644 --- a/src/lib/elementary/efl_ui_item.eo +++ b/src/lib/elementary/efl_ui_item.eo @@ -55,5 +55,6 @@ abstract @beta Efl.Ui.Item extends Efl.Ui.Layout_Base implements Efl.Ui.Selectab Efl.Object.finalize; Efl.Object.destructor; Efl.Ui.Selectable.selected {get; set;} + Efl.Ui.Widget.widget_input_event_handler; } } diff --git a/src/lib/elementary/elm_config.c b/src/lib/elementary/elm_config.c index 484728627b..e8418b50eb 100644 --- a/src/lib/elementary/elm_config.c +++ b/src/lib/elementary/elm_config.c @@ -2292,6 +2292,35 @@ _elm_key_bindings_update(Elm_Config *cfg, Elm_Config *syscfg EINA_UNUSED) } } +static void +_elm_key_bindings_copy_missing_bindings(Elm_Config *cfg, Elm_Config *syscfg) +{ + Eina_Hash *safed_bindings = eina_hash_string_superfast_new(NULL); + Elm_Config_Bindings_Widget *wd; + Eina_List *n, *nnext; + Eina_Bool missing_bindings = EINA_FALSE; + + EINA_LIST_FOREACH(cfg->bindings, n, wd) + { + eina_hash_add(safed_bindings, wd->name, wd); + } + + EINA_LIST_FOREACH_SAFE(syscfg->bindings, n, nnext, wd) + { + if (!eina_hash_find(safed_bindings, wd->name)) + { + syscfg->bindings = eina_list_remove_list(syscfg->bindings, n); + cfg->bindings = eina_list_append(cfg->bindings, wd); + printf("Upgraded keybindings for %s!\n", wd->name); + missing_bindings = EINA_TRUE; + } + } + if (missing_bindings) + { + printf("There have been missing Key bindings in the config, config is now adjusted\n"); + } +} + static void _config_update(void) { @@ -2415,6 +2444,13 @@ _config_update(void) _elm_config->win_no_border = EINA_FALSE; IFCFGEND + IFCFG(0x0022) + + _elm_key_bindings_copy_missing_bindings(_elm_config, tcfg); + /* after this function call, the tcfg is partly invalidated, reload! */ + _config_free(tcfg); + tcfg = _config_system_load(); + IFCFGEND /** * Fix user config for current ELM_CONFIG_EPOCH here. **/ diff --git a/src/lib/elementary/elm_priv.h b/src/lib/elementary/elm_priv.h index 97727723ac..a4b1a35735 100644 --- a/src/lib/elementary/elm_priv.h +++ b/src/lib/elementary/elm_priv.h @@ -268,7 +268,7 @@ struct _Efl_Ui_Theme_Data * the users config doesn't need to be wiped - simply new values need * to be put in */ -# define ELM_CONFIG_FILE_GENERATION 0x0015 +# define ELM_CONFIG_FILE_GENERATION 0x0016 # define ELM_CONFIG_VERSION_EPOCH_OFFSET 16 # define ELM_CONFIG_VERSION ((ELM_CONFIG_EPOCH << ELM_CONFIG_VERSION_EPOCH_OFFSET) | \ ELM_CONFIG_FILE_GENERATION)