diff --git a/kitty/screen.c b/kitty/screen.c index 20f00d86c..f612720f9 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -2425,16 +2425,6 @@ dirty_scroll(Screen *self) { screen_pause_rendering(self, false, 0); } -static inline bool -pixel_scroll_enabled(const Screen *self) { - return OPT(pixel_scroll) && self->linebuf == self->main_linebuf && !self->paused_rendering.expires_at; -} - -static inline unsigned int -render_lines_for_screen(const Screen *self) { - return self->lines + (pixel_scroll_enabled(self) ? 2u : 0u); -} - static inline int render_row_offset_for_screen(const Screen *self) { return pixel_scroll_enabled(self) ? 1 : 0; diff --git a/kitty/screen.h b/kitty/screen.h index f0f85b4c7..101e9d753 100644 --- a/kitty/screen.h +++ b/kitty/screen.h @@ -194,6 +194,8 @@ typedef struct { ExtraCursors extra_cursors; } Screen; +#define pixel_scroll_enabled(screen) (global_state.opts.pixel_scroll && !screen->paused_rendering.expires_at && screen->linebuf == screen->main_linebuf) +#define render_lines_for_screen(screen) (screen->lines + (pixel_scroll_enabled(screen) ? 1u : 0u)) void screen_align(Screen*); void screen_restore_cursor(Screen *); diff --git a/kitty/shaders.c b/kitty/shaders.c index 87dd9c6dc..f5ccd64fd 100644 --- a/kitty/shaders.c +++ b/kitty/shaders.c @@ -40,25 +40,15 @@ typedef struct UIRenderData { color_type background_color; // RGB only } UIRenderData; -static inline bool -pixel_scroll_enabled_for_render(const Screen *screen) { - return OPT(pixel_scroll) && !screen->paused_rendering.expires_at && screen->linebuf == screen->main_linebuf; -} - -static inline unsigned int -render_lines_for_screen(const Screen *screen) { - return screen->lines + (pixel_scroll_enabled_for_render(screen) ? 1u : 0u); -} - static inline float row_offset_for_screen(const Screen *screen) { - if (!pixel_scroll_enabled_for_render(screen) || !screen->cell_size.height) return 0.f; + if (!pixel_scroll_enabled(screen) || !screen->cell_size.height) return 0.f; return -1.f + (float)(screen->pixel_scroll_offset_y / (double)screen->cell_size.height); } static inline float scroll_offset_lines_for_screen(const Screen *screen) { - if (!pixel_scroll_enabled_for_render(screen) || !screen->cell_size.height) return 0.f; + if (!pixel_scroll_enabled(screen) || !screen->cell_size.height) return 0.f; return (float)(screen->pixel_scroll_offset_y / (double)screen->cell_size.height); } @@ -508,7 +498,7 @@ cell_update_uniform_block(ssize_t vao_idx, Screen *screen, int uniform_buffer, c if (rd->cursor_opacity != 0 && cursor->is_visible) { rd->cursor_x1 = cursor->x, rd->cursor_y1 = cursor->y; rd->cursor_x2 = cursor->x, rd->cursor_y2 = cursor->y; - if (pixel_scroll_enabled_for_render(screen)) { + if (pixel_scroll_enabled(screen)) { rd->cursor_y1 += 1; rd->cursor_y2 += 1; }