<div dir="ltr">Hi,<div class="gmail_extra"><br><div class="gmail_quote">On 15 July 2014 14:57, Rui Matos <span dir="ltr"><<a href="mailto:tiagomatos@gmail.com" target="_blank">tiagomatos@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">While we have keyboard focus, the server's xkb code is already locking<br>
and latching modifiers appropriately while processing keyboard<br>
events.<br>
<br>
Since there is no guaranteed order between wl_keyboard key and<br>
modifiers events, if we got the modifiers event with a locked or<br>
latched modifier and then process the key press event for that<br>
modifier we would wrongly unlock/unlatch. To prevent this, we ignore<br>
locked and latched modifiers while any of our surfaces has keyboard<br>
focus.<br></blockquote><div><br></div><div>Wow, I really wish I'd encoded that properly in the wl_keyboard spec.</div><div><br></div><div>Sending modifiers before key is _seriously_ broken, and no-one should ever do it. There are corner cases it completely and horrifically breaks.</div>
<div><br></div><div>X11 actually got this right for once: the state sent with the key event is the state that applied _immediately before the press_, i.e. unaffected by the press itself. Where it slipped up was not updating you with the state immediately after the press as well, but you cannot interpret the press with the state the press itself created.</div>
<div><br></div><div>I'm very much tempted to merge Jonny's repeat rate patches which take us to a new wl_keyboard version, and including in that version a requirement that this ordering be observed.</div><div><br>
</div><div>If Mutter sends modifiers before key, _please_ reverse that.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
But we always need to set the xkb group index since this might be<br>
triggered programatically by the wayland compositor at any time.<br>
---<br>
<br>
Note that xwayland's xkb state handling needs quite a bit of work to<br>
make it reliable. Basically, if the wl_keyboard.modifiers event comes<br>
in after the wl_keyboard.enter event we won't update the locked and<br>
latched modifiers properly. Right now this just happens to work with<br>
mutter.<br>
<br>
I'm working on a proper fix for this which requires API changes to the<br>
core xkb code in order for us to be able to tell it to ignore modifier<br>
state processing on key events and instead always set that state from<br>
wl_keyboard.modifiers events like any other wayland client.<br>
<br>
Extra API will also be needed to tell the xkb request processing code<br>
to return errors and/or silently drop X client requests that try to<br>
change any xkb state and keymaps.<br>
<br>
Anyway, that wouldn't be acceptable for the upcoming 1.16 release so<br>
I'm just proposing this targetted fix for the group index to be<br>
honored which I'd like to have working on the next GNOME release.<br></blockquote><div><br></div><div>Agreed to all of the above, but, wouldn't we be better off waiting for a modifiers event straight after enter? Although that's another thing which really needs encoding into the protocol ... oh well.</div>
<div><br></div><div>Reviewed-by: Daniel Stone <<a href="mailto:daniels@collabora.com">daniels@collabora.com</a>></div><div><br></div><div>Cheers,</div><div>Daniel </div></div></div></div>