e17 xkb patch building on ecore new event api. patch from:

http://trac.enlightenment.org/e/ticket/1306

but modified formatting and no theme changes.



SVN revision: 75410
devs/princeamd/enlightenment-0.17-elive
Carsten Haitzler 11 years ago
parent 40a67e9222
commit 887dfcf3d9
  1. 3
      src/bin/e_config.c
  2. 1
      src/bin/e_config.h
  3. 81
      src/bin/e_xkb.c
  4. 2
      src/bin/e_xkb.h
  5. 4
      src/modules/xkbswitch/e_mod_config.c
  6. 63
      src/modules/xkbswitch/e_mod_main.c
  7. 2
      src/modules/xkbswitch/e_mod_main.h
  8. 2
      src/modules/xkbswitch/e_mod_parse.c

@ -929,7 +929,7 @@ 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.cur_group, INT);
e_config_load();
e_config_save_queue();
@ -1171,7 +1171,6 @@ e_config_load(void)
COPYVAL(exec.show_run_dialog);
COPYVAL(exec.show_exit_dialog);
IFCFGEND;
IFCFG(0x0136);
_e_config_acpi_bindings_add();
IFCFGEND;

@ -382,6 +382,7 @@ struct _E_Config
Eina_List *used_options;
int only_label;
const char *default_model;
int cur_group;
} xkb;
};

@ -1,6 +1,6 @@
#include "e.h"
static void _e_xkb_update_event(void);
static void _e_xkb_update_event(int);
EAPI int E_EVENT_XKB_CHANGED = 0;
@ -9,7 +9,7 @@ EAPI int
e_xkb_init(void)
{
E_EVENT_XKB_CHANGED = ecore_event_type_new();
e_xkb_update();
e_xkb_update(-1);
return 1;
}
@ -20,7 +20,7 @@ e_xkb_shutdown(void)
}
EAPI void
e_xkb_update(void)
e_xkb_update(int cur_group)
{
E_Config_XKB_Layout *cl;
E_Config_XKB_Option *op;
@ -28,20 +28,30 @@ e_xkb_update(void)
Eina_Strbuf *buf;
if (!e_config->xkb.used_layouts) return;
if (cur_group != -1)
{
ecore_x_xkb_select_group(cur_group);
return;
}
/* We put an empty -option here in order to override all previously
* set options.
*/
buf = eina_strbuf_new();
eina_strbuf_append(buf, "setxkbmap '");
eina_strbuf_append(buf, "setxkbmap -layout '");
EINA_LIST_FOREACH(e_config->xkb.used_layouts, l, cl)
{
if (cl->name)
{
eina_strbuf_append(buf, cl->name);
eina_strbuf_append(buf, ",");
}
}
eina_strbuf_append(buf, "'");
/* use first entry in used layouts */
cl = e_config->xkb.used_layouts->data;
eina_strbuf_append(buf, cl->name);
eina_strbuf_append(buf, "'");
if ((cl->variant)
/* workaround xkb bug */
&& (!(!strcmp(cl->variant, "basic"))))
@ -88,40 +98,23 @@ e_xkb_update(void)
EAPI void
e_xkb_layout_next(void)
{
void *odata, *ndata;
Eina_List *l;
odata = eina_list_data_get(e_config->xkb.used_layouts);
EINA_LIST_FOREACH(eina_list_next(e_config->xkb.used_layouts), l, ndata)
{
eina_list_data_set(eina_list_prev(l), ndata);
}
eina_list_data_set(eina_list_last(e_config->xkb.used_layouts), odata);
e_xkb_update();
_e_xkb_update_event();
int nb_groups = eina_list_count(e_config->xkb.used_layouts);
e_config->xkb.cur_group = (e_config->xkb.cur_group + 1) % nb_groups;
e_xkb_update(e_config->xkb.cur_group);
_e_xkb_update_event(e_config->xkb.cur_group);
e_config_save_queue();
}
EAPI void
e_xkb_layout_prev(void)
{
void *odata, *ndata;
Eina_List *l;
odata = eina_list_data_get(eina_list_last(e_config->xkb.used_layouts));
for (l = e_config->xkb.used_layouts, ndata = eina_list_data_get(l);
l; l = eina_list_next(l))
{
if (eina_list_next(l))
ndata = eina_list_data_set(eina_list_next(l), ndata);
}
eina_list_data_set(e_config->xkb.used_layouts, odata);
e_xkb_update();
_e_xkb_update_event();
int nb_groups = eina_list_count(e_config->xkb.used_layouts);
e_config->xkb.cur_group = (e_config->xkb.cur_group == 0) ?
(nb_groups - 1) : (e_config->xkb.cur_group - 1);
e_xkb_update(e_config->xkb.cur_group);
_e_xkb_update_event(e_config->xkb.cur_group);
e_config_save_queue();
}
@ -130,19 +123,17 @@ e_xkb_layout_set(const char *name)
{
Eina_List *l;
E_Config_XKB_Layout *cl;
int cur_group = -1;
if (!name) return;
EINA_LIST_FOREACH(eina_list_next(e_config->xkb.used_layouts), l, cl)
{
cur_group++;
if (!cl->name) continue;
if (!strcmp(cl->name, name))
{
e_config->xkb.used_layouts =
eina_list_remove_list(e_config->xkb.used_layouts, l);
e_config->xkb.used_layouts =
eina_list_prepend(e_config->xkb.used_layouts, cl);
e_xkb_update();
_e_xkb_update_event();
e_xkb_update(cur_group);
_e_xkb_update_event(cur_group);
break;
}
}
@ -176,11 +167,11 @@ e_xkb_flag_file_get(char *buf, size_t bufsize, const char *name)
e_prefix_data_get(), name ? name : "unknown");
if (!ecore_file_exists(buf))
snprintf(buf, bufsize, "%s/data/flags/unknown_flag.png",
e_prefix_data_get());
e_prefix_data_get());
}
static void
_e_xkb_update_event(void)
_e_xkb_update_event(int cur_group)
{
ecore_event_add(E_EVENT_XKB_CHANGED, NULL, NULL, NULL);
ecore_event_add(E_EVENT_XKB_CHANGED, NULL, NULL, (void *)cur_group);
}

@ -5,7 +5,7 @@
EAPI int e_xkb_init(void);
EAPI int e_xkb_shutdown(void);
EAPI void e_xkb_update(void);
EAPI void e_xkb_update(int);
EAPI void e_xkb_layout_next(void);
EAPI void e_xkb_layout_prev(void);
EAPI void e_xkb_layout_set(const char *name);

@ -211,8 +211,8 @@ _basic_apply(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
e_config->xkb.used_options = eina_list_append(e_config->xkb.used_options, oc);
}
e_xkb_update();
_xkb_update_icon();
e_xkb_update(-1);
_xkb_update_icon(0);
e_config_save_queue();
return 1;

@ -2,6 +2,7 @@
#include "e_mod_main.h"
#include "e_mod_parse.h"
/* GADCON */
static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style);
static void _gc_shutdown(E_Gadcon_Client *gcc);
@ -12,6 +13,7 @@ static Evas_Object *_gc_icon(const E_Gadcon_Client_Class *client_class, Evas *ev
/* EVENTS */
static Eina_Bool _xkb_changed(void *data, int type, void *event_info);
static Eina_Bool _xkb_changed_state(void *data __UNUSED__,int type __UNUSED__, void *event);
static void _e_xkb_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event);
static void _e_xkb_cb_menu_configure(void *data, E_Menu *mn, E_Menu_Item *mi __UNUSED__);
static void _e_xkb_cb_lmenu_post(void *data, E_Menu *menu __UNUSED__);
@ -75,6 +77,7 @@ e_modapi_init(E_Module *m)
_xkb_cfg_dialog);
_xkb.module = m;
_xkb.evh = ecore_event_handler_add(E_EVENT_XKB_CHANGED, _xkb_changed, NULL);
ecore_event_handler_add(ECORE_X_EVENT_XKB_STATE_NOTIFY, _xkb_changed_state, NULL);
/* Gadcon */
e_gadcon_provider_register(&_gc_class);
return m;
@ -112,15 +115,21 @@ e_modapi_save(E_Module *m __UNUSED__)
* current layout state.
*/
void
_xkb_update_icon(void)
_xkb_update_icon(int cur_group)
{
Instance *inst;
Eina_List *l;
const char *name;
E_Config_XKB_Layout *layout;
const char *name=NULL;
int grp = -1;
if (!e_config->xkb.used_layouts) return;
name = ((E_Config_XKB_Layout*)
eina_list_data_get(e_config->xkb.used_layouts))->name;
INF("ui: %d",cur_group);
EINA_LIST_FOREACH(e_config->xkb.used_layouts, l, layout)
{
grp++;
if (cur_group == grp) name = layout->name;
}
if ((name) && (strchr(name, '/'))) name = strchr(name, '/') + 1;
@ -198,7 +207,7 @@ _gc_init(E_Gadcon *gc, const char *gcname, const char *id, const char *style)
inst->o_xkbflag);
}
else inst->o_xkbflag = NULL;
/* e_config->xkb.used_layout */
/* Hook some menus */
evas_object_event_callback_add(inst->o_xkbswitch, EVAS_CALLBACK_MOUSE_DOWN,
_e_xkb_cb_mouse_down, inst);
@ -271,10 +280,20 @@ _gc_icon(const E_Gadcon_Client_Class *client_class __UNUSED__, Evas *evas)
static Eina_Bool
_xkb_changed(void *data __UNUSED__, int type __UNUSED__, void *event_info __UNUSED__)
{
_xkb_update_icon();
_xkb_update_icon((int)data);
return ECORE_CALLBACK_PASS_ON;
}
static Eina_Bool
_xkb_changed_state(void *data __UNUSED__,int type __UNUSED__,void *event __UNUSED__)
{
Ecore_X_Event_Xkb *ev=(Ecore_X_Event_Xkb *)event;
INF("xkb group %d",ev->group);
e_config->xkb.cur_group = ev->group;
_xkb_update_icon(ev->group);
return ECORE_CALLBACK_PASS_ON;
}
#if 0
static int
_xkb_menu_items_sort(const void *data1, const void *data2)
{
@ -287,7 +306,7 @@ _xkb_menu_items_sort(const void *data1, const void *data2)
if (!v) v = strcmp(cl1->variant, cl2->variant);
return v;
}
#endif
static void
_e_xkb_cb_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event)
{
@ -344,7 +363,7 @@ _e_xkb_cb_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSE
Eina_List *l;
int dir;
char buf[PATH_MAX];
Eina_List *tlist = NULL;
int grp = -1;
mi = e_menu_item_new(inst->lmenu);
@ -354,16 +373,9 @@ _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);
EINA_LIST_FOREACH(e_config->xkb.used_layouts, l, cl)
{
tlist = eina_list_append(tlist, cl);
}
tlist = eina_list_sort(tlist, eina_list_count(tlist),
_xkb_menu_items_sort);
/* Append all the layouts */
EINA_LIST_FOREACH(tlist, l, cl)
EINA_LIST_FOREACH(e_config->xkb.used_layouts, l, cl)
{
const char *name = cl->name;
@ -371,8 +383,9 @@ _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, (cl == e_config->xkb.used_layouts->data) ? 1 : 0);
(mi, (grp == e_config->xkb.cur_group) ? 1 : 0);
e_xkb_flag_file_get(buf, sizeof(buf), name);
e_menu_item_icon_file_set(mi, buf);
snprintf(buf, sizeof(buf), "%s (%s, %s)", cl->name,
@ -381,7 +394,6 @@ _e_xkb_cb_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSE
e_menu_item_callback_set(mi, _e_xkb_cb_lmenu_set, cl);
}
if (tlist) eina_list_free(tlist);
/* Deactivate callback */
e_menu_post_deactivate_callback_set(inst->lmenu,
@ -469,13 +481,16 @@ _e_xkb_cb_lmenu_set(void *data, E_Menu *mn __UNUSED__, E_Menu_Item *mi __UNUSED_
{
Eina_List *l;
void *ndata;
void *odata = eina_list_data_get(e_config->xkb.used_layouts);
int cur_group = -1, grp = -1;
EINA_LIST_FOREACH(e_config->xkb.used_layouts, l, ndata)
{
if (ndata == data) eina_list_data_set(l, odata);
grp++;
if (ndata == data) cur_group = grp;
}
eina_list_data_set(e_config->xkb.used_layouts, data);
e_xkb_update();
_xkb_update_icon();
if (cur_group != -1)
{
e_xkb_update(cur_group);
_xkb_update_icon(cur_group);
}
}

@ -22,7 +22,7 @@ EAPI void *e_modapi_init (E_Module *m);
EAPI int e_modapi_shutdown(E_Module *m);
EAPI int e_modapi_save (E_Module *m);
void _xkb_update_icon(void);
void _xkb_update_icon(int);
E_Config_Dialog *_xkb_cfg_dialog(E_Container *con, const char *params);
extern Xkb _xkb;

@ -209,7 +209,7 @@ parse_rules(void)
while (p[0] == ' ') ++p;
/* skip "grp" options for switching kbd layouts */
if (strncmp(name, "grp", 3))
//if (strncmp(name, "grp", 3))
{
if (!strchr(name, ':'))
{

Loading…
Cancel
Save