bu5hm4n pushed a commit to branch master. http://git.enlightenment.org/core/enlightenment.git/commit/?id=30b22f30af9a95e63c5fdf0f7d042262390c3131
commit 30b22f30af9a95e63c5fdf0f7d042262390c3131 Author: Marcel Hollerbach <marcel-hollerb...@t-online.de> Date: Thu Jun 30 20:24:21 2016 +0200 e_xkb: use the new e_comp_wl_input_index_set api For now the setting of a new layout does not mean the complete file needs to be recompiled. --- src/bin/e_xkb.c | 68 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/src/bin/e_xkb.c b/src/bin/e_xkb.c index 0aa1782..4f19ba9 100644 --- a/src/bin/e_xkb.c +++ b/src/bin/e_xkb.c @@ -3,6 +3,7 @@ static void _e_xkb_update_event(int); static void _e_xkb_type_reconfig(E_Pixmap_Type comp_type); +static void _e_xkb_type_update(E_Pixmap_Type comp_type, int cur_group); static int _e_xkb_cur_group = -1; static Ecore_Event_Handler *xkb_state_handler = NULL, *xkb_new_keyboard_handler = NULL; @@ -118,6 +119,11 @@ e_xkb_init(E_Pixmap_Type comp_type) if (comp_type == E_PIXMAP_TYPE_X) ecore_timer_add(1.5, _e_xkb_init_timer, NULL); + else if (comp_type == E_PIXMAP_TYPE_WL) + { + _eval_cur_group(); + _e_xkb_type_update(comp_type, e_config->xkb.cur_group); + } return 1; } @@ -238,18 +244,26 @@ _e_x_xkb_update(int cur_group) } } + static void _e_wl_xkb_update(int cur_group) { #ifdef HAVE_WAYLAND + e_comp_wl_input_keymap_index_set(cur_group); + _e_xkb_update_event(cur_group); +#endif +} + + +static void +_e_wl_xkb_reconfig(void) +{ +#ifdef HAVE_WAYLAND E_Config_XKB_Option *op; E_Config_XKB_Layout *cl; Eina_Strbuf *options, *layouts, *variants; - Eina_List *l, *selected; + Eina_List *l; - if (cur_group == -1) { - cur_group = e_config->xkb.cur_group; - } options = eina_strbuf_new(); @@ -267,28 +281,10 @@ _e_wl_xkb_update(int cur_group) variants = eina_strbuf_new(); //search for the correct layout - selected = eina_list_nth_list(e_config->xkb.used_layouts, cur_group); - if (!selected) selected = e_config->xkb.used_layouts; - /* create layouts */ - //first walk from the selected layout to the end - EINA_LIST_FOREACH(selected, l, cl) - { - if (cl->name) - { - eina_strbuf_append(layouts, cl->name); - eina_strbuf_append_char(layouts, ','); - } - if (cl->variant) - { - eina_strbuf_append(variants, cl->variant); - eina_strbuf_append_char(variants, ','); - } - } - //then append all item from the first to the selected + /* create layouts */ EINA_LIST_FOREACH(e_config->xkb.used_layouts, l, cl) { - if (selected == l) break; if (cl->name) { eina_strbuf_append(layouts, cl->name); @@ -301,10 +297,8 @@ _e_wl_xkb_update(int cur_group) eina_strbuf_append_char(variants, ','); } } + /* collect model to use */ - l = eina_list_nth_list(e_config->xkb.used_layouts, cur_group); - if (!l) return; - cl = eina_list_data_get(l); /* set keymap to the compositor */ e_comp_wl_input_keymap_set(NULL, @@ -314,8 +308,6 @@ _e_wl_xkb_update(int cur_group) eina_strbuf_string_get(options) //list of options ); - e_config->xkb.cur_group = cur_group; - _e_xkb_update_event(cur_group); eina_strbuf_free(variants); eina_strbuf_free(layouts); eina_strbuf_free(options); @@ -330,10 +322,7 @@ _e_xkb_type_reconfig(E_Pixmap_Type comp_type) if (comp_type == E_PIXMAP_TYPE_X) _e_x_xkb_reconfig(); else if (comp_type == E_PIXMAP_TYPE_WL) - { - _eval_cur_group(); - _e_wl_xkb_update(e_config->xkb.cur_group); - } + _e_wl_xkb_reconfig(); } E_API void @@ -342,16 +331,25 @@ e_xkb_reconfig(void) _e_xkb_type_reconfig(e_comp->comp_type); } -E_API void -e_xkb_update(int cur_group) +static void +_e_xkb_type_update(E_Pixmap_Type comp_type, int cur_group) { - if (e_comp->comp_type == E_PIXMAP_TYPE_WL) + e_config->xkb.cur_group = cur_group; + e_config_save_queue(); + + if (comp_type == E_PIXMAP_TYPE_WL) _e_wl_xkb_update(cur_group); else _e_x_xkb_update(cur_group); } E_API void +e_xkb_update(int cur_group) +{ + _e_xkb_type_update(e_comp->comp_type, cur_group); +} + +E_API void e_xkb_layout_next(void) { Eina_List *l; --