[PATCH] input charset not initialized correctly on Win32
Petr Pajas <[email protected]>
| Newsgroups | gmane.comp.lang.perl.tk |
|---|---|
| Organization | UFAL MFF UK |
| Message-ID | <[email protected]> |
Hi Nick, All, I found that Windows users of my Tk-804 based app who have Czech keyboard (CS) set as *default* can't input Czech characters into input entries until they switch from CS->EN->CS using the Alt+Shift Windows shortcut (until they do, messy characters appear on the screen instead). After the switching to EN and back everything works fine (it also works fine if EN keyboard layout is the default and the user switches to CZ when the app starts). Going through the win32 sources, I easily identified the problem in pTk/mTk/win/tkWinX.c. The best patch I could manage is attached. Here's what happens: Tk tracks keyboard layout switches by listening to the Win32 WM_INPUTLANGCHANGE event in order to keep its info about the current input encoding up-to-date. The problem is, that it doesn't initialize its internal variables according to the initial layout (probably assuming its always EN). Please have a look at the patch and consider applying it. The patch is against the latest CPAN release (Tk-804.027). Also, does is this file taken from Tcl/Tk? Should I contact those guys too? Thanks, -- Petr
tkWinX.c.patch
(text/x-diff, 827 B)
--- pTk/mTk/win/tkWinX.c.orig 2005-12-05 23:59:10.000000000 +0100
+++ pTk/mTk/win/tkWinX.c 2005-12-06 00:05:26.000000000 +0100
@@ -250,6 +250,9 @@
TkWinXInit(hInstance)
HINSTANCE hInstance;
{
+ CHARSETINFO lpCs;
+ DWORD lpCP;
+
if (childClassInitialized != 0) {
return;
}
@@ -318,6 +321,17 @@
}
/*
+ * Initialize input language info
+ */
+ if(GetLocaleInfo(LANGIDFROMLCID(GetKeyboardLayout(0)),
+ LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER,
+ (LPWSTR) &lpCP,sizeof(lpCP)/sizeof(TCHAR))==0)
+ return CP_ACP;
+ if (TranslateCharsetInfo((DWORD *)lpCP, &lpCs, TCI_SRCCODEPAGE)==0)
+ return CP_ACP;
+ UpdateInputLanguage(lpCs.ciCharset);
+
+ /*
* Make sure we cleanup on finalize.
*/
Tcl_CreateExitHandler((Tcl_ExitProc *) TkWinXCleanup,