Skip to content

Commit 234c74a

Browse files
committed
Make foreground opacity configurable
1 parent 853a29c commit 234c74a

File tree

5 files changed

+11
-4
lines changed

5 files changed

+11
-4
lines changed

kitty/cell_vertex.glsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
// Inputs {{{
1414
layout(std140) uniform CellRenderData {
15-
float xstart, ystart, dx, dy, sprite_dx, sprite_dy, background_opacity, cursor_text_uses_bg;
15+
float xstart, ystart, dx, dy, sprite_dx, sprite_dy, background_opacity, foreground_opacity, cursor_text_uses_bg;
1616

1717
uint default_fg, default_bg, highlight_fg, highlight_bg, cursor_color, cursor_text_color, url_color, url_style, inverted;
1818

@@ -184,7 +184,7 @@ void main() {
184184
fg_as_uint = has_mark * color_table[NUM_COLORS + MARK_MASK + 1 + mark] + (ONE - has_mark) * fg_as_uint;
185185
foreground = color_to_vec(fg_as_uint);
186186
float has_dim = float((text_attrs >> DIM_SHIFT) & ONE);
187-
effective_text_alpha = inactive_text_alpha * mix(1.0, dim_opacity, has_dim);
187+
effective_text_alpha = foreground_opacity * inactive_text_alpha * mix(1.0, dim_opacity, has_dim);
188188
float in_url = float((is_selected & TWO) >> 1);
189189
decoration_fg = choose_color(in_url, color_to_vec(url_color), to_color(colors[2], fg_as_uint));
190190
#ifdef USE_SELECTION_FG

kitty/config_data.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,11 @@ def active_tab_title_template(x: str) -> Optional[str]:
987987
default as it has a performance cost)
988988
'''))
989989

990+
o('foreground_opacity', 1.0, option_type=unit_float, long_text=_('''
991+
The opacity of the foreground. A number between 0 and 1, where 1 is opaque and
992+
0 is fully transparent. This has similar constraints to :opt:`background_opacity`
993+
'''))
994+
990995

991996
def config_or_absolute_path(x: str) -> Optional[str]:
992997
if x.lower() == 'none':

kitty/shaders.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ send_graphics_data_to_gpu(size_t image_count, ssize_t gvao_idx, const ImageRende
252252
static inline void
253253
cell_update_uniform_block(ssize_t vao_idx, Screen *screen, int uniform_buffer, GLfloat xstart, GLfloat ystart, GLfloat dx, GLfloat dy, CursorRenderInfo *cursor, bool inverted, OSWindow *os_window) {
254254
struct CellRenderData {
255-
GLfloat xstart, ystart, dx, dy, sprite_dx, sprite_dy, background_opacity, cursor_text_uses_bg;
255+
GLfloat xstart, ystart, dx, dy, sprite_dx, sprite_dy, background_opacity, foreground_opacity, cursor_text_uses_bg;
256256

257257
GLuint default_fg, default_bg, highlight_fg, highlight_bg, cursor_color, cursor_text_color, url_color, url_style, inverted;
258258

@@ -295,6 +295,7 @@ cell_update_uniform_block(ssize_t vao_idx, Screen *screen, int uniform_buffer, G
295295
rd->sprite_dx = 1.0f / (float)x; rd->sprite_dy = 1.0f / (float)y;
296296
rd->inverted = inverted ? 1 : 0;
297297
rd->background_opacity = os_window->is_semi_transparent ? os_window->background_opacity : 1.0f;
298+
rd->foreground_opacity = os_window->is_semi_transparent ? OPT(foreground_opacity) : 1.0f;
298299

299300
#define COLOR(name) colorprofile_to_color(screen->color_profile, screen->color_profile->overridden.name, screen->color_profile->configured.name)
300301
rd->default_fg = COLOR(default_fg); rd->default_bg = COLOR(default_bg); rd->highlight_fg = COLOR(highlight_fg); rd->highlight_bg = COLOR(highlight_bg);

kitty/state.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,7 @@ PYWRAP1(set_options) {
653653
S(background_image_layout, bglayout);
654654
S(background_tint, PyFloat_AsFloat);
655655
S(background_image_linear, PyObject_IsTrue);
656+
S(foreground_opacity, PyFloat_AsFloat);
656657
S(dim_opacity, PyFloat_AsFloat);
657658
S(dynamic_background_opacity, PyObject_IsTrue);
658659
S(inactive_text_alpha, PyFloat_AsFloat);

kitty/state.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ typedef struct {
4444
WindowTitleIn macos_show_window_title_in;
4545
int adjust_line_height_px, adjust_column_width_px;
4646
float adjust_line_height_frac, adjust_column_width_frac;
47-
float background_opacity, dim_opacity;
47+
float background_opacity, foreground_opacity, dim_opacity;
4848

4949
char* background_image;
5050
BackgroundImageLayout background_image_layout;

0 commit comments

Comments
 (0)