mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-05-29 11:38:38 +03:00
apprt/embedded: add draw now API
This commit is contained in:
@ -504,6 +504,7 @@ ghostty_app_t ghostty_surface_app(ghostty_surface_t);
|
||||
bool ghostty_surface_transparent(ghostty_surface_t);
|
||||
bool ghostty_surface_needs_confirm_quit(ghostty_surface_t);
|
||||
void ghostty_surface_refresh(ghostty_surface_t);
|
||||
void ghostty_surface_draw(ghostty_surface_t);
|
||||
void ghostty_surface_set_content_scale(ghostty_surface_t, double, double);
|
||||
void ghostty_surface_set_focus(ghostty_surface_t, bool);
|
||||
void ghostty_surface_set_occlusion(ghostty_surface_t, bool);
|
||||
|
@ -439,7 +439,7 @@ extension Ghostty {
|
||||
|
||||
override func updateLayer() {
|
||||
guard let surface = self.surface else { return }
|
||||
ghostty_surface_refresh(surface);
|
||||
ghostty_surface_draw(surface);
|
||||
}
|
||||
|
||||
override func acceptsFirstMouse(for event: NSEvent?) -> Bool {
|
||||
|
@ -553,6 +553,13 @@ pub fn close(self: *Surface) void {
|
||||
self.rt_surface.close(self.needsConfirmQuit());
|
||||
}
|
||||
|
||||
/// Forces the surface to render. This is useful for when the surface
|
||||
/// is in the middle of animation (such as a resize, etc.) or when
|
||||
/// the render timer is managed manually by the apprt.
|
||||
pub fn draw(self: *Surface) !void {
|
||||
try self.renderer_thread.draw_now.notify();
|
||||
}
|
||||
|
||||
/// Activate the inspector. This will begin collecting inspection data.
|
||||
/// This will not affect the GUI. The GUI must use performAction to
|
||||
/// show/hide the inspector UI.
|
||||
|
@ -653,6 +653,13 @@ pub const Surface = struct {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn draw(self: *Surface) void {
|
||||
self.core_surface.draw() catch |err| {
|
||||
log.err("error in draw err={}", .{err});
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
pub fn updateContentScale(self: *Surface, x: f64, y: f64) void {
|
||||
// We are an embedded API so the caller can send us all sorts of
|
||||
// garbage. We want to make sure that the float values are valid
|
||||
@ -1525,6 +1532,12 @@ pub const CAPI = struct {
|
||||
surface.refresh();
|
||||
}
|
||||
|
||||
/// Tell the surface that it needs to schedule a render
|
||||
/// call as soon as possible (NOW if possible).
|
||||
export fn ghostty_surface_draw(surface: *Surface) void {
|
||||
surface.draw();
|
||||
}
|
||||
|
||||
/// Update the size of a surface. This will trigger resize notifications
|
||||
/// to the pty and the renderer.
|
||||
export fn ghostty_surface_set_size(surface: *Surface, w: u32, h: u32) void {
|
||||
|
Reference in New Issue
Block a user