xkb: Switch delay to a group

Ilya Murav'jov muravev at yandex.ru
Tue Feb 2 14:30:15 PST 2010


 Here is my use case: I use Ctrl+Ins for switching between
layouts/groups (Russian and English). But many application suggests hot
keys like Ctrl+Ins+<Key> so I am out of luck in such cases now. It is
because xserver switches immediately after pressing Ctrl and Shift so
the last key <Key> pressing means just pressing only that single <Key>.
This issue is actual with other switching popular keybindings such as
Alt+Shift.

It would be nice if group switching/locked is delayed until I release
Ctrl and Shift (if I don't press <Key> before, of course). So, I've
investigated xkb source code and here is the big picture regarding the
issue, see xkb/xkbAction.c:


XkbHandleActions(DeviceIntPtr dev,DeviceIntPtr kbd,xEvent *xE,int count)
    ...
    if (pressEvent) {
	act = XkbGetKeyAction(xkbi,&xkbi->state,key);
	if (act.type == XkbSA_LockGroup) /* changing locked_group !!! */
	    _XkbFilterLatchState(xkbi,filter,key,&act);
    }
    ...
    XkbComputeDerivedState(xkbi); /* calculate effective group !!! */


My suggestion is to update the code in such a way:


XkbHandleActions(DeviceIntPtr dev,DeviceIntPtr kbd,xEvent *xE,int count)
    ...
    act = XkbGetKeyAction(xkbi,&xkbi->state,key);
    if (pressEvent) {
	if (act.type == XkbSA_LockGroup)
	    state.group_change_needed = True;
    } else { // modifier is released
	if (act.type == XkbSA_LockGroup && state.group_change_needed)
	    _XkbFilterLatchState(xkbi,filter,key,&act);
    }
    ...
    if( "pressed any non-modifier <Key>" )
        state.group_change_needed = False;
    ...
    XkbComputeDerivedState(xkbi); /* calculate effective group !!! */

What do you think about that?

Regards,
 Ilya Murav'jov



More information about the xorg mailing list