diff --git a/windows/pageant.c b/windows/pageant.c index 0e3868a0..cb0abb97 100644 --- a/windows/pageant.c +++ b/windows/pageant.c @@ -1270,6 +1270,9 @@ static LRESULT CALLBACK TrayWndProc(HWND hwnd, UINT message, } break; } + case WM_NETEVENT: + winselgui_response(wParam, lParam); + return 0; case WM_DESTROY: quit_help(hwnd); PostQuitMessage(0); diff --git a/windows/platform.h b/windows/platform.h index 33891c5f..8018ba23 100644 --- a/windows/platform.h +++ b/windows/platform.h @@ -333,6 +333,7 @@ const char *do_select(SOCKET skt, bool enable); */ void winselgui_set_hwnd(HWND hwnd); void winselgui_clear_hwnd(void); +void winselgui_response(WPARAM wParam, LPARAM lParam); void winselcli_setup(void); SOCKET winselcli_unique_socket(void); diff --git a/windows/select-gui.c b/windows/select-gui.c index de3d9091..4c37c345 100644 --- a/windows/select-gui.c +++ b/windows/select-gui.c @@ -36,3 +36,30 @@ const char *do_select(SOCKET skt, bool enable) return NULL; } + +struct wm_netevent_params { + /* Used to pass data to wm_netevent_callback */ + WPARAM wParam; + LPARAM lParam; +}; + +static void wm_netevent_callback(void *vctx) +{ + struct wm_netevent_params *params = (struct wm_netevent_params *)vctx; + select_result(params->wParam, params->lParam); + sfree(params); +} + +void winselgui_response(WPARAM wParam, LPARAM lParam) +{ + /* + * To protect against re-entrancy when Windows's recv() + * immediately triggers a new WSAAsyncSelect window message, we + * don't call select_result directly from this handler but instead + * wait until we're back out at the top level of the message loop. + */ + struct wm_netevent_params *params = snew(struct wm_netevent_params); + params->wParam = wParam; + params->lParam = lParam; + queue_toplevel_callback(wm_netevent_callback, params); +} diff --git a/windows/window.c b/windows/window.c index c1cd0c4c..ebcaa74a 100644 --- a/windows/window.c +++ b/windows/window.c @@ -151,12 +151,6 @@ static Conf *conf; static LogContext *logctx; static Terminal *term; -struct wm_netevent_params { - /* Used to pass data to wm_netevent_callback */ - WPARAM wParam; - LPARAM lParam; -}; - static void conf_cache_data(void); static int cursor_type; static int vtmode; @@ -1117,16 +1111,6 @@ void cmdline_error(const char *fmt, ...) exit(1); } -/* - * Actually do the job requested by a WM_NETEVENT - */ -static void wm_netevent_callback(void *vctx) -{ - struct wm_netevent_params *params = (struct wm_netevent_params *)vctx; - select_result(params->wParam, params->lParam); - sfree(vctx); -} - static inline rgb rgb_from_colorref(COLORREF cr) { rgb toret; @@ -2812,21 +2796,9 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, ShowCaret(hwnd); return 0; } - case WM_NETEVENT: { - /* - * To protect against re-entrancy when Windows's recv() - * immediately triggers a new WSAAsyncSelect window - * message, we don't call select_result directly from this - * handler but instead wait until we're back out at the - * top level of the message loop. - */ - struct wm_netevent_params *params = - snew(struct wm_netevent_params); - params->wParam = wParam; - params->lParam = lParam; - queue_toplevel_callback(wm_netevent_callback, params); + case WM_NETEVENT: + winselgui_response(wParam, lParam); return 0; - } case WM_SETFOCUS: term_set_focus(term, true); CreateCaret(hwnd, caretbm, font_width, font_height);