1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-25 01:02:24 +00:00

OS X: pass Command key back to GTK if it's not being Meta.

This fixes the problem I'd previously noticed, that if you don't
configure the "Command key acts as Meta" setting, then keystrokes like
Command-Q which _ought_ to function as accelerators for the
application menu bar don't.

Turns out that this was for the totally obvious reason: the keyboard
event was still being processed by gtkwin.c's key_event() and
translated via the GTK IM into ordinary keyboard input. If instead I
return FALSE from key_event on detecting that a key event has a
non-Meta-configured Command modifier, then it will go to the next-
level key-event handler inside GTK itself which implements the menu
accelerator behaviour. Another problem ticked off the OS X checklist.
This commit is contained in:
Simon Tatham 2017-12-18 10:43:13 +00:00
parent 3faca7724a
commit 1904c404ed
2 changed files with 9 additions and 9 deletions

View File

@ -27,15 +27,6 @@ and you should get unix/PuTTY.app and unix/PTerm.app as output.
TODO list for a sensible GTK3 PuTTY/pterm on OS X:
Menu items' keyboard shortcuts (Command-Q for Quit, Command-V for
Paste) do not currently work. It's intentional that if you turn on
'Command key acts as Meta' in the configuration then those shortcuts
should be superseded by the Meta-key functionality (e.g. Cmd-Q should
send ESC Q to the session), for the benefit of people whose non-Mac
keyboard reflexes expect the Meta key to be in that position; but if
you don't turn that option on, then these shortcuts should work as an
ordinary Mac user expects, and currently they don't.
Mouse wheel events and trackpad scrolling gestures don't work quite
right in the terminal drawing area.

View File

@ -168,6 +168,9 @@ struct gui_data {
int cursor_type;
int drawtype;
int meta_mod_mask;
#ifdef OSX_META_KEY_CONFIG
int system_mod_mask;
#endif
};
static void cache_conf_values(struct gui_data *inst)
@ -181,6 +184,7 @@ static void cache_conf_values(struct gui_data *inst)
inst->meta_mod_mask |= GDK_MOD1_MASK;
if (conf_get_int(inst->conf, CONF_osx_command_meta))
inst->meta_mod_mask |= GDK_MOD2_MASK;
inst->system_mod_mask = GDK_MOD2_MASK & ~inst->meta_mod_mask;
#else
inst->meta_mod_mask = GDK_MOD1_MASK;
#endif
@ -780,6 +784,11 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
int ucsval, start, end, special, output_charset, use_ucsoutput;
int nethack_mode, app_keypad_mode;
#ifdef OSX_META_KEY_CONFIG
if (event->state & inst->system_mod_mask)
return FALSE; /* let GTK process OS X Command key */
#endif
/* Remember the timestamp. */
inst->input_event_time = event->time;