pkgs/foot-transparent: rebase around latest commit; fix transparent margins

This commit is contained in:
ErrorNoInternet 2024-03-14 10:16:40 +03:00 committed by NotAShelf
parent 38a1dd67d5
commit 55967fc299
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29

View file

@ -1,18 +1,19 @@
diff --git a/CHANGELOG.md b/CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md
index 84a8aef4..9332efed 100644 index 9ceab4d5..146e7992 100644
--- a/CHANGELOG.md --- a/CHANGELOG.md
+++ b/CHANGELOG.md +++ b/CHANGELOG.md
@@ -63,7 +63,7 @@ @@ -334,7 +334,8 @@
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 `fullscreen_alpha`. + windows ([#1416][1416]) by default but can be enabled with
+ `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/meson.build b/meson.build diff --git a/meson.build b/meson.build
index aeb2daa6..6a19db47 100644 index 719352bc..eb38c0f8 100644
--- a/meson.build --- a/meson.build
+++ b/meson.build +++ b/meson.build
@@ -73,6 +73,9 @@ add_project_arguments( @@ -73,6 +73,9 @@ add_project_arguments(
@ -25,16 +26,16 @@ index aeb2daa6..6a19db47 100644
cc.get_supported_arguments( cc.get_supported_arguments(
['-pedantic', ['-pedantic',
'-fstrict-aliasing', '-fstrict-aliasing',
@@ -388,6 +391,7 @@ summary( @@ -374,6 +377,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(),
'Wayland: xdg-activation-v1': xdg_activation, 'utmp backend': utmp_backend,
'Wayland: fractional-scale-v1': fractional_scale, '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 d16e23ae..153c5453 100644 index ab7a07be..7919431e 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,
@ -42,22 +43,22 @@ index d16e23ae..153c5453 100644
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 48957a0a..21f335eb 100644 index 91472027..847984a9 100644
--- a/render.c --- a/render.c
+++ b/render.c +++ b/render.c
@@ -534,6 +534,13 @@ render_cell(struct terminal *term, pixman_image_t *pix, @@ -525,6 +525,13 @@ render_cell(struct terminal *term, pixman_image_t *pix, pixman_region32_t *damag
} }
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;
@ -65,7 +66,7 @@ index 48957a0a..21f335eb 100644
if (term->window->is_fullscreen) { if (term->window->is_fullscreen) {
/* /*
* Note: disable transparency when fullscreened. * Note: disable transparency when fullscreened.
@@ -559,6 +566,7 @@ render_cell(struct terminal *term, pixman_image_t *pix, @@ -562,6 +569,7 @@ render_cell(struct terminal *term, pixman_image_t *pix, pixman_region32_t *damag
} else { } else {
alpha = term->colors.alpha; alpha = term->colors.alpha;
} }
@ -73,13 +74,37 @@ index 48957a0a..21f335eb 100644
} }
} }
@@ -2163,7 +2171,7 @@ render_csd_button_maximize_maximized( @@ -900,6 +908,10 @@ render_margin(struct terminal *term, struct buffer *buf,
{ x_margin + shrink, y_margin + thick, thick, width - 2 * thick - shrink }, const int bmargin = term->height - term->margins.bottom;
{ x_margin + width - thick - shrink, y_margin + thick, thick, width - 2 * thick - shrink }, const int line_count = end_line - start_line;
{ x_margin + shrink, y_margin + width - thick - shrink, width - 2 * shrink, thick }});
- +#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;
uint16_t alpha = term->colors.alpha;
@@ -909,6 +921,7 @@ render_margin(struct terminal *term, struct buffer *buf,
}
pixman_color_t bg = color_hex_to_pixman_with_alpha(_bg, alpha);
+#endif
pixman_image_fill_rectangles(
PIXMAN_OP_SRC, buf->pix[0], &bg, 4,
@@ -2817,8 +2830,14 @@ grid_render(struct terminal *term)
xassert(term->height > 0);
struct buffer_chain *chain = term->render.chains.grid;
+ +
pixman_image_unref(src); +#if defined(FOOT_FULLSCREEN_ALPHA_ENABLED) && FOOT_FULLSCREEN_ALPHA_ENABLED
+ bool use_alpha = term->colors.alpha != 0xffff;
} +#else
bool use_alpha = !term->window->is_fullscreen &&
term->colors.alpha != 0xffff;
+#endif
+
struct buffer *buf = shm_get_buffer(
chain, term->width, term->height, use_alpha);