mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
apprt: add C API for detecting background transparency per surface
This commit is contained in:
@ -276,6 +276,7 @@ void *ghostty_app_userdata(ghostty_app_t);
|
||||
ghostty_surface_t ghostty_surface_new(ghostty_app_t, ghostty_surface_config_s*);
|
||||
void ghostty_surface_free(ghostty_surface_t);
|
||||
ghostty_app_t ghostty_surface_app(ghostty_surface_t);
|
||||
bool ghostty_surface_transparent(ghostty_surface_t);
|
||||
void ghostty_surface_refresh(ghostty_surface_t);
|
||||
void ghostty_surface_set_content_scale(ghostty_surface_t, double, double);
|
||||
void ghostty_surface_set_focus(ghostty_surface_t, bool);
|
||||
|
@ -197,6 +197,15 @@ extension Ghostty {
|
||||
ghostty_surface_set_size(surface, UInt32(scaledSize.width), UInt32(scaledSize.height))
|
||||
}
|
||||
|
||||
override func viewDidMoveToWindow() {
|
||||
guard let window = self.window else { return }
|
||||
guard let surface = self.surface else { return }
|
||||
guard ghostty_surface_transparent(surface) else { return }
|
||||
window.isOpaque = false
|
||||
window.hasShadow = false
|
||||
window.backgroundColor = .clear
|
||||
}
|
||||
|
||||
override func resignFirstResponder() -> Bool {
|
||||
let result = super.resignFirstResponder()
|
||||
|
||||
|
@ -470,6 +470,11 @@ pub const CAPI = struct {
|
||||
return surface.app;
|
||||
}
|
||||
|
||||
/// Returns ture if the surface has transparency set.
|
||||
export fn ghostty_surface_transparent(surface: *Surface) bool {
|
||||
return surface.app.config.@"background-opacity" < 1.0;
|
||||
}
|
||||
|
||||
/// Tell the surface that it needs to schedule a render
|
||||
export fn ghostty_surface_refresh(surface: *Surface) void {
|
||||
surface.refresh();
|
||||
|
Reference in New Issue
Block a user