From 56d2c3e990509d18de31e6009e0d0c6254f99b67 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Thu, 2 Jan 2025 09:08:24 +0100 Subject: config: don't allow colors.flash-alpha to be 1.0 A compositor will not send a frame callback for our main window if it is fully occluded (for example, by a fully opaque overlay...). This causes the overlay to stuck. For regular buffers, it _should_ be enough to *not* hint the compositor it's opaque. But at least some compositor special cases single-pixel buffers, and actually look at their pixel value. Thus, we have two options: implement frame callback handling for the overlay sub-surface, or ensure we don't use a fully opaque surface. Since no overlays are fully opaque by default, and the flash surface is the only one that can be configured to be opaque (colors.flash-alpha), and since adding frame callback handling adds a lot of boilerplate code... let's go with the simpler solution of --- render.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'render.c') diff --git a/render.c b/render.c index ed6b802e..8fc741b5 100644 --- a/render.c +++ b/render.c @@ -1898,6 +1898,27 @@ render_overlay(struct terminal *term) break; case OVERLAY_FLASH: + /* + * A compositor will not send a frame callback for our main + * window if it is fully occluded (for example, by a fully + * opaque overlay...). This causes the overlay to stuck. + * + * For regular buffers, it _should_ be enough to *not* hint + * the compositor it's opaque. But at least some compositor + * special cases single-pixel buffers, and actually look at + * their pixel value. + * + * Thus, we have two options: implement frame callback + * handling for the overlay sub-surface, or ensure we don't + * use a fully opaque surface. Since no overlays are fully + * opaque by default, and the flash surface is the only one + * that can be configured to be opaque (colors.flash-alpha), + * and since adding frame callback handling adds a lot of + * boilerplate code... let's go with the simpler solution of + * not allowing colors.flash-alpha to be 1.0. + */ + xassert(term->conf->colors.flash_alpha != 0xffff); + color = color_hex_to_pixman_with_alpha( term->conf->colors.flash, term->conf->colors.flash_alpha); -- cgit v1.3 From f5c10a245229fe173d58ecdc71e4a917524eaf7b Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Fri, 3 Jan 2025 07:33:14 +0100 Subject: render: fix order we're checking custom codepoints Fixes a crash when trying to print a "Legacy Computing" symbol (U+1FB00-U+1FB9B). Closes #1901 --- CHANGELOG.md | 7 +++++++ render.c | 10 +++++----- terminal.h | 12 ++++++------ 3 files changed, 18 insertions(+), 11 deletions(-) (limited to 'render.c') diff --git a/CHANGELOG.md b/CHANGELOG.md index 994805dd..1461fa63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,6 +72,13 @@ ### Deprecated ### Removed ### Fixed + +* Regression: trying to print a Unicode _"Legacy Computing symbol"_, + in the range U+1FB00 - U+1FB9B would crash foot ([#][]). + +[1901]: https://codeberg.org/dnkl/foot/issues/1901 + + ### Security ### Contributors diff --git a/render.c b/render.c index 8fc741b5..5a924743 100644 --- a/render.c +++ b/render.c @@ -817,14 +817,14 @@ render_cell(struct terminal *term, pixman_image_t *pix, pixman_region32_t *damag size_t count; size_t idx; - if (base >= GLYPH_OCTANTS_FIRST) { - arr = &term->custom_glyphs.octants; - count = GLYPH_OCTANTS_COUNT; - idx = base - GLYPH_OCTANTS_FIRST; - } else if (base >= GLYPH_LEGACY_FIRST) { + if (base >= GLYPH_LEGACY_FIRST) { arr = &term->custom_glyphs.legacy; count = GLYPH_LEGACY_COUNT; idx = base - GLYPH_LEGACY_FIRST; + } else if (base >= GLYPH_OCTANTS_FIRST) { + arr = &term->custom_glyphs.octants; + count = GLYPH_OCTANTS_COUNT; + idx = base - GLYPH_OCTANTS_FIRST; } else if (base >= GLYPH_BRAILLE_FIRST) { arr = &term->custom_glyphs.braille; count = GLYPH_BRAILLE_COUNT; diff --git a/terminal.h b/terminal.h index d3c7f335..813510fe 100644 --- a/terminal.h +++ b/terminal.h @@ -482,8 +482,8 @@ struct terminal { struct { struct fcft_glyph **box_drawing; struct fcft_glyph **braille; - struct fcft_glyph **legacy; struct fcft_glyph **octants; + struct fcft_glyph **legacy; #define GLYPH_BOX_DRAWING_FIRST 0x2500 #define GLYPH_BOX_DRAWING_LAST 0x259F @@ -495,15 +495,15 @@ struct terminal { #define GLYPH_BRAILLE_COUNT \ (GLYPH_BRAILLE_LAST - GLYPH_BRAILLE_FIRST + 1) - #define GLYPH_LEGACY_FIRST 0x1FB00 - #define GLYPH_LEGACY_LAST 0x1FB9B - #define GLYPH_LEGACY_COUNT \ - (GLYPH_LEGACY_LAST - GLYPH_LEGACY_FIRST + 1) - #define GLYPH_OCTANTS_FIRST 0x1CD00 #define GLYPH_OCTANTS_LAST 0x1CDE5 #define GLYPH_OCTANTS_COUNT \ (GLYPH_OCTANTS_LAST - GLYPH_OCTANTS_FIRST + 1) + + #define GLYPH_LEGACY_FIRST 0x1FB00 + #define GLYPH_LEGACY_LAST 0x1FB9B + #define GLYPH_LEGACY_COUNT \ + (GLYPH_LEGACY_LAST - GLYPH_LEGACY_FIRST + 1) } custom_glyphs; bool is_sending_paste_data; -- cgit v1.3