Fix bug in updatePossibleKeyCodes() with dead keys and modifiers
authorJuan Luis Boya García <ntrrgc@gmail.com>
Wed, 23 Oct 2013 10:34:02 +0000 (12:34 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Mon, 25 Nov 2013 08:32:41 +0000 (09:32 +0100)
commit157da36977213237939df14608753bb3ec280f0b
tree1a9421aacabd6b59eb008860b3b9b85e49d3b825
parent72f6bd8d51911f8a2a0dadc7fa10509fa86970a1
Fix bug in updatePossibleKeyCodes() with dead keys and modifiers

As it was until now, QWindowsKeyMapper::updatePossibleKeyCodes() tested
using ToUnicode for which characters produce a key with every possible
combination of modifiers.

Calling ToUnicode with a dead key is dangerous, because MS Windows keeps
it in the driver buffer, so if you call ToUnicode with acute key and
then you press a, you get an á.

To prevent this, updatePossibleKeyCodes() checked if the key that was
being tested was a dead key. If true, it inserted an space and then
repeated the key in order to reset the system internal buffers to the
same state they were before the call.

The problem with this is if the dead key is really two keys (like ^ or ´
in US International keyboard layout) and you press one of those keys
without the modifier to make it a dead key (i.e. 6 in US International):
Since updatePossibleKeyCodes() only tests for the key that was pressed
it gets 6 is not a dead key, and thus it does not execute the
workaround. Thus, the next time the user presses 'a' they get 'â'
instead because updatePossibleKeyCodes() set the dead key on the
keyboard buffer and did not run the workaround.

This patch makes updatePossibleKeyCodes() run the workaround if any
possible combination of modifiers with the key being examinated makes a
dead key.

Task-number: QTBUG-33591
Change-Id: I8c0b27586f7c62798986258b1b84aa90e4c5d64c
(cherry picked from commit b98a031b813a83374897b23f4f7710a238f2e7b6)
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Juan Luis Boya García <ntrrgc@gmail.com>
src/gui/kernel/qkeymapper_win.cpp