mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-29 06:46:35 -04:00
render: whole-window transparency when unfocused
This adds a new option, colors.unfocused-alpha. When set to a value < 1.0, the entire window (*everything* - all bg/fg colors, images etc) are made transparent while the window does not have keyboard focus. The way this is implemented (trying to keep the patch small), we need to do full-screen repaints while in this mode. That is, all screen updates result in full-screen repaints when: * The window does not have keyboard focus * The window *just* gained keyboard focus (i.e. last frame was rendered with transparency) As such, one can expect a fairly large performance impact when there’s large amount of output while the window is unfocused. Focused windows are unaffected, as are unfocused windows when colors.unfocused-alpha == 1.0.
This commit is contained in:
parent
2fbc336eb9
commit
9013a810f1
7 changed files with 57 additions and 0 deletions
20
render.c
20
render.c
|
|
@ -2366,6 +2366,9 @@ grid_render(struct terminal *term)
|
|||
term->render.last_buf->height != buf->height ||
|
||||
term->flash.active || term->render.was_flashing ||
|
||||
term->is_searching != term->render.was_searching ||
|
||||
(term->conf->colors.unfocused_alpha < 0xffff && (
|
||||
!term->kbd_focus ||
|
||||
!term->render.was_focused)) ||
|
||||
term->render.margins)
|
||||
{
|
||||
force_full_repaint(term, buf);
|
||||
|
|
@ -2392,6 +2395,7 @@ grid_render(struct terminal *term)
|
|||
term->render.last_buf = buf;
|
||||
term->render.was_flashing = term->flash.active;
|
||||
term->render.was_searching = term->is_searching;
|
||||
term->render.was_focused = term->kbd_focus;
|
||||
|
||||
shm_addref(buf);
|
||||
buf->age = 0;
|
||||
|
|
@ -2677,6 +2681,22 @@ grid_render(struct terminal *term)
|
|||
xassert(buf->width % term->scale == 0);
|
||||
xassert(buf->height % term->scale == 0);
|
||||
|
||||
if (!term->kbd_focus && term->conf->colors.unfocused_alpha < 0xffff) {
|
||||
pixman_color_t unfocused_alpha =
|
||||
{0, 0, 0, term->conf->colors.unfocused_alpha};
|
||||
pixman_image_t *transparent =
|
||||
pixman_image_create_solid_fill(&unfocused_alpha);
|
||||
|
||||
pixman_image_composite32(
|
||||
PIXMAN_OP_IN_REVERSE, transparent, NULL, buf->pix[0],
|
||||
0, 0, 0, 0, 0, 0, buf->width, buf->height);
|
||||
|
||||
pixman_image_unref(transparent);
|
||||
|
||||
wl_surface_damage_buffer(
|
||||
term->window->surface, 0, 0, buf->width, buf->height);
|
||||
}
|
||||
|
||||
wl_surface_attach(term->window->surface, buf->wl_buf, 0, 0);
|
||||
wl_surface_commit(term->window->surface);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue