mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-18 13:30:29 +00:00
core: add 64 bit unique ID to every core surface
- Expose that ID as the environment variable GHOSTTY_SURFACE_ID to processes running in Ghostty surfaces. - Add a function to the core app to search for surfaces by ID. - ID is randomly generated, it has no other meaning other than as a unique identifier for the surface. The ID also cannot be zero as that is used to indicate a null ID in some situations.
This commit is contained in:
10
src/App.zig
10
src/App.zig
@@ -524,6 +524,16 @@ fn hasSurface(self: *const App, surface: *const Surface) bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Search for a surface by a 64 bit unique ID.
|
||||
pub fn findSurfaceByID(self: *const App, id: u64) ?*Surface {
|
||||
for (self.surfaces.items) |v| {
|
||||
const surface: *Surface = v.core();
|
||||
if (surface.id == id) return surface;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
fn hasRtSurface(self: *const App, surface: *apprt.Surface) bool {
|
||||
for (self.surfaces.items) |v| {
|
||||
if (v == surface) return true;
|
||||
|
||||
Reference in New Issue
Block a user