From 1dc922e5a43f9613d93921383aab9ffc8980564c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Wed, 1 Jan 2025 09:23:33 +0100 Subject: [PATCH 1/8] changelog: add new 'unreleased' section --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b4af316..3271c24b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Changelog +* [Unreleased](#unreleased) * [1.20.0](#1-20-0) * [1.19.0](#1-19-0) * [1.18.1](#1-18-1) @@ -55,6 +56,16 @@ * [1.2.0](#1-2-0) +## Unreleased +### Added +### Changed +### Deprecated +### Removed +### Fixed +### Security +### Contributors + + ## 1.20.0 ### Added From f8ebe985a8b4daea12a3f9e2630884d70e044e89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Wed, 1 Jan 2025 09:29:11 +0100 Subject: [PATCH 2/8] changelog: add missing issue ref --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3271c24b..c824b82e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -80,6 +80,8 @@ host clipboard access via the OSC-52 escape sequence ([#1867][1867]). +[1867]: https://codeberg.org/dnkl/foot/issues/1867 + ### Changed From c7ab7b353996634c61abd7cd66d32459a6e3da4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Thu, 2 Jan 2025 08:58:48 +0100 Subject: [PATCH 3/8] term: limit app-id to 2048 characters Unsure if the protocol imposes a limit (haven't found any documentation), or if the issue is in the libwayland implementation, or wlroots (triggers in at least sway+river). The issue is that setting a too long app-id causes the compositor (river at least) to peg the CPU at 100%, and stop sending e.g. frame callbacks to foot. Closes #1897 --- CHANGELOG.md | 7 +++++++ terminal.c | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c824b82e..bdc1828b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,6 +59,13 @@ ## Unreleased ### Added ### Changed + +* Runtime changes to the app-id (OSC-176) now limits the app-id string + to 2048 characters ([#1897][1897]). + +[1897]: https://codeberg.org/dnkl/foot/issues/1897 + + ### Deprecated ### Removed ### Fixed diff --git a/terminal.c b/terminal.c index a4963bc8..5a74631a 100644 --- a/terminal.c +++ b/terminal.c @@ -3588,8 +3588,10 @@ term_set_app_id(struct terminal *term, const char *app_id) { if (app_id != NULL && *app_id == '\0') app_id = NULL; + if (term->app_id == NULL && app_id == NULL) return; + if (term->app_id != NULL && app_id != NULL && streq(term->app_id, app_id)) return; @@ -3604,6 +3606,19 @@ term_set_app_id(struct terminal *term, const char *app_id) } else { term->app_id = NULL; } + + const size_t length = strlen(app_id); + if (length > 2048) { + /* + * Not sure if there's a limit in the protocol, or the + * libwayland implementation, or e.g. wlroots, but too long + * app-id's (not e.g. title) causes at least river and sway to + * peg the CPU at 100%, and stop sending e.g. frame callbacks. + * + */ + term->app_id[2048] = '\0'; + } + render_refresh_app_id(term); render_refresh_icon(term); } From 56d2c3e990509d18de31e6009e0d0c6254f99b67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Thu, 2 Jan 2025 09:08:24 +0100 Subject: [PATCH 4/8] 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 --- CHANGELOG.md | 3 +++ config.c | 4 ++-- render.c | 21 +++++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bdc1828b..994805dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -62,6 +62,9 @@ * Runtime changes to the app-id (OSC-176) now limits the app-id string to 2048 characters ([#1897][1897]). +* `colors.flash-alpha` can no longer be set to 1.0 (i.e. fully + opaque). This fixes an issue where the window would be stuck in the + flash state. [1897]: https://codeberg.org/dnkl/foot/issues/1897 diff --git a/config.c b/config.c index 7f1ce055..3b8ce7e8 100644 --- a/config.c +++ b/config.c @@ -1445,8 +1445,8 @@ parse_section_colors(struct context *ctx) if (!value_to_float(ctx, &alpha)) return false; - if (alpha < 0. || alpha > 1.) { - LOG_CONTEXTUAL_ERR("not in range 0.0-1.0"); + if (alpha < 0. || alpha >= 1.) { + LOG_CONTEXTUAL_ERR("not in range 0.0-0.999"); return false; } 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); From 7c1cee0373034b6eba17d12146d340eec68bb5d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Thu, 2 Jan 2025 09:12:06 +0100 Subject: [PATCH 5/8] notify: disable debug logging --- notify.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notify.c b/notify.c index c77c0606..e8688180 100644 --- a/notify.c +++ b/notify.c @@ -10,7 +10,7 @@ #include #define LOG_MODULE "notify" -#define LOG_ENABLE_DBG 1 +#define LOG_ENABLE_DBG 0 #include "log.h" #include "config.h" #include "spawn.h" From 9f5be55d1cdf2a25fa3bb47247420cc658e646f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Thu, 2 Jan 2025 09:12:11 +0100 Subject: [PATCH 6/8] osc: disable debug logging --- osc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osc.c b/osc.c index 2c02f53a..17639c19 100644 --- a/osc.c +++ b/osc.c @@ -8,7 +8,7 @@ #include #define LOG_MODULE "osc" -#define LOG_ENABLE_DBG 1 +#define LOG_ENABLE_DBG 0 #include "log.h" #include "base64.h" #include "config.h" From 9cde179034eb42ad032be4492ea6fc8bc91331ef Mon Sep 17 00:00:00 2001 From: evplus Date: Thu, 2 Jan 2025 11:53:49 +0100 Subject: [PATCH 7/8] themes: add iterm theme from alacritty --- themes/iterm | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 themes/iterm diff --git a/themes/iterm b/themes/iterm new file mode 100644 index 00000000..45b1a0bf --- /dev/null +++ b/themes/iterm @@ -0,0 +1,27 @@ +# -*- conf -*- +# this foot theme is based on alacritty iterm theme: +# https://github.com/alacritty/alacritty-theme/blob/master/themes/iterm.toml + +[colors] +foreground=fffbf6 +background=101421 + +## Normal/regular colors (color palette 0-7) +regular0=2e2e2e # black +regular1=eb4129 # red +regular2=abe047 # green +regular3=f6c744 # yellow +regular4=47a0f3 # blue +regular5=7b5cb0 # magenta +regular6=64dbed # cyan +regular7=e5e9f0 # white + +## Bright colors (color palette 8-15) +bright0=565656 # bright black +bright1=ec5357 # bright red +bright2=c0e17d # bright green +bright3=f9da6a # bright yellow +bright4=49a4f8 # bright blue +bright5=a47de9 # bright magenta +bright6=99faf2 # bright cyan +bright7=ffffff # bright white From f5c10a245229fe173d58ecdc71e4a917524eaf7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Fri, 3 Jan 2025 07:33:14 +0100 Subject: [PATCH 8/8] 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(-) 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;