Why double translation on keydown?
shachar at shemesh.biz
Thu Apr 5 13:41:56 CDT 2007
The current code for keyboard translation goes something like this, if I
understood it correctly:
* An X11 event arrives with the physical keycode for the key pressed.
* Said code is translated into a VKey based on the current keyboard
* Keycode is translated into a, well, keycode for Windows. 99% of
the cases this is the same one, as it's the same PC keyboard as ever.
* The vkey and translated keycode are sent as WM_KEYDOWN or
* In all probability, the process calls TranslateMessage
* TranslateMessage calls (indirectly) X11DRV_ToUnicodeEx
* X11DRV_ToUnicodeEx takes the virtual key, looks it up (using a for
loop!!!!) in the same table consulted before to find out what the
original X11 keycode was.
* That vkey is passed, after some manipulation, to XKeysymToKeycode
to produce a keycode
* Said keycode is passed to XLookupString to get an actual key for it
This process seems, to me, overly long and inefficient. It requires
building fairly complex lookup tables for both vkey and Windows keycode.
I fail to see what is gained. Why not use the following process instead:
* An X11 event arrives
* Use the native keycode as the keycode.
* Translate the vkey as before.
* Send WM_(SYS)KEYDOWN as before
* In X11DRV_ToUnicodeEx:
* Use the keycode to lookup with key using XLookupString
I fail to see why the forward and backwards translation is good for.
More information about the wine-devel