Do not store Screen pointer on CursorTrail
The lifetime of the Screen pointer is managed by Window. Also we want the cursor trail color to be the color of the active window cursor not the color of the cursor in the last rendered window.
This commit is contained in:
parent
65f0571b2c
commit
5e7e512d8a
4 changed files with 9 additions and 10 deletions
|
|
@ -802,17 +802,19 @@ render_prepared_os_window(OSWindow *os_window, unsigned int active_window_id, co
|
|||
br->is_dirty = false;
|
||||
if (TD.screen && os_window->num_tabs >= OPT(tab_bar_min_tabs)) draw_cells(TD.vao_idx, &TD, os_window, true, true, false, NULL);
|
||||
unsigned int num_of_visible_windows = 0;
|
||||
Window *active_window = NULL;
|
||||
for (unsigned int i = 0; i < tab->num_windows; i++) { if (tab->windows[i].visible) num_of_visible_windows++; }
|
||||
for (unsigned int i = 0; i < tab->num_windows; i++) {
|
||||
Window *w = tab->windows + i;
|
||||
if (w->visible && WD.screen) {
|
||||
bool is_active_window = i == tab->active_window;
|
||||
if (is_active_window) active_window = w;
|
||||
draw_cells(WD.vao_idx, &WD, os_window, is_active_window, false, num_of_visible_windows == 1, w);
|
||||
if (WD.screen->start_visual_bell_at != 0) set_maximum_wait(ANIMATION_SAMPLE_WAIT);
|
||||
w->cursor_opacity_at_last_render = WD.screen->cursor_render_info.opacity; w->last_cursor_shape = WD.screen->cursor_render_info.shape;
|
||||
}
|
||||
}
|
||||
if (OPT(cursor_trail) && tab->cursor_trail.needs_render) draw_cursor_trail(&tab->cursor_trail);
|
||||
if (OPT(cursor_trail) && tab->cursor_trail.needs_render) draw_cursor_trail(&tab->cursor_trail, active_window);
|
||||
if (os_window->live_resize.in_progress) draw_resizing_text(os_window);
|
||||
swap_window_buffers(os_window);
|
||||
os_window->last_active_tab = os_window->active_tab; os_window->last_num_tabs = os_window->num_tabs; os_window->last_active_window_id = active_window_id;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include <float.h>
|
||||
#include "state.h"
|
||||
#include "float.h"
|
||||
|
||||
inline static float
|
||||
norm(float x, float y) {
|
||||
|
|
@ -43,7 +43,6 @@ update_cursor_trail_target(CursorTrail *ct, Window *w) {
|
|||
EDGE(x, 1) = right;
|
||||
EDGE(y, 0) = top;
|
||||
EDGE(y, 1) = bottom;
|
||||
ct->screen = WD.screen;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -368,6 +368,8 @@ cell_update_uniform_block(ssize_t vao_idx, Screen *screen, int uniform_buffer, c
|
|||
if (IS_SPECIAL_COLOR(cursor_text_color)) rd->cursor_fg = cell_bg;
|
||||
else rd->cursor_fg = COLOR(cursor_text_color);
|
||||
}
|
||||
// store last rendered cursor color for trail rendering
|
||||
screen->last_rendered.cursor_bg = rd->cursor_bg;
|
||||
} 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) && line_for_cursor && line_for_cursor->gpu_cells[cursor->x].attrs.width > 1) {
|
||||
|
|
@ -385,9 +387,6 @@ cell_update_uniform_block(ssize_t vao_idx, Screen *screen, int uniform_buffer, c
|
|||
#undef COLOR
|
||||
rd->url_color = OPT(url_color); rd->url_style = OPT(url_style);
|
||||
|
||||
// store last rendered cursor color for trail rendering
|
||||
screen->last_rendered.cursor_bg = rd->cursor_bg;
|
||||
|
||||
unmap_vao_buffer(vao_idx, uniform_buffer); rd = NULL;
|
||||
}
|
||||
|
||||
|
|
@ -1148,7 +1147,7 @@ init_trail_program(void) {
|
|||
}
|
||||
|
||||
void
|
||||
draw_cursor_trail(CursorTrail *trail) {
|
||||
draw_cursor_trail(CursorTrail *trail, Window *active_window) {
|
||||
bind_program(TRAIL_PROGRAM);
|
||||
|
||||
glUniform4fv(trail_program_layout.uniforms.x_coords, 1, trail->corner_x);
|
||||
|
|
@ -1157,7 +1156,7 @@ draw_cursor_trail(CursorTrail *trail) {
|
|||
glUniform2fv(trail_program_layout.uniforms.cursor_edge_x, 1, trail->cursor_edge_x);
|
||||
glUniform2fv(trail_program_layout.uniforms.cursor_edge_y, 1, trail->cursor_edge_y);
|
||||
|
||||
color_vec3(trail_program_layout.uniforms.trail_color, trail->screen->last_rendered.cursor_bg);
|
||||
color_vec3(trail_program_layout.uniforms.trail_color, active_window ? active_window->render_data.screen->last_rendered.cursor_bg : OPT(foreground));
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
|
|
|
|||
|
|
@ -218,7 +218,6 @@ typedef struct {
|
|||
typedef struct {
|
||||
bool needs_render;
|
||||
monotonic_t updated_at;
|
||||
Screen* screen;
|
||||
float corner_x[4];
|
||||
float corner_y[4];
|
||||
float cursor_edge_x[2];
|
||||
|
|
@ -366,7 +365,7 @@ ssize_t create_border_vao(void);
|
|||
bool send_cell_data_to_gpu(ssize_t, float, float, float, float, Screen *, OSWindow *);
|
||||
void draw_cells(ssize_t, const WindowRenderData*, OSWindow *, bool, bool, bool, Window*);
|
||||
void draw_centered_alpha_mask(OSWindow *w, size_t screen_width, size_t screen_height, size_t width, size_t height, uint8_t *canvas, float);
|
||||
void draw_cursor_trail(CursorTrail *trail);
|
||||
void draw_cursor_trail(CursorTrail *trail, Window *active_window);
|
||||
bool update_cursor_trail(CursorTrail *ct, Window *w, monotonic_t now, OSWindow *os_window);
|
||||
void update_surface_size(int, int, uint32_t);
|
||||
void free_texture(uint32_t*);
|
||||
|
|
|
|||
Loading…
Reference in a new issue