Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/ghostty.h
Original file line number Diff line number Diff line change
Expand Up @@ -1637,6 +1637,9 @@ GHOSTTY_API void ghostty_surface_set_pty_tee_cb(ghostty_surface_t,
void* userdata);

GHOSTTY_API bool ghostty_surface_mouse_captured(ghostty_surface_t);
// cmux fork: true when the terminal's active screen is the alternate screen.
// Takes the renderer state mutex, same as ghostty_surface_mouse_captured.
GHOSTTY_API bool ghostty_surface_is_alternate_screen(ghostty_surface_t);
GHOSTTY_API bool ghostty_surface_mouse_button(ghostty_surface_t,
ghostty_input_mouse_state_e,
ghostty_input_mouse_button_e,
Expand Down
8 changes: 8 additions & 0 deletions src/Surface.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5650,6 +5650,14 @@ pub fn mouseCaptured(self: *Surface) bool {
return self.io.terminal.flags.mouse_event != .none;
}

/// Returns true if the terminal's active screen is the alternate screen
/// (e.g. a full-screen TUI such as vim, less, or htop is running).
pub fn isAlternateScreen(self: *Surface) bool {
self.renderer_state.mutex.lockUncancelable(global.io());
defer self.renderer_state.mutex.unlock(global.io());
return self.io.terminal.screens.active_key == .alternate;
}

/// Called for mouse button press/release events. This will return true
/// if the mouse event was consumed in some way (i.e. the program is capturing
/// mouse events). If the event was not consumed, then false is returned.
Expand Down
6 changes: 6 additions & 0 deletions src/apprt/embedded.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5014,6 +5014,12 @@ pub const CAPI = struct {
return surface.core_surface.mouseCaptured();
}

/// Returns true if the terminal's active screen is the alternate
/// screen (cmux-specific).
export fn ghostty_surface_is_alternate_screen(surface: *Surface) bool {
return surface.core_surface.isAlternateScreen();
}

/// Tell the surface that it needs to schedule a render
export fn ghostty_surface_mouse_button(
surface: *Surface,
Expand Down
Loading