X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/blobdiff_plain/ea02dce6c09227ddac8d09919555a8dcaa0ee564..e571c4d7ffa1cf60330ac0c7e3fb8b62533ff60e:/window.c diff --git a/window.c b/window.c index c1f3fac2..08559493 100644 --- a/window.c +++ b/window.c @@ -667,7 +667,7 @@ void connection_fatal(char *fmt, ...) { vsprintf(stuff, fmt, ap); va_end(ap); MessageBox(hwnd, stuff, "PuTTY Fatal Error", MB_ICONERROR | MB_OK); - if (cfg.close_on_exit) + if (cfg.close_on_exit == COE_ALWAYS) PostQuitMessage(1); else { session_closed = TRUE; @@ -692,16 +692,17 @@ static void enact_pending_netevent(void) { ret = select_result (pend_netevent_wParam, pend_netevent_lParam); reentering = 0; - if (ret == 0) { - if (cfg.close_on_exit) + if (ret == 0 && !session_closed) { + /* Abnormal exits will already have set session_closed and taken + * appropriate action. */ + if (cfg.close_on_exit == COE_ALWAYS || + cfg.close_on_exit == COE_NORMAL) PostQuitMessage(0); else { - if (!session_closed) { - session_closed = TRUE; - SetWindowText (hwnd, "PuTTY (inactive)"); - MessageBox(hwnd, "Connection closed by remote host", - "PuTTY", MB_OK | MB_ICONINFORMATION); - } + session_closed = TRUE; + SetWindowText (hwnd, "PuTTY (inactive)"); + MessageBox(hwnd, "Connection closed by remote host", + "PuTTY", MB_OK | MB_ICONINFORMATION); } } } @@ -807,6 +808,9 @@ font_messup: hdc = GetDC(hwnd); font_height = cfg.fontheight; + if (font_height > 0) { + font_height = -MulDiv(font_height, GetDeviceCaps(hdc, LOGPIXELSY), 72); + } font_width = pick_width; #define f(i,c,w,u) \ @@ -1395,6 +1399,10 @@ static LRESULT CALLBACK WndProc (HWND hwnd, UINT message, TO_CHR_Y(Y_POS(lParam))); } return 0; + case WM_NCMOUSEMOVE: + show_mouseptr(1); + noise_ultralight(lParam); + return 0; case WM_IGNORE_CLIP: ignore_clip = wParam; /* don't panic on DESTROYCLIPBOARD */ break; @@ -1718,7 +1726,7 @@ void do_text (Context ctx, int x, int y, char *text, int len, #endif /* This is CP437 ... junk translation */ static const unsigned char oemhighhalf[] = { - 0xff, 0xad, 0x9b, 0x9c, 0x6f, 0x9d, 0x7c, 0x15, + 0x20, 0xad, 0x9b, 0x9c, 0x6f, 0x9d, 0x7c, 0x15, 0x22, 0x43, 0xa6, 0xae, 0xaa, 0x2d, 0x52, 0xc4, 0xf8, 0xf1, 0xfd, 0x33, 0x27, 0xe6, 0x14, 0xfa, 0x2c, 0x31, 0xa7, 0xaf, 0xac, 0xab, 0x2f, 0xa8, @@ -2010,29 +2018,6 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam, keystate[VK_RMENU] = keystate[VK_MENU]; } - /* Note if AltGr was pressed and if it was used as a compose key */ - if (cfg.compose_key) { - if (wParam == VK_MENU && (HIWORD(lParam)&KF_EXTENDED)) - { - if (!compose_state) compose_key = wParam; - } - if (wParam == VK_APPS && !compose_state) - compose_key = wParam; - - if (wParam == compose_key) - { - if (compose_state == 0 && (HIWORD(lParam)&(KF_UP|KF_REPEAT))==0) - compose_state = 1; - else if (compose_state == 1 && (HIWORD(lParam)&KF_UP)) - compose_state = 2; - else - compose_state = 0; - } - else if (compose_state==1 && wParam != VK_CONTROL) - compose_state = 0; - } else { - compose_state = 0; - } /* Nastyness with NUMLock - Shift-NUMLock is left alone though */ if ( (cfg.funky_type == 3 || @@ -2059,14 +2044,43 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam, key_down = ((HIWORD(lParam)&KF_UP)==0); - /* Make sure Ctrl-ALT is not the same as AltGr for ToAscii */ - if (left_alt && (keystate[VK_CONTROL]&0x80)) - keystate[VK_MENU] = 0; + /* Make sure Ctrl-ALT is not the same as AltGr for ToAscii unless told. */ + if (left_alt && (keystate[VK_CONTROL]&0x80)) { + if (cfg.ctrlaltkeys) + keystate[VK_MENU] = 0; + else { + keystate[VK_RMENU] = 0x80; + left_alt = 0; + } + } scan = (HIWORD(lParam) & (KF_UP | KF_EXTENDED | 0xFF)); shift_state = ((keystate[VK_SHIFT]&0x80)!=0) + ((keystate[VK_CONTROL]&0x80)!=0)*2; + /* Note if AltGr was pressed and if it was used as a compose key */ + if (!compose_state) { + compose_key = -1; + if (cfg.compose_key) { + if (wParam == VK_MENU && (HIWORD(lParam)&KF_EXTENDED)) + compose_key = wParam; + } + if (wParam == VK_APPS) + compose_key = wParam; + } + + if (wParam == compose_key) + { + if (compose_state == 0 && (HIWORD(lParam)&(KF_UP|KF_REPEAT))==0) + compose_state = 1; + else if (compose_state == 1 && (HIWORD(lParam)&KF_UP)) + compose_state = 2; + else + compose_state = 0; + } + else if (compose_state==1 && wParam != VK_CONTROL) + compose_state = 0; + /* * Record that we pressed key so the scroll window can be reset, but * be careful to avoid Shift-UP/Down @@ -2237,6 +2251,10 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam, { *p++ = 3; return p - output; } + if (wParam == VK_PAUSE) /* Break/Pause */ + { + *p++ = 26; *p++ = 0; return -2; + } /* Control-2 to Control-8 are special */ if (shift_state == 2 && wParam >= '2' && wParam <= '8') { @@ -2420,6 +2438,7 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam, } else return 0; } + else alt_state = 0; return -1; }