static int compose_state = 0;
-static OSVERSIONINFOEX osVersion;
+static OSVERSIONINFO osVersion;
/* Dummy routine, only required in plink. */
void ldisc_update(int echo, int edit)
{
ZeroMemory(&osVersion, sizeof(osVersion));
- osVersion.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
-
- if(!GetVersionEx ((OSVERSIONINFO *) &osVersion)) {
- // If OSVERSIONINFOEX doesn't work, try OSVERSIONINFO.
-
osVersion.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
- if (!GetVersionEx ( (OSVERSIONINFO *) &osVersion))
- return FALSE;
- }
+ if (!GetVersionEx ( (OSVERSIONINFO *) &osVersion)) {
+ MessageBox(NULL, "Windows refuses to report a version",
+ "PuTTY Fatal Error", MB_OK | MB_ICONEXCLAMATION);
+ return 1;
+ }
}
/*
int msg, events;
if (startup) {
msg = WM_NETEVENT;
- events = FD_READ | FD_WRITE | FD_OOB | FD_CLOSE;
+ events = (FD_CONNECT | FD_READ | FD_WRITE |
+ FD_OOB | FD_CLOSE | FD_ACCEPT);
} else {
msg = events = 0;
}
{
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;
}
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);
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:
len = TranslateKey(message, wParam, lParam, buf);
if (len == -1)
return DefWindowProc(hwnd, message, wParam, lParam);
- ldisc_send(buf, len);
- if (len > 0)
+ if (len != 0) {
+ /*
+ * We need not bother about stdin backlogs
+ * here, because in GUI PuTTY we can't do
+ * anything about it anyway; there's no means
+ * of asking Windows to hold off on KEYDOWN
+ * messages. We _have_ to buffer everything
+ * we're sent.
+ */
+ ldisc_send(buf, len);
show_mouseptr(0);
+ }
}
}
return 0;
}
return 0;
case WM_SETCURSOR:
- if (send_raw_mouse) {
+ if (send_raw_mouse && LOWORD(lParam) == HTCLIENT) {
SetCursor(LoadCursor(NULL, IDC_ARROW));
return TRUE;
}
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);
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;
}
case VK_F20:
code = 34;
break;
+ }
+ if ((shift_state&2) == 0) switch (wParam) {
case VK_HOME:
code = 1;
break;
luni_send(&keybuf, 1);
} else {
ch = (char) alt_sum;
+ /*
+ * We need not bother about stdin
+ * backlogs here, because in GUI PuTTY
+ * we can't do anything about it
+ * anyway; there's no means of asking
+ * Windows to hold off on KEYDOWN
+ * messages. We _have_ to buffer
+ * everything we're sent.
+ */
ldisc_send(&ch, 1);
}
alt_sum = 0;
lpage_send(kbd_codepage, cbuf + !left_alt,
1 + !!left_alt);
}
+ show_mouseptr(0);
}
/* This is so the ALT-Numpad and dead keys work correctly. */
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;
}