mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 08:16:13 +03:00
Merge pull request #118 from mitchellh/focus
terminal: implement focus event mode 1004
This commit is contained in:
@ -1152,6 +1152,22 @@ pub fn focusCallback(self: *Surface, focused: bool) !void {
|
||||
|
||||
// Schedule render which also drains our mailbox
|
||||
try self.queueRender();
|
||||
|
||||
// Notify the app about focus in/out if it is requesting it
|
||||
{
|
||||
self.renderer_state.mutex.lock();
|
||||
const focus_event = self.io.terminal.modes.focus_event;
|
||||
self.renderer_state.mutex.unlock();
|
||||
|
||||
if (focus_event) {
|
||||
const seq = if (focused) "\x1b[I" else "\x1b[O";
|
||||
_ = self.io_thread.mailbox.push(.{
|
||||
.write_stable = seq,
|
||||
}, .{ .forever = {} });
|
||||
|
||||
try self.io_thread.wakeup.notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn refreshCallback(self: *Surface) !void {
|
||||
|
@ -80,6 +80,7 @@ modes: packed struct {
|
||||
deccolm: bool = false, // 3,
|
||||
deccolm_supported: bool = false, // 40
|
||||
|
||||
focus_event: bool = false, // 1004
|
||||
mouse_alternate_scroll: bool = true, // 1007
|
||||
mouse_event: MouseEvents = .none,
|
||||
mouse_format: MouseFormat = .x10,
|
||||
|
@ -95,6 +95,9 @@ pub const Mode = enum(u16) {
|
||||
/// to track mouse movement.
|
||||
mouse_event_any = 1003,
|
||||
|
||||
/// Send focus in/out events.
|
||||
focus_event = 1004,
|
||||
|
||||
/// Report mouse position in the utf8 format to support larger screens.
|
||||
mouse_format_utf8 = 1005,
|
||||
|
||||
|
@ -1061,6 +1061,8 @@ const StreamHandler = struct {
|
||||
|
||||
.mouse_alternate_scroll => self.terminal.modes.mouse_alternate_scroll = enabled,
|
||||
|
||||
.focus_event => self.terminal.modes.focus_event = enabled,
|
||||
|
||||
else => if (enabled) log.warn("unimplemented mode: {}", .{mode}),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user