X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/b2a1eade5dd99b8252fab726a6f78f419e0d52a2..8f57d7538f2fa8ebd57099f0237e29084ff1cd7f:/window.c diff --git a/window.c b/window.c index 46bf64f2..869e91f3 100644 --- a/window.c +++ b/window.c @@ -71,13 +71,16 @@ static void init_fonts(int); static void another_font(int); static void deinit_fonts(void); -static int extra_width, extra_height; +static int full_screen = 0, extra_width, extra_height; +static LONG old_wind_style; +static WINDOWPLACEMENT old_wind_placement; static int pending_netevent = 0; static WPARAM pend_netevent_wParam = 0; static LPARAM pend_netevent_lParam = 0; static void enact_pending_netevent(void); static void flash_window(int mode); +static void flip_full_screen(void); static time_t last_movement = 0; @@ -706,7 +709,8 @@ char *do_select(SOCKET skt, int startup) int msg, events; if (startup) { msg = WM_NETEVENT; - events = FD_READ | FD_WRITE | FD_OOB | FD_CLOSE | FD_ACCEPT; + events = (FD_CONNECT | FD_READ | FD_WRITE | + FD_OOB | FD_CLOSE | FD_ACCEPT); } else { msg = events = 0; } @@ -1129,7 +1133,8 @@ static void click(Mouse_Button b, int x, int y, int shift, int ctrl) { int thistime = GetMessageTime(); - if (send_raw_mouse) { + if (send_raw_mouse && !(cfg.mouse_override && shift)) { + lastbtn = MBT_NOTHING; term_mouse(b, MA_CLICK, x, y, shift, ctrl); return; } @@ -1492,6 +1497,17 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, case IDM_ABOUT: showabout(hwnd); break; + case SC_KEYMENU: + /* + * We get this if the System menu has been activated. + * This might happen from within TranslateKey, in which + * case it really wants to be followed by a `space' + * character to actually _bring the menu up_ rather + * than just sitting there in `ready to appear' state. + */ + if( lParam == 0 ) + PostMessage(hwnd, WM_CHAR, ' ', 0); + break; default: if (wParam >= IDM_SAVED_MIN && wParam <= IDM_SAVED_MAX) { SendMessage(hwnd, WM_SYSCOMMAND, IDM_SAVEDSESS, wParam); @@ -1654,6 +1670,9 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, pending_netevent = TRUE; pend_netevent_wParam = wParam; pend_netevent_lParam = lParam; + if (WSAGETSELECTEVENT(lParam) != FD_READ) + enact_pending_netevent(); + time(&last_movement); return 0; case WM_SETFOCUS: @@ -1945,7 +1964,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, } return 0; case WM_SETCURSOR: - if (send_raw_mouse) { + if (send_raw_mouse && LOWORD(lParam) == HTCLIENT) { SetCursor(LoadCursor(NULL, IDC_ARROW)); return TRUE; } @@ -2293,7 +2312,6 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam, int scan, left_alt = 0, key_down, shift_state; int r, i, code; unsigned char *p = output; - static int alt_state = 0; static int alt_sum = 0; HKL kbd_layout = GetKeyboardLayout(0); @@ -2534,11 +2552,13 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam, return -1; } if (left_alt && wParam == VK_SPACE && cfg.alt_space) { - alt_state = 0; - PostMessage(hwnd, WM_CHAR, ' ', 0); SendMessage(hwnd, WM_SYSCOMMAND, SC_KEYMENU, 0); return -1; } + if (left_alt && wParam == VK_RETURN && cfg.fullscreenonaltenter) { + flip_full_screen(); + return -1; + } /* Control-Numlock for app-keypad mode switch */ if (wParam == VK_PAUSE && shift_state == 2) { app_keypad_keys ^= 1; @@ -2795,6 +2815,8 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam, case VK_F20: code = 34; break; + } + if ((shift_state&2) == 0) switch (wParam) { case VK_HOME: code = 1; break; @@ -3043,19 +3065,15 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam, keys[0] = 10; } - /* ALT alone may or may not want to bring up the System menu */ - if (wParam == VK_MENU) { - if (cfg.alt_only) { - if (message == WM_SYSKEYDOWN) - alt_state = 1; - else if (message == WM_SYSKEYUP && alt_state) - PostMessage(hwnd, WM_CHAR, ' ', 0); - if (message == WM_SYSKEYUP) - alt_state = 0; - } else - return 0; - } else - alt_state = 0; + /* + * ALT alone may or may not want to bring up the System menu. + * If it's not meant to, we return 0 on presses or releases of + * ALT, to show that we've swallowed the keystroke. Otherwise + * we return -1, which means Windows will give the keystroke + * its default handling (i.e. bring up the System menu). + */ + if (wParam == VK_MENU && !cfg.alt_only) + return 0; return -1; } @@ -3404,3 +3422,27 @@ void beep(int mode) flash_window(2); /* start */ } } + +/* + * Toggle full screen mode. Thanks to cwis@nerim.fr for the + * implementation. + */ +static void flip_full_screen(void) +{ + if (!full_screen) { + int cx, cy; + + cx = GetSystemMetrics(SM_CXSCREEN); + cy = GetSystemMetrics(SM_CYSCREEN); + GetWindowPlacement(hwnd, &old_wind_placement); + old_wind_style = GetWindowLong(hwnd, GWL_STYLE); + SetWindowLong(hwnd, GWL_STYLE, + old_wind_style & ~(WS_CAPTION | WS_BORDER | WS_THICKFRAME)); + SetWindowPos(hwnd, HWND_TOP, 0, 0, cx, cy, SWP_SHOWWINDOW); + full_screen = 1; + } else { + SetWindowLong(hwnd, GWL_STYLE, old_wind_style); + SetWindowPlacement(hwnd,&old_wind_placement); + full_screen = 0; + } +}