macos: track surface focus state

This commit is contained in:
Mitchell Hashimoto
2023-02-18 16:51:36 -08:00
parent 78754ff3ac
commit 6b450f7c7d
8 changed files with 132 additions and 4 deletions

View File

@@ -414,6 +414,11 @@ pub const CAPI = struct {
win.window.updateContentScale(x, y);
}
/// Update the focused state of a surface.
export fn ghostty_surface_set_focus(win: *Window, focused: bool) void {
win.window.focusCallback(focused);
}
/// Tell the surface that it needs to schedule a render
export fn ghostty_surface_key(
win: *Window,

View File

@@ -167,4 +167,11 @@ pub const Window = struct {
return;
};
}
pub fn focusCallback(self: *const Window, focused: bool) void {
self.core_win.focusCallback(focused) catch |err| {
log.err("error in focus callback err={}", .{err});
return;
};
}
};