foot-transparent: update fullscreen-transparency patch
Some checks are pending
Checks / check (NIXPKGS_ALLOW_INSECURE=1 nix flake check --accept-flake-config --impure) (push) Waiting to run
Checks / check (nix run .#alejandra-custom -- -c . -e ./npins) (push) Waiting to run
Checks / build (push) Blocked by required conditions

Thanks @imnotpoz <3
This commit is contained in:
raf 2025-03-20 16:03:22 +03:00
parent 4e3c6d8781
commit 043205a3d8
No known key found for this signature in database
GPG key ID: 29D95B64378DB4BF
2 changed files with 58 additions and 42 deletions

View file

@ -1,64 +1,75 @@
diff --git a/CHANGELOG.md b/CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9ceab4d5..146e7992 100644 index 7ed4bd7a..013ff1be 100644
--- a/CHANGELOG.md --- a/CHANGELOG.md
+++ b/CHANGELOG.md +++ b/CHANGELOG.md
@@ -334,7 +334,8 @@ @@ -913,7 +913,7 @@
instead of the one least recently. instead of the one least recently.
* Starlight theme (the default theme) updated to [V4][starlight-v4] * Starlight theme (the default theme) updated to [V4][starlight-v4]
* Background transparency (alpha) is now disabled in fullscreened * Background transparency (alpha) is now disabled in fullscreened
- windows ([#1416][1416]). - windows ([#1416][1416]).
+ windows ([#1416][1416]) by default but can be enabled with + windows ([#1416][1416]) by default but can be enabled with `fullscreen_alpha`.
+ `fullscreen_alpha`.
* Foot server systemd units now use the standard * Foot server systemd units now use the standard
graphical-session.target ([#1281][1281]). graphical-session.target ([#1281][1281]).
* If `$XDG_RUNTIME_DIR/foot-$WAYLAND_DISPLAY.sock` does not exist, * If `$XDG_RUNTIME_DIR/foot-$WAYLAND_DISPLAY.sock` does not exist,
diff --git a/INSTALL.md b/INSTALL.md
index 7df8d0b8..0f7f1aef 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -148,6 +148,7 @@ Available compile-time options:
| `-Ddocs` | feature | `auto` | Builds and install documentation | scdoc |
| `-Dtests` | bool | `true` | Build tests (adds a `ninja test` build target) | None |
| `-Dime` | bool | `true` | Enables IME support | None |
+| `-Dfullscreen-alpha` | bool | `false` | Enables transparency on fullscreen windows | None |
| `-Dgrapheme-clustering` | feature | `auto` | Enables grapheme clustering | libutf8proc |
| `-Dterminfo` | feature | `enabled` | Build and install terminfo files | tic (ncurses) |
| `-Ddefault-terminfo` | string | `foot` | Default value of `TERM` | None |
diff --git a/meson.build b/meson.build diff --git a/meson.build b/meson.build
index 719352bc..eb38c0f8 100644 index e85d95e5..bf9b021a 100644
--- a/meson.build --- a/meson.build
+++ b/meson.build +++ b/meson.build
@@ -73,6 +73,9 @@ add_project_arguments( @@ -82,6 +82,9 @@ add_project_arguments(
(get_option('b_pgo') == 'use' (get_option('b_pgo') == 'use'
? ['-DFOOT_PGO_ENABLED=1'] ? ['-DFOOT_PGO_ENABLED=1']
: []) + : []) +
+ (get_option('fullscreen_alpha') + (get_option('fullscreen-alpha')
+ ? ['-DFOOT_FULLSCREEN_ALPHA_ENABLED=1'] + ? ['-DFOOT_FULLSCREEN_ALPHA_ENABLED=1']
+ : []) + + : []) +
cc.get_supported_arguments( cc.get_supported_arguments(
['-pedantic', ['-pedantic',
'-fstrict-aliasing', '-fstrict-aliasing',
@@ -374,6 +377,7 @@ summary( @@ -414,6 +417,7 @@ summary(
'Documentation': scdoc.found(), 'Documentation': scdoc.found(),
'Themes': get_option('themes'), 'Themes': get_option('themes'),
'IME': get_option('ime'), 'IME': get_option('ime'),
+ 'Fullscreen alpha': get_option('fullscreen_alpha'), + 'Fullscreen alpha': get_option('fullscreen-alpha'),
'Grapheme clustering': utf8proc.found(), 'Grapheme clustering': utf8proc.found(),
'utmp backend': utmp_backend, 'utmp backend': utmp_backend,
'utmp helper default path': utmp_default_helper_path, 'utmp helper default path': utmp_default_helper_path,
diff --git a/meson_options.txt b/meson_options.txt diff --git a/meson_options.txt b/meson_options.txt
index ab7a07be..7919431e 100644 index ab7a07be..30078102 100644
--- a/meson_options.txt --- a/meson_options.txt
+++ b/meson_options.txt +++ b/meson_options.txt
@@ -7,6 +7,9 @@ option('themes', type: 'boolean', value: true, @@ -7,6 +7,9 @@ option('themes', type: 'boolean', value: true,
option('ime', type: 'boolean', value: true, option('ime', type: 'boolean', value: true,
description: 'IME (Input Method Editor) support') description: 'IME (Input Method Editor) support')
+option('fullscreen_alpha', type: 'boolean', value: false, +option('fullscreen-alpha', type: 'boolean', value: false,
+ description: 'Enables transparency on fullscreen windows') + description: 'Enables transparency on fullscreen windows')
+ +
option('grapheme-clustering', type: 'feature', option('grapheme-clustering', type: 'feature',
description: 'Enables grapheme clustering using libutf8proc. Requires fcft with harfbuzz support to be useful.') description: 'Enables grapheme clustering using libutf8proc. Requires fcft with harfbuzz support to be useful.')
diff --git a/render.c b/render.c diff --git a/render.c b/render.c
index 91472027..847984a9 100644 index 4975394f..eddf465a 100644
--- a/render.c --- a/render.c
+++ b/render.c +++ b/render.c
@@ -525,6 +525,13 @@ render_cell(struct terminal *term, pixman_image_t *pix, pixman_region32_t *damag @@ -746,6 +746,13 @@ render_cell(struct terminal *term, pixman_image_t *pix,
} }
else if (cell->attrs.bg_src == COLOR_DEFAULT) { else if (cell->attrs.bg_src == COLOR_DEFAULT) {
+#if defined(FOOT_FULLSCREEN_ALPHA_ENABLED) && FOOT_FULLSCREEN_ALPHA_ENABLED +#if defined(FOOT_FULLSCREEN_ALPHA_ENABLED) && FOOT_FULLSCREEN_ALPHA_ENABLED
+ /* + /*
+ * Note: I don't care about the stupid ass Wayland + * Note: I don't care about the stupid ass wayland
+ * protocol I want transparent fullscreen windows. + * protocol I want transparent fullscreen windows.
+ */ + */
+ alpha = term->colors.alpha; + alpha = term->colors.alpha;
@ -66,46 +77,37 @@ index 91472027..847984a9 100644
if (term->window->is_fullscreen) { if (term->window->is_fullscreen) {
/* /*
* Note: disable transparency when fullscreened. * Note: disable transparency when fullscreened.
@@ -562,6 +569,7 @@ render_cell(struct terminal *term, pixman_image_t *pix, pixman_region32_t *damag @@ -783,6 +790,7 @@ render_cell(struct terminal *term, pixman_image_t *pix,
} else { } else {
alpha = term->colors.alpha; alpha = term->colors.alpha;
} }
+#endif +#endif
} }
} }
@@ -900,6 +908,10 @@ render_margin(struct terminal *term, struct buffer *buf, @@ -1191,10 +1199,12 @@ render_margin(struct terminal *term, struct buffer *buf,
const int bmargin = term->height - term->margins.bottom;
const int line_count = end_line - start_line;
+#if defined(FOOT_FULLSCREEN_ALPHA_ENABLED) && FOOT_FULLSCREEN_ALPHA_ENABLED
+ uint32_t _bg = !term->reverse ? term->colors.bg : term->colors.fg;
+ pixman_color_t bg = color_hex_to_pixman_with_alpha(_bg, term->colors.alpha);
+#else
const uint32_t _bg = !term->reverse ? term->colors.bg : term->colors.fg; const uint32_t _bg = !term->reverse ? term->colors.bg : term->colors.fg;
uint16_t alpha = term->colors.alpha; uint16_t alpha = term->colors.alpha;
@@ -909,6 +921,7 @@ render_margin(struct terminal *term, struct buffer *buf, +#if !defined(FOOT_FULLSCREEN_ALPHA_ENABLED) || !FOOT_FULLSCREEN_ALPHA_ENABLED
if (term->window->is_fullscreen) {
/* Disable alpha in fullscreen - see render_cell() for details */
alpha = 0xffff;
} }
pixman_color_t bg = color_hex_to_pixman_with_alpha(_bg, alpha);
+#endif +#endif
pixman_image_fill_rectangles( pixman_color_t bg = color_hex_to_pixman_with_alpha(_bg, alpha, gamma_correct);
PIXMAN_OP_SRC, buf->pix[0], &bg, 4,
@@ -2817,8 +2830,14 @@ grid_render(struct terminal *term) @@ -3220,8 +3230,12 @@ grid_render(struct terminal *term)
xassert(term->height > 0); xassert(term->height > 0);
struct buffer_chain *chain = term->render.chains.grid; struct buffer_chain *chain = term->render.chains.grid;
+
+#if defined(FOOT_FULLSCREEN_ALPHA_ENABLED) && FOOT_FULLSCREEN_ALPHA_ENABLED +#if defined(FOOT_FULLSCREEN_ALPHA_ENABLED) && FOOT_FULLSCREEN_ALPHA_ENABLED
+ bool use_alpha = term->colors.alpha != 0xffff; + bool use_alpha = term->colors.alpha != 0xffff;
+#else +#else
bool use_alpha = !term->window->is_fullscreen && bool use_alpha = !term->window->is_fullscreen &&
term->colors.alpha != 0xffff; term->colors.alpha != 0xffff;
+#endif +#endif
+
struct buffer *buf = shm_get_buffer( struct buffer *buf = shm_get_buffer(
chain, term->width, term->height, use_alpha); chain, term->width, term->height, use_alpha);

View file

@ -1,6 +1,7 @@
{ {
lib, lib,
fetchFromGitea, fetchFromGitea,
fcft,
foot, foot,
pins, pins,
date, date,
@ -21,7 +22,20 @@ in {
}; };
patches = (prev.patches or []) ++ [./0001-fullscreen-transparency.patch]; patches = (prev.patches or []) ++ [./0001-fullscreen-transparency.patch];
mesonFlags = (prev.mesonFlags or []) ++ ["-Dfullscreen_alpha=true"]; mesonFlags = (prev.mesonFlags or []) ++ ["-Dfullscreen-alpha=true"];
nativeBuildInputs =
(prev.nativeBuildInputs or [])
++ [
(fcft.overrideAttrs {
src = fetchFromGitea {
domain = "codeberg.org";
owner = "dnkl";
repo = "fcft";
tag = "3.3.1";
hash = "sha256-qgNNowWQhiu6pr9bmWbBo3mHgdkmNpDHDBeTidk32SE=";
};
})
];
meta = { meta = {
description = "Patched version of Foor terminal emulator that brings back fullscreen transparency"; description = "Patched version of Foor terminal emulator that brings back fullscreen transparency";