diff --git a/kitty/gl.c b/kitty/gl.c index be7919603..1032d623e 100644 --- a/kitty/gl.c +++ b/kitty/gl.c @@ -186,6 +186,16 @@ restore_viewport(void) { glViewport(saved_viewport[0], saved_viewport[1], saved_viewport[2], saved_viewport[3]); } +void +enable_scissor_using_top_left_origin(Viewport vp, unsigned full_framebuffer_height) { + glEnable(GL_SCISSOR_TEST); + GLsizei newy = full_framebuffer_height - (vp.top + vp.height); + glScissor(vp.left, newy, vp.width, vp.height); +} + +void +disable_scissor(void) { glDisable(GL_SCISSOR_TEST); } + static float linear_to_srgb(float c) { return (c <= 0.0031308f) ? 12.92f * c : 1.055f * powf(c, 1.0f / 2.4f) - 0.055f; } diff --git a/kitty/gl.h b/kitty/gl.h index 6202f6255..3ae2f1453 100644 --- a/kitty/gl.h +++ b/kitty/gl.h @@ -67,3 +67,5 @@ void check_framebuffer_status_or_die(void); void restore_viewport(void); void bind_framebuffer_for_output(unsigned fbid); void set_framebuffer_to_use_for_output(unsigned fbid); +void enable_scissor_using_top_left_origin(Viewport, unsigned); +void disable_scissor(void); diff --git a/kitty/shaders.c b/kitty/shaders.c index 9c4dbdd3f..7c16e9d18 100644 --- a/kitty/shaders.c +++ b/kitty/shaders.c @@ -803,11 +803,17 @@ render_a_bar(const UIRenderData *ui, WindowBarData *bar, PyObject *title, bool a .height=bar_height + 2 * border_width, .left=ui->screen_left, .width=ui->screen_width, .top=ui->screen_top}; if (along_bottom) border_rect.top += ui->screen_height - border_rect.height; const unsigned sh = ui->full_framebuffer_height; + // first blank the area to be drawn to background + enable_scissor_using_top_left_origin(border_rect, sh); + blank_canvas(1.f, bg); + disable_scissor(); + // then draw the rendered text save_viewport_using_top_left_origin( border_rect.left + border_width, border_rect.top + border_width, bar_width, bar_height, sh); draw_graphics(GRAPHICS_PROGRAM, &data, 0, 1, 1.f); restore_viewport(); free_texture(&data.texture_id); + // finally draw border with transparent bg draw_rounded_rect(ui->os_window, border_rect, sh, 1, ui->cell_width, fg, bg, 0.f); return border_rect.height; }