ton of xkb fixes:

* e will no longer lose your currently selected layout on restart
* desklock layout switching now works real güd
* new e_config values to determine current and current user-selected kbd layout
* wasted my entire morning doing this

ticket #1538



SVN revision: 77356
devs/princeamd/enlightenment-0.17-elive
Mike Blumenkrantz 11 years ago
parent 07d8a49d00
commit b247496406
  1. 13
      src/bin/e_config.c
  2. 6
      src/bin/e_config.h
  3. 16
      src/bin/e_desklock.c
  4. 34
      src/bin/e_xkb.c
  5. 1
      src/bin/e_xkb.h
  6. 44
      src/modules/conf_display/e_int_config_desklock.c
  7. 8
      src/modules/xkbswitch/e_mod_config.c
  8. 17
      src/modules/xkbswitch/e_mod_main.c

@ -932,7 +932,9 @@ e_config_init(void)
E_CONFIG_LIST(D, T, xkb.used_options, _e_config_xkb_option_edd);
E_CONFIG_VAL(D, T, xkb.only_label, INT);
E_CONFIG_VAL(D, T, xkb.default_model, STR);
E_CONFIG_VAL(D, T, xkb.desklock_group, INT);
E_CONFIG_VAL(D, T, xkb.selected_layout, STR);
E_CONFIG_VAL(D, T, xkb.cur_layout, STR);
E_CONFIG_VAL(D, T, xkb.desklock_layout, STR);
//E_CONFIG_VAL(D, T, xkb.cur_group, INT);
E_CONFIG_VAL(D, T, exe_always_single_instance, UCHAR);
@ -1240,8 +1242,10 @@ e_config_load(void)
COPYVAL(window_grouping);
IFCFGEND;
IFCFG(0x0156);
e_config->xkb.desklock_group = -1;
IFCFG(0x0157);
e_config->xkb.selected_layout = NULL;
e_config->xkb.cur_layout = NULL;
e_config->xkb.desklock_layout = NULL;
IFCFGEND;
e_config->config_version = E_CONFIG_FILE_VERSION;
@ -2126,6 +2130,9 @@ _e_config_free(E_Config *ecf)
if (ecf->desktop_default_name) eina_stringshare_del(ecf->desktop_default_name);
if (ecf->language) eina_stringshare_del(ecf->language);
eina_stringshare_del(ecf->desklock_language);
eina_stringshare_del(ecf->xkb.selected_layout);
eina_stringshare_del(ecf->xkb.cur_layout);
eina_stringshare_del(ecf->xkb.desklock_layout);
if (ecf->transition_start) eina_stringshare_del(ecf->transition_start);
if (ecf->transition_desk) eina_stringshare_del(ecf->transition_desk);
if (ecf->transition_change) eina_stringshare_del(ecf->transition_change);

@ -37,7 +37,7 @@ typedef struct _E_Event_Config_Icon_Theme E_Event_Config_Icon_Theme;
/* increment this whenever a new set of config values are added but the users
* config doesn't need to be wiped - simply new values need to be put in
*/
#define E_CONFIG_FILE_GENERATION 0x0156
#define E_CONFIG_FILE_GENERATION 0x0157
#define E_CONFIG_FILE_VERSION ((E_CONFIG_FILE_EPOCH << 16) | E_CONFIG_FILE_GENERATION)
struct _E_Config
@ -386,7 +386,9 @@ struct _E_Config
int only_label;
const char *default_model;
int cur_group;
int desklock_group;
const char *cur_layout; // whatever the current layout is
const char *selected_layout; // whatever teh current layout that the user has selected is
const char *desklock_layout;
} xkb;
unsigned char exe_always_single_instance;

@ -76,7 +76,6 @@ static Ecore_Event_Handler *_e_desklock_run_handler = NULL;
static Ecore_Job *job = NULL;
static Eina_List *tasks = NULL;
/***********************************************************************/
static Eina_Bool _e_desklock_cb_key_down(void *data, int type, void *event);
@ -226,8 +225,8 @@ e_desklock_show(Eina_Bool suspend)
if (e_config->desklock_language)
e_intl_language_set(e_config->desklock_language);
if (e_config->xkb.desklock_group != -1)
e_xkb_update(e_config->xkb.desklock_group);
if (e_config->xkb.desklock_layout)
e_xkb_layout_set(e_config->xkb.desklock_layout);
_e_custom_desklock_exe =
ecore_exe_run(e_config->desklock_custom_desklock_cmd, NULL);
e_util_library_path_restore();
@ -313,8 +312,8 @@ works:
if (e_config->desklock_language)
e_intl_language_set(e_config->desklock_language);
if (e_config->xkb.desklock_group != -1)
e_xkb_update(e_config->xkb.desklock_group);
if (e_config->xkb.desklock_layout)
e_xkb_layout_set(e_config->xkb.desklock_layout);
total_zone_num = _e_desklock_zone_num_get();
EINA_LIST_FOREACH(managers, l, man)
@ -385,8 +384,11 @@ e_desklock_hide(void)
if (e_config->desklock_language)
e_intl_language_set(e_config->language);
if (e_config->xkb.desklock_group != -1)
e_xkb_update(e_config->xkb.cur_group);
if (e_config->xkb.cur_layout == e_config->xkb.desklock_layout)
{
if (e_config->xkb.selected_layout)
e_xkb_layout_set(e_config->xkb.selected_layout);
}
_e_desklock_state = EINA_FALSE;
ev = E_NEW(E_Event_Desklock, 1);

@ -2,6 +2,8 @@
static void _e_xkb_update_event(int);
static int _e_xkb_cur_group = -1;
EAPI int E_EVENT_XKB_CHANGED = 0;
/* externally accessible functions */
@ -10,6 +12,15 @@ e_xkb_init(void)
{
E_EVENT_XKB_CHANGED = ecore_event_type_new();
e_xkb_update(-1);
if (e_config->xkb.cur_layout) e_xkb_layout_set(e_config->xkb.cur_layout);
else if (e_config->xkb.selected_layout) e_xkb_layout_set(e_config->xkb.selected_layout);
else if (e_config->xkb.used_layouts)
{
E_Config_XKB_Layout *cl;
cl = eina_list_data_get(e_config->xkb.used_layouts);
e_xkb_layout_set(cl->name);
}
return 1;
}
@ -30,6 +41,7 @@ e_xkb_update(int cur_group)
if (!e_config->xkb.used_layouts) return;
if (cur_group != -1)
{
_e_xkb_cur_group = cur_group;
ecore_x_xkb_select_group(cur_group);
return;
}
@ -120,6 +132,22 @@ e_xkb_layout_prev(void)
e_config_save_queue();
}
/* always use this function to get the current layout's name
* to ensure the most accurate results!!!
*/
EAPI const char *
e_xkb_layout_get(void)
{
E_Config_XKB_Layout *cl;
unsigned int n = 0;
if (e_config->xkb.cur_layout) return e_config->xkb.cur_layout;
if (_e_xkb_cur_group >= 0)
n = _e_xkb_cur_group;
cl = eina_list_nth(e_config->xkb.used_layouts, n);
return cl ? cl->name : NULL;
}
EAPI void
e_xkb_layout_set(const char *name)
{
@ -128,12 +156,14 @@ e_xkb_layout_set(const char *name)
int cur_group = -1;
if (!name) return;
EINA_LIST_FOREACH(eina_list_next(e_config->xkb.used_layouts), l, cl)
EINA_LIST_FOREACH(e_config->xkb.used_layouts, l, cl)
{
cur_group++;
if (!cl->name) continue;
if (!strcmp(cl->name, name))
if ((cl->name == name) || (!strcmp(cl->name, name)))
{
eina_stringshare_replace(&e_config->xkb.cur_layout, cl->name);
INF("Setting keyboard layout: %s", name);
e_xkb_update(cur_group);
_e_xkb_update_event(cur_group);
break;

@ -8,6 +8,7 @@ EAPI int e_xkb_shutdown(void);
EAPI void e_xkb_update(int);
EAPI void e_xkb_layout_next(void);
EAPI void e_xkb_layout_prev(void);
EAPI const char *e_xkb_layout_get(void);
EAPI void e_xkb_layout_set(const char *name);
EAPI const char *e_xkb_layout_name_reduce(const char *name);
EAPI void e_xkb_e_icon_flag_setup(Evas_Object *eicon, const char *name);

@ -33,7 +33,7 @@ struct _E_Config_Dialog_Data
char *custom_lock_cmd;
/* Layout */
int desklock_group;
const char *desklock_layout;
/* Timers */
int screensaver_lock;
@ -132,7 +132,7 @@ _fill_data(E_Config_Dialog_Data *cfdata)
if (e_config->desklock_custom_desklock_cmd)
cfdata->custom_lock_cmd = strdup(e_config->desklock_custom_desklock_cmd);
cfdata->desklock_group = e_config->xkb.desklock_group;
cfdata->desklock_layout = e_config->xkb.desklock_layout;
cfdata->start_locked = e_config->desklock_start_locked;
cfdata->lock_on_suspend = e_config->desklock_on_suspend;
cfdata->auto_lock = e_config->desklock_autolock_idle;
@ -200,14 +200,6 @@ _basic_screensaver_lock_cb_changed(void *data, Evas_Object *o __UNUSED__)
e_widget_disabled_set(cfdata->gui.post_screensaver_slider, disable);
}
static void
_layout_changed(void *data)
{
E_Config_Dialog_Data *cfdata = data;
cfdata->desklock_group = e_widget_ilist_selected_get(cfdata->gui.kbd_list);
}
static Evas_Object *
_basic_create(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dialog_Data *cfdata)
{
@ -245,7 +237,7 @@ _basic_create(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dialog_Data
1, 0, 1, 0, 0.5, 0.0);
/* Keyboard Layout */
cfdata->gui.kbd_list = ol = e_widget_ilist_add(evas, 32 * e_scale, 32 * e_scale, NULL);
cfdata->gui.kbd_list = ol = e_widget_ilist_add(evas, 32 * e_scale, 32 * e_scale, &cfdata->desklock_layout);
EINA_LIST_FOREACH(e_config->xkb.used_layouts, l, cl)
{
Evas_Object *icon, *end;
@ -256,8 +248,11 @@ _basic_create(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dialog_Data
if (e_theme_edje_object_set(end, "base/theme/widgets",
"e/widgets/ilist/toggle_end"))
{
if (grp == cfdata->desklock_group)
edje_object_signal_emit(end, "e,state,checked", "e");
if (name == cfdata->desklock_layout)
{
edje_object_signal_emit(end, "e,state,checked", "e");
e_widget_ilist_selected_set(ol, grp);
}
else
edje_object_signal_emit(end, "e,state,unchecked", "e");
}
@ -277,7 +272,7 @@ _basic_create(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dialog_Data
snprintf(buf, sizeof(buf), "%s (%s, %s)", cl->name, cl->model, cl->variant);
else
snprintf(buf, sizeof(buf), "%s (%s)", cl->name, cl->model);
e_widget_ilist_append_full(ol, icon, end, buf, _layout_changed, cfdata, NULL);
e_widget_ilist_append_full(ol, icon, end, buf, NULL, cfdata, cl->name);
grp++;
}
e_widget_toolbook_page_append(otb, NULL, _("Keyboard Layout"), ol,
@ -402,7 +397,7 @@ _basic_create(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dialog_Data
static int
_basic_apply(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
{
Eina_List *l;
const Eina_List *l;
const char *bg;
E_Config_Desklock_Background *cbg;
@ -414,7 +409,22 @@ _basic_apply(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
e_config->desklock_autolock_idle_timeout = (cfdata->idle_time * 60);
e_config->desklock_ask_presentation = cfdata->ask_presentation;
e_config->desklock_ask_presentation_timeout = cfdata->ask_presentation_timeout;
e_config->xkb.desklock_group = cfdata->desklock_group;
if (e_config->xkb.desklock_layout != cfdata->desklock_layout)
{
e_config->xkb.desklock_layout = eina_stringshare_ref(cfdata->desklock_layout);
if (cfdata->desklock_layout)
{
E_Ilist_Item *ili;
EINA_LIST_FOREACH(e_widget_ilist_items_get(cfdata->gui.kbd_list), l, ili)
{
if (ili->selected)
edje_object_signal_emit(ili->o_end, "e,state,checked", "e");
else
edje_object_signal_emit(ili->o_end, "e,state,unchecked", "e");
}
}
}
if (cfdata->bgs)
{
@ -454,7 +464,7 @@ _basic_check_changed(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfda
Eina_List *l, *ll;
E_Config_Desklock_Background *cbg;
if (e_config->xkb.desklock_group != cfdata->desklock_group)
if (e_config->xkb.desklock_layout != cfdata->desklock_layout)
return 1;
if (e_config->desklock_start_locked != cfdata->start_locked)

@ -180,9 +180,9 @@ _basic_apply(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
EINA_LIST_FOREACH(cfdata->cfg_layouts, l, cl)
{
nl = E_NEW(E_Config_XKB_Layout, 1);
nl->name = eina_stringshare_add(cl->name);
nl->model = eina_stringshare_add(cl->model);
nl->variant = eina_stringshare_add(cl->variant);
nl->name = eina_stringshare_ref(cl->name);
nl->model = eina_stringshare_ref(cl->model);
nl->variant = eina_stringshare_ref(cl->variant);
e_config->xkb.used_layouts =
eina_list_append(e_config->xkb.used_layouts, nl);
@ -204,7 +204,7 @@ _basic_apply(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
if (!od->enabled) continue;
oc = E_NEW(E_Config_XKB_Option, 1);
oc->name = eina_stringshare_add(od->name);
oc->name = eina_stringshare_ref(od->name);
e_config->xkb.used_options = eina_list_append(e_config->xkb.used_options, oc);
}

@ -187,10 +187,11 @@ _gc_init(E_Gadcon *gc, const char *gcname, const char *id, const char *style)
Instance *inst;
const char *name;
if (e_config->xkb.used_layouts)
name = e_config->xkb.cur_layout;
if (!name) name = e_config->xkb.selected_layout;
if ((!name) && e_config->xkb.used_layouts)
name = ((E_Config_XKB_Layout *)
eina_list_data_get(e_config->xkb.used_layouts))->name;
else name = NULL;
/* The instance */
inst = E_NEW(Instance, 1);
@ -374,11 +375,11 @@ _e_xkb_cb_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSE
if (inst->lmenu)
{
E_Config_XKB_Layout *cl;
const char *cur;
E_Menu_Item *mi;
Eina_List *l;
int dir;
char buf[4096];
int grp = -1;
mi = e_menu_item_new(inst->lmenu);
@ -388,6 +389,7 @@ _e_xkb_cb_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSE
mi = e_menu_item_new(inst->lmenu);
e_menu_item_separator_set(mi, 1);
cur = e_xkb_layout_get();
/* Append all the layouts */
EINA_LIST_FOREACH(e_config->xkb.used_layouts, l, cl)
@ -398,9 +400,8 @@ _e_xkb_cb_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSE
e_menu_item_radio_set(mi, 1);
e_menu_item_radio_group_set(mi, 1);
grp++;
e_menu_item_toggle_set
(mi, (grp == e_config->xkb.cur_group) ? 1 : 0);
if (cur == name)
e_menu_item_toggle_set(mi, 1);
e_xkb_flag_file_get(buf, sizeof(buf), name);
e_menu_item_icon_file_set(mi, buf);
if (cl->variant)
@ -512,6 +513,7 @@ _e_xkb_cb_lmenu_set(void *data, E_Menu *mn __UNUSED__, E_Menu_Item *mi __UNUSED_
Eina_List *l;
void *ndata;
int cur_group = -1, grp = -1;
E_Config_XKB_Layout *cl = data;
EINA_LIST_FOREACH(e_config->xkb.used_layouts, l, ndata)
{
@ -520,7 +522,8 @@ _e_xkb_cb_lmenu_set(void *data, E_Menu *mn __UNUSED__, E_Menu_Item *mi __UNUSED_
}
if (cur_group != -1)
{
e_xkb_update(cur_group);
e_xkb_layout_set(cl->name);
eina_stringshare_replace(&e_config->xkb.selected_layout, cl->name);
_xkb_update_icon(cur_group);
}
}

Loading…
Cancel
Save