bu5hm4n pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=62440eb5fe519f8d929c85d5f633f06914721ff4

commit 62440eb5fe519f8d929c85d5f633f06914721ff4
Author: Marcel Hollerbach <marcel-hollerb...@t-online.de>
Date:   Wed Mar 23 09:38:34 2016 +0100

    e_comp_wl: let keymaps be set when compositor is not running
    
    if someone tries to set a new file to the wl compositor and it is not
    running the values are cached now and setted when the compositor is
    running.
---
 src/bin/e_comp_wl_input.c | 61 ++++++++++++++++++++++++++++++++---------------
 1 file changed, 42 insertions(+), 19 deletions(-)

diff --git a/src/bin/e_comp_wl_input.c b/src/bin/e_comp_wl_input.c
index 3ff6099..4b2807e 100644
--- a/src/bin/e_comp_wl_input.c
+++ b/src/bin/e_comp_wl_input.c
@@ -8,6 +8,13 @@
 
 E_API int E_EVENT_TEXT_INPUT_PANEL_VISIBILITY_CHANGE = -1;
 static xkb_keycode_t (*_xkb_keymap_key_by_name)(void *, const char *);
+static void _e_comp_wl_input_context_keymap_set(struct xkb_keymap *keymap, 
struct xkb_context *context);
+
+
+//the following two fields are just set by e_comp_wl_input_keymap_set if it is 
called before e_comp_wl is valid.
+//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 void
 _e_comp_wl_input_update_seat_caps(void)
@@ -448,6 +455,8 @@ e_comp_wl_input_init(void)
 
    _xkb_keymap_key_by_name = dlsym(NULL, "xkb_keymap_key_by_name");
 
+    _e_comp_wl_input_context_keymap_set(cached_keymap, cached_context);
+
    return EINA_TRUE;
 }
 
@@ -604,10 +613,40 @@ e_comp_wl_input_keyboard_enabled_set(Eina_Bool enabled)
    _e_comp_wl_input_update_seat_caps();
 }
 
+static void
+_e_comp_wl_input_context_keymap_set(struct xkb_keymap *keymap, struct 
xkb_context *context)
+{
+   if (e_comp_wl)
+     {
+        //we have a initializied and running compositor here
+        if (e_comp_wl->xkb.context)
+          xkb_context_unref(e_comp_wl->xkb.context);
+        e_comp_wl->xkb.context = context;
+
+        /* update compositor keymap */
+        _e_comp_wl_input_keymap_update(keymap);
+     }
+   else
+     {
+        //we dont have a running compositor here, cache the values, init will 
pick them
+        cached_context = context;
+        cached_keymap = keymap;
+     }
+
+//set the values to the drm devices
+#ifdef HAVE_WL_DRM
+   if (e_config->xkb.use_cache)
+     ecore_drm_device_keyboard_cached_context_set(context);
+   if (e_config->xkb.use_cache)
+     ecore_drm_device_keyboard_cached_keymap_set(keymap);
+#endif
+}
+
 E_API void
 e_comp_wl_input_keymap_set(const char *rules, const char *model, const char 
*layout, const char *variant, const char *options)
 {
    struct xkb_keymap *keymap;
+   struct xkb_context *context;
    struct xkb_rule_names names;
 
    /* DBG("COMP_WL: Keymap Set: %s %s %s", rules, model, layout); */
@@ -630,21 +669,11 @@ e_comp_wl_input_keymap_set(const char *rules, const char 
*model, const char *lay
    if (options) names.options = options;
    else names.options = NULL;
 
-   /* 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);
-
-#ifdef HAVE_WL_DRM
-   if (e_config->xkb.use_cache)
-     ecore_drm_device_keyboard_cached_context_set(e_comp_wl->xkb.context);
-#endif
+   context = xkb_context_new(0);
 
    /* fetch new keymap based on names */
-   keymap = xkb_map_new_from_names(e_comp_wl->xkb.context, &names, 0);
+   keymap = xkb_map_new_from_names(context, &names, 0);
 
    if (!keymap)
      {
@@ -652,13 +681,7 @@ e_comp_wl_input_keymap_set(const char *rules, const char 
*model, const char *lay
         return;
      }
 
-   /* 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
+   _e_comp_wl_input_context_keymap_set(keymap, context);
 }
 
 E_API void

-- 


Reply via email to