mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-03-22 14:39:24 -05:00
Robert de Bath's `Patch.a_alt_key': clean up the handling of
Alt-Space, Alt-only and the System menu. It lets Windows do more of the work, and also saves a static variable, so it must be good :-) [originally from svn r1237]
This commit is contained in:
parent
8e58b47df2
commit
f1c2f2fcf0
38
window.c
38
window.c
@ -1493,6 +1493,17 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
|||||||
case IDM_ABOUT:
|
case IDM_ABOUT:
|
||||||
showabout(hwnd);
|
showabout(hwnd);
|
||||||
break;
|
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:
|
default:
|
||||||
if (wParam >= IDM_SAVED_MIN && wParam <= IDM_SAVED_MAX) {
|
if (wParam >= IDM_SAVED_MIN && wParam <= IDM_SAVED_MAX) {
|
||||||
SendMessage(hwnd, WM_SYSCOMMAND, IDM_SAVEDSESS, wParam);
|
SendMessage(hwnd, WM_SYSCOMMAND, IDM_SAVEDSESS, wParam);
|
||||||
@ -2294,7 +2305,6 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
|
|||||||
int scan, left_alt = 0, key_down, shift_state;
|
int scan, left_alt = 0, key_down, shift_state;
|
||||||
int r, i, code;
|
int r, i, code;
|
||||||
unsigned char *p = output;
|
unsigned char *p = output;
|
||||||
static int alt_state = 0;
|
|
||||||
static int alt_sum = 0;
|
static int alt_sum = 0;
|
||||||
|
|
||||||
HKL kbd_layout = GetKeyboardLayout(0);
|
HKL kbd_layout = GetKeyboardLayout(0);
|
||||||
@ -2535,8 +2545,6 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (left_alt && wParam == VK_SPACE && cfg.alt_space) {
|
if (left_alt && wParam == VK_SPACE && cfg.alt_space) {
|
||||||
alt_state = 0;
|
|
||||||
PostMessage(hwnd, WM_CHAR, ' ', 0);
|
|
||||||
SendMessage(hwnd, WM_SYSCOMMAND, SC_KEYMENU, 0);
|
SendMessage(hwnd, WM_SYSCOMMAND, SC_KEYMENU, 0);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -2796,6 +2804,8 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
|
|||||||
case VK_F20:
|
case VK_F20:
|
||||||
code = 34;
|
code = 34;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
if ((shift_state&2) == 0) switch (wParam) {
|
||||||
case VK_HOME:
|
case VK_HOME:
|
||||||
code = 1;
|
code = 1;
|
||||||
break;
|
break;
|
||||||
@ -3044,19 +3054,15 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
|
|||||||
keys[0] = 10;
|
keys[0] = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ALT alone may or may not want to bring up the System menu */
|
/*
|
||||||
if (wParam == VK_MENU) {
|
* ALT alone may or may not want to bring up the System menu.
|
||||||
if (cfg.alt_only) {
|
* If it's not meant to, we return 0 on presses or releases of
|
||||||
if (message == WM_SYSKEYDOWN)
|
* ALT, to show that we've swallowed the keystroke. Otherwise
|
||||||
alt_state = 1;
|
* we return -1, which means Windows will give the keystroke
|
||||||
else if (message == WM_SYSKEYUP && alt_state)
|
* its default handling (i.e. bring up the System menu).
|
||||||
PostMessage(hwnd, WM_CHAR, ' ', 0);
|
*/
|
||||||
if (message == WM_SYSKEYUP)
|
if (wParam == VK_MENU && !cfg.alt_only)
|
||||||
alt_state = 0;
|
return 0;
|
||||||
} else
|
|
||||||
return 0;
|
|
||||||
} else
|
|
||||||
alt_state = 0;
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user