e_comp_wl: introduce api to set index of keymap

this commit introduces the setting of the index. Setting the index here
means that the layout with the id 0..n, out of the compiled keymap file
will be used. After a new index is set the modifiers are updated, that
the client are aware of the new resulting group.

If the api is called before the compositor is inited (this can happen
in e_xkb, so the drm can use the keymap at startup) then the index is
saved in between and will be flushed once the compositor does the init.
devs/illogict/signals_priority
Marcel Hollerbach 7 years ago
parent 4606be46d3
commit d1e700cb68
  1. 1
      src/bin/e_comp_wl.h
  2. 67
      src/bin/e_comp_wl_input.c
  3. 2
      src/bin/e_comp_wl_input.h

@ -164,6 +164,7 @@ struct _E_Comp_Wl_Data
xkb_mod_index_t mod_super;
xkb_mod_mask_t mod_depressed, mod_latched, mod_locked;
xkb_layout_index_t mod_group;
xkb_layout_index_t choosen_group;
struct wl_array keys;
struct wl_resource *focus;
int mod_changed;

@ -19,6 +19,7 @@ static void _e_comp_wl_input_context_keymap_set(struct xkb_keymap *keymap, struc
//when then later init is called those two fields are used in the keymap of the e_comp_wl struct
static struct xkb_context *cached_context;
static struct xkb_keymap *cached_keymap;
static xkb_layout_index_t choosen_group;
static void
_e_comp_wl_input_update_seat_caps(void)
@ -346,22 +347,11 @@ _e_comp_wl_input_keymap_fd_get(off_t size)
return fd;
}
static void
_e_comp_wl_input_keymap_update(struct xkb_keymap *keymap)
_e_comp_wl_input_state_update(void)
{
char *tmp;
xkb_mod_mask_t latched = 0, locked = 0;
struct wl_resource *res;
Eina_List *l;
/* unreference any existing keymap */
if (e_comp_wl->xkb.keymap)
xkb_map_unref(e_comp_wl->xkb.keymap);
/* unmap any existing keyboard area */
if (e_comp_wl->xkb.area)
munmap(e_comp_wl->xkb.area, e_comp_wl->xkb.size);
if (e_comp_wl->xkb.fd >= 0) close(e_comp_wl->xkb.fd);
/* unreference any existing keyboard state */
if (e_comp_wl->xkb.state)
@ -376,14 +366,38 @@ _e_comp_wl_input_keymap_update(struct xkb_keymap *keymap)
}
/* create a new xkb state */
e_comp_wl->xkb.state = xkb_state_new(keymap);
e_comp_wl->xkb.state = xkb_state_new(e_comp_wl->xkb.keymap);
xkb_state_update_mask(e_comp_wl->xkb.state, 0,
latched, locked, 0, 0, 0);
latched, locked,
e_comp_wl->kbd.choosen_group,
0,
0);
}
static void
_e_comp_wl_input_keymap_update(struct xkb_keymap *keymap)
{
char *tmp;
struct wl_resource *res;
Eina_List *l;
/* unreference any existing keymap */
if (e_comp_wl->xkb.keymap)
xkb_map_unref(e_comp_wl->xkb.keymap);
/* unmap any existing keyboard area */
if (e_comp_wl->xkb.area)
munmap(e_comp_wl->xkb.area, e_comp_wl->xkb.size);
if (e_comp_wl->xkb.fd >= 0) close(e_comp_wl->xkb.fd);
/* increment keymap reference */
e_comp_wl->xkb.keymap = keymap;
/* update the state */
_e_comp_wl_input_state_update();
/* fetch updated modifiers */
e_comp_wl->kbd.mod_shift =
xkb_map_mod_get_index(keymap, XKB_MOD_NAME_SHIFT);
@ -464,6 +478,13 @@ e_comp_wl_input_init(void)
else
e_comp_wl_input_keymap_set(NULL, NULL, NULL, NULL, NULL);
if (choosen_group)
e_comp_wl_input_keymap_index_set(choosen_group);
else
e_comp_wl_input_keymap_index_set(0);
e_comp_wl_input_keyboard_modifiers_update();
return EINA_TRUE;
}
@ -663,6 +684,22 @@ _e_comp_wl_input_context_keymap_set(struct xkb_keymap *keymap, struct xkb_contex
#endif
}
E_API void
e_comp_wl_input_keymap_index_set(xkb_layout_index_t index)
{
if (e_comp_wl)
{
e_comp_wl->kbd.choosen_group = index;
_e_comp_wl_input_state_update();
e_comp_wl_input_keyboard_modifiers_update();
}
else
choosen_group = index;
}
E_API void
e_comp_wl_input_keymap_set(const char *rules, const char *model, const char *layout, const char *variant, const char *options)
{

@ -29,6 +29,8 @@ E_API void e_comp_wl_input_pointer_enabled_set(Eina_Bool enabled);
E_API void e_comp_wl_input_keyboard_enabled_set(Eina_Bool enabled);
E_API void e_comp_wl_input_touch_enabled_set(Eina_Bool enabled);
E_API void e_comp_wl_input_keymap_index_set(xkb_layout_index_t index);
E_API void e_comp_wl_input_keymap_set(const char *rules, const char *model, const char *layout, const char *variant, const char *options);
E_API void e_comp_wl_input_keyboard_event_generate(const char *key, int mods, Eina_Bool up);

Loading…
Cancel
Save