X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=windows%2Fwindow.c;h=4d581d70522166de6b96df89845a4dbeff6d9049;hb=9fc67313fb7dda826c9c464a21e0900c724769b1;hp=b460b53431fd7745cc07a149a1f69816a2853415;hpb=7ecf13564a8d716000ce78146d1aaf4422432a4f;p=PuTTY.git diff --git a/windows/window.c b/windows/window.c index b460b534..4d581d70 100644 --- a/windows/window.c +++ b/windows/window.c @@ -588,10 +588,6 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) memset(&ucsdata, 0, sizeof(ucsdata)); - term = term_init(&cfg, &ucsdata, NULL); - logctx = log_init(NULL, &cfg); - term_provide_logctx(term, logctx); - cfgtopalette(); /* @@ -605,9 +601,8 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) font_height = 20; extra_width = 25; extra_height = 28; - term_size(term, cfg.height, cfg.width, cfg.savelines); - guess_width = extra_width + font_width * term->cols; - guess_height = extra_height + font_height * term->rows; + guess_width = extra_width + font_width * cfg.width; + guess_height = extra_height + font_height * cfg.height; { RECT r; get_fullscreen_rect(&r); @@ -634,6 +629,17 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) NULL, NULL, inst, NULL); } + /* + * Initialise the terminal. (We have to do this _after_ + * creating the window, since the terminal is the first thing + * which will call schedule_timer(), which will in turn call + * timer_change_notify() which will expect hwnd to exist. + */ + term = term_init(&cfg, &ucsdata, NULL); + logctx = log_init(NULL, &cfg); + term_provide_logctx(term, logctx); + term_size(term, cfg.height, cfg.width, cfg.savelines); + /* * Initialise the fonts, simultaneously correcting the guesses * for font_{width,height}. @@ -770,7 +776,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) logpal = NULL; init_palette(); - term->has_focus = (GetForegroundWindow() == hwnd); + term_set_focus(term, GetForegroundWindow() == hwnd); UpdateWindow(hwnd); if (GetMessage(&msg, NULL, 0, 0) == 1) { @@ -787,7 +793,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) continue; /* The messages seem unreliable; especially if we're being tricky */ - term->has_focus = (GetForegroundWindow() == hwnd); + term_set_focus(term, GetForegroundWindow() == hwnd); net_pending_errors(); @@ -2317,7 +2323,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, net_pending_errors(); return 0; case WM_SETFOCUS: - term->has_focus = TRUE; + term_set_focus(term, TRUE); CreateCaret(hwnd, caretbm, font_width, font_height); ShowCaret(hwnd); flash_window(0); /* stop */ @@ -2326,7 +2332,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, break; case WM_KILLFOCUS: show_mouseptr(1); - term->has_focus = FALSE; + term_set_focus(term, FALSE); DestroyCaret(); caret_x = caret_y = -1; /* ensure caret is replaced next time */ term_update(term);