feat: avoid sigwinch handling if we detect in band resize capability
This commit is contained in:
parent
3816ec2327
commit
9b00805546
2 changed files with 17 additions and 15 deletions
|
@ -103,8 +103,11 @@ pub fn run(self: *Self) !void {
|
||||||
|
|
||||||
panic_cleanup = .{ .a = self.a, .tty = &self.tty, .vx = &self.vx };
|
panic_cleanup = .{ .a = self.a, .tty = &self.tty, .vx = &self.vx };
|
||||||
if (!self.no_alternate) try self.vx.enterAltScreen(self.tty.anyWriter());
|
if (!self.no_alternate) try self.vx.enterAltScreen(self.tty.anyWriter());
|
||||||
|
if (builtin.os.tag == .windows) {
|
||||||
try self.resize(.{ .rows = 25, .cols = 80, .x_pixel = 0, .y_pixel = 0 }); // dummy resize to fully init vaxis
|
try self.resize(.{ .rows = 25, .cols = 80, .x_pixel = 0, .y_pixel = 0 }); // dummy resize to fully init vaxis
|
||||||
try self.query_resize();
|
} else {
|
||||||
|
try self.sigwinch();
|
||||||
|
}
|
||||||
try self.vx.setBracketedPaste(self.tty.anyWriter(), true);
|
try self.vx.setBracketedPaste(self.tty.anyWriter(), true);
|
||||||
try self.vx.queryTerminalSend(self.tty.anyWriter());
|
try self.vx.queryTerminalSend(self.tty.anyWriter());
|
||||||
|
|
||||||
|
@ -118,8 +121,8 @@ pub fn render(self: *Self) !void {
|
||||||
try bufferedWriter.flush();
|
try bufferedWriter.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn query_resize(self: *Self) !void {
|
pub fn sigwinch(self: *Self) !void {
|
||||||
if (builtin.os.tag != .windows)
|
if (builtin.os.tag == .windows or self.vx.state.in_band_resize) return;
|
||||||
try self.resize(try vaxis.Tty.getWinsize(self.input_fd_blocking()));
|
try self.resize(try vaxis.Tty.getWinsize(self.input_fd_blocking()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,7 +247,13 @@ pub fn process_input_event(self: *Self, input_: []const u8, text: ?[]const u8) !
|
||||||
},
|
},
|
||||||
.color_report => {},
|
.color_report => {},
|
||||||
.color_scheme => {},
|
.color_scheme => {},
|
||||||
.winsize => |ws| try self.resize(ws),
|
.winsize => |ws| {
|
||||||
|
if (!self.vx.state.in_band_resize) {
|
||||||
|
self.vx.state.in_band_resize = true;
|
||||||
|
self.logger.print("in band resize capability detected", .{});
|
||||||
|
}
|
||||||
|
try self.resize(ws);
|
||||||
|
},
|
||||||
|
|
||||||
.cap_unicode => {
|
.cap_unicode => {
|
||||||
self.logger.print("unicode capability detected", .{});
|
self.logger.print("unicode capability detected", .{});
|
||||||
|
@ -463,11 +472,6 @@ const Loop = struct {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
else => {
|
else => {
|
||||||
const winsize = try vaxis.Tty.getWinsize(self.tty.fd);
|
|
||||||
if (@hasField(Event, "winsize")) {
|
|
||||||
self.postEvent(.{ .winsize = winsize });
|
|
||||||
}
|
|
||||||
|
|
||||||
var parser: vaxis.Parser = .{
|
var parser: vaxis.Parser = .{
|
||||||
.grapheme_data = &self.vaxis.unicode.grapheme_data,
|
.grapheme_data = &self.vaxis.unicode.grapheme_data,
|
||||||
};
|
};
|
||||||
|
@ -497,8 +501,6 @@ const Loop = struct {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (result.event) |event| {
|
if (result.event) |event| {
|
||||||
if (event == .winsize)
|
|
||||||
self.vaxis.state.in_band_resize = true;
|
|
||||||
self.postEvent(event);
|
self.postEvent(event);
|
||||||
}
|
}
|
||||||
if (result.n < n) {
|
if (result.n < n) {
|
||||||
|
|
|
@ -54,7 +54,7 @@ final_exit: []const u8 = "normal",
|
||||||
render_pending: bool = false,
|
render_pending: bool = false,
|
||||||
keepalive_timer: ?tp.Cancellable = null,
|
keepalive_timer: ?tp.Cancellable = null,
|
||||||
|
|
||||||
const keepalive = std.time.us_per_s * 60 * 60 * 24 * 356; // one year
|
const keepalive = std.time.us_per_day * 365; // one year
|
||||||
const idle_frames = 0;
|
const idle_frames = 0;
|
||||||
|
|
||||||
const init_delay = 1; // ms
|
const init_delay = 1; // ms
|
||||||
|
@ -233,7 +233,7 @@ fn receive_safe(self: *Self, from: tp.pid_ref, m: tp.message) !void {
|
||||||
if (builtin.os.tag != .windows)
|
if (builtin.os.tag != .windows)
|
||||||
if (try m.match(.{"sigwinch"})) {
|
if (try m.match(.{"sigwinch"})) {
|
||||||
try self.listen_sigwinch();
|
try self.listen_sigwinch();
|
||||||
self.rdr.query_resize() catch |e| return self.logger.err("query_resize", e);
|
self.rdr.sigwinch() catch |e| return self.logger.err("query_resize", e);
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue