diff --git a/docs/changelog.rst b/docs/changelog.rst index 5d193fe3d..94b8c01ff 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -13,6 +13,9 @@ To update |kitty|, :doc:`follow the instructions `. - Add support for specifying a background image, see :opt:`background_image` (:iss:`163` and :pull:`2326`) +- A new :opt:`background_tint` option to darken the background under the text + area when using background images and/or transparent windows. + 0.16.0 [2020-01-28] diff --git a/kitty/config_data.py b/kitty/config_data.py index 6960cf30b..bf49e3ec8 100644 --- a/kitty/config_data.py +++ b/kitty/config_data.py @@ -864,12 +864,6 @@ Path to a background image. Must be in PNG format.''')) o('background_image_layout', 'tiled', option_type=choices('tiled', 'scaled', 'mirror-tiled'), long_text=_(''' Whether to tile or scale the background image.''')) -o('background_image_tint', 0.5, option_type=unit_float, long_text=_(''' -How much to tint the background image by the background area. The tint is applied -only under the text area, not margin/borders. Makes it easier to read the text. -Tinting is done using the current background color for each window. -''')) - o('background_image_linear', False, long_text=_(''' When background image is scaled, whether linear interpolation should be used.''')) @@ -879,6 +873,14 @@ shortcuts (:sc:`increase_background_opacity` and :sc:`decrease_background_opacit or the remote control facility. ''')) +o('background_tint', 0.0, option_type=unit_float, long_text=_(''' +How much to tint the background image by the background color. The tint is applied +only under the text area, not margin/borders. Makes it easier to read the text. +Tinting is done using the current background color for each window. This setting +applies only if :opt:`background_opacity` is set and transparent windows are supported +or :opt:`background_image` is set. +''')) + o('dim_opacity', 0.75, option_type=unit_float, long_text=_(''' How much to dim text that has the DIM/FAINT attribute set. One means no dimming and zero means fully dimmed (i.e. invisible).''')) diff --git a/kitty/shaders.c b/kitty/shaders.c index 92bba9cfe..18b7cc023 100644 --- a/kitty/shaders.c +++ b/kitty/shaders.c @@ -446,7 +446,7 @@ draw_tint(bool premult, Screen *screen, GLfloat xstart, GLfloat ystart, GLfloat bind_program(TINT_PROGRAM); color_type window_bg = colorprofile_to_color(screen->color_profile, screen->color_profile->overridden.default_bg, screen->color_profile->configured.default_bg); #define C(shift) ((((GLfloat)((window_bg >> shift) & 0xFF)) / 255.0f)) - float alpha = OPT(background_image_tint); + float alpha = OPT(background_tint); if (premult) glUniform4f(tint_program_layout.tint_color_location, C(16) * alpha, C(8) * alpha, C(0) * alpha, alpha); else glUniform4f(tint_program_layout.tint_color_location, C(16), C(8), C(0), alpha); #undef C @@ -464,7 +464,7 @@ draw_cells_interleaved(ssize_t vao_idx, ssize_t gvao_idx, Screen *screen, OSWind bind_program(CELL_BG_PROGRAM); glUniform1ui(cell_program_layouts[CELL_BG_PROGRAM].draw_bg_bitfield_location, 3); glDrawArraysInstanced(GL_TRIANGLE_FAN, 0, 4, screen->lines * screen->columns); - } else if (OPT(background_image_tint) > 0) draw_tint(false, screen, xstart, ystart, width, height); + } else if (OPT(background_tint) > 0) draw_tint(false, screen, xstart, ystart, width, height); if (screen->grman->num_of_below_refs || has_bgimage(w)) { if (screen->grman->num_of_below_refs) draw_graphics( @@ -490,7 +490,7 @@ draw_cells_interleaved(ssize_t vao_idx, ssize_t gvao_idx, Screen *screen, OSWind static void draw_cells_interleaved_premult(ssize_t vao_idx, ssize_t gvao_idx, Screen *screen, OSWindow *os_window, GLfloat xstart, GLfloat ystart, GLfloat width, GLfloat height) { - if (has_bgimage(os_window) && OPT(background_image_tint) > 0.f) { + if (OPT(background_tint) > 0.f) { glEnable(GL_BLEND); BLEND_PREMULT; draw_tint(true, screen, xstart, ystart, width, height); diff --git a/kitty/state.c b/kitty/state.c index a30cfc010..23015ef41 100644 --- a/kitty/state.c +++ b/kitty/state.c @@ -560,7 +560,7 @@ PYWRAP1(set_options) { S(cursor_stop_blinking_after, parse_s_double_to_monotonic_t); S(background_opacity, PyFloat_AsFloat); S(background_image_layout, bglayout); - S(background_image_tint, PyFloat_AsFloat); + S(background_tint, PyFloat_AsFloat); S(background_image_linear, PyObject_IsTrue); S(dim_opacity, PyFloat_AsFloat); S(dynamic_background_opacity, PyObject_IsTrue); diff --git a/kitty/state.h b/kitty/state.h index d3394e1bf..4427d506b 100644 --- a/kitty/state.h +++ b/kitty/state.h @@ -42,7 +42,7 @@ typedef struct { char* background_image; BackgroundImageLayout background_image_layout; bool background_image_linear; - float background_image_tint; + float background_tint; bool dynamic_background_opacity; float inactive_text_alpha;