diff --git a/kitty/child-monitor.c b/kitty/child-monitor.c index 99d0add49..7bd869c2a 100644 --- a/kitty/child-monitor.c +++ b/kitty/child-monitor.c @@ -601,6 +601,7 @@ render(double now) { if (!w->num_tabs || !should_os_window_be_rendered(w)) continue; make_os_window_context_current(w); if (w->viewport_size_dirty) { + w->clear_count = 0; update_surface_size(w->viewport_width, w->viewport_height, w->offscreen_texture_id); w->viewport_size_dirty = false; } diff --git a/kitty/gl.h b/kitty/gl.h index 1ba0821bb..b3943d260 100644 --- a/kitty/gl.h +++ b/kitty/gl.h @@ -64,6 +64,7 @@ gl_init() { void update_surface_size(int w, int h, GLuint offscreen_texture_id) { + glViewport(0, 0, w, h); if (offscreen_texture_id) { glBindTexture(GL_TEXTURE_2D, offscreen_texture_id); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); diff --git a/kitty/shaders.c b/kitty/shaders.c index 0915eb5f9..ba37b4b44 100644 --- a/kitty/shaders.c +++ b/kitty/shaders.c @@ -365,6 +365,14 @@ draw_cells_interleaved(ssize_t vao_idx, ssize_t gvao_idx, Screen *screen, OSWind void draw_cells(ssize_t vao_idx, ssize_t gvao_idx, GLfloat xstart, GLfloat ystart, GLfloat dx, GLfloat dy, Screen *screen, OSWindow *os_window) { + if (os_window->clear_count < 2) { + os_window->clear_count++; +#define C(shift) (((GLfloat)((OPT(background) >> shift) & 0xFF)) / 255.0f) + glClearColor(C(16), C(8), C(0), os_window->is_semi_transparent ? OPT(background_opacity) : 1.0f); +#undef C + glClear(GL_COLOR_BUFFER_BIT); + } + cell_prepare_to_render(vao_idx, gvao_idx, screen, xstart, ystart, dx, dy); GLfloat w = (GLfloat)screen->columns * dx, h = (GLfloat)screen->lines * dy; #define SCALE(w, x) ((GLfloat)(os_window->viewport_##w) * (GLfloat)(x)) diff --git a/kitty/state.h b/kitty/state.h index 7b7d51266..0c9df0a8f 100644 --- a/kitty/state.h +++ b/kitty/state.h @@ -104,6 +104,7 @@ typedef struct { bool has_pending_resizes; bool is_semi_transparent; uint32_t offscreen_texture_id; + unsigned int clear_count; } OSWindow;