Problem of grabbing the first keystroke after input device keymap switch

Daniel Stone daniel at fooishbar.org
Tue Aug 11 11:07:20 PDT 2009


Hi,

On Fri, Feb 13, 2009 at 07:20:36PM -0800, Henry Zhao wrote:
> In a system with multiple input keyboard devices,  keymap switch takes
> place when server receives the first keystroke from a new device. Before
> posting it updates the keymap of core device, and sends out
> SendMappingNotify() (all done in SwitchsCoreKeyboard()).
> 
> However in my testing case, the client is unable to grab this first 
> keystroke,
> although it can correctly grab subsequent strokes from the new device. 
> With "xmodmap -pk" I am sure the keymap switch takes place as expected.
> 
> After receiving mapping notify, the client does another round of grab based
> on the new keymap,  and at that point  I can tell the keymap is already
> correctly updated.  But the client is still unable to grab the first 
> keystroke.
> 
> It does not seem to be a timing issue: I add some delay after 
> SendMappingNotify()
> in SwitchsCoreKeyboard() to postpone posting,   but this does not help.
> 
> Any thoughts ?

This is pretty much unfixable without actually using Xi2 and grabbing on
the slave devices rather than the master.  The only way you could
completely eliminate the race is to add API to the clients to say that
they've all processed the mapping change and you're free to unfreeze
grab events, but, er, if you're changing all your clients anyway, just
use Xi2 ...

Cheers,
Daniel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg/attachments/20090811/e0355d75/attachment.pgp>


More information about the xorg mailing list