Skip to content

Commit 4e55a8c

Browse files
committed
Make foreground opacity configurable
1 parent 258b268 commit 4e55a8c

File tree

8 files changed

+35
-6
lines changed

8 files changed

+35
-6
lines changed

kittens/diff/options/types.py

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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/options/definition.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,14 @@
10021002
'''
10031003
)
10041004

1005+
opt('foreground_opacity', '1.0',
1006+
option_type='unit_float', ctype='float',
1007+
long_text='''
1008+
The opacity of the foreground. A number between 0 and 1, where 1 is opaque and
1009+
0 is fully transparent. This has similar constraints to :opt:`background_opacity`.
1010+
'''
1011+
)
1012+
10051013
opt('background_image', 'none',
10061014
option_type='config_or_absolute_path', ctype='!background_image',
10071015
long_text='Path to a background image. Must be in PNG format.'

kitty/options/parse.py

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

kitty/options/to-c-generated.h

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

kitty/options/types.py

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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.h

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

4747
char* background_image;
4848
BackgroundImageLayout background_image_layout;

0 commit comments

Comments
 (0)