Fix background_tint not applying to window margins and padding
Fixes #3933
This commit is contained in:
parent
1402c5bbfa
commit
cf22729dfa
@ -46,6 +46,8 @@ Detailed list of changes
|
||||
|
||||
- Tab bar: Improve empty space management when some tabs have short titles, allocate the saved space to the active tab (:iss:`5548`)
|
||||
|
||||
- Fix :opt:`background_tint` not applying to window margins and padding (:iss:`3933`)
|
||||
|
||||
|
||||
0.26.3 [2022-09-22]
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
#version GLSL_VERSION
|
||||
uniform float background_opacity;
|
||||
in vec3 color;
|
||||
in vec4 color;
|
||||
out vec4 final_color;
|
||||
|
||||
void main() {
|
||||
final_color = vec4(color * background_opacity, background_opacity);
|
||||
final_color = color;
|
||||
}
|
||||
|
||||
@ -6,9 +6,11 @@ uniform vec3 inactive_border_color;
|
||||
uniform vec3 bell_border_color;
|
||||
uniform vec3 tab_bar_bg;
|
||||
uniform vec3 tab_bar_margin_color;
|
||||
uniform float background_opacity;
|
||||
uniform float tint_opacity, tint_premult;
|
||||
in vec4 rect; // left, top, right, bottom
|
||||
in uint rect_color;
|
||||
out vec3 color;
|
||||
out vec4 color;
|
||||
|
||||
// indices into the rect vector
|
||||
const int LEFT = 0;
|
||||
@ -35,5 +37,9 @@ void main() {
|
||||
gl_Position = vec4(rect[pos.x], rect[pos.y], 0, 1);
|
||||
int rc = int(rect_color);
|
||||
vec3 window_bg = vec3(to_color(rect_color >> 24), to_color(rect_color >> 16), to_color(rect_color >> 8));
|
||||
color = W(0, default_bg) + W(1, active_border_color) + W(2, inactive_border_color) + W(3, window_bg) + W(4, bell_border_color) + W(5, tab_bar_bg) + W(6, tab_bar_margin_color);
|
||||
vec3 color3 = W(0, default_bg) + W(1, active_border_color) + W(2, inactive_border_color) + W(3, window_bg) + W(4, bell_border_color) + W(5, tab_bar_bg) + W(6, tab_bar_margin_color);
|
||||
float is_default_bg = float(rc & 1);
|
||||
float final_opacity = is_default_bg * tint_opacity + (1 - is_default_bg) * background_opacity;
|
||||
float final_premult_opacity = is_default_bg * tint_premult + (1 - is_default_bg) * background_opacity;
|
||||
color = vec4(color3 * final_premult_opacity, final_opacity);
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ class Borders:
|
||||
draw_minimal_borders = opts.draw_minimal_borders and max(opts.window_margin_width) < 1
|
||||
add_borders_rect(self.os_window_id, self.tab_id, 0, 0, 0, 0, BorderColor.default_bg)
|
||||
has_background_image = os_window_has_background_image(self.os_window_id)
|
||||
if not has_background_image:
|
||||
if not has_background_image or opts.background_tint > 0.0:
|
||||
for br in current_layout.blank_rects:
|
||||
add_borders_rect(self.os_window_id, self.tab_id, *br, BorderColor.default_bg)
|
||||
for tbr in tab_bar_rects:
|
||||
|
||||
@ -1310,11 +1310,10 @@ this option by reloading the config is not supported.
|
||||
opt('background_tint', '0.0',
|
||||
option_type='unit_float', ctype='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. This option makes it
|
||||
easier to read the text. Tinting is done using the current background color for
|
||||
each window. This option applies only if :opt:`background_opacity` is set and
|
||||
transparent windows are supported or :opt:`background_image` is set.
|
||||
How much to tint the background image by the background color. This option
|
||||
makes it easier to read the text. Tinting is done using the current background
|
||||
color for each window. This option applies only if :opt:`background_opacity` is
|
||||
set and transparent windows are supported or :opt:`background_image` is set.
|
||||
'''
|
||||
)
|
||||
|
||||
|
||||
@ -707,7 +707,7 @@ draw_cells_interleaved(ssize_t vao_idx, ssize_t gvao_idx, Screen *screen, OSWind
|
||||
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_tint) > 0) {
|
||||
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE);
|
||||
BLEND_ONTO_OPAQUE;
|
||||
draw_tint(false, screen, crd);
|
||||
BLEND_ONTO_OPAQUE;
|
||||
}
|
||||
@ -924,7 +924,7 @@ draw_cells(ssize_t vao_idx, ssize_t gvao_idx, const ScreenRenderData *srd, float
|
||||
// }}}
|
||||
|
||||
// Borders {{{
|
||||
enum BorderUniforms { BORDER_viewport, BORDER_background_opacity, BORDER_default_bg, BORDER_active_border_color, BORDER_inactive_border_color, BORDER_bell_border_color, BORDER_tab_bar_bg, BORDER_tab_bar_margin_color, NUM_BORDER_UNIFORMS };
|
||||
enum BorderUniforms { BORDER_viewport, BORDER_background_opacity, BORDER_tint_opacity, BORDER_tint_premult, BORDER_default_bg, BORDER_active_border_color, BORDER_inactive_border_color, BORDER_bell_border_color, BORDER_tab_bar_bg, BORDER_tab_bar_margin_color, NUM_BORDER_UNIFORMS };
|
||||
static GLint border_uniform_locations[NUM_BORDER_UNIFORMS] = {0};
|
||||
|
||||
static void
|
||||
@ -932,6 +932,8 @@ init_borders_program(void) {
|
||||
#define SET_LOC(which) border_uniform_locations[BORDER_##which] = get_uniform_location(BORDERS_PROGRAM, #which);
|
||||
SET_LOC(viewport)
|
||||
SET_LOC(background_opacity)
|
||||
SET_LOC(tint_opacity)
|
||||
SET_LOC(tint_premult)
|
||||
SET_LOC(default_bg)
|
||||
SET_LOC(active_border_color)
|
||||
SET_LOC(inactive_border_color)
|
||||
@ -956,12 +958,17 @@ create_border_vao(void) {
|
||||
|
||||
void
|
||||
draw_borders(ssize_t vao_idx, unsigned int num_border_rects, BorderRect *rect_buf, bool rect_data_is_dirty, uint32_t viewport_width, uint32_t viewport_height, color_type active_window_bg, unsigned int num_visible_windows, bool all_windows_have_same_bg, OSWindow *w) {
|
||||
|
||||
float background_opacity = w->is_semi_transparent ? w->background_opacity: 1.0f;
|
||||
float tint_opacity = background_opacity;
|
||||
float tint_premult = background_opacity;
|
||||
if (has_bgimage(w)) {
|
||||
glEnable(GL_BLEND);
|
||||
BLEND_ONTO_OPAQUE;
|
||||
draw_bg(w);
|
||||
BLEND_ONTO_OPAQUE;
|
||||
background_opacity = 1.0f;
|
||||
tint_opacity = OPT(background_tint);
|
||||
tint_premult = 1.0f;
|
||||
}
|
||||
|
||||
if (num_border_rects) {
|
||||
@ -974,7 +981,9 @@ draw_borders(ssize_t vao_idx, unsigned int num_border_rects, BorderRect *rect_bu
|
||||
unmap_vao_buffer(vao_idx, 0);
|
||||
}
|
||||
#define CV3(x) (((float)((x >> 16) & 0xff))/255.f), (((float)((x >> 8) & 0xff))/255.f), (((float)(x & 0xff))/255.f)
|
||||
glUniform1f(border_uniform_locations[BORDER_background_opacity], w->is_semi_transparent ? w->background_opacity: 1.0f);
|
||||
glUniform1f(border_uniform_locations[BORDER_background_opacity], background_opacity);
|
||||
glUniform1f(border_uniform_locations[BORDER_tint_opacity], tint_opacity);
|
||||
glUniform1f(border_uniform_locations[BORDER_tint_premult], tint_premult);
|
||||
glUniform3f(border_uniform_locations[BORDER_active_border_color], CV3(OPT(active_border_color)));
|
||||
glUniform3f(border_uniform_locations[BORDER_inactive_border_color], CV3(OPT(inactive_border_color)));
|
||||
glUniform3f(border_uniform_locations[BORDER_bell_border_color], CV3(OPT(bell_border_color)));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user