Fix out of order key events in Chrome on Linux.
commit1c683ec5ef4103a5526e2e1cf43d81f6d4f0b486
authordtapuska <dtapuska@chromium.org>
Fri, 28 Aug 2015 18:43:58 +0000 (28 11:43 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 28 Aug 2015 18:44:38 +0000 (28 18:44 +0000)
tree9ae318d50fe521e655e04b15afee6c24a61c354d
parent5a4765134975a3d0c974dc44e4a5d8e3ece66390
Fix out of order key events in Chrome on Linux.

The ibus-gtk layer was using XPutBackEvent which pushes an event to the
top of the X event queue. The problem with this is that if the gtk event
loop processes more than one event before the X event loop executes the
X message pump will see the events in reverse order.

Fix this by using XSendEvent which sends the event to the display and puts
it at the end of the list. However; it appears that the wire protocol for
XKeyEvent has 16 bits of accuracy defined for the state variable; yet the
struct is 32 bits for that field. While the state variable ends up still
being correct when you use XPutBackEvent because it is just an in process
copy; the XSendEvent is a serialization to the XServer and results in loss
of precision. To get around this pack the high bits that are used into
an empty field that is used.

BUG=524084

Review URL: https://codereview.chromium.org/1302373006

Cr-Commit-Position: refs/heads/master@{#346194}
chrome/browser/ui/libgtk2ui/gtk2_event_loop.cc
chrome/browser/ui/libgtk2ui/x11_input_method_context_impl_gtk2.cc