forked from enlightenment/enlightenment
Set cached xkb context/keymap
Summary: Set xkb context and keymap to Ecore_Drm. In enlightenment (used in wayland with drm backend), keymap is used only one. So for avoid unnecessary open keymap files, set cached context and keymap. But for this, enlightenment must compile keymap before init ecore_drm. So I changed booting sequence also. Test Plan: Distinguish time between before and after during add a keyboard device. Reviewers: raster, devilhorns, zmike Subscribers: cedric, input.hacker, ohduna Differential Revision: https://phab.enlightenment.org/D3504
This commit is contained in:
parent
b50a94296a
commit
bdb462e19f
|
@ -215,6 +215,7 @@ group "E_Config" struct {
|
|||
value "update.later" uchar: 0;
|
||||
value "xkb.only_label" int: 0;
|
||||
value "xkb.default_model" string: "default";
|
||||
value "xkb.use_cache" uchar: 0;
|
||||
value "keyboard.repeat_delay" int: 400;
|
||||
value "keyboard.repeat_rate" int: 25;
|
||||
value "exe_always_single_instance" uchar: 0;
|
||||
|
|
|
@ -865,6 +865,7 @@ group "E_Config" struct {
|
|||
}
|
||||
value "xkb.only_label" int: 0;
|
||||
value "xkb.default_model" string: "default";
|
||||
value "xkb.use_cache" uchar: 0;
|
||||
value "keyboard.repeat_delay" int: 400;
|
||||
value "keyboard.repeat_rate" int: 25;
|
||||
value "exe_always_single_instance" uchar: 1;
|
||||
|
|
|
@ -1106,6 +1106,7 @@ group "E_Config" struct {
|
|||
}
|
||||
value "xkb.only_label" int: 0;
|
||||
value "xkb.default_model" string: "default";
|
||||
value "xkb.use_cache" uchar: 0;
|
||||
value "keyboard.repeat_delay" int: 400;
|
||||
value "keyboard.repeat_rate" int: 25;
|
||||
value "exe_always_single_instance" uchar: 0;
|
||||
|
|
|
@ -1128,6 +1128,7 @@ group "E_Config" struct {
|
|||
}
|
||||
value "xkb.only_label" int: 0;
|
||||
value "xkb.default_model" string: "default";
|
||||
value "xkb.use_cache" uchar: 0;
|
||||
value "keyboard.repeat_delay" int: 400;
|
||||
value "keyboard.repeat_rate" int: 25;
|
||||
value "exe_always_single_instance" uchar: 0;
|
||||
|
|
|
@ -2655,7 +2655,7 @@ _e_comp_wl_compositor_create(void)
|
|||
if (!layout) layout = strdup("us");
|
||||
|
||||
/* update compositor keymap */
|
||||
e_comp_wl_input_keymap_set(rules, model, layout);
|
||||
e_comp_wl_input_keymap_set(rules, model, layout, NULL, NULL);
|
||||
}
|
||||
#endif
|
||||
e_comp_wl->wl.client_disp = ecore_wl2_display_connect(NULL);
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
#define E_COMP_WL
|
||||
#include "e.h"
|
||||
#include <sys/mman.h>
|
||||
#ifdef HAVE_WL_DRM
|
||||
#include <Ecore_Drm.h>
|
||||
#endif
|
||||
|
||||
E_API int E_EVENT_TEXT_INPUT_PANEL_VISIBILITY_CHANGE = -1;
|
||||
|
||||
|
@ -586,14 +589,19 @@ e_comp_wl_input_keyboard_enabled_set(Eina_Bool enabled)
|
|||
}
|
||||
|
||||
E_API void
|
||||
e_comp_wl_input_keymap_set(const char *rules, const char *model, const char *layout)
|
||||
e_comp_wl_input_keymap_set(const char *rules, const char *model, const char *layout, struct xkb_context *dflt_ctx, struct xkb_keymap *dflt_map)
|
||||
{
|
||||
struct xkb_keymap *keymap;
|
||||
struct xkb_rule_names names;
|
||||
Eina_Bool use_dflt_xkb = EINA_FALSE;
|
||||
|
||||
/* DBG("COMP_WL: Keymap Set: %s %s %s", rules, model, layout); */
|
||||
|
||||
if (dflt_ctx && dflt_map) use_dflt_xkb = EINA_TRUE;
|
||||
|
||||
/* assemble xkb_rule_names so we can fetch keymap */
|
||||
if (!use_dflt_xkb)
|
||||
{
|
||||
memset(&names, 0, sizeof(names));
|
||||
if (rules) names.rules = strdup(rules);
|
||||
else names.rules = strdup("evdev");
|
||||
|
@ -601,26 +609,42 @@ e_comp_wl_input_keymap_set(const char *rules, const char *model, const char *lay
|
|||
else names.model = strdup("pc105");
|
||||
if (layout) names.layout = strdup(layout);
|
||||
else names.layout = strdup("us");
|
||||
}
|
||||
|
||||
/* unreference any existing context */
|
||||
if (e_comp_wl->xkb.context)
|
||||
xkb_context_unref(e_comp_wl->xkb.context);
|
||||
|
||||
/* create a new xkb context */
|
||||
e_comp_wl->xkb.context = xkb_context_new(0);
|
||||
if (use_dflt_xkb) e_comp_wl->xkb.context = dflt_ctx;
|
||||
else e_comp_wl->xkb.context = xkb_context_new(0);
|
||||
|
||||
#ifdef HAVE_WL_DRM
|
||||
if (e_config->xkb.use_cache)
|
||||
ecore_drm_device_keyboard_cached_context_set(e_comp_wl->xkb.context);
|
||||
#endif
|
||||
|
||||
/* fetch new keymap based on names */
|
||||
keymap = xkb_map_new_from_names(e_comp_wl->xkb.context, &names, 0);
|
||||
if (use_dflt_xkb) keymap = dflt_map;
|
||||
else keymap = xkb_map_new_from_names(e_comp_wl->xkb.context, &names, 0);
|
||||
if (keymap)
|
||||
{
|
||||
/* update compositor keymap */
|
||||
_e_comp_wl_input_keymap_update(keymap);
|
||||
}
|
||||
|
||||
#ifdef HAVE_WL_DRM
|
||||
if (e_config->xkb.use_cache)
|
||||
ecore_drm_device_keyboard_cached_keymap_set(keymap);
|
||||
#endif
|
||||
|
||||
/* cleanup */
|
||||
if (!use_dflt_xkb)
|
||||
{
|
||||
free((char *)names.rules);
|
||||
free((char *)names.model);
|
||||
free((char *)names.layout);
|
||||
}
|
||||
}
|
||||
|
||||
E_API void
|
||||
|
|
|
@ -29,7 +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_set(const char *rules, const char *model, const char *layout);
|
||||
E_API void e_comp_wl_input_keymap_set(const char *rules, const char *model, const char *layout,
|
||||
struct xkb_context *dflt_ctx, struct xkb_keymap *dflt_map);
|
||||
|
||||
# endif
|
||||
#endif
|
||||
|
|
|
@ -752,6 +752,7 @@ _e_config_edd_init(Eina_Bool old)
|
|||
E_CONFIG_VAL(D, T, xkb.only_label, INT);
|
||||
E_CONFIG_VAL(D, T, xkb.dont_touch_my_damn_keyboard, UCHAR);
|
||||
E_CONFIG_VAL(D, T, xkb.default_model, STR);
|
||||
E_CONFIG_VAL(D, T, xkb.use_cache, UCHAR);
|
||||
|
||||
E_CONFIG_VAL(D, T, keyboard.repeat_delay, INT);
|
||||
E_CONFIG_VAL(D, T, keyboard.repeat_rate, INT);
|
||||
|
|
|
@ -428,6 +428,7 @@ struct _E_Config
|
|||
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;
|
||||
Eina_Bool use_cache;
|
||||
} xkb;
|
||||
|
||||
struct
|
||||
|
|
|
@ -668,10 +668,32 @@ _drm_read_pixels(E_Comp_Wl_Output *output, void *pixels)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_e_mod_drm_keymap_set(struct xkb_context *ctx, struct xkb_keymap *map)
|
||||
{
|
||||
struct xkb_rule_names names;
|
||||
|
||||
ctx = xkb_context_new(0);
|
||||
EINA_SAFETY_ON_NULL_RETURN(ctx);
|
||||
|
||||
memset(&names, 0, sizeof(names));
|
||||
names.rules = strdup("evdev");
|
||||
names.model = strdup("pc105");
|
||||
names.layout = strdup("us");
|
||||
|
||||
map = xkb_map_new_from_names(ctx, &names, 0);
|
||||
EINA_SAFETY_ON_NULL_RETURN(map);
|
||||
|
||||
ecore_drm_device_keyboard_cached_context_set(ctx);
|
||||
ecore_drm_device_keyboard_cached_keymap_set(map);
|
||||
}
|
||||
|
||||
E_API void *
|
||||
e_modapi_init(E_Module *m)
|
||||
{
|
||||
int w = 0, h = 0;
|
||||
struct xkb_context *ctx = NULL;
|
||||
struct xkb_keymap *map = NULL;
|
||||
|
||||
printf("LOAD WL_DRM MODULE\n");
|
||||
|
||||
|
@ -682,6 +704,8 @@ e_modapi_init(E_Module *m)
|
|||
/* return NULL; */
|
||||
/* } */
|
||||
|
||||
_e_mod_drm_keymap_set(ctx, map);
|
||||
|
||||
if (e_comp_config_get()->engine == E_COMP_ENGINE_GL)
|
||||
{
|
||||
e_comp->ee = ecore_evas_new("gl_drm", 0, 0, 1, 1, NULL);
|
||||
|
@ -743,7 +767,7 @@ e_modapi_init(E_Module *m)
|
|||
|
||||
/* FIXME: This is just for testing at the moment....
|
||||
* happens to jive with what drm does */
|
||||
e_comp_wl_input_keymap_set(NULL, NULL, NULL);
|
||||
e_comp_wl_input_keymap_set(NULL, NULL, NULL, ctx, map);
|
||||
|
||||
activate_handler =
|
||||
ecore_event_handler_add(ECORE_DRM_EVENT_ACTIVATE,
|
||||
|
|
|
@ -58,7 +58,7 @@ e_modapi_init(E_Module *m)
|
|||
e_comp->pointer = e_pointer_canvas_new(e_comp->ee, EINA_TRUE);
|
||||
e_comp->pointer->color = EINA_TRUE;
|
||||
|
||||
e_comp_wl_input_keymap_set(NULL, NULL, NULL);
|
||||
e_comp_wl_input_keymap_set(NULL, NULL, NULL, NULL, NULL);
|
||||
wl_wl_init();
|
||||
|
||||
return m;
|
||||
|
|
|
@ -50,7 +50,7 @@ _cb_keymap_changed(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EIN
|
|||
if (!layout) layout = strdup("us");
|
||||
|
||||
/* update compositor keymap */
|
||||
e_comp_wl_input_keymap_set(rules, model, layout);
|
||||
e_comp_wl_input_keymap_set(rules, model, layout, NULL, NULL);
|
||||
|
||||
free(rules);
|
||||
free(model);
|
||||
|
|
Loading…
Reference in New Issue