mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-06-25 02:17:03 +00:00
Fix cursor rendering during rendering pause
This commit is contained in:
parent
ab919f6fa1
commit
e50447c840
4 changed files with 22 additions and 15 deletions
|
|
@ -651,7 +651,9 @@ pyset_iutf8(ChildMonitor *self, PyObject *args) {
|
|||
|
||||
static bool
|
||||
cursor_needs_render(Window *w) {
|
||||
return w->cursor_visible_at_last_render != w->render_data.screen->cursor_render_info.is_visible || w->render_data.screen->last_rendered.cursor_x != w->render_data.screen->cursor_render_info.x || w->render_data.screen->last_rendered.cursor_y != w->render_data.screen->cursor_render_info.y || w->last_cursor_shape != w->render_data.screen->cursor_render_info.shape;
|
||||
#define cri w->render_data.screen->cursor_render_info
|
||||
return w->cursor_visible_at_last_render != cri.is_visible || w->render_data.screen->last_rendered.cursor_x != cri.x || w->render_data.screen->last_rendered.cursor_y != cri.y || w->last_cursor_shape != cri.shape;
|
||||
#undef cri
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
|
|||
|
|
@ -1324,7 +1324,7 @@ change_pointer_shape(Screen *self, PyObject *args) {
|
|||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
unsigned long
|
||||
static unsigned long
|
||||
screen_current_char_width(Screen *self) {
|
||||
unsigned long ans = 1;
|
||||
if (self->cursor->x < self->columns - 1 && self->cursor->y < self->lines) {
|
||||
|
|
@ -1335,7 +1335,7 @@ screen_current_char_width(Screen *self) {
|
|||
|
||||
bool
|
||||
screen_is_cursor_visible(const Screen *self) {
|
||||
return self->modes.mDECTCEM;
|
||||
return self->paused_rendering.expires_at ? self->paused_rendering.cursor_visible : self->modes.mDECTCEM;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -2393,9 +2393,10 @@ screen_pause_rendering(Screen *self, bool pause, int for_in_ms) {
|
|||
if (self->paused_rendering.expires_at) return false;
|
||||
if (for_in_ms <= 0) for_in_ms = 2000;
|
||||
self->paused_rendering.expires_at = monotonic() + ms_to_monotonic_t(for_in_ms);
|
||||
self->paused_rendering.inverted = self->modes.mDECSCNM ? true : false;
|
||||
self->paused_rendering.inverted = self->modes.mDECSCNM;
|
||||
self->paused_rendering.scrolled_by = self->scrolled_by;
|
||||
self->paused_rendering.cell_data_updated = false;
|
||||
self->paused_rendering.cursor_visible = self->modes.mDECTCEM;
|
||||
memcpy(&self->paused_rendering.cursor, self->cursor, sizeof(self->paused_rendering.cursor));
|
||||
memcpy(&self->paused_rendering.color_profile, self->color_profile, sizeof(self->paused_rendering.color_profile));
|
||||
if (!self->paused_rendering.linebuf || self->paused_rendering.linebuf->xnum != self->columns || self->paused_rendering.linebuf->ynum != self->lines) {
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ typedef struct {
|
|||
monotonic_t expires_at;
|
||||
Cursor cursor;
|
||||
ColorProfile color_profile;
|
||||
bool inverted, cell_data_updated;
|
||||
bool inverted, cell_data_updated, cursor_visible;
|
||||
unsigned int scrolled_by;
|
||||
LineBuf *linebuf;
|
||||
Selections selections, url_ranges;
|
||||
|
|
@ -245,7 +245,6 @@ void screen_update_selection(Screen *self, index_type x, index_type y, bool in_l
|
|||
bool screen_history_scroll(Screen *self, int amt, bool upwards);
|
||||
PyObject* as_text_history_buf(HistoryBuf *self, PyObject *args, ANSIBuf *output);
|
||||
Line* screen_visual_line(Screen *self, index_type y);
|
||||
unsigned long screen_current_char_width(Screen *self);
|
||||
void screen_mark_url(Screen *self, index_type start_x, index_type start_y, index_type end_x, index_type end_y);
|
||||
void set_active_hyperlink(Screen*, char*, char*);
|
||||
hyperlink_id_type screen_mark_hyperlink(Screen*, index_type, index_type);
|
||||
|
|
|
|||
|
|
@ -321,6 +321,7 @@ cell_update_uniform_block(ssize_t vao_idx, Screen *screen, int uniform_buffer, c
|
|||
rd->use_cell_for_selection_bg = IS_SPECIAL_COLOR(highlight_bg) ? 1. : 0.;
|
||||
// Cursor position
|
||||
enum { BLOCK_IDX = 0, BEAM_IDX = NUM_UNDERLINE_STYLES + 3, UNDERLINE_IDX = NUM_UNDERLINE_STYLES + 4, UNFOCUSED_IDX = NUM_UNDERLINE_STYLES + 5 };
|
||||
Line *line_for_cursor = NULL;
|
||||
if (cursor->is_visible) {
|
||||
rd->cursor_x = cursor->x, rd->cursor_y = cursor->y;
|
||||
if (cursor->is_focused) {
|
||||
|
|
@ -335,14 +336,19 @@ cell_update_uniform_block(ssize_t vao_idx, Screen *screen, int uniform_buffer, c
|
|||
} else rd->cursor_fg_sprite_idx = UNFOCUSED_IDX;
|
||||
color_type cell_fg = rd->default_fg, cell_bg = rd->default_bg;
|
||||
index_type cell_color_x = cursor->x;
|
||||
bool cursor_ok = cursor->x < screen->columns && cursor->y < screen->lines;
|
||||
bool reversed = false;
|
||||
if (cursor_ok) {
|
||||
linebuf_init_line(screen->linebuf, cursor->y);
|
||||
colors_for_cell(screen->linebuf->line, cp, &cell_color_x, &cell_fg, &cell_bg, &reversed);
|
||||
if (cursor->x < screen->columns && cursor->y < screen->lines) {
|
||||
if (screen->paused_rendering.expires_at) {
|
||||
linebuf_init_line(screen->paused_rendering.linebuf, cursor->y); line_for_cursor = screen->paused_rendering.linebuf->line;
|
||||
} else {
|
||||
linebuf_init_line(screen->linebuf, cursor->y); line_for_cursor = screen->linebuf->line;
|
||||
}
|
||||
}
|
||||
if (line_for_cursor) {
|
||||
colors_for_cell(line_for_cursor, cp, &cell_color_x, &cell_fg, &cell_bg, &reversed);
|
||||
}
|
||||
if (IS_SPECIAL_COLOR(cursor_color)) {
|
||||
if (cursor_ok) pick_cursor_color(screen->linebuf->line, cp, cell_fg, cell_bg, cell_color_x, &rd->cursor_fg, &rd->cursor_bg, rd->default_fg, rd->default_bg);
|
||||
if (line_for_cursor) pick_cursor_color(line_for_cursor, cp, cell_fg, cell_bg, cell_color_x, &rd->cursor_fg, &rd->cursor_bg, rd->default_fg, rd->default_bg);
|
||||
else { rd->cursor_fg = rd->default_bg; rd->cursor_bg = rd->default_fg; }
|
||||
if (cell_bg == cell_fg) {
|
||||
rd->cursor_fg = rd->default_bg; rd->cursor_bg = rd->default_fg;
|
||||
|
|
@ -354,10 +360,9 @@ cell_update_uniform_block(ssize_t vao_idx, Screen *screen, int uniform_buffer, c
|
|||
}
|
||||
} else rd->cursor_x = screen->columns, rd->cursor_y = screen->lines;
|
||||
rd->cursor_w = rd->cursor_x;
|
||||
if (
|
||||
(rd->cursor_fg_sprite_idx == BLOCK_IDX || rd->cursor_fg_sprite_idx == UNDERLINE_IDX) &&
|
||||
screen_current_char_width(screen) > 1
|
||||
) rd->cursor_w += 1;
|
||||
if ((rd->cursor_fg_sprite_idx == BLOCK_IDX || rd->cursor_fg_sprite_idx == UNDERLINE_IDX) && line_for_cursor && line_for_cursor->gpu_cells[cursor->x].attrs.width > 1) {
|
||||
rd->cursor_w += 1;
|
||||
}
|
||||
|
||||
rd->xnum = screen->columns; rd->ynum = screen->lines;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue