[kmscon-devel] About keyboard shortcuts and consumed modifiers

Ran Benita ran234 at gmail.com
Sun Mar 10 15:30:39 PDT 2013


On Sun, Mar 10, 2013 at 04:27:07PM +0100, David Herrmann wrote:
> Hi Ran
> 
> On Sun, Mar 10, 2013 at 11:21 AM, Ran Benita <ran234 at gmail.com> wrote:
> > I noticed the last commit added a nice feature for dynamically
> > increasing/decreasing the font size with a shortcut. The default is
> > <Ctrl><+> and <Ctrl><->.
> >
> > When I tried it I noticed that you need to use <Ctrl><Shift><=> to get
> > the effect of <Ctrl><+>, because on this keymap the <+> is shifted. I
> > think though that the expected behavior is that you don't actually need
> > to use Shift there.. I wrote some explanation on this a while back, I
> > thought it might intrest you:
> > http://cgit.freedesktop.org/libxkbcommon/tree/xkbcommon/xkbcommon.h?id=bb620df7aa98c129#n1323
> 
> I am aware of the problem, but didn't have the time to fix it. Thanks
> for pointing me to the xkb_*_consumed_*() helpers.

Well in a German layout (if you use that) I see that + is not shifted,
so you might have missed that.

> So to fix this bug, I basically want to call
> xkb_state_mod_mask_remove_consumed() on the keycode+modifiers for each
> key-event and pass this as "effective_mods" or something like this
> along, right? And I should call this _after_ xkb_state_update_key(),
> right?

I might have confused two separate issues in my message.

First to solve the issue with the + and =, I don't see a better solution
than just adding two bindings, one one + and one with =. This boils down
to the fact that eventually you are comparing the keysyms. Solving it in
another way, like probing the keymap levels etc., would just be more
complicated (but I haven't thought of it too much). Of course for
letters (e.g. <Ctrl><A> vs. <Ctrl><a>) it's easier, because you just
convert to lower or upper case. But with + and = it's completely
arbitrary.

Second, about the consumed modifiers. I suggest being explicit, i.e. add
a 'consumed_mods' field to the event, and do the comparison as described
in the mod_index_is_consumed comment. The function to calculate this
mask should be similar to shl_xkb_get_mods (or maybe just make this one
return the two masks at once). Then you can just use the
xkb_state_mod_index_is_consumed() function. The remove_consumed() function
wouldn't work with a mask of SHL_*_MASK, because those may be different
than the xkbcommon modifier indexes which it expects.

> I think that's the easiest way. Any comments?

Hope I haven't confused you too much :)


More information about the kmscon-devel mailing list