Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compose sequences ignored when no keysym is specified #880

Closed
eigengrau opened this issue Sep 6, 2018 · 4 comments
Closed

Compose sequences ignored when no keysym is specified #880

eigengrau opened this issue Sep 6, 2018 · 4 comments

Comments

@eigengrau
Copy link

This is probably a back-end issue, but FWIW, when a compose sequence is defined in ~/.XCompose without supplying a keysym, kitty ignores the input. E.g., the following will not produce any output.

<Multi_key> <d> <a> <n> <c> <e> : "♪┌|°з°|┘♪ └|°ε°|┐♪ ┌|°з°|┘♪" # Wee dancing people

As per man 5 Compose, EVENT : "STRING" is a legal compose entry. Maybe you can advise whether this issue should be filed against glfw.

@kovidgoyal
Copy link
Owner

Compose files are read by libxkbcommon not kitty directly. You should file the report against that project. (I long ago removed the default glfw key handling and replaced it with libxkbcomon as glfw does not support dead keys at all, among other problems).

@eigengrau
Copy link
Author

eigengrau commented Sep 6, 2018

Oh, if you’re handling this in libxkbcommon, then the compose file parsing is likely not an issue, since I know that other libxkbcommon-based applications support these sequences. I think the issue might be with glfw_xkb_handle_key_event. The function assumes that the input is not yet complete unless there’s a keysym. However, for multi-character sequences defined without an associated keysym, it looks like this does not have to be true.

When I apply the following, it shows me that key_event.text is ♪┌|°з°|┘♪ └|°ε°|┐♪ ┌|°з°|┘♪, so the compose lookup seems to work. The issue is just that it’s not used as input.

  diff --git a/glfw/xkb_glfw.c b/glfw/xkb_glfw.c
  index c4baf5ff..df9c1153 100644
  --- a/glfw/xkb_glfw.c
  +++ b/glfw/xkb_glfw.c
  @@ -474,6 +474,7 @@ glfw_xkb_handle_key_event(_GLFWwindow *window, _GLFWXKBData *xkb, xkb_keycode_t
           glfw_sym = compose_symbol(sg->composeState, syms[0]);
           if (glfw_sym == XKB_KEY_NoSymbol) {
               debug("compose not complete, ignoring.\n");
  +            debug("text: %s\n", key_event.text);
               return;
           }
           debug("composed_sym: %s ", glfw_xkb_keysym_name(glfw_sym));

@kovidgoyal
Copy link
Owner

See if this fixes it for you:

diff --git a/glfw/xkb_glfw.c b/glfw/xkb_glfw.c
index c4baf5ff..5908bf4a 100644
--- a/glfw/xkb_glfw.c
+++ b/glfw/xkb_glfw.c
@@ -335,12 +335,14 @@ glfw_xkb_should_repeat(_GLFWXKBData *xkb, xkb_keycode_t scancode) {
 static KeyEvent key_event = {};
 
 static inline xkb_keysym_t
-compose_symbol(struct xkb_compose_state *composeState, xkb_keysym_t sym) {
+compose_symbol(struct xkb_compose_state *composeState, xkb_keysym_t sym, int *compose_completed) {
+    *compose_completed = 0;
     if (sym == XKB_KEY_NoSymbol || !composeState) return sym;
     if (xkb_compose_state_feed(composeState, sym) != XKB_COMPOSE_FEED_ACCEPTED) return sym;
     switch (xkb_compose_state_get_status(composeState)) {
         case XKB_COMPOSE_COMPOSED:
             xkb_compose_state_get_utf8(composeState, key_event.text, sizeof(key_event.text));
+            *compose_completed = 1;
             return xkb_compose_state_get_one_sym(composeState);
         case XKB_COMPOSE_COMPOSING:
         case XKB_COMPOSE_CANCELLED:
@@ -471,8 +473,9 @@ glfw_xkb_handle_key_event(_GLFWwindow *window, _GLFWXKBData *xkb, xkb_keycode_t
     debug("clean_sym: %s ", glfw_xkb_keysym_name(clean_syms[0]));
     if (action == GLFW_PRESS || action == GLFW_REPEAT) {
         const char *text_type = "composed_text";
-        glfw_sym = compose_symbol(sg->composeState, syms[0]);
-        if (glfw_sym == XKB_KEY_NoSymbol) {
+        int compose_completed;
+        glfw_sym = compose_symbol(sg->composeState, syms[0], &compose_completed);
+        if (glfw_sym == XKB_KEY_NoSymbol && !compose_completed) {
             debug("compose not complete, ignoring.\n");
             return;
         }

I dont have the time right now to test it, so if it works let me know
and I will merge it or better, send a PR.

eigengrau pushed a commit to eigengrau/kitty that referenced this issue Sep 6, 2018
Compose sequences can be defined without an associated symbol. To test for
sequence completeness, we now also check whether XKB returned associated text.

Fixes kovidgoyal#880.
eigengrau pushed a commit to eigengrau/kitty that referenced this issue Sep 6, 2018
Compose sequences can be defined without an associated symbol. To test for
completeness, we now also rely on XKB’s reported compose state.

Fixes kovidgoyal#880.
@eigengrau
Copy link
Author

This resolves the issue. My naive approach was if ( … && strlen(key_event.text) == 0), but yours is better. Committed with you set as author.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants