X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/9bc81a2c80570fd9141d83f921b9bb1ef99a631b..d92624dccee63e8bee8653e8ae845ffad3490b67:/window.c diff --git a/window.c b/window.c index 3d4f080b..e2107ec3 100644 --- a/window.c +++ b/window.c @@ -128,6 +128,8 @@ static char *window_name, *icon_name; static int compose_state = 0; +static OSVERSIONINFO osVersion; + /* Dummy routine, only required in plink. */ void ldisc_update(int echo, int edit) { @@ -166,6 +168,16 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) * config box. */ defuse_showwindow(); + { + ZeroMemory(&osVersion, sizeof(osVersion)); + osVersion.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); + if (!GetVersionEx ( (OSVERSIONINFO *) &osVersion)) { + MessageBox(NULL, "Windows refuses to report a version", + "PuTTY Fatal Error", MB_OK | MB_ICONEXCLAMATION); + return 1; + } + } + /* * Process the command line. */ @@ -694,7 +706,7 @@ char *do_select(SOCKET skt, int startup) int msg, events; if (startup) { msg = WM_NETEVENT; - events = FD_READ | FD_WRITE | FD_OOB | FD_CLOSE; + events = FD_READ | FD_WRITE | FD_OOB | FD_CLOSE | FD_ACCEPT; } else { msg = events = 0; } @@ -1851,6 +1863,14 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, len = TranslateKey(message, wParam, lParam, buf); if (len == -1) return DefWindowProc(hwnd, message, wParam, lParam); + + /* + * We need not bother about stdin backlogs here, + * because in GUI PuTTY we can't do anything about + * it anyway; there's no means of asking Windows to + * hold off on KEYDOWN messages. We _have_ to + * buffer everything we're sent. + */ ldisc_send(buf, len); if (len > 0) @@ -1873,6 +1893,31 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, kbd_codepage = atoi(lbuf); } break; + case WM_IME_COMPOSITION: + { + HIMC hIMC; + int n; + char *buff; + + if(osVersion.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS || + osVersion.dwPlatformId == VER_PLATFORM_WIN32s) break; /* no Unicode */ + + if ((lParam & GCS_RESULTSTR) == 0) /* Composition unfinished. */ + break; /* fall back to DefWindowProc */ + + hIMC = ImmGetContext(hwnd); + n = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0); + + if (n > 0) { + buff = (char*) smalloc(n); + ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, buff, n); + luni_send((unsigned short *)buff, n / 2); + free(buff); + } + ImmReleaseContext(hwnd, hIMC); + return 1; + } + case WM_IME_CHAR: if (wParam & 0xFF00) { unsigned char buf[2]; @@ -1916,8 +1961,27 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, */ void sys_cursor(int x, int y) { - if (has_focus) - SetCaretPos(x * font_width, y * font_height); + COMPOSITIONFORM cf; + HIMC hIMC; + + if (!has_focus) return; + + SetCaretPos(x * font_width, y * font_height); + + /* IMM calls on Win98 and beyond only */ + if(osVersion.dwPlatformId == VER_PLATFORM_WIN32s) return; /* 3.11 */ + + if(osVersion.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS && + osVersion.dwMinorVersion == 0) return; /* 95 */ + + /* we should have the IMM functions */ + hIMC = ImmGetContext(hwnd); + cf.dwStyle = CFS_POINT; + cf.ptCurrentPos.x = x * font_width; + cf.ptCurrentPos.y = y * font_height; + ImmSetCompositionWindow(hIMC, &cf); + + ImmReleaseContext(hwnd, hIMC); } /* @@ -2942,6 +3006,15 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam, luni_send(&keybuf, 1); } else { ch = (char) alt_sum; + /* + * We need not bother about stdin + * backlogs here, because in GUI PuTTY + * we can't do anything about it + * anyway; there's no means of asking + * Windows to hold off on KEYDOWN + * messages. We _have_ to buffer + * everything we're sent. + */ ldisc_send(&ch, 1); } alt_sum = 0;