From 8dfc39bfb48bcbf71c57b1f870d9ade2ad4b730a Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Tue, 24 Nov 2020 20:41:25 +0000 Subject: [PATCH] gtk: make Ctrl processing notice if use_ucsoutput is true. Again in the GDK Broadway backend, where we never get a non-Unicode translation of any keystroke: when we come to the code that handles Ctrl+letter (and other symbols), we were basing the Ctrl transform on output[1], that is, the non-Unicode translation we had so far. But we didn't have one. Now we check the use_ucsoutput flag to decide which of output and ucsoutput to start from, and as a result, Ctrl+keys works again on Broadway. --- unix/gtkwin.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/unix/gtkwin.c b/unix/gtkwin.c index 18dfd39d..c27b353b 100644 --- a/unix/gtkwin.c +++ b/unix/gtkwin.c @@ -1674,35 +1674,37 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data) * The translations below are in line with X11 policy as far * as I know. */ if ((event->state & GDK_CONTROL_MASK) && end == 2) { -#ifdef KEY_EVENT_DIAGNOSTICS - int orig = output[1]; -#endif + int orig = use_ucsoutput ? ucsoutput[1] : output[1]; + int new = orig; - if (output[1] >= '3' && output[1] <= '7') { + if (new >= '3' && new <= '7') { /* ^3,...,^7 map to 0x1B,...,0x1F */ - output[1] += '\x1B' - '3'; - } else if (output[1] == '2' || output[1] == ' ') { + new += '\x1B' - '3'; + } else if (new == '2' || new == ' ') { /* ^2 and ^Space are both ^@, i.e. \0 */ - output[1] = '\0'; - } else if (output[1] == '8') { + new = '\0'; + } else if (new == '8') { /* ^8 is DEL */ - output[1] = '\x7F'; - } else if (output[1] == '/') { + new = '\x7F'; + } else if (new == '/') { /* ^/ is the same as ^_ */ - output[1] = '\x1F'; - } else if (output[1] >= 0x40 && output[1] < 0x7F) { + new = '\x1F'; + } else if (new >= 0x40 && new < 0x7F) { /* Everything anywhere near the alphabetics just gets * masked. */ - output[1] &= 0x1F; + new &= 0x1F; } /* Anything else, e.g. '0', is unchanged. */ #ifdef KEY_EVENT_DIAGNOSTICS - if (orig == output[1]) + if (orig == new) { debug(" - manual Ctrl key handling did nothing\n"); - else + } else { debug(" - manual Ctrl key handling: %02x -> %02x\n", - (unsigned)orig, (unsigned)output[1]); + (unsigned)orig, (unsigned)new); + output[1] = new; + use_ucsoutput = false; + } #endif }