From 55967fc299e7ea8aca7e43ce95e38f6aabbb4f4d Mon Sep 17 00:00:00 2001 From: ErrorNoInternet Date: Thu, 14 Mar 2024 10:16:40 +0300 Subject: [PATCH] pkgs/foot-transparent: rebase around latest commit; fix transparent margins --- patches/0001-foot-transparent.patch | 67 ++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 21 deletions(-) diff --git a/patches/0001-foot-transparent.patch b/patches/0001-foot-transparent.patch index da1c819..d17c652 100644 --- a/patches/0001-foot-transparent.patch +++ b/patches/0001-foot-transparent.patch @@ -1,18 +1,19 @@ diff --git a/CHANGELOG.md b/CHANGELOG.md -index 84a8aef4..9332efed 100644 +index 9ceab4d5..146e7992 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md -@@ -63,7 +63,7 @@ +@@ -334,7 +334,8 @@ instead of the one least recently. * Starlight theme (the default theme) updated to [V4][starlight-v4] * Background transparency (alpha) is now disabled in fullscreened - 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 graphical-session.target ([#1281][1281]). * If `$XDG_RUNTIME_DIR/foot-$WAYLAND_DISPLAY.sock` does not exist, diff --git a/meson.build b/meson.build -index aeb2daa6..6a19db47 100644 +index 719352bc..eb38c0f8 100644 --- a/meson.build +++ b/meson.build @@ -73,6 +73,9 @@ add_project_arguments( @@ -25,16 +26,16 @@ index aeb2daa6..6a19db47 100644 cc.get_supported_arguments( ['-pedantic', '-fstrict-aliasing', -@@ -388,6 +391,7 @@ summary( +@@ -374,6 +377,7 @@ summary( 'Documentation': scdoc.found(), 'Themes': get_option('themes'), 'IME': get_option('ime'), + 'Fullscreen alpha': get_option('fullscreen_alpha'), 'Grapheme clustering': utf8proc.found(), - 'Wayland: xdg-activation-v1': xdg_activation, - 'Wayland: fractional-scale-v1': fractional_scale, + 'utmp backend': utmp_backend, + 'utmp helper default path': utmp_default_helper_path, diff --git a/meson_options.txt b/meson_options.txt -index d16e23ae..153c5453 100644 +index ab7a07be..7919431e 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -7,6 +7,9 @@ option('themes', type: 'boolean', value: true, @@ -42,22 +43,22 @@ index d16e23ae..153c5453 100644 description: 'IME (Input Method Editor) support') +option('fullscreen_alpha', type: 'boolean', value: false, -+ description: 'Enables transparency on fullscreen windows') ++ description: 'Enables transparency on fullscreen windows') + option('grapheme-clustering', type: 'feature', description: 'Enables grapheme clustering using libutf8proc. Requires fcft with harfbuzz support to be useful.') diff --git a/render.c b/render.c -index 48957a0a..21f335eb 100644 +index 91472027..847984a9 100644 --- a/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) { +#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. + */ + alpha = term->colors.alpha; @@ -65,7 +66,7 @@ index 48957a0a..21f335eb 100644 if (term->window->is_fullscreen) { /* * 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 { alpha = term->colors.alpha; } @@ -73,13 +74,37 @@ index 48957a0a..21f335eb 100644 } } -@@ -2163,7 +2171,7 @@ render_csd_button_maximize_maximized( - { x_margin + shrink, y_margin + thick, thick, width - 2 * thick - shrink }, - { x_margin + width - thick - shrink, y_margin + thick, thick, width - 2 * thick - shrink }, - { x_margin + shrink, y_margin + width - thick - shrink, width - 2 * shrink, thick }}); -- +@@ -900,6 +908,10 @@ 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; + 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);