Dont require restart to change text_fg_override_threshold from zero to non-zero
This commit is contained in:
parent
53073f34d7
commit
b45d7ae21f
5 changed files with 30 additions and 14 deletions
|
|
@ -147,7 +147,7 @@
|
|||
startup_notification_handler,
|
||||
which,
|
||||
)
|
||||
from .window import CommandOutput, CwdRequest, Window
|
||||
from .window import CommandOutput, CwdRequest, Window, load_shader_programs
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .rc.base import ResponseType
|
||||
|
|
@ -2409,6 +2409,7 @@ def apply_new_options(self, opts: Options) -> None:
|
|||
for w in self.all_windows:
|
||||
self.default_bg_changed_for(w.id)
|
||||
w.refresh(reload_all_gpu_data=True)
|
||||
load_shader_programs.recompile_if_needed()
|
||||
|
||||
@ac('misc', '''
|
||||
Reload the config file
|
||||
|
|
|
|||
|
|
@ -458,7 +458,7 @@ def add_window(os_window_id: int, tab_id: int, title: str) -> int:
|
|||
|
||||
|
||||
def compile_program(
|
||||
which: int, vertex_shader: str, fragment_shader: str
|
||||
which: int, vertex_shader: str, fragment_shader: str, allow_recompile: bool = False
|
||||
) -> int:
|
||||
pass
|
||||
|
||||
|
|
|
|||
|
|
@ -276,8 +276,7 @@
|
|||
foreground and background is below this threshold, the foreground color will be set
|
||||
to white if the background is dark or black if the background is light. The default
|
||||
value is :code:`0`, which means no overriding is performed. Useful when working with applications
|
||||
that use colors that do not contrast well with your preferred color scheme. Changing this option
|
||||
from zero to a non-zero value or vice versa requires a restart of kitty.
|
||||
that use colors that do not contrast well with your preferred color scheme.
|
||||
''')
|
||||
|
||||
egr() # }}}
|
||||
|
|
|
|||
|
|
@ -1071,12 +1071,15 @@ draw_borders(ssize_t vao_idx, unsigned int num_border_rects, BorderRect *rect_bu
|
|||
static PyObject*
|
||||
compile_program(PyObject UNUSED *self, PyObject *args) {
|
||||
const char *vertex_shader, *fragment_shader;
|
||||
int which;
|
||||
int which, allow_recompile = 0;
|
||||
GLuint vertex_shader_id = 0, fragment_shader_id = 0;
|
||||
if (!PyArg_ParseTuple(args, "iss", &which, &vertex_shader, &fragment_shader)) return NULL;
|
||||
if (!PyArg_ParseTuple(args, "iss|p", &which, &vertex_shader, &fragment_shader, &allow_recompile)) return NULL;
|
||||
if (which < 0 || which >= NUM_PROGRAMS) { PyErr_Format(PyExc_ValueError, "Unknown program: %d", which); return NULL; }
|
||||
Program *program = program_ptr(which);
|
||||
if (program->id != 0) { PyErr_SetString(PyExc_ValueError, "program already compiled"); return NULL; }
|
||||
if (program->id != 0) {
|
||||
if (allow_recompile) { glDeleteProgram(program->id); program->id = 0; }
|
||||
else { PyErr_SetString(PyExc_ValueError, "program already compiled"); return NULL; }
|
||||
}
|
||||
program->id = glCreateProgram();
|
||||
vertex_shader_id = compile_shader(GL_VERTEX_SHADER, vertex_shader);
|
||||
fragment_shader_id = compile_shader(GL_FRAGMENT_SHADER, fragment_shader);
|
||||
|
|
|
|||
|
|
@ -374,8 +374,20 @@ def sub(m: 're.Match[str]') -> str:
|
|||
|
||||
class LoadShaderPrograms:
|
||||
|
||||
def __call__(self, semi_transparent: bool = False) -> None:
|
||||
compile_program(BLIT_PROGRAM, *load_shaders('blit'))
|
||||
text_fg_override_threshold: float = 0
|
||||
semi_transparent: bool = False
|
||||
|
||||
@property
|
||||
def needs_recompile(self) -> bool:
|
||||
return get_options().text_fg_override_threshold != self.text_fg_override_threshold
|
||||
|
||||
def recompile_if_needed(self) -> None:
|
||||
if self.needs_recompile:
|
||||
self(self.semi_transparent, allow_recompile=True)
|
||||
|
||||
def __call__(self, semi_transparent: bool = False, allow_recompile: bool = False) -> None:
|
||||
self.semi_transparent = semi_transparent
|
||||
compile_program(BLIT_PROGRAM, *load_shaders('blit'), allow_recompile)
|
||||
v, f = load_shaders('cell')
|
||||
|
||||
for which, p in {
|
||||
|
|
@ -397,12 +409,13 @@ def __call__(self, semi_transparent: bool = False) -> None:
|
|||
DECORATION_MASK=DECORATION_MASK,
|
||||
STRIKE_SPRITE_INDEX=NUM_UNDERLINE_STYLES + 1,
|
||||
)
|
||||
if get_options().text_fg_override_threshold != 0.:
|
||||
self.text_fg_override_threshold = get_options().text_fg_override_threshold
|
||||
if self.text_fg_override_threshold != 0.:
|
||||
ff = ff.replace('#define NO_FG_OVERRIDE', '#define FG_OVERRIDE')
|
||||
if semi_transparent:
|
||||
vv = vv.replace('#define NOT_TRANSPARENT', '#define TRANSPARENT')
|
||||
ff = ff.replace('#define NOT_TRANSPARENT', '#define TRANSPARENT')
|
||||
compile_program(p, vv, ff)
|
||||
compile_program(p, vv, ff, allow_recompile)
|
||||
|
||||
v, f = load_shaders('graphics')
|
||||
for which, p in {
|
||||
|
|
@ -411,12 +424,12 @@ def __call__(self, semi_transparent: bool = False) -> None:
|
|||
'ALPHA_MASK': GRAPHICS_ALPHA_MASK_PROGRAM,
|
||||
}.items():
|
||||
ff = f.replace('ALPHA_TYPE', which)
|
||||
compile_program(p, v, ff)
|
||||
compile_program(p, v, ff, allow_recompile)
|
||||
|
||||
v, f = load_shaders('bgimage')
|
||||
compile_program(BGIMAGE_PROGRAM, v, f)
|
||||
compile_program(BGIMAGE_PROGRAM, v, f, allow_recompile)
|
||||
v, f = load_shaders('tint')
|
||||
compile_program(TINT_PROGRAM, v, f)
|
||||
compile_program(TINT_PROGRAM, v, f, allow_recompile)
|
||||
init_cell_program()
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue