Set up kbd_codepage at the start of the program, as well as when the
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Thu, 29 Nov 2001 21:30:59 +0000 (21:30 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Thu, 29 Nov 2001 21:30:59 +0000 (21:30 +0000)
input locale changes. With any luck this should sort out the Polish
Unicode problems.

git-svn-id: svn://svn.tartarus.org/sgt/putty@1427 cda61777-01e9-0310-a592-d414129be87e

window.c

index 5018218..11533e2 100644 (file)
--- a/window.c
+++ b/window.c
@@ -73,6 +73,7 @@ static void init_palette(void);
 static void init_fonts(int, int);
 static void another_font(int);
 static void deinit_fonts(void);
+static void set_input_locale(HKL);
 
 /* Window layout information */
 static void reset_window(int);
@@ -589,6 +590,11 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
     }
 
     /*
+     * Set up the initial input locale.
+     */
+    set_input_locale(GetKeyboardLayout(0));
+
+    /*
      * Finally show the window!
      */
     ShowWindow(hwnd, show);
@@ -1367,6 +1373,16 @@ static void reset_window(int reinit) {
     }
 }
 
+static void set_input_locale(HKL kl)
+{
+    char lbuf[20];
+
+    GetLocaleInfo(LOWORD(kl), LOCALE_IDEFAULTANSICODEPAGE,
+                 lbuf, sizeof(lbuf));
+
+    kbd_codepage = atoi(lbuf);
+}
+
 static void click(Mouse_Button b, int x, int y, int shift, int ctrl, int alt)
 {
     int thistime = GetMessageTime();
@@ -2287,19 +2303,9 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
        net_pending_errors();
        return 0;
       case WM_INPUTLANGCHANGE:
-       {
-           /* wParam == Font number */
-           /* lParam == Locale */
-           char lbuf[20];
-           HKL NewInputLocale = (HKL) lParam;
-
-           // lParam == GetKeyboardLayout(0);
-
-           GetLocaleInfo(LOWORD(NewInputLocale),
-                         LOCALE_IDEFAULTANSICODEPAGE, lbuf, sizeof(lbuf));
-
-           kbd_codepage = atoi(lbuf);
-       }
+       /* wParam == Font number */
+       /* lParam == Locale */
+       set_input_locale((HKL)lParam);
        break;
       case WM_IME_NOTIFY:
        if(wParam == IMN_SETOPENSTATUS) {