diff --git a/include/ghostty.h b/include/ghostty.h index b0e5c3fd6..354da33d0 100644 --- a/include/ghostty.h +++ b/include/ghostty.h @@ -615,6 +615,7 @@ ghostty_app_t ghostty_app_new(const ghostty_runtime_config_s*, void ghostty_app_free(ghostty_app_t); bool ghostty_app_tick(ghostty_app_t); void* ghostty_app_userdata(ghostty_app_t); +void ghostty_app_set_focus(ghostty_app_t, bool); bool ghostty_app_key(ghostty_app_t, ghostty_input_key_s); void ghostty_app_keyboard_changed(ghostty_app_t); void ghostty_app_open_config(ghostty_app_t); diff --git a/src/apprt/embedded.zig b/src/apprt/embedded.zig index dc6006caf..4d45166aa 100644 --- a/src/apprt/embedded.zig +++ b/src/apprt/embedded.zig @@ -132,6 +132,11 @@ pub const App = struct { surface: *Surface, }; + /// See CoreApp.focusEvent + pub fn focusEvent(self: *App, focused: bool) void { + self.core_app.focusEvent(focused); + } + /// See CoreApp.keyEvent. pub fn keyEvent( self: *App, @@ -1296,6 +1301,14 @@ pub const CAPI = struct { core_app.destroy(); } + /// Update the focused state of the app. + export fn ghostty_app_set_focus( + app: *App, + focused: bool, + ) void { + app.focusEvent(focused); + } + /// Notify the app of a global keypress capture. This will return /// true if the key was captured by the app, in which case the caller /// should not process the key.