Skip to content

Inform backends if events have been handled

Arjan Molenaar requested to merge amolenaar/gtk:macos-native-key-bindings into main

In this case, macOS has a couple of default key bindings. Those should only trigger, if not handled by the application.

Current situation

The event handled state is propagated partially, however, gtk_main_do_event() always returns TRUE. This prevents the backend from knowing if the event was actually handled. In case of unhandled events, we should allow the native app to handle those.

New situation

The event handled state is propagated all the way up to the native backend.

For Windows, Wayland, and X11 this has no effect, since the return code is ignored.

By knowing the handled state on macOS, default key bindings such as Cmd+` (change window) and Ctrl+F2 (focus menu), can be activate with default shortcuts.

This MR makes some changes to API's on both GTK and GDK side. I hope this is okay. Both GtkWindow and GtkTooltipWindow propagate the handled state. Not sure if GtkPopupWindow should do too.

Fixes #2914 (closed), #5637 (closed)

Edited by Arjan Molenaar

Merge request reports