mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-27 02:02:26 +00:00
Turns out that the compose-keys fix in r9567 did in fact break one
piece of keyboard handling: if Num Lock is on, numeric keypad keys are
eaten by the IM, so we must avoid passing them to the IM in the first
place if we're in any non-default numeric keypad mode (application or
Nethack).
This is a grubby way to do it, but the more obvious approach of just
moving the Nethack and app-keypad if statements up to above the IM
call doesn't work because those statements depend on the generic
Alt-prefix handling that happens just _below_ the IM call. So instead
I just repeat the list of keystrokes and modes in an if statement
conditionalising the IM call.
[originally from svn r9573]
[r9567 == 7fc8db15b2
]
This commit is contained in:
parent
d0ac277f78
commit
a3f74661c8
@ -532,6 +532,7 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
|
|||||||
char output[256];
|
char output[256];
|
||||||
wchar_t ucsoutput[2];
|
wchar_t ucsoutput[2];
|
||||||
int ucsval, start, end, special, output_charset, use_ucsoutput;
|
int ucsval, start, end, special, output_charset, use_ucsoutput;
|
||||||
|
int nethack_mode, app_keypad_mode;
|
||||||
|
|
||||||
/* Remember the timestamp. */
|
/* Remember the timestamp. */
|
||||||
inst->input_event_time = event->time;
|
inst->input_event_time = event->time;
|
||||||
@ -673,6 +674,10 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
|
|||||||
special = FALSE;
|
special = FALSE;
|
||||||
use_ucsoutput = FALSE;
|
use_ucsoutput = FALSE;
|
||||||
|
|
||||||
|
nethack_mode = conf_get_int(inst->conf, CONF_nethack_keypad);
|
||||||
|
app_keypad_mode = (inst->term->app_keypad_keys &&
|
||||||
|
!conf_get_int(inst->conf, CONF_no_applic_k));
|
||||||
|
|
||||||
/* ALT+things gives leading Escape. */
|
/* ALT+things gives leading Escape. */
|
||||||
output[0] = '\033';
|
output[0] = '\033';
|
||||||
#if !GTK_CHECK_VERSION(2,0,0)
|
#if !GTK_CHECK_VERSION(2,0,0)
|
||||||
@ -686,8 +691,68 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
|
|||||||
output_charset = CS_ISO8859_1;
|
output_charset = CS_ISO8859_1;
|
||||||
strncpy(output+1, event->string, lenof(output)-1);
|
strncpy(output+1, event->string, lenof(output)-1);
|
||||||
#else
|
#else
|
||||||
if (gtk_im_context_filter_keypress(inst->imc, event))
|
/*
|
||||||
return TRUE;
|
* Most things can now be passed to
|
||||||
|
* gtk_im_context_filter_keypress without breaking anything
|
||||||
|
* below this point. An exception is the numeric keypad if
|
||||||
|
* we're in Nethack or application mode: the IM will eat
|
||||||
|
* numeric keypad presses if Num Lock is on, but we don't want
|
||||||
|
* it to.
|
||||||
|
*/
|
||||||
|
if (app_keypad_mode &&
|
||||||
|
(event->keyval == GDK_Num_Lock ||
|
||||||
|
event->keyval == GDK_KP_Divide ||
|
||||||
|
event->keyval == GDK_KP_Multiply ||
|
||||||
|
event->keyval == GDK_KP_Subtract ||
|
||||||
|
event->keyval == GDK_KP_Add ||
|
||||||
|
event->keyval == GDK_KP_Enter ||
|
||||||
|
event->keyval == GDK_KP_0 ||
|
||||||
|
event->keyval == GDK_KP_Insert ||
|
||||||
|
event->keyval == GDK_KP_1 ||
|
||||||
|
event->keyval == GDK_KP_End ||
|
||||||
|
event->keyval == GDK_KP_2 ||
|
||||||
|
event->keyval == GDK_KP_Down ||
|
||||||
|
event->keyval == GDK_KP_3 ||
|
||||||
|
event->keyval == GDK_KP_Page_Down ||
|
||||||
|
event->keyval == GDK_KP_4 ||
|
||||||
|
event->keyval == GDK_KP_Left ||
|
||||||
|
event->keyval == GDK_KP_5 ||
|
||||||
|
event->keyval == GDK_KP_Begin ||
|
||||||
|
event->keyval == GDK_KP_6 ||
|
||||||
|
event->keyval == GDK_KP_Right ||
|
||||||
|
event->keyval == GDK_KP_7 ||
|
||||||
|
event->keyval == GDK_KP_Home ||
|
||||||
|
event->keyval == GDK_KP_8 ||
|
||||||
|
event->keyval == GDK_KP_Up ||
|
||||||
|
event->keyval == GDK_KP_9 ||
|
||||||
|
event->keyval == GDK_KP_Page_Up ||
|
||||||
|
event->keyval == GDK_KP_Decimal ||
|
||||||
|
event->keyval == GDK_KP_Delete)) {
|
||||||
|
/* app keypad; do nothing */
|
||||||
|
} else if (nethack_mode &&
|
||||||
|
(event->keyval == GDK_KP_1 ||
|
||||||
|
event->keyval == GDK_KP_End ||
|
||||||
|
event->keyval == GDK_KP_2 ||
|
||||||
|
event->keyval == GDK_KP_Down ||
|
||||||
|
event->keyval == GDK_KP_3 ||
|
||||||
|
event->keyval == GDK_KP_Page_Down ||
|
||||||
|
event->keyval == GDK_KP_4 ||
|
||||||
|
event->keyval == GDK_KP_Left ||
|
||||||
|
event->keyval == GDK_KP_5 ||
|
||||||
|
event->keyval == GDK_KP_Begin ||
|
||||||
|
event->keyval == GDK_KP_6 ||
|
||||||
|
event->keyval == GDK_KP_Right ||
|
||||||
|
event->keyval == GDK_KP_7 ||
|
||||||
|
event->keyval == GDK_KP_Home ||
|
||||||
|
event->keyval == GDK_KP_8 ||
|
||||||
|
event->keyval == GDK_KP_Up ||
|
||||||
|
event->keyval == GDK_KP_9 ||
|
||||||
|
event->keyval == GDK_KP_Page_Up)) {
|
||||||
|
/* nethack mode; do nothing */
|
||||||
|
} else {
|
||||||
|
if (gtk_im_context_filter_keypress(inst->imc, event))
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GDK 2.0 arranges to have done some translation for us: in
|
* GDK 2.0 arranges to have done some translation for us: in
|
||||||
@ -817,7 +882,7 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
|
|||||||
/*
|
/*
|
||||||
* NetHack keypad mode.
|
* NetHack keypad mode.
|
||||||
*/
|
*/
|
||||||
if (conf_get_int(inst->conf, CONF_nethack_keypad)) {
|
if (nethack_mode) {
|
||||||
char *keys = NULL;
|
char *keys = NULL;
|
||||||
switch (event->keyval) {
|
switch (event->keyval) {
|
||||||
case GDK_KP_1: case GDK_KP_End: keys = "bB\002"; break;
|
case GDK_KP_1: case GDK_KP_End: keys = "bB\002"; break;
|
||||||
@ -846,8 +911,7 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
|
|||||||
/*
|
/*
|
||||||
* Application keypad mode.
|
* Application keypad mode.
|
||||||
*/
|
*/
|
||||||
if (inst->term->app_keypad_keys &&
|
if (app_keypad_mode) {
|
||||||
!conf_get_int(inst->conf, CONF_no_applic_k)) {
|
|
||||||
int xkey = 0;
|
int xkey = 0;
|
||||||
switch (event->keyval) {
|
switch (event->keyval) {
|
||||||
case GDK_Num_Lock: xkey = 'P'; break;
|
case GDK_Num_Lock: xkey = 'P'; break;
|
||||||
|
Loading…
Reference in New Issue
Block a user