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

Rofi does not work well with custom layouts #485

Closed
AlexDaniel opened this issue Oct 22, 2016 · 14 comments
Closed

Rofi does not work well with custom layouts #485

AlexDaniel opened this issue Oct 22, 2016 · 14 comments
Labels
Milestone

Comments

@AlexDaniel
Copy link

Version

Version: 1.2.0

Configuration

Default

Launch Command

Any

Steps to reproduce

Configure your xkb layout to have some non-letter keys on the third level. For example:

key <AC05> { [ i, I, BackSpace, BackSpace ] };

Alternatively, try some layout that already has it (Neo?).

Then try using this key in rofi (AltGr+key).

What behaviour you see

Rofi does not recognize Backspace, Delete, Left, Right or any other non-letter key.

What behaviour you expect to see

I expect Backspace to work as Backspace, just like it does in any other program.

@DaveDavenport DaveDavenport added this to the 1.3 milestone Oct 22, 2016
@DaveDavenport
Copy link
Collaborator

Rofi sees the key as 'Alt-Backspace'. To see this, start rofi with: ' -kb-remove-char-back Alt+Backspace,Backspace'. Then it works.

@sardemff7 do you have any solution for this? It seems we are not seeing just the final key, but also the raw keymap..

@AlexDaniel
Copy link
Author

Confirming, -kb-remove-char-back Alt+Backspace works here as well.

@DaveDavenport
Copy link
Collaborator

@sardemff7 Does this look like a sane fix?

diff --git a/source/view.c b/source/view.c
index 30a6da1..733c142 100644
--- a/source/view.c
+++ b/source/view.c
@@ -1189,8 +1189,10 @@ static void rofi_view_handle_keypress ( RofiViewState *state, xkb_stuff *xkb, xc
         len = xkb_state_key_get_utf8 ( xkb->state, xkpe->detail, pad, sizeof ( pad ) );
     }

-    unsigned int modstate = x11_canonalize_mask ( xkpe->state );
+    xkb_mod_mask_t mod = xkb_state_serialize_mods ( xkb->state, XKB_STATE_MODS_EFFECTIVE );
+    xkb_mod_mask_t rrstate = xkb_state_mod_mask_remove_consumed ( xkb->state, key,mod );

+    unsigned int modstate = x11_canonalize_mask ( rrstate );
     if ( key != XKB_KEY_NoSymbol ) {
         KeyBindingAction action;
         action = abe_find_action ( modstate, key );

@DaveDavenport
Copy link
Collaborator

This seems to remove shift/control from shift-enter/control-enter

@DaveDavenport
Copy link
Collaborator

@xkbcommon What is the normal way to handle a situation like this?
I want the Control-i to produce just a backspace (see discussion above) , as xkb_state_mod_mask_remove_consumed nicely does. But Shift-Enter also get the shift removed (and I want to be able to bind that).

I can make specific exceptions, but prefer a nice solution?

@fooishbar
Copy link

@DaveDavenport Does the discussion in xkbcommon/libxkbcommon#17 help at all?

@DaveDavenport
Copy link
Collaborator

Thanks, I will give it a read.

@DaveDavenport
Copy link
Collaborator

DaveDavenport commented Nov 14, 2016

@xkbcommon @fooishbar

I took a look at the thread a few days back. It does not seem to help in my use-case. (I am probably doing something wrong, I think I just found out what I am doing wrong.)
I also got some inconsistent behavior from xkb:
If I use:

xkb_state_mod_mask_remove_consumed ( xkb->state, key,mod );

I get 0 back, all mods consumed, when pressing the alt+i binding however if I call

xkb_state_key_get_consumed_mods(struct xkb_state *state, xkb_keycode_t kc)

It also returns 0. No mods consumed... What is it?

If I look at implementation, it looks like we hit (present in both calls):

    key = XkbKey(state->keymap, kc);
    if (!key)
        return 0;

This seems wrong behavior, in the first case it should return mask not 0.

@DaveDavenport
Copy link
Collaborator

Ok, fixed above patch.

@DaveDavenport
Copy link
Collaborator

For me the alt+i for backspace works, and shift/control-enter seems to work correctly.

@AlexDaniel
Copy link
Author

Confirming, works fine now.

rbn42 pushed a commit to rbn42/rofi that referenced this issue Dec 13, 2016
@fooishbar
Copy link

@DaveDavenport For what it's worth, XkbKey() will only return NULL when the keycode is out of bounds. At that point it doesn't really matter what we return for the mask since it's a nonsensical question. At a guess, your root error (which you seem to have fixed) was passing the keysym key rather than the keycode xpke->detail; you can use the remove API if you just pass the right values.

@DaveDavenport
Copy link
Collaborator

you must have an amazing backlog, replying after 2 1/2 years.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants