X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/blobdiff_plain/ec8679e9b667dd6de9ef29e0d01085b219901e3b..2784cd098cc201db40725bb11c888791cba0ee0f:/window.c?ds=inline diff --git a/window.c b/window.c index 91b4dc53..fe9d2e91 100644 --- a/window.c +++ b/window.c @@ -13,6 +13,7 @@ #define PUTTY_DO_GLOBALS /* actually _define_ globals */ #include "putty.h" +#include "storage.h" #include "win_res.h" #define IDM_SHOWLOG 0x0010 @@ -82,6 +83,8 @@ static RGBTRIPLE defpal[NCOLOURS]; static HWND hwnd; +static HBITMAP caretbm; + static int dbltime, lasttime, lastact; static Mouse_Button lastbtn; @@ -176,8 +179,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) { "to continue?", "PuTTY Warning", MB_YESNO | MB_ICONWARNING) == IDYES) { - random_destroy_seed(); - registry_cleanup(); + cleanup_all(); } exit(0); } @@ -383,6 +385,17 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) { SWP_NOMOVE | SWP_NOREDRAW | SWP_NOZORDER); /* + * Set up a caret bitmap, with no content. + */ + { + char *bits; + int size = (font_width+15)/16 * 2 * font_height; + bits = calloc(size, 1); + caretbm = CreateBitmap(font_width, font_height, 1, 1, bits); + free(bits); + } + + /* * Initialise the scroll bar. */ { @@ -402,7 +415,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) { */ { char *error; - char msg[1024]; + char msg[1024], *title; char *realhost; error = back->init (hwnd, cfg.host, cfg.port, &realhost); @@ -412,9 +425,14 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) { return 0; } window_name = icon_name = NULL; - sprintf(msg, "%s - PuTTY", realhost); - set_title (msg); - set_icon (msg); + if (*cfg.wintitle) { + title = cfg.wintitle; + } else { + sprintf(msg, "%s - PuTTY", realhost); + title = msg; + } + set_title (title); + set_icon (title); } session_closed = FALSE; @@ -536,9 +554,11 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) { KillTimer(hwnd, timer_id); timer_id = 0; } + HideCaret(hwnd); if (inbuf_head) term_out(); term_update(); + ShowCaret(hwnd); if (!has_focus) timer_id = SetTimer(hwnd, 1, 2000, NULL); else if (cfg.blinktext) @@ -990,7 +1010,9 @@ static LRESULT CALLBACK WndProc (HWND hwnd, UINT message, enact_pending_netevent(); if (inbuf_head) term_out(); + HideCaret(hwnd); term_update(); + ShowCaret(hwnd); return 0; case WM_CREATE: break; @@ -1243,6 +1265,7 @@ static LRESULT CALLBACK WndProc (HWND hwnd, UINT message, case WM_PAINT: { PAINTSTRUCT p; + HideCaret(hwnd); hdc = BeginPaint (hwnd, &p); if (pal) { SelectPalette (hdc, pal, TRUE); @@ -1253,6 +1276,7 @@ static LRESULT CALLBACK WndProc (HWND hwnd, UINT message, SelectObject (hdc, GetStockObject(SYSTEM_FONT)); SelectObject (hdc, GetStockObject(WHITE_PEN)); EndPaint (hwnd, &p); + ShowCaret(hwnd); } return 0; case WM_NETEVENT: @@ -1269,7 +1293,8 @@ static LRESULT CALLBACK WndProc (HWND hwnd, UINT message, return 0; case WM_SETFOCUS: has_focus = TRUE; - CreateCaret(hwnd, NULL, font_width, font_height); + CreateCaret(hwnd, caretbm, 0, 0); + ShowCaret(hwnd); term_out(); term_update(); break;