International keyboard support in Win98


Subject: International keyboard support in Win98
From: Lukas Pietsch (pietsch@mail.uni-freiburg.de)
Date: Thu Dec 21 2000 - 03:01:26 CST


[My apologies if you should receive this twice. I posted it
yesterday to abiword-dev, but probably too early. I think I
wasn't yet recognized to be on the list at the time, so I'm
resending it.]

I posted a bug report about Abiword's deficient handling of
keyboard input of non-ascii characters yesterday. I've been
trying to understand what's going on, and here is what I found
out after browsing through Microsoft's MSDN. I haven't got the
Abiword source code here, though. Maybe somebody can check if I'm
guessing right?

Apparently, what happens is this: when I try to switch to a new
keyboard layout, say, from German to Turkish, Abiword
acknowledges to the system that the change has taken place. The
system then starts using the Turkish keyboard driver to translate
physical keyboard "scan codes" into
"virtual keycodes", but Abiword still uses the German keyboard
driver to translate these virtual keycodes into character codes.
The result is chaos.

More detailed description: The system sends Abiword a
"WM_INPUTLANGCHANGEREQUEST" message. Abiword accepts it. The
system then activates the new keyboard layout driver and, when
done, sends out another "WM_INPUTLANGCHANGE". This message
contains a handle to the new keyboard language (HKL) as a
parameter. I suppose Abiword is expected to store this value
somewhere.

After that, when I type, the system sends WM_KEYDOWN messages to
Abiword. These messages contain "virtual-key" codes which Windows
has calculated using the new keyboard layout. Normally, the
application is expected to pass these back to another Windows
API, TranslateMessage, to let the system translate these into
character codes and send them back to the application in a
WM_CHAR message. The system has kept track of the keyboard
settings and will again use the correct, Turkish, translation
table.

However, there seem to be a number of alternative API's that
allow an unruly application to go it alone. For instance, an
application can translate a virtual-key code into a character
code using the ToAscii or ToAsciiEx functions. With the ToAsciiEx
function, the application can specify a keyboard layout handle
(HKL) of its own choice.

Is this what Abiword is doing? Trying to be clever and stay in
control of everything, Abiword keeps telling the system which HKL
to use. Unfortunately, it has forgotten to keep track of the
correct HKL when the system provided it; so it always passes the
HKL to the default keyboard language.

If that's what's happening, then it shouldn't be too difficult to
fix, right?

-----------------------------------------------------
Lukas Pietsch
University of Freiburg
English Department

Phone (p.) (#49) (761) 696 37 23
mailto:pietsch@mail.uni-freiburg.de



This archive was generated by hypermail 2b25 : Thu Dec 21 2000 - 03:02:39 CST