Skip to content

macOS: Add native keyboard shortcuts

Arjan Molenaar requested to merge amolenaar/macos-keybindings into main

I'll drop this MR as one approach to fix #3421, support for macOS keybindings.

Currently, key mappings use Ctrl as their primary modifier. This is the default on Linux and Windows. On macOS, Cmd is the primary modifier. It would be really nice for GTK users on macOS to get this native experience.

Changes:

  • Drop GDK_MOD2_MASK as intermediate step to map Cmd.
  • Add extra keyboard shortcuts for macOS in #ifdef __APPLE__ blocks.

I figured it's probably better to only add extra macOS keybindings and not replace existing ones. The extra keyboard shortcuts do not hurt, although some keyboard shortcuts (such as <Ctrl> ↑ ↓ → ←) are used by the system and will never reach the application. Also, there are many places where multiple key combo's are used to activate the same action.

I tried to keep the grouping of key bindings. Hence you can find multiple __APPLE__ blocks in one file.

@matthiasc, @chergert, @jralls Is this is a good approach? I did some code changes, basically to illustrate what I have in mind.

Edited by Arjan Molenaar

Merge request reports