X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/cecb13f6928246c1fc9f49c5613938b97b86da3d..76347f46fb70138ad34af07b2ab00625600931f1:/windows/window.c diff --git a/windows/window.c b/windows/window.c index fe90483e..80467745 100644 --- a/windows/window.c +++ b/windows/window.c @@ -158,7 +158,7 @@ static enum { } und_mode; static int descent; -#define NCFGCOLOURS 24 +#define NCFGCOLOURS 22 #define NEXTCOLOURS 240 #define NALLCOLOURS (NCFGCOLOURS + NEXTCOLOURS) static COLORREF colours[NALLCOLOURS]; @@ -177,6 +177,8 @@ static Mouse_Button lastbtn; static int send_raw_mouse = 0; static int wheel_accumulator = 0; +static int busy_status = BUSY_NOT; + static char *window_name, *icon_name; static int compose_state = 0; @@ -542,9 +544,20 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) } /* - * Trim a colon suffix off the hostname if it's there. + * Trim a colon suffix off the hostname if it's there. In + * order to protect IPv6 address literals against this + * treatment, we do not do this if there's _more_ than one + * colon. */ - cfg.host[strcspn(cfg.host, ":")] = '\0'; + { + char *c = strchr(cfg.host, ':'); + + if (c) { + char *d = strchr(c+1, ':'); + if (!d) + *c = '\0'; + } + } /* * Remove any remaining whitespace from the hostname. @@ -635,7 +648,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) * 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. + * timer_change_notify() which will expect hwnd to exist.) */ term = term_init(&cfg, &ucsdata, NULL); logctx = log_init(NULL, &cfg); @@ -938,6 +951,50 @@ void update_specials_menu(void *frontend) } } +static void update_mouse_pointer(void) +{ + LPTSTR curstype; + int force_visible = FALSE; + static int forced_visible = FALSE; + switch (busy_status) { + case BUSY_NOT: + if (send_raw_mouse) + curstype = IDC_ARROW; + else + curstype = IDC_IBEAM; + break; + case BUSY_WAITING: + curstype = IDC_APPSTARTING; /* this may be an abuse */ + force_visible = TRUE; + break; + case BUSY_CPU: + curstype = IDC_WAIT; + force_visible = TRUE; + break; + default: + assert(0); + } + { + HCURSOR cursor = LoadCursor(NULL, curstype); + SetClassLong(hwnd, GCL_HCURSOR, (LONG)cursor); + SetCursor(cursor); /* force redraw of cursor at current posn */ + } + if (force_visible != forced_visible) { + /* We want some cursor shapes to be visible always. + * Along with show_mouseptr(), this manages the ShowCursor() + * counter such that if we switch back to a non-force_visible + * cursor, the previous visibility state is restored. */ + ShowCursor(force_visible); + forced_visible = force_visible; + } +} + +void set_busy_status(void *frontend, int status) +{ + busy_status = status; + update_mouse_pointer(); +} + /* * set or clear the "raw mouse message" mode */ @@ -945,7 +1002,7 @@ void set_raw_mouse_mode(void *frontend, int activate) { activate = activate && !cfg.no_mouse_rep; send_raw_mouse = activate; - SetCursor(LoadCursor(NULL, activate ? IDC_ARROW : IDC_IBEAM)); + update_mouse_pointer(); } /* @@ -1725,6 +1782,8 @@ static Mouse_Button translate_button(Mouse_Button button) static void show_mouseptr(int show) { + /* NB that the counter in ShowCursor() is also frobbed by + * update_mouse_pointer() */ static int cursor_visible = 1; if (!cfg.hide_mouseptr) /* override if this feature disabled */ show = 1; @@ -1803,7 +1862,8 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, if (!cfg.warn_on_close || session_closed || MessageBox(hwnd, "Are you sure you want to close this session?", - str, MB_ICONWARNING | MB_OKCANCEL) == IDOK) + str, MB_ICONWARNING | MB_OKCANCEL | MB_DEFBUTTON2) + == IDOK) DestroyWindow(hwnd); sfree(str); } @@ -1900,7 +1960,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, GetWindowText(hwnd, cfg.wintitle, sizeof(cfg.wintitle)); prev_cfg = cfg; - if (!do_reconfig(hwnd)) + if (!do_reconfig(hwnd, back ? back->cfg_info(backhandle) : 0)) break; { @@ -2295,10 +2355,10 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, HBRUSH fillcolour, oldbrush; HPEN edge, oldpen; fillcolour = CreateSolidBrush ( - colours[(ATTR_DEFBG>>ATTR_BGSHIFT)*2]); + colours[ATTR_DEFBG>>ATTR_BGSHIFT]); oldbrush = SelectObject(hdc, fillcolour); edge = CreatePen(PS_SOLID, 0, - colours[(ATTR_DEFBG>>ATTR_BGSHIFT)*2]); + colours[ATTR_DEFBG>>ATTR_BGSHIFT]); oldpen = SelectObject(hdc, edge); /* @@ -2320,7 +2380,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, Rectangle(hdc, p.rcPaint.left, p.rcPaint.top, p.rcPaint.right, p.rcPaint.bottom); - // SelectClipRgn(hdc, NULL); + /* SelectClipRgn(hdc, NULL); */ SelectObject(hdc, oldbrush); DeleteObject(fillcolour); @@ -2740,12 +2800,6 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, lpage_send(ldisc, CP_ACP, &c, 1, 1); } return 0; - case WM_SETCURSOR: - if (send_raw_mouse && LOWORD(lParam) == HTCLIENT) { - SetCursor(LoadCursor(NULL, IDC_ARROW)); - return TRUE; - } - break; case WM_SYSCOLORCHANGE: if (cfg.system_colour) { /* Refresh palette from system colours. */ @@ -3234,7 +3288,7 @@ void do_cursor(Context ctx, int x, int y, wchar_t *text, int len, if (attr & TATTR_ACTCURS) { HPEN oldpen; oldpen = - SelectObject(hdc, CreatePen(PS_SOLID, 0, colours[23])); + SelectObject(hdc, CreatePen(PS_SOLID, 0, colours[261])); MoveToEx(hdc, startx, starty, NULL); LineTo(hdc, startx + dx * length, starty + dy * length); oldpen = SelectObject(hdc, oldpen); @@ -3242,7 +3296,7 @@ void do_cursor(Context ctx, int x, int y, wchar_t *text, int len, } else { for (i = 0; i < length; i++) { if (i % 2 == 0) { - SetPixel(hdc, startx, starty, colours[23]); + SetPixel(hdc, startx, starty, colours[261]); } startx += dx; starty += dy;