From 8b979e9dba808dd9942e8cbe0a57195f674a227d Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Mon, 22 Nov 2021 22:23:28 +0100 Subject: changelog: add #801 to “OSC-8 data not being cleared...” MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index c1f17114..63a1c1ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,7 +51,8 @@ resulting in invalid error messages (https://codeberg.org/dnkl/foot/issues/809). * OSC-8 data not being cleared when cell is overwritten - (https://codeberg.org/dnkl/foot/issues/804). + (https://codeberg.org/dnkl/foot/issues/804, + https://codeberg.org/dnkl/foot/issues/801). ### Contributors -- cgit v1.3 From caec64cbdae2fc59da2a40cf3bf142a3df9b15e5 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Mon, 22 Nov 2021 22:24:13 +0100 Subject: changelog: add new ‘unreleased’ section MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index 63a1c1ce..cffc2c25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Changelog +* [Unreleased](#Unreleased) * [1.10.1](#1-10-1) * [1.10.0](#1-10-0) * [1.9.2](#1-9-2) @@ -33,6 +34,16 @@ * [1.2.0](#1-2-0) +## Unreleased +### Added +### Changed +### Deprecated +### Removed +### Fixed +### Security +### Contributors + + ## 1.10.1 ### Added -- cgit v1.3 From c1c0f11821e36e96add5060916d83533308b4126 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Mon, 22 Nov 2021 23:02:25 +0100 Subject: config: add tweak.grapheme-width-method=max MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ‘max’ is a new value for ‘tweak.grapheme-width-method’. When enabled, the width of a grapheme cluster is that of the cluster’s widest codepoint. --- CHANGELOG.md | 5 +++++ config.c | 2 +- config.h | 6 +++++- doc/foot.ini.5.scd | 4 +++- vt.c | 4 ++++ 5 files changed, 18 insertions(+), 3 deletions(-) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index cffc2c25..a2255c08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,7 +35,12 @@ ## Unreleased + ### Added + +* New value, `max`, for `[tweak].grapheme-width-method`. + + ### Changed ### Deprecated ### Removed diff --git a/config.c b/config.c index 68061cc3..0616e87a 100644 --- a/config.c +++ b/config.c @@ -2248,7 +2248,7 @@ parse_section_tweak(struct context *ctx) return value_to_enum( ctx, - (const char *[]){"wcswidth", "double-width", NULL}, + (const char *[]){"wcswidth", "double-width", "max", NULL}, (int *)&conf->tweak.grapheme_width_method); } diff --git a/config.h b/config.h index 652f8422..afe9cf74 100644 --- a/config.h +++ b/config.h @@ -256,7 +256,11 @@ struct config { enum fcft_scaling_filter fcft_filter; bool overflowing_glyphs; bool grapheme_shaping; - enum {GRAPHEME_WIDTH_WCSWIDTH, GRAPHEME_WIDTH_DOUBLE} grapheme_width_method; + enum { + GRAPHEME_WIDTH_WCSWIDTH, + GRAPHEME_WIDTH_DOUBLE, + GRAPHEME_WIDTH_MAX, + } grapheme_width_method; bool render_timer_osd; bool render_timer_log; bool damage_whole_window; diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd index 9f5c429b..1b6c4d8c 100644 --- a/doc/foot.ini.5.scd +++ b/doc/foot.ini.5.scd @@ -1093,7 +1093,7 @@ any of these options. *grapheme-width-method* Selects which method to use when calculating the width (i.e. number of columns) of a grapheme cluster. One of - *double-width* and *wcswidth*. + *wcswidth*, *double-width* and *max*. *wcswidth* simply adds together the individual width of all codepoints making up the cluster. @@ -1104,6 +1104,8 @@ any of these options. internally to calculate the width. This results in cursor de-synchronization issues. + *max* uses the width of the largest codepoint in the cluster. + Default: _wcswidth_ *font-monospace-warn* diff --git a/vt.c b/vt.c index 687be912..736a2cfd 100644 --- a/vt.c +++ b/vt.c @@ -792,6 +792,10 @@ action_utf8_print(struct terminal *term, wchar_t wc) composed != NULL ? composed->width : base_width; switch (term->conf->tweak.grapheme_width_method) { + case GRAPHEME_WIDTH_MAX: + new_cc->width = max(grapheme_width, width); + break; + case GRAPHEME_WIDTH_DOUBLE: if (unlikely(wc == 0xfe0f)) width = 2; -- cgit v1.3 From 325ad6dd4e950546514448a838ce03027103d0bd Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Thu, 25 Nov 2021 15:21:53 +0100 Subject: input: finalize mouse selection on a pointer-leave event on the GRID surface If a mouse selection was ongoing, and the user switched workspace (probably using the keyboard...), and then back, the selection was still treated as ongoing, while all other mouse state has been reset. This meant the user had to tap at least once to stop the selection. --- CHANGELOG.md | 5 +++++ input.c | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index a2255c08..b506aafa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,11 @@ ### Deprecated ### Removed ### Fixed + +* An ongoing mouse selection is now finalized on a pointer leave event + (for example by switching workspace while doing a mouse selection). + + ### Security ### Contributors diff --git a/input.c b/input.c index 0aef43cc..02035909 100644 --- a/input.c +++ b/input.c @@ -1531,8 +1531,11 @@ wl_pointer_leave(void *data, struct wl_pointer *wl_pointer, render_refresh_csd(old_moused); break; - case TERM_SURF_NONE: case TERM_SURF_GRID: + selection_finalize(seat, old_moused, seat->pointer.serial); + break; + + case TERM_SURF_NONE: case TERM_SURF_SEARCH: case TERM_SURF_SCROLLBACK_INDICATOR: case TERM_SURF_RENDER_TIMER: -- cgit v1.3 From 8c50a7afd401686f645fb26676fbcaedb8d4ab62 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Thu, 25 Nov 2021 19:22:52 +0100 Subject: osc8: update URI ranges as we print data, *not* when the URI is closed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit At first, an OSC-8 URI range was added when we received the closing OSC-8 escape (i.e. with an empty URI). But, this meant that cursor movements while the OSC-8 escape was in effect wasn’t handled correctly, since we’d add a range that spanned the cursor movements. Attempts were made to handle this in the cursor movement functions, by closing and re-opening the URI. However, there are too many corner cases to make this a viable approach. Scrolling is one such example, line-wrapping another. This patch takes a different approach; emit, or update the URI range when we print to the grid. This models the intended behavior much more closely, where an active OSC-8 URI act like any other SGR attribute - it is applied to all cells printed to, but otherwise have no effect. To avoid killing performance, this is only done in the “generic” printer. This means OSC-8 open/close calls must now “switch” the ASCII printer. Note that the “fast” printer still needs to *erase* pre-existing OSC-8 URIs. Closes #816 --- CHANGELOG.md | 3 ++ grid.c | 152 +++++++++++++++++++++++++++++++++++++++++++++-------------- grid.h | 2 + terminal.c | 101 +++++++++------------------------------ terminal.h | 1 - 5 files changed, 143 insertions(+), 116 deletions(-) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index b506aafa..c185dd72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,9 @@ * An ongoing mouse selection is now finalized on a pointer leave event (for example by switching workspace while doing a mouse selection). +* OSC-8 URIs in the last column +* OSC-8 URIs sometimes being applied to too many, and seemingly + unrelated cells (https://codeberg.org/dnkl/foot/issues/816). ### Security diff --git a/grid.c b/grid.c index 459fa369..2dcbaa55 100644 --- a/grid.c +++ b/grid.c @@ -844,6 +844,117 @@ ensure_row_has_extra_data(struct row *row) row->extra = xcalloc(1, sizeof(*row->extra)); } +static void +verify_no_overlapping_uris(const struct row *row) +{ +#if defined(_DEBUG) + const struct row_data *extra = row->extra; + tll_foreach(extra->uri_ranges, it1) { + const struct row_uri_range *r1 = &it1->item; + + tll_foreach(extra->uri_ranges, it2) { + const struct row_uri_range *r2 = &it2->item; + + if (r1 == r2) + continue; + + if ((r1->start <= r2->start && r1->end >= r2->start) || + (r1->start <= r2->end && r1->end >= r2->end)) + { + BUG("OSC-8 URI overlap: %s: %d-%d: %s: %d-%d", + r1->uri, r1->start, r1->end, + r2->uri, r2->start, r2->end); + } + } + } +#endif +} + +void +grid_row_uri_range_put(struct row *row, int col, const char *uri, uint64_t id) +{ + ensure_row_has_extra_data(row); + + struct row_data *extra = row->extra; + tll_rforeach(extra->uri_ranges, it) { + struct row_uri_range *r = &it->item; + + if (r->end + 1 < col) { + /* Ranges are sorted, and this means all the remaining + * URIs *end* before ‘col’ */ + break; + } + + if (r->start <= col && r->end >= col) { + /* + * ‘col’ is *inside* an existing range + */ + + if (r->id == id) { + /* ‘col’ is already inside a matching URI range */ + goto out; + } + + /* Splice old range */ + if (r->start == r->end) + tll_remove(extra->uri_ranges, it); + else if (r->start == col) + r->start++; + else if (r->end == col) + r->end--; + else { + xassert(r->start < col); + xassert(r->end > col); + + struct row_uri_range new_tail = { + .start = col + 1, + .end = r->end, + .id = r->id, + .uri = xstrdup(r->uri), + }; + + r->end = col - 1; + + xassert(r->start <= r->end); + xassert(new_tail.start <= new_tail.end); + + tll_insert_after(extra->uri_ranges, it, new_tail); + } + + break; /* Break out add and a new range for ‘col’ */ + } + + else if (r->id != id) + continue; + +#if 0 /* Trust the URI ID, for now... */ + if (strcmp(r->uri, uri) != 0) + continue; +#endif + + else if (likely(r->end + 1 == col)) { + r->end = col; + goto out; + } + + else if (col + 1 == r->start) { + r->start = col; + goto out; + } + } + + struct row_uri_range new_range = { + .start = col, + .end = col, + .id = id, + .uri = xstrdup(uri), + }; + grid_row_uri_range_add(row, new_range); + +out: + verify_no_overlapping_uris(row); +} + void grid_row_uri_range_add(struct row *row, struct row_uri_range range) { @@ -858,20 +969,7 @@ grid_row_uri_range_add(struct row *row, struct row_uri_range range) tll_push_front(row->extra->uri_ranges, range); out: - ; -#if defined(_DEBUG) - tll_foreach(row->extra->uri_ranges, it1) { - tll_foreach(row->extra->uri_ranges, it2) { - if (&it1->item == &it2->item) - continue; - - xassert(it1->item.start != it2->item.start); - xassert(it1->item.start != it2->item.end); - xassert(it1->item.end != it2->item.start); - xassert(it1->item.end != it2->item.end); - } - } -#endif + verify_no_overlapping_uris(row); } void @@ -929,36 +1027,22 @@ UNITTEST struct row_data row_data = {.uri_ranges = tll_init()}; struct row row = {.extra = &row_data}; -#define row_has_no_overlapping_uris(row) \ - do { \ - tll_foreach((row)->extra->uri_ranges, it1) { \ - tll_foreach((row)->extra->uri_ranges, it2) { \ - if (&it1->item == &it2->item) \ - continue; \ - xassert(it1->item.start != it2->item.start); \ - xassert(it1->item.start != it2->item.end); \ - xassert(it1->item.end != it2->item.start); \ - xassert(it1->item.end != it2->item.end); \ - } \ - } \ - } while (0) - grid_row_uri_range_add(&row, (struct row_uri_range){1, 10}); xassert(tll_length(row_data.uri_ranges) == 1); xassert(tll_front(row_data.uri_ranges).start == 1); xassert(tll_front(row_data.uri_ranges).end == 10); - row_has_no_overlapping_uris(&row); + verify_no_overlapping_uris(&row); grid_row_uri_range_add(&row, (struct row_uri_range){11, 20}); xassert(tll_length(row_data.uri_ranges) == 2); xassert(tll_back(row_data.uri_ranges).start == 11); xassert(tll_back(row_data.uri_ranges).end == 20); - row_has_no_overlapping_uris(&row); + verify_no_overlapping_uris(&row); /* Erase both URis */ grid_row_uri_range_erase(&row, 1, 20); xassert(tll_length(row_data.uri_ranges) == 0); - row_has_no_overlapping_uris(&row); + verify_no_overlapping_uris(&row); /* Two URIs, then erase second half of the first, first half of the second */ @@ -970,7 +1054,7 @@ UNITTEST xassert(tll_front(row_data.uri_ranges).end == 4); xassert(tll_back(row_data.uri_ranges).start == 16); xassert(tll_back(row_data.uri_ranges).end == 20); - row_has_no_overlapping_uris(&row); + verify_no_overlapping_uris(&row); tll_pop_back(row_data.uri_ranges); tll_pop_back(row_data.uri_ranges); @@ -984,9 +1068,7 @@ UNITTEST xassert(tll_front(row_data.uri_ranges).end == 4); xassert(tll_back(row_data.uri_ranges).start == 7); xassert(tll_back(row_data.uri_ranges).end == 10); - row_has_no_overlapping_uris(&row); - -#undef row_has_no_overlapping_uris + verify_no_overlapping_uris(&row); tll_free(row_data.uri_ranges); } diff --git a/grid.h b/grid.h index e2cd3a63..8ede4773 100644 --- a/grid.h +++ b/grid.h @@ -74,6 +74,8 @@ grid_row_in_view(struct grid *grid, int row_no) return row; } +void grid_row_uri_range_put( + struct row *row, int col, const char *uri, uint64_t id); void grid_row_uri_range_add(struct row *row, struct row_uri_range range); void grid_row_uri_range_erase(struct row *row, int start, int end); diff --git a/terminal.c b/terminal.c index 4cc9ed09..03ff1898 100644 --- a/terminal.c +++ b/terminal.c @@ -1134,9 +1134,6 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper, .blink = {.fd = -1}, .vt = { .state = 0, /* STATE_GROUND */ - .osc8 = { - .begin = {-1, -1}, - }, }, .colors = { .fg = conf->colors.fg, @@ -1826,7 +1823,6 @@ term_reset(struct terminal *term, bool hard) term->vt = (struct vt){ .state = 0, /* STATE_GROUND */ - .osc8 = {.begin = (struct coord){-1, -1}}, }; if (term->grid == &term->alt) { @@ -3151,7 +3147,8 @@ print_insert(struct terminal *term, int width) static void print_spacer(struct terminal *term, int col, int remaining) { - struct row *row = term->grid->cur_row; + struct grid *grid = term->grid; + struct row *row = grid->cur_row; struct cell *cell = &row->cells[col]; cell->wc = CELL_SPACER + remaining; @@ -3210,7 +3207,19 @@ term_print(struct terminal *term, wchar_t wc, int width) cell->wc = term->vt.last_printed = wc; cell->attrs = term->vt.attrs; - const int uri_start = col; + if (term->vt.osc8.uri != NULL) { + grid_row_uri_range_put( + row, col, term->vt.osc8.uri, term->vt.osc8.id); + + switch (term->conf->url.osc8_underline) { + case OSC8_UNDERLINE_ALWAYS: + cell->attrs.url = true; + break; + + case OSC8_UNDERLINE_URL_MODE: + break; + } + } /* Advance cursor the 'additional' columns while dirty:ing the cells */ for (int i = 1; i < width && col < term->cols - 1; i++) { @@ -3226,9 +3235,6 @@ term_print(struct terminal *term, wchar_t wc, int width) xassert(!grid->cursor.lcf); grid->cursor.point.col = col; - - if (unlikely(row->extra != NULL)) - grid_row_uri_range_erase(row, uri_start, uri_start + width - 1); } static void @@ -3260,7 +3266,6 @@ ascii_printer_fast(struct terminal *term, wchar_t wc) cell->wc = term->vt.last_printed = wc; cell->attrs = term->vt.attrs; - /* Advance cursor */ if (unlikely(++col >= term->cols)) { grid->cursor.lcf = true; @@ -3287,6 +3292,7 @@ term_update_ascii_printer(struct terminal *term) { void (*new_printer)(struct terminal *term, wchar_t wc) = unlikely(tll_length(term->grid->sixel_images) > 0 || + term->vt.osc8.uri != NULL || term->charsets.set[term->charsets.selected] == CHARSET_GRAPHIC || term->insert_mode) ? &ascii_printer_generic @@ -3294,7 +3300,7 @@ term_update_ascii_printer(struct terminal *term) #if defined(_DEBUG) && LOG_ENABLE_DBG if (term->ascii_printer != new_printer) { - LOG_DBG("switching ASCII printer %s -> %s", + LOG_DBG("§switching ASCII printer %s -> %s", term->ascii_printer == &ascii_printer_fast ? "fast" : "generic", new_printer == &ascii_printer_fast ? "fast" : "generic"); } @@ -3491,84 +3497,19 @@ term_ime_set_cursor_rect(struct terminal *term, int x, int y, int width, void term_osc8_open(struct terminal *term, uint64_t id, const char *uri) { - if (unlikely(term->vt.osc8.begin.row >= 0)) { - /* It’s valid to switch from one URI to another without - * closing the first one */ - term_osc8_close(term); - } - + term_osc8_close(term); xassert(term->vt.osc8.uri == NULL); - term->vt.osc8.begin = (struct coord){ - .col = term->grid->cursor.point.col, - .row = grid_row_absolute(term->grid, term->grid->cursor.point.row), - }; term->vt.osc8.id = id; term->vt.osc8.uri = xstrdup(uri); + term_update_ascii_printer(term); } void term_osc8_close(struct terminal *term) { - if (term->vt.osc8.begin.row < 0) - return; - - if (term->vt.osc8.uri[0] == '\0') - goto done; - - struct coord start = term->vt.osc8.begin; - struct coord end = (struct coord){ - .col = term->grid->cursor.point.col, - .row = grid_row_absolute(term->grid, term->grid->cursor.point.row), - }; - - if (start.row == end.row && start.col == end.col) { - /* Zero-length URL, e.g: \E]8;;http://foo\E\\\E]8;;\E\\ */ - goto done; - } - - /* end is *inclusive */ - if (--end.col < 0) { - end.row--; - end.col = term->cols - 1; - } - - int r = start.row; - int start_col = start.col; - while (true) { - int end_col = r == end.row ? end.col : term->cols - 1; - - struct row *row = term->grid->rows[r]; - - switch (term->conf->url.osc8_underline) { - case OSC8_UNDERLINE_ALWAYS: - for (int c = start_col; c <= end_col; c++) - row->cells[c].attrs.url = true; - break; - - case OSC8_UNDERLINE_URL_MODE: - break; - } - - struct row_uri_range range = { - .start = start_col, - .end = end_col, - .id = term->vt.osc8.id, - .uri = xstrdup(term->vt.osc8.uri), - }; - grid_row_uri_range_add(row, range); - start_col = 0; - - if (r == end.row) - break; - - r++; - r &= term->grid->num_rows - 1; - } - -done: free(term->vt.osc8.uri); - term->vt.osc8.id = 0; term->vt.osc8.uri = NULL; - term->vt.osc8.begin = (struct coord){-1, -1}; + term->vt.osc8.id = 0; + term_update_ascii_printer(term); } diff --git a/terminal.h b/terminal.h index b0526803..1f3913ae 100644 --- a/terminal.h +++ b/terminal.h @@ -185,7 +185,6 @@ struct vt { struct { uint64_t id; char *uri; - struct coord begin; } osc8; struct { -- cgit v1.3 From be203aeae1280ad7cac3ec9e287d1dd97528f390 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Fri, 26 Nov 2021 20:27:55 +0100 Subject: grid: bug: OSC-8 URIs were incorrectly skipped while resizing the alt screen --- CHANGELOG.md | 2 ++ grid.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index c185dd72..9b928d68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,8 @@ * OSC-8 URIs in the last column * OSC-8 URIs sometimes being applied to too many, and seemingly unrelated cells (https://codeberg.org/dnkl/foot/issues/816). +* OSC-8 URIs incorrectly being dropped when resizing the terminal + window with the alternate screen active. ### Security diff --git a/grid.c b/grid.c index a68f1ee4..92675145 100644 --- a/grid.c +++ b/grid.c @@ -337,7 +337,7 @@ grid_resize_without_reflow( const struct row_uri_range *old_range = &old_row->extra->uri_ranges.v[i]; - if (old_range->start >= new_rows) { + if (old_range->start >= new_cols) { /* The whole range is truncated */ continue; } -- cgit v1.3 From 1f19dd6694b1268b40620ca5743ac458948ad0c5 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sat, 27 Nov 2021 18:47:20 +0100 Subject: changelog: kitty keyboard protocol - disambiguate escape codes --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b928d68..4c3ad3e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,9 @@ ### Added * New value, `max`, for `[tweak].grapheme-width-method`. +* Initial support for the [Kitty keyboard protocol](https://sw.kovidgoyal.net/kitty/keyboard-protocol/). + Modes supported: + - [Disambiguate escape codes](https://sw.kovidgoyal.net/kitty/keyboard-protocol/#disambiguate) ### Changed -- cgit v1.3 From 3afe317e4637d511bb4f795d20d8e0467c0e42bf Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Mon, 29 Nov 2021 19:23:58 +0100 Subject: render: fix csd border rendering glitch when width > 5px CSD borders are always *at least* 5px. If url.border-width=0, those 5px are all fully transparent (and act as interactive resize handles). As csd.border-width increases, the number of transparent pixels decrease. Once csd.border-width >= 5, the border is fully opaque. When csd.border-width > 5, then width of the border is (obviously) more than 5px. But, when rendering the opaque part of the border, we still used 5px for the invisible part, which caused some pixman rectangles to have negative x/y coordinates. This resulted in rendering glitches due to overflows in pixman when rendering the borders. The fix is to ensure the total border size is always at least, but not *always* 5px. That is, set it to max(5, csd.border-width). This patch also fixes an issue where the CSD borders were not dimmed (like the titlebar) when the window looses input focus. Closes #823 --- CHANGELOG.md | 3 +++ render.c | 26 ++++++++++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c3ad3e4..19f5c7ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,9 @@ unrelated cells (https://codeberg.org/dnkl/foot/issues/816). * OSC-8 URIs incorrectly being dropped when resizing the terminal window with the alternate screen active. +* CSD border not being dimmed when window is not focused. +* Visual corruption with large CSD borders + (https://codeberg.org/dnkl/foot/issues/823). ### Security diff --git a/render.c b/render.c index 2710c0a2..cd38d712 100644 --- a/render.c +++ b/render.c @@ -1763,14 +1763,16 @@ render_csd_border(struct terminal *term, enum csd_surface surf_idx, * The “visible” border. */ - int bwidth = term->conf->csd.border_width; /* Full border size */ - int vwidth = term->conf->csd.border_width_visible; /* Visibls size */ + int bwidth = max(term->conf->csd.border_width, + term->conf->csd.border_width_visible); /* Full border size */ + int vwidth = term->conf->csd.border_width_visible; /* Visibls size */ if (vwidth > 0) { const struct config *conf = term->conf; int x = 0, y = 0, w = 0, h = 0; + switch (surf_idx) { case CSD_SURF_TOP: case CSD_SURF_BOTTOM: @@ -1788,17 +1790,33 @@ render_csd_border(struct terminal *term, enum csd_surface surf_idx, h = info->height; break; - default: - break; + case CSD_SURF_TITLE: + case CSD_SURF_MINIMIZE: + case CSD_SURF_MAXIMIZE: + case CSD_SURF_CLOSE: + case CSD_SURF_COUNT: + BUG("unexpected CSD surface type"); } + xassert(x >= 0); + xassert(y >= 0); + xassert(w >= 0); + xassert(h >= 0); + + xassert(x + w <= info->width); + xassert(y + h <= info->height); + uint32_t _color = conf->csd.color.border_set ? conf->csd.color.border : conf->csd.color.title_set ? conf->csd.color.title : 0xffu << 24 | term->conf->colors.fg; + if (!term->visual_focus) + _color = color_dim(term, _color); + uint16_t alpha = _color >> 24 | (_color >> 24 << 8); pixman_color_t color = color_hex_to_pixman_with_alpha(_color, alpha); + pixman_image_fill_rectangles( PIXMAN_OP_SRC, buf->pix[0], &color, 1, &(pixman_rectangle16_t){x, y, w, h}); -- cgit v1.3 From fd82fb81fa8bef795eb4d9ac2fdccdf787c35759 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Tue, 30 Nov 2021 22:12:17 +0100 Subject: changelog: window-menu --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index 19f5c7ad..97f20302 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,8 @@ * Initial support for the [Kitty keyboard protocol](https://sw.kovidgoyal.net/kitty/keyboard-protocol/). Modes supported: - [Disambiguate escape codes](https://sw.kovidgoyal.net/kitty/keyboard-protocol/#disambiguate) +* “Window menu” (compositor provided) on right clicks on the CSD title + bar. ### Changed -- cgit v1.3 From 1619e83c13875f71f79e5ca0e4504dd59dd81d79 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Wed, 1 Dec 2021 20:04:01 +0100 Subject: input: always update the xcursor shape in pointer enter/motion events MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now that term_xcursor_update_for_seat() takes the current surface into account (i.e. doesn’t assume the cursor is over the main grid), there’s no longer any need to call render_xcursor_set() directly. Thus, we can simply call term_xcursor_update_for_seat() on **all** pointer enter and motion events. As long as we take care to update the internal state to reflect the, possibly new, current surface before doing so. Also make sure to **always** reset the seat’s “current” xcursor pointer on pointer leave events. This is done without actually sending anything to the compositor, but is necessary to ensure that we *do* send a request to update the xcursor on the next pointer enter event. --- CHANGELOG.md | 1 + input.c | 25 ++++++++++--------------- 2 files changed, 11 insertions(+), 15 deletions(-) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index 97f20302..1a725822 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,7 @@ * CSD border not being dimmed when window is not focused. * Visual corruption with large CSD borders (https://codeberg.org/dnkl/foot/issues/823). +* Mouse cursor shape sometimes not being updated correctly. ### Security diff --git a/input.c b/input.c index ef81b637..055c0fc8 100644 --- a/input.c +++ b/input.c @@ -1773,12 +1773,13 @@ wl_pointer_enter(void *data, struct wl_pointer *wl_pointer, xassert(tll_length(seat->mouse.buttons) == 0); - /* Scale may have changed */ - wayl_reload_xcursor_theme(seat, term->scale); - seat->mouse_focus = term; + term->active_surface = term_surface_kind(term, surface); + + wayl_reload_xcursor_theme(seat, term->scale); /* Scale may have changed */ + term_xcursor_update_for_seat(term, seat); - switch ((term->active_surface = term_surface_kind(term, surface))) { + switch (term->active_surface) { case TERM_SURF_GRID: { /* * Translate x,y pixel coordinate to a cell coordinate, or -1 @@ -1796,7 +1797,6 @@ wl_pointer_enter(void *data, struct wl_pointer *wl_pointer, else seat->mouse.row = (y - term->margins.top) / term->cell_height; - term_xcursor_update_for_seat(term, seat); break; } @@ -1805,20 +1805,15 @@ wl_pointer_enter(void *data, struct wl_pointer *wl_pointer, case TERM_SURF_RENDER_TIMER: case TERM_SURF_JUMP_LABEL: case TERM_SURF_TITLE: - render_xcursor_set(seat, term, XCURSOR_LEFT_PTR); - break; - case TERM_SURF_BORDER_LEFT: case TERM_SURF_BORDER_RIGHT: case TERM_SURF_BORDER_TOP: case TERM_SURF_BORDER_BOTTOM: - render_xcursor_set(seat, term, xcursor_for_csd_border(term, x, y)); break; case TERM_SURF_BUTTON_MINIMIZE: case TERM_SURF_BUTTON_MAXIMIZE: case TERM_SURF_BUTTON_CLOSE: - render_xcursor_set(seat, term, XCURSOR_LEFT_PTR); render_refresh_csd(term); break; @@ -1847,9 +1842,11 @@ wl_pointer_leave(void *data, struct wl_pointer *wl_pointer, wl_callback_destroy(seat->pointer.xcursor_callback); seat->pointer.xcursor_callback = NULL; seat->pointer.xcursor_pending = false; - seat->pointer.xcursor = NULL; } + /* Reset last-set-xcursor, to ensure we update it on a pointer-enter event */ + seat->pointer.xcursor = NULL; + /* Reset mouse state */ seat->mouse.x = seat->mouse.y = 0; seat->mouse.col = seat->mouse.row = 0; @@ -1876,7 +1873,6 @@ wl_pointer_leave(void *data, struct wl_pointer *wl_pointer, enum term_surface active_surface = old_moused->active_surface; old_moused->active_surface = TERM_SURF_NONE; - term_xcursor_update_for_seat(old_moused, seat); switch (active_surface) { case TERM_SURF_BUTTON_MINIMIZE: @@ -1929,6 +1925,8 @@ wl_pointer_motion(void *data, struct wl_pointer *wl_pointer, seat->mouse.x = x; seat->mouse.y = y; + term_xcursor_update_for_seat(term, seat); + enum term_surface surf_kind = term->active_surface; int button = 0; bool send_to_client = false; @@ -1966,7 +1964,6 @@ wl_pointer_motion(void *data, struct wl_pointer *wl_pointer, case TERM_SURF_BORDER_RIGHT: case TERM_SURF_BORDER_TOP: case TERM_SURF_BORDER_BOTTOM: - render_xcursor_set(seat, term, xcursor_for_csd_border(term, x, y)); break; case TERM_SURF_GRID: { @@ -2017,8 +2014,6 @@ wl_pointer_motion(void *data, struct wl_pointer *wl_pointer, xassert(seat->mouse.col == -1 || (seat->mouse.col >= 0 && seat->mouse.col < term->cols)); xassert(seat->mouse.row == -1 || (seat->mouse.row >= 0 && seat->mouse.row < term->rows)); - term_xcursor_update_for_seat(term, seat); - /* Cursor has moved to a different cell since last time */ bool cursor_is_on_new_cell = old_col != seat->mouse.col || old_row != seat->mouse.row; -- cgit v1.3 From a3016a6cc909d9c383359a4eaafd30bcd52bd272 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Tue, 30 Nov 2021 19:36:28 +0100 Subject: osc-4: don’t update the color of cells with RGB fg/bg colors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit OSC 4/104 changes the 256-color palette. We also run a pass over the visible cells, and update their colors. This was previously done by comparing the actual color of the cell, with the “old” color in the palette. If they matched, the cell was updated. This meant that cells with an RGB color (i.e. not a palette based color) was also updated, _if_ its color matched the palette color. Now that each cell tracks its color *source*, we can ignore all non-palette based cells. Note that this still isn’t perfect: if the palette contains multiple entries with the same color, we’ll end up updating the “wrong” cells. Closes #678 --- CHANGELOG.md | 2 ++ osc.c | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a725822..026e745c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -62,6 +62,8 @@ * Visual corruption with large CSD borders (https://codeberg.org/dnkl/foot/issues/823). * Mouse cursor shape sometimes not being updated correctly. +* Color palette changes (via OSC 4/104) no longer affect RGB colors + (https://codeberg.org/dnkl/foot/issues/678). ### Security diff --git a/osc.c b/osc.c index 910c1e02..357139b6 100644 --- a/osc.c +++ b/osc.c @@ -528,8 +528,7 @@ osc_notify(struct terminal *term, char *string) } static void -update_color_in_grids(struct terminal *term, uint32_t old_color, - uint32_t new_color) +update_color_in_grids(struct terminal *term, int palette_idx, uint32_t new_color) { /* * Update color of already rendered cells. @@ -560,16 +559,19 @@ update_color_in_grids(struct terminal *term, uint32_t old_color, for (size_t c = 0; c < term->grid->num_cols; c++) { struct cell *cell = &row->cells[c]; - if (cell->attrs.fg_src != COLOR_DEFAULT && - cell->attrs.fg == old_color) + enum color_source fg_src = cell->attrs.fg_src; + enum color_source bg_src = cell->attrs.bg_src; + + if ((fg_src == COLOR_BASE16 || fg_src == COLOR_BASE256) && + cell->attrs.fg == term->colors.table[palette_idx]) { cell->attrs.fg = new_color; cell->attrs.clean = 0; row->dirty = true; } - if (cell->attrs.bg_src != COLOR_DEFAULT && - cell->attrs.bg == old_color) + if ((bg_src == COLOR_BASE16 || bg_src == COLOR_BASE256) && + cell->attrs.bg == term->colors.table[palette_idx]) { cell->attrs.bg = new_color; cell->attrs.clean = 0; @@ -666,7 +668,7 @@ osc_dispatch(struct terminal *term) LOG_DBG("change color definition for #%u from %06x to %06x", idx, term->colors.table[idx], color); - update_color_in_grids(term, term->colors.table[idx], color); + update_color_in_grids(term, idx, color); term->colors.table[idx] = color; } } @@ -810,8 +812,7 @@ osc_dispatch(struct terminal *term) if (strlen(string) == 0) { LOG_DBG("resetting all colors"); for (size_t i = 0; i < ALEN(term->colors.table); i++) { - update_color_in_grids( - term, term->colors.table[i], term->conf->colors.table[i]); + update_color_in_grids(term, i, term->conf->colors.table[i]); term->colors.table[i] = term->conf->colors.table[i]; } } @@ -834,8 +835,7 @@ osc_dispatch(struct terminal *term) } LOG_DBG("resetting color #%u", idx); - update_color_in_grids( - term, term->colors.table[idx], term->conf->colors.table[idx]); + update_color_in_grids(term, idx, term->conf->colors.table[idx]); term->colors.table[idx] = term->conf->colors.table[idx]; } } -- cgit v1.3