From e1d66ad0c1a444ed497e614b039d0668dd1c8a32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 30 Jul 2023 13:27:42 +0200 Subject: [PATCH 1/7] =?UTF-8?q?changelog:=20add=20new=20=E2=80=98unrelease?= =?UTF-8?q?d=20section=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 975a3704..9ae61a47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Changelog +* [Unreleased](#unreleased) * [1.15.2](#1-15-2) * [1.15.1](#1-15-1) * [1.15.0](#1-15-0) @@ -44,6 +45,16 @@ * [1.2.0](#1-2-0) +## Unreleased +### Added +### Changed +### Deprecated +### Removed +### Fixed +### Security +### Contributors + + ## 1.15.2 ### Added From e56725044961248006350ea1e8455780c57a3f95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 31 Jul 2023 16:26:17 +0200 Subject: [PATCH 2/7] main: translate command line options to overrides Instead of special casing configuration affecting command line options (like --font, --fullscreen, --maximized etc), translate them to overrides, and let the configuration system handle them. This also fixes an issue where -f,--font did not set csd.font, if csd.font were otherwise unset. --- CHANGELOG.md | 4 ++ main.c | 107 +++++++++------------------------------------------ 2 files changed, 22 insertions(+), 89 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ae61a47..ad90b71b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,10 @@ ### Deprecated ### Removed ### Fixed + +* `-f,--font` command line option not affecting `csd.font` (if unset). + + ### Security ### Contributors diff --git a/main.c b/main.c index fc329574..38e3c148 100644 --- a/main.c +++ b/main.c @@ -222,21 +222,11 @@ main(int argc, char *const *argv) bool check_config = false; const char *conf_path = NULL; - const char *conf_term = NULL; - const char *conf_title = NULL; - const char *conf_app_id = NULL; const char *custom_cwd = NULL; - bool login_shell = false; - tll(char *) conf_fonts = tll_init(); - enum conf_size_type conf_size_type = CONF_SIZE_PX; - int conf_width = -1; - int conf_height = -1; bool as_server = false; const char *conf_server_socket_path = NULL; bool presentation_timings = false; bool hold = false; - bool maximized = false; - bool fullscreen = false; bool unlink_pid_file = false; const char *pid_file = NULL; enum log_class log_level = LOG_CLASS_WARNING; @@ -261,23 +251,23 @@ main(int argc, char *const *argv) break; case 'o': - tll_push_back(overrides, optarg); + tll_push_back(overrides, xstrdup(optarg)); break; case 't': - conf_term = optarg; + tll_push_back(overrides, xasprintf("term=%s", optarg)); break; case 'L': - login_shell = true; + tll_push_back(overrides, xstrdup("login-shell=yes")); break; case 'T': - conf_title = optarg; + tll_push_back(overrides, xasprintf("title%s", optarg)); break; case 'a': - conf_app_id = optarg; + tll_push_back(overrides, xasprintf("app-id=%s", optarg)); break; case 'D': { @@ -290,27 +280,11 @@ main(int argc, char *const *argv) break; } - case 'f': - tll_free_and_free(conf_fonts, free); - for (char *font = strtok(optarg, ","); font != NULL; font = strtok(NULL, ",")) { - - /* Strip leading spaces */ - while (*font != '\0' && isspace(*font)) - font++; - - /* Strip trailing spaces */ - char *end = font + strlen(font); - xassert(*end == '\0'); - end--; - while (end > font && isspace(*end)) - *(end--) = '\0'; - - if (strlen(font) == 0) - continue; - - tll_push_back(conf_fonts, font); - } + case 'f': { + char *font_override = xasprintf("font=%s", optarg); + tll_push_back(overrides, font_override); break; + } case 'w': { unsigned width, height; @@ -319,9 +293,9 @@ main(int argc, char *const *argv) return ret; } - conf_size_type = CONF_SIZE_PX; - conf_width = width; - conf_height = height; + tll_push_back( + overrides, xasprintf("initial-window-size-pixels=%ux%u", + width, height)); break; } @@ -332,9 +306,9 @@ main(int argc, char *const *argv) return ret; } - conf_size_type = CONF_SIZE_CELLS; - conf_width = width; - conf_height = height; + tll_push_back( + overrides, xasprintf("initial-window-size-chars=%ux%u", + width, height)); break; } @@ -353,13 +327,11 @@ main(int argc, char *const *argv) break; case 'm': - maximized = true; - fullscreen = false; + tll_push_back(overrides, xstrdup("initial-window-mode=maximized")); break; case 'F': - fullscreen = true; - maximized = false; + tll_push_back(overrides, xstrdup("initial-window-mode=fullscreen")); break; case 'p': @@ -494,7 +466,7 @@ main(int argc, char *const *argv) bool conf_successful = config_load( &conf, conf_path, &user_notifications, &overrides, check_config, as_server); - tll_free(overrides); + tll_free_and_free(overrides, free); if (!conf_successful) { config_free(&conf); return ret; @@ -515,53 +487,10 @@ main(int argc, char *const *argv) (enum fcft_log_class)log_level); fcft_set_scaling_filter(conf.tweak.fcft_filter); - if (conf_term != NULL) { - free(conf.term); - conf.term = xstrdup(conf_term); - } - if (conf_title != NULL) { - free(conf.title); - conf.title = xstrdup(conf_title); - } - if (conf_app_id != NULL) { - free(conf.app_id); - conf.app_id = xstrdup(conf_app_id); - } - if (login_shell) - conf.login_shell = true; - if (tll_length(conf_fonts) > 0) { - for (size_t i = 0; i < ALEN(conf.fonts); i++) - config_font_list_destroy(&conf.fonts[i]); - - struct config_font_list *font_list = &conf.fonts[0]; - xassert(font_list->count == 0); - xassert(font_list->arr == NULL); - - font_list->arr = xmalloc( - tll_length(conf_fonts) * sizeof(font_list->arr[0])); - - tll_foreach(conf_fonts, it) { - struct config_font font; - if (!config_font_parse(it->item, &font)) { - LOG_ERR("%s: invalid font specification", it->item); - } else - font_list->arr[font_list->count++] = font; - } - tll_free(conf_fonts); - } - if (conf_width > 0 && conf_height > 0) { - conf.size.type = conf_size_type; - conf.size.width = conf_width; - conf.size.height = conf_height; - } if (conf_server_socket_path != NULL) { free(conf.server_socket_path); conf.server_socket_path = xstrdup(conf_server_socket_path); } - if (maximized) - conf.startup_mode = STARTUP_MAXIMIZED; - else if (fullscreen) - conf.startup_mode = STARTUP_FULLSCREEN; conf.presentation_timings = presentation_timings; conf.hold_at_exit = hold; From a3d54614c7bc0a88b00bb98ad7bb2f730b0b7e72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 31 Jul 2023 16:29:08 +0200 Subject: [PATCH 3/7] render: OSD: center text vertically Rewrite render_osd(), and instead of passing in an y-offset, let render_osd() itself center the text inside the OSD buffer. This is done using the same baseline calculation term_font_baseline() does, except we use the buffer height instead of the line height. Note that most OSDs are sized based on the line height... Closes #1430 --- CHANGELOG.md | 4 ++++ render.c | 25 ++++++++++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad90b71b..a7e8fb97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,10 @@ ### Fixed * `-f,--font` command line option not affecting `csd.font` (if unset). +* Vertical alignment in URL jump labels, and the scrollback position + indicator. The fix in 1.15.2 was incorrect, and was reverted in the + last minute. But we forgot to remove the entry from the changelog + ([#1430][1430]). ### Security diff --git a/render.c b/render.c index 5c6eeb92..05d29c25 100644 --- a/render.c +++ b/render.c @@ -1890,7 +1890,7 @@ static void render_osd(struct terminal *term, const struct wayl_sub_surface *sub_surf, struct fcft_font *font, struct buffer *buf, const char32_t *text, uint32_t _fg, uint32_t _bg, - unsigned x, unsigned y) + unsigned x) { pixman_region32_t clip; pixman_region32_init_rect(&clip, 0, 0, buf->width, buf->height); @@ -1938,18 +1938,27 @@ render_osd(struct terminal *term, const struct wayl_sub_surface *sub_surf, pixman_image_t *src = pixman_image_create_solid_fill(&fg); + /* Calculate baseline */ + unsigned y; + { + const int line_height = buf->height; + const int font_height = max(font->height, font->ascent + font->descent); + const int glyph_top_y = round((line_height - font_height) / 2.); + y = term->font_y_ofs + glyph_top_y + font->ascent; + } + for (size_t i = 0; i < glyph_count; i++) { const struct fcft_glyph *glyph = glyphs[i]; if (pixman_image_get_format(glyph->pix) == PIXMAN_a8r8g8b8) { pixman_image_composite32( PIXMAN_OP_OVER, glyph->pix, NULL, buf->pix[0], 0, 0, 0, 0, - x + x_ofs + glyph->x, y + term->font_y_ofs + font->ascent /*term_font_baseline(term)*/ - glyph->y, + x + x_ofs + glyph->x, y - glyph->y, glyph->width, glyph->height); } else { pixman_image_composite32( PIXMAN_OP_OVER, src, glyph->pix, buf->pix[0], 0, 0, 0, 0, - x + x_ofs + glyph->x, y + term->font_y_ofs + font->ascent /* term_font_baseline(term)*/ - glyph->y, + x + x_ofs + glyph->x, y - glyph->y, glyph->width, glyph->height); } @@ -2011,9 +2020,7 @@ render_csd_title(struct terminal *term, const struct csd_data *info, const int margin = M != NULL ? M->advance.x : win->csd.font->max_advance.x; - render_osd(term, surf, win->csd.font, buf, title_text, fg, bg, margin, - (buf->height - win->csd.font->height) / 2); - + render_osd(term, surf, win->csd.font, buf, title_text, fg, bg, margin); csd_commit(term, &surf->surface, buf); free(_title_text); } @@ -2580,7 +2587,7 @@ render_scrollback_position(struct terminal *term) &win->scrollback_indicator, term->fonts[0], buf, text, fg, 0xffu << 24 | bg, - width - margin - c32len(text) * term->cell_width, margin); + width - margin - c32len(text) * term->cell_width); } static void @@ -2618,7 +2625,7 @@ render_render_timer(struct terminal *term, struct timespec render_time) &win->render_timer, term->fonts[0], buf, text, term->colors.table[0], 0xffu << 24 | term->colors.table[8 + 1], - margin, margin); + margin); } static void frame_callback( @@ -3664,7 +3671,7 @@ render_urls(struct terminal *term) render_osd( term, sub_surf, term->fonts[0], bufs[i], label, - fg, 0xffu << 24 | bg, x_margin, y_margin); + fg, 0xffu << 24 | bg, x_margin); free(info[i].text); } From d00a2a222ef92a971e9dbc7dab4d2654399f7ac2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 5 Aug 2023 07:19:51 +0200 Subject: [PATCH 4/7] vt: fix ASAN UB warning ../vt.c:648:13: runtime error: signed integer overflow: 3924432811 * 2654435761 cannot be represented in type 'long' SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../vt.c:648:13 in Closes #1456 --- vt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vt.c b/vt.c index 772bd41f..f6e8b79b 100644 --- a/vt.c +++ b/vt.c @@ -645,7 +645,7 @@ chain_key(uint32_t old_key, uint32_t new_wc) new_key ^= new_wc; /* Multiply with magic hash constant */ - new_key *= 2654435761; + new_key *= 2654435761ul; /* And mask, to ensure the new value is within range */ new_key &= CELL_COMB_CHARS_HI - CELL_COMB_CHARS_LO; From 5334e3d1aae017a92cdd858d0e426ecb813afb55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 5 Aug 2023 07:23:11 +0200 Subject: [PATCH 5/7] =?UTF-8?q?main:=20=E2=80=9Ctitle%s=E2=80=9D=20->=20?= =?UTF-8?q?=E2=80=9Ctitle=3D%s=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix regression of --title,-T option. This broken when command line parsing was switched to using overrides, in 0b4f1b4af20cea0afae39a2c1c4e42c22962dcde. Closes #1457 --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 38e3c148..dffd2b2b 100644 --- a/main.c +++ b/main.c @@ -263,7 +263,7 @@ main(int argc, char *const *argv) break; case 'T': - tll_push_back(overrides, xasprintf("title%s", optarg)); + tll_push_back(overrides, xasprintf("title=%s", optarg)); break; case 'a': From 341a5eeefdd6cfcd2baaea6af5a44dd1135c559b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 7 Aug 2023 16:39:42 +0200 Subject: [PATCH 6/7] changelog: prepare for 1.15.3 --- CHANGELOG.md | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7e8fb97..128b7b6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -* [Unreleased](#unreleased) +* [1.15.3](#1-15-3) * [1.15.2](#1-15-2) * [1.15.1](#1-15-1) * [1.15.0](#1-15-0) @@ -45,11 +45,8 @@ * [1.2.0](#1-2-0) -## Unreleased -### Added -### Changed -### Deprecated -### Removed +## 1.15.3 + ### Fixed * `-f,--font` command line option not affecting `csd.font` (if unset). @@ -59,10 +56,6 @@ ([#1430][1430]). -### Security -### Contributors - - ## 1.15.2 ### Added From f3146999454b0d28f19f61491bb33f203fe7c53e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 7 Aug 2023 16:39:54 +0200 Subject: [PATCH 7/7] meson: bump version to 1.15.3 --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 2792533a..a33202b5 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ project('foot', 'c', - version: '1.15.2', + version: '1.15.3', license: 'MIT', meson_version: '>=0.59.0', default_options: [