mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-11-17 05:32:41 +00:00
Custom shaders: Make bell-in-window event independent of visual bell
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
Fire the event directly from screen_bell() instead of piggy-backing on start_visual_bell_at in the render loop. Previously the event only fired when visual_bell_duration was non-zero and bells in windows that were not visible fired it late, when the window was next rendered. Now only bells in visible windows (in the active tab and not hidden by an overlay or the layout) fire the event.
This commit is contained in:
parent
e71d8c3ac4
commit
8a3dace409
4 changed files with 36 additions and 7 deletions
|
|
@ -130,6 +130,11 @@ Detailed list of changes
|
|||
events and uniforms for whether a command is running and whether the
|
||||
alternate screen is in use in the active window
|
||||
|
||||
- :doc:`Custom shaders <custom-shaders>`: Fix the ``bell-in-window`` event only
|
||||
firing when :opt:`visual_bell_duration` is non-zero. Bells in hidden windows,
|
||||
such as those in inactive tabs, no longer trigger the event late, when the
|
||||
window next becomes visible
|
||||
|
||||
- :doc:`choose-files <kittens/choose-files>`: Fix concurrent custom preview
|
||||
commands occasionally receiving the path of a different file.
|
||||
|
||||
|
|
|
|||
|
|
@ -586,12 +586,17 @@ be combined with ``|`` — any one of them will trigger the action.
|
|||
- The active tab changes.
|
||||
|
||||
* - ``bell-in-window``
|
||||
- A bell (BEL character) is received in any kitty window.
|
||||
- A bell (BEL character) is received in a visible kitty window. Bells
|
||||
in windows in inactive tabs or hidden by overlays or the layout do not
|
||||
trigger this event. This fires regardless of
|
||||
:opt:`visual_bell_duration`, so a shader can be used as a replacement
|
||||
for the builtin visual bell flash, by setting that option to zero.
|
||||
The geometry of the window in which the most recent bell occurred is
|
||||
available in ``d.bell_window_geometry`` (UV co-ordinates, origin
|
||||
bottom-left; ``.xy`` = lower-left corner, ``.zw`` = width and height).
|
||||
If that window is not currently visible in the active tab or layout,
|
||||
``d.bell_window_geometry`` equals ``d.central_area``.
|
||||
If that window is no longer visible, for example because it was closed
|
||||
or the active tab changed, ``d.bell_window_geometry`` equals
|
||||
``d.central_area``.
|
||||
|
||||
* - ``user-activity``
|
||||
- Any keyboard or mouse input is received.
|
||||
|
|
|
|||
|
|
@ -1029,10 +1029,6 @@ prepare_to_render_os_window(
|
|||
if (send_cell_data_to_gpu(WD.vao_idx, WD.screen, os_window)) needs_render = true;
|
||||
if (WD.screen->start_visual_bell_at | WD.screen->start_drag_overlay_at) needs_render = true;
|
||||
if (OPT(progress_bar) != PROGRESS_BAR_HIDDEN && WD.screen->progress_state == PROGRESS_STATE_INDETERMINATE) needs_render = true;
|
||||
if (WD.screen->start_visual_bell_at && WD.screen->start_visual_bell_at > os_window->last_rendered_at) {
|
||||
os_window->shader_anim_event_registry |= (1u << SHADER_ANIM_EVENT_BELL_IN_WINDOW);
|
||||
os_window->last_bell_window_id = w->id;
|
||||
}
|
||||
// Prepare window title bar screen data for GPU
|
||||
WindowRenderData *trd = &w->window_title_render_data;
|
||||
if (trd->screen && trd->geometry.bottom > trd->geometry.top && trd->geometry.right > trd->geometry.left) {
|
||||
|
|
|
|||
|
|
@ -3201,6 +3201,28 @@ screen_invert_colors(Screen *self) {
|
|||
return self->paused_rendering.expires_at ? self->paused_rendering.inverted : (self->modes.mDECSCNM ? true : false);
|
||||
}
|
||||
|
||||
// Fire the custom shader bell event, independently of the visual bell, but
|
||||
// only if the window is visible, i.e. in the active tab and not hidden by an
|
||||
// overlay or the layout, as otherwise the shader has nothing to draw over.
|
||||
static void
|
||||
fire_bell_shader_event(id_type window_id) {
|
||||
for (size_t o = 0; o < global_state.num_os_windows; o++) {
|
||||
OSWindow *osw = global_state.os_windows + o;
|
||||
if (osw->active_tab >= osw->num_tabs) continue;
|
||||
Tab *tab = osw->tabs + osw->active_tab;
|
||||
for (size_t i = 0; i < tab->num_windows; i++) {
|
||||
if (tab->windows[i].id == window_id) {
|
||||
if (tab->windows[i].visible) {
|
||||
osw->shader_anim_event_registry |= (1u << SHADER_ANIM_EVENT_BELL_IN_WINDOW);
|
||||
osw->last_bell_window_id = window_id;
|
||||
wakeup_main_loop();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
screen_bell(Screen *self) {
|
||||
if (self->ignore_bells.start) {
|
||||
|
|
@ -3213,6 +3235,7 @@ screen_bell(Screen *self) {
|
|||
}
|
||||
request_window_attention(self->window_id, OPT(enable_audio_bell));
|
||||
if (OPT(visual_bell_duration) > 0.0f) self->start_visual_bell_at = monotonic();
|
||||
if (self->window_id) fire_bell_shader_event(self->window_id);
|
||||
CALLBACK("on_bell", NULL);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue